summaryrefslogtreecommitdiff
path: root/noncore/apps/checkbook/mainwindow.cpp
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/apps/checkbook/mainwindow.cpp
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/apps/checkbook/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index d0fac3b..254ce6a 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -79,193 +79,193 @@ MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ )
79 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); 79 connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) );
80 actionOpen->addTo( popup ); 80 actionOpen->addTo( popup );
81 actionOpen->addTo( bar ); 81 actionOpen->addTo( bar );
82 82
83 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 83 actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
84 0, this, 0 ); 84 0, this, 0 );
85 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); 85 actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) );
86 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); 86 connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) );
87 actionDelete->addTo( popup ); 87 actionDelete->addTo( popup );
88 actionDelete->addTo( bar ); 88 actionDelete->addTo( bar );
89 89
90 popup->insertSeparator(); 90 popup->insertSeparator();
91 91
92 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 92 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
93 a->setWhatsThis( tr( "Click here to configure this app." ) ); 93 a->setWhatsThis( tr( "Click here to configure this app." ) );
94 connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); 94 connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) );
95 a->addTo( popup ); 95 a->addTo( popup );
96 a->addTo( bar ); 96 a->addTo( bar );
97 97
98 mb->insertItem( tr( "Checkbook" ), popup ); 98 mb->insertItem( tr( "Checkbook" ), popup );
99 99
100 // Load Checkbook selection list 100 // Load Checkbook selection list
101 checkbooks = new CBInfoList(); 101 checkbooks = new CBInfoList();
102 102
103 QDir checkdir( cbDir ); 103 QDir checkdir( cbDir );
104 if (checkdir.exists() == true) 104 if (checkdir.exists() == true)
105 { 105 {
106 QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, 106 QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable,
107 QDir::Time ); 107 QDir::Time );
108 CBInfo *cb = 0x0; 108 CBInfo *cb = 0x0;
109 QString filename; 109 QString filename;
110 110
111 for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) 111 for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ )
112 { 112 {
113 filename = cbDir; 113 filename = cbDir;
114 filename.append( (*it) ); 114 filename.append( (*it) );
115 115
116 cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); 116 cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename );
117 checkbooks->inSort( cb ); 117 checkbooks->inSort( cb );
118 } 118 }
119 } 119 }
120 120
121 // Build Checkbook selection list control 121 // Build Checkbook selection list control
122 cbList = 0x0; 122 cbList = 0x0;
123 buildList(); 123 buildList();
124 124
125 // open last book? 125 // open last book?
126 if( _cfg.isOpenLastBook() ) { 126 if( _cfg.isOpenLastBook() ) {
127 this->show(); 127 this->show();
128 this->showMaximized(); 128 this->showMaximized();
129 QListViewItem *itm=cbList->firstChild(); 129 QListViewItem *itm=cbList->firstChild();
130 while( itm ) { 130 while( itm ) {
131 if( itm->text(posName)==_cfg.getLastBook() ) { 131 if( itm->text(posName)==_cfg.getLastBook() ) {
132 openBook( itm ); 132 openBook( itm );
133 break; 133 break;
134 } 134 }
135 itm=itm->nextSibling(); 135 itm=itm->nextSibling();
136 } 136 }
137 } 137 }
138} 138}
139 139
140 140
141// --- ~MainWindow ------------------------------------------------------------ 141// --- ~MainWindow ------------------------------------------------------------
142MainWindow::~MainWindow() 142MainWindow::~MainWindow()
143{ 143{
144 writeConfig(); 144 writeConfig();
145} 145}
146 146
147 147
148// --- buildList -------------------------------------------------------------- 148// --- buildList --------------------------------------------------------------
149void MainWindow::buildList() 149void MainWindow::buildList()
150{ 150{
151 if ( cbList ) 151 if ( cbList )
152 delete cbList; 152 delete cbList;
153 153
154 cbList = new QListView( this ); 154 cbList = new QListView( this );
155 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); 155 QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) );
156 156
157 if ( _cfg.getShowLocks() ) 157 if ( _cfg.getShowLocks() )
158 { 158 {
159 cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); 159 cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 );
160 posName = 1; 160 posName = 1;
161 } 161 }
162 else 162 else
163 { 163 {
164 posName = 0; 164 posName = 0;
165 } 165 }
166 cbList->addColumn( tr( "Checkbook Name" ) ); 166 cbList->addColumn( tr( "Checkbook Name" ) );
167 if ( _cfg.getShowBalances() ) 167 if ( _cfg.getShowBalances() )
168 { 168 {
169 int colnum = cbList->addColumn( tr( "Balance" ) ); 169 int colnum = cbList->addColumn( tr( "Balance" ) );
170 cbList->setColumnAlignment( colnum, Qt::AlignRight ); 170 cbList->setColumnAlignment( colnum, Qt::AlignRight );
171 } 171 }
172 cbList->setAllColumnsShowFocus( TRUE ); 172 cbList->setAllColumnsShowFocus( TRUE );
173 cbList->setSorting( posName ); 173 cbList->setSorting( posName );
174 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); 174 QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold );
175 connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), 175 connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ),
176 this, SLOT( slotEdit() ) ); 176 this, SLOT( slotEdit() ) );
177 setCentralWidget( cbList ); 177 setCentralWidget( cbList );
178 178
179 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) 179 for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() )
180 { 180 {
181 addCheckbook( cb ); 181 addCheckbook( cb );
182 } 182 }
183} 183}
184 184
185void MainWindow::addCheckbook( CBInfo *cb ) 185void MainWindow::addCheckbook( CBInfo *cb )
186{ 186{
187 QListViewItem *lvi = new QListViewItem( cbList ); 187 QListViewItem *lvi = new QListViewItem( cbList );
188 if ( _cfg.getShowLocks() && !cb->password().isNull() ) 188 if ( _cfg.getShowLocks() && !cb->password().isNull() )
189 { 189 {
190 lvi->setPixmap( 0, lockIcon ); 190 lvi->setPixmap( 0, lockIcon );
191 } 191 }
192 lvi->setText( posName, cb->name() ); 192 lvi->setText( posName, cb->name() );
193 if ( _cfg.getShowBalances() ) 193 if ( _cfg.getShowBalances() )
194 { 194 {
195 QString balance; 195 QString balance;
196 balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); 196 balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() );
197 lvi->setText( posName + 1, balance ); 197 lvi->setText( posName + 1, balance );
198 } 198 }
199} 199}
200 200
201void MainWindow::buildFilename( const QString &name ) 201void MainWindow::buildFilename( const QString &name )
202{ 202{
203 tempFilename = cbDir; 203 tempFilename = cbDir;
204 tempFilename.append( name ); 204 tempFilename.append( name );
205 tempFilename.append( ".qcb" ); 205 tempFilename.append( ".qcb" );
206} 206}
207 207
208void MainWindow::slotNew() 208void MainWindow::slotNew()
209{ 209{
210 CBInfo *cb = new CBInfo(); 210 CBInfo *cb = new CBInfo();
211 211
212 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 212 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
213 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) 213 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
214 { 214 {
215 // Save new checkbook 215 // Save new checkbook
216 buildFilename( cb->name() ); 216 buildFilename( cb->name() );
217 _cfg.setLastBook( cb->name() ); 217 _cfg.setLastBook( cb->name() );
218 cb->setFilename( tempFilename ); 218 cb->setFilename( tempFilename );
219 cb->write(); 219 cb->write();
220 220
221 // Add to listbox 221 // Add to listbox
222 checkbooks->inSort( cb ); 222 checkbooks->inSort( cb );
223 addCheckbook( cb ); 223 addCheckbook( cb );
224 } 224 }
225 delete currcb; 225 delete currcb;
226} 226}
227 227
228// --- slotEdit --------------------------------------------------------------- 228// --- slotEdit ---------------------------------------------------------------
229void MainWindow::slotEdit() 229void MainWindow::slotEdit()
230{ 230{
231 // get name and open it 231 // get name and open it
232 QListViewItem *curritem = cbList->currentItem(); 232 QListViewItem *curritem = cbList->currentItem();
233 if ( !curritem ) 233 if ( !curritem )
234 return; 234 return;
235 openBook( curritem ); 235 openBook( curritem );
236} 236}
237 237
238 238
239// --- openBook --------------------------------------------------------------- 239// --- openBook ---------------------------------------------------------------
240void MainWindow::openBook(QListViewItem *curritem) 240void MainWindow::openBook(QListViewItem *curritem)
241{ 241{
242 // find book in List 242 // find book in List
243 QString currname=curritem->text(posName); 243 QString currname=curritem->text(posName);
244 CBInfo *cb = checkbooks->first(); 244 CBInfo *cb = checkbooks->first();
245 while ( cb ) { 245 while ( cb ) {
246 if ( cb->name() == currname ) 246 if ( cb->name() == currname )
247 break; 247 break;
248 cb = checkbooks->next(); 248 cb = checkbooks->next();
249 } 249 }
250 if ( !cb ) return; 250 if ( !cb ) return;
251 251
252 // 252 //
253 buildFilename( currname ); 253 buildFilename( currname );
254 float currbalance = cb->balance(); 254 float currbalance = cb->balance();
255 bool currlock = !cb->password().isNull(); 255 bool currlock = !cb->password().isNull();
256 256
257 if ( currlock ) 257 if ( currlock )
258 { 258 {
259 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); 259 Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
260 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) 260 if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() )
261 { 261 {
262 delete pw; 262 delete pw;
263 return; 263 return;
264 } 264 }
265 delete pw; 265 delete pw;
266 } 266 }
267 267
268 _cfg.setLastBook( currname ); 268 _cfg.setLastBook( currname );
269 Checkbook *currcb = new Checkbook( this, cb, &_cfg ); 269 Checkbook *currcb = new Checkbook( this, cb, &_cfg );
270 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) 270 if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
271 { 271 {