author | llornkcor <llornkcor> | 2004-07-08 08:43:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-07-08 08:43:12 (UTC) |
commit | 0dd3f56a7d0c79b251379831d1d53a80924d5eec (patch) (side-by-side diff) | |
tree | 22b618b7283192a83cdc6465b9d1eaca5eb8ae2e | |
parent | a53291faf419c90bf22db7cd6d6f26dece2053c1 (diff) | |
download | opie-0dd3f56a7d0c79b251379831d1d53a80924d5eec.zip opie-0dd3f56a7d0c79b251379831d1d53a80924d5eec.tar.gz opie-0dd3f56a7d0c79b251379831d1d53a80924d5eec.tar.bz2 |
dont add empty entry into bookmark list
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 6 |
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 @@ -41,196 +41,196 @@ #include <qregexp.h> #include <qregion.h> #include <qpaintdevicemetrics.h> #include <qvaluelist.h> #include <qlabel.h> #include <qclipboard.h> #include <qpainter.h> #include <qpalette.h> #include <qobjectlist.h> #include <qfontdialog.h> #include <qtextview.h> #include <qbrush.h> #include <qfile.h> #include <qfontinfo.h> #include <qscrollview.h> #include <qpoint.h> /* STD */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> static const int nfontsizes = 9; static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; #ifdef NOQUICKLAUNCH Gutenbrowser::Gutenbrowser() Gutenbrowser(); #else Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) #endif : QMainWindow() { // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); // e << ""; // QPEApplication::grabKeyboard(); showMainList=TRUE; working=false; this->setUpdatesEnabled(TRUE); // #ifndef Q_WS_QWS QString msg; msg="You have now entered unto gutenbrowser,\n"; msg+="make your self at home, sit back, relax and read something great.\n"; local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; setCaption("Gutenbrowser");// Embedded " VERSION); this->setUpdatesEnabled(TRUE); // bool firstTime=FALSE; topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); menu = new QHBoxLayout(-1,"menu"); buttons2 = new QHBoxLayout(-1,"buttons2"); edits = new QHBoxLayout(-1,"edits"); useSplitter=TRUE; initConfig(); initMenuBar(); initButtonBar(); initStatusBar(); initView(); initSlots(); qDebug("init finished"); QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); if( useIcons) toggleButtonIcons( TRUE); else toggleButtonIcons( FALSE); enableButtons(false); Config config("Gutenbrowser"); // populate menubuttonlist config.setGroup("General"); config.setGroup( "Files" ); QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); int i_numofFiles = s_numofFiles.toInt(); QString tempFileName; for (int i = 0; i <= i_numofFiles; i++) { // tempFileName.setNum(i); config.setGroup( "Files" ); QString ramble = config.readEntry( QString::number(i), "" ); config.setGroup( "Titles" ); QString tempTitle = config.readEntry( ramble, ""); config.setGroup( tempTitle); - int index=config.readNumEntry( "LineNumber", -1 ); + int index = config.readNumEntry( "LineNumber", -1 ); if( index != -1) { odebug << tempTitle << oendl; - bookmarksMenu->insertItem( tempTitle); + if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); } } // QString gutenIndex= local_library + "GUTINDEX.ALL"; QString gutenIndex = QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; qDebug("gutenindex "+gutenIndex ); if( QFile( gutenIndex).exists() ) { indexLib.setName( gutenIndex); } else { QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; newindexLib.setName( localLibIndexFile); } qDebug("attempting new library"); LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); loadCheck = false; chdir(local_library); if(!showMainList) { Lview->setFocus(); // if(firstTime) // Bookmark(); for (int i=1;i< qApp->argc();i++) { qDebug("Suppose we open somethin"); if(!load(qApp->argv()[i])) return; } } else { fillWithTitles(); mainList->setFocus(); // mainList->setCurrentItem(0); } writeConfig(); QTimer::singleShot( 250, this, SLOT(hideView()) ); } //end init Gutenbrowser::~Gutenbrowser() { // QPEApplication::grabKeyboard(); // QPEApplication::ungrabKeyboard(); odebug << "Exit" << oendl; } /* Google.com search */ void Gutenbrowser::InfoBarClick() { QString text; if( Lview->hasSelectedText()) { Lview->copy(); QClipboard *cb = QApplication::clipboard(); text = cb->text(); } else { // text=title; text=this->caption(); } searchGoogle(text); } /* download http with wget or preferred browser */ void Gutenbrowser::goGetit( const QString &url, bool showMsg) { // int eexit=0; QString cmd; // config.read(); qApp->processEvents(); QString filename = QPEApplication::qpeDir(); if(filename.right(1)!="/") filename+="/etc/gutenbrowser/"; else filename+="etc/gutenbrowser/"; odebug << "filename "+filename << oendl; // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); Config config("Gutenbrowser"); config.setGroup( "Browser" ); QString brow = config.readEntry("Preferred", "Opera"); odebug << "Preferred browser is "+brow << oendl; if(!showMsg) { //if we just get the gutenindex.all cmd="wget -O " + filename +" " + url+" 2>&1" ; chdir(local_library); odebug << "Issuing the system command: " << cmd << "" << oendl; Output *outDlg; outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); outDlg->showMaximized(); outDlg->show(); qApp->processEvents(); FILE *fp; char line[130]; outDlg->OutputEdit->append( tr("Running wget") ); sleep(1); fp = popen( (const char *) cmd, "r"); odebug << "Issuing the command\n"+cmd << oendl; // system(cmd); while ( fgets( line, sizeof line, fp)) { outDlg->OutputEdit->append(line); @@ -468,193 +468,193 @@ void Gutenbrowser::BackBtn() { if(!f.at( pageStopArray[i_pageNum - 1] )) odebug << "File positioned backward did not work" << oendl; } QString s; // int sizeLine=0; Lview->clear(); // QString insertString; for(int fd = 0; fd < pageSize ;fd++) { // Lview->removeLine( Lview->PageSize() ); f.readLine(s, 256); if(useWrap) s.replace(QRegExp("\n"),""); currentLine++; // insertString+=s; Lview->insertLine( s, -1); } // Lview->insertAt( insertString,0,0, FALSE); if( !BackButton->autoRepeat() && !BackButton->isDown()) { QString topR; QString lastR; QString pageR; // int sizer = Lview->lastRow() - Lview->topRow(); // int i_topRow = Lview->topRow(); if( i_pageNum < 1) i_pageNum = 1; setCaption(QString::number(i_pageNum)); } else { // int newTop = Lview->Top(); // if(Lview->lastRow() > i) Lview->MultiLine_Ex::pageUp( FALSE); // Lview->ScrollDown(1); // i_pageNum--; if( i_pageNum < 1) i_pageNum = 1; setStatus(); // Lview->setCursorPosition( Lview->Top(), 0, FALSE); } } Lview->setFocus(); } void Gutenbrowser::doBeginBtn() { if(loadCheck) { qApp->processEvents(); BeginBtn(); } } // moves text to the very top = 0 void Gutenbrowser::TopBtn() { if(loadCheck) { if( i_pageNum != 0) { odebug << "top" << oendl; qApp->processEvents(); currentLine = 0; i_pageNum = 1; int pageSize = Lview->PageSize() ; Lview->clear(); QString s; f.at(0); for(int fd=0; fd < pageSize ;fd++) { f.readLine(s, 256); if(useWrap) s.replace(QRegExp("\n"),""); Lview->insertLine(s ,-1); currentLine++; } // Lview->setCursorPosition( 0,0, FALSE); i_pageNum=1; setStatus(); } Lview->setFocus(); } } //moves text to the start of the EText void Gutenbrowser::BeginBtn() { i_pageNum = 1; currentLine = 0; QString s_pattern="*END*THE SMALL PRINT"; QString sPattern2 = "*END THE SMALL PRINT"; int pageSize = Lview->PageSize(); Lview->clear(); // int lines = Lview->numLines(); int pos = 0;//, i = 0; int i_topRow = Lview->topRow(); QString LeftText;// = Lview->text(); - int linesPerPage = Lview->lastRow() - Lview->topRow(); +// int linesPerPage = Lview->lastRow() - Lview->topRow(); // int pages = (( linesPerPage / Lview->editSize() ) ) +1; // int pageN = 0; i_pageNum = 1; int lastPage=1; int lineNo=0; QString s; f.at( 0); while ( !f.atEnd() ) { f.readLine(s, 256); lineNo++; LeftText = s; currentFilePos = f.at(); i_pageNum = lineNo/pageSize; if(lastPage < i_pageNum) { pageStopArray.resize(i_pageNum + 1); pageStopArray[i_pageNum ] = currentFilePos; // odebug << "new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; } // lastPage = i_pageNum; if( LeftText.find( s_pattern, 0 , TRUE) != -1 || LeftText.find( sPattern2, 0 , TRUE) != -1 ) { odebug << "<<<<<< FOUND IT!! new page number " << i_pageNum << ", found at " << currentFilePos << "" << oendl; break; } } if(f.atEnd()) //in case we didnt find anything, we need to show something f.at(0); Lview->clear(); for(int fd=0; fd < pageSize - 1;fd++) { f.readLine(s, 256); if(useWrap) s.replace(QRegExp("\n"),""); Lview->insertLine( s, -1); currentLine++; } i_pageNum = lineNo/pageSize; pageStopArray.resize(i_pageNum + 1); // int length = Lview->length(); qApp->processEvents(); if( pos > i_topRow ) { // Lview->setCursorPosition( pos+linesPerPage+2/* - i_topRow+3 */,0, FALSE); } else { // Lview->setCursorPosition( pos+2 , 0, FALSE ); } Lview->deselect(); // AdjustStatus(); Lview->setFocus(); } /* sets the current page and place as a bookmark*/ void Gutenbrowser::setBookmark() { int eexit=QMessageBox::information(this, "Note", "Do you really want to \nset this bookmark?." ,QMessageBox::Yes, QMessageBox::No); if (eexit== 3) { currentFilePos = f.at(); Config cfg("Gutenbrowser"); cfg.setGroup("General"); file_name = cfg.readEntry("Current",""); qApp->processEvents(); odebug << "Setting book mark "+file_name << oendl; cfg.setGroup("Titles"); title = cfg.readEntry(file_name,""); odebug << "title is "+ title << oendl; cfg.setGroup( "Bookmarks" ); cfg.writeEntry("File Name",file_name); cfg.writeEntry("Page Number",QString::number(i_pageNum) ); cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); cfg.writeEntry("Title", title); int row = Lview->topRow();// Lview->Top(); cfg.writeEntry("LineNumber",QString::number(row) ); cfg.setGroup(title); cfg.writeEntry("File Name",file_name); cfg.writeEntry( "LineNumber", QString::number( row)); cfg.writeEntry( "PagePosition", QString::number( pageStopArray[i_pageNum - 1])); cfg.writeEntry( "Page Number", QString::number( i_pageNum) ); cfg.write(); bookmarksMenu->insertItem( title); } } //end setBookmark /* goes to last set bookmark*/ |