summaryrefslogtreecommitdiff
path: root/core/pim/osearch/mainwindow.cpp
Unidiff
Diffstat (limited to 'core/pim/osearch/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/mainwindow.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index c6934db..aa52061 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -10,28 +10,30 @@
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11 11
12 12
13 13
14#include <qaction.h> 14#include <qaction.h>
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qpopupmenu.h> 16#include <qpopupmenu.h>
17#include <qtoolbutton.h> 17#include <qtoolbutton.h>
18#include <qstring.h> 18#include <qstring.h>
19#include <qlabel.h> 19#include <qlabel.h>
20#include <qfile.h> 20#include <qfile.h>
21#include <qhbuttongroup.h> 21#include <qhbuttongroup.h>
22#include <qhbox.h>
22#include <qpushbutton.h> 23#include <qpushbutton.h>
23#include <qintdict.h> 24#include <qintdict.h>
24#include <qlayout.h> 25#include <qlayout.h>
25#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qsignalmapper.h>
26#include <qtextbrowser.h> 28#include <qtextbrowser.h>
27#include <qregexp.h> 29#include <qregexp.h>
28#include <qwhatsthis.h> 30#include <qwhatsthis.h>
29#include <qpe/qpemenubar.h> 31#include <qpe/qpemenubar.h>
30#include <qpe/qpemessagebox.h> 32#include <qpe/qpemessagebox.h>
31#include <qpe/resource.h> 33#include <qpe/resource.h>
32#include <qpe/config.h> 34#include <qpe/config.h>
33#include <qpe/qpetoolbar.h> 35#include <qpe/qpetoolbar.h>
34#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
35#include <qpe/config.h> 37#include <qpe/config.h>
36#include <qpe/global.h> 38#include <qpe/global.h>
37#include <opie/owait.h> 39#include <opie/owait.h>
@@ -62,50 +64,52 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
62 64
63 resultsList = new OListView( mainFrame ); 65 resultsList = new OListView( mainFrame );
64 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 66 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
65 mainLayout->addWidget( resultsList ); 67 mainLayout->addWidget( resultsList );
66 68
67 detailsFrame = new QFrame( mainFrame, "detailsFrame" ); 69 detailsFrame = new QFrame( mainFrame, "detailsFrame" );
68 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); 70 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
69 richEdit = new QTextView( detailsFrame ); 71 richEdit = new QTextView( detailsFrame );
70 QWhatsThis::add( richEdit, tr("The details of the current result") ); 72 QWhatsThis::add( richEdit, tr("The details of the current result") );
71 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 73 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
72 detailsLayout->addWidget( richEdit ); 74 detailsLayout->addWidget( richEdit );
73 75
74 buttonGroupActions = new QHButtonGroup( this ); 76 buttonBox = new QHBox( mainFrame, "Button Box" );
75 buttonGroupActions->hide();
76 _buttonCount = 0;
77 77
78 buttonLayout = new QHBoxLayout( detailsFrame ); 78 _buttonCount = 0;
79 detailsLayout->addLayout( buttonLayout );
80 79
81 mainLayout->addWidget( detailsFrame ); 80 mainLayout->addWidget( detailsFrame );
81 mainLayout->addWidget( buttonBox );
82 detailsFrame->hide(); 82 detailsFrame->hide();
83 buttonBox->hide();
83 84
84 searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); 85 searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
85 searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); 86 searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
86 searches.append( new TodoSearch( resultsList, tr("todo") ) ); 87 searches.append( new TodoSearch( resultsList, tr("todo") ) );
87 searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); 88 searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
88 searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); 89 searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
89 90
90 setCentralWidget( mainFrame ); 91 setCentralWidget( mainFrame );
91 92
92 popupTimer = new QTimer(); 93 popupTimer = new QTimer();
93 searchTimer = new QTimer(); 94 searchTimer = new QTimer();
94 95
95 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 96 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
96 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); 97 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged()));
97 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 98 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
98 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 99 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
99 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); 100
101 signalMapper = new QSignalMapper( this );
102
103 connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) );
100 104
101 makeMenu(); 105 makeMenu();
102 106
103 Config cfg( "osearch", Config::User ); 107 Config cfg( "osearch", Config::User );
104 cfg.setGroup( "search_settings" ); 108 cfg.setGroup( "search_settings" );
105 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); 109 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) );
106 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); 110 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) );
107// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); 111// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) );
108} 112}
109 113
110void MainWindow::makeMenu() 114void MainWindow::makeMenu()
111{ 115{
@@ -174,40 +178,47 @@ MainWindow::~MainWindow()
174void MainWindow::setCurrent(QListViewItem *item) 178void MainWindow::setCurrent(QListViewItem *item)
175{ 179{
176 if (!item) return; 180 if (!item) return;
177 _currentItem = (OListViewItem*)item; 181 _currentItem = (OListViewItem*)item;
178 //_currentItem = dynamic_cast<OListViewItem*>(item); 182 //_currentItem = dynamic_cast<OListViewItem*>(item);
179 if (_currentItem->rtti() == OListViewItem::Result){ 183 if (_currentItem->rtti() == OListViewItem::Result){
180 ResultItem *res = (ResultItem*)item; 184 ResultItem *res = (ResultItem*)item;
181 // ResultItem *res = dynamic_cast<ResultItem*>(item); 185 // ResultItem *res = dynamic_cast<ResultItem*>(item);
182 richEdit->setText( res->toRichText() ); 186 richEdit->setText( res->toRichText() );
183 QIntDict<QString> acts = res->actions(); 187 QIntDict<QString> acts = res->actions();
184 QButton *button; 188 QButton *button;
185 for (uint i = 0; i < acts.count(); i++){ 189 for (uint i = 0; i < acts.count(); i++){
186 button = buttonGroupActions->find( i ); 190 button = buttonMap[i];
187 if (!button) { 191 if (!button) {
188 button = new QPushButton( detailsFrame ); 192 qWarning(" no button for %s", (*acts[i]).latin1() );
189 buttonLayout->addWidget( button, 0 ); 193 button = new QPushButton( buttonBox );
190 buttonGroupActions->insert( button, i); 194 buttonMap.insert( i, button );
195 signalMapper->setMapping(button, i );
196 connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) );
191 } 197 }
192 button->setText( *acts[i] ); 198 button->setText( *acts[i] );
193 button->show(); 199 button->show();
194 } 200 }
195 for (uint i = acts.count(); i < _buttonCount; i++){ 201 for (uint i = acts.count(); i < _buttonCount; i++){
196 button = buttonGroupActions->find( i ); 202 button = buttonMap[i];
197 if (button) button->hide(); 203 if (button) button->hide();
198 } 204 }
199 _buttonCount = acts.count(); 205 _buttonCount = acts.count();
200 detailsFrame->show(); 206 detailsFrame->show();
201 }else detailsFrame->hide(); 207 buttonBox->show();
208
209 }else {
210 detailsFrame->hide();
211 buttonBox->hide();
212 }
202 popupTimer->start( 300, true ); 213 popupTimer->start( 300, true );
203} 214}
204 215
205void MainWindow::stopTimer(QListViewItem*) 216void MainWindow::stopTimer(QListViewItem*)
206{ 217{
207 popupTimer->stop(); 218 popupTimer->stop();
208} 219}
209 220
210void MainWindow::showPopup() 221void MainWindow::showPopup()
211{ 222{
212 popupTimer->stop(); 223 popupTimer->stop();
213 if (!_currentItem) return; 224 if (!_currentItem) return;
@@ -244,23 +255,23 @@ void MainWindow::searchAll()
244{ 255{
245#ifdef NEW_OWAIT 256#ifdef NEW_OWAIT
246 OWait("searching..."); 257 OWait("searching...");
247#endif 258#endif
248 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 259 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
249 s->doSearch(); 260 s->doSearch();
250 //resultsList->repaint(); 261 //resultsList->repaint();
251 } 262 }
252} 263}
253 264
254void MainWindow::slotAction( int act ) 265void MainWindow::slotAction( int act )
255{ 266{
256 if (_currentItem->rtti() == OListViewItem::Result){ 267 if ( _currentItem && _currentItem->rtti() == OListViewItem::Result){
257 ResultItem *res = (ResultItem*)_currentItem; 268 ResultItem *res = (ResultItem*)_currentItem;
258 // ResultItem *res = dynamic_cast<ResultItem*>(item); 269 // ResultItem *res = dynamic_cast<ResultItem*>(item);
259 res->action(act); 270 res->action(act);
260 } 271 }
261} 272}
262 273
263void MainWindow::optionChanged(int i) 274void MainWindow::optionChanged(int )
264{ 275{
265 searchStringChanged(); 276 searchStringChanged();
266} 277}