Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/dialogs/kmymoneysplittable.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
53 | #include "mymoneyfile.h" | 53 | #include "mymoneyfile.h" | ||
54 | #include "mymoneyprice.h" | 54 | #include "mymoneyprice.h" | ||
55 | #include "kmymoneyedit.h" | 55 | #include "kmymoneyedit.h" | ||
56 | #include "kmymoneycategory.h" | 56 | #include "kmymoneycategory.h" | ||
57 | #include "kmymoneyaccountselector.h" | 57 | #include "kmymoneyaccountselector.h" | ||
58 | #include "kmymoneylineedit.h" | 58 | #include "kmymoneylineedit.h" | ||
59 | #include "mymoneysecurity.h" | 59 | #include "mymoneysecurity.h" | ||
60 | #include "kmymoneysettings.h" | 60 | #include "kmymoneysettings.h" | ||
61 | #include "kmymoneymvccombo.h" | ||||
62 | #include "mymoneytag.h" | ||||
63 | #include "kmymoneytagcombo.h" | ||||
64 | #include "ktagcontainer.h" | ||||
61 | #include "kcurrencycalculator.h" | 65 | #include "kcurrencycalculator.h" | ||
62 | #include "mymoneyutils.h" | 66 | #include "mymoneyutils.h" | ||
63 | #include "mymoneytracer.h" | 67 | #include "mymoneytracer.h" | ||
64 | #include "mymoneyexception.h" | 68 | #include "mymoneyexception.h" | ||
65 | #include "icons.h" | 69 | #include "icons.h" | ||
66 | #include "mymoneyenums.h" | 70 | #include "mymoneyenums.h" | ||
67 | 71 | | |||
68 | using namespace Icons; | 72 | using namespace Icons; | ||
69 | 73 | | |||
70 | class KMyMoneySplitTablePrivate | 74 | class KMyMoneySplitTablePrivate | ||
71 | { | 75 | { | ||
72 | Q_DISABLE_COPY(KMyMoneySplitTablePrivate) | 76 | Q_DISABLE_COPY(KMyMoneySplitTablePrivate) | ||
73 | 77 | | |||
74 | public: | 78 | public: | ||
75 | KMyMoneySplitTablePrivate() : | 79 | KMyMoneySplitTablePrivate() : | ||
76 | m_currentRow(0), | 80 | m_currentRow(0), | ||
77 | m_maxRows(0), | 81 | m_maxRows(0), | ||
78 | m_precision(2), | 82 | m_precision(2), | ||
79 | m_contextMenu(nullptr), | 83 | m_contextMenu(nullptr), | ||
80 | m_contextMenuDelete(nullptr), | 84 | m_contextMenuDelete(nullptr), | ||
81 | m_contextMenuDuplicate(nullptr), | 85 | m_contextMenuDuplicate(nullptr), | ||
82 | m_editCategory(0), | 86 | m_editCategory(0), | ||
87 | m_editTag(0), | ||||
83 | m_editMemo(0), | 88 | m_editMemo(0), | ||
84 | m_editAmount(0) | 89 | m_editAmount(0) | ||
85 | { | 90 | { | ||
86 | } | 91 | } | ||
87 | 92 | | |||
88 | ~KMyMoneySplitTablePrivate() | 93 | ~KMyMoneySplitTablePrivate() | ||
89 | { | 94 | { | ||
90 | } | 95 | } | ||
Show All 28 Lines | |||||
119 | /** | 124 | /** | ||
120 | * This member contains a pointer to the input widget for the category. | 125 | * This member contains a pointer to the input widget for the category. | ||
121 | * The widget will be created and destroyed dynamically in createInputWidgets() | 126 | * The widget will be created and destroyed dynamically in createInputWidgets() | ||
122 | * and destroyInputWidgets(). | 127 | * and destroyInputWidgets(). | ||
123 | */ | 128 | */ | ||
124 | QPointer<KMyMoneyCategory> m_editCategory; | 129 | QPointer<KMyMoneyCategory> m_editCategory; | ||
125 | 130 | | |||
126 | /** | 131 | /** | ||
132 | * This member contains a pointer to the tag widget for the memo. | ||||
133 | */ | ||||
134 | QPointer<KTagContainer> m_editTag; | ||||
135 | | ||||
136 | /** | ||||
127 | * This member contains a pointer to the input widget for the memo. | 137 | * This member contains a pointer to the input widget for the memo. | ||
128 | * The widget will be created and destroyed dynamically in createInputWidgets() | 138 | * The widget will be created and destroyed dynamically in createInputWidgets() | ||
129 | * and destroyInputWidgets(). | 139 | * and destroyInputWidgets(). | ||
130 | */ | 140 | */ | ||
131 | QPointer<KMyMoneyLineEdit> m_editMemo; | 141 | QPointer<KMyMoneyLineEdit> m_editMemo; | ||
132 | 142 | | |||
133 | /** | 143 | /** | ||
134 | * This member contains a pointer to the input widget for the amount. | 144 | * This member contains a pointer to the input widget for the amount. | ||
Show All 19 Lines | 162 | KMyMoneySplitTable::KMyMoneySplitTable(QWidget *parent) : | |||
154 | d_ptr(new KMyMoneySplitTablePrivate) | 164 | d_ptr(new KMyMoneySplitTablePrivate) | ||
155 | { | 165 | { | ||
156 | Q_D(KMyMoneySplitTable); | 166 | Q_D(KMyMoneySplitTable); | ||
157 | // used for custom coloring with the help of the application's stylesheet | 167 | // used for custom coloring with the help of the application's stylesheet | ||
158 | setObjectName(QLatin1String("splittable")); | 168 | setObjectName(QLatin1String("splittable")); | ||
159 | 169 | | |||
160 | // setup the transactions table | 170 | // setup the transactions table | ||
161 | setRowCount(1); | 171 | setRowCount(1); | ||
162 | setColumnCount(3); | 172 | setColumnCount(4); | ||
163 | QStringList labels; | 173 | QStringList labels; | ||
164 | labels << i18n("Category") << i18n("Memo") << i18n("Amount"); | 174 | labels << i18n("Category") << i18n("Memo") << i18n("Tag") << i18n("Amount"); | ||
165 | setHorizontalHeaderLabels(labels); | 175 | setHorizontalHeaderLabels(labels); | ||
166 | setSelectionMode(QAbstractItemView::SingleSelection); | 176 | setSelectionMode(QAbstractItemView::SingleSelection); | ||
167 | setSelectionBehavior(QAbstractItemView::SelectRows); | 177 | setSelectionBehavior(QAbstractItemView::SelectRows); | ||
168 | int left, top, right, bottom; | 178 | int left, top, right, bottom; | ||
169 | getContentsMargins(&left, &top, &right, &bottom); | 179 | getContentsMargins(&left, &top, &right, &bottom); | ||
170 | setContentsMargins(0, top, right, bottom); | 180 | setContentsMargins(0, top, right, bottom); | ||
171 | 181 | | |||
172 | setFont(KMyMoneySettings::listCellFontEx()); | 182 | setFont(KMyMoneySettings::listCellFontEx()); | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 363 | if (box && box->isVisible()) { | |||
355 | le->completionBox(false)->hide(); | 365 | le->completionBox(false)->hide(); | ||
356 | } | 366 | } | ||
357 | } | 367 | } | ||
358 | } | 368 | } | ||
359 | 369 | | |||
360 | // in case we have the 'enter moves focus between fields', we need to simulate | 370 | // in case we have the 'enter moves focus between fields', we need to simulate | ||
361 | // a TAB key when the object 'o' points to the category or memo field. | 371 | // a TAB key when the object 'o' points to the category or memo field. | ||
362 | if (KMyMoneySettings::enterMovesBetweenFields()) { | 372 | if (KMyMoneySettings::enterMovesBetweenFields()) { | ||
363 | if (o == d->m_editCategory->lineEdit() || o == d->m_editMemo) { | 373 | if (o == d->m_editCategory->lineEdit() || o == d->m_editMemo || o == d->m_editTag) { | ||
364 | terminate = false; | 374 | terminate = false; | ||
365 | QKeyEvent evt(e->type(), | 375 | QKeyEvent evt(e->type(), | ||
366 | Qt::Key_Tab, k->modifiers(), QString(), | 376 | Qt::Key_Tab, k->modifiers(), QString(), | ||
367 | k->isAutoRepeat(), k->count()); | 377 | k->isAutoRepeat(), k->count()); | ||
368 | 378 | | |||
369 | QApplication::sendEvent(o, &evt); | 379 | QApplication::sendEvent(o, &evt); | ||
370 | } | 380 | } | ||
371 | } | 381 | } | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 506 | case 0: | |||
497 | editWidget = d->m_editCategory->lineEdit(); | 507 | editWidget = d->m_editCategory->lineEdit(); | ||
498 | break; | 508 | break; | ||
499 | 509 | | |||
500 | case 1: | 510 | case 1: | ||
501 | editWidget = d->m_editMemo; | 511 | editWidget = d->m_editMemo; | ||
502 | break; | 512 | break; | ||
503 | 513 | | |||
504 | case 2: | 514 | case 2: | ||
515 | d->m_editTag->tagCombo()->setFocus(); | ||||
516 | break; | ||||
517 | | ||||
518 | case 3: | ||||
505 | editWidget = d->m_editAmount->lineedit(); | 519 | editWidget = d->m_editAmount->lineedit(); | ||
506 | break; | 520 | break; | ||
507 | 521 | | |||
508 | default: | 522 | default: | ||
509 | break; | 523 | break; | ||
510 | } | 524 | } | ||
511 | if (editWidget) { | 525 | if (editWidget) { | ||
512 | editWidget->setFocus(); | 526 | editWidget->setFocus(); | ||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 642 | else | |||
629 | setItem(numRows, 0, new QTableWidgetItem(colText)); | 643 | setItem(numRows, 0, new QTableWidgetItem(colText)); | ||
630 | 644 | | |||
631 | textItem = item(numRows, 1); | 645 | textItem = item(numRows, 1); | ||
632 | if (textItem) | 646 | if (textItem) | ||
633 | textItem->setText((*it).memo()); | 647 | textItem->setText((*it).memo()); | ||
634 | else | 648 | else | ||
635 | setItem(numRows, 1, new QTableWidgetItem((*it).memo())); | 649 | setItem(numRows, 1, new QTableWidgetItem((*it).memo())); | ||
636 | 650 | | |||
637 | textItem = item(numRows, 2); | 651 | QList<QString> tl = (*it).tagIdList(); | ||
652 | QStringList tagNames; | ||||
653 | if (!tl.isEmpty()) { | ||||
654 | for (int i = 0; i < tl.size(); i++) | ||||
655 | tagNames.append(MyMoneyFile::instance()->tag(tl[i]).name()); | ||||
656 | } | ||||
657 | setItem(numRows, 2, new QTableWidgetItem(tagNames.join(", "))); | ||||
658 | | ||||
659 | textItem = item(numRows, 3); | ||||
638 | if (textItem) | 660 | if (textItem) | ||
639 | textItem->setText(amountTxt); | 661 | textItem->setText(amountTxt); | ||
640 | else | 662 | else | ||
641 | setItem(numRows, 2, new QTableWidgetItem(amountTxt)); | 663 | setItem(numRows, 3, new QTableWidgetItem(amountTxt)); | ||
642 | 664 | | |||
643 | item(numRows, 2)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); | 665 | item(numRows, 3)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); | ||
644 | 666 | | |||
645 | ++numRows; | 667 | ++numRows; | ||
646 | } | 668 | } | ||
647 | 669 | | |||
648 | // now clean out the remainder of the table | 670 | // now clean out the remainder of the table | ||
649 | while (numRows < static_cast<unsigned long>(rowCount())) { | 671 | while (numRows < static_cast<unsigned long>(rowCount())) { | ||
650 | for (auto i = 0 ; i < 3; ++i) { | 672 | for (auto i = 0 ; i < 4; ++i) { | ||
651 | textItem = item(numRows, i); | 673 | textItem = item(numRows, i); | ||
652 | if (textItem) | 674 | if (textItem) | ||
653 | textItem->setText(""); | 675 | textItem->setText(""); | ||
654 | else | 676 | else | ||
655 | setItem(numRows, i, new QTableWidgetItem("")); | 677 | setItem(numRows, i, new QTableWidgetItem("")); | ||
656 | } | 678 | } | ||
657 | item(numRows, 2)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); | 679 | item(numRows, 3)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); | ||
658 | ++numRows; | 680 | ++numRows; | ||
659 | } | 681 | } | ||
660 | } | 682 | } | ||
661 | 683 | | |||
662 | void KMyMoneySplitTable::updateTransactionTableSize() | 684 | void KMyMoneySplitTable::updateTransactionTableSize() | ||
663 | { | 685 | { | ||
664 | Q_D(KMyMoneySplitTable); | 686 | Q_D(KMyMoneySplitTable); | ||
665 | // get current size of transactions table | 687 | // get current size of transactions table | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 773 | { | |||
765 | if (d->m_editCategory->selectedItem() != d->m_split.accountId()) { | 787 | if (d->m_editCategory->selectedItem() != d->m_split.accountId()) { | ||
766 | s1.setAccountId(d->m_editCategory->selectedItem()); | 788 | s1.setAccountId(d->m_editCategory->selectedItem()); | ||
767 | needUpdate = true; | 789 | needUpdate = true; | ||
768 | } | 790 | } | ||
769 | if (d->m_editMemo->text() != d->m_split.memo()) { | 791 | if (d->m_editMemo->text() != d->m_split.memo()) { | ||
770 | s1.setMemo(d->m_editMemo->text()); | 792 | s1.setMemo(d->m_editMemo->text()); | ||
771 | needUpdate = true; | 793 | needUpdate = true; | ||
772 | } | 794 | } | ||
795 | if (d->m_editTag->selectedTags() != d->m_split.tagIdList()) { | ||||
796 | s1.setTagIdList(d->m_editTag->selectedTags()); | ||||
797 | needUpdate = true; | ||||
798 | } | ||||
773 | if (d->m_editAmount->value() != d->m_split.value()) { | 799 | if (d->m_editAmount->value() != d->m_split.value()) { | ||
774 | s1.setValue(d->m_editAmount->value()); | 800 | s1.setValue(d->m_editAmount->value()); | ||
775 | needUpdate = true; | 801 | needUpdate = true; | ||
776 | } | 802 | } | ||
777 | 803 | | |||
778 | if (needUpdate) { | 804 | if (needUpdate) { | ||
779 | if (!s1.value().isZero()) { | 805 | if (!s1.value().isZero()) { | ||
780 | MyMoneyAccount cat = file->account(s1.accountId()); | 806 | MyMoneyAccount cat = file->account(s1.accountId()); | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | 895 | if (isEditMode()) { | |||
878 | this->setFocus(); | 904 | this->setFocus(); | ||
879 | } | 905 | } | ||
880 | } | 906 | } | ||
881 | 907 | | |||
882 | bool KMyMoneySplitTable::isEditMode() const | 908 | bool KMyMoneySplitTable::isEditMode() const | ||
883 | { | 909 | { | ||
884 | Q_D(const KMyMoneySplitTable); | 910 | Q_D(const KMyMoneySplitTable); | ||
885 | // while the edit widgets exist we're in edit mode | 911 | // while the edit widgets exist we're in edit mode | ||
886 | return d->m_editAmount || d->m_editMemo || d->m_editCategory; | 912 | return d->m_editAmount || d->m_editMemo || d->m_editCategory || d->m_editTag; | ||
887 | } | 913 | } | ||
888 | 914 | | |||
889 | bool KMyMoneySplitTable::isEditSplitValid() const | 915 | bool KMyMoneySplitTable::isEditSplitValid() const | ||
890 | { | 916 | { | ||
891 | Q_D(const KMyMoneySplitTable); | 917 | Q_D(const KMyMoneySplitTable); | ||
892 | return isEditMode() && !d->m_editCategory->selectedItem().isEmpty(); | 918 | return isEditMode() && !(d->m_editCategory && d->m_editCategory->selectedItem().isEmpty()); | ||
tbaumgart: This is dead code | |||||
893 | } | 919 | } | ||
894 | 920 | | |||
895 | void KMyMoneySplitTable::destroyEditWidgets() | 921 | void KMyMoneySplitTable::destroyEditWidgets() | ||
896 | { | 922 | { | ||
897 | MYMONEYTRACER(tracer); | 923 | MYMONEYTRACER(tracer); | ||
898 | 924 | | |||
899 | Q_D(KMyMoneySplitTable); | 925 | Q_D(KMyMoneySplitTable); | ||
900 | emit editFinished(); | 926 | emit editFinished(); | ||
901 | 927 | | |||
902 | disconnect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, this, &KMyMoneySplitTable::slotLoadEditWidgets); | 928 | disconnect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, this, &KMyMoneySplitTable::slotLoadEditWidgets); | ||
903 | 929 | | |||
904 | destroyEditWidget(d->m_currentRow, 0); | 930 | destroyEditWidget(d->m_currentRow, 0); | ||
905 | destroyEditWidget(d->m_currentRow, 1); | 931 | destroyEditWidget(d->m_currentRow, 1); | ||
906 | destroyEditWidget(d->m_currentRow, 2); | 932 | destroyEditWidget(d->m_currentRow, 2); | ||
933 | destroyEditWidget(d->m_currentRow, 3); | ||||
907 | destroyEditWidget(d->m_currentRow + 1, 0); | 934 | destroyEditWidget(d->m_currentRow + 1, 0); | ||
908 | } | 935 | } | ||
909 | 936 | | |||
910 | void KMyMoneySplitTable::destroyEditWidget(int r, int c) | 937 | void KMyMoneySplitTable::destroyEditWidget(int r, int c) | ||
911 | { | 938 | { | ||
912 | if (QWidget* cw = cellWidget(r, c)) | 939 | if (QWidget* cw = cellWidget(r, c)) | ||
913 | cw->hide(); | 940 | cw->hide(); | ||
914 | removeCellWidget(r, c); | 941 | removeCellWidget(r, c); | ||
Show All 20 Lines | 945 | { | |||
935 | d->m_editCategory->setFont(cellFont); | 962 | d->m_editCategory->setFont(cellFont); | ||
936 | connect(d->m_editCategory, SIGNAL(createItem(QString,QString&)), this, SIGNAL(createCategory(QString,QString&))); | 963 | connect(d->m_editCategory, SIGNAL(createItem(QString,QString&)), this, SIGNAL(createCategory(QString,QString&))); | ||
937 | connect(d->m_editCategory, SIGNAL(objectCreation(bool)), this, SIGNAL(objectCreation(bool))); | 964 | connect(d->m_editCategory, SIGNAL(objectCreation(bool)), this, SIGNAL(objectCreation(bool))); | ||
938 | 965 | | |||
939 | d->m_editMemo = new KMyMoneyLineEdit(0, false, Qt::AlignLeft | Qt::AlignVCenter); | 966 | d->m_editMemo = new KMyMoneyLineEdit(0, false, Qt::AlignLeft | Qt::AlignVCenter); | ||
940 | d->m_editMemo->setPlaceholderText(i18n("Memo")); | 967 | d->m_editMemo->setPlaceholderText(i18n("Memo")); | ||
941 | d->m_editMemo->setFont(cellFont); | 968 | d->m_editMemo->setFont(cellFont); | ||
942 | 969 | | |||
970 | d->m_editTag = new KTagContainer; | ||||
971 | d->m_editTag->tagCombo()->setPlaceholderText(i18n("Tag")); | ||||
972 | d->m_editTag->tagCombo()->setFont(cellFont); | ||||
973 | d->m_editTag->loadTags(MyMoneyFile::instance()->tagList()); | ||||
974 | connect(d->m_editTag->tagCombo(), SIGNAL(createItem(QString,QString&)), this, SIGNAL(createTag(QString,QString&))); | ||||
975 | connect(d->m_editTag->tagCombo(), SIGNAL(objectCreation(bool)), this, SIGNAL(objectCreation(bool))); | ||||
976 | | ||||
943 | // create buttons for the mouse users | 977 | // create buttons for the mouse users | ||
944 | d->m_registerButtonFrame = new QFrame(this); | 978 | d->m_registerButtonFrame = new QFrame(this); | ||
945 | d->m_registerButtonFrame->setContentsMargins(0, 0, 0, 0); | 979 | d->m_registerButtonFrame->setContentsMargins(0, 0, 0, 0); | ||
946 | d->m_registerButtonFrame->setAutoFillBackground(true); | 980 | d->m_registerButtonFrame->setAutoFillBackground(true); | ||
947 | 981 | | |||
948 | QHBoxLayout* l = new QHBoxLayout(d->m_registerButtonFrame); | 982 | QHBoxLayout* l = new QHBoxLayout(d->m_registerButtonFrame); | ||
949 | l->setContentsMargins(0, 0, 0, 0); | 983 | l->setContentsMargins(0, 0, 0, 0); | ||
950 | l->setSpacing(0); | 984 | l->setSpacing(0); | ||
951 | d->m_registerEnterButton = new QPushButton(Icons::get(Icon::DialogOK) | 985 | d->m_registerEnterButton = new QPushButton(Icons::get(Icon::DialogOK) | ||
952 | , QString(), d->m_registerButtonFrame); | 986 | , QString(), d->m_registerButtonFrame); | ||
953 | d->m_registerCancelButton = new QPushButton(Icons::get(Icon::DialogCancel) | 987 | d->m_registerCancelButton = new QPushButton(Icons::get(Icon::DialogCancel) | ||
954 | , QString(), d->m_registerButtonFrame); | 988 | , QString(), d->m_registerButtonFrame); | ||
955 | 989 | | |||
956 | l->addWidget(d->m_registerEnterButton); | 990 | l->addWidget(d->m_registerEnterButton); | ||
957 | l->addWidget(d->m_registerCancelButton); | 991 | l->addWidget(d->m_registerCancelButton); | ||
958 | l->addStretch(2); | 992 | l->addStretch(2); | ||
959 | 993 | | |||
960 | connect(d->m_registerEnterButton.data(), &QAbstractButton::clicked, this, &KMyMoneySplitTable::slotEndEdit); | 994 | connect(d->m_registerEnterButton.data(), &QAbstractButton::clicked, this, &KMyMoneySplitTable::slotEndEdit); | ||
961 | connect(d->m_registerCancelButton.data(), &QAbstractButton::clicked, this, &KMyMoneySplitTable::slotCancelEdit); | 995 | connect(d->m_registerCancelButton.data(), &QAbstractButton::clicked, this, &KMyMoneySplitTable::slotCancelEdit); | ||
962 | 996 | | |||
963 | // setup tab order | 997 | // setup tab order | ||
964 | addToTabOrder(d->m_editCategory); | 998 | addToTabOrder(d->m_editCategory); | ||
965 | addToTabOrder(d->m_editMemo); | 999 | addToTabOrder(d->m_editMemo); | ||
1000 | addToTabOrder(d->m_editTag); | ||||
966 | addToTabOrder(d->m_editAmount); | 1001 | addToTabOrder(d->m_editAmount); | ||
967 | addToTabOrder(d->m_registerEnterButton); | 1002 | addToTabOrder(d->m_registerEnterButton); | ||
968 | addToTabOrder(d->m_registerCancelButton); | 1003 | addToTabOrder(d->m_registerCancelButton); | ||
969 | 1004 | | |||
970 | if (!d->m_split.accountId().isEmpty()) { | 1005 | if (!d->m_split.accountId().isEmpty()) { | ||
971 | d->m_editCategory->setSelectedItem(d->m_split.accountId()); | 1006 | d->m_editCategory->setSelectedItem(d->m_split.accountId()); | ||
972 | } else { | 1007 | } else { | ||
973 | // check if the transaction is balanced or not. If not, | 1008 | // check if the transaction is balanced or not. If not, | ||
974 | // assign the remainder to the amount. | 1009 | // assign the remainder to the amount. | ||
975 | MyMoneyMoney diff; | 1010 | MyMoneyMoney diff; | ||
976 | QList<MyMoneySplit> list = d->m_transaction.splits(); | 1011 | QList<MyMoneySplit> list = d->m_transaction.splits(); | ||
977 | QList<MyMoneySplit>::ConstIterator it_s; | 1012 | QList<MyMoneySplit>::ConstIterator it_s; | ||
978 | for (it_s = list.constBegin(); it_s != list.constEnd(); ++it_s) { | 1013 | for (it_s = list.constBegin(); it_s != list.constEnd(); ++it_s) { | ||
979 | if (!(*it_s).accountId().isEmpty()) | 1014 | if (!(*it_s).accountId().isEmpty()) | ||
980 | diff += (*it_s).value(); | 1015 | diff += (*it_s).value(); | ||
981 | } | 1016 | } | ||
982 | d->m_split.setValue(-diff); | 1017 | d->m_split.setValue(-diff); | ||
983 | } | 1018 | } | ||
984 | 1019 | | |||
1020 | QList<QString> t = d->m_split.tagIdList(); | ||||
1021 | if (!t.isEmpty()) { | ||||
1022 | for (int i = 0; i < t.size(); i++) | ||||
1023 | d->m_editTag->addTagWidget(t[i]); | ||||
1024 | } | ||||
1025 | | ||||
985 | d->m_editMemo->loadText(d->m_split.memo()); | 1026 | d->m_editMemo->loadText(d->m_split.memo()); | ||
986 | // don't allow automatically calculated values to be modified | 1027 | // don't allow automatically calculated values to be modified | ||
987 | if (d->m_split.value() == MyMoneyMoney::autoCalc) { | 1028 | if (d->m_split.value() == MyMoneyMoney::autoCalc) { | ||
988 | d->m_editAmount->setEnabled(false); | 1029 | d->m_editAmount->setEnabled(false); | ||
989 | d->m_editAmount->loadText("will be calculated"); | 1030 | d->m_editAmount->loadText("will be calculated"); | ||
990 | } else | 1031 | } else | ||
991 | d->m_editAmount->setValue(d->m_split.value()); | 1032 | d->m_editAmount->setValue(d->m_split.value()); | ||
992 | 1033 | | |||
993 | setCellWidget(d->m_currentRow, 0, d->m_editCategory); | 1034 | setCellWidget(d->m_currentRow, 0, d->m_editCategory); | ||
994 | setCellWidget(d->m_currentRow, 1, d->m_editMemo); | 1035 | setCellWidget(d->m_currentRow, 1, d->m_editMemo); | ||
995 | setCellWidget(d->m_currentRow, 2, d->m_editAmount); | 1036 | setCellWidget(d->m_currentRow, 2, d->m_editTag); | ||
1037 | setCellWidget(d->m_currentRow, 3, d->m_editAmount); | ||||
996 | setCellWidget(d->m_currentRow + 1, 0, d->m_registerButtonFrame); | 1038 | setCellWidget(d->m_currentRow + 1, 0, d->m_registerButtonFrame); | ||
997 | 1039 | | |||
998 | // load e.g. the category widget with the account list | 1040 | // load e.g. the category widget with the account list | ||
999 | slotLoadEditWidgets(); | 1041 | slotLoadEditWidgets(); | ||
1000 | connect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, this, &KMyMoneySplitTable::slotLoadEditWidgets); | 1042 | connect(MyMoneyFile::instance(), &MyMoneyFile::dataChanged, this, &KMyMoneySplitTable::slotLoadEditWidgets); | ||
1001 | 1043 | | |||
1002 | foreach (QWidget* w, d->m_tabOrderWidgets) { | 1044 | foreach (QWidget* w, d->m_tabOrderWidgets) { | ||
1003 | if (w) { | 1045 | if (w) { | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
This is dead code