-rw-r--r-- | noncore/apps/checkbook/qcheckbook.cpp | 226 | ||||
-rw-r--r-- | noncore/apps/checkbook/qcheckview.cpp | 822 |
2 files changed, 523 insertions, 525 deletions
diff --git a/noncore/apps/checkbook/qcheckbook.cpp b/noncore/apps/checkbook/qcheckbook.cpp index 797127e..bb7a5ac 100644 --- a/noncore/apps/checkbook/qcheckbook.cpp +++ b/noncore/apps/checkbook/qcheckbook.cpp | |||
@@ -1,149 +1,147 @@ | |||
1 | #include "qcheckbook.h" | 1 | #include "qcheckbook.h" |
2 | 2 | ||
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qstatusbar.h> | 4 | #include <qstatusbar.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qdir.h> | 8 | #include <qdir.h> |
9 | 9 | ||
10 | QCheckBook::QCheckBook() | 10 | QCheckBook::QCheckBook() |
11 | : QMainWindow(), | 11 | : QMainWindow(), |
12 | m_view(), | 12 | m_view(), |
13 | m_view2(), | 13 | m_view2(), |
14 | m_view3() | 14 | m_view3() |
15 | { | 15 | { |
16 | initCheck = false; | 16 | initCheck = false; |
17 | initMM = false; | 17 | initMM = false; |
18 | setCaption("Checking"); | 18 | setCaption("Checking"); |
19 | statusBar()->hide(); | 19 | statusBar()->hide(); |
20 | menuBar()->hide(); | 20 | menuBar()->hide(); |
21 | 21 | ||
22 | bar = new QToolBar(this); | 22 | bar = new QToolBar(this); |
23 | bar->setHorizontalStretchable( TRUE ); | 23 | bar->setHorizontalStretchable( TRUE ); |
24 | 24 | ||
25 | addToolBar(bar); | 25 | addToolBar(bar); |
26 | 26 | ||
27 | Config config("qcheckbook"); | 27 | Config config("qcheckbook"); |
28 | config.setGroup("Global"); | 28 | config.setGroup("Global"); |
29 | QString lastCheck = config.readEntry("LastCheckBook", QString("")); | 29 | QString lastCheck = config.readEntry("LastCheckBook", QString("")); |
30 | 30 | ||
31 | QString checkdirname = QDir::homeDirPath(); | 31 | QString checkdirname = QDir::homeDirPath(); |
32 | checkdirname.append("/.checkbooks/"); | 32 | checkdirname.append("/.checkbooks/"); |
33 | checkdirname.append(lastCheck); | 33 | checkdirname.append(lastCheck); |
34 | QFile f(checkdirname); | 34 | QFile f(checkdirname); |
35 | 35 | ||
36 | 36 | ||
37 | if (lastCheck.isEmpty() == false && lastCheck != "" && f.exists() == true) | 37 | if (lastCheck.isEmpty() == false && lastCheck != "" && f.exists() == true) |
38 | { | 38 | { |
39 | newCheck(lastCheck); | 39 | newCheck(lastCheck); |
40 | } else { | 40 | } else { |
41 | initMainMenus(); | 41 | initMainMenus(); |
42 | } | 42 | } |
43 | 43 | ||
44 | setToolBarsMovable( FALSE ); | 44 | setToolBarsMovable( FALSE ); |
45 | } | 45 | } |
46 | 46 | ||
47 | void QCheckBook::newCheck(const QString &filename) | 47 | void QCheckBook::newCheck(const QString &filename) |
48 | { | 48 | { |
49 | if (filename.isEmpty() == false) | 49 | if (filename.isEmpty() == false) |
50 | { | 50 | { |
51 | initCheck = true; | 51 | initCheck = true; |
52 | if (m_view != 0) | 52 | if (m_view != 0) |
53 | { | 53 | { |
54 | delete m_view; | 54 | m_view=0; |
55 | } | 55 | delete m_view; |
56 | m_view = new QCheckView(this, filename); | 56 | } |
57 | m_view->hide(); | 57 | m_view = new QCheckView(this, filename); |
58 | connect(m_view, SIGNAL(reload(const QString &)), this, SLOT(newCheck(const QString &))); | 58 | m_view->hide(); |
59 | 59 | connect(m_view, SIGNAL(reload(const QString &)), this, SLOT(newCheck(const QString &))); | |
60 | if (initMM == true) | 60 | if (initMM == true) |
61 | { | 61 | { |
62 | delete nb1; | 62 | delete nb1; |
63 | } | 63 | } |
64 | 64 | bar->clear(); | |
65 | bar->clear(); | 65 | mbar = new QMenuBar(bar); |
66 | 66 | mbar->setMargin(0); | |
67 | mbar = new QMenuBar(bar); | 67 | |
68 | mbar->setMargin(0); | 68 | QPixmap newIcon = Resource::loadPixmap( "new" ); |
69 | 69 | nb2 = new QToolButton( newIcon, "New", QString::null, m_view, SLOT(newClicked()), bar, "new item" ); | |
70 | QPixmap newIcon = Resource::loadPixmap( "new" ); | 70 | QPixmap pixmap = Resource::loadPixmap( "pixmap" ); |
71 | nb2 = new QToolButton( newIcon, "New", QString::null, m_view, SLOT(newClicked()), bar, "new item" ); | 71 | m_filename = filename; |
72 | QPixmap pixmap = Resource::loadPixmap( "pixmap" ); | 72 | nb3 = new QToolButton( pixmap, "Graph", QString::null, this, SLOT(newGraph()), bar, "new graph" ); |
73 | m_filename = filename; | 73 | |
74 | nb3 = new QToolButton( pixmap, "Graph", QString::null, this, SLOT(newGraph()), bar, "new graph" ); | 74 | QPixmap closeIcon = Resource::loadPixmap( "close" ); |
75 | 75 | nb4 = new QToolButton( closeIcon, "Close", QString::null, this, SLOT(initMainMenus()), bar, "close graph" ); | |
76 | QPixmap closeIcon = Resource::loadPixmap( "close" ); | 76 | |
77 | nb4 = new QToolButton( closeIcon, "Close", QString::null, this, SLOT(initMainMenus()), bar, "close graph" ); | 77 | popup = new QPopupMenu(m_view); |
78 | 78 | popup->insertItem("&New Entry", m_view, SLOT(newClicked())); | |
79 | popup = new QPopupMenu(m_view); | 79 | popup->insertItem("&Graph Checkbook", this, SLOT(newGraph())); |
80 | popup->insertItem("&New Entry", m_view, SLOT(newClicked())); | 80 | popup->insertItem("&Close Checkbook", this, SLOT(initMainMenus())); |
81 | popup->insertItem("&Graph Checkbook", this, SLOT(newGraph())); | 81 | popup->insertItem("&Exit", this, SLOT(close())); |
82 | popup->insertItem("&Close Checkbook", this, SLOT(initMainMenus())); | 82 | mbar->insertItem("&File", popup); |
83 | popup->insertItem("&Exit", this, SLOT(close())); | 83 | |
84 | mbar->insertItem("&File", popup); | 84 | setCentralWidget(m_view); |
85 | 85 | m_view->show(); | |
86 | setCentralWidget(m_view); | 86 | |
87 | m_view->show(); | 87 | Config config("qcheckbook"); |
88 | 88 | config.setGroup("Global"); | |
89 | Config config("qcheckbook"); | 89 | config.writeEntry("LastCheckBook", filename); |
90 | config.setGroup("Global"); | 90 | initMM = false; |
91 | config.writeEntry("LastCheckBook", filename); | 91 | } |
92 | initMM = false; | ||
93 | } | ||
94 | } | 92 | } |
95 | 93 | ||
96 | void QCheckBook::close() | 94 | void QCheckBook::close() |
97 | { | 95 | { |
98 | QApplication::exit(); | 96 | QApplication::exit(); |
99 | } | 97 | } |
100 | 98 | ||
101 | void QCheckBook::newGraph() | 99 | void QCheckBook::newGraph() |
102 | { | 100 | { |
103 | if (m_filename.isEmpty() == false) | 101 | if (m_filename.isEmpty() == false) |
104 | { | 102 | { |
105 | m_view2 = new QCheckGraph(m_filename); | 103 | m_view2 = new QCheckGraph(m_filename); |
106 | m_view2->showMaximized(); | 104 | m_view2->showMaximized(); |
107 | } | 105 | } |
108 | } | 106 | } |
109 | 107 | ||
110 | void QCheckBook::initMainMenus() | 108 | void QCheckBook::initMainMenus() |
111 | { | 109 | { |
112 | Config config("qcheckbook"); | 110 | Config config("qcheckbook"); |
113 | config.setGroup("Global"); | 111 | config.setGroup("Global"); |
114 | config.writeEntry("LastCheckBook", QString("")); | 112 | config.writeEntry("LastCheckBook", QString("")); |
115 | initMM = true; | 113 | initMM = true; |
116 | m_filename = ""; | 114 | m_filename = ""; |
117 | if (m_view3 != 0) | 115 | if (m_view3 != 0) |
118 | { | 116 | { |
119 | delete m_view3; | 117 | delete m_view3; |
120 | } | 118 | } |
121 | m_view3 = new QCheckMainMenu(this); | 119 | m_view3 = new QCheckMainMenu(this); |
122 | m_view3->hide(); | 120 | m_view3->hide(); |
123 | 121 | ||
124 | if (initCheck == true) | 122 | if (initCheck == true) |
125 | { | 123 | { |
126 | delete nb2; | 124 | delete nb2; |
127 | delete nb3; | 125 | delete nb3; |
128 | delete nb4; | 126 | delete nb4; |
129 | } | 127 | } |
130 | 128 | ||
131 | bar->clear(); | 129 | bar->clear(); |
132 | 130 | ||
133 | mbar = new QMenuBar(bar); | 131 | mbar = new QMenuBar(bar); |
134 | mbar->setMargin(0); | 132 | mbar->setMargin(0); |
135 | 133 | ||
136 | QPixmap newIcon = Resource::loadPixmap( "new" ); | 134 | QPixmap newIcon = Resource::loadPixmap( "new" ); |
137 | nb1 = new QToolButton( newIcon, "New", QString::null, m_view3, SLOT(newClicked()), bar, "new book" ); | 135 | nb1 = new QToolButton( newIcon, "New", QString::null, m_view3, SLOT(newClicked()), bar, "new book" ); |
138 | 136 | ||
139 | popup = new QPopupMenu(); | 137 | popup = new QPopupMenu(); |
140 | popup->insertItem("&New", m_view3, SLOT(newClicked())); | 138 | popup->insertItem("&New", m_view3, SLOT(newClicked())); |
141 | popup->insertItem("&Exit", this, SLOT(close())); | 139 | popup->insertItem("&Exit", this, SLOT(close())); |
142 | mbar->insertItem("&File", popup); | 140 | mbar->insertItem("&File", popup); |
143 | 141 | ||
144 | setCentralWidget(m_view3); | 142 | setCentralWidget(m_view3); |
145 | m_view3->show(); | 143 | m_view3->show(); |
146 | 144 | ||
147 | connect(m_view3, SIGNAL(itemSelected(const QString &)), this, SLOT(newCheck(const QString &))); | 145 | connect(m_view3, SIGNAL(itemSelected(const QString &)), this, SLOT(newCheck(const QString &))); |
148 | initCheck = false; | 146 | initCheck = false; |
149 | } | 147 | } |
diff --git a/noncore/apps/checkbook/qcheckview.cpp b/noncore/apps/checkbook/qcheckview.cpp index 6f103e2..ddc3fa9 100644 --- a/noncore/apps/checkbook/qcheckview.cpp +++ b/noncore/apps/checkbook/qcheckview.cpp | |||
@@ -10,449 +10,449 @@ | |||
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | #include <qdatetime.h> | 12 | #include <qdatetime.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <qcheckbox.h> | 14 | #include <qcheckbox.h> |
15 | #include <qfile.h> | 15 | #include <qfile.h> |
16 | #include <qtextstream.h> | 16 | #include <qtextstream.h> |
17 | #include <qbuttongroup.h> | 17 | #include <qbuttongroup.h> |
18 | #include <qradiobutton.h> | 18 | #include <qradiobutton.h> |
19 | #include <qheader.h> | 19 | #include <qheader.h> |
20 | 20 | ||
21 | QCheckView::QCheckView(QWidget *parent, QString filename) | 21 | QCheckView::QCheckView(QWidget *parent, QString filename) |
22 | : QCheckViewBase(parent) | 22 | : QCheckViewBase(parent) |
23 | { | 23 | { |
24 | tblTransactions->setHScrollBarMode( QTable::AlwaysOff ); | 24 | tblTransactions->setHScrollBarMode( QTable::AlwaysOff ); |
25 | tblTransactions->setNumRows( 0 ); | 25 | tblTransactions->setNumRows( 0 ); |
26 | tblTransactions->setNumCols( 4 ); | 26 | tblTransactions->setNumCols( 4 ); |
27 | tblTransactions->setShowGrid( FALSE ); | 27 | tblTransactions->setShowGrid( FALSE ); |
28 | tblTransactions->horizontalHeader()->setLabel(0, "Num", 29); | 28 | tblTransactions->horizontalHeader()->setLabel(0, "Num", 29); |
29 | tblTransactions->horizontalHeader()->setLabel(1, "Description", 81); | 29 | tblTransactions->horizontalHeader()->setLabel(1, "Description", 81); |
30 | tblTransactions->horizontalHeader()->setLabel(2, "Date", 57); | 30 | tblTransactions->horizontalHeader()->setLabel(2, "Date", 57); |
31 | tblTransactions->horizontalHeader()->setLabel(3, "Amount", 59); | 31 | tblTransactions->horizontalHeader()->setLabel(3, "Amount", 59); |
32 | tblTransactions->verticalHeader()->hide(); | 32 | tblTransactions->verticalHeader()->hide(); |
33 | tblTransactions->setLeftMargin( 0 ); | 33 | tblTransactions->setLeftMargin( 0 ); |
34 | tblTransactions->setSelectionMode(QTable::NoSelection); | 34 | tblTransactions->setSelectionMode(QTable::NoSelection); |
35 | 35 | ||
36 | m_filename = filename; | 36 | m_filename = filename; |
37 | load(filename); | 37 | load(filename); |
38 | } | 38 | } |
39 | 39 | ||
40 | void QCheckView::deleteClicked(int row, int col) | 40 | void QCheckView::deleteClicked(int row, int col) |
41 | { | 41 | { |
42 | QStringList existing; | 42 | QStringList existing; |
43 | QString rowText = tblTransactions->text(row, 0); | 43 | QString rowText = tblTransactions->text(row, 0); |
44 | config->setGroup(rowText); | 44 | config->setGroup(rowText); |
45 | QString originalamount = config->readEntry("Amount", "0.00"); | 45 | QString originalamount = config->readEntry("Amount", "0.00"); |
46 | 46 | ||
47 | config->setGroup("Data"); | 47 | config->setGroup("Data"); |
48 | int lastCheck = config->readNumEntry("LastCheck", 0); | 48 | int lastCheck = config->readNumEntry("LastCheck", 0); |
49 | 49 | ||
50 | qWarning(rowText); | 50 | qWarning(rowText); |
51 | config->setGroup(rowText); | 51 | config->setGroup(rowText); |
52 | QString payment = config->readEntry("Payment", "true"); | 52 | QString payment = config->readEntry("Payment", "true"); |
53 | if ( payment == QString("true") && rowText.toInt() <= lastCheck) | 53 | if ( payment == QString("true") && rowText.toInt() <= lastCheck) |
54 | { | 54 | { |
55 | for(int i = row; i != (lastCheck); i++) | 55 | for(int i = row; i != (lastCheck); i++) |
56 | { | 56 | { |
57 | config->setGroup(tblTransactions->text(i, 0)); | 57 | config->setGroup(tblTransactions->text(i, 0)); |
58 | QString ibalance = config->readEntry("Balance", "0.00"); | 58 | QString ibalance = config->readEntry("Balance", "0.00"); |
59 | // this adds the old amount on to the transaction and then takes the new amount away | 59 | // this adds the old amount on to the transaction and then takes the new amount away |
60 | QString newbalance = calculator(ibalance, originalamount, false); | 60 | QString newbalance = calculator(ibalance, originalamount, false); |
61 | config->writeEntry("Balance", newbalance); | 61 | config->writeEntry("Balance", newbalance); |
62 | 62 | ||
63 | if (i == (lastCheck - 1)) | 63 | if (i == (lastCheck - 1)) |
64 | { | 64 | { |
65 | config->setGroup("Totals"); | 65 | config->setGroup("Totals"); |
66 | config->writeEntry("Balance", newbalance); | 66 | config->writeEntry("Balance", newbalance); |
67 | break; | 67 | break; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | QString category = config->readEntry("Category", "Error"); | 70 | QString category = config->readEntry("Category", "Error"); |
71 | if (category != QString("Error")) | 71 | if (category != QString("Error")) |
72 | { | 72 | { |
73 | config->setGroup("Totals"); | 73 | config->setGroup("Totals"); |
74 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); | 74 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); |
75 | QString categorytotal = config->readEntry(category, QString("0")); | 75 | QString categorytotal = config->readEntry(category, QString("0")); |
76 | categorytotal = calculator(categorytotal, originalamount, true); | 76 | categorytotal = calculator(categorytotal, originalamount, true); |
77 | config->writeEntry(category, categorytotal); | 77 | config->writeEntry(category, categorytotal); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | if ( payment == QString("false") && rowText.toInt() <= lastCheck) | 80 | if ( payment == QString("false") && rowText.toInt() <= lastCheck) |
81 | { | 81 | { |
82 | for(int i = row; i != (lastCheck); i++) | 82 | for(int i = row; i != (lastCheck); i++) |
83 | { | 83 | { |
84 | config->setGroup(tblTransactions->text(i, 0)); | 84 | config->setGroup(tblTransactions->text(i, 0)); |
85 | QString ibalance = config->readEntry("Balance", "0.00"); | 85 | QString ibalance = config->readEntry("Balance", "0.00"); |
86 | // this subtracts the old amount on to the transaction and then adds the new amount on | 86 | // this subtracts the old amount on to the transaction and then adds the new amount on |
87 | QString newbalance = calculator(ibalance, originalamount, true); | 87 | QString newbalance = calculator(ibalance, originalamount, true); |
88 | config->writeEntry("Balance", newbalance); | 88 | config->writeEntry("Balance", newbalance); |
89 | 89 | ||
90 | if (i == lastCheck - 1) | 90 | if (i == lastCheck - 1) |
91 | { | 91 | { |
92 | config->setGroup("Totals"); | 92 | config->setGroup("Totals"); |
93 | config->writeEntry("Balance", newbalance); | 93 | config->writeEntry("Balance", newbalance); |
94 | break; | 94 | break; |
95 | } | 95 | } |
96 | } | 96 | } |
97 | config->setGroup("Totals"); | 97 | config->setGroup("Totals"); |
98 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); | 98 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); |
99 | } | 99 | } |
100 | for (int i = rowText.toInt(); i != lastCheck; i++) | 100 | for (int i = rowText.toInt(); i != lastCheck; i++) |
101 | { | 101 | { |
102 | qWarning(QString::number(i +1)); | 102 | qWarning(QString::number(i +1)); |
103 | config->setGroup(QString::number(i +1)); | 103 | config->setGroup(QString::number(i +1)); |
104 | QString origamount = config->readEntry("Amount", "0"); | 104 | QString origamount = config->readEntry("Amount", "0"); |
105 | qWarning(origamount); | 105 | qWarning(origamount); |
106 | QString origbalance = config->readEntry("Balance", "0"); | 106 | QString origbalance = config->readEntry("Balance", "0"); |
107 | QString origchecknumber = config->readEntry("CheckNumber", "0"); | 107 | QString origchecknumber = config->readEntry("CheckNumber", "0"); |
108 | QString origcomments = config->readEntry("Comments", ""); | 108 | QString origcomments = config->readEntry("Comments", ""); |
109 | QString origdate = config->readEntry("Date", "01/01/2000"); | 109 | QString origdate = config->readEntry("Date", "01/01/2000"); |
110 | QString origdescription = config->readEntry("Description", "No Description"); | 110 | QString origdescription = config->readEntry("Description", "No Description"); |
111 | QString origpayment = config->readEntry("Payment", "true"); | 111 | QString origpayment = config->readEntry("Payment", "true"); |
112 | QString origtransactionfee = config->readEntry("TransactionFee", "0"); | 112 | QString origtransactionfee = config->readEntry("TransactionFee", "0"); |
113 | QString origtype = config->readEntry("Type", "0"); | 113 | QString origtype = config->readEntry("Type", "0"); |
114 | 114 | ||
115 | if (config->hasKey("Category")) | 115 | if (config->hasKey("Category")) |
116 | { | 116 | { |
117 | QString origcategory = config->readEntry("Category", "No Category"); | 117 | QString origcategory = config->readEntry("Category", "No Category"); |
118 | config->removeGroup(); | 118 | config->removeGroup(); |
119 | config->setGroup(QString::number(i)); | 119 | config->setGroup(QString::number(i)); |
120 | config->clearGroup(); | 120 | config->clearGroup(); |
121 | config->writeEntry("Category", origcategory); | 121 | config->writeEntry("Category", origcategory); |
122 | } else { | 122 | } else { |
123 | config->removeGroup(); | 123 | config->removeGroup(); |
124 | config->setGroup(QString::number(i)); | 124 | config->setGroup(QString::number(i)); |
125 | config->clearGroup(); | 125 | config->clearGroup(); |
126 | } | 126 | } |
127 | config->writeEntry("Amount", origamount); | 127 | config->writeEntry("Amount", origamount); |
128 | config->writeEntry("Balance", origbalance); | 128 | config->writeEntry("Balance", origbalance); |
129 | config->writeEntry("CheckNumber", origchecknumber); | 129 | config->writeEntry("CheckNumber", origchecknumber); |
130 | config->writeEntry("Comments", origcomments); | 130 | config->writeEntry("Comments", origcomments); |
131 | config->writeEntry("Date", origdate); | 131 | config->writeEntry("Date", origdate); |
132 | config->writeEntry("Description", origdescription); | 132 | config->writeEntry("Description", origdescription); |
133 | config->writeEntry("Payment", origpayment); | 133 | config->writeEntry("Payment", origpayment); |
134 | config->writeEntry("TransactionFee", origtransactionfee); | 134 | config->writeEntry("TransactionFee", origtransactionfee); |
135 | config->writeEntry("Type", origtype); | 135 | config->writeEntry("Type", origtype); |
136 | } | 136 | } |
137 | tblTransactions->clearCell(row, col); | 137 | tblTransactions->clearCell(row, col); |
138 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | 138 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); |
139 | config->setGroup("Data"); | 139 | config->setGroup("Data"); |
140 | config->writeEntry("LastCheck", QString::number(QString(config->readEntry("LastCheck", 0)).toInt() -1)); | 140 | config->writeEntry("LastCheck", QString::number(QString(config->readEntry("LastCheck", 0)).toInt() -1)); |
141 | config->write(); | 141 | config->write(); |
142 | delete qcd; | 142 | delete qcd; |
143 | emit reload(m_filename); | 143 | emit reload(m_filename); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | void QCheckView::load(const QString filename) | 147 | void QCheckView::load(const QString filename) |
148 | { | 148 | { |
149 | config = new Config(filename, Config::File); | 149 | config = new Config(filename, Config::File); |
150 | 150 | ||
151 | connect(tblTransactions, SIGNAL(clicked(int, int, int, const QPoint &)), this, SLOT(tableClicked(int, int, int, const QPoint &))); | 151 | connect(tblTransactions, SIGNAL(clicked(int, int, int, const QPoint &)), this, SLOT(tableClicked(int, int, int, const QPoint &))); |
152 | 152 | ||
153 | config->setGroup("Totals"); | 153 | config->setGroup("Totals"); |
154 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | 154 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); |
155 | 155 | ||
156 | config->setGroup("Data"); | 156 | config->setGroup("Data"); |
157 | int lastCheck = config->readNumEntry("LastCheck", 1); | 157 | int lastCheck = config->readNumEntry("LastCheck", 1); |
158 | for (int i = 1; i != (lastCheck + 1); i++) | 158 | for (int i = 1; i != (lastCheck + 1); i++) |
159 | { | 159 | { |
160 | config->setGroup(QString::number(i)); | 160 | config->setGroup(QString::number(i)); |
161 | QString item = config->readEntry("Description", QString("Not Found")); | 161 | QString item = config->readEntry("Description", QString("Not Found")); |
162 | if (item != "Not Found") | 162 | if (item != "Not Found") |
163 | { | 163 | { |
164 | QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, QString::number(i)); | 164 | QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, QString::number(i)); |
165 | QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Description", QString("None"))); | 165 | QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Description", QString("None"))); |
166 | QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Date", QString("None"))); | 166 | QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, config->readEntry("Date", QString("None"))); |
167 | QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + config->readEntry("Amount", QString("0.00")))); | 167 | QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + config->readEntry("Amount", QString("0.00")))); |
168 | int row = tblTransactions->numRows(); | 168 | int row = tblTransactions->numRows(); |
169 | tblTransactions->setNumRows(row + 1); | 169 | tblTransactions->setNumRows(row + 1); |
170 | tblTransactions->setItem(row,0, qti); | 170 | tblTransactions->setItem(row,0, qti); |
171 | tblTransactions->setItem(row,1, qti1); | 171 | tblTransactions->setItem(row,1, qti1); |
172 | tblTransactions->setItem(row,2, qti2); | 172 | tblTransactions->setItem(row,2, qti2); |
173 | tblTransactions->setItem(row,3, qti3); | 173 | tblTransactions->setItem(row,3, qti3); |
174 | tblTransactions->updateCell(row, 0); | 174 | tblTransactions->updateCell(row, 0); |
175 | tblTransactions->updateCell(row, 1); | 175 | tblTransactions->updateCell(row, 1); |
176 | tblTransactions->updateCell(row, 2); | 176 | tblTransactions->updateCell(row, 2); |
177 | tblTransactions->updateCell(row, 3); | 177 | tblTransactions->updateCell(row, 3); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | void QCheckView::editClicked(int row, int col) | 182 | void QCheckView::editClicked(int row, int col) |
183 | { | 183 | { |
184 | delete qcd; | 184 | delete qcd; |
185 | QStringList existing; | 185 | QStringList existing; |
186 | QString rowText = tblTransactions->text(row, 0); | 186 | QString rowText = tblTransactions->text(row, 0); |
187 | config->setGroup("Data"); | 187 | config->setGroup("Data"); |
188 | QString recent = config->readEntry("Recent", ""); | 188 | QString recent = config->readEntry("Recent", ""); |
189 | 189 | ||
190 | config->setGroup(rowText); | 190 | config->setGroup(rowText); |
191 | //We need the original amount to add or subtract to check's blanaces written after this edited check | 191 | //We need the original amount to add or subtract to check's blanaces written after this edited check |
192 | QString originalamount = config->readEntry("Amount", "0.00"); | 192 | QString originalamount = config->readEntry("Amount", "0.00"); |
193 | QString originalcategory = config->readEntry("Category", "None"); | 193 | QString originalcategory = config->readEntry("Category", "None"); |
194 | 194 | ||
195 | existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << originalamount << config->readEntry("TransactionFee", "") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << recent; | 195 | existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << originalamount << config->readEntry("TransactionFee", "") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << recent; |
196 | QStringList result = QCheckEntry::popupEntry(existing); | 196 | QStringList result = QCheckEntry::popupEntry(existing); |
197 | if (result.isEmpty() == false) | 197 | if (result.isEmpty() == false) |
198 | { | 198 | { |
199 | config->setGroup("Data"); | 199 | config->setGroup("Data"); |
200 | int lastCheck = config->readNumEntry("LastCheck", 0); | 200 | int lastCheck = config->readNumEntry("LastCheck", 0); |
201 | config->writeEntry("Recent", result[9]); | 201 | config->writeEntry("Recent", result[9]); |
202 | 202 | ||
203 | config->setGroup(rowText); | 203 | config->setGroup(rowText); |
204 | 204 | ||
205 | tblTransactions->setText(row, 1, result[1]); | 205 | tblTransactions->setText(row, 1, result[1]); |
206 | tblTransactions->updateCell(row, 1); | 206 | tblTransactions->updateCell(row, 1); |
207 | 207 | ||
208 | tblTransactions->setText(row, 2, result[7]); | 208 | tblTransactions->setText(row, 2, result[7]); |
209 | tblTransactions->updateCell(row, 2); | 209 | tblTransactions->updateCell(row, 2); |
210 | 210 | ||
211 | tblTransactions->setText(row, 3, QString("$" + result[5])); | 211 | tblTransactions->setText(row, 3, QString("$" + result[5])); |
212 | tblTransactions->updateCell(row, 3); | 212 | tblTransactions->updateCell(row, 3); |
213 | 213 | ||
214 | // This is how the list looks: | 214 | // This is how the list looks: |
215 | // 0: true or false, true == payment, false == deposit | 215 | // 0: true or false, true == payment, false == deposit |
216 | // 1: description of the transaction | 216 | // 1: description of the transaction |
217 | // 2: category name | 217 | // 2: category name |
218 | // 3: transaction type (stores the integer value of the index of the combobox) | 218 | // 3: transaction type (stores the integer value of the index of the combobox) |
219 | // 4: check number of the transaction (if any) | 219 | // 4: check number of the transaction (if any) |
220 | // 5: transaction amount | 220 | // 5: transaction amount |
221 | // 6: transaction fee (e.g. service charge, or ATM charge). | 221 | // 6: transaction fee (e.g. service charge, or ATM charge). |
222 | // 7: date of the transaction | 222 | // 7: date of the transaction |
223 | // 8: additional comments | 223 | // 8: additional comments |
224 | config->writeEntry("Payment", result[0]); | 224 | config->writeEntry("Payment", result[0]); |
225 | config->writeEntry("Description", result[1]); | 225 | config->writeEntry("Description", result[1]); |
226 | if (result[0] == QString("true")) | 226 | if (result[0] == QString("true")) |
227 | { | 227 | { |
228 | config->writeEntry("Category", result[2]); | 228 | config->writeEntry("Category", result[2]); |
229 | } | 229 | } |
230 | config->writeEntry("Type", result[3]); | 230 | config->writeEntry("Type", result[3]); |
231 | config->writeEntry("CheckNumber", result[4]); | 231 | config->writeEntry("CheckNumber", result[4]); |
232 | config->writeEntry("Amount", result[5]); | 232 | config->writeEntry("Amount", result[5]); |
233 | config->writeEntry("TransactionFee", result[6]); | 233 | config->writeEntry("TransactionFee", result[6]); |
234 | config->writeEntry("Date", result[7]); | 234 | config->writeEntry("Date", result[7]); |
235 | config->writeEntry("Comments", result[8]); | 235 | config->writeEntry("Comments", result[8]); |
236 | if (result[0] == QString("true")) | 236 | if (result[0] == QString("true")) |
237 | { | 237 | { |
238 | if (rowText.toInt() <= lastCheck) | 238 | if (rowText.toInt() <= lastCheck) |
239 | { | 239 | { |
240 | for(int i = (rowText.toInt() - 1); i != (lastCheck); i++) | 240 | for(int i = (rowText.toInt() - 1); i != (lastCheck); i++) |
241 | { | 241 | { |
242 | config->setGroup(tblTransactions->text(i, 0)); | 242 | config->setGroup(tblTransactions->text(i, 0)); |
243 | QString ibalance = config->readEntry("Balance", "0.00"); | 243 | QString ibalance = config->readEntry("Balance", "0.00"); |
244 | 244 | ||
245 | // this adds the old amount on to the transaction and then takes the new amount away | 245 | // this adds the old amount on to the transaction and then takes the new amount away |
246 | QString newbalance = calculator(calculator(ibalance, originalamount, false), result[5], true); | 246 | QString newbalance = calculator(calculator(ibalance, originalamount, false), result[5], true); |
247 | config->writeEntry("Balance", newbalance); | 247 | config->writeEntry("Balance", newbalance); |
248 | if (i == (lastCheck - 1)) | 248 | if (i == (lastCheck - 1)) |
249 | { | 249 | { |
250 | config->setGroup("Totals"); | 250 | config->setGroup("Totals"); |
251 | config->writeEntry("Balance", newbalance); | 251 | config->writeEntry("Balance", newbalance); |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |
256 | config->setGroup("Totals"); | 256 | config->setGroup("Totals"); |
257 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); | 257 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), originalamount, true)); |
258 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), result[5], false)); | 258 | config->writeEntry("Spent", calculator(config->readEntry("Spent", QString("0")), result[5], false)); |
259 | 259 | ||
260 | if (result[2] == originalcategory) | 260 | if (result[2] == originalcategory) |
261 | { | 261 | { |
262 | QString categorytotal = config->readEntry(result[2], QString("0")); | 262 | QString categorytotal = config->readEntry(result[2], QString("0")); |
263 | categorytotal = calculator(categorytotal, originalamount, true); | 263 | categorytotal = calculator(categorytotal, originalamount, true); |
264 | categorytotal = calculator(categorytotal, result[5], false); | 264 | categorytotal = calculator(categorytotal, result[5], false); |
265 | config->writeEntry(result[2], categorytotal); | 265 | config->writeEntry(result[2], categorytotal); |
266 | } else { | 266 | } else { |
267 | QString origtotal = config->readEntry(originalcategory, QString("0")); | 267 | QString origtotal = config->readEntry(originalcategory, QString("0")); |
268 | QString origfinal = calculator(origtotal, result[5], true); | 268 | QString origfinal = calculator(origtotal, result[5], true); |
269 | if (origfinal == "0" || origfinal == "0.00") | 269 | if (origfinal == "0" || origfinal == "0.00") |
270 | { | 270 | { |
271 | config->removeEntry(originalcategory); | 271 | config->removeEntry(originalcategory); |
272 | } else { | 272 | } else { |
273 | config->writeEntry(originalcategory, origfinal); | 273 | config->writeEntry(originalcategory, origfinal); |
274 | } | 274 | } |
275 | QString categorytotal = config->readEntry(result[2], QString("0")); | 275 | QString categorytotal = config->readEntry(result[2], QString("0")); |
276 | categorytotal = calculator(categorytotal, originalamount, false); | 276 | categorytotal = calculator(categorytotal, originalamount, false); |
277 | config->writeEntry(result[2],categorytotal); | 277 | config->writeEntry(result[2],categorytotal); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | if (result[0] == QString("false")) | 280 | if (result[0] == QString("false")) |
281 | { | 281 | { |
282 | if (rowText.toInt() <= lastCheck) | 282 | if (rowText.toInt() <= lastCheck) |
283 | { | 283 | { |
284 | for(int i = (rowText.toInt() - 1 ); i != (lastCheck); i++) | 284 | for(int i = (rowText.toInt() - 1 ); i != (lastCheck); i++) |
285 | { | 285 | { |
286 | config->setGroup(tblTransactions->text(i, 0)); | 286 | config->setGroup(tblTransactions->text(i, 0)); |
287 | QString ibalance = config->readEntry("Balance", "0.00"); | 287 | QString ibalance = config->readEntry("Balance", "0.00"); |
288 | 288 | ||
289 | // this subtracts the old amount on to the transaction and then adds the new amount on | 289 | // this subtracts the old amount on to the transaction and then adds the new amount on |
290 | QString newbalance = calculator(calculator(ibalance, originalamount, true), result[5], false); | 290 | QString newbalance = calculator(calculator(ibalance, originalamount, true), result[5], false); |
291 | config->writeEntry("Balance", newbalance); | 291 | config->writeEntry("Balance", newbalance); |
292 | if (i == lastCheck - 1) | 292 | if (i == lastCheck - 1) |
293 | { | 293 | { |
294 | config->setGroup("Totals"); | 294 | config->setGroup("Totals"); |
295 | config->writeEntry("Balance", newbalance); | 295 | config->writeEntry("Balance", newbalance); |
296 | break; | 296 | break; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | } | 299 | } |
300 | config->setGroup("Totals"); | 300 | config->setGroup("Totals"); |
301 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); | 301 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), originalamount, true)); |
302 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), result[5], false)); | 302 | config->writeEntry("Deposited", calculator(config->readEntry("Deposited", QString("0")), result[5], false)); |
303 | } | 303 | } |
304 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | 304 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); |
305 | config->write(); | 305 | config->write(); |
306 | } | 306 | } |
307 | } | 307 | } |
308 | void QCheckView::tableClicked(int row, int col, int mouseButton, const QPoint &mousePos) | 308 | void QCheckView::tableClicked(int row, int col, int mouseButton, const QPoint &mousePos) |
309 | { | 309 | { |
310 | if (tblTransactions->text(row, col).isEmpty() == false) | 310 | if (tblTransactions->text(row, col).isEmpty() == false) |
311 | { | 311 | { |
312 | QStringList existing; | 312 | QStringList existing; |
313 | config->setGroup(tblTransactions->text(row, 0)); | 313 | config->setGroup(tblTransactions->text(row, 0)); |
314 | existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << config->readEntry("Amount", "0.00") << config->readEntry("TransactionFee", "0.00") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << config->readEntry("Balance", "0.00"); | 314 | existing << config->readEntry("Payment", "true") << config->readEntry("Description", "No Description Found") << config->readEntry("Category", "Misc.") << config->readEntry("Type", "0") << config->readEntry("CheckNumber", "0") << config->readEntry("Amount", "0.00") << config->readEntry("TransactionFee", "0.00") << config->readEntry("Date", "01/01/2001") << config->readEntry("Comments", "") << config->readEntry("Balance", "0.00"); |
315 | qcd = new QCheckDetails(row, col, existing); | 315 | qcd = new QCheckDetails(row, col, existing); |
316 | qcd->showMaximized(); | 316 | qcd->showMaximized(); |
317 | connect(qcd, SIGNAL(editClicked(int, int)), this, SLOT(editClicked(int, int))); | 317 | connect(qcd, SIGNAL(editClicked(int, int)), this, SLOT(editClicked(int, int))); |
318 | connect(qcd, SIGNAL(deleteClicked(int, int)), this, SLOT(deleteClicked(int, int))); | 318 | connect(qcd, SIGNAL(deleteClicked(int, int)), this, SLOT(deleteClicked(int, int))); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void QCheckView::newClicked() | 322 | void QCheckView::newClicked() |
323 | { | 323 | { |
324 | config->setGroup("Data"); | 324 | config->setGroup("Data"); |
325 | QString recent = config->readEntry("Recent", ""); | 325 | QString recent = config->readEntry("Recent", ""); |
326 | QStringList kindablank; | 326 | QStringList kindablank; |
327 | kindablank << recent; | 327 | kindablank << recent; |
328 | QStringList result = QCheckEntry::popupEntry(kindablank); | 328 | QStringList result = QCheckEntry::popupEntry(kindablank); |
329 | if (result.count() > 1) | 329 | if (result.count() > 1) |
330 | { | 330 | { |
331 | QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, result[1]); | 331 | QTableItem *qti = new QTableItem(tblTransactions, QTableItem::Never, result[1]); |
332 | int row = tblTransactions->numRows(); | 332 | int row = tblTransactions->numRows(); |
333 | tblTransactions->setNumRows(row + 1); | 333 | tblTransactions->setNumRows(row + 1); |
334 | tblTransactions->setItem(row,1, qti); | 334 | tblTransactions->setItem(row,1, qti); |
335 | tblTransactions->updateCell(row, 1); | 335 | tblTransactions->updateCell(row, 1); |
336 | config->setGroup("Data"); | 336 | config->setGroup("Data"); |
337 | config->writeEntry("Recent", result[9]); | 337 | config->writeEntry("Recent", result[9]); |
338 | int lastCheck = config->readNumEntry("LastCheck", 0); | 338 | int lastCheck = config->readNumEntry("LastCheck", 0); |
339 | if (lastCheck == 0) | 339 | if (lastCheck == 0) |
340 | { | 340 | { |
341 | config->writeEntry("LastCheck", 1); | 341 | config->writeEntry("LastCheck", 1); |
342 | } else { | 342 | } else { |
343 | config->writeEntry("LastCheck", (lastCheck + 1)); | 343 | config->writeEntry("LastCheck", (lastCheck + 1)); |
344 | } | 344 | } |
345 | QString number = QString::number(lastCheck + 1); | 345 | QString number = QString::number(lastCheck + 1); |
346 | config->setGroup(number); | 346 | config->setGroup(number); |
347 | 347 | ||
348 | QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, number); | 348 | QTableItem *qti1 = new QTableItem(tblTransactions, QTableItem::Never, number); |
349 | tblTransactions->setItem(row, 0, qti1); | 349 | tblTransactions->setItem(row, 0, qti1); |
350 | tblTransactions->updateCell(row, 0); | 350 | tblTransactions->updateCell(row, 0); |
351 | 351 | ||
352 | QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, result[7]); | 352 | QTableItem *qti2 = new QTableItem(tblTransactions, QTableItem::Never, result[7]); |
353 | tblTransactions->setItem(row, 2, qti2); | 353 | tblTransactions->setItem(row, 2, qti2); |
354 | tblTransactions->updateCell(row, 2); | 354 | tblTransactions->updateCell(row, 2); |
355 | 355 | ||
356 | QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + result[5])); | 356 | QTableItem *qti3 = new QTableItem(tblTransactions, QTableItem::Never, QString("$" + result[5])); |
357 | tblTransactions->setItem(row, 3, qti3); | 357 | tblTransactions->setItem(row, 3, qti3); |
358 | tblTransactions->updateCell(row, 3); | 358 | tblTransactions->updateCell(row, 3); |
359 | 359 | ||
360 | // This is how the list looks: | 360 | // This is how the list looks: |
361 | // 0: true or false, true == payment, false == deposit | 361 | // 0: true or false, true == payment, false == deposit |
362 | // 1: description of the transaction | 362 | // 1: description of the transaction |
363 | // 2: category name | 363 | // 2: category name |
364 | // 3: transaction type (stores the integer value of the index of the combobox) | 364 | // 3: transaction type (stores the integer value of the index of the combobox) |
365 | // 4: check number of the transaction (if any) | 365 | // 4: check number of the transaction (if any) |
366 | // 5: transaction amount | 366 | // 5: transaction amount |
367 | // 6: transaction fee (e.g. service charge, or ATM charge). | 367 | // 6: transaction fee (e.g. service charge, or ATM charge). |
368 | // 7: date of the transaction | 368 | // 7: date of the transaction |
369 | config->writeEntry("Payment", result[0]); | 369 | config->writeEntry("Payment", result[0]); |
370 | config->writeEntry("Description", result[1]); | 370 | config->writeEntry("Description", result[1]); |
371 | if (result[0] == QString("true")) | 371 | if (result[0] == QString("true")) |
372 | { | 372 | { |
373 | config->writeEntry("Category", result[2]); | 373 | config->writeEntry("Category", result[2]); |
374 | } | 374 | } |
375 | config->writeEntry("Type", result[3]); | 375 | config->writeEntry("Type", result[3]); |
376 | config->writeEntry("CheckNumber", result[4]); | 376 | config->writeEntry("CheckNumber", result[4]); |
377 | config->writeEntry("Amount", result[5]); | 377 | config->writeEntry("Amount", result[5]); |
378 | config->writeEntry("TransactionFee", result[6]); | 378 | config->writeEntry("TransactionFee", result[6]); |
379 | config->writeEntry("Date", result[7]); | 379 | config->writeEntry("Date", result[7]); |
380 | config->writeEntry("Comments", result[8]); | 380 | config->writeEntry("Comments", result[8]); |
381 | config->setGroup("Totals"); | 381 | config->setGroup("Totals"); |
382 | if (result[0] == QString("true")) | 382 | if (result[0] == QString("true")) |
383 | { | 383 | { |
384 | QString totalspent = config->readEntry("Spent", QString("0")); | 384 | QString totalspent = config->readEntry("Spent", QString("0")); |
385 | totalspent = calculator(totalspent, result[5], false); | 385 | totalspent = calculator(totalspent, result[5], false); |
386 | config->writeEntry("Spent", totalspent); | 386 | config->writeEntry("Spent", totalspent); |
387 | QString balance = config->readEntry("Balance", QString("0")); | 387 | QString balance = config->readEntry("Balance", QString("0")); |
388 | balance = calculator(balance, result[5], true); | 388 | balance = calculator(balance, result[5], true); |
389 | 389 | ||
390 | // Make sure to add the fee on, if any | 390 | // Make sure to add the fee on, if any |
391 | balance = calculator(balance, result[6], true); | 391 | balance = calculator(balance, result[6], true); |
392 | 392 | ||
393 | config->writeEntry("Balance", balance); | 393 | config->writeEntry("Balance", balance); |
394 | 394 | ||
395 | config->setGroup(number); | 395 | config->setGroup(number); |
396 | config->writeEntry("Balance", balance); | 396 | config->writeEntry("Balance", balance); |
397 | 397 | ||
398 | config->setGroup("Totals"); | 398 | config->setGroup("Totals"); |
399 | QString categorytotal = config->readEntry(result[2], QString("0")); | 399 | QString categorytotal = config->readEntry(result[2], QString("0")); |
400 | categorytotal = calculator(categorytotal, result[5], false); | 400 | categorytotal = calculator(categorytotal, result[5], false); |
401 | config->writeEntry(result[2], categorytotal); | 401 | config->writeEntry(result[2], categorytotal); |
402 | } | 402 | } |
403 | if (result[0] == QString("false")) | 403 | if (result[0] == QString("false")) |
404 | { | 404 | { |
405 | QString totaldeposited = config->readEntry("Deposited", QString("0")); | 405 | QString totaldeposited = config->readEntry("Deposited", QString("0")); |
406 | totaldeposited = calculator(totaldeposited, result[5], false); | 406 | totaldeposited = calculator(totaldeposited, result[5], false); |
407 | config->writeEntry("Deposited", totaldeposited); | 407 | config->writeEntry("Deposited", totaldeposited); |
408 | QString balance = config->readEntry("Balance", QString("0")); | 408 | QString balance = config->readEntry("Balance", QString("0")); |
409 | balance = calculator(balance, result[5], false); | 409 | balance = calculator(balance, result[5], false); |
410 | 410 | ||
411 | // Make sure to add the fee on, if any | 411 | // Make sure to add the fee on, if any |
412 | balance = calculator(balance, result[6], true); | 412 | balance = calculator(balance, result[6], true); |
413 | 413 | ||
414 | config->writeEntry("Balance", balance); | 414 | config->writeEntry("Balance", balance); |
415 | 415 | ||
416 | config->setGroup(number); | 416 | config->setGroup(number); |
417 | config->writeEntry("Balance", balance); | 417 | config->writeEntry("Balance", balance); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | config->setGroup("Totals"); | 420 | config->setGroup("Totals"); |
421 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); | 421 | labelBalance->setText(QString("$" + config->readEntry("Balance", QString("0.00")))); |
422 | config->write(); | 422 | config->write(); |
423 | } | 423 | } |
424 | 424 | ||
425 | QString QCheckView::calculator(QString largervalue, QString smallervalue, bool subtract) | 425 | QString QCheckView::calculator(QString largervalue, QString smallervalue, bool subtract) |
426 | { | 426 | { |
427 | // This class provides a way to eliminate the ARM processor problem of not being able to handle | 427 | // This class provides a way to eliminate the ARM processor problem of not being able to handle |
428 | // decimals. I just take the two QString'ed numbers and find the decimal point, then I remove the decimal | 428 | // decimals. I just take the two QString'ed numbers and find the decimal point, then I remove the decimal |
429 | // point seperating the number into two. Then I convert it to cents (times it times 100) and add/ | 429 | // point seperating the number into two. Then I convert it to cents (times it times 100) and add/ |
430 | // substract the two together. Put the decimals back in, and return. | 430 | // substract the two together. Put the decimals back in, and return. |
431 | 431 | ||
432 | largervalue = largervalue.remove(largervalue.find(".", 0, false), 1); | 432 | largervalue = largervalue.remove(largervalue.find(".", 0, false), 1); |
433 | smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1); | 433 | smallervalue = smallervalue.remove(smallervalue.find(".", 0, false), 1); |
434 | 434 | ||
435 | int largercents = largervalue.toInt(); | 435 | int largercents = largervalue.toInt(); |
436 | int smallercents = smallervalue.toInt(); | 436 | int smallercents = smallervalue.toInt(); |
437 | 437 | ||
438 | int finalammount = 0; | 438 | int finalammount = 0; |
439 | 439 | ||
440 | if (subtract == true) | 440 | if (subtract == true) |
441 | { | 441 | { |
442 | finalammount = largercents - smallercents; | 442 | finalammount = largercents - smallercents; |
443 | } else { | 443 | } else { |
444 | finalammount = largercents + smallercents; | 444 | finalammount = largercents + smallercents; |
445 | } | 445 | } |
446 | 446 | ||
447 | QString returnvalue = QString::number(finalammount); | 447 | QString returnvalue = QString::number(finalammount); |
448 | if (returnvalue.length() >= 2) | 448 | if (returnvalue.length() >= 2) |
449 | { | 449 | { |
450 | returnvalue.insert((returnvalue.length() - 2), "."); | 450 | returnvalue.insert((returnvalue.length() - 2), "."); |
451 | } else { | 451 | } else { |
452 | if (returnvalue.length() == 1) | 452 | if (returnvalue.length() == 1) |
453 | { | 453 | { |
454 | returnvalue.prepend("0.0"); | 454 | returnvalue.prepend("0.0"); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | return returnvalue; | 457 | return returnvalue; |
458 | } | 458 | } |