diff --git a/dirnotes b/dirnotes index e7798d7..8b54218 100755 --- a/dirnotes +++ b/dirnotes @@ -112,6 +112,7 @@ def parse(): return parser.parse_args() +#~ class FileObj(QtCore.QObject): class FileObj(): FILE_IS_DIR = -1 FILE_IS_LINK = -2 @@ -143,11 +144,14 @@ class FileObj(): # we need to move these cases out to a handler except Exception as e: print("problem setting the comment on file %s" % (self.fileName,)) - print("error "+e) - if os.access(self.fileName, os.W_OK)!=True: + print("error "+repr(e)) + ## todo: elif file.is_sym() the kernel won't allow comments on symlinks....stored in database + if self.size == FileObj.FILE_IS_LINK: + print("Linux does not allow comments on symlinks; comment is stored in database") + elif os.access(self.fileName, os.W_OK)!=True: print("you don't appear to have write permissions on this file") # change the listbox background to yellow - self.displayBox.notifyUnchanged() + self.displayBox.notifyUnchanged() elif "Errno 95" in str(e): print("is this a VFAT or EXFAT volume? these don't allow comments") return False @@ -195,14 +199,15 @@ class DirNotes(QMainWindow): self.curPath, filename = os.path.split(argFilename) print("working on <"+self.curPath+"> and <"+filename+">") - self.refill() - lb.setHorizontalHeaderItem(0,QTableWidgetItem("File")) lb.setHorizontalHeaderItem(1,QTableWidgetItem("Date/Time")) lb.setHorizontalHeaderItem(2,QTableWidgetItem("Size")) lb.setHorizontalHeaderItem(3,QTableWidgetItem("Comment")) - lb.resizeColumnsToContents() + lb.setSortingEnabled(True) + self.refill() + lb.resizeColumnsToContents() + e = QLabel("View and edit file comments stored in extended attributes user.xdg.comment",win) b1 = QPushButton("restore from database",win) @@ -285,10 +290,12 @@ class DirNotes(QMainWindow): # this is a list of all the file for i in range(len(d)): this_file = FileObj(current+'/'+d[i]) + print("insert order check: " + d[i] + " " + str(i)) #~ self.files.update({this_file.getName(),this_file}) self.files = self.files + [this_file] item = QTableWidgetItem(d[i]) item.setFlags(QtCore.Qt.ItemIsEnabled) + item.setData(32,this_file) # keep a hidden copy of the full path self.lb.setItem(i,0,item) #lb.itemAt(i,0).setFlags(Qt.ItemIsEnabled) #NoItemFlags) comment = this_file.getComment() @@ -315,17 +322,21 @@ class DirNotes(QMainWindow): def change(self,x): print("debugging " + x.text() + " r:" + str(x.row()) + " c:" + str(x.column())) - the_file = dn.files[x.row()] - r = the_file.setComment(str(x.text())) + print(" selected file: "+self.lb.item(x.row(),0).data(32).toPyObject().getName()) + the_file = self.lb.item(x.row(),0).data(32).toPyObject() + print(" and the row file is "+the_file.getName()) + r = the_file.setComment(str(x.text())) ## fix me store the FileObj in the data if r: self.db.log(the_file.getName(),x.text()) def restore_from_database(self): print("restore from database") - fileName = str(self.lb.item(self.lb.currentRow(),0).text()) + # retrieve the full path name + fileName = str(self.lb.item(self.lb.currentRow(),0).data(32).toPyObject().getName()) + print("using filename: "+fileName) existing_comment = str(self.lb.item(self.lb.currentRow(),3).text()) print("restore....existing="+existing_comment+"=") if len(existing_comment) > 0: - m = QMessageBox() + m = QMessageBox() m.setText("This file already has a comment. Overwrite?") m.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel); if m.exec_() != QMessageBox.Ok: @@ -402,3 +413,10 @@ user.xdg.publisher -choose & cancel buttons ''' + +''' commandline xattr +getfattr -h (don't follow symlink) -d (dump all properties) +''' +''' qt set color + newitem.setData(Qt.BackgroundRole,QBrush(QColor("yellow"))) +'''