summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
Unidiff
Diffstat (limited to 'noncore/todayplugins/stockticker/stockticker/helpwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stockticker/helpwindow.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
index 410d642..2498bf9 100644
--- a/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
+++ b/noncore/todayplugins/stockticker/stockticker/helpwindow.cpp
@@ -166,47 +166,49 @@ void HelpWindow::textChanged()
166 } 166 }
167 if ( !exists ) { 167 if ( !exists ) {
168 pathCombo->insertItem( selectedURL, 0 ); 168 pathCombo->insertItem( selectedURL, 0 );
169 pathCombo->setCurrentItem( 0 ); 169 pathCombo->setCurrentItem( 0 );
170 mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; 170 mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
171 } else 171 } else
172 pathCombo->setCurrentItem( i ); 172 pathCombo->setCurrentItem( i );
173 selectedURL = QString::null; 173 selectedURL = QString::null;
174 } 174 }
175} 175}
176 176
177HelpWindow::~HelpWindow() 177HelpWindow::~HelpWindow()
178{ 178{
179 history.clear(); 179 history.clear();
180 QMap<int, QString>::Iterator it = mHistory.begin(); 180 QMap<int, QString>::Iterator it = mHistory.begin();
181 for ( ; it != mHistory.end(); ++it ) 181 for ( ; it != mHistory.end(); ++it )
182 history.append( *it ); 182 history.append( *it );
183 183
184 QFile f( QDir::currentDirPath() + "/.history" ); 184 QFile f( QDir::currentDirPath() + "/.history" );
185 f.open( IO_WriteOnly ); 185 if ( f.open( IO_WriteOnly ) ) {
186 QDataStream s( &f ); 186 QDataStream s( &f );
187 s << history; 187 s << history;
188 f.close(); 188 f.close();
189 }
189 190
190 bookmarks.clear(); 191 bookmarks.clear();
191 QMap<int, QString>::Iterator it2 = mBookmarks.begin(); 192 QMap<int, QString>::Iterator it2 = mBookmarks.begin();
192 for ( ; it2 != mBookmarks.end(); ++it2 ) 193 for ( ; it2 != mBookmarks.end(); ++it2 )
193 bookmarks.append( *it2 ); 194 bookmarks.append( *it2 );
194 195
195 QFile f2( QDir::currentDirPath() + "/.bookmarks" ); 196 QFile f2( QDir::currentDirPath() + "/.bookmarks" );
196 f2.open( IO_WriteOnly ); 197 if ( !f2.open( IO_WriteOnly ) )
198 return;
197 QDataStream s2( &f2 ); 199 QDataStream s2( &f2 );
198 s2 << bookmarks; 200 s2 << bookmarks;
199 f2.close(); 201 f2.close();
200} 202}
201 203
202void HelpWindow::openFile() 204void HelpWindow::openFile()
203{ 205{
204#ifndef QT_NO_FILEDIALOG 206#ifndef QT_NO_FILEDIALOG
205 QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this ); 207 QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );
206 if ( !fn.isEmpty() ) 208 if ( !fn.isEmpty() )
207 browser->setSource( fn ); 209 browser->setSource( fn );
208#endif 210#endif
209} 211}
210 212
211void HelpWindow::newWindow() 213void HelpWindow::newWindow()
212{ 214{
@@ -218,50 +220,52 @@ void HelpWindow::pathSelected( const QString &_path )
218 browser->setSource( _path ); 220 browser->setSource( _path );
219 QMap<int, QString>::Iterator it = mHistory.begin(); 221 QMap<int, QString>::Iterator it = mHistory.begin();
220 bool exists = FALSE; 222 bool exists = FALSE;
221 for ( ; it != mHistory.end(); ++it ) { 223 for ( ; it != mHistory.end(); ++it ) {
222 if ( *it == _path ) { 224 if ( *it == _path ) {
223 exists = TRUE; 225 exists = TRUE;
224 break; 226 break;
225 } 227 }
226 } 228 }
227 if ( !exists ) 229 if ( !exists )
228 mHistory[ hist->insertItem( _path ) ] = _path; 230 mHistory[ hist->insertItem( _path ) ] = _path;
229} 231}
230 232
231void HelpWindow::readHistory() 233void HelpWindow::readHistory()
232{ 234{
233 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { 235 if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) {
234 QFile f( QDir::currentDirPath() + "/.history" ); 236 QFile f( QDir::currentDirPath() + "/.history" );
235 f.open( IO_ReadOnly ); 237 if ( !f.open( IO_ReadOnly ) )
236 QDataStream s( &f ); 238 return;
237 s >> history; 239 QDataStream s( &f );
238 f.close(); 240 s >> history;
239 while ( history.count() > 20 ) 241 f.close();
240 history.remove( history.begin() ); 242 while ( history.count() > 20 )
243 history.remove( history.begin() );
241 } 244 }
242} 245}
243 246
244void HelpWindow::readBookmarks() 247void HelpWindow::readBookmarks()
245{ 248{
246 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { 249 if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) {
247 QFile f( QDir::currentDirPath() + "/.bookmarks" ); 250 QFile f( QDir::currentDirPath() + "/.bookmarks" );
248 f.open( IO_ReadOnly ); 251 if ( !f.open( IO_ReadOnly ) )
249 QDataStream s( &f ); 252 return;
250 s >> bookmarks; 253 QDataStream s( &f );
251 f.close(); 254 s >> bookmarks;
255 f.close();
252 } 256 }
253} 257}
254 258
255void HelpWindow::histChosen( int i ) 259void HelpWindow::histChosen( int i )
256{ 260{
257 if ( mHistory.contains( i ) ) 261 if ( mHistory.contains( i ) )
258 browser->setSource( mHistory[ i ] ); 262 browser->setSource( mHistory[ i ] );
259} 263}
260 264
261void HelpWindow::bookmChosen( int i ) 265void HelpWindow::bookmChosen( int i )
262{ 266{
263 if ( mBookmarks.contains( i ) ) 267 if ( mBookmarks.contains( i ) )
264 browser->setSource( mBookmarks[ i ] ); 268 browser->setSource( mBookmarks[ i ] );
265} 269}
266 270
267void HelpWindow::addBookmark() 271void HelpWindow::addBookmark()