summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/SearchDialog.cpp
blob: d989304c2d95cdfcbc545b4c141afe745dffca8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/****************************************************************************
** Created: Tue Aug 29 11:45:00 2000**/
//     copyright            : (C) 2000 -2004 by llornkcor
//     email                : ljp@llornkcor.com

#include "SearchDialog.h"
#include "SearchResults.h"

#include <qlayout.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qmessagebox.h>
#include <qdir.h>
#include <qpe/config.h>

/*This is just a single text entry dialog */
SearchDialog::SearchDialog( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
        setName( "SearchDialog" );
    Config cfg("Gutenbrowser");
    cfg.setGroup("General");
    QString lastSearch=cfg.readEntry("LastSearch","");

#warning FIXME
    // FIXME
    resize( 220,100);
    
    QGridLayout *layout = new QGridLayout( this );
    layout->setSpacing( 2);
    layout->setMargin( 2);

    QString local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
    TextLabel1 = new QLabel( this, "TextLabel1" );
    layout->addMultiCellWidget( TextLabel1, 0, 0, 0, 1);

    label1Str= "<P>Enter text to search etext for </P>" ;
    TextLabel1->setText( tr( label1Str) );

    SearchLineEdit = new QLineEdit( this, "SearchLineEdit" );
    layout->addMultiCellWidget( SearchLineEdit, 1, 1, 0, 1);

    buttonOk = new QPushButton( this, "buttonOk" );
    buttonOk->setText( tr( "Sea&rch"  ) );
    buttonOk->setAutoDefault( TRUE );
    buttonOk->setToggleButton( TRUE);
    buttonOk->setDefault( TRUE );

    layout->addMultiCellWidget(buttonOk, 2, 2, 0, 0);

    buttonCancel = new QPushButton( this, "buttonCancel" );
    buttonCancel->setText( tr( "&Cancel"  ) );
    buttonCancel->setAutoDefault( TRUE );
    layout->addMultiCellWidget(buttonCancel, 2, 2, 1, 1);
//    buttonCancel->setMaximumWidth(40);


    if( (QString)name !="Etext Search" )
        SearchLineEdit->setText(lastSearch);

    caseSensitiveCheckBox = new QCheckBox ( tr("Case Sensitive"), this );
    layout->addMultiCellWidget( caseSensitiveCheckBox, 3, 3, 0, 1);

      // signals and slots connections
    connect( buttonOk, SIGNAL( clicked() ), this, SLOT( byeBye() ) );

    connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( closed() ) );
    SearchLineEdit->setFocus();
}

SearchDialog::~SearchDialog()
{
}

QString SearchDialog::get_text() {
  return SearchLineEdit->text();
}

bool SearchDialog::get_direction() {
  return false; //search forward
}

bool SearchDialog::case_sensitive() {
  return true;
}

bool SearchDialog::forward_search() {
  return true;
}

void SearchDialog::byeBye()
{

    searchString = get_text();
//    odebug << "Search string is "+searchString << oendl; 
    Config cfg("Gutenbrowser");
    cfg.setGroup("General");
    cfg.writeEntry("LastSearch",searchString);

    QString thisName=name();
    if( thisName.find("Library Search", 0, TRUE) != -1) {
          //  searchString = SearchLineEdit->text();
        accept();
    } else {

        buttonOk->setDown(TRUE);

        emit search_signal();
        buttonOk->setDown(FALSE);
    }
}

void SearchDialog::closed()
{
    searchString = get_text();
//    odebug << "Search string is "+searchString << oendl; 
    Config cfg("Gutenbrowser");
    cfg.setGroup("General");
    cfg.writeEntry("LastSearch",searchString);

    emit search_done_signal();
      //this->reject();
    this->hide();
}


void SearchDialog::setLabel(QString labelText)
{
    TextLabel1->setText( tr( label1Str+labelText) );
}