summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp25
-rw-r--r--core/pim/datebook/datebook.h7
-rw-r--r--library/datebookdb.cpp14
-rw-r--r--library/datebookdb.h1
4 files changed, 29 insertions, 18 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 97c305c..c23129a 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -75,25 +75,25 @@
75 75
76 76
77DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 77DateBook::DateBook( QWidget *parent, const char *, WFlags f )
78 : QMainWindow( parent, "datebook", f ), 78 : QMainWindow( parent, "datebook", f ),
79 aPreset( FALSE ), 79 aPreset( FALSE ),
80 presetTime( -1 ), 80 presetTime( -1 ),
81 startTime( 8 ), // an acceptable default 81 startTime( 8 ), // an acceptable default
82 syncing(FALSE), 82 syncing(FALSE),
83 inSearch(FALSE) 83 inSearch(FALSE)
84{ 84{
85 QTime t; 85 QTime t;
86 t.start(); 86 t.start();
87 db = new DateBookDB; 87 db = new DateBookDBHack;
88 qDebug("loading db t=%d", t.elapsed() ); 88 qDebug("loading db t=%d", t.elapsed() );
89 loadSettings(); 89 loadSettings();
90 setCaption( tr("Calendar") ); 90 setCaption( tr("Calendar") );
91 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 91 setIcon( Resource::loadPixmap( "datebook_icon" ) );
92 92
93 setToolBarsMovable( FALSE ); 93 setToolBarsMovable( FALSE );
94 94
95 views = new QWidgetStack( this ); 95 views = new QWidgetStack( this );
96 setCentralWidget( views ); 96 setCentralWidget( views );
97 97
98 dayView = 0; 98 dayView = 0;
99 weekView = 0; 99 weekView = 0;
@@ -224,25 +224,25 @@ void DateBook::receive( const QCString &msg, const QByteArray &data )
224 if ( msg == "timeChange(QString)" ) { 224 if ( msg == "timeChange(QString)" ) {
225 // update active view! 225 // update active view!
226 if ( dayAction->isOn() ) 226 if ( dayAction->isOn() )
227 viewDay(); 227 viewDay();
228 else if ( weekAction->isOn() ) 228 else if ( weekAction->isOn() )
229 viewWeek(); 229 viewWeek();
230 else if ( monthAction->isOn() ) 230 else if ( monthAction->isOn() )
231 viewMonth(); 231 viewMonth();
232 } 232 }
233 else if (msg == "editEvent(int)") { 233 else if (msg == "editEvent(int)") {
234 int uid; 234 int uid;
235 stream >> uid; 235 stream >> uid;
236 Event e=db->getEvent(uid); 236 Event e=db->eventByUID(uid);
237 editEvent(e); 237 editEvent(e);
238 } 238 }
239} 239}
240 240
241DateBook::~DateBook() 241DateBook::~DateBook()
242{ 242{
243} 243}
244 244
245void DateBook::slotSettings() 245void DateBook::slotSettings()
246{ 246{
247 DateBookSettings frmSettings( ampm, this ); 247 DateBookSettings frmSettings( ampm, this );
248 frmSettings.setStartTime( startTime ); 248 frmSettings.setStartTime( startTime );
@@ -956,12 +956,33 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
956 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), 956 dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
957 dtEnd.date().day() ); 957 dtEnd.date().day() );
958 } else { 958 } else {
959 if ( wrapAround ) { 959 if ( wrapAround ) {
960 emit signalWrapAround(); 960 emit signalWrapAround();
961 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); 961 rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
962 nonrev.setStart( rev.start() ); 962 nonrev.setStart( rev.start() );
963 } else 963 } else
964 emit signalNotFound(); 964 emit signalNotFound();
965 wrapAround = !wrapAround; 965 wrapAround = !wrapAround;
966 } 966 }
967} 967}
968
969Event DateBookDBHack::eventByUID(int uid) {
970
971 // FIXME: Dirty Hacks to get hold of the private event lists
972 QDate start;
973 QDate end=start.addDays(-1);
974 QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
975 QValueList<Event> myRepeatEvents=getRawRepeats();
976
977 QValueList<Event>::ConstIterator it;
978
979 for (it = myEventList.begin(); it != myEventList.end(); it++) {
980 if ((*it).uid() == uid) return *it;
981 }
982 for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
983 if ((*it).uid() == uid) return *it;
984 }
985
986 qDebug("Event not found: uid=%d\n", uid);
987}
988
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 2ffcdbe..d1fe90d 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -25,24 +25,29 @@
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26 26
27class QAction; 27class QAction;
28class QWidgetStack; 28class QWidgetStack;
29class DateBookDay; 29class DateBookDay;
30class DateBookWeek; 30class DateBookWeek;
31class DateBookWeekLst; 31class DateBookWeekLst;
32class DateBookMonth; 32class DateBookMonth;
33class Event; 33class Event;
34class QDate; 34class QDate;
35class Ir; 35class Ir;
36 36
37class DateBookDBHack : public DateBookDB {
38 public:
39 Event eventByUID(int id);
40};
41
37class DateBook : public QMainWindow 42class DateBook : public QMainWindow
38{ 43{
39 Q_OBJECT 44 Q_OBJECT
40 45
41public: 46public:
42 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 47 DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
43 ~DateBook(); 48 ~DateBook();
44 49
45signals: 50signals:
46 void newEvent(); 51 void newEvent();
47 void signalNotFound(); 52 void signalNotFound();
48 void signalWrapAround(); 53 void signalWrapAround();
@@ -90,25 +95,25 @@ private slots:
90 void beamDone( Ir *ir ); 95 void beamDone( Ir *ir );
91 96
92private: 97private:
93 void addEvent( const Event &e ); 98 void addEvent( const Event &e );
94 void initDay(); 99 void initDay();
95 void initWeek(); 100 void initWeek();
96 void initWeekLst(); 101 void initWeekLst();
97 void initMonth(); 102 void initMonth();
98 void loadSettings(); 103 void loadSettings();
99 void saveSettings(); 104 void saveSettings();
100 105
101private: 106private:
102 DateBookDB *db; 107 DateBookDBHack *db;
103 QWidgetStack *views; 108 QWidgetStack *views;
104 DateBookDay *dayView; 109 DateBookDay *dayView;
105 DateBookWeek *weekView; 110 DateBookWeek *weekView;
106 DateBookMonth *monthView; 111 DateBookMonth *monthView;
107 DateBookWeekLst *weekLstView; 112 DateBookWeekLst *weekLstView;
108 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
109 bool aPreset; // have everything set to alarm? 114 bool aPreset; // have everything set to alarm?
110 int presetTime; // the standard time for the alarm 115 int presetTime; // the standard time for the alarm
111 int startTime; 116 int startTime;
112 bool ampm; 117 bool ampm;
113 bool onMonday; 118 bool onMonday;
114 119
diff --git a/library/datebookdb.cpp b/library/datebookdb.cpp
index da5a797..2ac9a0c 100644
--- a/library/datebookdb.cpp
+++ b/library/datebookdb.cpp
@@ -578,38 +578,24 @@ QValueList<EffectiveEvent> DateBookDB::getEffectiveEvents( const QDateTime &dt)
578 QValueList<EffectiveEvent> tmpList; 578 QValueList<EffectiveEvent> tmpList;
579 QDateTime dtTmp; 579 QDateTime dtTmp;
580 580
581 for (it = day.begin(); it != day.end(); ++it ) { 581 for (it = day.begin(); it != day.end(); ++it ) {
582 dtTmp = QDateTime( (*it).date(), (*it).start() ); 582 dtTmp = QDateTime( (*it).date(), (*it).start() );
583 // at the moment we don't have second granularity, be nice about that.. 583 // at the moment we don't have second granularity, be nice about that..
584 if ( QABS(dt.secsTo(dtTmp)) < 60 ) 584 if ( QABS(dt.secsTo(dtTmp)) < 60 )
585 tmpList.append( *it ); 585 tmpList.append( *it );
586 } 586 }
587 return tmpList; 587 return tmpList;
588} 588}
589 589
590Event DateBookDB::getEvent( int uid ) {
591 QValueList<Event>::ConstIterator it;
592
593 for (it = eventList.begin(); it != eventList.end(); it++) {
594 if ((*it).uid() == uid) return *it;
595 }
596 for (it = repeatEvents.begin(); it != repeatEvents.end(); it++) {
597 if ((*it).uid() == uid) return *it;
598 }
599
600 qDebug("Event not found: uid=%d\n", uid);
601}
602
603
604void DateBookDB::addEvent( const Event &ev, bool doalarm ) 590void DateBookDB::addEvent( const Event &ev, bool doalarm )
605{ 591{
606 // write to the journal... 592 // write to the journal...
607 saveJournalEntry( ev, ACTION_ADD, -1, false ); 593 saveJournalEntry( ev, ACTION_ADD, -1, false );
608 addJFEvent( ev, doalarm ); 594 addJFEvent( ev, doalarm );
609 d->clean = false; 595 d->clean = false;
610} 596}
611 597
612void DateBookDB::addJFEvent( const Event &ev, bool doalarm ) 598void DateBookDB::addJFEvent( const Event &ev, bool doalarm )
613{ 599{
614 if ( doalarm && ev.hasAlarm() ) 600 if ( doalarm && ev.hasAlarm() )
615 addEventAlarm( ev ); 601 addEventAlarm( ev );
diff --git a/library/datebookdb.h b/library/datebookdb.h
index e4c251c..0add028 100644
--- a/library/datebookdb.h
+++ b/library/datebookdb.h
@@ -35,25 +35,24 @@ class DateBookDB
35public: 35public:
36 DateBookDB(); 36 DateBookDB();
37 ~DateBookDB(); 37 ~DateBookDB();
38 38
39 // very depreciated now!!! 39 // very depreciated now!!!
40 QValueList<Event> getEvents( const QDate &from, const QDate &to ); 40 QValueList<Event> getEvents( const QDate &from, const QDate &to );
41 QValueList<Event> getEvents( const QDateTime &start ); 41 QValueList<Event> getEvents( const QDateTime &start );
42 42
43 // USE THESE!!! 43 // USE THESE!!!
44 QValueList<EffectiveEvent> getEffectiveEvents( const QDate &from, 44 QValueList<EffectiveEvent> getEffectiveEvents( const QDate &from,
45 const QDate &to ); 45 const QDate &to );
46 QValueList<EffectiveEvent> getEffectiveEvents( const QDateTime &start ); 46 QValueList<EffectiveEvent> getEffectiveEvents( const QDateTime &start );
47 Event getEvent( int uid );
48 47
49 QValueList<Event> getRawRepeats() const; 48 QValueList<Event> getRawRepeats() const;
50 QValueList<Event> getNonRepeatingEvents( const QDate &from, 49 QValueList<Event> getNonRepeatingEvents( const QDate &from,
51 const QDate &to ) const; 50 const QDate &to ) const;
52 51
53 // Use these when dealing with adding removing events... 52 // Use these when dealing with adding removing events...
54 void addEvent( const Event &ev, bool doalarm=TRUE ); 53 void addEvent( const Event &ev, bool doalarm=TRUE );
55 void removeEvent( const Event &ev ); 54 void removeEvent( const Event &ev );
56 void editEvent( const Event &old, Event &ev ); 55 void editEvent( const Event &old, Event &ev );
57 // add/remove event without journaling ( these ended up in public by accident, never 56 // add/remove event without journaling ( these ended up in public by accident, never
58 // use them unless you know what you are doing...), 57 // use them unless you know what you are doing...),
59 // please put them in private if we ever can change the class... 58 // please put them in private if we ever can change the class...