author | erik <erik> | 2007-01-22 22:56:12 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-22 22:56:12 (UTC) |
commit | 9b4871054d01a47b4c546952a0948553413840d6 (patch) (unidiff) | |
tree | 4e0248489c2790cf4225a116cfb903b637d4cdf0 /noncore/apps/opie-gutenbrowser/helpwindow.cpp | |
parent | f60301bab1f8aa3693089036a3791a01ae6f9db8 (diff) | |
download | opie-9b4871054d01a47b4c546952a0948553413840d6.zip opie-9b4871054d01a47b4c546952a0948553413840d6.tar.gz opie-9b4871054d01a47b4c546952a0948553413840d6.tar.bz2 |
Every file in this commit makes a call to a function which returns a value.
Each file also didn't check the return value.
This commit changes it so that every single non-checked call in these files
is checked.
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/helpwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-gutenbrowser/helpwindow.cpp | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/noncore/apps/opie-gutenbrowser/helpwindow.cpp b/noncore/apps/opie-gutenbrowser/helpwindow.cpp index 4bdac02..f444a2e 100644 --- a/noncore/apps/opie-gutenbrowser/helpwindow.cpp +++ b/noncore/apps/opie-gutenbrowser/helpwindow.cpp | |||
@@ -172,78 +172,71 @@ void HelpWindow::textChanged() | |||
172 | if ( !selectedURL.isEmpty() && pathCombo ) { | 172 | if ( !selectedURL.isEmpty() && pathCombo ) { |
173 | bool exists = FALSE; | 173 | bool exists = FALSE; |
174 | int i; | 174 | int i; |
175 | for ( i = 0; i < pathCombo->count(); ++i ) { | 175 | for ( i = 0; i < pathCombo->count(); ++i ) { |
176 | if ( pathCombo->text( i ) == selectedURL ) { | 176 | if ( pathCombo->text( i ) == selectedURL ) { |
177 | exists = TRUE; | 177 | exists = TRUE; |
178 | break; | 178 | break; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | if ( !exists ) { | 181 | if ( !exists ) { |
182 | pathCombo->insertItem( selectedURL, 0 ); | 182 | pathCombo->insertItem( selectedURL, 0 ); |
183 | pathCombo->setCurrentItem( 0 ); | 183 | pathCombo->setCurrentItem( 0 ); |
184 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 184 | mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
185 | } else | 185 | } else |
186 | pathCombo->setCurrentItem( i ); | 186 | pathCombo->setCurrentItem( i ); |
187 | selectedURL = QString::null; | 187 | selectedURL = QString::null; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | HelpWindow::~HelpWindow() | 191 | HelpWindow::~HelpWindow() |
192 | { | 192 | { |
193 | history.clear(); | 193 | history.clear(); |
194 | QMap<int, QString>::Iterator it = mHistory.begin(); | 194 | QMap<int, QString>::Iterator it = mHistory.begin(); |
195 | for ( ; it != mHistory.end(); ++it ) | 195 | for ( ; it != mHistory.end(); ++it ) |
196 | history.append( *it ); | 196 | history.append( *it ); |
197 | 197 | ||
198 | QFile f( QDir::currentDirPath() + "/.history" ); | 198 | QFile f( QDir::currentDirPath() + "/.history" ); |
199 | f.open( IO_WriteOnly ); | 199 | if ( f.open( IO_WriteOnly ) ) { |
200 | QDataStream s( &f ); | 200 | QDataStream s( &f ); |
201 | s << history; | 201 | s << history; |
202 | f.close(); | 202 | f.close(); |
203 | } | ||
203 | 204 | ||
204 | bookmarks.clear(); | 205 | bookmarks.clear(); |
205 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 206 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
206 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 207 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
207 | bookmarks.append( *it2 ); | 208 | bookmarks.append( *it2 ); |
208 | 209 | ||
209 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 210 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
210 | f2.open( IO_WriteOnly ); | 211 | if ( !f2.open( IO_WriteOnly ) ) |
212 | return; | ||
213 | |||
211 | QDataStream s2( &f2 ); | 214 | QDataStream s2( &f2 ); |
212 | s2 << bookmarks; | 215 | s2 << bookmarks; |
213 | f2.close(); | 216 | f2.close(); |
214 | } | 217 | } |
215 | 218 | ||
216 | // void HelpWindow::about() | ||
217 | // { | ||
218 | // QMessageBox::about( this, "Gutenbrowser", "<p>Thanks to Trolltech for this</p>" ); | ||
219 | // } | ||
220 | |||
221 | // void HelpWindow::aboutQt() | ||
222 | // { | ||
223 | // QMessageBox::aboutQt( this, "QBrowser" ); | ||
224 | // } | ||
225 | |||
226 | void HelpWindow::openFile() | 219 | void HelpWindow::openFile() |
227 | { | 220 | { |
228 | #ifndef QT_NO_FILEDIALOG | 221 | #ifndef QT_NO_FILEDIALOG |
229 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); | 222 | QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); |
230 | if ( !fn.isEmpty() ) | 223 | if ( !fn.isEmpty() ) |
231 | browser->setSource( fn ); | 224 | browser->setSource( fn ); |
232 | #endif | 225 | #endif |
233 | } | 226 | } |
234 | 227 | ||
235 | void HelpWindow::newWindow() | 228 | void HelpWindow::newWindow() |
236 | { | 229 | { |
237 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 230 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
238 | } | 231 | } |
239 | 232 | ||
240 | void HelpWindow::print() | 233 | void HelpWindow::print() |
241 | { | 234 | { |
242 | #ifndef QT_NO_PRINTER | 235 | #ifndef QT_NO_PRINTER |
243 | QPrinter printer; | 236 | QPrinter printer; |
244 | printer.setFullPage(TRUE); | 237 | printer.setFullPage(TRUE); |
245 | if ( printer.setup() ) { | 238 | if ( printer.setup() ) { |
246 | QPainter p( &printer ); | 239 | QPainter p( &printer ); |
247 | QPaintDeviceMetrics metrics(p.device()); | 240 | QPaintDeviceMetrics metrics(p.device()); |
248 | int dpix = metrics.logicalDpiX(); | 241 | int dpix = metrics.logicalDpiX(); |
249 | int dpiy = metrics.logicalDpiY(); | 242 | int dpiy = metrics.logicalDpiY(); |
@@ -271,63 +264,68 @@ void HelpWindow::print() | |||
271 | printer.newPage(); | 264 | printer.newPage(); |
272 | page++; | 265 | page++; |
273 | } while (TRUE); | 266 | } while (TRUE); |
274 | } | 267 | } |
275 | #endif | 268 | #endif |
276 | } | 269 | } |
277 | 270 | ||
278 | void HelpWindow::pathSelected( const QString &_path ) | 271 | void HelpWindow::pathSelected( const QString &_path ) |
279 | { | 272 | { |
280 | browser->setSource( _path ); | 273 | browser->setSource( _path ); |
281 | QMap<int, QString>::Iterator it = mHistory.begin(); | 274 | QMap<int, QString>::Iterator it = mHistory.begin(); |
282 | bool exists = FALSE; | 275 | bool exists = FALSE; |
283 | for ( ; it != mHistory.end(); ++it ) { | 276 | for ( ; it != mHistory.end(); ++it ) { |
284 | if ( *it == _path ) { | 277 | if ( *it == _path ) { |
285 | exists = TRUE; | 278 | exists = TRUE; |
286 | break; | 279 | break; |
287 | } | 280 | } |
288 | } | 281 | } |
289 | if ( !exists ) | 282 | if ( !exists ) |
290 | mHistory[ hist->insertItem( _path ) ] = _path; | 283 | mHistory[ hist->insertItem( _path ) ] = _path; |
291 | } | 284 | } |
292 | 285 | ||
293 | void HelpWindow::readHistory() | 286 | void HelpWindow::readHistory() |
294 | { | 287 | { |
295 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 288 | if ( !QFile::exists( QDir::currentDirPath() + "/.history" ) ) |
296 | QFile f( QDir::currentDirPath() + "/.history" ); | 289 | return; |
297 | f.open( IO_ReadOnly ); | 290 | |
298 | QDataStream s( &f ); | 291 | QFile f( QDir::currentDirPath() + "/.history" ); |
299 | s >> history; | 292 | if ( !f.open( IO_ReadOnly ) ) |
300 | f.close(); | 293 | return; |
301 | while ( history.count() > 20 ) | 294 | |
302 | history.remove( history.begin() ); | 295 | QDataStream s( &f ); |
303 | } | 296 | s >> history; |
297 | f.close(); | ||
298 | while ( history.count() > 20 ) | ||
299 | history.remove( history.begin() ); | ||
304 | } | 300 | } |
305 | 301 | ||
306 | void HelpWindow::readBookmarks() | 302 | void HelpWindow::readBookmarks() |
307 | { | 303 | { |
308 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 304 | if ( !QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) |
309 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 305 | return; |
310 | f.open( IO_ReadOnly ); | 306 | |
311 | QDataStream s( &f ); | 307 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
312 | s >> bookmarks; | 308 | if ( !f.open( IO_ReadOnly ) ) |
313 | f.close(); | 309 | return; |
314 | } | 310 | QDataStream s( &f ); |
311 | s >> bookmarks; | ||
312 | f.close(); | ||
315 | } | 313 | } |
316 | 314 | ||
317 | void HelpWindow::histChosen( int i ) | 315 | void HelpWindow::histChosen( int i ) |
318 | { | 316 | { |
319 | if ( mHistory.contains( i ) ) | 317 | if ( mHistory.contains( i ) ) |
320 | browser->setSource( mHistory[ i ] ); | 318 | browser->setSource( mHistory[ i ] ); |
321 | } | 319 | } |
322 | 320 | ||
323 | void HelpWindow::bookmChosen( int i ) | 321 | void HelpWindow::bookmChosen( int i ) |
324 | { | 322 | { |
325 | if ( mBookmarks.contains( i ) ) | 323 | if ( mBookmarks.contains( i ) ) |
326 | browser->setSource( mBookmarks[ i ] ); | 324 | browser->setSource( mBookmarks[ i ] ); |
327 | } | 325 | } |
328 | 326 | ||
329 | void HelpWindow::addBookmark() | 327 | void HelpWindow::addBookmark() |
330 | { | 328 | { |
331 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 329 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
332 | } | 330 | } |
333 | 331 | ||