summaryrefslogtreecommitdiff
authorchicken <chicken>2004-11-02 19:46:53 (UTC)
committer chicken <chicken>2004-11-02 19:46:53 (UTC)
commit30c9ee6ca6442c66f02c004dd960b26eeab6dee2 (patch) (unidiff)
tree4e399ff17e29ae3b7769f69e926d76f7dfeb8128
parent029fc220470de74b7c1a148c9ea934c17686149f (diff)
downloadopie-30c9ee6ca6442c66f02c004dd960b26eeab6dee2.zip
opie-30c9ee6ca6442c66f02c004dd960b26eeab6dee2.tar.gz
opie-30c9ee6ca6442c66f02c004dd960b26eeab6dee2.tar.bz2
switching to sqlite3
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/budgetdisplay.cpp2
-rwxr-xr-xnoncore/apps/qashmoney/transfer.h4
2 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/qashmoney/budgetdisplay.cpp b/noncore/apps/qashmoney/budgetdisplay.cpp
index 3fc4e6c..b83eb46 100755
--- a/noncore/apps/qashmoney/budgetdisplay.cpp
+++ b/noncore/apps/qashmoney/budgetdisplay.cpp
@@ -1,417 +1,417 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include <qheader.h> 2#include <qheader.h>
3#include <sqlite.h> 3#include <sqlite3.h>
4 4
5#include "budgetdisplay.h" 5#include "budgetdisplay.h"
6#include "budget.h" 6#include "budget.h"
7#include "datepicker.h" 7#include "datepicker.h"
8#include "transaction.h" 8#include "transaction.h"
9 9
10extern Preferences *preferences; 10extern Preferences *preferences;
11extern Budget *budget; 11extern Budget *budget;
12extern Transaction *transaction; 12extern Transaction *transaction;
13 13
14BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent ) 14BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent )
15 { 15 {
16 QFont font = this->font(); 16 QFont font = this->font();
17 font.setWeight ( QFont::Bold ); 17 font.setWeight ( QFont::Bold );
18 18
19 //set the default date to today 19 //set the default date to today
20 newDate = QDate::currentDate (); 20 newDate = QDate::currentDate ();
21 year = newDate.year(); 21 year = newDate.year();
22 month = newDate.month(); 22 month = newDate.month();
23 day = newDate.day(); 23 day = newDate.day();
24 datelabel = preferences->getDate ( year, month ); 24 datelabel = preferences->getDate ( year, month );
25 25
26 setCaption ( "Budget" ); 26 setCaption ( "Budget" );
27 27
28 firstline = new QHBox ( this ); 28 firstline = new QHBox ( this );
29 firstline->setSpacing ( 2 ); 29 firstline->setSpacing ( 2 );
30 secondline = new QHBox ( this ); 30 secondline = new QHBox ( this );
31 secondline->setSpacing ( 10 ); 31 secondline->setSpacing ( 10 );
32 32
33 menu = new QMenuBar ( this ); 33 menu = new QMenuBar ( this );
34 menu->setFrameStyle ( QFrame::Box | QFrame::Sunken ); 34 menu->setFrameStyle ( QFrame::Box | QFrame::Sunken );
35 budgetmenu = new QPopupMenu ( this ); 35 budgetmenu = new QPopupMenu ( this );
36 lineitemsmenu = new QPopupMenu ( this ); 36 lineitemsmenu = new QPopupMenu ( this );
37 datemenu = new QPopupMenu ( this ); 37 datemenu = new QPopupMenu ( this );
38 menu->insertItem ( "Budget", budgetmenu ); 38 menu->insertItem ( "Budget", budgetmenu );
39 menu->insertItem ( "Line Item", lineitemsmenu ); 39 menu->insertItem ( "Line Item", lineitemsmenu );
40 menu->insertItem ( "Date", datemenu ); 40 menu->insertItem ( "Date", datemenu );
41 budgetmenu->insertItem ( "New", this, SLOT ( newBudget() ), 0, 1 ); 41 budgetmenu->insertItem ( "New", this, SLOT ( newBudget() ), 0, 1 );
42 budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget() ), 0, 2 ); 42 budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget() ), 0, 2 );
43 budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget() ), 0, 3 ); 43 budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget() ), 0, 3 );
44 lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem() ), 0, 1 ); 44 lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem() ), 0, 1 );
45 lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem() ), 0, 2 ); 45 lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem() ), 0, 2 );
46 lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem() ), 0, 3 ); 46 lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem() ), 0, 3 );
47 datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) ); 47 datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) );
48 48
49 budgetbox = new QComboBox ( firstline ); 49 budgetbox = new QComboBox ( firstline );
50 connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) ); 50 connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) );
51 51
52 budgetview = new QComboBox ( firstline ); 52 budgetview = new QComboBox ( firstline );
53 budgetview->insertItem ( "Month" ); 53 budgetview->insertItem ( "Month" );
54 budgetview->insertItem ( "Year" ); 54 budgetview->insertItem ( "Year" );
55 connect ( budgetview, SIGNAL ( activated(int) ), this, SLOT ( setCurrentView(int) ) ); 55 connect ( budgetview, SIGNAL ( activated(int) ), this, SLOT ( setCurrentView(int) ) );
56 56
57 budgeted = new QLabel ( secondline ); 57 budgeted = new QLabel ( secondline );
58 budgeted->setFont ( font ); 58 budgeted->setFont ( font );
59 actual = new QLabel ( secondline ); 59 actual = new QLabel ( secondline );
60 actual->setFont ( font ); 60 actual->setFont ( font );
61 date = new QLabel ( secondline ); 61 date = new QLabel ( secondline );
62 date->setFont ( font ); 62 date->setFont ( font );
63 63
64 listview = new QListView ( this ); 64 listview = new QListView ( this );
65 listview->setAllColumnsShowFocus ( TRUE ); 65 listview->setAllColumnsShowFocus ( TRUE );
66 listview->setShowSortIndicator ( TRUE ); 66 listview->setShowSortIndicator ( TRUE );
67 listview->setRootIsDecorated ( TRUE ); 67 listview->setRootIsDecorated ( TRUE );
68 listview->setMultiSelection ( FALSE ); 68 listview->setMultiSelection ( FALSE );
69 listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13 69 listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13
70 listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14 70 listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14
71 listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15 71 listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15
72 listview->addColumn ( "", 0 ); // line item ids 72 listview->addColumn ( "", 0 ); // line item ids
73 listview->setColumnWidthMode ( 0, QListView::Manual ); 73 listview->setColumnWidthMode ( 0, QListView::Manual );
74 listview->setColumnWidthMode ( 1, QListView::Manual ); 74 listview->setColumnWidthMode ( 1, QListView::Manual );
75 listview->setColumnWidthMode ( 2, QListView::Manual ); 75 listview->setColumnWidthMode ( 2, QListView::Manual );
76 listview->setColumnAlignment ( 1, Qt::AlignRight ); 76 listview->setColumnAlignment ( 1, Qt::AlignRight );
77 listview->setColumnAlignment ( 2, Qt::AlignRight ); 77 listview->setColumnAlignment ( 2, Qt::AlignRight );
78 listview->setColumnWidthMode ( 3, QListView::Manual ); 78 listview->setColumnWidthMode ( 3, QListView::Manual );
79 79
80 listview->header()->setTracking ( FALSE ); 80 listview->header()->setTracking ( FALSE );
81 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) ); 81 connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) );
82 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) ); 82 connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) );
83 83
84 // pull the column sorting preference from the preferences table, and configure the listview accordingly 84 // pull the column sorting preference from the preferences table, and configure the listview accordingly
85 int column = 0; 85 int column = 0;
86 int direction = 0; 86 int direction = 0;
87 preferences->getSortingPreference ( 3, &column, &direction ); 87 preferences->getSortingPreference ( 3, &column, &direction );
88 listview->setSorting ( column, direction ); 88 listview->setSorting ( column, direction );
89 89
90 displayBudgetNames(); 90 displayBudgetNames();
91 91
92 layout = new QVBoxLayout ( this, 2, 2 ); 92 layout = new QVBoxLayout ( this, 2, 2 );
93 layout->setMenuBar ( menu ); 93 layout->setMenuBar ( menu );
94 layout->addWidget ( firstline ); 94 layout->addWidget ( firstline );
95 layout->addWidget ( secondline ); 95 layout->addWidget ( secondline );
96 layout->addWidget ( listview ); 96 layout->addWidget ( listview );
97 } 97 }
98 98
99void BudgetDisplay::deleteBudget () 99void BudgetDisplay::deleteBudget ()
100 { 100 {
101 listview->clear(); 101 listview->clear();
102 transaction->clearBudgetIDs ( currentbudget ); 102 transaction->clearBudgetIDs ( currentbudget );
103 budget->deleteBudget ( currentbudget ); 103 budget->deleteBudget ( currentbudget );
104 if ( budgetbox->count() != 0 ) 104 if ( budgetbox->count() != 0 )
105 displayBudgetNames(); 105 displayBudgetNames();
106 checkBudgets(); 106 checkBudgets();
107 } 107 }
108 108
109void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize ) 109void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize )
110 { 110 {
111 switch ( column ) 111 switch ( column )
112 { 112 {
113 case 0: 113 case 0:
114 preferences->changeColumnPreference ( 13, newsize ); 114 preferences->changeColumnPreference ( 13, newsize );
115 break; 115 break;
116 case 1: 116 case 1:
117 preferences->changeColumnPreference ( 14, newsize ); 117 preferences->changeColumnPreference ( 14, newsize );
118 break; 118 break;
119 case 2: 119 case 2:
120 preferences->changeColumnPreference ( 15, newsize ); 120 preferences->changeColumnPreference ( 15, newsize );
121 break; 121 break;
122 } 122 }
123 } 123 }
124 124
125void BudgetDisplay::saveSortingPreference ( int column ) 125void BudgetDisplay::saveSortingPreference ( int column )
126 { 126 {
127 preferences->changeSortingPreference ( 3, column ); 127 preferences->changeSortingPreference ( 3, column );
128 } 128 }
129 129
130int BudgetDisplay::getIDColumn () 130int BudgetDisplay::getIDColumn ()
131 { 131 {
132 int counter; 132 int counter;
133 int columns = listview->columns(); 133 int columns = listview->columns();
134 for ( counter = 0; counter <= columns; counter++ ) 134 for ( counter = 0; counter <= columns; counter++ )
135 if ( listview->header()->label ( counter ).length() == 0 ) 135 if ( listview->header()->label ( counter ).length() == 0 )
136 return counter; 136 return counter;
137 } 137 }
138 138
139void BudgetDisplay::newBudget () 139void BudgetDisplay::newBudget ()
140 { 140 {
141 constructBudgetWindow(); 141 constructBudgetWindow();
142 int response = nb->exec(); 142 int response = nb->exec();
143 if ( response == 1 ) 143 if ( response == 1 )
144 { 144 {
145 // open a new budget object 145 // open a new budget object
146 int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 ); 146 int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 );
147 transaction->clearBudgetIDs ( addedbudget ); 147 transaction->clearBudgetIDs ( addedbudget );
148 displayBudgetNames(); 148 displayBudgetNames();
149 } 149 }
150 checkBudgets(); 150 checkBudgets();
151 } 151 }
152 152
153void BudgetDisplay::constructBudgetWindow () 153void BudgetDisplay::constructBudgetWindow ()
154 { 154 {
155 //construct and format the new budget window 155 //construct and format the new budget window
156 nb = new QDialog ( this, 0, TRUE ); 156 nb = new QDialog ( this, 0, TRUE );
157 nb->setCaption ( "Budget" ); 157 nb->setCaption ( "Budget" );
158 QLabel *namelabel = new QLabel ( "Budget Name", nb ); 158 QLabel *namelabel = new QLabel ( "Budget Name", nb );
159 budgetname = new QLineEdit ( nb ); 159 budgetname = new QLineEdit ( nb );
160 QLabel *descriptionlabel = new QLabel ( "Description", nb ); 160 QLabel *descriptionlabel = new QLabel ( "Description", nb );
161 description = new QLineEdit ( nb ); 161 description = new QLineEdit ( nb );
162 currencybox = new Currency ( nb ); 162 currencybox = new Currency ( nb );
163 QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 ); 163 QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 );
164 layout->addWidget ( namelabel ); 164 layout->addWidget ( namelabel );
165 layout->addWidget ( budgetname ); 165 layout->addWidget ( budgetname );
166 layout->addWidget ( descriptionlabel ); 166 layout->addWidget ( descriptionlabel );
167 layout->addWidget ( description ); 167 layout->addWidget ( description );
168 layout->addWidget ( currencybox ); 168 layout->addWidget ( currencybox );
169 } 169 }
170 170
171void BudgetDisplay::displayBudgetNames () 171void BudgetDisplay::displayBudgetNames ()
172 { 172 {
173 budgetbox->clear(); 173 budgetbox->clear();
174 if ( budget->getNumberOfBudgets() != 0 ) 174 if ( budget->getNumberOfBudgets() != 0 )
175 { 175 {
176 ids = budget->getBudgetIDs(); 176 ids = budget->getBudgetIDs();
177 for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it ) 177 for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it )
178 { 178 {
179 QString flag = "/opt/QtPalmtop/pics/flags/"; 179 QString flag = "/opt/QtPalmtop/pics/flags/";
180 flag.append ( budget->getCurrency ( (*it).toInt() ) ); 180 flag.append ( budget->getCurrency ( (*it).toInt() ) );
181 flag.append ( ".png" ); 181 flag.append ( ".png" );
182 budgetbox->insertItem ( QPixmap ( flag ), budget->getBudgetName ( (*it).toInt() ) ); 182 budgetbox->insertItem ( QPixmap ( flag ), budget->getBudgetName ( (*it).toInt() ) );
183 } 183 }
184 setCurrentBudget ( 0 ); 184 setCurrentBudget ( 0 );
185 } 185 }
186 else 186 else
187 checkBudgets(); 187 checkBudgets();
188 } 188 }
189 189
190void BudgetDisplay::setCurrentBudget ( int index ) 190void BudgetDisplay::setCurrentBudget ( int index )
191 { 191 {
192 currentbudget = ( ids->operator[] ( index ).toInt() ); 192 currentbudget = ( ids->operator[] ( index ).toInt() );
193 displayLineItems(); 193 displayLineItems();
194 } 194 }
195 195
196void BudgetDisplay::setCurrentView ( int index ) 196void BudgetDisplay::setCurrentView ( int index )
197 { 197 {
198 displayLineItems(); 198 displayLineItems();
199 } 199 }
200 200
201void BudgetDisplay::showCalendar () 201void BudgetDisplay::showCalendar ()
202 { 202 {
203 // create new calendar object and show it 203 // create new calendar object and show it
204 DatePicker *dp = new DatePicker ( QDate ( year, month, day ) ); 204 DatePicker *dp = new DatePicker ( QDate ( year, month, day ) );
205 dp->daylabel->hide(); 205 dp->daylabel->hide();
206 dp->daybox->hide(); 206 dp->daybox->hide();
207 if ( budgetview->currentItem() == 1 ) 207 if ( budgetview->currentItem() == 1 )
208 { 208 {
209 dp->monthlabel->hide(); 209 dp->monthlabel->hide();
210 dp->monthbox->hide(); 210 dp->monthbox->hide();
211 } 211 }
212 dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); 212 dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) );
213 213
214 int response = dp->exec(); 214 int response = dp->exec();
215 if ( response == 1 ) 215 if ( response == 1 )
216 { 216 {
217 // Set date integers 217 // Set date integers
218 year = dp->getYear(); 218 year = dp->getYear();
219 if ( budgetview->currentItem() == 0 ) 219 if ( budgetview->currentItem() == 0 )
220 month = dp->getMonth(); 220 month = dp->getMonth();
221 else 221 else
222 month = newDate.month(); 222 month = newDate.month();
223 datelabel = preferences->getDate ( year, month ); 223 datelabel = preferences->getDate ( year, month );
224 displayLineItems(); 224 displayLineItems();
225 } 225 }
226 } 226 }
227 227
228void BudgetDisplay::newLineItem () 228void BudgetDisplay::newLineItem ()
229 { 229 {
230 //construct and format the new line item window 230 //construct and format the new line item window
231 constructLineItemWindow (); 231 constructLineItemWindow ();
232 232
233 int response = newlineitem->exec(); 233 int response = newlineitem->exec();
234 if ( response == 1 ) 234 if ( response == 1 )
235 { 235 {
236 float amount; 236 float amount;
237 if ( lineitemtime->currentItem() == 0 ) 237 if ( lineitemtime->currentItem() == 0 )
238 amount = lineitemamount->text().toFloat(); 238 amount = lineitemamount->text().toFloat();
239 else if ( lineitemtime->currentItem() == 1 ) 239 else if ( lineitemtime->currentItem() == 1 )
240 amount = lineitemamount->text().toFloat() * 12; 240 amount = lineitemamount->text().toFloat() * 12;
241 else 241 else
242 amount = lineitemamount->text().toFloat() * 52; 242 amount = lineitemamount->text().toFloat() * 52;
243 int lineitemadded = budget->addLineItem ( currentbudget, lineitemname->text(), amount, lineitemtime->currentItem() ); 243 int lineitemadded = budget->addLineItem ( currentbudget, lineitemname->text(), amount, lineitemtime->currentItem() );
244 transaction->clearBudgetIDs ( currentbudget, lineitemadded ); 244 transaction->clearBudgetIDs ( currentbudget, lineitemadded );
245 displayLineItems(); 245 displayLineItems();
246 } 246 }
247 checkBudgets(); 247 checkBudgets();
248 } 248 }
249 249
250void BudgetDisplay::constructLineItemWindow () 250void BudgetDisplay::constructLineItemWindow ()
251 { 251 {
252 //construct and format the new budget window 252 //construct and format the new budget window
253 newlineitem = new QDialog ( this, 0, TRUE ); 253 newlineitem = new QDialog ( this, 0, TRUE );
254 newlineitem->setCaption ( "Line Item" ); 254 newlineitem->setCaption ( "Line Item" );
255 QLabel *namelabel = new QLabel ( "Line Item Name", newlineitem ); 255 QLabel *namelabel = new QLabel ( "Line Item Name", newlineitem );
256 lineitemname = new QLineEdit ( newlineitem ); 256 lineitemname = new QLineEdit ( newlineitem );
257 QLabel *budgetamountlabel = new QLabel ( "Budget Amount", newlineitem ); 257 QLabel *budgetamountlabel = new QLabel ( "Budget Amount", newlineitem );
258 lineitemamount = new QLineEdit ( newlineitem ); 258 lineitemamount = new QLineEdit ( newlineitem );
259 QLabel *lineitemtimelabel = new QLabel ( "Per:", newlineitem ); 259 QLabel *lineitemtimelabel = new QLabel ( "Per:", newlineitem );
260 lineitemtime = new QComboBox ( newlineitem ); 260 lineitemtime = new QComboBox ( newlineitem );
261 lineitemtime->insertItem ( "Year" ); // type 0 261 lineitemtime->insertItem ( "Year" ); // type 0
262 lineitemtime->insertItem ( "Month" ); // type 1 262 lineitemtime->insertItem ( "Month" ); // type 1
263 lineitemtime->insertItem ( "Week" ); // type 2 263 lineitemtime->insertItem ( "Week" ); // type 2
264 QBoxLayout *layout = new QVBoxLayout ( newlineitem, 2, 2 ); 264 QBoxLayout *layout = new QVBoxLayout ( newlineitem, 2, 2 );
265 layout->addWidget ( namelabel ); 265 layout->addWidget ( namelabel );
266 layout->addWidget ( lineitemname ); 266 layout->addWidget ( lineitemname );
267 layout->addWidget ( budgetamountlabel ); 267 layout->addWidget ( budgetamountlabel );
268 layout->addWidget ( lineitemamount ); 268 layout->addWidget ( lineitemamount );
269 layout->addWidget ( lineitemtimelabel ); 269 layout->addWidget ( lineitemtimelabel );
270 layout->addWidget ( lineitemtime ); 270 layout->addWidget ( lineitemtime );
271 } 271 }
272 272
273void BudgetDisplay::deleteLineItem () 273void BudgetDisplay::deleteLineItem ()
274 { 274 {
275 if ( listview->selectedItem() != 0 ) 275 if ( listview->selectedItem() != 0 )
276 { 276 {
277 int lineitemid = listview->selectedItem()->text ( getIDColumn() ).toInt(); 277 int lineitemid = listview->selectedItem()->text ( getIDColumn() ).toInt();
278 transaction->clearBudgetIDs ( currentbudget, lineitemid ); 278 transaction->clearBudgetIDs ( currentbudget, lineitemid );
279 budget->deleteLineItem ( currentbudget, lineitemid ); 279 budget->deleteLineItem ( currentbudget, lineitemid );
280 displayBudgetNames(); 280 displayBudgetNames();
281 } 281 }
282 else 282 else
283 QMessageBox::warning ( this, "QashMoney", "Please select a line item to delete." ); 283 QMessageBox::warning ( this, "QashMoney", "Please select a line item to delete." );
284 checkBudgets(); 284 checkBudgets();
285 } 285 }
286 286
287void BudgetDisplay::displayLineItems () 287void BudgetDisplay::displayLineItems ()
288 { 288 {
289 listview->clear(); 289 listview->clear();
290 if ( budget->getNumberOfBudgets() != 0 ) 290 if ( budget->getNumberOfBudgets() != 0 )
291 { 291 {
292 QString budgettable = budgetbox->currentText(); 292 QString budgettable = budgetbox->currentText();
293 budgettable.append ( QString::number ( currentbudget ) ); 293 budgettable.append ( QString::number ( currentbudget ) );
294 budget->displayLineItems ( currentbudget, listview, month, year, budgetview->currentItem() ); 294 budget->displayLineItems ( currentbudget, listview, month, year, budgetview->currentItem() );
295 totalactual = transaction->getActualTotal ( currentbudget, year, month, budgetview->currentItem() ); 295 totalactual = transaction->getActualTotal ( currentbudget, year, month, budgetview->currentItem() );
296 totalbudget = budget->getBudgetTotal ( currentbudget, budgetview->currentItem() ); 296 totalbudget = budget->getBudgetTotal ( currentbudget, budgetview->currentItem() );
297 updateBudgetInformation(); 297 updateBudgetInformation();
298 } 298 }
299 } 299 }
300 300
301void BudgetDisplay::checkBudgets () 301void BudgetDisplay::checkBudgets ()
302 { 302 {
303 if ( budget->getNumberOfBudgets() == 0 ) 303 if ( budget->getNumberOfBudgets() == 0 )
304 { 304 {
305 budgetview->setEnabled ( FALSE ); 305 budgetview->setEnabled ( FALSE );
306 budgetmenu->setItemEnabled ( 2, FALSE ); 306 budgetmenu->setItemEnabled ( 2, FALSE );
307 budgetmenu->setItemEnabled ( 3, FALSE ); 307 budgetmenu->setItemEnabled ( 3, FALSE );
308 lineitemsmenu->setItemEnabled ( 1, FALSE ); 308 lineitemsmenu->setItemEnabled ( 1, FALSE );
309 lineitemsmenu->setItemEnabled ( 2, FALSE ); 309 lineitemsmenu->setItemEnabled ( 2, FALSE );
310 lineitemsmenu->setItemEnabled ( 3, FALSE ); 310 lineitemsmenu->setItemEnabled ( 3, FALSE );
311 } 311 }
312 else 312 else
313 { 313 {
314 budgetview->setEnabled ( TRUE ); 314 budgetview->setEnabled ( TRUE );
315 budgetmenu->setItemEnabled ( 2, TRUE ); 315 budgetmenu->setItemEnabled ( 2, TRUE );
316 budgetmenu->setItemEnabled ( 3, TRUE ); 316 budgetmenu->setItemEnabled ( 3, TRUE );
317 lineitemsmenu->setItemEnabled ( 1, TRUE ); 317 lineitemsmenu->setItemEnabled ( 1, TRUE );
318 lineitemsmenu->setItemEnabled ( 2, FALSE ); 318 lineitemsmenu->setItemEnabled ( 2, FALSE );
319 lineitemsmenu->setItemEnabled ( 3, FALSE ); 319 lineitemsmenu->setItemEnabled ( 3, FALSE );
320 320
321 if ( budget->getNumberOfLineItems ( currentbudget ) != 0 ) 321 if ( budget->getNumberOfLineItems ( currentbudget ) != 0 )
322 { 322 {
323 lineitemsmenu->setItemEnabled ( 2, TRUE ); 323 lineitemsmenu->setItemEnabled ( 2, TRUE );
324 lineitemsmenu->setItemEnabled ( 3, TRUE ); 324 lineitemsmenu->setItemEnabled ( 3, TRUE );
325 } 325 }
326 } 326 }
327 } 327 }
328 328
329void BudgetDisplay::updateBudgetInformation () 329void BudgetDisplay::updateBudgetInformation ()
330 { 330 {
331 if ( budgetview->currentItem() == 0 ) 331 if ( budgetview->currentItem() == 0 )
332 { 332 {
333 datelabel = preferences->getDate ( year, month ); 333 datelabel = preferences->getDate ( year, month );
334 datelabel.prepend ( "Date: " ); 334 datelabel.prepend ( "Date: " );
335 date->setText ( datelabel ); 335 date->setText ( datelabel );
336 } 336 }
337 else 337 else
338 date->setText ( QString::number ( year ) ); 338 date->setText ( QString::number ( year ) );
339 339
340 QString budget = "Budget: "; 340 QString budget = "Budget: ";
341 budget.append ( totalbudget ); 341 budget.append ( totalbudget );
342 budgeted->setText ( budget ); 342 budgeted->setText ( budget );
343 343
344 QString actualamount = "Actual: "; 344 QString actualamount = "Actual: ";
345 actualamount.append ( totalactual ); 345 actualamount.append ( totalactual );
346 actual->setText ( actualamount ); 346 actual->setText ( actualamount );
347 } 347 }
348 348
349void BudgetDisplay::editBudget () 349void BudgetDisplay::editBudget ()
350 { 350 {
351 constructBudgetWindow(); 351 constructBudgetWindow();
352 352
353 //set the title 353 //set the title
354 budgetname->setText ( budget->getBudgetName ( currentbudget ) ); 354 budgetname->setText ( budget->getBudgetName ( currentbudget ) );
355 //set the description 355 //set the description
356 description->setText ( budget->getBudgetDescription ( currentbudget ) ); 356 description->setText ( budget->getBudgetDescription ( currentbudget ) );
357 // retrieve the two character currency code then 357 // retrieve the two character currency code then
358 // go through the currencty box and find the code 358 // go through the currencty box and find the code
359 //set the currency box to that index number 359 //set the currency box to that index number
360 int count = currencybox->currencybox->count(); 360 int count = currencybox->currencybox->count();
361 QString code = budget->getCurrency ( currentbudget ); 361 QString code = budget->getCurrency ( currentbudget );
362 for ( int counter = 0; count - 1; counter++ ) 362 for ( int counter = 0; count - 1; counter++ )
363 { 363 {
364 if ( QString::compare (currencybox->currencybox->text ( counter ), code ) == 0 ) 364 if ( QString::compare (currencybox->currencybox->text ( counter ), code ) == 0 )
365 { 365 {
366 currencybox->currencybox->setCurrentItem ( counter ); 366 currencybox->currencybox->setCurrentItem ( counter );
367 break; 367 break;
368 } 368 }
369 } 369 }
370 int response = nb->exec(); 370 int response = nb->exec();
371 if ( response == 1 ) 371 if ( response == 1 )
372 { 372 {
373 budget->updateBudget ( budgetname->text(), description->text(), currencybox->currencybox->currentText(), currentbudget ); 373 budget->updateBudget ( budgetname->text(), description->text(), currencybox->currencybox->currentText(), currentbudget );
374 displayBudgetNames(); 374 displayBudgetNames();
375 } 375 }
376 } 376 }
377 377
378void BudgetDisplay::editLineItem () 378void BudgetDisplay::editLineItem ()
379 { 379 {
380 if ( listview->selectedItem() != 0 ) 380 if ( listview->selectedItem() != 0 )
381 { 381 {
382 constructLineItemWindow(); 382 constructLineItemWindow();
383 383
384 // set the line item name 384 // set the line item name
385 lineitemname->setText ( listview->selectedItem()->text( 0 ) ); 385 lineitemname->setText ( listview->selectedItem()->text( 0 ) );
386 386
387 // set the line item time combobox 387 // set the line item time combobox
388 int lineitemtype = budget->getLineItemTime ( currentbudget, listview->selectedItem()->text ( 3 ).toInt() ); 388 int lineitemtype = budget->getLineItemTime ( currentbudget, listview->selectedItem()->text ( 3 ).toInt() );
389 lineitemtime->setCurrentItem ( lineitemtype ); 389 lineitemtime->setCurrentItem ( lineitemtype );
390 390
391 // set the line item amount 391 // set the line item amount
392 float amount = budget->getLineItemAmount ( currentbudget, listview->selectedItem()->text ( 3 ).toInt() ); 392 float amount = budget->getLineItemAmount ( currentbudget, listview->selectedItem()->text ( 3 ).toInt() );
393 if ( lineitemtype == 1 ) 393 if ( lineitemtype == 1 )
394 amount = amount / 12; 394 amount = amount / 12;
395 else if ( lineitemtype == 2 ) 395 else if ( lineitemtype == 2 )
396 amount = amount / 52; 396 amount = amount / 52;
397 lineitemamount->setText ( QString::number ( amount ) ); 397 lineitemamount->setText ( QString::number ( amount ) );
398 398
399 int response = newlineitem->exec(); 399 int response = newlineitem->exec();
400 if ( response == 1 ) 400 if ( response == 1 )
401 { 401 {
402 float amount; 402 float amount;
403 if ( lineitemtime->currentItem() == 0 ) 403 if ( lineitemtime->currentItem() == 0 )
404 amount = lineitemamount->text().toFloat(); 404 amount = lineitemamount->text().toFloat();
405 else if ( lineitemtime->currentItem() == 1 ) 405 else if ( lineitemtime->currentItem() == 1 )
406 amount = lineitemamount->text().toFloat() * 12; 406 amount = lineitemamount->text().toFloat() * 12;
407 else 407 else
408 amount = lineitemamount->text().toFloat() * 52; 408 amount = lineitemamount->text().toFloat() * 52;
409 budget->updateLineItem ( lineitemname->text(), amount, lineitemtime->currentItem(), currentbudget, listview->selectedItem()->text ( 3 ).toInt() ); 409 budget->updateLineItem ( lineitemname->text(), amount, lineitemtime->currentItem(), currentbudget, listview->selectedItem()->text ( 3 ).toInt() );
410 displayLineItems(); 410 displayLineItems();
411 } 411 }
412 } 412 }
413 else 413 else
414 QMessageBox::warning ( this, "QashMoney", "Please select a line item to edit." ); 414 QMessageBox::warning ( this, "QashMoney", "Please select a line item to edit." );
415 } 415 }
416 416
417 417
diff --git a/noncore/apps/qashmoney/transfer.h b/noncore/apps/qashmoney/transfer.h
index e910e7c..cec3386 100755
--- a/noncore/apps/qashmoney/transfer.h
+++ b/noncore/apps/qashmoney/transfer.h
@@ -1,52 +1,52 @@
1#ifndef TRANSFER_H 1#ifndef TRANSFER_H
2#define TRANSFER_H 2#define TRANSFER_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qstring.h> 5#include <qstring.h>
6#include <sqlite.h> 6#include <sqlite3.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8 8
9#include "preferences.h" 9#include "preferences.h"
10 10
11class Transfer 11class Transfer
12 { 12 {
13 public: 13 public:
14 14
15 Transfer (); 15 Transfer ();
16 ~Transfer (); 16 ~Transfer ();
17 17
18 // This function adds a new transfer to the database. It takes the fromaccount, toaccount, 18 // This function adds a new transfer to the database. It takes the fromaccount, toaccount,
19 // number, frombudget, tobudget, day, month, year, amount, cleared 19 // number, frombudget, tobudget, day, month, year, amount, cleared
20 void addTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared ); 20 void addTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared );
21 void updateTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared, int transferid ); 21 void updateTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared, int transferid );
22 22
23 // Deletes a transfer. Takes the transferid as its parameter 23 // Deletes a transfer. Takes the transferid as its parameter
24 void deleteTransfer ( int ); 24 void deleteTransfer ( int );
25 25
26 // Deletes all transfers for a given accountid 26 // Deletes all transfers for a given accountid
27 void deleteAllTransfers ( int accountid ); 27 void deleteAllTransfers ( int accountid );
28 28
29 // Returns the number of checking transfers 29 // Returns the number of checking transfers
30 int getNumberOfTransfers (); 30 int getNumberOfTransfers ();
31 int getNumberOfTransfers ( int accountid ); 31 int getNumberOfTransfers ( int accountid );
32 32
33 void displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate ); 33 void displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate );
34 int getCleared ( int id ); 34 int getCleared ( int id );
35 void setCleared ( int id, int cleared ); 35 void setCleared ( int id, int cleared );
36 int getFromAccountID ( int id ); 36 int getFromAccountID ( int id );
37 int getToAccountID ( int id ); 37 int getToAccountID ( int id );
38 38
39 int getDay ( int id ); 39 int getDay ( int id );
40 int getMonth ( int id ); 40 int getMonth ( int id );
41 int getYear ( int id ); 41 int getYear ( int id );
42 QString getAmount ( int id ); 42 QString getAmount ( int id );
43 43
44 private: 44 private:
45 45
46 sqlite *db; 46 sqlite3 *db;
47 }; 47 };
48 48
49#endif 49#endif
50 50
51 51
52 52