-rw-r--r-- | core/pim/osearch/applnksearch.cpp | 5 | ||||
-rw-r--r-- | core/pim/osearch/contactitem.cpp | 4 | ||||
-rw-r--r-- | core/pim/osearch/datebooksearch.cpp | 53 | ||||
-rw-r--r-- | core/pim/osearch/datebooksearch.h | 8 | ||||
-rw-r--r-- | core/pim/osearch/doclnksearch.cpp | 1 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 43 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.h | 2 | ||||
-rw-r--r-- | core/pim/osearch/olistviewitem.cpp | 11 | ||||
-rw-r--r-- | core/pim/osearch/olistviewitem.h | 3 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.cpp | 50 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.h | 9 | ||||
-rw-r--r-- | core/pim/osearch/todosearch.cpp | 37 | ||||
-rw-r--r-- | core/pim/osearch/todosearch.h | 6 |
13 files changed, 174 insertions, 58 deletions
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp index d5b181b..5fa36bb 100644 --- a/core/pim/osearch/applnksearch.cpp +++ b/core/pim/osearch/applnksearch.cpp @@ -20,49 +20,48 @@ #include "applnkitem.h" AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, name) { _apps = 0; QIconSet is = Resource::loadIconSet( "osearch/applications" ); //QIconSet is = Resource::loadIconSet( "AppsIcon" ); setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); } AppLnkSearch::~AppLnkSearch() { delete _apps; } void AppLnkSearch::load() { _apps = new AppLnkSet(QPEApplication::qpeDir()); } int AppLnkSearch::search() { - int count = 0; QList<AppLnk> appList = _apps->children(); for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ if ( (_search.match( app->name() ) != -1) || (_search.match(app->comment()) != -1) || (_search.match(app->exec()) != -1) ) { - count++; insertItem( app ); } qApp->processEvents( 100 ); } - return count; + return _resultCount; } void AppLnkSearch::insertItem( void *rec ) { new AppLnkItem( this, (AppLnk*)rec ); + _resultCount++; } void AppLnkSearch::setSearch(QRegExp re) { setOpen( false ); SearchGroup::setSearch( re ); } diff --git a/core/pim/osearch/contactitem.cpp b/core/pim/osearch/contactitem.cpp index 1d24b18..ad43ba2 100644 --- a/core/pim/osearch/contactitem.cpp +++ b/core/pim/osearch/contactitem.cpp @@ -49,56 +49,56 @@ void ContactItem::setIcon() break; case Qtopia::HomePhone: icon = Resource::loadPixmap( "addressbook/phonehome" ); break; case Qtopia::HomeFax: icon = Resource::loadPixmap( "addressbook/faxhome" ); break; case Qtopia::HomeMobile: icon = Resource::loadPixmap( "addressbook/mobilehome" ); break; case Qtopia::HomeWebPage: icon = Resource::loadPixmap( "addressbook/webpagehome" ); break; case Qtopia::BusinessWebPage: icon = Resource::loadPixmap( "addressbook/webpagework" ); break; case Qtopia::Title: case Qtopia::JobTitle: case Qtopia::FirstName: case Qtopia::MiddleName: case Qtopia::LastName: case Qtopia::Suffix: case Qtopia::Nickname: case Qtopia::FileAs: - icon = Resource::loadPixmap( "addressbook/identity" ); + icon = Resource::loadPixmap( "osearch/identity" ); break; case Qtopia::HomeStreet: case Qtopia::HomeCity: case Qtopia::HomeState: case Qtopia::HomeZip: case Qtopia::HomeCountry: - icon = Resource::loadPixmap( "addressbook/addresshome" ); + icon = Resource::loadPixmap( "osearch/addresshome" ); break; case Qtopia::Company: case Qtopia::BusinessCity: case Qtopia::BusinessStreet: case Qtopia::BusinessZip: case Qtopia::BusinessCountry: case Qtopia::Department: case Qtopia::Office: case Qtopia::Manager: case Qtopia::BusinessPager: case Qtopia::Profession: icon = Resource::loadPixmap( "addressbook/addresshome" ); break; case Qtopia::Assistant: case Qtopia::Spouse: case Qtopia::Children: icon = Resource::loadPixmap( "osearch/personal" ); break; case Qtopia::Birthday: case Qtopia::Anniversary: icon = Resource::loadPixmap( "osearch/clock" ); break; case Qtopia::Notes: icon = Resource::loadPixmap( "txt" ); diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp index 7aabcea..5da7ae9 100644 --- a/core/pim/osearch/datebooksearch.cpp +++ b/core/pim/osearch/datebooksearch.cpp @@ -1,55 +1,92 @@ // // // C++ Implementation: $MODULE$ // // Description: // // // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 // // Copyright: See COPYING file that comes with this distribution // // #include "datebooksearch.h" #include "eventitem.h" +#include <qpe/resource.h> +#include <qpe/config.h> #include <opie/oevent.h> +#include <opie/orecur.h> #include <opie/odatebookaccess.h> #include <qiconset.h> -#include <qpe/resource.h> +#include <qaction.h> +#include <qdatetime.h> +#include <qpopupmenu.h> DatebookSearch::DatebookSearch(QListView* parent, QString name) -: SearchGroup(parent, name) +: SearchGroup(parent, name), _dates(0), _popupMenu(0) { - _dates = 0; QIconSet is = Resource::loadIconSet( "datebook/DateBook" ); setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); - + actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true ); + actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true ); + Config cfg( "osearch", Config::User ); + cfg.setGroup( "datebook_settings" ); + actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) ); + actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) ); } - DatebookSearch::~DatebookSearch() { + qDebug("SAVE DATEBOOK SEARCH CONFIG"); + Config cfg( "osearch", Config::User ); + cfg.setGroup( "datebook_settings" ); + cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() ); + cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() ); delete _dates; + delete _popupMenu; + delete actionShowPastEvents; + delete actionSearchInDates; } void DatebookSearch::load() { _dates = new ODateBookAccess(); _dates->load(); } int DatebookSearch::search() { ORecordList<OEvent> results = _dates->matchRegexp(_search); for (uint i = 0; i < results.count(); i++) - new EventItem( this, new OEvent( results[i] )); - return results.count(); + insertItem( new OEvent( results[i] ) ); + return _resultCount; } -void DatebookSearch::insertItem( void* ) +void DatebookSearch::insertItem( void *rec ) { + OEvent *ev = (OEvent*)rec; + if ( !actionShowPastEvents->isOn() && + ev->endDateTime() < QDateTime::currentDateTime() && + !ev->recurrence().doesRecur() + ) return; + if ( !actionSearchInDates->isOn() && ( + ev->lastHitField() == Qtopia::StartDateTime || + ev->lastHitField() == Qtopia::EndDateTime ) + ) return; + new EventItem( this, ev ); + _resultCount++; +} +QPopupMenu* DatebookSearch::popupMenu() +{ + if (!_popupMenu){ + _popupMenu = new QPopupMenu( 0 ); + actionShowPastEvents->addTo( _popupMenu ); + actionSearchInDates->addTo( _popupMenu ); } + return _popupMenu; +} + diff --git a/core/pim/osearch/datebooksearch.h b/core/pim/osearch/datebooksearch.h index bb31462..a6d115e 100644 --- a/core/pim/osearch/datebooksearch.h +++ b/core/pim/osearch/datebooksearch.h @@ -1,40 +1,44 @@ // // // C++ Interface: $MODULE$ // // Description: // // // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 // // Copyright: See COPYING file that comes with this distribution // // #ifndef DATEBOOKSEARCH_H #define DATEBOOKSEARCH_H #include "searchgroup.h" class ODateBookAccess; +class QAction; /** @author Patrick S. Vogt */ class DatebookSearch : public SearchGroup { public: DatebookSearch(QListView* parent, QString name); - ~DatebookSearch(); + virtual QPopupMenu* popupMenu(); + protected: virtual void load(); virtual int search(); virtual void insertItem( void* ); private: ODateBookAccess *_dates; - + QAction *actionShowPastEvents; + QAction *actionSearchInDates; + QPopupMenu *_popupMenu; }; #endif diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp index 123eaa0..d97eeb8 100644 --- a/core/pim/osearch/doclnksearch.cpp +++ b/core/pim/osearch/doclnksearch.cpp @@ -18,25 +18,26 @@ #include <qpe/resource.h> #include "doclnkitem.h" DocLnkSearch::DocLnkSearch(QListView* parent, QString name) : AppLnkSearch(parent, name) { QIconSet is = Resource::loadIconSet( "osearch/documents" ); setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); } DocLnkSearch::~DocLnkSearch() { } void DocLnkSearch::load() { _apps = new DocLnkSet(QPEApplication::documentDir()); } void DocLnkSearch::insertItem( void *rec ) { new DocLnkItem( this, (DocLnk*)rec ); + _resultCount++; } diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index b80c637..89ab690 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp @@ -1,45 +1,46 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "mainwindow.h" #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> +#include <qpe/global.h> #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> #include <qhbuttongroup.h> #include <qpushbutton.h> #include <qintdict.h> #include <qlayout.h> #include <qlineedit.h> #include <qtextbrowser.h> #include <qregexp.h> #include "olistview.h" #include "olistviewitem.h" #include "resultitem.h" #include "adresssearch.h" #include "todosearch.h" #include "datebooksearch.h" #include "applnksearch.h" #include "doclnksearch.h" @@ -63,175 +64,201 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : detailsFrame = new QFrame( mainFrame, "detailsFrame" ); QVBoxLayout *detailsLayout = new QVBoxLayout( detailsFrame ); richEdit = new QTextView( detailsFrame ); richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding)); //richEdit->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum )); detailsLayout->addWidget( richEdit, 1 ); buttonGroupActions = new QHButtonGroup( this ); buttonGroupActions->hide(); _buttonCount = 0; // buttonGroupActions->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); buttonLayout = new QHBoxLayout( detailsFrame ); detailsLayout->addLayout( buttonLayout ); mainLayout->addWidget( detailsFrame ); detailsFrame->hide(); searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); searches.append( new TodoSearch( resultsList, tr("todo") ) ); searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); - makeMenu(); setCentralWidget( mainFrame ); popupTimer = new QTimer(); searchTimer = new QTimer(); connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); + makeMenu(); Config cfg( "osearch", Config::User ); cfg.setGroup( "search_settings" ); actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); +// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) ); } void MainWindow::makeMenu() { QPEToolBar *toolBar = new QPEToolBar( this ); QPEToolBar *searchBar = new QPEToolBar(this); QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *searchMenu = new QPopupMenu( menuBar ); // QPopupMenu *viewMenu = new QPopupMenu( menuBar ); QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); menuBar->insertItem( tr( "Search" ), searchMenu ); menuBar->insertItem( tr( "Settings" ), cfgMenu ); + + //SETTINGS MENU cfgMenu->insertItem( tr( "Search" ), searchOptions ); + QPopupMenu *pop; + for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ + pop = s->popupMenu(); + if (pop){ + qDebug("inserting settings menu for %s",s->text(0).latin1()); + cfgMenu->insertItem( s->text(0), pop ); + //connect( pop, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) ); + } + } //SEARCH SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); SearchAllAction->addTo( searchMenu ); searchMenu->insertItem( tr( "Options" ), searchOptions ); + //connect( searchOptions, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) ); //SEARCH OPTIONS + //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true ); + //actionWholeWordsOnly->addTo( searchOptions ); actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); actionCaseSensitiv->addTo( searchOptions ); actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); actionWildcards->addTo( searchOptions ); //SEARCH BAR addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); searchEdit->setFocus(); searchBar->setHorizontalStretchable( TRUE ); searchBar->setStretchableWidget( searchEdit ); SearchAllAction->addTo( searchBar ); connect( searchEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( setSearch( const QString & ) ) ); } MainWindow::~MainWindow() { Config cfg( "osearch", Config::User ); cfg.setGroup( "search_settings" ); cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); cfg.writeEntry( "wildcards", actionWildcards->isOn() ); + //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() ); } void MainWindow::setCurrent(QListViewItem *item) { if (!item) return; _currentItem = (OListViewItem*)item; // _currentItem = dynamic_cast<OListViewItem*>(item); if (_currentItem->rtti() == OListViewItem::Result){ ResultItem *res = (ResultItem*)item; // ResultItem *res = dynamic_cast<ResultItem*>(item); richEdit->setText( res->toRichText() ); QIntDict<QString> acts = res->actions(); QButton *button; for (uint i = 0; i < acts.count(); i++){ button = buttonGroupActions->find( i ); qDebug("action %i >%s<",i,acts[i]->latin1()); if (!button) { qDebug("BUTTON"); button = new QPushButton( detailsFrame ); buttonLayout->addWidget( button, 0 ); buttonGroupActions->insert( button, i); } button->setText( *acts[i] ); button->show(); } for (uint i = acts.count(); i < _buttonCount; i++){ qDebug("remove button %i of %i",i, _buttonCount); button = buttonGroupActions->find( i ); if (button) button->hide(); } _buttonCount = acts.count(); -// buttonShow = new QPushButton( detailsFrame, "Show" ) ; -// buttonShow->setText( "test" ); -// buttonLayout->addWidget( buttonShow, 0 ); -// buttonGroupActions->insert(buttonShow); detailsFrame->show(); }else detailsFrame->hide(); - //_currentItem = (OListViewItem*)item; - popupTimer->start( 300 ); + popupTimer->start( 300, true ); } void MainWindow::stopTimer(QListViewItem*) { popupTimer->stop(); } void MainWindow::showPopup() { qDebug("showPopup"); + popupTimer->stop(); if (!_currentItem) return; + QPopupMenu *pop = _currentItem->popupMenu(); + if (pop) pop->popup( QCursor::pos() ); } void MainWindow::setSearch( const QString &key ) { searchTimer->stop(); _searchString = key; searchTimer->start( 300 ); } void MainWindow::searchStringChanged() { searchTimer->stop(); - QRegExp re( _searchString, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); + QString ss = _searchString; + //ss = Global::stringQuote( _searchString ); +// if (actionWholeWordsOnly->isOn()) +// ss = "\\s"+_searchString+"\\s"; + qDebug(" set searchString >%s<",ss.latin1()); + QRegExp re( ss ); + re.setCaseSensitive( actionCaseSensitiv->isOn() ); + re.setWildcard( actionWildcards->isOn() ); for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) s->setSearch( re ); } void MainWindow::searchAll() { for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ s->doSearch(); //resultsList->repaint(); } } void MainWindow::slotAction( int act) { if (_currentItem->rtti() == OListViewItem::Result){ ResultItem *res = (ResultItem*)_currentItem; // ResultItem *res = dynamic_cast<ResultItem*>(item); res->action(act); } } +void MainWindow::optionChanged(int i) +{ + qDebug("optionChanged(%i)",i); + searchStringChanged(); +} diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h index 939762e..cba11c5 100644 --- a/core/pim/osearch/mainwindow.h +++ b/core/pim/osearch/mainwindow.h @@ -30,47 +30,49 @@ class OListViewItem; class QHButtonGroup; class SearchGroup; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~MainWindow(); public slots: void setCurrent(QListViewItem*); void setSearch( const QString& ); void searchAll(); protected slots: void slotAction(int); void showPopup(); void stopTimer( QListViewItem* ); void searchStringChanged(); + void optionChanged(int); private: OListView *resultsList; QTextView *richEdit; OListViewItem *_currentItem; QVBoxLayout *mainLayout; QHBoxLayout *buttonLayout; QFrame *detailsFrame; QTimer *popupTimer; QTimer *searchTimer; QString _searchString; QList<SearchGroup> searches; QHButtonGroup *buttonGroupActions; QAction *SearchAllAction; QAction *actionCaseSensitiv; QAction *actionWildcards; + //QAction *actionWholeWordsOnly; uint _buttonCount; void makeMenu(); }; #endif diff --git a/core/pim/osearch/olistviewitem.cpp b/core/pim/osearch/olistviewitem.cpp index 29c5942..2d67559 100644 --- a/core/pim/osearch/olistviewitem.cpp +++ b/core/pim/osearch/olistviewitem.cpp @@ -7,24 +7,35 @@ * * ***************************************************************************/ #include "olistviewitem.h" OListViewItem::OListViewItem(OListViewItem *parent) : QListViewItem(parent) { } OListViewItem::OListViewItem(OListViewItem *parent, QString name) : QListViewItem(parent,name) { } OListViewItem::OListViewItem(QListView *parent, QString name) : QListViewItem(parent, name) { } OListViewItem::~OListViewItem() { } +void OListViewItem::clearList() +{ + QListViewItem *item = firstChild(); + QListViewItem *toDel; + while ( item != 0 ) { + toDel = item; + item = item->nextSibling(); + delete toDel; + } +} + diff --git a/core/pim/osearch/olistviewitem.h b/core/pim/osearch/olistviewitem.h index 66471f1..9e072a1 100644 --- a/core/pim/osearch/olistviewitem.h +++ b/core/pim/osearch/olistviewitem.h @@ -3,27 +3,30 @@ * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef LISTVIEWITEMCONF_H #define LISTVIEWITEMCONF_H #include <qlistview.h> class OListViewItem : public QListViewItem { public: enum {Raw, Searchgroup, Result, Contact, Todo, Event}; OListViewItem(OListViewItem *parent); OListViewItem(OListViewItem *parent, QString name); OListViewItem(QListView *parent, QString name); ~OListViewItem(); virtual void expand(){}; virtual int rtti() { return Raw;} + virtual QPopupMenu* popupMenu() { return 0;}; + void clearList(); + }; #endif diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp index 490deea..e307696 100644 --- a/core/pim/osearch/searchgroup.cpp +++ b/core/pim/osearch/searchgroup.cpp @@ -1,87 +1,93 @@ // // // C++ Implementation: $MODULE$ // // Description: // // // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 // // Copyright: See COPYING file that comes with this distribution // // #include "searchgroup.h" #include <qregexp.h> -// #include <qapplication.h> -// #include <opie/owait.h> +#include <qapplication.h> +#include <opie/owait.h> #include "olistviewitem.h" +//#define NEW_OWAIT +#ifndef NEW_OWAIT +static OWait *wait = 0; +#endif + SearchGroup::SearchGroup(QListView* parent, QString name) : OListViewItem(parent, name) { _name = name; loaded = false; } SearchGroup::~SearchGroup() { } void SearchGroup::expand() { //expanded = true; clearList(); if (_search.isEmpty()) return; OListViewItem *dummy = new OListViewItem( this, "searching..."); setOpen( true ); repaint(); int res_count = realSearch(); setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); delete dummy; repaint(); } void SearchGroup::doSearch() { clearList(); if (_search.isEmpty()) return; - int res_count = realSearch(); - setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); + _resultCount = realSearch(); // repaint(); } -void SearchGroup::clearList() -{ - QListViewItem *item = firstChild(); - QListViewItem *toDel; - while ( item != 0 ) { - toDel = item; - item = item->nextSibling(); - delete toDel; - } -} - void SearchGroup::setSearch(QRegExp re) { + if (re == _search) return; setText(0, _name+" - "+re.pattern() ); _search = re; if (isOpen()) expand(); else new OListViewItem( this, "searching..."); } int SearchGroup::realSearch() { - //emit isSearching( tr(" Searching for %s in %s" ).arg( _search.pattern().latin1()).arg( _name ) ); -/* OWait *wait = new OWait( qApp->mainWidget(), "test" ); - wait->show();*/ +#ifndef NEW_OWAIT + qDebug("NOT using NEW_OWAIT"); + if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" ); + wait->show(); + qApp->processEvents(); +#else + qDebug("using NEW_OWAIT"); + OWait::start( "osearch" ); +#endif if (!loaded) load(); - int count = search(); -/* wait->hide(); - delete wait;*/ - return count; + _resultCount = 0; + _resultCount = search(); + setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")"); + +#ifndef NEW_OWAIT + wait->hide(); +#else + OWait::stop(); +#endif + return _resultCount; } diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h index 32f32e0..a755e06 100644 --- a/core/pim/osearch/searchgroup.h +++ b/core/pim/osearch/searchgroup.h @@ -1,51 +1,48 @@ // // // C++ Interface: $MODULE$ // // Description: // // // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 // // Copyright: See COPYING file that comes with this distribution // // #ifndef SEARCHGROUP_H #define SEARCHGROUP_H #include "olistviewitem.h" class QRegExp; +class QPopupMenu; /** @author Patrick S. Vogt */ -class SearchGroup : public OListViewItem //, QObject +class SearchGroup : public OListViewItem { -//Q_OBJECT public: SearchGroup(QListView* parent, QString name); ~SearchGroup(); virtual void expand(); virtual void doSearch(); virtual void setSearch(QRegExp); virtual int rtti() { return Searchgroup;} -// signals: -// isSearching(QString); - protected: QRegExp _search; virtual void load() = 0; virtual int search() = 0; virtual void insertItem( void* ) = 0; - void clearList(); QString _name; bool loaded; + int _resultCount; private: int realSearch(); }; #endif diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp index c9fa61a..08bbe93 100644 --- a/core/pim/osearch/todosearch.cpp +++ b/core/pim/osearch/todosearch.cpp @@ -1,55 +1,80 @@ // // // C++ Implementation: $MODULE$ // // Description: // // // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 // // Copyright: See COPYING file that comes with this distribution // // #include "todosearch.h" #include <opie/otodoaccess.h> #include <opie/otodo.h> -#include <qiconset.h> #include <qpe/resource.h> +#include <qpe/config.h> +#include <qiconset.h> +#include <qaction.h> +#include <qpopupmenu.h> #include "todoitem.h" TodoSearch::TodoSearch(QListView* parent, QString name) -: SearchGroup(parent, name) +: SearchGroup(parent, name), _todos(0), _popupMenu(0) { - _todos = 0; // AppLnkSet als(QPEApplication::qpeDir()); // setPixmap( 0, als.findExec("todolist")->pixmap() ); QIconSet is = Resource::loadIconSet( "todo/TodoList" ); setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); + actionShowCompleted = new QAction( QObject::tr("show completed tasks"),QString::null, 0, 0, 0, true ); + Config cfg( "osearch", Config::User ); + cfg.setGroup( "todo_settings" ); + actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) ); + } TodoSearch::~TodoSearch() { + Config cfg( "osearch", Config::User ); + cfg.setGroup( "todo_settings" ); + cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() ); + delete _popupMenu; + delete actionShowCompleted; delete _todos; } void TodoSearch::load() { _todos = new OTodoAccess(); _todos->load(); } int TodoSearch::search() { ORecordList<OTodo> results = _todos->matchRegexp(_search); for (uint i = 0; i < results.count(); i++) - new TodoItem( this, new OTodo( results[i] )); - return results.count(); + insertItem( new OTodo( results[i] )); + return _resultCount; } -void TodoSearch::insertItem( void* ) +void TodoSearch::insertItem( void *rec ) { + OTodo *todo = (OTodo*)rec; + if (!actionShowCompleted->isOn() && + todo->isCompleted() ) return; + new TodoItem( this, todo ); + _resultCount++; +} +QPopupMenu* TodoSearch::popupMenu() +{ + if (!_popupMenu){ + _popupMenu = new QPopupMenu( 0 ); + actionShowCompleted->addTo( _popupMenu ); + } + return _popupMenu; } diff --git a/core/pim/osearch/todosearch.h b/core/pim/osearch/todosearch.h index 1d025d6..ee175da 100644 --- a/core/pim/osearch/todosearch.h +++ b/core/pim/osearch/todosearch.h @@ -1,39 +1,43 @@ // // // C++ Interface: $MODULE$ // // Description: // // // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 // // Copyright: See COPYING file that comes with this distribution // // #ifndef TODOSEARCH_H #define TODOSEARCH_H #include "searchgroup.h" class OTodoAccess; +class QAction; /** @author Patrick S. Vogt */ class TodoSearch : public SearchGroup { public: TodoSearch(QListView* parent, QString name); - ~TodoSearch(); + virtual QPopupMenu* popupMenu(); + protected: virtual void load(); virtual int search(); virtual void insertItem( void* ); private: OTodoAccess *_todos; + QAction *actionShowCompleted; + QPopupMenu *_popupMenu; }; #endif |