summaryrefslogtreecommitdiffabout
path: root/korganizer/searchdialog.cpp
Unidiff
Diffstat (limited to 'korganizer/searchdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index db60383..7a945e3 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -161,139 +161,145 @@ void SearchDialog::raiseAndSelect()
161 mSearchEvent->setChecked( false ); 161 mSearchEvent->setChecked( false );
162 } 162 }
163 } 163 }
164 else { 164 else {
165 if ( ! mSearchEvent->isChecked() ) { 165 if ( ! mSearchEvent->isChecked() ) {
166 mSearchEvent->setChecked( true ); 166 mSearchEvent->setChecked( true );
167 mSearchJournal->setChecked( false ); 167 mSearchJournal->setChecked( false );
168 mSearchTodo->setChecked( false ); 168 mSearchTodo->setChecked( false );
169 } 169 }
170 } 170 }
171 } 171 }
172 currentState = newState; 172 currentState = newState;
173 raise(); 173 raise();
174} 174}
175void SearchDialog::setFocusToList() 175void SearchDialog::setFocusToList()
176{ 176{
177 listView->resetFocus(); 177 listView->resetFocus();
178} 178}
179void SearchDialog::accept() 179void SearchDialog::accept()
180{ 180{
181 doSearch(); 181 doSearch();
182} 182}
183void SearchDialog::updateList() 183void SearchDialog::updateList()
184{ 184{
185 //listView->updateList(); 185 //listView->updateList();
186 if ( isVisible() ) { 186 if ( isVisible() ) {
187 updateView(); 187 updateView();
188 //qDebug("SearchDialog::updated "); 188 //qDebug("SearchDialog::updated ");
189 } 189 }
190 else { 190 else {
191 listView->clear(); 191 listView->clear();
192 //qDebug("SearchDialog::cleared "); 192 //qDebug("SearchDialog::cleared ");
193 193
194 } 194 }
195} 195}
196void SearchDialog::searchTextChanged( const QString &_text ) 196void SearchDialog::searchTextChanged( const QString &_text )
197{ 197{
198#if 0 198#if 0
199 enableButton( KDialogBase::User1, !_text.isEmpty() ); 199 enableButton( KDialogBase::User1, !_text.isEmpty() );
200#endif 200#endif
201} 201}
202 202
203void SearchDialog::doSearch() 203void SearchDialog::doSearch()
204{ 204{
205 QRegExp re; 205 QRegExp re;
206 206
207 re.setWildcard(true); // most people understand these better. 207 re.setWildcard(true); // most people understand these better.
208 re.setCaseSensitive(false); 208 re.setCaseSensitive(false);
209 re.setPattern(searchEdit->text()); 209 QString st = searchEdit->text();
210 if ( st.right(1) != "*")
211 st += "*";
212 re.setPattern(st);
210 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 213 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
211 KMessageBox::sorry(this, 214 KMessageBox::sorry(this,
212 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 215 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
213 return; 216 return;
214 } 217 }
215 if (!re.isValid() ) { 218 if (!re.isValid() ) {
216 KMessageBox::sorry(this, 219 KMessageBox::sorry(this,
217 i18n("Invalid search expression,\ncannot perform " 220 i18n("Invalid search expression,\ncannot perform "
218 "the search.\nPlease enter a search expression\n" 221 "the search.\nPlease enter a search expression\n"
219 "using the wildcard characters\n '*' and '?'" 222 "using the wildcard characters\n '*' and '?'"
220 "where needed.")); 223 "where needed."));
221 return; 224 return;
222 } 225 }
223 226
224 search(re); 227 search(re);
225 228
226 listView->setStartDate( mStartDate->date() ); 229 listView->setStartDate( mStartDate->date() );
227 listView->showEvents(mMatchedEvents); 230 listView->showEvents(mMatchedEvents);
228 listView->addTodos(mMatchedTodos); 231 listView->addTodos(mMatchedTodos);
229 listView->addJournals(mMatchedJournals); 232 listView->addJournals(mMatchedJournals);
230 233
231 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 234 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
232 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 235 setCaption(i18n("No items found. Use '*' and '?' where needed."));
233 } else { 236 } else {
234 QString mess; 237 QString mess;
235 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 238 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
236 setCaption( i18n("KO/Pi Find: ") + mess); 239 setCaption( i18n("KO/Pi Find: ") + mess);
237 240
238 } 241 }
239 searchEdit->setFocus(); 242 searchEdit->setFocus();
240} 243}
241void SearchDialog::updateConfig() 244void SearchDialog::updateConfig()
242{ 245{
243 listView->updateConfig(); 246 listView->updateConfig();
244} 247}
245void SearchDialog::updateView() 248void SearchDialog::updateView()
246{ 249{
247 //qDebug("SearchDialog::updateView() %d ", isVisible()); 250 //qDebug("SearchDialog::updateView() %d ", isVisible());
248 QRegExp re; 251 QRegExp re;
249 re.setWildcard(true); // most people understand these better. 252 re.setWildcard(true); // most people understand these better.
250 re.setCaseSensitive(false); 253 re.setCaseSensitive(false);
251 re.setPattern(searchEdit->text()); 254 QString st = searchEdit->text();
255 if ( st.right(1) != "*")
256 st += "*";
257 re.setPattern(st);
252 if (re.isValid()) { 258 if (re.isValid()) {
253 search(re); 259 search(re);
254 } else { 260 } else {
255 mMatchedEvents.clear(); 261 mMatchedEvents.clear();
256 mMatchedTodos.clear(); 262 mMatchedTodos.clear();
257 mMatchedJournals.clear(); 263 mMatchedJournals.clear();
258 } 264 }
259 listView->setStartDate( mStartDate->date() ); 265 listView->setStartDate( mStartDate->date() );
260 listView->showEvents(mMatchedEvents); 266 listView->showEvents(mMatchedEvents);
261 listView->addTodos(mMatchedTodos); 267 listView->addTodos(mMatchedTodos);
262 listView->addJournals(mMatchedJournals); 268 listView->addJournals(mMatchedJournals);
263} 269}
264 270
265void SearchDialog::search(const QRegExp &re) 271void SearchDialog::search(const QRegExp &re)
266{ 272{
267 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 273 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
268 mEndDate->date(), 274 mEndDate->date(),
269 false /*mInclusiveCheck->isChecked()*/ ); 275 false /*mInclusiveCheck->isChecked()*/ );
270 276
271 mMatchedEvents.clear(); 277 mMatchedEvents.clear();
272 if ( mSearchEvent->isChecked() ) { 278 if ( mSearchEvent->isChecked() ) {
273 Event *ev; 279 Event *ev;
274 for(ev=events.first();ev;ev=events.next()) { 280 for(ev=events.first();ev;ev=events.next()) {
275 if (mSummaryCheck->isChecked()) { 281 if (mSummaryCheck->isChecked()) {
276#if QT_VERSION >= 0x030000 282#if QT_VERSION >= 0x030000
277 if (re.search(ev->summary()) != -1) 283 if (re.search(ev->summary()) != -1)
278#else 284#else
279 if (re.match(ev->summary()) != -1) 285 if (re.match(ev->summary()) != -1)
280#endif 286#endif
281 { 287 {
282 mMatchedEvents.append(ev); 288 mMatchedEvents.append(ev);
283 continue; 289 continue;
284 } 290 }
285#if QT_VERSION >= 0x030000 291#if QT_VERSION >= 0x030000
286 if (re.search(ev->location()) != -1) 292 if (re.search(ev->location()) != -1)
287#else 293#else
288 if (re.match(ev->location()) != -1) 294 if (re.match(ev->location()) != -1)
289#endif 295#endif
290 { 296 {
291 mMatchedEvents.append(ev); 297 mMatchedEvents.append(ev);
292 continue; 298 continue;
293 } 299 }
294 } 300 }
295 if (mDescriptionCheck->isChecked()) { 301 if (mDescriptionCheck->isChecked()) {
296#if QT_VERSION >= 0x030000 302#if QT_VERSION >= 0x030000
297 if (re.search(ev->description()) != -1) 303 if (re.search(ev->description()) != -1)
298#else 304#else
299 if (re.match(ev->description()) != -1) 305 if (re.match(ev->description()) != -1)