Make subscription/chan labels editable

Fixes #67
This commit is contained in:
mailchuck 2015-10-27 19:50:52 +01:00
parent 97b38f9daf
commit dd2f83ff4d
No known key found for this signature in database
GPG Key ID: B6311FA753FBF089
2 changed files with 25 additions and 7 deletions

View File

@ -444,6 +444,8 @@ class MyForm(QtGui.QMainWindow):
newSubItem = Ui_FolderWidget(newItem, 0, address, folder, 0) newSubItem = Ui_FolderWidget(newItem, 0, address, folder, 0)
newItem.setUnreadCount(unread) newItem.setUnreadCount(unread)
newItem.setFlags (newItem.flags() | QtCore.Qt.ItemIsEditable)
treeWidget.setSortingEnabled(True) treeWidget.setSortingEnabled(True)
def rerenderTabTreeMessages(self): def rerenderTabTreeMessages(self):
@ -537,8 +539,7 @@ class MyForm(QtGui.QMainWindow):
unread += db[toAddress][folder] unread += db[toAddress][folder]
j += 1 j += 1
widget.setUnreadCount(unread) widget.setUnreadCount(unread)
if (tab == 'messages'): widget.setFlags (widget.flags() | QtCore.Qt.ItemIsEditable)
widget.setFlags (widget.flags() | QtCore.Qt.ItemIsEditable)
i += 1 i += 1
treeWidget.setSortingEnabled(True) treeWidget.setSortingEnabled(True)
@ -658,8 +659,12 @@ class MyForm(QtGui.QMainWindow):
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged) "itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL( QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.treeWidgetItemClicked) "itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL( QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.treeWidgetItemClicked) "itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
# Put the colored icon on the status bar # Put the colored icon on the status bar
# self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) # self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
@ -3613,7 +3618,7 @@ class MyForm(QtGui.QMainWindow):
if column != 0: if column != 0:
return return
# only account names of normal addresses (no chans/mailinglists) # only account names of normal addresses (no chans/mailinglists)
if (not isinstance(item, Ui_AddressWidget)) or item.type != 'normal' or not self.getCurrentTreeWidget() or self.getCurrentTreeWidget().currentItem() is None: if (not isinstance(item, Ui_AddressWidget)) or (not self.getCurrentTreeWidget()) or self.getCurrentTreeWidget().currentItem() is None:
return return
# not visible # not visible
if (not self.getCurrentItem()) or (not isinstance (self.getCurrentItem(), Ui_AddressWidget)): if (not self.getCurrentItem()) or (not isinstance (self.getCurrentItem(), Ui_AddressWidget)):
@ -3625,7 +3630,10 @@ class MyForm(QtGui.QMainWindow):
newLabel = str(item.text(0)) newLabel = str(item.text(0))
newLabel = newLabel.replace("(" + str(item.address) + ")", '') newLabel = newLabel.replace("(" + str(item.address) + ")", '')
newLabel = newLabel.rstrip() newLabel = newLabel.rstrip()
oldLabel = shared.config.get(str(item.address), 'label') if item.type == "subscription":
oldLabel = item.label
else:
oldLabel = shared.config.get(str(item.address), 'label')
oldLabel = oldLabel.replace("(" + str(item.address) + ")", '') oldLabel = oldLabel.replace("(" + str(item.address) + ")", '')
oldLabel = oldLabel.rstrip() oldLabel = oldLabel.rstrip()
# unchanged, do not do anything either # unchanged, do not do anything either
@ -3637,12 +3645,18 @@ class MyForm(QtGui.QMainWindow):
return return
self.recurDepth += 1 self.recurDepth += 1
shared.config.set(str(item.address), 'label', newLabel) if item.type == "subscription":
sqlExecute(
'''UPDATE subscriptions SET label=? WHERE address=?''',
newLabel, item.address)
item.setLabel(newLabel)
else:
shared.config.set(str(item.address), 'label', newLabel)
shared.writeKeysFile()
item.updateText() item.updateText()
shared.writeKeysFile()
if item.type == 'mailinglist': if item.type == 'mailinglist':
self.rerenderComboBoxSendFromBroadcast() self.rerenderComboBoxSendFromBroadcast()
else: elif item.type != "subscription":
self.rerenderComboBoxSendFrom() self.rerenderComboBoxSendFrom()
self.recurDepth -= 1 self.recurDepth -= 1

View File

@ -183,6 +183,10 @@ class Ui_SubscriptionWidget(Ui_AddressWidget, AccountMixin):
def setType(self): def setType(self):
self.type = "subscription" self.type = "subscription"
def edit(self):
self.setText(0, self.label)
super(QtGui.QAbstractItemView, self).edit()
def updateText(self): def updateText(self):
if not self.initialised: if not self.initialised: