class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) # codeCompletionBlock start from PyQt4.QtGui import QComboBox, QToolButton, QStackedWidget self.accountSelection = QComboBox() self.accountButton = QToolButton() self.accountStack = QStackedWidget() # codeCompletionBlock end uic.loadUi(getUiFile('MainWindow'), self) self.model = Model() self.model.loadLastSession() self.actionAdd_Account.triggered.connect(self.addSubAccount) self.accountSelection.currentIndexChanged.connect(self.accountStack.setCurrentIndex) def addSubAccount(self): data = inquireAccountData() account = self.model.createNewAccount(data['name'], data['description'], data['numbers']) self.model.addNewAccount(account) self.accountSelection.addItem(account.description) self.accountStack.addWidget(AccountWidget())
class Controller(QObject): def __init__(self, parent=None): super(Controller, self).__init__(parent) self.model = Model() self.createFactories() # self.view = MainWindow() # # self.view.show() def createFactories(self): self.bankFactory = BankFactory() self.accountFactory = AccountFactory() self.subaccountFactory = SubaccountFactory() self.correspondentFactory = CorrespondentFactory() self.transactionFactory = TransactionFactory() def getTransactions(self, account, start, end): pass def inquireAccountData(self): return {'name': 'Account A', 'description': 'genericAccount', 'numbers': {'account': 1, 'bank': 2, 'iban': 3, 'bic': 4}} def createNewAccount(self): data = self.inquireAccountData() account = Account(data['name'], data['description'], data['numbers']) self.model.addNewAccount(account) self.view.addNewAccount(account) def readCSV(self, csvpath): entries = csvreader.readStatement(csvpath) for entry in entries: cdata = dict( name=entry[CNAME], accountNumber=entry[CACCOUNT], bankCode=entry[CBANKCODE], iban=entry[CIBAN], bic=entry[CBIC]) correspondent = self.correspondentFactory.getCorrespondent(cdata) tdata = dict( account=entry[ACCOUNT], amount=entry[AMOUNT], purpose=entry[PURPOSE], correspondent=correspondent, issueDate=entry[ISSUEDATE], executionDate=entry[EXECDATE], accountingEntry=entry[ACCENTRY], info=entry[INFO]) self.transactionFactory.getTransaction(tdata)