Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/models/ledgermodel.cpp
Context not available. | |||||
34 | // Project Includes | 34 | // Project Includes | ||
---|---|---|---|---|---|
35 | 35 | | |||
36 | #include "mymoneytransaction.h" | 36 | #include "mymoneytransaction.h" | ||
37 | #include "mymoneytransactionfilter.h" | ||||
37 | #include "mymoneyfile.h" | 38 | #include "mymoneyfile.h" | ||
39 | #include "mymoneypayee.h" | ||||
38 | #include "mymoneymoney.h" | 40 | #include "mymoneymoney.h" | ||
39 | #include "kmymoneyutils.h" | 41 | #include "kmymoneyutils.h" | ||
40 | #include "kmymoneyglobalsettings.h" | 42 | #include "kmymoneyglobalsettings.h" | ||
43 | #include "mymoneyenums.h" | ||||
44 | | ||||
45 | using namespace eMyMoney; | ||||
41 | 46 | | |||
42 | LedgerItem::LedgerItem() | 47 | LedgerItem::LedgerItem() | ||
43 | { | 48 | { | ||
Context not available. | |||||
281 | LedgerSortFilterProxyModel::LedgerSortFilterProxyModel(QObject* parent) | 286 | LedgerSortFilterProxyModel::LedgerSortFilterProxyModel(QObject* parent) | ||
282 | : QSortFilterProxyModel(parent) | 287 | : QSortFilterProxyModel(parent) | ||
283 | , m_showNewTransaction(false) | 288 | , m_showNewTransaction(false) | ||
284 | , m_accountType(MyMoneyAccount::Asset) | 289 | , m_accountType(Account::Asset) | ||
285 | { | 290 | { | ||
286 | setFilterRole(LedgerRole::AccountIdRole); | 291 | setFilterRole(LedgerRole::AccountIdRole); | ||
287 | setFilterKeyColumn(0); | 292 | setFilterKeyColumn(0); | ||
Context not available. | |||||
293 | { | 298 | { | ||
294 | } | 299 | } | ||
295 | 300 | | |||
296 | void LedgerSortFilterProxyModel::setAccountType(MyMoneyAccount::accountTypeE type) | 301 | void LedgerSortFilterProxyModel::setAccountType(Account type) | ||
297 | { | 302 | { | ||
298 | m_accountType = type; | 303 | m_accountType = type; | ||
299 | } | 304 | } | ||
Context not available. | |||||
304 | switch(section) { | 309 | switch(section) { | ||
305 | case LedgerModel::PaymentColumn: | 310 | case LedgerModel::PaymentColumn: | ||
306 | switch(m_accountType) { | 311 | switch(m_accountType) { | ||
307 | case MyMoneyAccount::CreditCard: | 312 | case Account::CreditCard: | ||
308 | return i18nc("Payment made with credit card", "Charge"); | 313 | return i18nc("Payment made with credit card", "Charge"); | ||
309 | 314 | | |||
310 | case MyMoneyAccount::Asset: | 315 | case Account::Asset: | ||
311 | case MyMoneyAccount::AssetLoan: | 316 | case Account::AssetLoan: | ||
312 | return i18nc("Decrease of asset/liability value", "Decrease"); | 317 | return i18nc("Decrease of asset/liability value", "Decrease"); | ||
313 | 318 | | |||
314 | case MyMoneyAccount::Liability: | 319 | case Account::Liability: | ||
315 | case MyMoneyAccount::Loan: | 320 | case Account::Loan: | ||
316 | return i18nc("Increase of asset/liability value", "Increase"); | 321 | return i18nc("Increase of asset/liability value", "Increase"); | ||
317 | 322 | | |||
318 | case MyMoneyAccount::Income: | 323 | case Account::Income: | ||
319 | case MyMoneyAccount::Expense: | 324 | case Account::Expense: | ||
320 | return i18n("Income"); | 325 | return i18n("Income"); | ||
321 | 326 | | |||
322 | default: | 327 | default: | ||
Context not available. | |||||
326 | 331 | | |||
327 | case LedgerModel::DepositColumn: | 332 | case LedgerModel::DepositColumn: | ||
328 | switch(m_accountType) { | 333 | switch(m_accountType) { | ||
329 | case MyMoneyAccount::CreditCard: | 334 | case Account::CreditCard: | ||
330 | return i18nc("Payment towards credit card", "Payment"); | 335 | return i18nc("Payment towards credit card", "Payment"); | ||
331 | 336 | | |||
332 | case MyMoneyAccount::Asset: | 337 | case Account::Asset: | ||
333 | case MyMoneyAccount::AssetLoan: | 338 | case Account::AssetLoan: | ||
334 | return i18nc("Increase of asset/liability value", "Increase"); | 339 | return i18nc("Increase of asset/liability value", "Increase"); | ||
335 | 340 | | |||
336 | case MyMoneyAccount::Liability: | 341 | case Account::Liability: | ||
337 | case MyMoneyAccount::Loan: | 342 | case Account::Loan: | ||
338 | return i18nc("Decrease of asset/liability value", "Decrease"); | 343 | return i18nc("Decrease of asset/liability value", "Decrease"); | ||
339 | 344 | | |||
340 | case MyMoneyAccount::Income: | 345 | case Account::Income: | ||
341 | case MyMoneyAccount::Expense: | 346 | case Account::Expense: | ||
342 | return i18n("Expense"); | 347 | return i18n("Expense"); | ||
343 | 348 | | |||
344 | default: | 349 | default: | ||
Context not available. | |||||
435 | { | 440 | { | ||
436 | MyMoneyFile* file = MyMoneyFile::instance(); | 441 | MyMoneyFile* file = MyMoneyFile::instance(); | ||
437 | 442 | | |||
438 | connect(file, SIGNAL(objectAdded(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(addTransaction(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); | 443 | connect(file, SIGNAL(objectAdded(File::Object,MyMoneyObject*const)), this, SLOT(addTransaction(File::Object,MyMoneyObject*const))); | ||
439 | connect(file, SIGNAL(objectModified(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(modifyTransaction(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); | 444 | connect(file, SIGNAL(objectModified(File::Object,MyMoneyObject*const)), this, SLOT(modifyTransaction(File::Object,MyMoneyObject*const))); | ||
440 | connect(file, SIGNAL(objectRemoved(MyMoneyFile::notificationObjectT,QString)), this, SLOT(removeTransaction(MyMoneyFile::notificationObjectT,QString))); | 445 | connect(file, SIGNAL(objectRemoved(File::Object,QString)), this, SLOT(removeTransaction(File::Object,QString))); | ||
441 | 446 | | |||
442 | connect(file, SIGNAL(objectAdded(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(addSchedule(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); | 447 | connect(file, SIGNAL(objectAdded(File::Object,MyMoneyObject*const)), this, SLOT(addSchedule(File::Object,MyMoneyObject*const))); | ||
443 | connect(file, SIGNAL(objectModified(MyMoneyFile::notificationObjectT,MyMoneyObject*const)), this, SLOT(modifySchedule(MyMoneyFile::notificationObjectT,MyMoneyObject*const))); | 448 | connect(file, SIGNAL(objectModified(File::Object,MyMoneyObject*const)), this, SLOT(modifySchedule(File::Object,MyMoneyObject*const))); | ||
444 | connect(file, SIGNAL(objectRemoved(MyMoneyFile::notificationObjectT,QString)), this, SLOT(removeSchedule(MyMoneyFile::notificationObjectT,QString))); | 449 | connect(file, SIGNAL(objectRemoved(File::Object,QString)), this, SLOT(removeSchedule(File::Object,QString))); | ||
445 | } | 450 | } | ||
446 | 451 | | |||
447 | LedgerModel::~LedgerModel() | 452 | LedgerModel::~LedgerModel() | ||
Context not available. | |||||
836 | } | 841 | } | ||
837 | 842 | | |||
838 | // if this is a one time schedule, we can bail out here as we're done | 843 | // if this is a one time schedule, we can bail out here as we're done | ||
839 | if (schedule.occurrence() == MyMoneySchedule::OCCUR_ONCE) | 844 | if (schedule.occurrence() == Schedule::Occurrence::Once) | ||
840 | break; | 845 | break; | ||
841 | 846 | | |||
842 | // for all others, we check if the next payment date is still 'in range' | 847 | // for all others, we check if the next payment date is still 'in range' | ||
Context not available. | |||||
876 | qDebug() << "Loaded" << rowCount() << "elements"; | 881 | qDebug() << "Loaded" << rowCount() << "elements"; | ||
877 | } | 882 | } | ||
878 | 883 | | |||
879 | void LedgerModel::addTransaction(MyMoneyFile::notificationObjectT objType, const MyMoneyObject * const obj) | 884 | void LedgerModel::addTransaction(File::Object objType, const MyMoneyObject * const obj) | ||
880 | { | 885 | { | ||
881 | if(objType != MyMoneyFile::notifyTransaction) { | 886 | if(objType != File::Object::Transaction) { | ||
882 | return; | 887 | return; | ||
883 | } | 888 | } | ||
884 | 889 | | |||
Context not available. | |||||
896 | Q_ASSERT(d->m_ledgerItems.count() == rowCount()); | 901 | Q_ASSERT(d->m_ledgerItems.count() == rowCount()); | ||
897 | } | 902 | } | ||
898 | 903 | | |||
899 | void LedgerModel::modifyTransaction(MyMoneyFile::notificationObjectT objType, const MyMoneyObject* const obj) | 904 | void LedgerModel::modifyTransaction(File::Object objType, const MyMoneyObject* const obj) | ||
900 | { | 905 | { | ||
901 | if(objType != MyMoneyFile::notifyTransaction) { | 906 | if(objType != File::Object::Transaction) { | ||
902 | return; | 907 | return; | ||
903 | } | 908 | } | ||
904 | 909 | | |||
Context not available. | |||||
967 | Q_ASSERT(d->m_ledgerItems.count() == rowCount()); | 972 | Q_ASSERT(d->m_ledgerItems.count() == rowCount()); | ||
968 | } | 973 | } | ||
969 | 974 | | |||
970 | void LedgerModel::removeTransaction(MyMoneyFile::notificationObjectT objType, const QString& id) | 975 | void LedgerModel::removeTransaction(File::Object objType, const QString& id) | ||
971 | { | 976 | { | ||
972 | if(objType != MyMoneyFile::notifyTransaction) { | 977 | if(objType != File::Object::Transaction) { | ||
973 | return; | 978 | return; | ||
974 | } | 979 | } | ||
975 | 980 | | |||
Context not available. | |||||
989 | } | 994 | } | ||
990 | } | 995 | } | ||
991 | 996 | | |||
992 | void LedgerModel::addSchedule(MyMoneyFile::notificationObjectT objType, const MyMoneyObject*const obj) | 997 | void LedgerModel::addSchedule(File::Object objType, const MyMoneyObject*const obj) | ||
993 | { | 998 | { | ||
994 | Q_UNUSED(obj); | 999 | Q_UNUSED(obj); | ||
995 | if(objType != MyMoneyFile::notifySchedule) { | 1000 | if(objType != File::Object::Schedule) { | ||
996 | return; | 1001 | return; | ||
997 | } | 1002 | } | ||
998 | 1003 | | |||
999 | /// @todo implement LedgerModel::addSchedule | 1004 | /// @todo implement LedgerModel::addSchedule | ||
1000 | } | 1005 | } | ||
1001 | 1006 | | |||
1002 | void LedgerModel::modifySchedule(MyMoneyFile::notificationObjectT objType, const MyMoneyObject*const obj) | 1007 | void LedgerModel::modifySchedule(File::Object objType, const MyMoneyObject*const obj) | ||
1003 | { | 1008 | { | ||
1004 | Q_UNUSED(obj); | 1009 | Q_UNUSED(obj); | ||
1005 | if(objType != MyMoneyFile::notifySchedule) { | 1010 | if(objType != File::Object::Schedule) { | ||
1006 | return; | 1011 | return; | ||
1007 | } | 1012 | } | ||
1008 | 1013 | | |||
1009 | /// @todo implement LedgerModel::modifySchedule | 1014 | /// @todo implement LedgerModel::modifySchedule | ||
1010 | } | 1015 | } | ||
1011 | 1016 | | |||
1012 | void LedgerModel::removeSchedule(MyMoneyFile::notificationObjectT objType, const QString& id) | 1017 | void LedgerModel::removeSchedule(File::Object objType, const QString& id) | ||
1013 | { | 1018 | { | ||
1014 | Q_UNUSED(id); | 1019 | Q_UNUSED(id); | ||
1015 | if(objType != MyMoneyFile::notifySchedule) { | 1020 | if(objType != File::Object::Schedule) { | ||
1016 | return; | 1021 | return; | ||
1017 | } | 1022 | } | ||
1018 | 1023 | | |||
Context not available. |