working table

This commit is contained in:
Rinaldus 2016-07-26 06:03:10 +03:00
parent ee0cb9b7de
commit ee2d66c8c8
Signed by: Rinaldus
GPG Key ID: CB02A5190B0EC070
3 changed files with 62 additions and 14 deletions

View File

@ -266,11 +266,62 @@ class Details(QDialog):
self.ui = Ui_Details()
self.ui.setupUi(self)
self.ui.btnRefresh.clicked.connect(self.Refresh_clicked)
def closeEvent(self, event):
event.ignore()
self.hide()
def Refresh_clicked(self):
mail_count = 0
AllFroms=[]
AllSubjs=[]
AllDates=[]
if (GlobalSettingsExist() and AccountExist()):
m = Mail()
groups = settings.childGroups()
for i in range (len(groups)):
settings.beginGroup(groups[i])
group = groups[i]
user = settings.value("Login")
password = settings.value("Password")
mailserver = settings.value("MailServer")
port = settings.value("Port")
ssl = settings.value("SSL")
settings.endGroup()
if m.login(mailserver,port,user,password,ssl):
if (mail_count == "ERROR" or m.checkMail() == "ERROR"):
mail_count = "ERROR"
else:
mail_count += m.checkMail()
AllFroms.extend(m.parseMail("From"))
AllSubjs.extend(m.parseMail("Subject"))
AllDates.extend(m.parseMail("Date"))
else:
mail_count = "CONNECTION_ERROR"
else:
mail_count = "CONFIGURATION_ERROR"
data = {"From":AllFroms,
"Subject":AllSubjs,
"Date":AllDates,}
self.ui.tableWidget.setRowCount(len(AllFroms))
self.ui.tableWidget.setColumnCount(3)
#Enter data onto Table
horHeaders = []
for n, key in enumerate(sorted(data.keys())):
#print(data.keys())
horHeaders.append(key)
for m, item in enumerate(data[key]):
newitem = QtWidgets.QTableWidgetItem(item)
self.ui.tableWidget.setItem(m, n, newitem)
#Add Header
self.ui.tableWidget.setHorizontalHeaderLabels(horHeaders)
#Adjust size of Table
self.ui.tableWidget.resizeColumnsToContents()
self.ui.tableWidget.resizeRowsToContents()
# Common functions
@ -338,9 +389,6 @@ def mail_check():
mail_count = "ERROR"
else:
mail_count += m.checkMail()
print("FROM:",m.parseMail("From"))
print("SUBJECT:",m.parseMail("Subject"))
print("DATE:",m.parseMail("Date"))
else:
mail_count = "CONNECTION_ERROR"
else:

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>467</height>
<width>1048</width>
<height>619</height>
</rect>
</property>
<property name="windowTitle">
@ -19,7 +19,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="pushButton">
<widget class="QPushButton" name="btnRefresh">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>

View File

@ -11,23 +11,23 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Details(object):
def setupUi(self, Details):
Details.setObjectName("Details")
Details.resize(730, 467)
Details.resize(1048, 619)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/mailbox_empty.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
Details.setWindowIcon(icon)
self.verticalLayout_2 = QtWidgets.QVBoxLayout(Details)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.pushButton = QtWidgets.QPushButton(Details)
self.btnRefresh = QtWidgets.QPushButton(Details)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
self.pushButton.setSizePolicy(sizePolicy)
sizePolicy.setHeightForWidth(self.btnRefresh.sizePolicy().hasHeightForWidth())
self.btnRefresh.setSizePolicy(sizePolicy)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/icons/check_now.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon1)
self.pushButton.setObjectName("pushButton")
self.verticalLayout_2.addWidget(self.pushButton)
self.btnRefresh.setIcon(icon1)
self.btnRefresh.setObjectName("btnRefresh")
self.verticalLayout_2.addWidget(self.btnRefresh)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.tableWidget = QtWidgets.QTableWidget(Details)
@ -43,6 +43,6 @@ class Ui_Details(object):
def retranslateUi(self, Details):
_translate = QtCore.QCoreApplication.translate
Details.setWindowTitle(_translate("Details", "Mail Notifier"))
self.pushButton.setText(_translate("Details", "Refresh"))
self.btnRefresh.setText(_translate("Details", "Refresh"))
import resources_rc