@@ -533,7 +533,7 @@ def rerenderTabTree(self, tab):
533
533
try :
534
534
subwidget .setUnreadCount (
535
535
db [toAddress ][subwidget .folderName ])
536
- if subwidget .folderName not in [ "new" , "trash" , "sent" ] :
536
+ if subwidget .folderName not in ( "new" , "trash" , "sent" ) :
537
537
unread += db [toAddress ][subwidget .folderName ]
538
538
db [toAddress ].pop (subwidget .folderName , None )
539
539
except :
@@ -549,7 +549,7 @@ def rerenderTabTree(self, tab):
549
549
if toAddress is not None and tab == 'messages' and folder == "new" :
550
550
continue
551
551
subwidget = Ui_FolderWidget (widget , j , toAddress , f , c )
552
- if subwidget .folderName not in [ "new" , "trash" , "sent" ] :
552
+ if subwidget .folderName not in ( "new" , "trash" , "sent" ) :
553
553
unread += c
554
554
j += 1
555
555
widget .setUnreadCount (unread )
@@ -565,7 +565,7 @@ def rerenderTabTree(self, tab):
565
565
if toAddress is not None and tab == 'messages' and folder == "new" :
566
566
continue
567
567
subwidget = Ui_FolderWidget (widget , j , toAddress , folder , db [toAddress ][folder ])
568
- if subwidget .folderName not in [ "new" , "trash" , "sent" ] :
568
+ if subwidget .folderName not in ( "new" , "trash" , "sent" ) :
569
569
unread += db [toAddress ][folder ]
570
570
j += 1
571
571
widget .setUnreadCount (unread )
@@ -934,14 +934,17 @@ def updateUnreadStatus(self, widget, row, msgid, unread=True):
934
934
for col in (0 , 1 , 2 ):
935
935
related .item (rrow , col ).setUnread (not status )
936
936
937
- def propagateUnreadCount (self , address = None , folder = "inbox" , widget = None , type = 1 ):
938
- widgets = [self .ui .treeWidgetYourIdentities , self .ui .treeWidgetSubscriptions , self .ui .treeWidgetChans ]
937
+ def propagateUnreadCount (
938
+ self , address = None , folder = "inbox" , widget = None , type = 1 ):
939
+ widgets = (
940
+ self .ui .treeWidgetYourIdentities ,
941
+ self .ui .treeWidgetSubscriptions , self .ui .treeWidgetChans )
939
942
queryReturn = sqlQuery ("SELECT toaddress, folder, COUNT(msgid) AS cnt FROM inbox WHERE read = 0 GROUP BY toaddress, folder" )
940
943
totalUnread = {}
941
944
normalUnread = {}
942
945
for row in queryReturn :
943
946
normalUnread [row [0 ]] = {}
944
- if row [1 ] in [ "trash" ] :
947
+ if row [1 ] == "trash" :
945
948
continue
946
949
normalUnread [row [0 ]][row [1 ]] = row [2 ]
947
950
if row [1 ] in totalUnread :
@@ -953,7 +956,7 @@ def propagateUnreadCount(self, address = None, folder = "inbox", widget = None,
953
956
for row in queryReturn :
954
957
broadcastsUnread [row [0 ]] = {}
955
958
broadcastsUnread [row [0 ]][row [1 ]] = row [2 ]
956
-
959
+
957
960
for treeWidget in widgets :
958
961
root = treeWidget .invisibleRootItem ()
959
962
for i in range (root .childCount ()):
@@ -1908,10 +1911,10 @@ def addRow(address, label, type):
1908
1911
for address in sorted (
1909
1912
oldRows , key = lambda x : oldRows [x ][2 ], reverse = True
1910
1913
):
1911
- if address in newRows :
1914
+ try :
1912
1915
completerList .append (
1913
1916
newRows .pop (address )[0 ] + " <" + address + ">" )
1914
- else :
1917
+ except KeyError :
1915
1918
self .ui .tableWidgetAddressBook .removeRow (oldRows [address ][2 ])
1916
1919
for address in newRows :
1917
1920
addRow (address , newRows [address ][0 ], newRows [address ][1 ])
@@ -1985,13 +1988,12 @@ def click_pushButtonSend(self):
1985
1988
1986
1989
# To send a message to specific people (rather than broadcast)
1987
1990
if sendMessageToPeople :
1988
- toAddressesList = [
1991
+ toAddressesList = set ( [
1989
1992
s .strip () for s in toAddresses .replace (',' , ';' ).split (';' )
1990
- ]
1993
+ ])
1991
1994
# remove duplicate addresses. If the user has one address
1992
1995
# with a BM- and the same address without the BM-, this will
1993
1996
# not catch it. They'll send the message to the person twice.
1994
- toAddressesList = list (set (toAddressesList ))
1995
1997
for toAddress in toAddressesList :
1996
1998
if toAddress != '' :
1997
1999
# label plus address
@@ -2238,7 +2240,7 @@ def click_pushButtonSend(self):
2238
2240
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''' , * t )
2239
2241
2240
2242
toLabel = str_broadcast_subscribers
2241
-
2243
+
2242
2244
self .displayNewSentMessage (
2243
2245
toAddress , toLabel , fromAddress , subject , message , ackdata )
2244
2246
@@ -2339,25 +2341,42 @@ def rerenderComboBoxSendFromBroadcast(self):
2339
2341
# receives a message to an address that is acting as a
2340
2342
# pseudo-mailing-list. The message will be broadcast out. This function
2341
2343
# puts the message on the 'Sent' tab.
2342
- def displayNewSentMessage (self , toAddress , toLabel , fromAddress , subject , message , ackdata ):
2344
+ def displayNewSentMessage (
2345
+ self , toAddress , toLabel , fromAddress , subject ,
2346
+ message , ackdata ):
2343
2347
acct = accountClass (fromAddress )
2344
2348
acct .parseMessage (toAddress , fromAddress , subject , message )
2345
2349
tab = - 1
2346
- for sent in [self .ui .tableWidgetInbox , self .ui .tableWidgetInboxSubscriptions , self .ui .tableWidgetInboxChans ]:
2350
+ for sent in (
2351
+ self .ui .tableWidgetInbox ,
2352
+ self .ui .tableWidgetInboxSubscriptions ,
2353
+ self .ui .tableWidgetInboxChans
2354
+ ):
2347
2355
tab += 1
2348
2356
if tab == 1 :
2349
2357
tab = 2
2350
2358
treeWidget = self .widgetConvert (sent )
2351
2359
if self .getCurrentFolder (treeWidget ) != "sent" :
2352
2360
continue
2353
- if treeWidget == self .ui .treeWidgetYourIdentities and self .getCurrentAccount (treeWidget ) not in (fromAddress , None , False ):
2361
+ if treeWidget == self .ui .treeWidgetYourIdentities \
2362
+ and self .getCurrentAccount (treeWidget ) not in (
2363
+ fromAddress , None , False ):
2354
2364
continue
2355
- elif treeWidget in [self .ui .treeWidgetSubscriptions , self .ui .treeWidgetChans ] and self .getCurrentAccount (treeWidget ) != toAddress :
2365
+ elif treeWidget in (
2366
+ self .ui .treeWidgetSubscriptions ,
2367
+ self .ui .treeWidgetChans
2368
+ ) and self .getCurrentAccount (treeWidget ) != toAddress :
2356
2369
continue
2357
- elif not helper_search .check_match (toAddress , fromAddress , subject , message , self .getCurrentSearchOption (tab ), self .getCurrentSearchLine (tab )):
2370
+ elif not helper_search .check_match (
2371
+ toAddress , fromAddress , subject , message ,
2372
+ self .getCurrentSearchOption (tab ),
2373
+ self .getCurrentSearchLine (tab )
2374
+ ):
2358
2375
continue
2359
2376
2360
- self .addMessageListItemSent (sent , toAddress , fromAddress , subject , "msgqueued" , ackdata , time .time ())
2377
+ self .addMessageListItemSent (
2378
+ sent , toAddress , fromAddress , subject , "msgqueued" ,
2379
+ ackdata , time .time ())
2361
2380
self .getAccountTextedit (acct ).setPlainText (message )
2362
2381
sent .setCurrentCell (0 , 0 )
2363
2382
@@ -2370,11 +2389,11 @@ def displayNewInboxMessage(
2370
2389
inbox = self .getAccountMessagelist (acct )
2371
2390
ret = None
2372
2391
tab = - 1
2373
- for treeWidget in [
2392
+ for treeWidget in (
2374
2393
self .ui .treeWidgetYourIdentities ,
2375
2394
self .ui .treeWidgetSubscriptions ,
2376
2395
self .ui .treeWidgetChans
2377
- ] :
2396
+ ) :
2378
2397
tab += 1
2379
2398
if tab == 1 :
2380
2399
tab = 2
@@ -2389,15 +2408,15 @@ def displayNewInboxMessage(
2389
2408
if tableWidget == inbox \
2390
2409
and self .getCurrentAccount (treeWidget ) == acct .address \
2391
2410
and self .getCurrentFolder (treeWidget ) \
2392
- in [ "inbox" , None ] :
2411
+ in ( "inbox" , None ) :
2393
2412
ret = self .addMessageListItemInbox (
2394
2413
inbox , "inbox" , inventoryHash , toAddress , fromAddress ,
2395
2414
subject , time .time (), 0
2396
2415
)
2397
2416
elif treeWidget == self .ui .treeWidgetYourIdentities \
2398
2417
and self .getCurrentAccount (treeWidget ) is None \
2399
2418
and self .getCurrentFolder (treeWidget ) \
2400
- in [ "inbox" , "new" , None ] :
2419
+ in ( "inbox" , "new" , None ) :
2401
2420
ret = self .addMessageListItemInbox (
2402
2421
tableWidget , "inbox" , inventoryHash , toAddress ,
2403
2422
fromAddress , subject , time .time (), 0
@@ -3129,8 +3148,11 @@ def setSendFromComboBox(self, address=None):
3129
3148
currentInboxRow = messagelist .currentRow ()
3130
3149
address = messagelist .item (
3131
3150
currentInboxRow , 0 ).address
3132
- for box in [self .ui .comboBoxSendFrom , self .ui .comboBoxSendFromBroadcast ]:
3133
- listOfAddressesInComboBoxSendFrom = [str (box .itemData (i )) for i in range (box .count ())]
3151
+ for box in (
3152
+ self .ui .comboBoxSendFrom , self .ui .comboBoxSendFromBroadcast
3153
+ ):
3154
+ listOfAddressesInComboBoxSendFrom = [
3155
+ str (box .itemData (i )) for i in range (box .count ())]
3134
3156
if address in listOfAddressesInComboBoxSendFrom :
3135
3157
currentIndex = listOfAddressesInComboBoxSendFrom .index (address )
3136
3158
box .setCurrentIndex (currentIndex )
@@ -3240,7 +3262,7 @@ def on_action_InboxReply(self, replyType=None):
3240
3262
quotedText = self .quoted_text (
3241
3263
unicode (messageAtCurrentInboxRow , 'utf-8' , 'replace' ))
3242
3264
widget ['message' ].setPlainText (quotedText )
3243
- if acct .subject [0 :3 ] in [ 'Re:' , 'RE:' ] :
3265
+ if acct .subject [0 :3 ] in ( 'Re:' , 'RE:' ) :
3244
3266
widget ['subject' ].setText (
3245
3267
tableWidget .item (currentInboxRow , 2 ).label )
3246
3268
else :
@@ -3887,12 +3909,11 @@ def on_action_ClipboardMessagelist(self):
3887
3909
tableWidget = self .getCurrentMessagelist ()
3888
3910
currentColumn = tableWidget .currentColumn ()
3889
3911
currentRow = tableWidget .currentRow ()
3912
+ currentFolder = self .getCurrentFolder ()
3890
3913
if currentColumn not in (0 , 1 , 2 ): # to, from, subject
3891
- if self .getCurrentFolder () == "sent" :
3892
- currentColumn = 0
3893
- else :
3894
- currentColumn = 1
3895
- if self .getCurrentFolder () == "sent" :
3914
+ currentColumn = 0 if currentFolder == "sent" else 1
3915
+
3916
+ if currentFolder == "sent" :
3896
3917
myAddress = tableWidget .item (currentRow , 1 ).data (QtCore .Qt .UserRole )
3897
3918
otherAddress = tableWidget .item (currentRow , 0 ).data (QtCore .Qt .UserRole )
3898
3919
else :
@@ -3906,7 +3927,7 @@ def on_action_ClipboardMessagelist(self):
3906
3927
text = tableWidget .item (currentRow , currentColumn ).label
3907
3928
else :
3908
3929
text = tableWidget .item (currentRow , currentColumn ).data (QtCore .Qt .UserRole )
3909
- # text = unicode(str(text), 'utf-8', 'ignore')
3930
+
3910
3931
clipboard = QtWidgets .QApplication .clipboard ()
3911
3932
clipboard .setText (text )
3912
3933
0 commit comments