Addressbook / Tree / Messagelist rendering
Some changes that didn't propagate correctly before now do. Addresses #76
This commit is contained in:
parent
f159133f14
commit
4e4da254fa
|
@ -3861,10 +3861,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
return
|
return
|
||||||
|
|
||||||
newLabel = str(item.text(0))
|
newLabel = str(item.text(0))
|
||||||
if item.type == AccountMixin.SUBSCRIPTION:
|
oldLabel = item.defaultLabel()
|
||||||
oldLabel = item.label
|
|
||||||
else:
|
|
||||||
oldLabel = shared.config.get(str(item.address), 'label')
|
|
||||||
# unchanged, do not do anything either
|
# unchanged, do not do anything either
|
||||||
if newLabel == oldLabel:
|
if newLabel == oldLabel:
|
||||||
return
|
return
|
||||||
|
@ -3881,6 +3879,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.rerenderMessagelistFromLabels()
|
self.rerenderMessagelistFromLabels()
|
||||||
if item.type != AccountMixin.SUBSCRIPTION:
|
if item.type != AccountMixin.SUBSCRIPTION:
|
||||||
self.rerenderMessagelistToLabels()
|
self.rerenderMessagelistToLabels()
|
||||||
|
if item.type in (AccountMixin.NORMAL, AccountMixin.CHAN, AccountMixin.SUBSCRIPTION):
|
||||||
|
self.rerenderAddressBook()
|
||||||
self.recurDepth -= 1
|
self.recurDepth -= 1
|
||||||
|
|
||||||
def tableWidgetInboxItemClicked(self):
|
def tableWidgetInboxItemClicked(self):
|
||||||
|
@ -3935,7 +3935,9 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
messageTextedit.setTextColor(QtGui.QColor())
|
messageTextedit.setTextColor(QtGui.QColor())
|
||||||
messageTextedit.setContent(message)
|
messageTextedit.setContent(message)
|
||||||
|
|
||||||
def tableWidgetAddressBookItemChanged(self):
|
def tableWidgetAddressBookItemChanged(self, item):
|
||||||
|
if item.type == AccountMixin.CHAN:
|
||||||
|
self.rerenderComboBoxSendFrom()
|
||||||
self.rerenderMessagelistFromLabels()
|
self.rerenderMessagelistFromLabels()
|
||||||
self.rerenderMessagelistToLabels()
|
self.rerenderMessagelistToLabels()
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,30 @@ class AccountMixin (object):
|
||||||
self.type = AccountMixin.SUBSCRIPTION
|
self.type = AccountMixin.SUBSCRIPTION
|
||||||
else:
|
else:
|
||||||
self.type = self.NORMAL
|
self.type = self.NORMAL
|
||||||
|
|
||||||
|
def defaultLabel(self):
|
||||||
|
queryreturn = None
|
||||||
|
retval = None
|
||||||
|
if self.type in (AccountMixin.NORMAL, AccountMixin.CHAN, AccountMixin.MAILINGLIST):
|
||||||
|
try:
|
||||||
|
retval = unicode(shared.config.get(self.address, 'label'), 'utf-8')
|
||||||
|
except Exception as e:
|
||||||
|
queryreturn = sqlQuery(
|
||||||
|
'''select label from addressbook where address=?''', self.address)
|
||||||
|
elif self.type == AccountMixin.SUBSCRIPTION:
|
||||||
|
queryreturn = sqlQuery(
|
||||||
|
'''select label from subscriptions where address=?''', self.address)
|
||||||
|
if queryreturn is not None:
|
||||||
|
if queryreturn != []:
|
||||||
|
for row in queryreturn:
|
||||||
|
retval, = row
|
||||||
|
retval = unicode(retval, 'utf-8')
|
||||||
|
elif self.address is None or self.type == AccountMixin.ALL:
|
||||||
|
return unicode(str(QtGui.QApplication.translate("MainWindow", "All accounts")), 'utf-8')
|
||||||
|
if retval is None:
|
||||||
|
return unicode(self.address, 'utf-8')
|
||||||
|
else:
|
||||||
|
return retval
|
||||||
|
|
||||||
def updateText(self):
|
def updateText(self):
|
||||||
pass
|
pass
|
||||||
|
@ -241,15 +265,17 @@ class Ui_SubscriptionWidget(Ui_AddressWidget, AccountMixin):
|
||||||
self.setAddress(address)
|
self.setAddress(address)
|
||||||
self.setEnabled(enabled)
|
self.setEnabled(enabled)
|
||||||
self.setType()
|
self.setType()
|
||||||
self.setLabel(label)
|
|
||||||
self.initialised = True
|
self.initialised = True
|
||||||
self.setUnreadCount (unreadCount) # does updateText
|
self.setUnreadCount (unreadCount) # does updateText
|
||||||
|
|
||||||
def setLabel(self, label):
|
|
||||||
self.label = label
|
|
||||||
|
|
||||||
def _getLabel(self):
|
def _getLabel(self):
|
||||||
return unicode(self.label, 'utf-8)')
|
queryreturn = sqlQuery(
|
||||||
|
'''select label from subscriptions where address=?''', self.address)
|
||||||
|
if queryreturn != []:
|
||||||
|
for row in queryreturn:
|
||||||
|
retval, = row
|
||||||
|
return unicode(retval, 'utf-8')
|
||||||
|
return unicode(self.address, 'utf-8')
|
||||||
|
|
||||||
def setType(self):
|
def setType(self):
|
||||||
super(Ui_SubscriptionWidget, self).setType() # sets it editable
|
super(Ui_SubscriptionWidget, self).setType() # sets it editable
|
||||||
|
@ -258,12 +284,12 @@ class Ui_SubscriptionWidget(Ui_AddressWidget, AccountMixin):
|
||||||
def setData(self, column, role, value):
|
def setData(self, column, role, value):
|
||||||
if role == QtCore.Qt.EditRole:
|
if role == QtCore.Qt.EditRole:
|
||||||
if isinstance(value, QtCore.QVariant):
|
if isinstance(value, QtCore.QVariant):
|
||||||
self.setLabel(str(value.toString()))
|
label = str(value.toString())
|
||||||
else:
|
else:
|
||||||
self.setLabel(str(value))
|
label = str(value)
|
||||||
sqlExecute(
|
sqlExecute(
|
||||||
'''UPDATE subscriptions SET label=? WHERE address=?''',
|
'''UPDATE subscriptions SET label=? WHERE address=?''',
|
||||||
self.label, self.address)
|
label, self.address)
|
||||||
return super(Ui_SubscriptionWidget, self).setData(column, role, value)
|
return super(Ui_SubscriptionWidget, self).setData(column, role, value)
|
||||||
|
|
||||||
def updateText(self):
|
def updateText(self):
|
||||||
|
@ -424,17 +450,20 @@ class Ui_AddressBookWidgetItem(QtGui.QTableWidgetItem, AccountMixin):
|
||||||
return super(Ui_AddressBookWidgetItem, self).data(role)
|
return super(Ui_AddressBookWidgetItem, self).data(role)
|
||||||
|
|
||||||
def setData(self, role, value):
|
def setData(self, role, value):
|
||||||
if role == QtCore.Qt.EditRole and self.type in [AccountMixin.NORMAL, AccountMixin.MAILINGLIST]:
|
if role == QtCore.Qt.EditRole:
|
||||||
if isinstance(value, QtCore.QVariant):
|
if isinstance(value, QtCore.QVariant):
|
||||||
self.label = str(value.toString())
|
self.label = str(value.toString())
|
||||||
else:
|
else:
|
||||||
self.label = str(value)
|
self.label = str(value)
|
||||||
if self.type == AccountMixin.NORMAL or self.type == AccountMixin.MAILINGLIST:
|
if self.type in (AccountMixin.NORMAL, AccountMixin.MAILINGLIST, AccountMixin.CHAN):
|
||||||
sqlExecute('''UPDATE addressbook set label=? WHERE address=?''', self.label ,self.address)
|
try:
|
||||||
|
a = shared.config.get(self.address, 'label')
|
||||||
|
shared.config.set(self.address, 'label', self.label)
|
||||||
|
except:
|
||||||
|
sqlExecute('''UPDATE addressbook set label=? WHERE address=?''', self.label, self.address)
|
||||||
elif self.type == AccountMixin.SUBSCRIPTION:
|
elif self.type == AccountMixin.SUBSCRIPTION:
|
||||||
pass
|
from debug import logger
|
||||||
elif self.type == AccountMixin.CHAN:
|
sqlExecute('''UPDATE subscriptions set label=? WHERE address=?''', self.label, self.address)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
return super(Ui_AddressBookWidgetItem, self).setData(role, value)
|
return super(Ui_AddressBookWidgetItem, self).setData(role, value)
|
||||||
|
@ -457,8 +486,9 @@ class Ui_AddressBookWidgetItemLabel(Ui_AddressBookWidgetItem):
|
||||||
self.address = address
|
self.address = address
|
||||||
self.label = label
|
self.label = label
|
||||||
|
|
||||||
def setLabel(self, label):
|
def data(self, role):
|
||||||
self.label = label
|
self.label = self.defaultLabel()
|
||||||
|
return super(Ui_AddressBookWidgetItemLabel, self).data(role)
|
||||||
|
|
||||||
|
|
||||||
class Ui_AddressBookWidgetItemAddress(Ui_AddressBookWidgetItem):
|
class Ui_AddressBookWidgetItemAddress(Ui_AddressBookWidgetItem):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user