summaryrefslogtreecommitdiffabout
path: root/korganizer/searchdialog.cpp
Unidiff
Diffstat (limited to 'korganizer/searchdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index db60383..7a945e3 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -185,91 +185,97 @@ void SearchDialog::updateList()
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()) {