File action menu edits

This commit is contained in:
Maxim Stewart 2019-07-06 21:18:32 -05:00
parent 8d877eb71b
commit 634de3f6b0
4 changed files with 26 additions and 17 deletions

Binary file not shown.

View File

@ -58,9 +58,9 @@ class GridSignals:
self.copyCutArry = self.grid.returnSelectedFiles()
def paste(self, widget):
print(len(self.copyCutArry))
self.currentPath = self.grid.returnCurrentPath()
status = self.filehandler.paste(self.copyCutArry, self.currentPath, self.pasteType)
status = self.filehandler.paste(self.copyCutArry, self.currentPath, self.pasteType)
if status == 0:
self.grid.setIconViewDir(self.currentPath)
if self.pasteType == 2: # cut == 2

View File

@ -62,6 +62,7 @@ class FileHandler:
else: # Create Folder
os.mkdir(name)
except Exception as e:
print(e)
return 1
return 0
@ -69,22 +70,26 @@ class FileHandler:
def paste(self, files, toPath, pasteType):
try:
for file in files:
parts = file.split("/")
toBePath = toPath + parts[len(parts) - 1]
finalForm = file + self.dedupPathIter(toBePath)
parts = file.split("/")
toBePath = toPath + "/" + parts[len(parts) - 1] # Used to check for duplicates
finalForm = file + self.dedupPathIter(toBePath)
isDuplicate = finalForm != file
if isDuplicate:
os.rename(file, finalForm)
if pasteType == 1: # copy paste = 1
shutil.copy2(finalForm, toPath)
if isDuplicate:
os.rename(finalForm, file) # Rename back after copy completes
if pasteType == 2: # cut paste = 2
shutil.move(finalForm, toPath)
print(toBePath)
print(finalForm)
except Exception as e:
print(e)
return 1
# if finalForm != file:
# os.rename(file, finalForm)
#
# if pasteType == 1: # copy paste == 1
# shutil.move(finalForm, toPath)
# if pasteType == 2: # cut paste == 2
# shutil.copy2(finalForm, toPath)
return 0
def delete(self, toDeleteFiles):
try:
@ -124,7 +129,6 @@ class FileHandler:
print("The folder/file does not exist")
return 1
except Exception as e:
print("An error occured moving the file to trash:")
print(e)
return 1
@ -140,7 +144,6 @@ class FileHandler:
print("The folder/file does not exist")
return 1
except Exception as e:
print("An error occured renaming the file:")
print(e)
return 1

View File

@ -197,7 +197,13 @@ class Grid:
print(e)
def returnSelectedFiles(self):
return self.selectedFiles
# NOTE: Just returning selectedFiles looks like it returns a "pointer"
# to the children. This mean we lose the list if any left click occures
# in this class.
files = []
for file in self.selectedFiles:
files.append(file)
return files
def returnCurrentPath(self):
return self.currentPath