summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/mainwindow.cpp54
-rw-r--r--core/pim/osearch/mainwindow.h4
-rw-r--r--core/pim/osearch/osearch.pro1
-rw-r--r--core/pim/osearch/searchgroup.cpp15
-rw-r--r--core/pim/osearch/searchgroup.h4
5 files changed, 42 insertions, 36 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index a0b7b23..e15cc7e 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -2,203 +2,207 @@
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 10// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
11 11
12 12
13#include "mainwindow.h" 13#include "mainwindow.h"
14 14
15#include <qpe/qpemenubar.h> 15#include <qpe/qpemenubar.h>
16#include <qpe/qpemessagebox.h> 16#include <qpe/qpemessagebox.h>
17#include <qpe/resource.h> 17#include <qpe/resource.h>
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qaction.h> 21#include <qaction.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qtoolbutton.h> 24#include <qtoolbutton.h>
25#include <qstring.h> 25#include <qstring.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qfile.h> 27#include <qfile.h>
28#include <qhbuttongroup.h> 28#include <qhbuttongroup.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qintdict.h> 30#include <qintdict.h>
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qtextbrowser.h> 33#include <qtextbrowser.h>
34#include <qregexp.h>
34 35
35#include "olistview.h" 36#include "olistview.h"
36#include "olistviewitem.h" 37#include "olistviewitem.h"
37#include "resultitem.h" 38#include "resultitem.h"
38#include "adresssearch.h" 39#include "adresssearch.h"
39#include "todosearch.h" 40#include "todosearch.h"
40#include "datebooksearch.h" 41#include "datebooksearch.h"
41#include "applnksearch.h" 42#include "applnksearch.h"
42#include "doclnksearch.h" 43#include "doclnksearch.h"
43 44
44MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : 45MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
45 QMainWindow( parent, name, f ), _currentItem(0) 46 QMainWindow( parent, name, f ), _currentItem(0)
46{ 47{
47 setCaption( tr("OSearch") ); 48 setCaption( tr("OSearch") );
48 49
49 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 50 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
50 51
51 QFrame *mainFrame = new QFrame( this, "mainFrame" ); 52 QFrame *mainFrame = new QFrame( this, "mainFrame" );
52 53
53 mainLayout = new QVBoxLayout( mainFrame ); 54 mainLayout = new QVBoxLayout( mainFrame );
54 mainLayout->setSpacing( 0 ); 55 mainLayout->setSpacing( 0 );
55 mainLayout->setMargin( 0 ); 56 mainLayout->setMargin( 0 );
56 57
57 resultsList = new OListView( mainFrame ); 58 resultsList = new OListView( mainFrame );
58 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 59 resultsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
59 mainLayout->addWidget( resultsList, 1 ); 60 mainLayout->addWidget( resultsList, 1 );
60 61
61 detailsFrame = new QFrame( mainFrame, "detailsFrame" ); 62 detailsFrame = new QFrame( mainFrame, "detailsFrame" );
62 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); 63 QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame );
63 richEdit = new QTextView( detailsFrame ); 64 richEdit = new QTextView( detailsFrame );
64 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); 65 richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));
65 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); 66 //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ));
66 detailsLayout->addWidget( richEdit, 1 ); 67 detailsLayout->addWidget( richEdit, 1 );
67 68
68 buttonGroupActions = new QHButtonGroup( this ); 69 buttonGroupActions = new QHButtonGroup( this );
70 buttonGroupActions->hide();
69 _buttonCount = 0; 71 _buttonCount = 0;
70// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 72// buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
71 73
72 buttonLayout = new QHBoxLayout( detailsFrame ); 74 buttonLayout = new QHBoxLayout( detailsFrame );
73 buttonGroupActions->hide(); 75 detailsLayout->addLayout( buttonLayout );
74 //buttonLayout->addWidget( buttonGroupActions, 0 ); 76
75
76 detailsLayout->addLayout( buttonLayout );
77 /*
78 QPushButton *buttonShow = new QPushButton( detailsFrame, "Show" );
79 buttonShow->setText( tr("show") );
80 QPushButton *buttonEdit = new QPushButton( detailsFrame, "Edit" );
81 buttonEdit->setText( tr("edit") );
82 buttonLayout->addWidget( buttonShow, 0 );
83 buttonLayout->addWidget( buttonEdit, 0 );
84*/
85 mainLayout->addWidget( detailsFrame ); 77 mainLayout->addWidget( detailsFrame );
86 detailsFrame->hide(); 78 detailsFrame->hide();
87 79
88 searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); 80 searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
89 searches.append( new TodoSearch( resultsList, tr("todo") ) ); 81 searches.append( new TodoSearch( resultsList, tr("todo") ) );
90 searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); 82 searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
91 searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); 83 searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
92 searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); 84 searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
93 85
94 makeMenu(); 86 makeMenu();
95 setCentralWidget( mainFrame ); 87 setCentralWidget( mainFrame );
96 88
97 popupTimer = new QTimer(); 89 popupTimer = new QTimer();
98 90
99 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 91 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
100 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 92 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
101 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 93 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
102 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); 94 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
103// connect(buttonEdit, SIGNAL(clicked()), SLOT( editItem() ) );
104 95
105} 96}
106 97
107void MainWindow::makeMenu() 98void MainWindow::makeMenu()
108{ 99{
109// QPEToolBar *toolBar = new QPEToolBar( this ); 100 QPEToolBar *toolBar = new QPEToolBar( this );
110// QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); 101 QPEToolBar *searchBar = new QPEToolBar(this);
111// QPopupMenu *searchMenu = new QPopupMenu( menuBar ); 102 QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
103 QPopupMenu *searchMenu = new QPopupMenu( menuBar );
112// QPopupMenu *viewMenu = new QPopupMenu( menuBar ); 104// QPopupMenu *viewMenu = new QPopupMenu( menuBar );
113// QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); 105// QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
114// 106//
115 setToolBarsMovable( false ); 107 setToolBarsMovable( false );
116// toolBar->setHorizontalStretchable( true ); 108 toolBar->setHorizontalStretchable( true );
117// menuBar->insertItem( tr( "Search" ), searchMenu ); 109 menuBar->insertItem( tr( "Search" ), searchMenu );
118// menuBar->insertItem( tr( "View" ), viewMenu ); 110// menuBar->insertItem( tr( "View" ), viewMenu );
119// menuBar->insertItem( tr( "Settings" ), cfgMenu ); 111// menuBar->insertItem( tr( "Settings" ), cfgMenu );
120 112
121 //SEARCH 113 //SEARCH
122 QPEToolBar *searchBar = new QPEToolBar(this); 114 QAction *action = new QAction( tr("Search all"),QString::null, 0, this, 0 );
123 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 115 connect( action, SIGNAL(activated()), this, SLOT(searchAll()) );
124 QLabel *label = new QLabel( tr("Search: "), searchBar ); 116 action->addTo( searchMenu );
125// label->setBackgroundMode( PaletteForeground ); 117 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true );
126 searchBar->setHorizontalStretchable( TRUE ); 118 actionCaseSensitiv->addTo( searchMenu );
119 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true );
120 actionWildcards->addTo( searchMenu );
121
122 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
127 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); 123 QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" );
124 searchBar->setHorizontalStretchable( TRUE );
128 searchBar->setStretchableWidget( searchEdit ); 125 searchBar->setStretchableWidget( searchEdit );
129 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 126 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
130 this, SLOT( setSearch( const QString & ) ) ); 127 this, SLOT( setSearch( const QString & ) ) );
131 128
132
133} 129}
134 130
135MainWindow::~MainWindow() 131MainWindow::~MainWindow()
136{ 132{
137} 133}
138 134
139void MainWindow::setCurrent(QListViewItem *item) 135void MainWindow::setCurrent(QListViewItem *item)
140{ 136{
141 if (!item) return; 137 if (!item) return;
142 _currentItem = (OListViewItem*)item; 138 _currentItem = (OListViewItem*)item;
143 //_currentItem = dynamic_cast<OListViewItem*>(item); 139 //_currentItem = dynamic_cast<OListViewItem*>(item);
144 if (_currentItem->rtti() == OListViewItem::Result){ 140 if (_currentItem->rtti() == OListViewItem::Result){
145 ResultItem *res = (ResultItem*)item; 141 ResultItem *res = (ResultItem*)item;
146 // ResultItem *res = dynamic_cast<ResultItem*>(item); 142 // ResultItem *res = dynamic_cast<ResultItem*>(item);
147 richEdit->setText( res->toRichText() ); 143 richEdit->setText( res->toRichText() );
148 QIntDict<QString> acts = res->actions(); 144 QIntDict<QString> acts = res->actions();
149 QButton *button; 145 QButton *button;
150 for (uint i = 0; i < acts.count(); i++){ 146 for (uint i = 0; i < acts.count(); i++){
151 button = buttonGroupActions->find( i ); 147 button = buttonGroupActions->find( i );
152 qDebug("action %i >%s<",i,acts[i]->latin1()); 148 qDebug("action %i >%s<",i,acts[i]->latin1());
153 if (!button) { 149 if (!button) {
154 qDebug("BUTTON"); 150 qDebug("BUTTON");
155 button = new QPushButton( detailsFrame ); 151 button = new QPushButton( detailsFrame );
156 buttonLayout->addWidget( button, 0 ); 152 buttonLayout->addWidget( button, 0 );
157 buttonGroupActions->insert( button, i); 153 buttonGroupActions->insert( button, i);
158 } 154 }
159 button->setText( *acts[i] ); 155 button->setText( *acts[i] );
160 button->show(); 156 button->show();
161 } 157 }
162 for (uint i = acts.count(); i < _buttonCount; i++){ 158 for (uint i = acts.count(); i < _buttonCount; i++){
163 qDebug("remove button %i of %i",i, _buttonCount); 159 qDebug("remove button %i of %i",i, _buttonCount);
164 button = buttonGroupActions->find( i ); 160 button = buttonGroupActions->find( i );
165 if (button) button->hide(); 161 if (button) button->hide();
166 } 162 }
167 _buttonCount = acts.count(); 163 _buttonCount = acts.count();
168 // buttonShow = new QPushButton( detailsFrame, "Show" ) ; 164 // buttonShow = new QPushButton( detailsFrame, "Show" ) ;
169 // buttonShow->setText( "test" ); 165 // buttonShow->setText( "test" );
170 // buttonLayout->addWidget( buttonShow, 0 ); 166 // buttonLayout->addWidget( buttonShow, 0 );
171// buttonGroupActions->insert(buttonShow); 167// buttonGroupActions->insert(buttonShow);
172 detailsFrame->show(); 168 detailsFrame->show();
173 }else detailsFrame->hide(); 169 }else detailsFrame->hide();
174 //_currentItem = (OListViewItem*)item; 170 //_currentItem = (OListViewItem*)item;
175 popupTimer->start( 300 ); 171 popupTimer->start( 300 );
176} 172}
177 173
178void MainWindow::stopTimer(QListViewItem*) 174void MainWindow::stopTimer(QListViewItem*)
179{ 175{
180 popupTimer->stop(); 176 popupTimer->stop();
181} 177}
182 178
183void MainWindow::showPopup() 179void MainWindow::showPopup()
184{ 180{
185 qDebug("showPopup"); 181 qDebug("showPopup");
186 if (!_currentItem) return; 182 if (!_currentItem) return;
187} 183}
188 184
189void MainWindow::setSearch( const QString &key ) 185void MainWindow::setSearch( const QString &key )
190{ 186{
187 QRegExp re( key, actionCaseSensitiv->isOn(), actionWildcards->isOn() );
191 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) 188 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
192 s->setSearch( key ); 189 s->setSearch( re );
193} 190}
194 191
192void MainWindow::searchAll()
193{
194 bool openState;
195 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
196 s->doSearch();
197 }
198}
195 199
196void MainWindow::slotAction( int act) 200void MainWindow::slotAction( int act)
197{ 201{
198 if (_currentItem->rtti() == OListViewItem::Result){ 202 if (_currentItem->rtti() == OListViewItem::Result){
199 ResultItem *res = (ResultItem*)_currentItem; 203 ResultItem *res = (ResultItem*)_currentItem;
200 // ResultItem *res = dynamic_cast<ResultItem*>(item); 204 // ResultItem *res = dynamic_cast<ResultItem*>(item);
201 res->action(act); 205 res->action(act);
202 } 206 }
203} 207}
204 208
diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h
index f6ae0a4..2773205 100644
--- a/core/pim/osearch/mainwindow.h
+++ b/core/pim/osearch/mainwindow.h
@@ -17,54 +17,56 @@
17#include <qaction.h> 17#include <qaction.h>
18#include <qlist.h> 18#include <qlist.h>
19#include <qtimer.h> 19#include <qtimer.h>
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21 21
22class QPEToolBar; 22class QPEToolBar;
23class QVBoxLayout; 23class QVBoxLayout;
24class QHBoxLayout; 24class QHBoxLayout;
25class QTextView; 25class QTextView;
26class QFrame; 26class QFrame;
27class QListViewItem; 27class QListViewItem;
28class OListView; 28class OListView;
29class OListViewItem; 29class OListViewItem;
30class QHButtonGroup; 30class QHButtonGroup;
31 31
32class SearchGroup; 32class SearchGroup;
33 33
34class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38 38
39public: 39public:
40 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 40 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
41 ~MainWindow(); 41 ~MainWindow();
42 42
43 43
44public slots: 44public slots:
45 void setCurrent(QListViewItem*); 45 void setCurrent(QListViewItem*);
46 void showPopup(); 46 void showPopup();
47 void stopTimer( QListViewItem* ); 47 void stopTimer( QListViewItem* );
48 void setSearch( const QString& ); 48 void setSearch( const QString& );
49 void searchAll();
49 50
50protected slots: 51protected slots:
51 void slotAction(int); 52 void slotAction(int);
52 53
53private: 54private:
54 OListView *resultsList; 55 OListView *resultsList;
55 QTextView *richEdit; 56 QTextView *richEdit;
56 OListViewItem *_currentItem; 57 OListViewItem *_currentItem;
57 QVBoxLayout *mainLayout; 58 QVBoxLayout *mainLayout;
58 QHBoxLayout *buttonLayout; 59 QHBoxLayout *buttonLayout;
59 QFrame *detailsFrame; 60 QFrame *detailsFrame;
60// OListViewItem *_item;
61 QTimer *popupTimer; 61 QTimer *popupTimer;
62 62
63 QList<SearchGroup> searches; 63 QList<SearchGroup> searches;
64 QHButtonGroup *buttonGroupActions; 64 QHButtonGroup *buttonGroupActions;
65 QAction *actionCaseSensitiv;
66 QAction *actionWildcards;
65 uint _buttonCount; 67 uint _buttonCount;
66 void makeMenu(); 68 void makeMenu();
67}; 69};
68 70
69#endif 71#endif
70 72
diff --git a/core/pim/osearch/osearch.pro b/core/pim/osearch/osearch.pro
index d5dcda2..2e571e3 100644
--- a/core/pim/osearch/osearch.pro
+++ b/core/pim/osearch/osearch.pro
@@ -1,35 +1,36 @@
1DEPENDPATH += $(OPIEDIR)/include 1DEPENDPATH += $(OPIEDIR)/include
2LIBS += -lqpe -lopie 2LIBS += -lqpe -lopie
3INTERFACES = 3INTERFACES =
4include ( $(OPIEDIR)/include.pro )
4TEMPLATE = app 5TEMPLATE = app
5CONFIG += debug warn_on qt 6CONFIG += debug warn_on qt
6DESTDIR = $(OPIEDIR)/bin 7DESTDIR = $(OPIEDIR)/bin
7TARGET = osearch 8TARGET = osearch
8INCLUDEPATH = $(OPIEDIR)/include 9INCLUDEPATH = $(OPIEDIR)/include
9SOURCES += main.cpp \ 10SOURCES += main.cpp \
10 mainwindow.cpp \ 11 mainwindow.cpp \
11 olistview.cpp \ 12 olistview.cpp \
12 olistviewitem.cpp \ 13 olistviewitem.cpp \
13 adresssearch.cpp \ 14 adresssearch.cpp \
14 todosearch.cpp \ 15 todosearch.cpp \
15 datebooksearch.cpp \ 16 datebooksearch.cpp \
16 searchgroup.cpp \ 17 searchgroup.cpp \
17 resultitem.cpp \ 18 resultitem.cpp \
18 todoitem.cpp \ 19 todoitem.cpp \
19 contactitem.cpp \ 20 contactitem.cpp \
20 eventitem.cpp \ 21 eventitem.cpp \
21 applnksearch.cpp \ 22 applnksearch.cpp \
22 applnkitem.cpp \ 23 applnkitem.cpp \
23 doclnkitem.cpp \ 24 doclnkitem.cpp \
24 doclnksearch.cpp 25 doclnksearch.cpp
25HEADERS += mainwindow.h \ 26HEADERS += mainwindow.h \
26 olistview.h \ 27 olistview.h \
27 olistviewitem.h \ 28 olistviewitem.h \
28 adresssearch.h \ 29 adresssearch.h \
29 todosearch.h \ 30 todosearch.h \
30 datebooksearch.h \ 31 datebooksearch.h \
31 searchgroup.h \ 32 searchgroup.h \
32 resultitem.h \ 33 resultitem.h \
33 todoitem.h \ 34 todoitem.h \
34 contactitem.h \ 35 contactitem.h \
35 eventitem.h \ 36 eventitem.h \
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp
index d062207..3159984 100644
--- a/core/pim/osearch/searchgroup.cpp
+++ b/core/pim/osearch/searchgroup.cpp
@@ -13,61 +13,62 @@
13#include "searchgroup.h" 13#include "searchgroup.h"
14 14
15#include <qregexp.h> 15#include <qregexp.h>
16 16
17#include "olistviewitem.h" 17#include "olistviewitem.h"
18 18
19SearchGroup::SearchGroup(QListView* parent, QString name) 19SearchGroup::SearchGroup(QListView* parent, QString name)
20: OListViewItem(parent, name) 20: OListViewItem(parent, name)
21{ 21{
22 _name = name; 22 _name = name;
23 loaded = false; 23 loaded = false;
24 expanded = false; 24 expanded = false;
25} 25}
26 26
27 27
28SearchGroup::~SearchGroup() 28SearchGroup::~SearchGroup()
29{ 29{
30} 30}
31 31
32 32
33void SearchGroup::expand() 33void SearchGroup::expand()
34{ 34{
35 clearList(); 35 clearList();
36 if (_search.isEmpty()) return; 36 if (_search.isEmpty()) return;
37 OListViewItem *dummy = new OListViewItem( this, "searching..."); 37 OListViewItem *dummy = new OListViewItem( this, "searching...");
38 setOpen( expanded ); 38 setOpen( expanded );
39 if (!loaded) load(); 39 if (!loaded) load();
40 int res_count = search(); 40 int res_count = search();
41 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); 41 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
42 delete dummy; 42 delete dummy;
43} 43}
44 44
45void SearchGroup::doSearch()
46{
47 clearList();
48 if (_search.isEmpty()) return;
49 if (!loaded) load();
50 int res_count = search();
51 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
52}
45 53
46void SearchGroup::clearList() 54void SearchGroup::clearList()
47{ 55{
48 QListViewItem *item = firstChild(); 56 QListViewItem *item = firstChild();
49 QListViewItem *toDel; 57 QListViewItem *toDel;
50 58
51 while ( item != 0 ) { 59 while ( item != 0 ) {
52 toDel = item; 60 toDel = item;
53 item = item->nextSibling(); 61 item = item->nextSibling();
54 delete toDel; 62 delete toDel;
55 } 63 }
56 expanded = true; 64 expanded = true;
57} 65}
58 66
59void SearchGroup::setSearch(QString s)
60{
61 setSearch( QRegExp( s ) );
62 _search.setCaseSensitive(false);
63}
64
65
66void SearchGroup::setSearch(QRegExp re) 67void SearchGroup::setSearch(QRegExp re)
67{ 68{
68 setText(0, _name+" - "+re.pattern() ); 69 setText(0, _name+" - "+re.pattern() );
69 _search = re; 70 _search = re;
70 if (expanded) expand(); 71 if (expanded) expand();
71 else new OListViewItem( this, "searching..."); 72 else new OListViewItem( this, "searching...");
72} 73}
73 74
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index 35949f0..bf5dc67 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -1,48 +1,46 @@
1// 1//
2// 2//
3// C++ Interface: $MODULE$ 3// C++ Interface: $MODULE$
4// 4//
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#ifndef SEARCHGROUP_H 13#ifndef SEARCHGROUP_H
14#define SEARCHGROUP_H 14#define SEARCHGROUP_H
15 15
16#include "olistviewitem.h" 16#include "olistviewitem.h"
17 17
18class QRegExp; 18class QRegExp;
19 19
20/** 20/**
21@author Patrick S. Vogt 21@author Patrick S. Vogt
22*/ 22*/
23class SearchGroup : public OListViewItem 23class SearchGroup : public OListViewItem
24{ 24{
25public: 25public:
26 SearchGroup(QListView* parent, QString name); 26 SearchGroup(QListView* parent, QString name);
27 27
28 ~SearchGroup(); 28 ~SearchGroup();
29 29
30 virtual void expand(); 30 virtual void expand();
31 virtual void setSearch(QString); 31 virtual void doSearch();
32 virtual void setSearch(QRegExp); 32 virtual void setSearch(QRegExp);
33 virtual int rtti() { return Searchgroup;} 33 virtual int rtti() { return Searchgroup;}
34 34
35
36
37protected: 35protected:
38 QRegExp _search; 36 QRegExp _search;
39 virtual void load() = 0; 37 virtual void load() = 0;
40 virtual int search() = 0; 38 virtual int search() = 0;
41 virtual void insertItem( void* ) = 0; 39 virtual void insertItem( void* ) = 0;
42 void clearList(); 40 void clearList();
43 QString _name; 41 QString _name;
44 bool expanded; 42 bool expanded;
45 bool loaded; 43 bool loaded;
46}; 44};
47 45
48#endif 46#endif