author | mickeyl <mickeyl> | 2003-10-27 19:51:32 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-27 19:51:32 (UTC) |
commit | 951d1d4125a80dc814f95d2956853bf53ca52e9a (patch) (unidiff) | |
tree | 46c7a70b80a7eebb54cd59c46204c28335f3821c /noncore/apps/checkbook/cbinfo.cpp | |
parent | f0a15a9866f9eddfe10596e63a1e6300b92b9e3f (diff) | |
download | opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.zip opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.gz opie-951d1d4125a80dc814f95d2956853bf53ca52e9a.tar.bz2 |
merge noncore/apps/* except
- advancedfm (ljp, please...)
- odict (tille, please...)
Diffstat (limited to 'noncore/apps/checkbook/cbinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/cbinfo.cpp | 116 |
1 files changed, 74 insertions, 42 deletions
diff --git a/noncore/apps/checkbook/cbinfo.cpp b/noncore/apps/checkbook/cbinfo.cpp index 9fdc6b2..36dde04 100644 --- a/noncore/apps/checkbook/cbinfo.cpp +++ b/noncore/apps/checkbook/cbinfo.cpp | |||
@@ -35,2 +35,3 @@ | |||
35 | 35 | ||
36 | // --- CBInfo ----------------------------------------------------------------- | ||
36 | CBInfo::CBInfo() | 37 | CBInfo::CBInfo() |
@@ -46,2 +47,5 @@ CBInfo::CBInfo() | |||
46 | sb = 0.0; | 47 | sb = 0.0; |
48 | _sLastTab=""; | ||
49 | _first=-1; | ||
50 | _last=-1; | ||
47 | 51 | ||
@@ -50,2 +54,4 @@ CBInfo::CBInfo() | |||
50 | 54 | ||
55 | |||
56 | // --- CBInfo ----------------------------------------------------------------- | ||
51 | CBInfo::CBInfo( const QString &name, const QString &filename ) | 57 | CBInfo::CBInfo( const QString &name, const QString &filename ) |
@@ -64,2 +70,5 @@ CBInfo::CBInfo( const QString &name, const QString &filename ) | |||
64 | nt = config.readEntry( "Notes", "" ); | 70 | nt = config.readEntry( "Notes", "" ); |
71 | _sLastTab = config.readEntry("LastTab", ""); | ||
72 | _first=config.readNumEntry("First", -1); | ||
73 | _sSortOrder = config.readEntry( "SortOrder", QWidget::tr("Date") ); | ||
65 | 74 | ||
@@ -71,2 +80,3 @@ CBInfo::CBInfo( const QString &name, const QString &filename ) | |||
71 | 80 | ||
81 | // --- balance ---------------------------------------------------------------- | ||
72 | float CBInfo::balance() | 82 | float CBInfo::balance() |
@@ -77,2 +87,3 @@ float CBInfo::balance() | |||
77 | 87 | ||
88 | // --- write ------------------------------------------------------------------ | ||
78 | void CBInfo::write() | 89 | void CBInfo::write() |
@@ -81,5 +92,3 @@ void CBInfo::write() | |||
81 | if ( f.exists() ) | 92 | if ( f.exists() ) |
82 | { | ||
83 | f.remove(); | 93 | f.remove(); |
84 | } | ||
85 | 94 | ||
@@ -87,3 +96,20 @@ void CBInfo::write() | |||
87 | 96 | ||
88 | // Save info | 97 | |
98 | // fix transaction numbers | ||
99 | _first=-1; | ||
100 | TranInfo *prev=NULL; | ||
101 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { | ||
102 | if( _first<0 ) _first=tran->id(); | ||
103 | if( prev ) prev->setNext( tran->id() ); | ||
104 | tran->setNext(-1); | ||
105 | prev=tran; | ||
106 | } | ||
107 | |||
108 | // Save transactions | ||
109 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) { | ||
110 | tran->write(config); | ||
111 | } | ||
112 | |||
113 | // Save info | ||
114 | if( _first<0 && _last>=0 ) _first=_last; | ||
89 | config->setGroup( "Account" ); | 115 | config->setGroup( "Account" ); |
@@ -95,2 +121,3 @@ void CBInfo::write() | |||
95 | config->writeEntry( "Notes", nt ); | 121 | config->writeEntry( "Notes", nt ); |
122 | config->writeEntry( "LastTab", _sLastTab ); | ||
96 | QString balstr; | 123 | QString balstr; |
@@ -98,12 +125,6 @@ void CBInfo::write() | |||
98 | config->writeEntry( "Balance", balstr ); | 125 | config->writeEntry( "Balance", balstr ); |
126 | config->writeEntry( "First", _first ); | ||
127 | config->writeEntry( "SortOrder", _sSortOrder ); | ||
99 | 128 | ||
100 | // Save transactions | 129 | config->write(); |
101 | int i = 1; | ||
102 | for ( TranInfo *tran = tl->first(); tran; tran = tl->next() ) | ||
103 | { | ||
104 | tran->write( config, i ); | ||
105 | i++; | ||
106 | } | ||
107 | config->write(); | ||
108 | |||
109 | delete config; | 130 | delete config; |
@@ -111,14 +132,16 @@ void CBInfo::write() | |||
111 | 132 | ||
112 | TranInfo *CBInfo::findTransaction( const QString &checknum, const QString &date, | 133 | |
113 | const QString &desc ) | 134 | // --- findTransaction -------------------------------------------------------- |
135 | TranInfo *CBInfo::findTransaction( const QString &sId ) | ||
114 | { | 136 | { |
115 | TranInfo *traninfo = tl->first(); | 137 | bool bOk; |
116 | while ( traninfo ) | 138 | int id=sId.toInt( &bOk ); |
117 | { | 139 | if( !bOk ) |
118 | if ( traninfo->number() == checknum && traninfo->datestr() == date && | 140 | return(false); |
119 | traninfo->desc() == desc ) | 141 | TranInfo *traninfo; |
120 | break; | 142 | for(traninfo=tl->first(); traninfo; traninfo=tl->next()) { |
121 | traninfo = tl->next(); | 143 | if( traninfo->id() == id ) |
122 | } | 144 | break; |
123 | return( traninfo ); | 145 | } |
146 | return(traninfo); | ||
124 | } | 147 | } |
@@ -127,3 +150,3 @@ void CBInfo::addTransaction( TranInfo *tran ) | |||
127 | { | 150 | { |
128 | tl->inSort( tran ); | 151 | tl->append( tran ); |
129 | calcBalance(); | 152 | calcBalance(); |
@@ -133,4 +156,4 @@ void CBInfo::removeTransaction( TranInfo *tran ) | |||
133 | { | 156 | { |
134 | tl->remove( tran ); | 157 | tl->removeRef( tran ); |
135 | delete tran; | 158 | delete tran; |
136 | calcBalance(); | 159 | calcBalance(); |
@@ -138,2 +161,5 @@ void CBInfo::removeTransaction( TranInfo *tran ) | |||
138 | 161 | ||
162 | |||
163 | // --- loadTransactions ------------------------------------------------------- | ||
164 | // Reads the transactions. Either the old way 1-n or as linked list. | ||
139 | void CBInfo::loadTransactions() | 165 | void CBInfo::loadTransactions() |
@@ -146,20 +172,25 @@ void CBInfo::loadTransactions() | |||
146 | Config config( fn, Config::File ); | 172 | Config config( fn, Config::File ); |
147 | 173 | int i=_first; | |
148 | for ( int i = 1; trandesc != QString::null; i++ ) | 174 | bool bOld=false; |
149 | { | 175 | if( i==-1 ) { |
150 | tran = new TranInfo( config, i ); | 176 | i=1; |
151 | trandesc = tran->desc(); | 177 | bOld=true; |
152 | if ( trandesc != QString::null ) | 178 | } |
153 | { | 179 | while( i>=0 ) { |
154 | tl->inSort( tran ); | 180 | _last=i; |
155 | } | 181 | tran=new TranInfo(config, i); |
156 | else | 182 | trandesc = tran->desc(); |
157 | { | 183 | if( trandesc==QString::null ) { |
158 | delete tran; | 184 | delete tran; |
159 | } | 185 | break; |
160 | } | 186 | } |
161 | 187 | tl->append(tran); | |
162 | calcBalance(); | 188 | i= bOld ? i+1 : tran->getNext(); |
189 | } | ||
190 | |||
191 | calcBalance(); | ||
163 | } | 192 | } |
164 | 193 | ||
194 | |||
195 | // --- calcBalance ------------------------------------------------------------ | ||
165 | void CBInfo::calcBalance() | 196 | void CBInfo::calcBalance() |
@@ -182,2 +213,3 @@ void CBInfo::calcBalance() | |||
182 | 213 | ||
214 | |||
183 | int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) | 215 | int CBInfoList::compareItems( QCollection::Item item1, QCollection::Item item2 ) |