-rw-r--r-- | korganizer/searchdialog.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 678e1bd..341a839 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -119,96 +119,101 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) | |||
119 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); | 119 | connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); |
120 | 120 | ||
121 | setCaption( i18n("KO/Pi Find: ")); | 121 | setCaption( i18n("KO/Pi Find: ")); |
122 | #ifdef DESKTOP_VERSION | 122 | #ifdef DESKTOP_VERSION |
123 | OkButton = new QPushButton( i18n("Close"), this ); | 123 | OkButton = new QPushButton( i18n("Close"), this ); |
124 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); | 124 | connect(OkButton,SIGNAL(clicked()),SLOT(hide())); |
125 | #endif | 125 | #endif |
126 | } | 126 | } |
127 | 127 | ||
128 | SearchDialog::~SearchDialog() | 128 | SearchDialog::~SearchDialog() |
129 | { | 129 | { |
130 | 130 | ||
131 | } | 131 | } |
132 | void SearchDialog::setFocusToList() | 132 | void SearchDialog::setFocusToList() |
133 | { | 133 | { |
134 | listView->resetFocus(); | 134 | listView->resetFocus(); |
135 | } | 135 | } |
136 | void SearchDialog::accept() | 136 | void SearchDialog::accept() |
137 | { | 137 | { |
138 | doSearch(); | 138 | doSearch(); |
139 | } | 139 | } |
140 | void SearchDialog::updateList() | 140 | void SearchDialog::updateList() |
141 | { | 141 | { |
142 | //listView->updateList(); | 142 | //listView->updateList(); |
143 | if ( isVisible() ) { | 143 | if ( isVisible() ) { |
144 | updateView(); | 144 | updateView(); |
145 | //qDebug("SearchDialog::updated "); | 145 | //qDebug("SearchDialog::updated "); |
146 | } | 146 | } |
147 | else { | 147 | else { |
148 | listView->clear(); | 148 | listView->clear(); |
149 | //qDebug("SearchDialog::cleared "); | 149 | //qDebug("SearchDialog::cleared "); |
150 | 150 | ||
151 | } | 151 | } |
152 | } | 152 | } |
153 | void SearchDialog::searchTextChanged( const QString &_text ) | 153 | void SearchDialog::searchTextChanged( const QString &_text ) |
154 | { | 154 | { |
155 | #if 0 | 155 | #if 0 |
156 | enableButton( KDialogBase::User1, !_text.isEmpty() ); | 156 | enableButton( KDialogBase::User1, !_text.isEmpty() ); |
157 | #endif | 157 | #endif |
158 | } | 158 | } |
159 | 159 | ||
160 | void SearchDialog::doSearch() | 160 | void SearchDialog::doSearch() |
161 | { | 161 | { |
162 | QRegExp re; | 162 | QRegExp re; |
163 | 163 | ||
164 | re.setWildcard(true); // most people understand these better. | 164 | re.setWildcard(true); // most people understand these better. |
165 | re.setCaseSensitive(false); | 165 | re.setCaseSensitive(false); |
166 | re.setPattern(searchEdit->text()); | 166 | re.setPattern(searchEdit->text()); |
167 | if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { | ||
168 | KMessageBox::sorry(this, | ||
169 | i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); | ||
170 | return; | ||
171 | } | ||
167 | if (!re.isValid() ) { | 172 | if (!re.isValid() ) { |
168 | KMessageBox::sorry(this, | 173 | KMessageBox::sorry(this, |
169 | i18n("Invalid search expression,\ncannot perform " | 174 | i18n("Invalid search expression,\ncannot perform " |
170 | "the search.\nPlease enter a search expression\n" | 175 | "the search.\nPlease enter a search expression\n" |
171 | "using the wildcard characters\n '*' and '?'" | 176 | "using the wildcard characters\n '*' and '?'" |
172 | "where needed.")); | 177 | "where needed.")); |
173 | return; | 178 | return; |
174 | } | 179 | } |
175 | 180 | ||
176 | search(re); | 181 | search(re); |
177 | 182 | ||
178 | listView->setStartDate( mStartDate->date() ); | 183 | listView->setStartDate( mStartDate->date() ); |
179 | listView->showEvents(mMatchedEvents); | 184 | listView->showEvents(mMatchedEvents); |
180 | listView->addTodos(mMatchedTodos); | 185 | listView->addTodos(mMatchedTodos); |
181 | listView->addJournals(mMatchedJournals); | 186 | listView->addJournals(mMatchedJournals); |
182 | 187 | ||
183 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { | 188 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { |
184 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); | 189 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); |
185 | } else { | 190 | } else { |
186 | QString mess; | 191 | QString mess; |
187 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); | 192 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); |
188 | setCaption( i18n("KO/Pi Find: ") + mess); | 193 | setCaption( i18n("KO/Pi Find: ") + mess); |
189 | 194 | ||
190 | } | 195 | } |
191 | searchEdit->setFocus(); | 196 | searchEdit->setFocus(); |
192 | } | 197 | } |
193 | void SearchDialog::updateConfig() | 198 | void SearchDialog::updateConfig() |
194 | { | 199 | { |
195 | listView->updateConfig(); | 200 | listView->updateConfig(); |
196 | } | 201 | } |
197 | void SearchDialog::updateView() | 202 | void SearchDialog::updateView() |
198 | { | 203 | { |
199 | 204 | ||
200 | QRegExp re; | 205 | QRegExp re; |
201 | re.setWildcard(true); // most people understand these better. | 206 | re.setWildcard(true); // most people understand these better. |
202 | re.setCaseSensitive(false); | 207 | re.setCaseSensitive(false); |
203 | re.setPattern(searchEdit->text()); | 208 | re.setPattern(searchEdit->text()); |
204 | if (re.isValid()) { | 209 | if (re.isValid()) { |
205 | search(re); | 210 | search(re); |
206 | } else { | 211 | } else { |
207 | mMatchedEvents.clear(); | 212 | mMatchedEvents.clear(); |
208 | mMatchedTodos.clear(); | 213 | mMatchedTodos.clear(); |
209 | mMatchedJournals.clear(); | 214 | mMatchedJournals.clear(); |
210 | } | 215 | } |
211 | listView->setStartDate( mStartDate->date() ); | 216 | listView->setStartDate( mStartDate->date() ); |
212 | listView->showEvents(mMatchedEvents); | 217 | listView->showEvents(mMatchedEvents); |
213 | listView->addTodos(mMatchedTodos); | 218 | listView->addTodos(mMatchedTodos); |
214 | listView->addJournals(mMatchedJournals); | 219 | listView->addJournals(mMatchedJournals); |