summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-08 08:43:12 (UTC)
committer llornkcor <llornkcor>2004-07-08 08:43:12 (UTC)
commit0dd3f56a7d0c79b251379831d1d53a80924d5eec (patch) (unidiff)
tree22b618b7283192a83cdc6465b9d1eaca5eb8ae2e
parenta53291faf419c90bf22db7cd6d6f26dece2053c1 (diff)
downloadopie-0dd3f56a7d0c79b251379831d1d53a80924d5eec.zip
opie-0dd3f56a7d0c79b251379831d1d53a80924d5eec.tar.gz
opie-0dd3f56a7d0c79b251379831d1d53a80924d5eec.tar.bz2
dont add empty entry into bookmark list
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index d0af114..644fae8 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -73,132 +73,132 @@ Gutenbrowser::Gutenbrowser()
73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) 73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
74#endif 74#endif
75 : QMainWindow() 75 : QMainWindow()
76{ 76{
77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
79 // e << ""; 79 // e << "";
80 // QPEApplication::grabKeyboard(); 80 // QPEApplication::grabKeyboard();
81 showMainList=TRUE; 81 showMainList=TRUE;
82 working=false; 82 working=false;
83 this->setUpdatesEnabled(TRUE); 83 this->setUpdatesEnabled(TRUE);
84 // #ifndef Q_WS_QWS 84 // #ifndef Q_WS_QWS
85 QString msg; 85 QString msg;
86 msg="You have now entered unto gutenbrowser,\n"; 86 msg="You have now entered unto gutenbrowser,\n";
87 msg+="make your self at home, sit back, relax and read something great.\n"; 87 msg+="make your self at home, sit back, relax and read something great.\n";
88 88
89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
90 setCaption("Gutenbrowser");// Embedded " VERSION); 90 setCaption("Gutenbrowser");// Embedded " VERSION);
91 this->setUpdatesEnabled(TRUE); 91 this->setUpdatesEnabled(TRUE);
92 92
93 // bool firstTime=FALSE; 93 // bool firstTime=FALSE;
94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); 94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout");
95 95
96 menu = new QHBoxLayout(-1,"menu"); 96 menu = new QHBoxLayout(-1,"menu");
97 buttons2 = new QHBoxLayout(-1,"buttons2"); 97 buttons2 = new QHBoxLayout(-1,"buttons2");
98 edits = new QHBoxLayout(-1,"edits"); 98 edits = new QHBoxLayout(-1,"edits");
99 99
100 useSplitter=TRUE; 100 useSplitter=TRUE;
101 101
102 initConfig(); 102 initConfig();
103 initMenuBar(); 103 initMenuBar();
104 initButtonBar(); 104 initButtonBar();
105 initStatusBar(); 105 initStatusBar();
106 initView(); 106 initView();
107 initSlots(); 107 initSlots();
108 qDebug("init finished"); 108 qDebug("init finished");
109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); 109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
110 110
111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), 111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)),
112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); 112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) );
113 if( useIcons) 113 if( useIcons)
114 toggleButtonIcons( TRUE); 114 toggleButtonIcons( TRUE);
115 else 115 else
116 toggleButtonIcons( FALSE); 116 toggleButtonIcons( FALSE);
117 117
118 enableButtons(false); 118 enableButtons(false);
119 119
120 Config config("Gutenbrowser"); // populate menubuttonlist 120 Config config("Gutenbrowser"); // populate menubuttonlist
121 config.setGroup("General"); 121 config.setGroup("General");
122 122
123 config.setGroup( "Files" ); 123 config.setGroup( "Files" );
124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
125 int i_numofFiles = s_numofFiles.toInt(); 125 int i_numofFiles = s_numofFiles.toInt();
126 126
127 QString tempFileName; 127 QString tempFileName;
128 128
129 for (int i = 0; i <= i_numofFiles; i++) { 129 for (int i = 0; i <= i_numofFiles; i++) {
130 // tempFileName.setNum(i); 130 // tempFileName.setNum(i);
131 config.setGroup( "Files" ); 131 config.setGroup( "Files" );
132 QString ramble = config.readEntry( QString::number(i), "" ); 132 QString ramble = config.readEntry( QString::number(i), "" );
133 133
134 config.setGroup( "Titles" ); 134 config.setGroup( "Titles" );
135 QString tempTitle = config.readEntry( ramble, ""); 135 QString tempTitle = config.readEntry( ramble, "");
136 config.setGroup( tempTitle); 136 config.setGroup( tempTitle);
137 int index=config.readNumEntry( "LineNumber", -1 ); 137 int index = config.readNumEntry( "LineNumber", -1 );
138 if( index != -1) { 138 if( index != -1) {
139 odebug << tempTitle << oendl; 139 odebug << tempTitle << oendl;
140 bookmarksMenu->insertItem( tempTitle); 140 if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle);
141 } 141 }
142 } 142 }
143 143
144 // QString gutenIndex= local_library + "GUTINDEX.ALL"; 144 // QString gutenIndex= local_library + "GUTINDEX.ALL";
145 QString gutenIndex = QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; 145 QString gutenIndex = QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL";
146 qDebug("gutenindex "+gutenIndex ); 146 qDebug("gutenindex "+gutenIndex );
147 if( QFile( gutenIndex).exists() ) { 147 if( QFile( gutenIndex).exists() ) {
148 indexLib.setName( gutenIndex); 148 indexLib.setName( gutenIndex);
149 } else { 149 } else {
150 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; 150 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT";
151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; 151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT";
152 newindexLib.setName( localLibIndexFile); 152 newindexLib.setName( localLibIndexFile);
153 } 153 }
154 qDebug("attempting new library"); 154 qDebug("attempting new library");
155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); 155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
156 loadCheck = false; 156 loadCheck = false;
157 chdir(local_library); 157 chdir(local_library);
158 if(!showMainList) { 158 if(!showMainList) {
159 Lview->setFocus(); 159 Lview->setFocus();
160 // if(firstTime) 160 // if(firstTime)
161 // Bookmark(); 161 // Bookmark();
162 for (int i=1;i< qApp->argc();i++) { 162 for (int i=1;i< qApp->argc();i++) {
163 qDebug("Suppose we open somethin"); 163 qDebug("Suppose we open somethin");
164 if(!load(qApp->argv()[i])) return; 164 if(!load(qApp->argv()[i])) return;
165 } 165 }
166 } else { 166 } else {
167 fillWithTitles(); 167 fillWithTitles();
168 mainList->setFocus(); 168 mainList->setFocus();
169 // mainList->setCurrentItem(0); 169 // mainList->setCurrentItem(0);
170 170
171 } 171 }
172 writeConfig(); 172 writeConfig();
173 QTimer::singleShot( 250, this, SLOT(hideView()) ); 173 QTimer::singleShot( 250, this, SLOT(hideView()) );
174} //end init 174} //end init
175 175
176Gutenbrowser::~Gutenbrowser() { 176Gutenbrowser::~Gutenbrowser() {
177 // QPEApplication::grabKeyboard(); 177 // QPEApplication::grabKeyboard();
178 // QPEApplication::ungrabKeyboard(); 178 // QPEApplication::ungrabKeyboard();
179 odebug << "Exit" << oendl; 179 odebug << "Exit" << oendl;
180} 180}
181 181
182 /* 182 /*
183 Google.com search */ 183 Google.com search */
184void Gutenbrowser::InfoBarClick() { 184void Gutenbrowser::InfoBarClick() {
185 QString text; 185 QString text;
186 if( Lview->hasSelectedText()) { 186 if( Lview->hasSelectedText()) {
187 Lview->copy(); 187 Lview->copy();
188 QClipboard *cb = QApplication::clipboard(); 188 QClipboard *cb = QApplication::clipboard();
189 text = cb->text(); 189 text = cb->text();
190 } else { 190 } else {
191 // text=title; 191 // text=title;
192 text=this->caption(); 192 text=this->caption();
193 } 193 }
194 searchGoogle(text); 194 searchGoogle(text);
195} 195}
196 196
197 /* 197 /*
198 download http with wget or preferred browser */ 198 download http with wget or preferred browser */
199void Gutenbrowser::goGetit( const QString &url, bool showMsg) { 199void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
200 // int eexit=0; 200 // int eexit=0;
201 QString cmd; 201 QString cmd;
202 // config.read(); 202 // config.read();
203 qApp->processEvents(); 203 qApp->processEvents();
204 QString filename = QPEApplication::qpeDir(); 204 QString filename = QPEApplication::qpeDir();
@@ -500,129 +500,129 @@ void Gutenbrowser::BackBtn() {
500 Lview->MultiLine_Ex::pageUp( FALSE); 500 Lview->MultiLine_Ex::pageUp( FALSE);
501 // Lview->ScrollDown(1); 501 // Lview->ScrollDown(1);
502 // i_pageNum--; 502 // i_pageNum--;
503 if( i_pageNum < 1) 503 if( i_pageNum < 1)
504 i_pageNum = 1; 504 i_pageNum = 1;
505 setStatus(); 505 setStatus();
506// Lview->setCursorPosition( Lview->Top(), 0, FALSE); 506// Lview->setCursorPosition( Lview->Top(), 0, FALSE);
507 507
508 } 508 }
509 } 509 }
510 Lview->setFocus(); 510 Lview->setFocus();
511} 511}
512 512
513void Gutenbrowser::doBeginBtn() { 513void Gutenbrowser::doBeginBtn() {
514 if(loadCheck) { 514 if(loadCheck) {
515 qApp->processEvents(); 515 qApp->processEvents();
516 BeginBtn(); 516 BeginBtn();
517 } 517 }
518} 518}
519 519
520 // moves text to the very top = 0 520 // moves text to the very top = 0
521void Gutenbrowser::TopBtn() { 521void Gutenbrowser::TopBtn() {
522 522
523 if(loadCheck) { 523 if(loadCheck) {
524 if( i_pageNum != 0) { 524 if( i_pageNum != 0) {
525 odebug << "top" << oendl; 525 odebug << "top" << oendl;
526 qApp->processEvents(); 526 qApp->processEvents();
527 currentLine = 0; 527 currentLine = 0;
528 i_pageNum = 1; 528 i_pageNum = 1;
529 int pageSize = Lview->PageSize() ; 529 int pageSize = Lview->PageSize() ;
530 Lview->clear(); 530 Lview->clear();
531 QString s; 531 QString s;
532 f.at(0); 532 f.at(0);
533 for(int fd=0; fd < pageSize ;fd++) { 533 for(int fd=0; fd < pageSize ;fd++) {
534 f.readLine(s, 256); 534 f.readLine(s, 256);
535 if(useWrap) 535 if(useWrap)
536 s.replace(QRegExp("\n"),""); 536 s.replace(QRegExp("\n"),"");
537 Lview->insertLine(s ,-1); 537 Lview->insertLine(s ,-1);
538 currentLine++; 538 currentLine++;
539 } 539 }
540// Lview->setCursorPosition( 0,0, FALSE); 540// Lview->setCursorPosition( 0,0, FALSE);
541 i_pageNum=1; 541 i_pageNum=1;
542 setStatus(); 542 setStatus();
543 } 543 }
544 Lview->setFocus(); 544 Lview->setFocus();
545 } 545 }
546} 546}
547 547
548 //moves text to the start of the EText 548 //moves text to the start of the EText
549void Gutenbrowser::BeginBtn() { 549void Gutenbrowser::BeginBtn() {
550 i_pageNum = 1; 550 i_pageNum = 1;
551 currentLine = 0; 551 currentLine = 0;
552 QString s_pattern="*END*THE SMALL PRINT"; 552 QString s_pattern="*END*THE SMALL PRINT";
553 QString sPattern2 = "*END THE SMALL PRINT"; 553 QString sPattern2 = "*END THE SMALL PRINT";
554 554
555 int pageSize = Lview->PageSize(); 555 int pageSize = Lview->PageSize();
556 Lview->clear(); 556 Lview->clear();
557 557
558 // int lines = Lview->numLines(); 558 // int lines = Lview->numLines();
559 int pos = 0;//, i = 0; 559 int pos = 0;//, i = 0;
560 int i_topRow = Lview->topRow(); 560 int i_topRow = Lview->topRow();
561 561
562 QString LeftText;// = Lview->text(); 562 QString LeftText;// = Lview->text();
563 563
564 int linesPerPage = Lview->lastRow() - Lview->topRow(); 564 // int linesPerPage = Lview->lastRow() - Lview->topRow();
565 // int pages = (( linesPerPage / Lview->editSize() ) ) +1; 565 // int pages = (( linesPerPage / Lview->editSize() ) ) +1;
566 // int pageN = 0; 566 // int pageN = 0;
567 i_pageNum = 1; 567 i_pageNum = 1;
568 int lastPage=1; 568 int lastPage=1;
569 int lineNo=0; 569 int lineNo=0;
570 QString s; 570 QString s;
571 f.at( 0); 571 f.at( 0);
572 572
573 while ( !f.atEnd() ) { 573 while ( !f.atEnd() ) {
574 f.readLine(s, 256); 574 f.readLine(s, 256);
575 lineNo++; 575 lineNo++;
576 LeftText = s; 576 LeftText = s;
577 currentFilePos = f.at(); 577 currentFilePos = f.at();
578 578
579 i_pageNum = lineNo/pageSize; 579 i_pageNum = lineNo/pageSize;
580 if(lastPage < i_pageNum) { 580 if(lastPage < i_pageNum) {
581 pageStopArray.resize(i_pageNum + 1); 581 pageStopArray.resize(i_pageNum + 1);
582 pageStopArray[i_pageNum ] = currentFilePos; 582 pageStopArray[i_pageNum ] = currentFilePos;
583 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 583 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
584 } 584 }
585 // lastPage = i_pageNum; 585 // lastPage = i_pageNum;
586 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { 586 if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) {
587 odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 587 odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
588 break; 588 break;
589 } 589 }
590 } 590 }
591 if(f.atEnd()) //in case we didnt find anything, we need to show something 591 if(f.atEnd()) //in case we didnt find anything, we need to show something
592 f.at(0); 592 f.at(0);
593 Lview->clear(); 593 Lview->clear();
594 for(int fd=0; fd < pageSize - 1;fd++) { 594 for(int fd=0; fd < pageSize - 1;fd++) {
595 f.readLine(s, 256); 595 f.readLine(s, 256);
596 if(useWrap) 596 if(useWrap)
597 s.replace(QRegExp("\n"),""); 597 s.replace(QRegExp("\n"),"");
598 Lview->insertLine( s, -1); 598 Lview->insertLine( s, -1);
599 currentLine++; 599 currentLine++;
600 } 600 }
601 601
602 i_pageNum = lineNo/pageSize; 602 i_pageNum = lineNo/pageSize;
603 pageStopArray.resize(i_pageNum + 1); 603 pageStopArray.resize(i_pageNum + 1);
604 // int length = Lview->length(); 604 // int length = Lview->length();
605 605
606 qApp->processEvents(); 606 qApp->processEvents();
607 607
608 if( pos > i_topRow ) { 608 if( pos > i_topRow ) {
609// Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); 609// Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE);
610 } else { 610 } else {
611// Lview->setCursorPosition( pos+2 , 0, FALSE ); 611// Lview->setCursorPosition( pos+2 , 0, FALSE );
612 } 612 }
613 613
614 Lview->deselect(); 614 Lview->deselect();
615 // AdjustStatus(); 615 // AdjustStatus();
616 Lview->setFocus(); 616 Lview->setFocus();
617} 617}
618 618
619 /* 619 /*
620 sets the current page and place as a bookmark*/ 620 sets the current page and place as a bookmark*/
621void Gutenbrowser::setBookmark() { 621void Gutenbrowser::setBookmark() {
622 int eexit=QMessageBox::information(this, "Note", 622 int eexit=QMessageBox::information(this, "Note",
623 "Do you really want to \nset this bookmark?." 623 "Do you really want to \nset this bookmark?."
624 ,QMessageBox::Yes, QMessageBox::No); 624 ,QMessageBox::Yes, QMessageBox::No);
625 if (eexit== 3) { 625 if (eexit== 3) {
626 626
627 currentFilePos = f.at(); 627 currentFilePos = f.at();
628 628