store a FileObj as the hidden property on column 0
this is the last version that has priority on the xattr the next version will have priority on the comments stored in the database and only set the xattr field as an option
This commit is contained in:
@@ -112,6 +112,7 @@ def parse():
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
#~ class FileObj(QtCore.QObject):
|
||||||
class FileObj():
|
class FileObj():
|
||||||
FILE_IS_DIR = -1
|
FILE_IS_DIR = -1
|
||||||
FILE_IS_LINK = -2
|
FILE_IS_LINK = -2
|
||||||
@@ -143,8 +144,11 @@ class FileObj():
|
|||||||
# we need to move these cases out to a handler
|
# we need to move these cases out to a handler
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("problem setting the comment on file %s" % (self.fileName,))
|
print("problem setting the comment on file %s" % (self.fileName,))
|
||||||
print("error "+e)
|
print("error "+repr(e))
|
||||||
if os.access(self.fileName, os.W_OK)!=True:
|
## 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")
|
print("you don't appear to have write permissions on this file")
|
||||||
# change the listbox background to yellow
|
# change the listbox background to yellow
|
||||||
self.displayBox.notifyUnchanged()
|
self.displayBox.notifyUnchanged()
|
||||||
@@ -195,12 +199,13 @@ class DirNotes(QMainWindow):
|
|||||||
self.curPath, filename = os.path.split(argFilename)
|
self.curPath, filename = os.path.split(argFilename)
|
||||||
print("working on <"+self.curPath+"> and <"+filename+">")
|
print("working on <"+self.curPath+"> and <"+filename+">")
|
||||||
|
|
||||||
self.refill()
|
|
||||||
|
|
||||||
lb.setHorizontalHeaderItem(0,QTableWidgetItem("File"))
|
lb.setHorizontalHeaderItem(0,QTableWidgetItem("File"))
|
||||||
lb.setHorizontalHeaderItem(1,QTableWidgetItem("Date/Time"))
|
lb.setHorizontalHeaderItem(1,QTableWidgetItem("Date/Time"))
|
||||||
lb.setHorizontalHeaderItem(2,QTableWidgetItem("Size"))
|
lb.setHorizontalHeaderItem(2,QTableWidgetItem("Size"))
|
||||||
lb.setHorizontalHeaderItem(3,QTableWidgetItem("Comment"))
|
lb.setHorizontalHeaderItem(3,QTableWidgetItem("Comment"))
|
||||||
|
lb.setSortingEnabled(True)
|
||||||
|
|
||||||
|
self.refill()
|
||||||
lb.resizeColumnsToContents()
|
lb.resizeColumnsToContents()
|
||||||
|
|
||||||
e = QLabel("View and edit file comments stored in extended attributes user.xdg.comment",win)
|
e = QLabel("View and edit file comments stored in extended attributes user.xdg.comment",win)
|
||||||
@@ -285,10 +290,12 @@ class DirNotes(QMainWindow):
|
|||||||
# this is a list of all the file
|
# this is a list of all the file
|
||||||
for i in range(len(d)):
|
for i in range(len(d)):
|
||||||
this_file = FileObj(current+'/'+d[i])
|
this_file = FileObj(current+'/'+d[i])
|
||||||
|
print("insert order check: " + d[i] + " " + str(i))
|
||||||
#~ self.files.update({this_file.getName(),this_file})
|
#~ self.files.update({this_file.getName(),this_file})
|
||||||
self.files = self.files + [this_file]
|
self.files = self.files + [this_file]
|
||||||
item = QTableWidgetItem(d[i])
|
item = QTableWidgetItem(d[i])
|
||||||
item.setFlags(QtCore.Qt.ItemIsEnabled)
|
item.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||||
|
item.setData(32,this_file) # keep a hidden copy of the full path
|
||||||
self.lb.setItem(i,0,item)
|
self.lb.setItem(i,0,item)
|
||||||
#lb.itemAt(i,0).setFlags(Qt.ItemIsEnabled) #NoItemFlags)
|
#lb.itemAt(i,0).setFlags(Qt.ItemIsEnabled) #NoItemFlags)
|
||||||
comment = this_file.getComment()
|
comment = this_file.getComment()
|
||||||
@@ -315,13 +322,17 @@ class DirNotes(QMainWindow):
|
|||||||
|
|
||||||
def change(self,x):
|
def change(self,x):
|
||||||
print("debugging " + x.text() + " r:" + str(x.row()) + " c:" + str(x.column()))
|
print("debugging " + x.text() + " r:" + str(x.row()) + " c:" + str(x.column()))
|
||||||
the_file = dn.files[x.row()]
|
print(" selected file: "+self.lb.item(x.row(),0).data(32).toPyObject().getName())
|
||||||
r = the_file.setComment(str(x.text()))
|
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:
|
if r:
|
||||||
self.db.log(the_file.getName(),x.text())
|
self.db.log(the_file.getName(),x.text())
|
||||||
def restore_from_database(self):
|
def restore_from_database(self):
|
||||||
print("restore from database")
|
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())
|
existing_comment = str(self.lb.item(self.lb.currentRow(),3).text())
|
||||||
print("restore....existing="+existing_comment+"=")
|
print("restore....existing="+existing_comment+"=")
|
||||||
if len(existing_comment) > 0:
|
if len(existing_comment) > 0:
|
||||||
@@ -402,3 +413,10 @@ user.xdg.publisher
|
|||||||
-choose & cancel buttons
|
-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")))
|
||||||
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user