2 from PyQt4.QtCore import *
3 from PyQt4.QtGui import *
5 from GUI.main_window import *
6 from GUI.inbox_window import *
7 from GUI.message_window import *
8 from GUI.sent_window import *
9 from csv_service import *
10 from notification_service import Notifier
13 #from windows import *
18 def showInboxMessages():
19 #ui.stackedWidget.setCurrentIndex(1)
22 def showSentMessages():
23 #ui.stackedWidget.setCurrentIndex(3)
27 #ui.stackedWidget.setCurrentIndex(2)
28 msg = msgs.getMsg(inboxWindow.listView.currentIndex().row())
29 #print msg.getMsgText()
30 inboxMsgWindow.msg_text.setText(msg.getMsgText())
31 inboxMsgWindow.msg_address.setText(msg.getSenderName())
32 inboxMsgWindow.msg_date.setText(msg.getDate())
34 #####################################
37 if msg.getImageData() == "":
38 inboxMsgWindow.frame.setPixmap(QPixmap("graphics/contact_trans_120.png"))
41 arr=QByteArray(msg.getImageData())
45 inboxMsgWindow.frame.setPixmap(img.scaled(120,120, Qt.KeepAspectRatioByExpanding))
51 #ui.stackedWidget.setCurrentIndex(4)
52 msg = msgs.getMsg(sentWindow.listView.currentIndex().row(), 1)
53 sentMsgWindow.msg_text.setText(msg.getMsgText())
54 sentMsgWindow.msg_address.setText(msg.getRecName())
55 sentMsgWindow.msg_date.setText(msg.getDate())
57 #####################################
59 if msg.getImageData() == "":
60 sentMsgWindow.frame.setPixmap(QPixmap("graphics/contact_trans_120.png"))
62 arr=QByteArray(msg.getImageData())
66 sentMsgWindow.frame.setPixmap(img.scaled(120,120, Qt.KeepAspectRatioByExpanding))
71 #allSenders=msgs.getAllSenders()
74 recvModel=RecvModel(msgs.recvLst)
75 inboxWindow.listView.setModel(recvModel)
78 #allSenders=msgs.getAllSenders()
81 sentModel=SentModel(msgs.sentLst)
82 sentWindow.listView.setModel(sentModel)
84 #for x in msgs.sentLst:
91 ################## Connect SIGNALS #######################
93 QObject.connect(mainWindow.inbox_button, SIGNAL("clicked()"), showInboxMessages)
94 QObject.connect(mainWindow.sent_button, SIGNAL("clicked()"),showSentMessages)
95 QObject.connect(inboxWindow.listView, SIGNAL("clicked(QModelIndex)"),showMsg)
96 QObject.connect(sentWindow.listView, SIGNAL("clicked(QModelIndex)"),showSentMsg)
97 QObject.connect(mainWindow.actionImport, SIGNAL("triggered()"),showInboxDialog)
98 QObject.connect(mainWindow.actionImport_Sent, SIGNAL("triggered()"),showSentDialog)
99 QObject.connect(inboxDialog, SIGNAL("fileSelected(QString)"), importInbox)
100 QObject.connect(sentDialog, SIGNAL("fileSelected(QString)"), importSent)
102 #QObject.connect(dialog, SIGNAL("fileSelected(QString)"), importInboxFile)
103 #QObject.connect(ui.msg_back, SIGNAL("clicked()"),showInboxMessages)
104 #QObject.connect(ui.sent_msg_back, SIGNAL("clicked()"),showSentMessages)
105 #QObject.connect(ui.sentView, SIGNAL("clicked(QModelIndex)"),showSentMsg)
107 ############################################################
109 ############################################################
113 ############################################################
115 ################# Other Init functions #####################
120 if msgs.hasImportedSent():
125 if msgs.hasImportedInbox():
131 msgs.fetchContactsInfo()
134 ###########################################################
136 #def showImportInboxFileDialog():
137 #name = QFileDialog.getOpenFileName(None, "Open Image", "/home/user/", "Image Files (*.png *.jpg *.bmp)");
138 #chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
141 def importInbox(path):
142 if msgs.importInbox(path):
143 notifier.requestPatience()
145 msgs.fetchContactsInfo()
148 notifier.showSuccess(len(msgs.recvLst))
150 notifier.showFailure()
152 def importSent(path):
153 if msgs.importSent(path):
154 notifier.requestPatience()
156 msgs.fetchContactsInfo()
159 notifier.showSuccess(len(msgs.sentLst))
161 notifier.showFailure()
164 def showInboxDialog():
165 if not msgs.hasImportedInbox() :
168 res = QMessageBox.question(mainWindow, "Retro Conversations",
169 "This will overwrite previously imported Inbox SMS. Proceed?", QMessageBox.Yes | QMessageBox.No);
171 if res == QMessageBox.Yes:
174 def showSentDialog():
175 if not msgs.hasImportedSent():
178 res = QMessageBox.question(mainWindow, "Retro Conversations",
179 "This will overwrite previously imported Sent SMS. Proceed?", QMessageBox.Yes | QMessageBox.No);
181 if res == QMessageBox.Yes:
184 if __name__ == '__main__':
185 app = QApplication(sys.argv)
186 #MainWindow = QtGui.QMainWindow()
187 #ui = Ui_MainWindow()
188 #ui.setupUi(MainWindow)
191 ####### Initialization #########
193 mainWindow = Ui_MainWindow()
194 inboxWindow = Ui_InboxWindow(mainWindow)
195 sentWindow = Ui_SentWindow(mainWindow)
196 inboxMsgWindow = Ui_MessageWindow(inboxWindow)
197 sentMsgWindow = Ui_MessageWindow(sentWindow)
201 inboxDialog = QFileDialog(mainWindow);
202 inboxDialog.setFilter("Recieved SMS CSV Files (*.csv)");
203 inboxDialog.setViewMode(QFileDialog.List);
205 sentDialog = QFileDialog(mainWindow);
206 sentDialog.setFilter("Sent SMS CSV Files (*.csv)");
207 sentDialog.setViewMode(QFileDialog.List);
213 #mainWindow=QMainWindow()
216 ################################
222 ################################
227 #name = QFileDialog.getOpenFileName(None,"Open Image", "/home/user/", "Image Files (*.png *.jpg *.bmp)");
229 sys.exit(app.exec_())