summaryrefslogtreecommitdiff
path: root/core/pim/osearch/datebooksearch.cpp
authortille <tille>2003-05-15 13:55:07 (UTC)
committer tille <tille>2003-05-15 13:55:07 (UTC)
commit80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6 (patch) (unidiff)
tree4245ef4caf67784b452b908a9528ae03f988bf4c /core/pim/osearch/datebooksearch.cpp
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 (limited to 'core/pim/osearch/datebooksearch.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/datebooksearch.cpp53
1 files changed, 45 insertions, 8 deletions
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
@@ -5,51 +5,88 @@
5// Description: 5// Description:
6// 6//
7// 7//
8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 8// Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
9// 9//
10// Copyright: See COPYING file that comes with this distribution 10// Copyright: See COPYING file that comes with this distribution
11// 11//
12// 12//
13#include "datebooksearch.h" 13#include "datebooksearch.h"
14 14
15#include "eventitem.h" 15#include "eventitem.h"
16 16
17#include <qpe/resource.h>
18#include <qpe/config.h>
17#include <opie/oevent.h> 19#include <opie/oevent.h>
20#include <opie/orecur.h>
18#include <opie/odatebookaccess.h> 21#include <opie/odatebookaccess.h>
19#include <qiconset.h> 22#include <qiconset.h>
20#include <qpe/resource.h> 23#include <qaction.h>
24#include <qdatetime.h>
25#include <qpopupmenu.h>
21 26
22DatebookSearch::DatebookSearch(QListView* parent, QString name) 27DatebookSearch::DatebookSearch(QListView* parent, QString name)
23: SearchGroup(parent, name) 28: SearchGroup(parent, name), _dates(0), _popupMenu(0)
24{ 29{
25 _dates = 0;
26 QIconSet is = Resource::loadIconSet( "datebook/DateBook" ); 30 QIconSet is = Resource::loadIconSet( "datebook/DateBook" );
27 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 31 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
28 32 actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true );
33 actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true );
34 Config cfg( "osearch", Config::User );
35 cfg.setGroup( "datebook_settings" );
36 actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) );
37 actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) );
29} 38}
30 39
31
32DatebookSearch::~DatebookSearch() 40DatebookSearch::~DatebookSearch()
33{ 41{
42 qDebug("SAVE DATEBOOK SEARCH CONFIG");
43 Config cfg( "osearch", Config::User );
44 cfg.setGroup( "datebook_settings" );
45 cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() );
46 cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() );
34 delete _dates; 47 delete _dates;
48 delete _popupMenu;
49 delete actionShowPastEvents;
50 delete actionSearchInDates;
35} 51}
36 52
37 53
38void DatebookSearch::load() 54void DatebookSearch::load()
39{ 55{
40 _dates = new ODateBookAccess(); 56 _dates = new ODateBookAccess();
41 _dates->load(); 57 _dates->load();
42} 58}
43 59
44int DatebookSearch::search() 60int DatebookSearch::search()
45{ 61{
46 ORecordList<OEvent> results = _dates->matchRegexp(_search); 62 ORecordList<OEvent> results = _dates->matchRegexp(_search);
47 for (uint i = 0; i < results.count(); i++) 63 for (uint i = 0; i < results.count(); i++)
48 new EventItem( this, new OEvent( results[i] )); 64 insertItem( new OEvent( results[i] ) );
49 return results.count(); 65 return _resultCount;
50} 66}
51 67
52void DatebookSearch::insertItem( void* ) 68void DatebookSearch::insertItem( void *rec )
53{ 69{
70 OEvent *ev = (OEvent*)rec;
71 if ( !actionShowPastEvents->isOn() &&
72 ev->endDateTime() < QDateTime::currentDateTime() &&
73 !ev->recurrence().doesRecur()
74 ) return;
75 if ( !actionSearchInDates->isOn() && (
76 ev->lastHitField() == Qtopia::StartDateTime ||
77 ev->lastHitField() == Qtopia::EndDateTime )
78 ) return;
79 new EventItem( this, ev );
80 _resultCount++;
81}
54 82
83QPopupMenu* DatebookSearch::popupMenu()
84{
85 if (!_popupMenu){
86 _popupMenu = new QPopupMenu( 0 );
87 actionShowPastEvents->addTo( _popupMenu );
88 actionSearchInDates->addTo( _popupMenu );
89 }
90 return _popupMenu;
55} 91}
92