summaryrefslogtreecommitdiff
authortille <tille>2003-05-15 13:55:07 (UTC)
committer tille <tille>2003-05-15 13:55:07 (UTC)
commit80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6 (patch) (side-by-side diff)
tree4245ef4caf67784b452b908a9528ae03f988bf4c
parentded2a7a5715af1d1f6aab0b79ba90d8a815a9adc (diff)
downloadopie-80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6.zip
opie-80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6.tar.gz
opie-80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6.tar.bz2
owait and settings for search group:
- hide completed todos - show only later events - do not display hits in datebook dated
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/applnksearch.cpp5
-rw-r--r--core/pim/osearch/contactitem.cpp4
-rw-r--r--core/pim/osearch/datebooksearch.cpp53
-rw-r--r--core/pim/osearch/datebooksearch.h8
-rw-r--r--core/pim/osearch/doclnksearch.cpp1
-rw-r--r--core/pim/osearch/mainwindow.cpp45
-rw-r--r--core/pim/osearch/mainwindow.h2
-rw-r--r--core/pim/osearch/olistviewitem.cpp11
-rw-r--r--core/pim/osearch/olistviewitem.h3
-rw-r--r--core/pim/osearch/searchgroup.cpp50
-rw-r--r--core/pim/osearch/searchgroup.h9
-rw-r--r--core/pim/osearch/todosearch.cpp37
-rw-r--r--core/pim/osearch/todosearch.h6
13 files changed, 175 insertions, 59 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
@@ -43,3 +43,2 @@ int AppLnkSearch::search()
{
- int count = 0;
QList<AppLnk> appList = _apps->children();
@@ -49,3 +48,2 @@ int AppLnkSearch::search()
|| (_search.match(app->exec()) != -1) ) {
- count++;
insertItem( app );
@@ -54,3 +52,3 @@ int AppLnkSearch::search()
}
- return count;
+ return _resultCount;
}
@@ -60,2 +58,3 @@ void AppLnkSearch::insertItem( void *rec )
new AppLnkItem( this, (AppLnk*)rec );
+ _resultCount++;
}
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
@@ -72,3 +72,3 @@ void ContactItem::setIcon()
case Qtopia::FileAs:
- icon = Resource::loadPixmap( "addressbook/identity" );
+ icon = Resource::loadPixmap( "osearch/identity" );
break;
@@ -79,3 +79,3 @@ void ContactItem::setIcon()
case Qtopia::HomeCountry:
- icon = Resource::loadPixmap( "addressbook/addresshome" );
+ icon = Resource::loadPixmap( "osearch/addresshome" );
break;
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
@@ -16,20 +16,36 @@
+#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;
}
@@ -47,9 +63,30 @@ int DatebookSearch::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
@@ -18,2 +18,3 @@
class ODateBookAccess;
+class QAction;
@@ -26,5 +27,6 @@ public:
DatebookSearch(QListView* parent, QString name);
-
~DatebookSearch();
+ virtual QPopupMenu* popupMenu();
+
protected:
@@ -36,3 +38,5 @@ private:
ODateBookAccess *_dates;
-
+ QAction *actionShowPastEvents;
+ QAction *actionSearchInDates;
+ QPopupMenu *_popupMenu;
};
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
@@ -41,2 +41,3 @@ 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
@@ -21,2 +21,3 @@
#include <qpe/config.h>
+#include <qpe/global.h>
#include <qaction.h>
@@ -86,3 +87,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
- makeMenu();
setCentralWidget( mainFrame );
@@ -98,2 +98,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
+ makeMenu();
@@ -103,2 +104,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) );
+// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) );
}
@@ -119,3 +121,14 @@ void MainWindow::makeMenu()
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) ) );
+ }
+ }
@@ -128,4 +141,7 @@ void MainWindow::makeMenu()
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 );
@@ -153,2 +169,3 @@ MainWindow::~MainWindow()
cfg.writeEntry( "wildcards", actionWildcards->isOn() );
+ //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() );
}
@@ -184,10 +201,5 @@ void MainWindow::setCurrent(QListViewItem *item)
_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 );
}
@@ -202,3 +214,6 @@ void MainWindow::showPopup()
qDebug("showPopup");
+ popupTimer->stop();
if (!_currentItem) return;
+ QPopupMenu *pop = _currentItem->popupMenu();
+ if (pop) pop->popup( QCursor::pos() );
}
@@ -215,3 +230,10 @@ 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() )
@@ -228,3 +250,3 @@ void MainWindow::searchAll()
-void MainWindow::slotAction( int act)
+void MainWindow::slotAction( int act )
{
@@ -237 +259,6 @@ void MainWindow::slotAction( int 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
@@ -53,2 +53,3 @@ protected slots:
void searchStringChanged();
+ void optionChanged(int);
@@ -70,2 +71,3 @@ private:
QAction *actionWildcards;
+ //QAction *actionWholeWordsOnly;
uint _buttonCount;
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
@@ -30 +30,12 @@ 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
@@ -26,2 +26,5 @@ public:
virtual int rtti() { return Raw;}
+ virtual QPopupMenu* popupMenu() { return 0;};
+ void clearList();
+
};
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
@@ -15,4 +15,4 @@
#include <qregexp.h>
-// #include <qapplication.h>
-// #include <opie/owait.h>
+#include <qapplication.h>
+#include <opie/owait.h>
@@ -20,2 +20,7 @@
+//#define NEW_OWAIT
+#ifndef NEW_OWAIT
+static OWait *wait = 0;
+#endif
+
SearchGroup::SearchGroup(QListView* parent, QString name)
@@ -51,4 +56,3 @@ void SearchGroup::doSearch()
if (_search.isEmpty()) return;
- int res_count = realSearch();
- setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
+ _resultCount = realSearch();
// repaint();
@@ -56,15 +60,5 @@ void SearchGroup::doSearch()
-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() );
@@ -77,10 +71,22 @@ 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
@@ -18,2 +18,3 @@
class QRegExp;
+class QPopupMenu;
@@ -22,5 +23,4 @@ class QRegExp;
*/
-class SearchGroup : public OListViewItem //, QObject
+class SearchGroup : public OListViewItem
{
-//Q_OBJECT
public:
@@ -35,5 +35,2 @@ public:
-// signals:
-// isSearching(QString);
-
protected:
@@ -43,5 +40,5 @@ protected:
virtual void insertItem( void* ) = 0;
- void clearList();
QString _name;
bool loaded;
+ int _resultCount;
private:
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
@@ -16,4 +16,7 @@
#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"
@@ -21,5 +24,4 @@
TodoSearch::TodoSearch(QListView* parent, QString name)
-: SearchGroup(parent, name)
+: SearchGroup(parent, name), _todos(0), _popupMenu(0)
{
- _todos = 0;
// AppLnkSet als(QPEApplication::qpeDir());
@@ -28,2 +30,7 @@ TodoSearch::TodoSearch(QListView* parent, QString name)
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 ) );
+
}
@@ -33,2 +40,7 @@ TodoSearch::~TodoSearch()
{
+ Config cfg( "osearch", Config::User );
+ cfg.setGroup( "todo_settings" );
+ cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() );
+ delete _popupMenu;
+ delete actionShowCompleted;
delete _todos;
@@ -47,9 +59,22 @@ int TodoSearch::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
@@ -18,2 +18,3 @@
class OTodoAccess;
+class QAction;
@@ -26,5 +27,6 @@ public:
TodoSearch(QListView* parent, QString name);
-
~TodoSearch();
+ virtual QPopupMenu* popupMenu();
+
protected:
@@ -36,2 +38,4 @@ private:
OTodoAccess *_todos;
+ QAction *actionShowCompleted;
+ QPopupMenu *_popupMenu;
};