summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/helpwindow.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/helpwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/helpwindow.cpp34
1 files changed, 16 insertions, 18 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
@@ -193,39 +193,32 @@ HelpWindow::~HelpWindow()
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
226void HelpWindow::openFile() 219void 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 );
@@ -289,33 +282,38 @@ void HelpWindow::pathSelected( const QString &_path )
289 if ( !exists ) 282 if ( !exists )
290 mHistory[ hist->insertItem( _path ) ] = _path; 283 mHistory[ hist->insertItem( _path ) ] = _path;
291} 284}
292 285
293void HelpWindow::readHistory() 286void HelpWindow::readHistory()
294{ 287{
295 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { 288 if ( !QFile::exists( QDir::currentDirPath() + "/.history" ) )
289 return;
290
296 QFile f( QDir::currentDirPath() + "/.history" ); 291 QFile f( QDir::currentDirPath() + "/.history" );
297 f.open( IO_ReadOnly ); 292 if ( !f.open( IO_ReadOnly ) )
293 return;
294
298 QDataStream s( &f ); 295 QDataStream s( &f );
299 s >> history; 296 s >> history;
300 f.close(); 297 f.close();
301 while ( history.count() > 20 ) 298 while ( history.count() > 20 )
302 history.remove( history.begin() ); 299 history.remove( history.begin() );
303 } 300 }
304}
305 301
306void HelpWindow::readBookmarks() 302void HelpWindow::readBookmarks()
307{ 303{
308 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { 304 if ( !QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) )
305 return;
306
309 QFile f( QDir::currentDirPath() + "/.bookmarks" ); 307 QFile f( QDir::currentDirPath() + "/.bookmarks" );
310 f.open( IO_ReadOnly ); 308 if ( !f.open( IO_ReadOnly ) )
309 return;
311 QDataStream s( &f ); 310 QDataStream s( &f );
312 s >> bookmarks; 311 s >> bookmarks;
313 f.close(); 312 f.close();
314 } 313 }
315}
316 314
317void HelpWindow::histChosen( int i ) 315void 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}