Diffstat (limited to 'core/pim/osearch/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index b80c637..89ab690 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -18,8 +18,9 @@ | |||
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 <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qpe/global.h> | ||
22 | #include <qaction.h> | 23 | #include <qaction.h> |
23 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
24 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
25 | #include <qtoolbutton.h> | 26 | #include <qtoolbutton.h> |
@@ -83,9 +84,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
83 | searches.append( new TodoSearch( resultsList, tr("todo") ) ); | 84 | searches.append( new TodoSearch( resultsList, tr("todo") ) ); |
84 | searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); | 85 | searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); |
85 | searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); | 86 | searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); |
86 | 87 | ||
87 | makeMenu(); | ||
88 | setCentralWidget( mainFrame ); | 88 | setCentralWidget( mainFrame ); |
89 | 89 | ||
90 | popupTimer = new QTimer(); | 90 | popupTimer = new QTimer(); |
91 | searchTimer = new QTimer(); | 91 | searchTimer = new QTimer(); |
@@ -95,13 +95,15 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
95 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | 95 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); |
96 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 96 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
97 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); | 97 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); |
98 | 98 | ||
99 | makeMenu(); | ||
99 | 100 | ||
100 | Config cfg( "osearch", Config::User ); | 101 | Config cfg( "osearch", Config::User ); |
101 | cfg.setGroup( "search_settings" ); | 102 | cfg.setGroup( "search_settings" ); |
102 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); | 103 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); |
103 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); | 104 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); |
105 | // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); | ||
104 | } | 106 | } |
105 | 107 | ||
106 | void MainWindow::makeMenu() | 108 | void MainWindow::makeMenu() |
107 | { | 109 | { |
@@ -116,19 +118,33 @@ void MainWindow::makeMenu() | |||
116 | setToolBarsMovable( false ); | 118 | setToolBarsMovable( false ); |
117 | toolBar->setHorizontalStretchable( true ); | 119 | toolBar->setHorizontalStretchable( true ); |
118 | menuBar->insertItem( tr( "Search" ), searchMenu ); | 120 | menuBar->insertItem( tr( "Search" ), searchMenu ); |
119 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 121 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
122 | |||
123 | //SETTINGS MENU | ||
120 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); | 124 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); |
125 | QPopupMenu *pop; | ||
126 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | ||
127 | pop = s->popupMenu(); | ||
128 | if (pop){ | ||
129 | qDebug("inserting settings menu for %s",s->text(0).latin1()); | ||
130 | cfgMenu->insertItem( s->text(0), pop ); | ||
131 | //connect( pop, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) ); | ||
132 | } | ||
133 | } | ||
121 | 134 | ||
122 | 135 | ||
123 | //SEARCH | 136 | //SEARCH |
124 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); | 137 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); |
125 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); | 138 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); |
126 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); | 139 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); |
127 | SearchAllAction->addTo( searchMenu ); | 140 | SearchAllAction->addTo( searchMenu ); |
128 | searchMenu->insertItem( tr( "Options" ), searchOptions ); | 141 | searchMenu->insertItem( tr( "Options" ), searchOptions ); |
142 | //connect( searchOptions, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) ); | ||
129 | 143 | ||
130 | //SEARCH OPTIONS | 144 | //SEARCH OPTIONS |
145 | //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); | ||
146 | //actionWholeWordsOnly->addTo( searchOptions ); | ||
131 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); | 147 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); |
132 | actionCaseSensitiv->addTo( searchOptions ); | 148 | actionCaseSensitiv->addTo( searchOptions ); |
133 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); | 149 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); |
134 | actionWildcards->addTo( searchOptions ); | 150 | actionWildcards->addTo( searchOptions ); |
@@ -150,8 +166,9 @@ MainWindow::~MainWindow() | |||
150 | Config cfg( "osearch", Config::User ); | 166 | Config cfg( "osearch", Config::User ); |
151 | cfg.setGroup( "search_settings" ); | 167 | cfg.setGroup( "search_settings" ); |
152 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); | 168 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); |
153 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); | 169 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); |
170 | //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); | ||
154 | } | 171 | } |
155 | 172 | ||
156 | void MainWindow::setCurrent(QListViewItem *item) | 173 | void MainWindow::setCurrent(QListViewItem *item) |
157 | { | 174 | { |
@@ -181,16 +198,11 @@ void MainWindow::setCurrent(QListViewItem *item) | |||
181 | button = buttonGroupActions->find( i ); | 198 | button = buttonGroupActions->find( i ); |
182 | if (button) button->hide(); | 199 | if (button) button->hide(); |
183 | } | 200 | } |
184 | _buttonCount = acts.count(); | 201 | _buttonCount = acts.count(); |
185 | // buttonShow = new QPushButton( detailsFrame, "Show" ) ; | ||
186 | // buttonShow->setText( "test" ); | ||
187 | // buttonLayout->addWidget( buttonShow, 0 ); | ||
188 | // buttonGroupActions->insert(buttonShow); | ||
189 | detailsFrame->show(); | 202 | detailsFrame->show(); |
190 | }else detailsFrame->hide(); | 203 | }else detailsFrame->hide(); |
191 | //_currentItem = (OListViewItem*)item; | 204 | popupTimer->start( 300, true ); |
192 | popupTimer->start( 300 ); | ||
193 | } | 205 | } |
194 | 206 | ||
195 | void MainWindow::stopTimer(QListViewItem*) | 207 | void MainWindow::stopTimer(QListViewItem*) |
196 | { | 208 | { |
@@ -199,9 +211,12 @@ void MainWindow::stopTimer(QListViewItem*) | |||
199 | 211 | ||
200 | void MainWindow::showPopup() | 212 | void MainWindow::showPopup() |
201 | { | 213 | { |
202 | qDebug("showPopup"); | 214 | qDebug("showPopup"); |
215 | popupTimer->stop(); | ||
203 | if (!_currentItem) return; | 216 | if (!_currentItem) return; |
217 | QPopupMenu *pop = _currentItem->popupMenu(); | ||
218 | if (pop) pop->popup( QCursor::pos() ); | ||
204 | } | 219 | } |
205 | 220 | ||
206 | void MainWindow::setSearch( const QString &key ) | 221 | void MainWindow::setSearch( const QString &key ) |
207 | { | 222 | { |
@@ -212,9 +227,16 @@ void MainWindow::setSearch( const QString &key ) | |||
212 | 227 | ||
213 | void MainWindow::searchStringChanged() | 228 | void MainWindow::searchStringChanged() |
214 | { | 229 | { |
215 | searchTimer->stop(); | 230 | searchTimer->stop(); |
216 | QRegExp re( _searchString, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); | 231 | QString ss = _searchString; |
232 | //ss = Global::stringQuote( _searchString ); | ||
233 | //if (actionWholeWordsOnly->isOn()) | ||
234 | // ss = "\\s"+_searchString+"\\s"; | ||
235 | qDebug(" set searchString >%s<",ss.latin1()); | ||
236 | QRegExp re( ss ); | ||
237 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); | ||
238 | re.setWildcard( actionWildcards->isOn() ); | ||
217 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) | 239 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
218 | s->setSearch( re ); | 240 | s->setSearch( re ); |
219 | } | 241 | } |
220 | 242 | ||
@@ -225,13 +247,18 @@ void MainWindow::searchAll() | |||
225 | //resultsList->repaint(); | 247 | //resultsList->repaint(); |
226 | } | 248 | } |
227 | } | 249 | } |
228 | 250 | ||
229 | void MainWindow::slotAction( int act) | 251 | void MainWindow::slotAction( int act ) |
230 | { | 252 | { |
231 | if (_currentItem->rtti() == OListViewItem::Result){ | 253 | if (_currentItem->rtti() == OListViewItem::Result){ |
232 | ResultItem *res = (ResultItem*)_currentItem; | 254 | ResultItem *res = (ResultItem*)_currentItem; |
233 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 255 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
234 | res->action(act); | 256 | res->action(act); |
235 | } | 257 | } |
236 | } | 258 | } |
237 | 259 | ||
260 | void MainWindow::optionChanged(int i) | ||
261 | { | ||
262 | qDebug("optionChanged(%i)",i); | ||
263 | searchStringChanged(); | ||
264 | } | ||