Minor style changes:
- removed list <-> set conversion in __init__ - tuples instead of lists if changes aren't needed - removed unnecessary variable redefinition in utils - rewrote languagebox module a bit - minor change in MyForm.rerenderAddressBook
This commit is contained in:
parent
326998953d
commit
284a915976
|
@ -545,7 +545,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:
|
||||||
|
@ -561,7 +561,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)
|
||||||
|
@ -577,7 +577,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)
|
||||||
|
@ -1990,10 +1990,10 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
for address in sorted(
|
for address in sorted(
|
||||||
oldRows, key=lambda x: oldRows[x][2], reverse=True
|
oldRows, key=lambda x: oldRows[x][2], reverse=True
|
||||||
):
|
):
|
||||||
if address in newRows:
|
try:
|
||||||
completerList.append(
|
completerList.append(
|
||||||
newRows.pop(address)[0] + " <" + address + ">")
|
newRows.pop(address)[0] + " <" + address + ">")
|
||||||
else:
|
except KeyError:
|
||||||
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
|
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
|
||||||
for address in newRows:
|
for address in newRows:
|
||||||
addRow(address, newRows[address][0], newRows[address][1])
|
addRow(address, newRows[address][0], newRows[address][1])
|
||||||
|
@ -2067,13 +2067,12 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
# To send a message to specific people (rather than broadcast)
|
# To send a message to specific people (rather than broadcast)
|
||||||
if sendMessageToPeople:
|
if sendMessageToPeople:
|
||||||
toAddressesList = [
|
toAddressesList = set([
|
||||||
s.strip() for s in toAddresses.replace(',', ';').split(';')
|
s.strip() for s in toAddresses.replace(',', ';').split(';')
|
||||||
]
|
])
|
||||||
# remove duplicate addresses. If the user has one address
|
# remove duplicate addresses. If the user has one address
|
||||||
# with a BM- and the same address without the BM-, this will
|
# with a BM- and the same address without the BM-, this will
|
||||||
# not catch it. They'll send the message to the person twice.
|
# not catch it. They'll send the message to the person twice.
|
||||||
toAddressesList = list(set(toAddressesList))
|
|
||||||
for toAddress in toAddressesList:
|
for toAddress in toAddressesList:
|
||||||
if toAddress != '':
|
if toAddress != '':
|
||||||
# label plus address
|
# label plus address
|
||||||
|
@ -2317,7 +2316,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''', *t)
|
||||||
|
|
||||||
toLabel = str_broadcast_subscribers
|
toLabel = str_broadcast_subscribers
|
||||||
|
|
||||||
self.displayNewSentMessage(
|
self.displayNewSentMessage(
|
||||||
toAddress, toLabel, fromAddress, subject, message, ackdata)
|
toAddress, toLabel, fromAddress, subject, message, ackdata)
|
||||||
|
|
||||||
|
@ -2418,25 +2417,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)
|
||||||
|
|
||||||
|
@ -2449,11 +2465,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
|
||||||
|
@ -2468,7 +2484,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
|
||||||
|
@ -2476,7 +2492,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
|
||||||
|
@ -2999,8 +3015,11 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
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)
|
||||||
|
@ -3123,7 +3142,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:
|
||||||
|
@ -3751,10 +3770,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
currentRow = tableWidget.currentRow()
|
currentRow = tableWidget.currentRow()
|
||||||
currentFolder = self.getCurrentFolder()
|
currentFolder = self.getCurrentFolder()
|
||||||
if currentColumn not in (0, 1, 2): # to, from, subject
|
if currentColumn not in (0, 1, 2): # to, from, subject
|
||||||
if currentFolder == "sent":
|
currentColumn = 0 if currentFolder == "sent" else 1
|
||||||
currentColumn = 0
|
|
||||||
else:
|
|
||||||
currentColumn = 1
|
|
||||||
if currentFolder == "sent":
|
if currentFolder == "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)
|
||||||
|
@ -3769,7 +3786,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)
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,13 @@ class LanguageBox(QtWidgets.QComboBox):
|
||||||
):
|
):
|
||||||
localeShort = \
|
localeShort = \
|
||||||
os.path.split(translationFile)[1].split("_", 1)[1][:-3]
|
os.path.split(translationFile)[1].split("_", 1)[1][:-3]
|
||||||
locale = QtCore.QLocale(localeShort)
|
|
||||||
if localeShort in LanguageBox.languageName:
|
if localeShort in LanguageBox.languageName:
|
||||||
self.addItem(
|
self.addItem(
|
||||||
LanguageBox.languageName[localeShort], localeShort)
|
LanguageBox.languageName[localeShort], localeShort)
|
||||||
elif locale.nativeLanguageName() == "":
|
|
||||||
self.addItem(localeShort, localeShort)
|
|
||||||
else:
|
else:
|
||||||
self.addItem(locale.nativeLanguageName(), localeShort)
|
locale = QtCore.QLocale(localeShort)
|
||||||
|
self.addItem(
|
||||||
|
locale.nativeLanguageName() or localeShort, localeShort)
|
||||||
|
|
||||||
configuredLocale = BMConfigParser().safeGet(
|
configuredLocale = BMConfigParser().safeGet(
|
||||||
'bitmessagesettings', 'userlocale', 'system')
|
'bitmessagesettings', 'userlocale', 'system')
|
||||||
|
|
|
@ -83,7 +83,6 @@ def avatarize(address):
|
||||||
"""
|
"""
|
||||||
idcon = QtGui.QIcon()
|
idcon = QtGui.QIcon()
|
||||||
icon_hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest()
|
icon_hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest()
|
||||||
str_broadcast_subscribers = '[Broadcast subscribers]'
|
|
||||||
if address == str_broadcast_subscribers:
|
if address == str_broadcast_subscribers:
|
||||||
# don't hash [Broadcast subscribers]
|
# don't hash [Broadcast subscribers]
|
||||||
icon_hash = address
|
icon_hash = address
|
||||||
|
|
Reference in New Issue
Block a user