Tuples instead of lists if changes aren't needed
This commit is contained in:
parent
d295049653
commit
ff4e5f7ade
|
@ -528,7 +528,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
try:
|
try:
|
||||||
subwidget.setUnreadCount(
|
subwidget.setUnreadCount(
|
||||||
db[toAddress][subwidget.folderName])
|
db[toAddress][subwidget.folderName])
|
||||||
if subwidget.folderName not in ["new", "trash", "sent"]:
|
if subwidget.folderName not in ("new", "trash", "sent"):
|
||||||
unread += db[toAddress][subwidget.folderName]
|
unread += db[toAddress][subwidget.folderName]
|
||||||
db[toAddress].pop(subwidget.folderName, None)
|
db[toAddress].pop(subwidget.folderName, None)
|
||||||
except:
|
except:
|
||||||
|
@ -544,7 +544,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if toAddress is not None and tab == 'messages' and folder == "new":
|
if toAddress is not None and tab == 'messages' and folder == "new":
|
||||||
continue
|
continue
|
||||||
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c)
|
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c)
|
||||||
if subwidget.folderName not in ["new", "trash", "sent"]:
|
if subwidget.folderName not in ("new", "trash", "sent"):
|
||||||
unread += c
|
unread += c
|
||||||
j += 1
|
j += 1
|
||||||
widget.setUnreadCount(unread)
|
widget.setUnreadCount(unread)
|
||||||
|
@ -560,7 +560,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if toAddress is not None and tab == 'messages' and folder == "new":
|
if toAddress is not None and tab == 'messages' and folder == "new":
|
||||||
continue
|
continue
|
||||||
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, db[toAddress][folder])
|
subwidget = Ui_FolderWidget(widget, j, toAddress, folder, db[toAddress][folder])
|
||||||
if subwidget.folderName not in ["new", "trash", "sent"]:
|
if subwidget.folderName not in ("new", "trash", "sent"):
|
||||||
unread += db[toAddress][folder]
|
unread += db[toAddress][folder]
|
||||||
j += 1
|
j += 1
|
||||||
widget.setUnreadCount(unread)
|
widget.setUnreadCount(unread)
|
||||||
|
@ -951,7 +951,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
normalUnread = {}
|
normalUnread = {}
|
||||||
for row in queryReturn:
|
for row in queryReturn:
|
||||||
normalUnread[row[0]] = {}
|
normalUnread[row[0]] = {}
|
||||||
if row[1] in ["trash"]:
|
if row[1] in ("trash"):
|
||||||
continue
|
continue
|
||||||
normalUnread[row[0]][row[1]] = row[2]
|
normalUnread[row[0]][row[1]] = row[2]
|
||||||
if row[1] in totalUnread:
|
if row[1] in totalUnread:
|
||||||
|
@ -2349,25 +2349,42 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
# receives a message to an address that is acting as a
|
# receives a message to an address that is acting as a
|
||||||
# pseudo-mailing-list. The message will be broadcast out. This function
|
# pseudo-mailing-list. The message will be broadcast out. This function
|
||||||
# puts the message on the 'Sent' tab.
|
# puts the message on the 'Sent' tab.
|
||||||
def displayNewSentMessage(self, toAddress, toLabel, fromAddress, subject, message, ackdata):
|
def displayNewSentMessage(
|
||||||
|
self, toAddress, toLabel, fromAddress, subject,
|
||||||
|
message, ackdata):
|
||||||
acct = accountClass(fromAddress)
|
acct = accountClass(fromAddress)
|
||||||
acct.parseMessage(toAddress, fromAddress, subject, message)
|
acct.parseMessage(toAddress, fromAddress, subject, message)
|
||||||
tab = -1
|
tab = -1
|
||||||
for sent in [self.ui.tableWidgetInbox, self.ui.tableWidgetInboxSubscriptions, self.ui.tableWidgetInboxChans]:
|
for sent in (
|
||||||
|
self.ui.tableWidgetInbox,
|
||||||
|
self.ui.tableWidgetInboxSubscriptions,
|
||||||
|
self.ui.tableWidgetInboxChans
|
||||||
|
):
|
||||||
tab += 1
|
tab += 1
|
||||||
if tab == 1:
|
if tab == 1:
|
||||||
tab = 2
|
tab = 2
|
||||||
treeWidget = self.widgetConvert(sent)
|
treeWidget = self.widgetConvert(sent)
|
||||||
if self.getCurrentFolder(treeWidget) != "sent":
|
if self.getCurrentFolder(treeWidget) != "sent":
|
||||||
continue
|
continue
|
||||||
if treeWidget == self.ui.treeWidgetYourIdentities and self.getCurrentAccount(treeWidget) not in (fromAddress, None, False):
|
if treeWidget == self.ui.treeWidgetYourIdentities \
|
||||||
|
and self.getCurrentAccount(treeWidget) not in (
|
||||||
|
fromAddress, None, False):
|
||||||
continue
|
continue
|
||||||
elif treeWidget in [self.ui.treeWidgetSubscriptions, self.ui.treeWidgetChans] and self.getCurrentAccount(treeWidget) != toAddress:
|
elif treeWidget in (
|
||||||
|
self.ui.treeWidgetSubscriptions,
|
||||||
|
self.ui.treeWidgetChans
|
||||||
|
) and self.getCurrentAccount(treeWidget) != toAddress:
|
||||||
continue
|
continue
|
||||||
elif not helper_search.check_match(toAddress, fromAddress, subject, message, self.getCurrentSearchOption(tab), self.getCurrentSearchLine(tab)):
|
elif not helper_search.check_match(
|
||||||
|
toAddress, fromAddress, subject, message,
|
||||||
|
self.getCurrentSearchOption(tab),
|
||||||
|
self.getCurrentSearchLine(tab)
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.addMessageListItemSent(sent, toAddress, fromAddress, subject, "msgqueued", ackdata, time.time())
|
self.addMessageListItemSent(
|
||||||
|
sent, toAddress, fromAddress, subject, "msgqueued",
|
||||||
|
ackdata, time.time())
|
||||||
self.getAccountTextedit(acct).setPlainText(message)
|
self.getAccountTextedit(acct).setPlainText(message)
|
||||||
sent.setCurrentCell(0, 0)
|
sent.setCurrentCell(0, 0)
|
||||||
|
|
||||||
|
@ -2380,11 +2397,11 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
inbox = self.getAccountMessagelist(acct)
|
inbox = self.getAccountMessagelist(acct)
|
||||||
ret = None
|
ret = None
|
||||||
tab = -1
|
tab = -1
|
||||||
for treeWidget in [
|
for treeWidget in (
|
||||||
self.ui.treeWidgetYourIdentities,
|
self.ui.treeWidgetYourIdentities,
|
||||||
self.ui.treeWidgetSubscriptions,
|
self.ui.treeWidgetSubscriptions,
|
||||||
self.ui.treeWidgetChans
|
self.ui.treeWidgetChans
|
||||||
]:
|
):
|
||||||
tab += 1
|
tab += 1
|
||||||
if tab == 1:
|
if tab == 1:
|
||||||
tab = 2
|
tab = 2
|
||||||
|
@ -2399,7 +2416,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
if tableWidget == inbox \
|
if tableWidget == inbox \
|
||||||
and self.getCurrentAccount(treeWidget) == acct.address \
|
and self.getCurrentAccount(treeWidget) == acct.address \
|
||||||
and self.getCurrentFolder(treeWidget) \
|
and self.getCurrentFolder(treeWidget) \
|
||||||
in ["inbox", None]:
|
in ("inbox", None):
|
||||||
ret = self.addMessageListItemInbox(
|
ret = self.addMessageListItemInbox(
|
||||||
inbox, "inbox", inventoryHash, toAddress, fromAddress,
|
inbox, "inbox", inventoryHash, toAddress, fromAddress,
|
||||||
subject, time.time(), 0
|
subject, time.time(), 0
|
||||||
|
@ -2407,7 +2424,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
elif treeWidget == self.ui.treeWidgetYourIdentities \
|
elif treeWidget == self.ui.treeWidgetYourIdentities \
|
||||||
and self.getCurrentAccount(treeWidget) is None \
|
and self.getCurrentAccount(treeWidget) is None \
|
||||||
and self.getCurrentFolder(treeWidget) \
|
and self.getCurrentFolder(treeWidget) \
|
||||||
in ["inbox", "new", None]:
|
in ("inbox", "new", None):
|
||||||
ret = self.addMessageListItemInbox(
|
ret = self.addMessageListItemInbox(
|
||||||
tableWidget, "inbox", inventoryHash, toAddress,
|
tableWidget, "inbox", inventoryHash, toAddress,
|
||||||
fromAddress, subject, time.time(), 0
|
fromAddress, subject, time.time(), 0
|
||||||
|
@ -3110,15 +3127,18 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
return quoteWrapper.fill(line)
|
return quoteWrapper.fill(line)
|
||||||
return '\n'.join([quote_line(l) for l in message.splitlines()]) + '\n\n'
|
return '\n'.join([quote_line(l) for l in message.splitlines()]) + '\n\n'
|
||||||
|
|
||||||
def setSendFromComboBox(self, address = None):
|
def setSendFromComboBox(self, address=None):
|
||||||
if address is None:
|
if address is None:
|
||||||
messagelist = self.getCurrentMessagelist()
|
messagelist = self.getCurrentMessagelist()
|
||||||
if messagelist:
|
if messagelist:
|
||||||
currentInboxRow = messagelist.currentRow()
|
currentInboxRow = messagelist.currentRow()
|
||||||
address = messagelist.item(
|
address = messagelist.item(
|
||||||
currentInboxRow, 0).address
|
currentInboxRow, 0).address
|
||||||
for box in [self.ui.comboBoxSendFrom, self.ui.comboBoxSendFromBroadcast]:
|
for box in (
|
||||||
listOfAddressesInComboBoxSendFrom = [str(box.itemData(i)) for i in range(box.count())]
|
self.ui.comboBoxSendFrom, self.ui.comboBoxSendFromBroadcast
|
||||||
|
):
|
||||||
|
listOfAddressesInComboBoxSendFrom = [
|
||||||
|
str(box.itemData(i)) for i in range(box.count())]
|
||||||
if address in listOfAddressesInComboBoxSendFrom:
|
if address in listOfAddressesInComboBoxSendFrom:
|
||||||
currentIndex = listOfAddressesInComboBoxSendFrom.index(address)
|
currentIndex = listOfAddressesInComboBoxSendFrom.index(address)
|
||||||
box.setCurrentIndex(currentIndex)
|
box.setCurrentIndex(currentIndex)
|
||||||
|
@ -3228,7 +3248,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
quotedText = self.quoted_text(
|
quotedText = self.quoted_text(
|
||||||
unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
|
unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
|
||||||
widget['message'].setPlainText(quotedText)
|
widget['message'].setPlainText(quotedText)
|
||||||
if acct.subject[0:3] in ['Re:', 'RE:']:
|
if acct.subject[0:3] in ('Re:', 'RE:'):
|
||||||
widget['subject'].setText(
|
widget['subject'].setText(
|
||||||
tableWidget.item(currentInboxRow, 2).label)
|
tableWidget.item(currentInboxRow, 2).label)
|
||||||
else:
|
else:
|
||||||
|
@ -3716,12 +3736,12 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
def getCurrentMessageTextedit(self):
|
def getCurrentMessageTextedit(self):
|
||||||
currentIndex = self.ui.tabWidget.currentIndex()
|
currentIndex = self.ui.tabWidget.currentIndex()
|
||||||
messagelistList = [
|
messagelistList = (
|
||||||
self.ui.textEditInboxMessage,
|
self.ui.textEditInboxMessage,
|
||||||
False,
|
False,
|
||||||
self.ui.textEditInboxMessageSubscriptions,
|
self.ui.textEditInboxMessageSubscriptions,
|
||||||
self.ui.textEditInboxMessageChans,
|
self.ui.textEditInboxMessageChans,
|
||||||
]
|
)
|
||||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||||
return messagelistList[currentIndex]
|
return messagelistList[currentIndex]
|
||||||
else:
|
else:
|
||||||
|
@ -3741,12 +3761,12 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
def getCurrentSearchLine(self, currentIndex=None, retObj=False):
|
def getCurrentSearchLine(self, currentIndex=None, retObj=False):
|
||||||
if currentIndex is None:
|
if currentIndex is None:
|
||||||
currentIndex = self.ui.tabWidget.currentIndex()
|
currentIndex = self.ui.tabWidget.currentIndex()
|
||||||
messagelistList = [
|
messagelistList = (
|
||||||
self.ui.inboxSearchLineEdit,
|
self.ui.inboxSearchLineEdit,
|
||||||
False,
|
False,
|
||||||
self.ui.inboxSearchLineEditSubscriptions,
|
self.ui.inboxSearchLineEditSubscriptions,
|
||||||
self.ui.inboxSearchLineEditChans,
|
self.ui.inboxSearchLineEditChans,
|
||||||
]
|
)
|
||||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||||
if retObj:
|
if retObj:
|
||||||
return messagelistList[currentIndex]
|
return messagelistList[currentIndex]
|
||||||
|
@ -3758,12 +3778,12 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
def getCurrentSearchOption(self, currentIndex=None):
|
def getCurrentSearchOption(self, currentIndex=None):
|
||||||
if currentIndex is None:
|
if currentIndex is None:
|
||||||
currentIndex = self.ui.tabWidget.currentIndex()
|
currentIndex = self.ui.tabWidget.currentIndex()
|
||||||
messagelistList = [
|
messagelistList = (
|
||||||
self.ui.inboxSearchOption,
|
self.ui.inboxSearchOption,
|
||||||
False,
|
False,
|
||||||
self.ui.inboxSearchOptionSubscriptions,
|
self.ui.inboxSearchOptionSubscriptions,
|
||||||
self.ui.inboxSearchOptionChans,
|
self.ui.inboxSearchOptionChans,
|
||||||
]
|
)
|
||||||
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
if currentIndex >= 0 and currentIndex < len(messagelistList):
|
||||||
return messagelistList[currentIndex].currentText()
|
return messagelistList[currentIndex].currentText()
|
||||||
|
|
||||||
|
@ -3872,12 +3892,11 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
tableWidget = self.getCurrentMessagelist()
|
tableWidget = self.getCurrentMessagelist()
|
||||||
currentColumn = tableWidget.currentColumn()
|
currentColumn = tableWidget.currentColumn()
|
||||||
currentRow = tableWidget.currentRow()
|
currentRow = tableWidget.currentRow()
|
||||||
if currentColumn not in [0, 1, 2]: # to, from, subject
|
currentFolder = self.getCurrentFolder()
|
||||||
if self.getCurrentFolder() == "sent":
|
if currentColumn not in (0, 1, 2): # to, from, subject
|
||||||
currentColumn = 0
|
currentColumn = 0 if currentFolder == "sent" else 1
|
||||||
else:
|
|
||||||
currentColumn = 1
|
if currentFolder == "sent":
|
||||||
if self.getCurrentFolder() == "sent":
|
|
||||||
myAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole)
|
myAddress = tableWidget.item(currentRow, 1).data(QtCore.Qt.UserRole)
|
||||||
otherAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole)
|
otherAddress = tableWidget.item(currentRow, 0).data(QtCore.Qt.UserRole)
|
||||||
else:
|
else:
|
||||||
|
@ -3891,7 +3910,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
text = tableWidget.item(currentRow, currentColumn).label
|
text = tableWidget.item(currentRow, currentColumn).label
|
||||||
else:
|
else:
|
||||||
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
|
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
|
||||||
# text = unicode(str(text), 'utf-8', 'ignore')
|
|
||||||
clipboard = QtWidgets.QApplication.clipboard()
|
clipboard = QtWidgets.QApplication.clipboard()
|
||||||
clipboard.setText(text)
|
clipboard.setText(text)
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user