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)
newItem.setUnreadCount(unread)
newItem.setFlags (newItem.flags() | QtCore.Qt.ItemIsEditable)
treeWidget.setSortingEnabled(True)
def rerenderTabTreeMessages(self):
@ -537,7 +539,6 @@ class MyForm(QtGui.QMainWindow):
unread += db[toAddress][folder]
j += 1
widget.setUnreadCount(unread)
if (tab == 'messages'):
widget.setFlags (widget.flags() | QtCore.Qt.ItemIsEditable)
i += 1
@ -658,8 +659,12 @@ class MyForm(QtGui.QMainWindow):
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetSubscriptions, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
"itemSelectionChanged ()"), self.treeWidgetItemClicked)
QtCore.QObject.connect(self.ui.treeWidgetChans, QtCore.SIGNAL(
"itemChanged (QTreeWidgetItem *, int)"), self.treeWidgetItemChanged)
# Put the colored icon on the status bar
# self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
@ -3613,7 +3618,7 @@ class MyForm(QtGui.QMainWindow):
if column != 0:
return
# 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
# not visible
if (not self.getCurrentItem()) or (not isinstance (self.getCurrentItem(), Ui_AddressWidget)):
@ -3625,6 +3630,9 @@ class MyForm(QtGui.QMainWindow):
newLabel = str(item.text(0))
newLabel = newLabel.replace("(" + str(item.address) + ")", '')
newLabel = newLabel.rstrip()
if item.type == "subscription":
oldLabel = item.label
else:
oldLabel = shared.config.get(str(item.address), 'label')
oldLabel = oldLabel.replace("(" + str(item.address) + ")", '')
oldLabel = oldLabel.rstrip()
@ -3637,12 +3645,18 @@ class MyForm(QtGui.QMainWindow):
return
self.recurDepth += 1
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)
item.updateText()
shared.writeKeysFile()
item.updateText()
if item.type == 'mailinglist':
self.rerenderComboBoxSendFromBroadcast()
else:
elif item.type != "subscription":
self.rerenderComboBoxSendFrom()
self.recurDepth -= 1

View File

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