From d3dfc5a0f760e4f5a683430aa3974269291dd11b Mon Sep 17 00:00:00 2001 From: Nimda Date: Thu, 25 Jul 2013 22:00:54 -0400 Subject: [PATCH 1/4] initial commit. Probably broken. --- src/bitmessageqt/__init__.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 0c00fba0..08c65eab 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -161,12 +161,15 @@ class MyForm(QtGui.QMainWindow): "MainWindow", "View HTML code as formatted text"), self.on_action_InboxMessageForceHtml) self.actionSaveMessageAs = self.ui.inboxContextMenuToolbar.addAction(_translate( "MainWindow", "Save message as..."), self.on_action_InboxSaveMessageAs) + self.actionMarkUnread = self.ui.inboxContextMenuToolbar.addAction(_translate( + "MainWindow", "Mark Unread"), self.on_action_InboxMarkUnread) self.ui.tableWidgetInbox.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) self.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL( 'customContextMenuRequested(const QPoint&)'), self.on_context_menuInbox) self.popMenuInbox = QtGui.QMenu(self) self.popMenuInbox.addAction(self.actionForceHtml) + self.popMenuInbox.addAction(self.actionMarkUnread) self.popMenuInbox.addSeparator() self.popMenuInbox.addAction(self.actionReply) self.popMenuInbox.addAction(self.actionAddSenderToAddressBook) @@ -2253,6 +2256,29 @@ class MyForm(QtGui.QMainWindow): content = content.replace('\n\n', '

') self.ui.textEditInboxMessage.setHtml(QtCore.QString(content)) + def on_action_InboxMarkUnread(self): + font = QFont() + font.setBold(True) + for row in self.ui.tableWidgetInbox.selectedIndexes(): + currentRow = row.row() + inventoryHashToMarkUnread = str(self.ui.tableWidgetInbox.item( + currentRow, 3).data(Qt.UserRole).toPyObject()) + t = (inventoryHashToMarkUnread,) + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put( + '''UPDATE inbox SET read=0 WHERE msgid=?''') + shared.sqlSubmitQueue.put(t) + shared.sqlReturnQueue.get() + shared.sqlLock.release() + self.ui.tableWidgetInbox.item(currentRow, 0).setFont(font) + self.ui.tableWidgetInbox.item(currentRow, 1).setFont(font) + self.ui.tableWidgetInbox.item(currentRow, 2).setFont(font) + self.ui.tableWidgetInbox.item(currentRow, 3).setFont(font) + shared.sqlLock.acquire() + shared.sqlSubmitQueue.put('commit') + shared.sqlLock.release() + self.ui.tableWidgetInbox.selectRow(currentRow + 1) # Hmm... + def on_action_InboxReply(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow() toAddressAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item( From ddaa1413a6b4194adea11a4af0ccd482f530789f Mon Sep 17 00:00:00 2001 From: Nimda Date: Thu, 25 Jul 2013 22:10:22 -0400 Subject: [PATCH 2/4] Remove selecting of next message. It doesn't seem to be necessary, and it would always fail if there was only one message in the inbox. --- src/bitmessageqt/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 08c65eab..03484384 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2277,7 +2277,10 @@ class MyForm(QtGui.QMainWindow): shared.sqlLock.acquire() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() - self.ui.tableWidgetInbox.selectRow(currentRow + 1) # Hmm... + # self.ui.tableWidgetInbox.selectRow(currentRow + 1) + # This doesn't de-select the last message if you try to mark it unread, but that doesn't interfere. Might not be necessary. + # We could also select upwards, but then our problem would be with the topmost message. + # Is there a way to deselect all rows? The Qt documentation does not indicate so. def on_action_InboxReply(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow() From 43cbf69103e24d95f9f400d776042d9eea04063b Mon Sep 17 00:00:00 2001 From: Nimda Date: Thu, 25 Jul 2013 22:20:53 -0400 Subject: [PATCH 3/4] Tabs are the root of all evil --- src/bitmessageqt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 03484384..2008e7b1 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2280,7 +2280,7 @@ class MyForm(QtGui.QMainWindow): # self.ui.tableWidgetInbox.selectRow(currentRow + 1) # This doesn't de-select the last message if you try to mark it unread, but that doesn't interfere. Might not be necessary. # We could also select upwards, but then our problem would be with the topmost message. - # Is there a way to deselect all rows? The Qt documentation does not indicate so. + # Is there a way to deselect all rows? The Qt documentation does not indicate so. def on_action_InboxReply(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow() From 5d2eb5ef1cdeaaa894417823f0111ecf4657296e Mon Sep 17 00:00:00 2001 From: nimdahk Date: Thu, 25 Jul 2013 23:56:38 -0400 Subject: [PATCH 4/4] more comments on the mark unread implementation --- src/bitmessageqt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 2008e7b1..96db1f92 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2280,7 +2280,7 @@ class MyForm(QtGui.QMainWindow): # self.ui.tableWidgetInbox.selectRow(currentRow + 1) # This doesn't de-select the last message if you try to mark it unread, but that doesn't interfere. Might not be necessary. # We could also select upwards, but then our problem would be with the topmost message. - # Is there a way to deselect all rows? The Qt documentation does not indicate so. + # self.ui.tableWidgetInbox.clearSelection() manages to mark the message as read again. def on_action_InboxReply(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow()