summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 2390520..0e9f64c 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -224,151 +224,149 @@ void SearchDialog::raiseAndSelect()
224 if ( ! mSearchTodo->isChecked() ) { 224 if ( ! mSearchTodo->isChecked() ) {
225 mSearchTodo->setChecked( true ); 225 mSearchTodo->setChecked( true );
226 mSearchJournal->setChecked( false ); 226 mSearchJournal->setChecked( false );
227 mSearchEvent->setChecked( false ); 227 mSearchEvent->setChecked( false );
228 } 228 }
229 } 229 }
230 else { 230 else {
231 if ( ! mSearchEvent->isChecked() ) { 231 if ( ! mSearchEvent->isChecked() ) {
232 mSearchEvent->setChecked( true ); 232 mSearchEvent->setChecked( true );
233 mSearchJournal->setChecked( false ); 233 mSearchJournal->setChecked( false );
234 mSearchTodo->setChecked( false ); 234 mSearchTodo->setChecked( false );
235 } 235 }
236 } 236 }
237 } 237 }
238 currentState = newState; 238 currentState = newState;
239 raise(); 239 raise();
240} 240}
241void SearchDialog::setFocusToList() 241void SearchDialog::setFocusToList()
242{ 242{
243 listView->resetFocus(); 243 listView->resetFocus();
244} 244}
245void SearchDialog::accept() 245void SearchDialog::accept()
246{ 246{
247 doSearch(); 247 doSearch();
248} 248}
249void SearchDialog::updateList() 249void SearchDialog::updateList()
250{ 250{
251 //listView->updateList(); 251 //listView->updateList();
252 if ( isVisible() ) { 252 if ( isVisible() ) {
253 updateView(); 253 updateView();
254 //qDebug("SearchDialog::updated "); 254 //qDebug("SearchDialog::updated ");
255 } 255 }
256 else { 256 else {
257 listView->clear(); 257 listView->clear();
258 //qDebug("SearchDialog::cleared "); 258 //qDebug("SearchDialog::cleared ");
259 259
260 } 260 }
261} 261}
262void SearchDialog::searchTextChanged( const QString &_text ) 262void SearchDialog::searchTextChanged( const QString &_text )
263{ 263{
264#if 0 264#if 0
265 enableButton( KDialogBase::User1, !_text.isEmpty() ); 265 enableButton( KDialogBase::User1, !_text.isEmpty() );
266#endif 266#endif
267} 267}
268 268
269void SearchDialog::doSearch() 269void SearchDialog::doSearch()
270{ 270{
271 QRegExp re; 271 QRegExp re;
272
273 re.setWildcard(true); // most people understand these better. 272 re.setWildcard(true); // most people understand these better.
274 re.setCaseSensitive(false); 273 re.setCaseSensitive(false);
275 QString st = searchEdit->text(); 274 QString st = searchEdit->text();
276 if ( st.right(1) != "*") 275 if ( st.right(1) != "*")
277 st += "*"; 276 st += "*";
278 re.setPattern(st); 277 re.setPattern(st);
279 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 278 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
280 KMessageBox::sorry(this, 279 KMessageBox::sorry(this,
281 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 280 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
282 return; 281 return;
283 } 282 }
284 if (!re.isValid() ) { 283 if (!re.isValid() ) {
285 KMessageBox::sorry(this, 284 KMessageBox::sorry(this,
286 i18n("Invalid search expression,\ncannot perform " 285 i18n("Invalid search expression,\ncannot perform "
287 "the search.\nPlease enter a search expression\n" 286 "the search.\nPlease enter a search expression\n"
288 "using the wildcard characters\n '*' and '?'" 287 "using the wildcard characters\n '*' and '?'"
289 "where needed.")); 288 "where needed."));
290 return; 289 return;
291 } 290 }
292 search(re); 291 search(re);
293 listView->setStartDate( mStartDate->date() ); 292 listView->setStartDate( mStartDate->date() );
294 listView->showEvents(mMatchedEvents); 293 listView->showEvents(mMatchedEvents);
295 listView->addTodos(mMatchedTodos); 294 listView->addTodos(mMatchedTodos);
296 listView->addJournals(mMatchedJournals); 295 listView->addJournals(mMatchedJournals);
297 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 296 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
298 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 297 setCaption(i18n("No items found. Use '*' and '?' where needed."));
299 } else { 298 } else {
300 QString mess; 299 QString mess;
301 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 300 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
302 setCaption( i18n("KO/Pi Find: ") + mess); 301 setCaption( i18n("KO/Pi Find: ") + mess);
303 302
304 } 303 }
305 searchEdit->setFocus(); 304 searchEdit->setFocus();
306} 305}
307void SearchDialog::updateConfig() 306void SearchDialog::updateConfig()
308{ 307{
309 listView->updateConfig(); 308 listView->updateConfig();
310} 309}
311void SearchDialog::updateView() 310void SearchDialog::updateView()
312{ 311{
313 //qDebug("SearchDialog::updateView() %d ", isVisible()); 312 //qDebug("SearchDialog::updateView() %d ", isVisible());
314 QRegExp re; 313 QRegExp re;
315 re.setWildcard(true); // most people understand these better. 314 re.setWildcard(true); // most people understand these better.
316 re.setCaseSensitive(false); 315 re.setCaseSensitive(false);
317 QString st = searchEdit->text(); 316 QString st = searchEdit->text();
318 if ( st.right(1) != "*") 317 if ( st.right(1) != "*")
319 st += "*"; 318 st += "*";
320 re.setPattern(st); 319 re.setPattern(st);
320 mMatchedEvents.clear();
321 mMatchedTodos.clear();
322 mMatchedJournals.clear();
321 if (re.isValid()) { 323 if (re.isValid()) {
322 search(re); 324 search(re);
323 } else {
324 mMatchedEvents.clear();
325 mMatchedTodos.clear();
326 mMatchedJournals.clear();
327 } 325 }
328 listView->setStartDate( mStartDate->date() ); 326 listView->setStartDate( mStartDate->date() );
329 listView->showEvents(mMatchedEvents); 327 listView->showEvents(mMatchedEvents);
330 listView->addTodos(mMatchedTodos); 328 listView->addTodos(mMatchedTodos);
331 listView->addJournals(mMatchedJournals); 329 listView->addJournals(mMatchedJournals);
332} 330}
333 331
334void SearchDialog::search(const QRegExp &re) 332void SearchDialog::search(const QRegExp &re)
335{ 333{
336 QPtrList<Event> events; 334 QPtrList<Event> events;
337 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 335 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
338 if ( mRefineItems->isChecked() ) events = mMatchedEvents; 336 if ( mRefineItems->isChecked() ) events = mMatchedEvents;
339 mMatchedEvents.clear(); 337 mMatchedEvents.clear();
340 } 338 }
341 if ( mSearchEvent->isChecked() ) { 339 if ( mSearchEvent->isChecked() ) {
342 if ( !mRefineItems->isChecked() ) 340 if ( !mRefineItems->isChecked() )
343 events = mCalendar->events( mStartDate->date(), 341 events = mCalendar->events( mStartDate->date(),
344 mEndDate->date(), 342 mEndDate->date(),
345 false /*mInclusiveCheck->isChecked()*/ ); 343 false /*mInclusiveCheck->isChecked()*/ );
346 344
347 345
348 Event *ev; 346 Event *ev;
349 for(ev=events.first();ev;ev=events.next()) { 347 for(ev=events.first();ev;ev=events.next()) {
350 if (mSummaryCheck->isChecked()) { 348 if (mSummaryCheck->isChecked()) {
351#if QT_VERSION >= 0x030000 349#if QT_VERSION >= 0x030000
352 if (re.search(ev->summary()) != -1) 350 if (re.search(ev->summary()) != -1)
353#else 351#else
354 if (re.match(ev->summary()) != -1) 352 if (re.match(ev->summary()) != -1)
355#endif 353#endif
356 { 354 {
357 if ( mSubItems->isChecked() ) 355 if ( mSubItems->isChecked() )
358 mMatchedEvents.remove(ev); 356 mMatchedEvents.remove(ev);
359 else { 357 else {
360 if ( !mMatchedEvents.contains( ev ) ) 358 if ( !mMatchedEvents.contains( ev ) )
361 mMatchedEvents.append(ev); 359 mMatchedEvents.append(ev);
362 } 360 }
363 continue; 361 continue;
364 } 362 }
365#if QT_VERSION >= 0x030000 363#if QT_VERSION >= 0x030000
366 if (re.search(ev->location()) != -1) 364 if (re.search(ev->location()) != -1)
367#else 365#else
368 if (re.match(ev->location()) != -1) 366 if (re.match(ev->location()) != -1)
369#endif 367#endif
370 { 368 {
371 if ( mSubItems->isChecked() ) 369 if ( mSubItems->isChecked() )
372 mMatchedEvents.remove(ev); 370 mMatchedEvents.remove(ev);
373 else{ 371 else{
374 if ( !mMatchedEvents.contains( ev ) ) 372 if ( !mMatchedEvents.contains( ev ) )