interface

This commit is contained in:
sbkaf 2015-03-19 18:25:50 +01:00
parent 505c5689c2
commit b86cf4b5cf
3 changed files with 121 additions and 9 deletions

View File

@ -202,7 +202,7 @@ class Main:
singleAPIThread.daemon = True # close the main program even if there are threads left
singleAPIThread.start()
connectToStream(1)
#connectToStream(1)
singleListenerThread = singleListener()
singleListenerThread.setup(selfInitiatedConnections)

View File

@ -555,10 +555,8 @@ class MyForm(QtGui.QMainWindow):
newSubItem.setText(0, _translate("MainWindow", "trash"))
# Load inbox from messages database file
self.loadInbox()
# Load Sent items from database
self.loadSent()
#self.loadInbox()
self.loadMessagelist("BM-2cTxBr9RxjorkjvkgTkD1AgjhUJBwDnVKY");
# Initialize the address book
self.rerenderAddressBook()
@ -889,6 +887,120 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetInbox.sortItems(3, Qt.DescendingOrder)
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent
# Load inbox from messages database file
def loadMessagelist(self, account, folder="inbox", where="", what=""):
what = "%" + what + "%"
if where == "To":
where = "toaddress"
elif where == "From":
where = "fromaddress"
elif where == "Subject":
where = "subject"
elif where == "Message":
where = "message"
else:
where = "toaddress || fromaddress || subject || message"
if folder == "sent":
accountaddress = "fromaddress"
else:
accountaddress = "toaddress"
sqlStatement = '''
SELECT msgid, toaddress, fromaddress, subject, received, read
FROM inbox WHERE %s=? AND folder=? AND %s LIKE ?
ORDER BY received
''' % (accounttype, where)
while self.ui.tableWidgetInbox.rowCount() > 0:
self.ui.tableWidgetInbox.removeRow(0)
font = QFont()
font.setBold(True)
queryreturn = sqlQuery(sqlStatement, account, folder, what)
for row in queryreturn:
msgid, toAddress, fromAddress, subject, received, read = row
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
try:
if toAddress == self.str_broadcast_subscribers:
toLabel = self.str_broadcast_subscribers
else:
toLabel = shared.config.get(toAddress, 'label')
except:
toLabel = ''
if toLabel == '':
toLabel = toAddress
fromLabel = ''
if shared.config.has_section(fromAddress):
fromLabel = shared.config.get(fromAddress, 'label')
if fromLabel == '': # If the fromAddress isn't one of our addresses and isn't a chan
queryreturn = sqlQuery(
'''select label from addressbook where address=?''', fromAddress)
if queryreturn != []:
for row in queryreturn:
fromLabel, = row
if fromLabel == '': # If this address wasn't in our address book...
queryreturn = sqlQuery(
'''select label from subscriptions where address=?''', fromAddress)
if queryreturn != []:
for row in queryreturn:
fromLabel, = row
if fromLabel == '':
fromLabel = fromAddress
# message row
self.ui.tableWidgetInbox.insertRow(0)
# to
to_item = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
to_item.setToolTip(unicode(toLabel, 'utf-8'))
to_item.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read:
to_item.setFont(font)
to_item.setData(Qt.UserRole, str(toAddress))
if shared.safeConfigGetBoolean(toAddress, 'mailinglist'):
to_item.setTextColor(QtGui.QColor(137, 04, 177)) # magenta
if shared.safeConfigGetBoolean(str(toAddress), 'chan'):
to_item.setTextColor(QtGui.QColor(216, 119, 0)) # orange
to_item.setIcon(avatarize(toAddress))
self.ui.tableWidgetInbox.setItem(0, 0, to_item)
# from
from_item = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
from_item.setToolTip(unicode(fromLabel, 'utf-8'))
from_item.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read:
from_item.setFont(font)
from_item.setData(Qt.UserRole, str(fromAddress))
if shared.safeConfigGetBoolean(str(fromAddress), 'chan'):
from_item.setTextColor(QtGui.QColor(216, 119, 0)) # orange
from_item.setIcon(avatarize(fromAddress))
self.ui.tableWidgetInbox.setItem(0, 1, from_item)
# subject
subject_item = QtGui.QTableWidgetItem(unicode(subject, 'utf-8'))
subject_item.setToolTip(unicode(subject, 'utf-8'))
subject_item.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read:
subject_item.setFont(font)
self.ui.tableWidgetInbox.setItem(0, 2, subject_item)
# time received
time_item = myTableWidgetItem(l10n.formatTimestamp(received))
time_item.setToolTip(l10n.formatTimestamp(received))
time_item.setData(Qt.UserRole, QByteArray(msgid))
time_item.setData(33, int(received))
time_item.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read:
time_item.setFont(font)
self.ui.tableWidgetInbox.setItem(0, 3, time_item)
self.ui.tableWidgetInbox.sortItems(3, Qt.DescendingOrder)
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent
# Load inbox from messages database file
def loadInbox(self, where="", what=""):
what = "%" + what + "%"
@ -3279,7 +3391,7 @@ class MyForm(QtGui.QMainWindow):
else:
message = "Error occurred: could not load message from disk."
message = unicode(message, 'utf-8)')
self.ui.textEditSentMessage.setPlainText(message)
self.ui.textEditInboxMessage.setPlainText(message)
def tableWidgetYourIdentitiesItemChanged(self):
currentRow = self.ui.tableWidgetYourIdentities.currentRow()

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'bmail.ui'
# Form implementation generated from reading ui file 'bitmessageui.ui'
#
# Created: Sun Mar 1 23:18:09 2015
# Created: Wed Mar 4 00:11:02 2015
# by: PyQt4 UI code generator 4.10.4
#
# WARNING! All changes made in this file will be lost!
@ -572,7 +572,7 @@ class Ui_MainWindow(object):
MainWindow.setTabOrder(self.tableWidgetConnectionCount, self.pushButtonStatusIcon)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "B-Mail", None))
MainWindow.setWindowTitle(_translate("MainWindow", "Bitmessage", None))
self.treeWidgetYourIdentities.headerItem().setText(0, _translate("MainWindow", "Identities", None))
self.pushButtonNewAddress.setText(_translate("MainWindow", "New Indentitiy", None))
self.inboxSearchLineEdit.setPlaceholderText(_translate("MainWindow", "Search", None))