summaryrefslogtreecommitdiff
path: root/core/pim/osearch/datebooksearch.cpp
Unidiff
Diffstat (limited to 'core/pim/osearch/datebooksearch.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/osearch/datebooksearch.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp
index 5da7ae9..50c76e0 100644
--- a/core/pim/osearch/datebooksearch.cpp
+++ b/core/pim/osearch/datebooksearch.cpp
@@ -1,79 +1,79 @@
1// 1//
2// 2//
3// C++ Implementation: $MODULE$ 3// C++ Implementation: $MODULE$
4// 4//
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> 17#include <qpe/resource.h>
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <opie/oevent.h> 19#include <opie/oevent.h>
20#include <opie/orecur.h> 20#include <opie/orecur.h>
21#include <opie/odatebookaccess.h> 21#include <opie/odatebookaccess.h>
22#include <qiconset.h> 22#include <qiconset.h>
23#include <qaction.h> 23#include <qaction.h>
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qpopupmenu.h> 25#include <qpopupmenu.h>
26 26
27DatebookSearch::DatebookSearch(QListView* parent, QString name) 27DatebookSearch::DatebookSearch(QListView* parent, QString name)
28: SearchGroup(parent, name), _dates(0), _popupMenu(0) 28: SearchGroup(parent, name), _dates(0), _popupMenu(0)
29{ 29{
30 QIconSet is = Resource::loadIconSet( "datebook/DateBook" ); 30 QIconSet is = Resource::loadIconSet( "datebook/DateBookSmall" );
31 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 31 setPixmap( 0, is.pixmap( QIconSet::Large, true ) );
32 actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true ); 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 ); 33 actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true );
34 Config cfg( "osearch", Config::User ); 34 Config cfg( "osearch", Config::User );
35 cfg.setGroup( "datebook_settings" ); 35 cfg.setGroup( "datebook_settings" );
36 actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) ); 36 actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) );
37 actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) ); 37 actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) );
38} 38}
39 39
40DatebookSearch::~DatebookSearch() 40DatebookSearch::~DatebookSearch()
41{ 41{
42 qDebug("SAVE DATEBOOK SEARCH CONFIG"); 42 qDebug("SAVE DATEBOOK SEARCH CONFIG");
43 Config cfg( "osearch", Config::User ); 43 Config cfg( "osearch", Config::User );
44 cfg.setGroup( "datebook_settings" ); 44 cfg.setGroup( "datebook_settings" );
45 cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() ); 45 cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() );
46 cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() ); 46 cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() );
47 delete _dates; 47 delete _dates;
48 delete _popupMenu; 48 delete _popupMenu;
49 delete actionShowPastEvents; 49 delete actionShowPastEvents;
50 delete actionSearchInDates; 50 delete actionSearchInDates;
51} 51}
52 52
53 53
54void DatebookSearch::load() 54void DatebookSearch::load()
55{ 55{
56 _dates = new ODateBookAccess(); 56 _dates = new ODateBookAccess();
57 _dates->load(); 57 _dates->load();
58} 58}
59 59
60int DatebookSearch::search() 60int DatebookSearch::search()
61{ 61{
62 ORecordList<OEvent> results = _dates->matchRegexp(_search); 62 ORecordList<OEvent> results = _dates->matchRegexp(_search);
63 for (uint i = 0; i < results.count(); i++) 63 for (uint i = 0; i < results.count(); i++)
64 insertItem( new OEvent( results[i] ) ); 64 insertItem( new OEvent( results[i] ) );
65 return _resultCount; 65 return _resultCount;
66} 66}
67 67
68void DatebookSearch::insertItem( void *rec ) 68void DatebookSearch::insertItem( void *rec )
69{ 69{
70 OEvent *ev = (OEvent*)rec; 70 OEvent *ev = (OEvent*)rec;
71 if ( !actionShowPastEvents->isOn() && 71 if ( !actionShowPastEvents->isOn() &&
72 ev->endDateTime() < QDateTime::currentDateTime() && 72 ev->endDateTime() < QDateTime::currentDateTime() &&
73 !ev->recurrence().doesRecur() 73 !ev->recurrence().doesRecur()
74 ) return; 74 ) return;
75 if ( !actionSearchInDates->isOn() && ( 75 if ( !actionSearchInDates->isOn() && (
76 ev->lastHitField() == Qtopia::StartDateTime || 76 ev->lastHitField() == Qtopia::StartDateTime ||
77 ev->lastHitField() == Qtopia::EndDateTime ) 77 ev->lastHitField() == Qtopia::EndDateTime )
78 ) return; 78 ) return;
79 new EventItem( this, ev ); 79 new EventItem( this, ev );