summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/helpwindow.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/helpwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/helpwindow.cpp64
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
@@ -190,42 +190,35 @@ void HelpWindow::textChanged()
190 190
191HelpWindow::~HelpWindow() 191HelpWindow::~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
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,32 +282,37 @@ 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" ) )
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
306void HelpWindow::readBookmarks() 302void 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
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 ] );