summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/cbinfo.cpp2
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/noncore/apps/checkbook/cbinfo.cpp b/noncore/apps/checkbook/cbinfo.cpp
index 3a39317..9fdc6b2 100644
--- a/noncore/apps/checkbook/cbinfo.cpp
+++ b/noncore/apps/checkbook/cbinfo.cpp
@@ -71,49 +71,49 @@ CBInfo::CBInfo( const QString &name, const QString &filename )
71 71
72float CBInfo::balance() 72float CBInfo::balance()
73{ 73{
74 calcBalance(); 74 calcBalance();
75 return b; 75 return b;
76} 76}
77 77
78void CBInfo::write() 78void CBInfo::write()
79{ 79{
80 QFile f( fn ); 80 QFile f( fn );
81 if ( f.exists() ) 81 if ( f.exists() )
82 { 82 {
83 f.remove(); 83 f.remove();
84 } 84 }
85 85
86 Config *config = new Config(fn, Config::File); 86 Config *config = new Config(fn, Config::File);
87 87
88 // Save info 88 // Save info
89 config->setGroup( "Account" ); 89 config->setGroup( "Account" );
90 config->writeEntryCrypt( "Password", pw ); 90 config->writeEntryCrypt( "Password", pw );
91 config->writeEntry( "Type", t ); 91 config->writeEntry( "Type", t );
92 config->writeEntry( "Bank", bn ); 92 config->writeEntry( "Bank", bn );
93 config->writeEntryCrypt( "Number", a ); 93 config->writeEntryCrypt( "Number", a );
94 config->writeEntryCrypt( "PINNumber", p ); 94 config->writeEntryCrypt( "PINNumber", p );
95 config->writeEntry( "Notes", n ); 95 config->writeEntry( "Notes", nt );
96 QString balstr; 96 QString balstr;
97 balstr.setNum( sb, 'f', 2 ); 97 balstr.setNum( sb, 'f', 2 );
98 config->writeEntry( "Balance", balstr ); 98 config->writeEntry( "Balance", balstr );
99 99
100 // Save transactions 100 // Save transactions
101 int i = 1; 101 int i = 1;
102 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) 102 for ( TranInfo *tran = tl->first(); tran; tran = tl->next() )
103 { 103 {
104 tran->write( config, i ); 104 tran->write( config, i );
105 i++; 105 i++;
106 } 106 }
107 config->write(); 107 config->write();
108 108
109 delete config; 109 delete config;
110} 110}
111 111
112TranInfo *CBInfo::findTransaction( const QString &checknum, const QString &date, 112TranInfo *CBInfo::findTransaction( const QString &checknum, const QString &date,
113 const QString &desc ) 113 const QString &desc )
114{ 114{
115 TranInfo *traninfo = tl->first(); 115 TranInfo *traninfo = tl->first();
116 while ( traninfo ) 116 while ( traninfo )
117 { 117 {
118 if ( traninfo->number() == checknum && traninfo->datestr() == date && 118 if ( traninfo->number() == checknum && traninfo->datestr() == date &&
119 traninfo->desc() == desc ) 119 traninfo->desc() == desc )
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index 68c6aee..cabd231 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -183,48 +183,54 @@ void MainWindow::addCheckbook( CBInfo *cb )
183 lvi->setText( posName, cb->name() ); 183 lvi->setText( posName, cb->name() );
184 if ( showBalances ) 184 if ( showBalances )
185 { 185 {
186 QString balance; 186 QString balance;
187 balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() ); 187 balance.sprintf( "%s%.2f", currencySymbol.latin1(), cb->balance() );
188 lvi->setText( posName + 1, balance ); 188 lvi->setText( posName + 1, balance );
189 } 189 }
190} 190}
191 191
192void MainWindow::buildFilename( const QString &name ) 192void MainWindow::buildFilename( const QString &name )
193{ 193{
194 tempFilename = cbDir; 194 tempFilename = cbDir;
195 tempFilename.append( name ); 195 tempFilename.append( name );
196 tempFilename.append( ".qcb" ); 196 tempFilename.append( ".qcb" );
197} 197}
198 198
199void MainWindow::slotNew() 199void MainWindow::slotNew()
200{ 200{
201 CBInfo *cb = new CBInfo(); 201 CBInfo *cb = new CBInfo();
202 202
203 Checkbook *currcb = new Checkbook( this, cb, currencySymbol ); 203 Checkbook *currcb = new Checkbook( this, cb, currencySymbol );
204 currcb->showMaximized(); 204 currcb->showMaximized();
205 if ( currcb->exec() == QDialog::Accepted ) 205 if ( currcb->exec() == QDialog::Accepted )
206 { 206 {
207 // Save new checkbook
208 buildFilename( cb->name() );
209 cb->setFilename( tempFilename );
210 cb->write();
211
212 // Add to listbox
207 checkbooks->inSort( cb ); 213 checkbooks->inSort( cb );
208 addCheckbook( cb ); 214 addCheckbook( cb );
209 } 215 }
210 delete currcb; 216 delete currcb;
211} 217}
212 218
213void MainWindow::slotEdit() 219void MainWindow::slotEdit()
214{ 220{
215 221
216 QListViewItem *curritem = cbList->currentItem(); 222 QListViewItem *curritem = cbList->currentItem();
217 if ( !curritem ) 223 if ( !curritem )
218 { 224 {
219 return; 225 return;
220 } 226 }
221 QString currname = curritem->text( posName ); 227 QString currname = curritem->text( posName );
222 228
223 CBInfo *cb = checkbooks->first(); 229 CBInfo *cb = checkbooks->first();
224 while ( cb ) 230 while ( cb )
225 { 231 {
226 if ( cb->name() == currname ) 232 if ( cb->name() == currname )
227 break; 233 break;
228 cb = checkbooks->next(); 234 cb = checkbooks->next();
229 } 235 }
230 if ( !cb ) 236 if ( !cb )