Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gutenbrowserData.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           gutenbrowser.cpp  -  description
00003                              -------------------
00004     begin                : Mon Jul 24 22:33:12 MDT 2000
00005     copyright            : (C) 2000 -2004 by llornkcor
00006     email                : ljp@llornkcor.com
00007 ***************************************************************************/
00008 /***************************************************************************
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  ***************************************************************************/
00014 
00015 //#include "gutenbrowserData.h"
00016 #include "gutenbrowser.h"
00017 #include "multiline_ex.h"
00018 
00019 /* OPIE */
00020 #include <opie2/odebug.h>
00021 #include <opie2/oresource.h>
00022 
00023 #include <qpe/config.h>
00024 #include <qpe/fontdatabase.h>
00025 #include <qpe/menubutton.h>
00026 #include <qpe/resource.h>
00027 #include <qpe/qpeapplication.h>
00028 
00029 /* QT */
00030 #include <qfontinfo.h>
00031 #include <qtoolbutton.h>
00032 
00033 void Gutenbrowser::initSlots() {
00034 
00035     connect(LibraryButton,SIGNAL(released()),SLOT(LibraryBtn()));
00036     connect(OpenButton,SIGNAL(released()),SLOT(OpenBtn()));
00037     connect(SearchButton,SIGNAL(released()),SLOT(SearchBtn()));
00038     connect(ForwardButton,SIGNAL(clicked()),SLOT(ForwardBtn()));
00039     connect(BackButton,SIGNAL(clicked()),SLOT(BackBtn()));
00040     connect(setBookmarkButton,SIGNAL(released()),SLOT(setBookmark()));
00041     connect(dictionaryButton,SIGNAL(released()),SLOT(LookupBtn()));
00042     connect(InfoBar,SIGNAL(clicked()),SLOT(InfoBarClick()));
00043     connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp()));
00044     connect(mainList,SIGNAL(clicked(QListBoxItem *)),SLOT(listClickedSlot(QListBoxItem *)));
00045     connect(bookmarksMenu,SIGNAL(activated(int)),SLOT(Bookmark(int)));
00046 }
00047 
00048 void Gutenbrowser::initConfig() {
00049 //odebug << "Starting configuration." << oendl;
00050     QDir library(local_library);
00051     if ( !library.exists()) {
00052         library.mkdir(local_library, TRUE);
00053         QString msg;
00054 // #ifndef Q_WS_WIN
00055         msg = "chmod 755 " + local_library;
00056         system(msg);
00057 //     QDir pixdir(local_library+"pix");
00058 //     if ( !pixdir.exists()) {
00059 //         pixdir.mkdir(local_library+"pix", TRUE);
00060 //         QString msg;
00061 //         msg = "chmod 755 " + local_library+"pix";
00062 //         system(msg);
00063 //     }
00064 // #endif
00065 
00066     }
00067       qDebug("init file is " + iniFile );;
00068 
00069 #ifdef Q_WS_QWS
00070     useSplitter=FALSE;
00071     Config config("Gutenbrowser");
00072 
00073     config.setGroup( "General" );
00074 //useWordWrap_CheckBox
00075     useIcons=TRUE;
00076 #else
00077 
00078     config.setGroup( "General" );
00079     QString s_Split=config.readEntry("Splitter", "TRUE" );
00080     QWidget *d = QApplication::desktop();
00081     int width=d->width();
00082     int height=d->height();
00083     int w=0, h=0;
00084     QString str, str2;
00085 
00086     this->setMaximumWidth(width);
00087 
00088     if(s_Split=="TRUE")
00089         useSplitter=TRUE;
00090     else
00091         useSplitter=FALSE;
00092 
00093     config.setGroup( "Geometry" );
00094     if(width < 1030) {
00095         str = config.readEntry("Frame", "700,500");
00096         if(  !str.isEmpty() && str.find(',')>=0) {
00097             sscanf(str,"%d,%d",&w,&h);
00098             resize(w,h);
00099             str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
00100             str = config.readEntry( "Position", str2);
00101         } else {
00102             resize( 740,510 );
00103             str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
00104             str = config.readEntry( "Position",str2);
00105         }
00106     } else {// desktop is high res
00107         str = config.readEntry("Frame", "990,640");
00108         if(  !str.isEmpty() && str.find(',')>=0) {
00109             sscanf(str,"%d,%d",&w,&h);
00110             resize(w,h);
00111             str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
00112             str = config.readEntry( "Position", str2);
00113         } else {
00114             resize( 990,640 );
00115             str2.sprintf("%d,%d", (width-w)/2,(height-h)/2);
00116             str = config.readEntry( "Position", str2);
00117         }
00118     }
00119     int posX, posY;
00120     bool ok;
00121     QString goober;
00122     goober=str.left( str.find(",", 0, TRUE) );
00123     posX=goober.toInt( &ok, 10);
00124     goober=str.right( str.findRev(",", -1, TRUE) );
00125     posY= goober.toInt( &ok, 10);
00126 //     move( posX, posY);
00127     str = config.readEntry("Icons", "TRUE");
00128     if(str == "TRUE")
00129         useIcons=TRUE;
00130     else
00131         useIcons=FALSE;
00132 #endif
00133 // #if defined(_WS_WIN_)
00134 //     move( posX-4, posY-20);
00135 // #endif
00136 
00137     config.setGroup( "Browser" );
00138     brow = config.readEntry( "Preferred", "Opera");
00139     config.setGroup( "FTPsite" );  // ftp server config
00140     ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
00141 //    ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
00142     ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(")        ",0,TRUE)+1) );
00143     ftp_host=ftp_host.stripWhiteSpace();
00144 
00145     ftp_base_dir= config.readEntry("base",  "/pub/gutenberg");
00146 
00147             //bool ok2;
00148     QString temp;
00149     QString copying;
00150     copying="";
00151 
00152     config.setGroup("General");
00153     QString qExit;
00154     qExit=config.readEntry("queryExit","TRUE");
00155     if(qExit=="TRUE") {
00156         b_queryExit=TRUE;
00157 qDebug("lease query before leaving the library.");;
00158     } else {
00159                         qDebug("Please DO NOT query before leaving the library.");
00160         b_queryExit=FALSE;
00161     }
00162 // bookmarks
00163 //       config.setGroup("Titles");
00164 //      QString tmpTitle=config.readEntry(file_name,"");
00165 
00166 
00167 }// end initConfig()
00168 
00169 #define SCALED  Opie::Core::OResource::SmallIcon
00170 
00171 void Gutenbrowser::initMenuBar()
00172 {
00173         qDebug("Starting menu init.");
00174       // menuBar entry fileMenu
00175     menubar = new QPEMenuBar(this);
00176 
00177     fileMenu=new QPopupMenu();
00178     fileMenu->insertItem( Opie::Core::OResource::loadPixmap("gutenbrowser/openbook", SCALED ),
00179                          "Open Local Library...", this, SLOT( OpenBtn()) );
00180 //    fileMenu->insertItem("Download FTPSite", this, SLOT( downloadFtpList()) );
00181     fileMenu->insertItem( Opie::Core::OResource::loadPixmap("home", SCALED ),
00182                           "Download Library Index", this, SLOT( downloadLibIndex()) );
00183     fileMenu->insertItem( Opie::Core::OResource::loadPixmap("quit",SCALED),
00184                           "Quit Gutenbrowser...", this, SLOT( ByeBye()) );
00185       // menuBar entry editMenu
00186 
00187     editMenu=new QPopupMenu();
00188 
00189     editMenu->insertItem( Opie::Core::OResource::loadPixmap("up", SCALED ), "Top",
00190                                                  this, SLOT(TopBtn()) );
00191     editMenu->insertItem( Opie::Core::OResource::loadPixmap("back",SCALED ), "Beginning",
00192                           this, SLOT(doBeginBtn()) );
00193     editMenu->insertItem( Opie::Core::OResource::loadPixmap("gutenbrowser/search",SCALED ), "Search",
00194                           this, SLOT(SearchBtn()) );
00195 
00196     editMenu->insertItem("Clear", this, SLOT(ClearEdit()) );
00197 
00198     optionsMenu= new QPopupMenu();
00199     optionsMenu->insertItem( Opie::Core::OResource::loadPixmap("gutenbrowser/configure",SCALED ),
00200                              "Configure", this, SLOT(doOptions()) );
00201 
00202     donateMenu = new QPopupMenu();
00203 //     donateMenu->insertItem("Gutenberg", this, SLOT(donateGutenberg()) );
00204     donateMenu->insertItem( Opie::Core::OResource::loadPixmap("gutenbrowser/gutenbrowser_sm", SCALED ),
00205                             "Gutenbrowser Developer", this, SLOT(infoGutenbrowser()) );
00206 
00207     menubar->insertItem("File", fileMenu);
00208     menubar->insertItem("Page", editMenu);
00209     menubar->insertItem("Options", optionsMenu);
00210 //    menubar->insertItem("More Info", donateMenu);
00211 
00212     menu->addWidget( menubar,0);
00213 
00214     topLayout->addLayout( menu, 0);
00215 }
00216 
00217 void Gutenbrowser::initButtonBar()
00218 {
00219 //      qDebug("Starting buttonbar init.");
00220 
00221     OpenButton = new QPushButton( this, "OpenButton" );
00222     OpenButton->setFocusPolicy( QWidget::TabFocus );
00223     LibraryButton = new QPushButton( this, "LibraryButton" );
00224     LibraryButton->setFocusPolicy( QWidget::TabFocus );
00225 
00226     BackButton = new QPushButton( this, "BackButton" );
00227     BackButton->setFocusPolicy( QWidget::TabFocus );
00228     BackButton->setAutoRepeat(TRUE);
00229 
00230     ForwardButton = new QPushButton( this, "ForwardButton" );
00231     ForwardButton->setFocusPolicy( QWidget::TabFocus );
00232 //    ForwardButton->setAutoRepeat(TRUE);
00233 
00234     SearchButton = new QPushButton( this, "SearchButton" );
00235     SearchButton->setFocusPolicy( QWidget::TabFocus );
00236 
00237     setBookmarkButton = new QPushButton( this, "setBookmark" );
00238     setBookmarkButton->setFocusPolicy( QWidget::TabFocus );
00239 
00240     lastBmkButton = new MenuButton( this, "lastBmkButton" );
00241     lastBmkButton->setFocusPolicy( QWidget::TabFocus );
00242 
00243     bookmarksMenu = new QPopupMenu();
00244     bookmarksMenu->insertItem("Last Set", this, SLOT(Bookmark( int) ));
00245 
00246     lastBmkButton->setPopup(bookmarksMenu);
00247 
00248     dictionaryButton = new QPushButton( this, "dictionaryButton" );
00249     dictionaryButton->setFocusPolicy( QWidget::TabFocus );
00250 
00251     InfoBar = new QPushButton( this, "Info_Bar" );
00252 //    if(!useSplitter) {
00253 
00254     buttonsHidden=false;
00255 
00256     buttons2->addWidget(OpenButton, 0, AlignCenter);
00257     buttons2->addWidget(LibraryButton, 0, AlignCenter);
00258     buttons2->addWidget(BackButton, 0, AlignCenter);
00259     buttons2->addWidget(ForwardButton, 0, AlignCenter);
00260     buttons2->addWidget(SearchButton, 0, AlignCenter);
00261     buttons2->addWidget(setBookmarkButton, 0, AlignCenter);
00262     buttons2->addWidget(lastBmkButton, 0, AlignCenter);
00263     buttons2->addWidget(dictionaryButton, 0, AlignCenter);
00264     buttons2->addWidget(InfoBar, 0, AlignCenter);
00265     buttons2->addStretch(5);
00266     buttons2->setSpacing(5);
00267 
00268     topLayout->addLayout( buttons2,0);
00269 }
00270 
00271 /* STATUSBAR*/
00272 void Gutenbrowser::initStatusBar()
00273 {
00274         qDebug("statusbar");
00275 // #ifndef Q_WS_QWS
00276 
00277 //     statusBar = new QStatusBar( this, "Status Bar");
00278 //     statusBar->message(IDS_STATUS_DEFAULT, 2000);
00279 // #endif
00280 }
00281 
00282 void Gutenbrowser::initView()
00283 {
00284       // set the main widget here
00285 //        QFont defaultFont( "charter", 10, 50, 0 );
00286     Lview = new MultiLine_Ex(this);
00287     Config cfg("Gutenbrowser");
00288     cfg.setGroup("Font");
00289 
00290     FontDatabase fdb;
00291     QFont defaultFont = Lview->font();
00292     QFontInfo fontInfo(defaultFont);
00293 
00294     QString family = cfg.readEntry("Family", fontInfo.family());
00295     QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
00296     int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
00297     QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
00298 
00299     defaultFont = fdb.font(family,style,i_size,charSet);
00300 
00301     QString italic = cfg.readEntry("Italic","FALSE");
00302     if(italic=="TRUE") {
00303         qDebug("Set Italic font");;
00304         defaultFont = fdb.font( family, "Regular", i_size,charSet); //workaround
00305         defaultFont.setItalic(TRUE);
00306     }
00307 
00308     Lview->setFont( defaultFont);
00309     update();
00310 
00311     cfg.setGroup("General");
00312 
00313     if( cfg.readBoolEntry("WordWrap", 1)) {
00314         Lview->setWordWrap(QMultiLineEdit::WidgetWidth);
00315         useWrap=true;
00316     } else {
00317         Lview->setWordWrap(QMultiLineEdit::NoWrap);
00318         useWrap = false;
00319     }
00320     mainList = new QListBox(this,"mainlist");
00321                 mainList->hide();
00322 //  QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
00323       //  mainList->showMaximized();
00324 //  mainList->setGeometry(2,30,230,160);
00325     Lview->setReadOnly( true);
00326     edits->addWidget( Lview);
00327     edits->addWidget(mainList);
00328 
00329 //     if(!showMainList) {
00330 //         Lview->setText( "\nThis is gutenbrowser for the Sharp Zaurus.\nMake your self at home, sit back, relax and read something great. ");
00331 //     }
00332 //              else
00333 //        Lview->hide();
00334 
00335     topLayout->addLayout( edits, 0);
00336                 qDebug("end initView");
00337 }
00338 
00339 void Gutenbrowser::hideView() {
00340 //              qWarning("Hide View");
00341                 mainList->show();
00342                 Lview->hide();
00343 }

Generated on Sat Nov 5 16:16:52 2005 for OPIE by  doxygen 1.4.2