X-Git-Url: http://git.maemo.org/git/?p=retroconv;a=blobdiff_plain;f=main.py;fp=main.py;h=5018484f45e10f8d8b1d224d37784aa9bbcc79d4;hp=aa102aab1f6e182e369c3b98fbdc374b0ae32c7a;hb=39b7e1e9a1d3e90acae7d9a300b849f5f9a202d8;hpb=e6f144ca963a86ab23ee5337750eba928d898406 diff --git a/main.py b/main.py index aa102aa..5018484 100644 --- a/main.py +++ b/main.py @@ -1,15 +1,19 @@ import sys from PyQt4.QtCore import * from PyQt4.QtGui import * -from csv_service import csvServ from models import * -#from windows import * from GUI.main_window import * from GUI.inbox_window import * from GUI.message_window import * from GUI.sent_window import * -# -msgs=csvServ("sms.csv", "sent.csv") +from csv_service import * +from notification_service import Notifier +#import gtk +""" +#from windows import * + + +""" def showInboxMessages(): #ui.stackedWidget.setCurrentIndex(1) @@ -22,7 +26,7 @@ def showSentMessages(): def showMsg(): #ui.stackedWidget.setCurrentIndex(2) msg = msgs.getMsg(inboxWindow.listView.currentIndex().row()) - print msg.getMsgText() + #print msg.getMsgText() inboxMsgWindow.msg_text.setText(msg.getMsgText()) inboxMsgWindow.msg_address.setText(msg.getSenderName()) inboxMsgWindow.msg_date.setText(msg.getDate()) @@ -80,6 +84,8 @@ def populateSent(): #for x in msgs.sentLst: #print x.getRecName() +msgs=csvServ() +notifier = Notifier() def init(): ################## Connect SIGNALS ####################### @@ -88,39 +94,130 @@ def init(): QObject.connect(mainWindow.sent_button, SIGNAL("clicked()"),showSentMessages) QObject.connect(inboxWindow.listView, SIGNAL("clicked(QModelIndex)"),showMsg) QObject.connect(sentWindow.listView, SIGNAL("clicked(QModelIndex)"),showSentMsg) + QObject.connect(mainWindow.actionImport, SIGNAL("triggered()"),showInboxDialog) + QObject.connect(mainWindow.actionImport_Sent, SIGNAL("triggered()"),showSentDialog) + QObject.connect(inboxDialog, SIGNAL("fileSelected(QString)"), importInbox) + QObject.connect(sentDialog, SIGNAL("fileSelected(QString)"), importSent) + + #QObject.connect(dialog, SIGNAL("fileSelected(QString)"), importInboxFile) #QObject.connect(ui.msg_back, SIGNAL("clicked()"),showInboxMessages) #QObject.connect(ui.sent_msg_back, SIGNAL("clicked()"),showSentMessages) #QObject.connect(ui.sentView, SIGNAL("clicked(QModelIndex)"),showSentMsg) ############################################################ + ############################################################ + + + + ############################################################ + ################# Other Init functions ##################### - populateInbox() - populateSent() + + fetch = False + + if msgs.hasImportedSent(): + fetch = True + msgs.fetchSent() + populateSent() + + if msgs.hasImportedInbox(): + fetch = True + msgs.fetchInbox() + populateInbox() + + if fetch: + msgs.fetchContactsInfo() + ########################################################### +#def showImportInboxFileDialog(): + #name = QFileDialog.getOpenFileName(None, "Open Image", "/home/user/", "Image Files (*.png *.jpg *.bmp)"); + #chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) + + +def importInbox(path): + if msgs.importInbox(path): + notifier.requestPatience() + + msgs.fetchContactsInfo() + populateInbox() + + notifier.showSuccess(len(msgs.recvLst)) + else: + notifier.showFailure() + +def importSent(path): + if msgs.importSent(path): + notifier.requestPatience() + + msgs.fetchContactsInfo() + populateSent() + + notifier.showSuccess(len(msgs.sentLst)) + else: + notifier.showFailure() + + +def showInboxDialog(): + if not msgs.hasImportedInbox() : + inboxDialog.open() + else: + print "Inbox is already Imported" + +def showSentDialog(): + if not msgs.hasImportedSent(): + sentDialog.open() + else: + print "Sent is already Imported" + if __name__ == '__main__': app = QApplication(sys.argv) #MainWindow = QtGui.QMainWindow() #ui = Ui_MainWindow() #ui.setupUi(MainWindow) #MainWindow.show() - + ####### Initialization ######### + mainWindow = Ui_MainWindow() inboxWindow = Ui_InboxWindow(mainWindow) sentWindow = Ui_SentWindow(mainWindow) inboxMsgWindow = Ui_MessageWindow(inboxWindow) sentMsgWindow = Ui_MessageWindow(sentWindow) + + + + inboxDialog = QFileDialog(mainWindow); + inboxDialog.setFilter("Recieved SMS CSV Files (*.csv)"); + inboxDialog.setViewMode(QFileDialog.List); + + sentDialog = QFileDialog(mainWindow); + sentDialog.setFilter("Sent SMS CSV Files (*.csv)"); + sentDialog.setViewMode(QFileDialog.List); + + + + + #mainWindow=QMainWindow() init() - + ################################ mainWindow.show() + + + ################################ + + #win = QMainWindow() + #win.show() + + #name = QFileDialog.getOpenFileName(None,"Open Image", "/home/user/", "Image Files (*.png *.jpg *.bmp)"); + sys.exit(app.exec_())