Beispiel #1
0
class Main(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(Main, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.mymodel = MyModel()
        self.sortModel = QtGui.QSortFilterProxyModel()
        self.sortModel.setDynamicSortFilter(True)
        self.sortModel.setSourceModel(self.mymodel)
        self.ui.transactionsList.setModel(self.sortModel)
        self.ui.transactionsList.setSortingEnabled(True)

    def on_payeeFilter_editingFinished(self):
        self.mymodel.doreset()
Beispiel #2
0
class Main(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(Main, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.db = db.Db('t.db')

        self.ui.filters.setDb(self.db)

        self.model = TransactionsListModel(self.db, self.ui.filters)
        self.ui.transactionsList.setModel(self.model)

        # connect events
        self.ui.filters.filtersChanged.connect(self.model.on_filtersChanged)

        # load data
        self.model.updateTransactionsList()
Beispiel #3
0
    def __init__(self, parent=None):
        super(Main, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.db = db.Db('t.db')

        self.model = TransactionsViewModel(self.db)
        self.ui.transactionsList.setModel(self.model)
        #self.ui.transactionsList.current = None
        self.show_accounts()
Beispiel #4
0
    def __init__(self, parent=None):
        super(Main, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.mymodel = MyModel()
        self.sortModel = QtGui.QSortFilterProxyModel()
        self.sortModel.setDynamicSortFilter(True)
        self.sortModel.setSourceModel(self.mymodel)
        self.ui.transactionsList.setModel(self.sortModel)
        self.ui.transactionsList.setSortingEnabled(True)
Beispiel #5
0
class Main(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(Main, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.db = db.Db('t.db')

        self.model = TransactionsViewModel(self.db)
        self.ui.transactionsList.setModel(self.model)
        #self.ui.transactionsList.current = None
        self.show_accounts()

    def show_accounts(self):
        items = []
        for a in self.db.query(schema.Account).order_by(schema.Account.name):
            i = QtGui.QTreeWidgetItem(map(str, [a.nick, a.number, a.name]))
            i.db_item = a
            items.append(i)

        self.ui.accountsList.clear()
        self.ui.accountsList.addTopLevelItems(items)

    def show_transactions(self, acc):
        if acc == self.ui.transactionsList.current:
            return
        self.ui.transactionsList.current = acc
        items = []
        for t in self.get_data(acc):
            if hasattr(t, 'amount'):
                i = QtGui.QTreeWidgetItem(
                        map(unicode, [t.amount, t.payee, t.date, t.category_id]))
                i.db_item = t
            else:
                i = QtGui.QTreeWidgetItem(
                        map(unicode, ['Balance', t.balance, t.date]))
            items.append(i)

        self.ui.transactionsList.clear()
        self.ui.transactionsList.addTopLevelItems(items)

## FIXME: mix transactions and balances
    #def get_data(self, acc):
        #tn = schema.Transaction
        #bn = schema.Balance
        #tns = self.db.query(tn).filter_by(account_id = acc)\
                #.order_by(tn.date.desc(), tn.payee, tn.amount).all()
        #bns = self.db.query(bn).filter_by(account_id = acc)\
                #.order_by(bn.date.desc()).all()
        #while len(tns) != 0 or len(bns) != 0:
            #if len(tns) == 0:
                #yield bns.pop(0)
            #elif len(bns) == 0:
                #yield tns.pop(0)
            #elif bns[0].date >= tns[0].date:
                #yield bns.pop(0)
            #else:
                #yield tns.pop(0)

    def on_accountsList_currentItemChanged(self, current=None, prev=None):
        if current is None:
            return
        self.model.set_account(current.db_item.id)

    def on_payeeFilter_editingFinished(self):
        self.model.set_filter(str(self.ui.payeeFilter.text()))