Diffstat (limited to 'core/pim/osearch/datebooksearch.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/osearch/datebooksearch.cpp | 53 |
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 | |||
@@ -16,20 +16,36 @@ | |||
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 | ||
22 | DatebookSearch::DatebookSearch(QListView* parent, QString name) | 27 | DatebookSearch::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 | |||
32 | DatebookSearch::~DatebookSearch() | 40 | DatebookSearch::~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 | } |
@@ -47,9 +63,30 @@ int DatebookSearch::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 | ||
52 | void DatebookSearch::insertItem( void* ) | 68 | void 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 | ||
83 | QPopupMenu* DatebookSearch::popupMenu() | ||
84 | { | ||
85 | if (!_popupMenu){ | ||
86 | _popupMenu = new QPopupMenu( 0 ); | ||
87 | actionShowPastEvents->addTo( _popupMenu ); | ||
88 | actionSearchInDates->addTo( _popupMenu ); | ||
55 | } | 89 | } |
90 | return _popupMenu; | ||
91 | } | ||
92 | |||