Initial Project Commit
[retroconv] / bak / main.py
1 from PyQt4.QtCore import *
2 from PyQt4.QtGui import *
3 from csv_service import csvServ
4 from sent_model import *
5 from windows import *
6         
7 msgs=csvServ("sms.csv", "sent.csv")
8
9
10 def showInboxMessages():
11         ui.stackedWidget.setCurrentIndex(1)
12
13 def showSentMessages():
14         ui.stackedWidget.setCurrentIndex(3)
15         
16         
17 def showMsg():
18         ui.stackedWidget.setCurrentIndex(2)
19         msg = msgs.getMsg(ui.listView.currentRow())
20         ui.msg_text.setText(msg.getMsgText())
21         ui.msg_from.setText(msg.getSenderName())
22         ui.msg_date.setText(msg.getDate())
23
24
25 def showSentMsg():
26         ui.stackedWidget.setCurrentIndex(4)
27         msg = msgs.getMsg(ui.sentView.currentIndex().row(), 1)
28         ui.sent_msg_text.setText(msg.getMsgText())
29         ui.sent_msg_to.setText(msg.getRecName())
30         ui.sent_msg_date.setText(msg.getDate())
31         
32         #####################################
33         
34         arr=QByteArray(msg.getImageData())
35         img = QPixmap()
36         img.loadFromData(arr)
37         
38         ui.frame.setPixmap(img.scaled(100,100))
39         
40 def populateInbox():
41         #allSenders=msgs.getAllSenders()
42         #for x in allSenders:
43         
44         for x in msgs.recvLst:
45                 ui.listView.addItem(x.getSenderName())
46                 
47 def populateSent():
48         #allSenders=msgs.getAllSenders()
49         #for x in allSenders:
50         
51         sentModel=SentModel(msgs.sentLst)
52         ui.sentView.setModel(sentModel)
53         
54         #for x in msgs.sentLst:
55                 #print x.getRecName()
56         
57
58 def init():
59         
60         ################## Connect SIGNALS #######################
61         
62         QObject.connect(ui.inboxButton, SIGNAL("clicked()"),showInboxMessages)
63         QObject.connect(ui.sentButton, SIGNAL("clicked()"),showSentMessages)
64         QObject.connect(ui.listView, SIGNAL("itemClicked(QListWidgetItem*)"),showMsg)
65         QObject.connect(ui.msg_back, SIGNAL("clicked()"),showInboxMessages)
66         QObject.connect(ui.sent_msg_back, SIGNAL("clicked()"),showSentMessages)
67         QObject.connect(ui.sentView, SIGNAL("clicked(QModelIndex)"),showSentMsg)
68         
69         ############################################################
70         
71         ################# Other Init functions #####################
72         
73         populateInbox()
74         populateSent()
75         
76         ###########################################################
77
78 import sys
79 app = QtGui.QApplication(sys.argv)
80 MainWindow = QtGui.QMainWindow()
81 ui = Ui_MainWindow()
82 ui.setupUi(MainWindow)
83 MainWindow.show()
84
85 ####### Initialization #########
86
87 init()
88
89 ################################
90
91 sys.exit(app.exec_())
92
93
94
95