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

SearchDialog.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Created: Tue Aug 29 11:45:00 2000**/
00003 //     copyright            : (C) 2000 -2004 by llornkcor
00004 //     email                : ljp@llornkcor.com
00005 
00006 #include "SearchDialog.h"
00007 #include "SearchResults.h"
00008 
00009 #include <qlayout.h>
00010 #include <qcheckbox.h>
00011 #include <qlabel.h>
00012 #include <qlineedit.h>
00013 #include <qpushbutton.h>
00014 #include <qvariant.h>
00015 #include <qtooltip.h>
00016 #include <qwhatsthis.h>
00017 #include <qmessagebox.h>
00018 #include <qdir.h>
00019 #include <qpe/config.h>
00020 
00021 /*This is just a single text entry dialog */
00022 SearchDialog::SearchDialog( QWidget* parent,  const char* name, bool modal, WFlags fl )
00023     : QDialog( parent, name, modal, fl )
00024 {
00025     if ( !name )
00026         setName( "SearchDialog" );
00027     Config cfg("Gutenbrowser");
00028     cfg.setGroup("General");
00029     QString lastSearch=cfg.readEntry("LastSearch","");
00030 
00031 #warning FIXME
00032     // FIXME
00033     resize( 220,110);
00034 
00035     QGridLayout *layout = new QGridLayout( this );
00036     layout->setSpacing( 2);
00037     layout->setMargin( 2);
00038 
00039     QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
00040     TextLabel1 = new QLabel( this, "TextLabel1" );
00041     layout->addMultiCellWidget( TextLabel1, 0, 0, 0, 1);
00042 
00043     label1Str= "<P>Enter text to search etext for </P>" ;
00044     TextLabel1->setText( tr( label1Str) );
00045 
00046     SearchLineEdit = new QLineEdit( this, "SearchLineEdit" );
00047     layout->addMultiCellWidget( SearchLineEdit, 1, 1, 0, 1);
00048 
00049     buttonOk = new QPushButton( this, "buttonOk" );
00050     buttonOk->setText( tr( "Sea&rch"  ) );
00051     buttonOk->setAutoDefault( TRUE );
00052     buttonOk->setToggleButton( TRUE);
00053     buttonOk->setDefault( TRUE );
00054 
00055     layout->addMultiCellWidget(buttonOk, 2, 2, 0, 0);
00056 
00057     buttonCancel = new QPushButton( this, "buttonCancel" );
00058     buttonCancel->setText( tr( "&Cancel"  ) );
00059     buttonCancel->setAutoDefault( TRUE );
00060     layout->addMultiCellWidget(buttonCancel, 2, 2, 1, 1);
00061 //    buttonCancel->setMaximumWidth(40);
00062 
00063 
00064     if( (QString)name !="Etext Search" )
00065         SearchLineEdit->setText(lastSearch);
00066 
00067     caseSensitiveCheckBox = new QCheckBox ( tr("Case Sensitive"), this );
00068     layout->addMultiCellWidget( caseSensitiveCheckBox, 3, 3, 0, 1);
00069 
00070       // signals and slots connections
00071     connect( buttonOk, SIGNAL( clicked() ), this, SLOT( byeBye() ) );
00072 
00073     connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( closed() ) );
00074     SearchLineEdit->setFocus();
00075 }
00076 
00077 SearchDialog::~SearchDialog()
00078 {
00079 }
00080 
00081 QString SearchDialog::get_text() {
00082   return SearchLineEdit->text();
00083 }
00084 
00085 bool SearchDialog::get_direction() {
00086   return false; //search forward
00087 }
00088 
00089 bool SearchDialog::case_sensitive() {
00090   return true;
00091 }
00092 
00093 bool SearchDialog::forward_search() {
00094   return true;
00095 }
00096 
00097 void SearchDialog::byeBye()
00098 {
00099 
00100     searchString = get_text();
00101 //    odebug << "Search string is "+searchString << oendl;
00102     Config cfg("Gutenbrowser");
00103     cfg.setGroup("General");
00104     cfg.writeEntry("LastSearch",searchString);
00105 
00106     QString thisName=name();
00107     if( thisName.find("Library Search", 0, TRUE) != -1) {
00108           //  searchString = SearchLineEdit->text();
00109         accept();
00110     } else {
00111 
00112         buttonOk->setDown(TRUE);
00113 
00114         emit search_signal();
00115         buttonOk->setDown(FALSE);
00116     }
00117 }
00118 
00119 void SearchDialog::closed()
00120 {
00121     searchString = get_text();
00122 //    odebug << "Search string is "+searchString << oendl;
00123     Config cfg("Gutenbrowser");
00124     cfg.setGroup("General");
00125     cfg.writeEntry("LastSearch",searchString);
00126 
00127     emit search_done_signal();
00128       //this->reject();
00129     this->hide();
00130 }
00131 
00132 
00133 void SearchDialog::setLabel(QString labelText)
00134 {
00135     TextLabel1->setText( tr( label1Str+labelText) );
00136 }

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