summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp26
-rw-r--r--noncore/apps/opie-gutenbrowser/helpwindow.cpp64
2 files changed, 41 insertions, 49 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index 733db17..8b02f9f 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -824,64 +824,58 @@ bool Gutenbrowser::load( const char *fileName) {
824 << ", pageSize " << Lview->PageSize() << oendl; 824 << ", pageSize " << Lview->PageSize() << oendl;
825 825
826 Lview->setMaxLines(Lview->PageSize()*2); 826 Lview->setMaxLines(Lview->PageSize()*2);
827// odebug << "Gulped " << currentLine << "" << oendl; 827// odebug << "Gulped " << currentLine << "" << oendl;
828 setCaption(title); 828 setCaption(title);
829 Lview->setAutoUpdate( TRUE); 829 Lview->setAutoUpdate( TRUE);
830 830
831// Lview->setCursorPosition(0,0,FALSE); 831// Lview->setCursorPosition(0,0,FALSE);
832 832
833 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; 833 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
834 //odebug << "number of pages " << pages << "" << oendl; 834 //odebug << "number of pages " << pages << "" << oendl;
835 835
836 loadCheck = true; 836 loadCheck = true;
837 enableButtons(true); 837 enableButtons(true);
838 if( donateMenu->count() == 3) { 838 if( donateMenu->count() == 3) {
839 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() )); 839 donateMenu->insertItem("Current Title", this, SLOT( InfoBarClick() ));
840 } 840 }
841 Lview->setFocus(); 841 Lview->setFocus();
842 842
843 // QCopEnvelope("QPE/System", "notBusy()" ); 843 // QCopEnvelope("QPE/System", "notBusy()" );
844 return true; 844 return true;
845} // end load 845} // end load
846 846
847void Gutenbrowser::Search() { 847void Gutenbrowser::Search() {
848 848 odebug << "Starting search dialog" << oendl;
849 // if( searchDlg->isHidden()) 849 searchDlg = new SearchDialog( this, "Etext Search", true);
850 { 850 searchDlg->setCaption( tr( "Etext Search" ));
851 odebug << "Starting search dialog" << oendl; 851 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot()));
852 searchDlg = new SearchDialog( this, "Etext Search", true); 852 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot()));
853 searchDlg->setCaption( tr( "Etext Search" )); 853
854 // searchDlg->setLabel( "- searches etext"); 854 QString resultString;
855 connect( searchDlg,SIGNAL( search_signal()),this,SLOT( search_slot())); 855 QString string = searchDlg->searchString;
856 connect( searchDlg,SIGNAL( search_done_signal()),this,SLOT( searchdone_slot())); 856 Lview->deselect();
857 857 searchDlg->show();
858 QString resultString;
859 QString string = searchDlg->searchString;
860 Lview->deselect();
861 searchDlg->show();
862 searchDlg->result();
863 }
864} 858}
865 859
866void Gutenbrowser::search_slot( ) { 860void Gutenbrowser::search_slot( ) {
867 int line, col; 861 int line, col;
868 if (!searchDlg /*&& !loadCheck */) 862 if (!searchDlg /*&& !loadCheck */)
869 return; 863 return;
870 864
871 Lview->getCursorPosition(&line,&col); 865 Lview->getCursorPosition(&line,&col);
872 QString to_find_string=searchDlg->get_text(); 866 QString to_find_string=searchDlg->get_text();
873 867
874 // searchDlg->get_direction();// is true if searching backward 868 // searchDlg->get_direction();// is true if searching backward
875 if ( last_search != 0 && searchDlg->get_direction() ){ 869 if ( last_search != 0 && searchDlg->get_direction() ){
876 col = col - pattern.length() - 1 ; 870 col = col - pattern.length() - 1 ;
877 } 871 }
878 again: 872 again:
879 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col); 873 int result = doSearch( to_find_string , /* searchDlg->case_sensitive()*/ TRUE, searchDlg->forward_search(), line, col);
880 if(result == 0){ 874 if(result == 0){
881 if(!searchDlg->get_direction()){ // forward search 875 if(!searchDlg->get_direction()){ // forward search
882 int query = QMessageBox::information( searchDlg, "Find", 876 int query = QMessageBox::information( searchDlg, "Find",
883 "End of document reached.\nContinue from the beginning?", 877 "End of document reached.\nContinue from the beginning?",
884 "Yes", "No", "", 0,1); 878 "Yes", "No", "", 0,1);
885 if (query == 0){ 879 if (query == 0){
886 line = 0; 880 line = 0;
887 col = 0; 881 col = 0;
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
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 );
232#endif 225#endif
233} 226}
234 227
235void HelpWindow::newWindow() 228void HelpWindow::newWindow()
236{ 229{
237 ( new HelpWindow(browser->source(), "qbrowser") )->show(); 230 ( new HelpWindow(browser->source(), "qbrowser") )->show();
238} 231}
239 232
240void HelpWindow::print() 233void 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
278void HelpWindow::pathSelected( const QString &_path ) 271void 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
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 ] );
321} 319}
322 320
323void HelpWindow::bookmChosen( int i ) 321void 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
329void HelpWindow::addBookmark() 327void HelpWindow::addBookmark()
330{ 328{
331 mBookmarks[ bookm->insertItem( caption() ) ] = caption(); 329 mBookmarks[ bookm->insertItem( caption() ) ] = caption();
332} 330}
333 331