summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-08 08:37:19 (UTC)
committer llornkcor <llornkcor>2004-07-08 08:37:19 (UTC)
commita53291faf419c90bf22db7cd6d6f26dece2053c1 (patch) (unidiff)
treed0a5a10621b8705502cc87bde43e18de39042be6
parenta7b08ae7dbce8675981321828e61c949968d1afe (diff)
downloadopie-a53291faf419c90bf22db7cd6d6f26dece2053c1.zip
opie-a53291faf419c90bf22db7cd6d6f26dece2053c1.tar.gz
opie-a53291faf419c90bf22db7cd6d6f26dece2053c1.tar.bz2
rework view, fix bookmarking
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp33
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.h1
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp17
3 files changed, 33 insertions, 18 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index be920dd..d0af114 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -158,21 +158,22 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
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 load(qApp->argv()[i]); 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} //end init 174} //end init
174 175
175Gutenbrowser::~Gutenbrowser() { 176Gutenbrowser::~Gutenbrowser() {
176 // QPEApplication::grabKeyboard(); 177 // QPEApplication::grabKeyboard();
177 // QPEApplication::ungrabKeyboard(); 178 // QPEApplication::ungrabKeyboard();
178 odebug << "Exit" << oendl; 179 odebug << "Exit" << oendl;
@@ -407,13 +408,13 @@ void Gutenbrowser::ForwardBtn() {
407 for(int fd=0; fd < pageSize - 1;fd++) { 408 for(int fd=0; fd < pageSize - 1;fd++) {
408 f.readLine(s, 256); 409 f.readLine(s, 256);
409 if(useWrap) 410 if(useWrap)
410 s.replace(QRegExp("\n"),""); 411 s.replace(QRegExp("\n"),"");
411 insertString+=s; 412 insertString+=s;
412 Lview->insertLine( s, -1); 413 Lview->insertLine( s, -1);
413 odebug << s << oendl; 414 // odebug << s << oendl;
414 currentLine++; 415 currentLine++;
415 } 416 }
416 // Lview->insertAt( insertString,0,0, FALSE); 417 // Lview->insertAt( insertString,0,0, FALSE);
417 currentFilePos = f.at(); 418 currentFilePos = f.at();
418 // if( i_pageNum != pages) { 419 // if( i_pageNum != pages) {
419 // Lview->MultiLine_Ex::pageDown( FALSE); 420 // Lview->MultiLine_Ex::pageDown( FALSE);
@@ -576,13 +577,13 @@ void Gutenbrowser::BeginBtn() {
576 currentFilePos = f.at(); 577 currentFilePos = f.at();
577 578
578 i_pageNum = lineNo/pageSize; 579 i_pageNum = lineNo/pageSize;
579 if(lastPage < i_pageNum) { 580 if(lastPage < i_pageNum) {
580 pageStopArray.resize(i_pageNum + 1); 581 pageStopArray.resize(i_pageNum + 1);
581 pageStopArray[i_pageNum ] = currentFilePos; 582 pageStopArray[i_pageNum ] = currentFilePos;
582 odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 583 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
583 } 584 }
584 // lastPage = i_pageNum; 585 // lastPage = i_pageNum;
585 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 ) {
586 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;
587 break; 588 break;
588 } 589 }
@@ -647,12 +648,13 @@ void Gutenbrowser::setBookmark() {
647 648
648 cfg.setGroup(title); 649 cfg.setGroup(title);
649 cfg.writeEntry("File Name",file_name); 650 cfg.writeEntry("File Name",file_name);
650 cfg.writeEntry( "LineNumber", QString::number( row)); 651 cfg.writeEntry( "LineNumber", QString::number( row));
651 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); 652 cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1]));
652 cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); 653 cfg.writeEntry( "Page Number", QString::number( i_pageNum) );
654 cfg.write();
653 bookmarksMenu->insertItem( title); 655 bookmarksMenu->insertItem( title);
654 } 656 }
655} //end setBookmark 657} //end setBookmark
656 658
657 659
658 /* goes to last set bookmark*/ 660 /* goes to last set bookmark*/
@@ -688,13 +690,13 @@ void Gutenbrowser::Bookmark( int itemId) {
688 // qApp->processEvents(); 690 // qApp->processEvents();
689 // Lview->setFocus(); 691 // Lview->setFocus();
690 this->setFocus(); 692 this->setFocus();
691 693
692 Lview->clear(); 694 Lview->clear();
693 695
694 load(file_name); 696 if(!load(file_name)) return;
695 697
696 int pageSize= Lview->PageSize(); 698 int pageSize= Lview->PageSize();
697 f.at(0); 699 f.at(0);
698 // Lview->clear(); 700 // Lview->clear();
699 QString s; 701 QString s;
700 int lineNo=0; 702 int lineNo=0;
@@ -705,13 +707,13 @@ void Gutenbrowser::Bookmark( int itemId) {
705 currentFilePos = f.at(); 707 currentFilePos = f.at();
706 708
707 i_pageNum = lineNo/pageSize; 709 i_pageNum = lineNo/pageSize;
708 if(lastPage < i_pageNum) { 710 if(lastPage < i_pageNum) {
709 pageStopArray.resize(i_pageNum + 1); 711 pageStopArray.resize(i_pageNum + 1);
710 pageStopArray[i_pageNum ] = currentFilePos; 712 pageStopArray[i_pageNum ] = currentFilePos;
711 odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; 713 // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl;
712 } 714 }
713 if(currentFilePos == bookmarkPosition) 715 if(currentFilePos == bookmarkPosition)
714 break; 716 break;
715 } 717 }
716 if(f.atEnd()) 718 if(f.atEnd())
717 f.at(0); 719 f.at(0);
@@ -744,27 +746,30 @@ void Gutenbrowser::Bookmark( int itemId) {
744 746
745bool Gutenbrowser::load( const char *fileName) { 747bool Gutenbrowser::load( const char *fileName) {
746 748
747 // QCopEnvelope ( "QPE/System", "busy()" ); 749 // QCopEnvelope ( "QPE/System", "busy()" );
748 odebug << "Title is already set as "+title << oendl; 750 odebug << "Title is already set as "+title << oendl;
749 odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl; 751 odebug << "sizeHint " << sizeHint().height() << " pageSize " << Lview->PageSize() << "" << oendl;
752 // pointSize = Lview->fontInfo().pointSize();
753 // odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl;
750 if( Lview->PageSize() < 4) { 754 if( Lview->PageSize() < 4) {
751 755
752 Lview->setMaximumHeight( sizeHint().height() ); 756 //Lview->setMaximumHeight( sizeHint().height() );
753 Lview->setMinimumHeight( sizeHint().height() ); 757 Lview->setMinimumHeight( sizeHint().height() );
754 pointSize = Lview->fontInfo().pointSize(); 758 pointSize = Lview->fontInfo().pointSize();
755 odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl; 759 odebug << "sizeHint " << sizeHint().height() << " point size " << pointSize << "" << oendl;
756 if(pointSize < 10) 760 if(pointSize < 15)
757 Lview->setFixedVisibleLines(19); 761 Lview->setFixedVisibleLines(19);
758 else 762 else
759 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2); 763 Lview->setFixedVisibleLines( ( (sizeHint().height() / pointSize ) * 2) -2);
760 } 764 }
761 765
762 Config cfg("Gutenbrowser"); 766 Config cfg("Gutenbrowser");
763 cfg.setGroup("General"); 767 cfg.setGroup("General");
764 cfg.writeEntry("Current",fileName); 768 cfg.writeEntry("Current",fileName);
769 cfg.write();
765 currentLine=0; 770 currentLine=0;
766 771
767 file_name=fileName; 772 file_name=fileName;
768 QString o_file = fileName; 773 QString o_file = fileName;
769 774
770 // if (i_pageNum < 1) { 775 // if (i_pageNum < 1) {
@@ -804,13 +809,13 @@ bool Gutenbrowser::load( const char *fileName) {
804 809
805 odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum 810 odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum
806 << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] 811 << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum]
807 << ", pageSize " << Lview->PageSize() << oendl; 812 << ", pageSize " << Lview->PageSize() << oendl;
808 813
809 Lview->setMaxLines(Lview->PageSize()*2); 814 Lview->setMaxLines(Lview->PageSize()*2);
810 odebug << "Gulped " << currentLine << "" << oendl; 815// odebug << "Gulped " << currentLine << "" << oendl;
811 setCaption(title); 816 setCaption(title);
812 Lview->setAutoUpdate( TRUE); 817 Lview->setAutoUpdate( TRUE);
813 818
814// Lview->setCursorPosition(0,0,FALSE); 819// Lview->setCursorPosition(0,0,FALSE);
815 820
816 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1; 821 // pages = (int)(( Lview->numLines() / Lview->editSize() ) / 2 ) +1;
@@ -1033,13 +1038,13 @@ void Gutenbrowser::LibraryBtn() {
1033 // // 1038 // //
1034 // file_name = file_name.left(4)+ ".txt"; 1039 // file_name = file_name.left(4)+ ".txt";
1035 if( LibraryDlg) 1040 if( LibraryDlg)
1036 delete LibraryDlg; 1041 delete LibraryDlg;
1037 setTitle(); 1042 setTitle();
1038 // QCopEnvelope ( "QPE/System", "busy()" ); 1043 // QCopEnvelope ( "QPE/System", "busy()" );
1039 load( file_name); 1044 if( !load( file_name)) return;
1040 } else { 1045 } else {
1041 printf("Not opening the file.\n"); 1046 printf("Not opening the file.\n");
1042 } 1047 }
1043 } 1048 }
1044 } 1049 }
1045 if(showMainList) { 1050 if(showMainList) {
@@ -1077,13 +1082,13 @@ void Gutenbrowser::OpenBtn() {
1077 mainList->hide(); 1082 mainList->hide();
1078 Lview->show(); 1083 Lview->show();
1079 qApp->processEvents(); 1084 qApp->processEvents();
1080 } 1085 }
1081 Lview->clear(); 1086 Lview->clear();
1082 // QCopEnvelope ( "QPE/System", "busy()" ); 1087 // QCopEnvelope ( "QPE/System", "busy()" );
1083 load(file_name); 1088 if(!load(file_name)) return;
1084 } else { 1089 } else {
1085 odebug << "file_name is empty!" << oendl; 1090 odebug << "file_name is empty!" << oendl;
1086 if(showMainList) { 1091 if(showMainList) {
1087 if(!Lview->isHidden()) 1092 if(!Lview->isHidden())
1088 Lview->hide(); 1093 Lview->hide();
1089 qApp->processEvents(); 1094 qApp->processEvents();
@@ -1775,13 +1780,13 @@ void Gutenbrowser::listClickedSlot( QListBoxItem * index) {
1775 // openFileTitle = title; 1780 // openFileTitle = title;
1776 Config config("Gutenbrowser"); 1781 Config config("Gutenbrowser");
1777 config.setGroup( "Files" ); 1782 config.setGroup( "Files" );
1778 QString file = config.readEntry(temp, ""); 1783 QString file = config.readEntry(temp, "");
1779 odebug << "About to load" << oendl; 1784 odebug << "About to load" << oendl;
1780 if( Lview->isVisible()) 1785 if( Lview->isVisible())
1781 load(file); 1786 if(!load(file)) return;
1782 1787
1783 config.setGroup( title); 1788 config.setGroup( title);
1784 file_name = config.readEntry("File Name", ""); 1789 file_name = config.readEntry("File Name", "");
1785 i_pageNum = config.readNumEntry("Page Number", 1); 1790 i_pageNum = config.readNumEntry("Page Number", 1);
1786 int Bmrkrow = config.readNumEntry("LineNumber", -1); 1791 int Bmrkrow = config.readNumEntry("LineNumber", -1);
1787 if(Bmrkrow > -1) { 1792 if(Bmrkrow > -1) {
@@ -1803,26 +1808,28 @@ void Gutenbrowser::infoGutenbrowser() {
1803 QMessageBox::message("Info","Gutenbrowser was developed by\n" 1808 QMessageBox::message("Info","Gutenbrowser was developed by\n"
1804 "Lorn Potter\n" 1809 "Lorn Potter\n"
1805 "ljp<ljp@llornkcor.com>\n"); 1810 "ljp<ljp@llornkcor.com>\n");
1806} 1811}
1807 1812
1808void Gutenbrowser::setDocument(const QString & frozenBoogers) { 1813void Gutenbrowser::setDocument(const QString & frozenBoogers) {
1809 this->hide(); 1814 // this->hide();
1815 qWarning("\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSET DOCUMENT\n");
1810 if(showMainList) { 1816 if(showMainList) {
1811 showMainList=FALSE; 1817 showMainList=FALSE;
1812 if(!mainList->isHidden()) 1818 if(!mainList->isHidden())
1813 mainList->hide(); 1819 mainList->hide();
1814 if(Lview->isHidden()) 1820 if(Lview->isHidden())
1815 Lview->show(); 1821 Lview->show();
1816 qApp->processEvents(); 1822 qApp->processEvents();
1817 } 1823 }
1818 DocLnk lnk; 1824 DocLnk lnk;
1819 lnk = DocLnk(frozenBoogers); 1825 lnk = DocLnk(frozenBoogers);
1826 qWarning("open "+frozenBoogers);
1820 // odebug << lnk.file() << oendl; 1827 // odebug << lnk.file() << oendl;
1821 title=lnk.comment(); 1828 title=lnk.comment();
1822 load( lnk.file()); 1829 if(!load( lnk.file())) return;
1823 this->show(); 1830 this->show();
1824 // odebug << title << oendl; 1831 // odebug << title << oendl;
1825 // qApp->processEvents(); 1832 // qApp->processEvents();
1826 // repaint(); 1833 // repaint();
1827} 1834}
1828 1835
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.h b/noncore/apps/opie-gutenbrowser/gutenbrowser.h
index acb6e59..2958f01 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.h
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.h
@@ -159,12 +159,13 @@ protected:
159 bool showMainList; 159 bool showMainList;
160 bool useIcons; 160 bool useIcons;
161 bool working; 161 bool working;
162 162
163 163
164protected slots: 164protected slots:
165 void hideView();
165 166
166 void BackBtn(); 167 void BackBtn();
167 void Bookmark( int); 168 void Bookmark( int);
168 void ByeBye(); 169 void ByeBye();
169 void ChangeFont(); 170 void ChangeFont();
170 void ClearEdit(); 171 void ClearEdit();
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
index 9473ba9..c93dbc5 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowserData.cpp
@@ -310,22 +310,29 @@ void Gutenbrowser::initView()
310 useWrap=true; 310 useWrap=true;
311 } else { 311 } else {
312 Lview->setWordWrap(QMultiLineEdit::NoWrap); 312 Lview->setWordWrap(QMultiLineEdit::NoWrap);
313 useWrap = false; 313 useWrap = false;
314 } 314 }
315 mainList = new QListBox(this,"mainlist"); 315 mainList = new QListBox(this,"mainlist");
316 316 mainList->hide();
317// QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); 317// QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
318 // mainList->showMaximized(); 318 // mainList->showMaximized();
319// mainList->setGeometry(2,30,230,160); 319// mainList->setGeometry(2,30,230,160);
320 Lview->setReadOnly( true); 320 Lview->setReadOnly( true);
321 edits->addWidget( Lview); 321 edits->addWidget( Lview);
322 edits->addWidget(mainList); 322 edits->addWidget(mainList);
323 323
324 if(!showMainList) { 324// if(!showMainList) {
325 Lview->setText( "\nThis is gutenbrowser for the Sharp Zaurus.\nMake your self at home, sit back, relax and read something great. "); 325// Lview->setText( "\nThis is gutenbrowser for the Sharp Zaurus.\nMake your self at home, sit back, relax and read something great. ");
326 } else 326// }
327 Lview->hide(); 327 // else
328// Lview->hide();
328 329
329 topLayout->addLayout( edits, 0); 330 topLayout->addLayout( edits, 0);
330 qDebug("end initView"); 331 qDebug("end initView");
331} 332}
333
334void Gutenbrowser::hideView() {
335 // qWarning("Hide View");
336 mainList->show();
337 Lview->hide();
338}