Added a help dialog. It needs filling out.

In the next version, get rid of the top-left directory chooser and just use
the listbox navigation....double click on column 1
This commit is contained in:
2015-12-22 22:16:02 -05:00
parent 16b3ee02c5
commit d8cfe7f1e3
+37 -7
View File
@@ -2,14 +2,17 @@
""" a simple gui or command line app
to view and create/edit file comments
comments are stored in xattr user.xdg.comment
comments are stored in an SQLite3 database
default ~/.dirnotes.db
where possible, comments are duplicated in
xattr user.xdg.comment
depends on python-pyxattr
because files are so often over-written, save a copy
of the comments in a database ~/.dirnotes.db
some file systems don't allow xattr, and even linux
doesn't allow xattr on symlinks, so the database is
considered primary
these comments stick to the symlink
these comments stick to the symlink, not the deref
"""
@@ -170,6 +173,30 @@ class SortableTableWidgetItem(QTableWidgetItem):
def __lt__(self, other):
return self.sortValue < other.sortValue
class HelpWidget(QDialog):
def __init__(self, parent):
super(QDialog, self).__init__(parent)
self.layout = QVBoxLayout(self)
self.tb = QLabel(self)
self.tb.setWordWrap(True)
msg = """<h1>Overview</h1>
This app allows you to add comments to files. The comments are stored in
a database, and where possible, saved in the xattr (hidden attributes)
field of the file system.
<p>
You can sort the directory listing by clicking on the column heading.
<p>
The small box at the top left lets you navigate the directory listings.
"""
self.tb.setText(msg)
self.tb.setFixedWidth(600)
self.pb = QPushButton('OK',self)
self.pb.setFixedWidth(200)
self.layout.addWidget(self.tb)
self.layout.addWidget(self.pb)
self.pb.pressed.connect(self.close)
self.show()
class DirNotes(QMainWindow):
''' the main window of the app
@@ -249,6 +276,7 @@ class DirNotes(QMainWindow):
mf.addAction("Restore comment from database", self.restore_from_database, "Ctrl+R")
mf.addSeparator()
mf.addAction("Quit", self.close, "Ctrl+Q")
mf.addAction("About", self.about, "Ctrl+H")
#~ QShortcut(QKeySequence("Ctrl+Q"), self, self.close)
self.setWindowTitle("DirNotes Alt-F for menu Dir: "+self.curPath)
@@ -265,6 +293,8 @@ class DirNotes(QMainWindow):
def sbn(self):
print("sort by name")
self.lb.sortItems(0)
def about(self):
HelpWidget(self)
def sbc(self):
print("sort by comment")
self.lb.sortItems(3,QtCore.Qt.DescendingOrder)
@@ -295,7 +325,7 @@ class DirNotes(QMainWindow):
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
item.setData(32,this_file) # keep a hidden copy of the file object
self.lb.setItem(i,0,item)
#lb.itemAt(i,0).setFlags(Qt.ItemIsEnabled) #NoItemFlags)
comment = this_file.getComment()
@@ -325,7 +355,7 @@ class DirNotes(QMainWindow):
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
r = the_file.setComment(str(x.text()))
if r:
self.db.log(the_file.getName(),x.text())
def restore_from_database(self):