Diffstat (limited to 'core/pim/osearch/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index bfe95b0..8b6a5df 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -108,193 +108,193 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
108 | buttonBox->hide(); | 108 | buttonBox->hide(); |
109 | 109 | ||
110 | searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); | 110 | searches.append( new AppLnkSearch( resultsList, tr("Applications") ) ); |
111 | searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); | 111 | searches.append( new DocLnkSearch( resultsList, tr("Documents") ) ); |
112 | searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); | 112 | searches.append( new TodoSearch( resultsList, tr("Todo List") ) ); |
113 | searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); | 113 | searches.append( new DatebookSearch( resultsList, tr("Calendar") ) ); |
114 | searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); | 114 | searches.append( new AdressSearch( resultsList, tr("Contacts") ) ); |
115 | 115 | ||
116 | setCentralWidget( mainFrame ); | 116 | setCentralWidget( mainFrame ); |
117 | 117 | ||
118 | popupTimer = new QTimer(); | 118 | popupTimer = new QTimer(); |
119 | searchTimer = new QTimer(); | 119 | searchTimer = new QTimer(); |
120 | 120 | ||
121 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | 121 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); |
122 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); | 122 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); |
123 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | 123 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); |
124 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 124 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
125 | 125 | ||
126 | signalMapper = new QSignalMapper( this ); | 126 | signalMapper = new QSignalMapper( this ); |
127 | 127 | ||
128 | connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); | 128 | connect(signalMapper, SIGNAL(mapped(int)), SLOT( slotAction(int) ) ); |
129 | 129 | ||
130 | makeMenu(); | 130 | makeMenu(); |
131 | 131 | ||
132 | Config cfg( "osearch", Config::User ); | 132 | Config cfg( "osearch", Config::User ); |
133 | cfg.setGroup( "search_settings" ); | 133 | cfg.setGroup( "search_settings" ); |
134 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); | 134 | actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); |
135 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); | 135 | actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); |
136 | // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); | 136 | // actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void MainWindow::makeMenu() | 139 | void MainWindow::makeMenu() |
140 | { | 140 | { |
141 | QToolBar *toolBar = new QToolBar( this ); | 141 | QToolBar *toolBar = new QToolBar( this ); |
142 | QToolBar *searchBar = new QToolBar(this); | 142 | QToolBar *searchBar = new QToolBar(this); |
143 | QMenuBar *menuBar = new QMenuBar( toolBar ); | 143 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
144 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); | 144 | QPopupMenu *searchMenu = new QPopupMenu( menuBar ); |
145 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 145 | // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
146 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 146 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
147 | QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); | 147 | QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); |
148 | 148 | ||
149 | setToolBarsMovable( false ); | 149 | setToolBarsMovable( false ); |
150 | toolBar->setHorizontalStretchable( true ); | 150 | toolBar->setHorizontalStretchable( true ); |
151 | menuBar->insertItem( tr( "Search" ), searchMenu ); | 151 | menuBar->insertItem( tr( "Search" ), searchMenu ); |
152 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 152 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
153 | 153 | ||
154 | //SETTINGS MENU | 154 | //SETTINGS MENU |
155 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); | 155 | cfgMenu->insertItem( tr( "Search" ), searchOptions ); |
156 | QPopupMenu *pop; | 156 | QPopupMenu *pop; |
157 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 157 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
158 | pop = s->popupMenu(); | 158 | pop = s->popupMenu(); |
159 | if (pop){ | 159 | if (pop){ |
160 | cfgMenu->insertItem( s->text(0), pop ); | 160 | cfgMenu->insertItem( s->text(0), pop ); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | //SEARCH | 165 | //SEARCH |
166 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); | 166 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); |
167 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); | 167 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); |
168 | // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); | 168 | // QWhatsThis::add( SearchAllAction, tr("Search everything...") ); |
169 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); | 169 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); |
170 | SearchAllAction->addTo( searchMenu ); | 170 | SearchAllAction->addTo( searchMenu ); |
171 | searchMenu->insertItem( tr( "Options" ), searchOptions ); | 171 | searchMenu->insertItem( tr( "Options" ), searchOptions ); |
172 | 172 | ||
173 | //SEARCH OPTIONS | 173 | //SEARCH OPTIONS |
174 | //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); | 174 | //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); |
175 | //actionWholeWordsOnly->addTo( searchOptions ); | 175 | //actionWholeWordsOnly->addTo( searchOptions ); |
176 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); | 176 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); |
177 | actionCaseSensitiv->addTo( searchOptions ); | 177 | actionCaseSensitiv->addTo( searchOptions ); |
178 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); | 178 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); |
179 | actionWildcards->addTo( searchOptions ); | 179 | actionWildcards->addTo( searchOptions ); |
180 | 180 | ||
181 | //SEARCH BAR | 181 | //SEARCH BAR |
182 | LabelEnterText = new QLabel( searchBar, "Label" ); | 182 | LabelEnterText = new QLabel( searchBar, "Label" ); |
183 | LabelEnterText->setAutoMask( FALSE ); | 183 | LabelEnterText->setAutoMask( FALSE ); |
184 | LabelEnterText->setText( tr( "Search for: " ) ); | 184 | LabelEnterText->setText( tr( "Search for: " ) ); |
185 | 185 | ||
186 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 186 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
187 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 187 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
188 | QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); | 188 | QWhatsThis::add( searchEdit, tr("Enter your search terms here") ); |
189 | searchEdit->setFocus(); | 189 | searchEdit->setFocus(); |
190 | searchBar->setHorizontalStretchable( TRUE ); | 190 | searchBar->setHorizontalStretchable( TRUE ); |
191 | searchBar->setStretchableWidget( searchEdit ); | 191 | searchBar->setStretchableWidget( searchEdit ); |
192 | 192 | ||
193 | //Search button | 193 | //Search button |
194 | SearchAllAction->addTo( searchBar ); | 194 | SearchAllAction->addTo( searchBar ); |
195 | 195 | ||
196 | //image ripped of off opie-login/loginwindow.cpp | 196 | //image ripped of off opie-login/loginwindow.cpp |
197 | QPixmap image1( ( const char** ) image1_data ); | 197 | QPixmap image1( ( const char** ) image1_data ); |
198 | 198 | ||
199 | //Clear text | 199 | //Clear text |
200 | ClearSearchText = new QToolButton( searchBar, "ClearSearchText"); | 200 | ClearSearchText = new QToolButton( searchBar, "ClearSearchText"); |
201 | ClearSearchText->setText( tr( "" ) ); | 201 | ClearSearchText->setText( tr( "" ) ); |
202 | ClearSearchText->setPixmap( image1 ); | 202 | ClearSearchText->setPixmap( image1 ); |
203 | 203 | ||
204 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ),this, SLOT( setSearch( const QString & ) ) ); | 204 | connect( searchEdit, SIGNAL( textChanged(const QString&) ),this, SLOT( setSearch(const QString&) ) ); |
205 | connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) ); | 205 | connect( ClearSearchText, SIGNAL( clicked() ), searchEdit, SLOT( clear() ) ); |
206 | 206 | ||
207 | } | 207 | } |
208 | 208 | ||
209 | MainWindow::~MainWindow() | 209 | MainWindow::~MainWindow() |
210 | { | 210 | { |
211 | Config cfg( "osearch", Config::User ); | 211 | Config cfg( "osearch", Config::User ); |
212 | cfg.setGroup( "search_settings" ); | 212 | cfg.setGroup( "search_settings" ); |
213 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); | 213 | cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); |
214 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); | 214 | cfg.writeEntry( "wildcards", actionWildcards->isOn() ); |
215 | //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); | 215 | //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); |
216 | } | 216 | } |
217 | 217 | ||
218 | void MainWindow::setCurrent(QListViewItem *item) | 218 | void MainWindow::setCurrent(QListViewItem *item) |
219 | { | 219 | { |
220 | if (!item) return; | 220 | if (!item) return; |
221 | _currentItem = (OListViewItem*)item; | 221 | _currentItem = (OListViewItem*)item; |
222 | //_currentItem = dynamic_cast<OListViewItem*>(item); | 222 | //_currentItem = dynamic_cast<OListViewItem*>(item); |
223 | if (_currentItem->rtti() == OListViewItem::Result){ | 223 | if (_currentItem->rtti() == OListViewItem::Result){ |
224 | ResultItem *res = (ResultItem*)item; | 224 | ResultItem *res = (ResultItem*)item; |
225 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 225 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
226 | richEdit->setText( res->toRichText() ); | 226 | richEdit->setText( res->toRichText() ); |
227 | QIntDict<QString> acts = res->actions(); | 227 | QIntDict<QString> acts = res->actions(); |
228 | QButton *button; | 228 | QButton *button; |
229 | for (uint i = 0; i < acts.count(); i++){ | 229 | for (uint i = 0; i < acts.count(); i++){ |
230 | button = buttonMap[i]; | 230 | button = buttonMap[i]; |
231 | if (!button) { | 231 | if (!button) { |
232 | qWarning(" no button for %s", (*acts[i]).latin1() ); | 232 | qWarning(" no button for %s", (*acts[i]).latin1() ); |
233 | button = new QPushButton( buttonBox ); | 233 | button = new QPushButton( buttonBox ); |
234 | buttonMap.insert( i, button ); | 234 | buttonMap.insert( i, button ); |
235 | signalMapper->setMapping(button, i ); | 235 | signalMapper->setMapping(button, i ); |
236 | connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); | 236 | connect(button, SIGNAL(clicked() ), signalMapper, SLOT(map() ) ); |
237 | } | 237 | } |
238 | button->setText( *acts[i] ); | 238 | button->setText( *acts[i] ); |
239 | button->show(); | 239 | button->show(); |
240 | } | 240 | } |
241 | for (uint i = acts.count(); i < _buttonCount; i++){ | 241 | for (uint i = acts.count(); i < _buttonCount; i++){ |
242 | button = buttonMap[i]; | 242 | button = buttonMap[i]; |
243 | if (button) button->hide(); | 243 | if (button) button->hide(); |
244 | } | 244 | } |
245 | _buttonCount = acts.count(); | 245 | _buttonCount = acts.count(); |
246 | detailsFrame->show(); | 246 | detailsFrame->show(); |
247 | buttonBox->show(); | 247 | buttonBox->show(); |
248 | 248 | ||
249 | }else { | 249 | }else { |
250 | detailsFrame->hide(); | 250 | detailsFrame->hide(); |
251 | buttonBox->hide(); | 251 | buttonBox->hide(); |
252 | } | 252 | } |
253 | popupTimer->start( 300, true ); | 253 | popupTimer->start( 300, true ); |
254 | } | 254 | } |
255 | 255 | ||
256 | void MainWindow::stopTimer(QListViewItem*) | 256 | void MainWindow::stopTimer(QListViewItem*) |
257 | { | 257 | { |
258 | popupTimer->stop(); | 258 | popupTimer->stop(); |
259 | } | 259 | } |
260 | 260 | ||
261 | void MainWindow::showPopup() | 261 | void MainWindow::showPopup() |
262 | { | 262 | { |
263 | popupTimer->stop(); | 263 | popupTimer->stop(); |
264 | if (!_currentItem) return; | 264 | if (!_currentItem) return; |
265 | QPopupMenu *pop = _currentItem->popupMenu(); | 265 | QPopupMenu *pop = _currentItem->popupMenu(); |
266 | if (pop) pop->popup( QCursor::pos() ); | 266 | if (pop) pop->popup( QCursor::pos() ); |
267 | } | 267 | } |
268 | 268 | ||
269 | void MainWindow::setSearch( const QString &key ) | 269 | void MainWindow::setSearch( const QString &key ) |
270 | { | 270 | { |
271 | searchTimer->stop(); | 271 | searchTimer->stop(); |
272 | _searchString = key; | 272 | _searchString = key; |
273 | searchTimer->start( 300 ); | 273 | searchTimer->start( 300 ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void MainWindow::searchStringChanged() | 276 | void MainWindow::searchStringChanged() |
277 | { | 277 | { |
278 | #ifdef NEW_OWAIT | 278 | #ifdef NEW_OWAIT |
279 | OWait("setting search string"); | 279 | OWait("setting search string"); |
280 | #endif | 280 | #endif |
281 | searchTimer->stop(); | 281 | searchTimer->stop(); |
282 | QString ss = _searchString; | 282 | QString ss = _searchString; |
283 | //ss = Global::stringQuote( _searchString ); | 283 | //ss = Global::stringQuote( _searchString ); |
284 | //if (actionWholeWordsOnly->isOn()) | 284 | //if (actionWholeWordsOnly->isOn()) |
285 | // ss = "\\s"+_searchString+"\\s"; | 285 | // ss = "\\s"+_searchString+"\\s"; |
286 | //qDebug(" set searchString >%s<",ss.latin1()); | 286 | //qDebug(" set searchString >%s<",ss.latin1()); |
287 | QRegExp re( ss ); | 287 | QRegExp re( ss ); |
288 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); | 288 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); |
289 | re.setWildcard( actionWildcards->isOn() ); | 289 | re.setWildcard( actionWildcards->isOn() ); |
290 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) | 290 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
291 | s->setSearch( re ); | 291 | s->setSearch( re ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void MainWindow::searchAll() | 294 | void MainWindow::searchAll() |
295 | { | 295 | { |
296 | #ifdef NEW_OWAIT | 296 | #ifdef NEW_OWAIT |
297 | OWait("searching..."); | 297 | OWait("searching..."); |
298 | #endif | 298 | #endif |
299 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 299 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
300 | s->doSearch(); | 300 | s->doSearch(); |