summaryrefslogtreecommitdiff
Side-by-side diff
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 @@
DateBook::DateBook( QWidget *parent, const char *, WFlags f )
: QMainWindow( parent, "datebook", f ),
aPreset( FALSE ),
presetTime( -1 ),
startTime( 8 ), // an acceptable default
syncing(FALSE),
inSearch(FALSE)
{
QTime t;
t.start();
- db = new DateBookDB;
+ db = new DateBookDBHack;
qDebug("loading db t=%d", t.elapsed() );
loadSettings();
setCaption( tr("Calendar") );
setIcon( Resource::loadPixmap( "datebook_icon" ) );
setToolBarsMovable( FALSE );
views = new QWidgetStack( this );
setCentralWidget( views );
dayView = 0;
weekView = 0;
@@ -224,25 +224,25 @@ void DateBook::receive( const QCString &msg, const QByteArray &data )
if ( msg == "timeChange(QString)" ) {
// update active view!
if ( dayAction->isOn() )
viewDay();
else if ( weekAction->isOn() )
viewWeek();
else if ( monthAction->isOn() )
viewMonth();
}
else if (msg == "editEvent(int)") {
int uid;
stream >> uid;
- Event e=db->getEvent(uid);
+ Event e=db->eventByUID(uid);
editEvent(e);
}
}
DateBook::~DateBook()
{
}
void DateBook::slotSettings()
{
DateBookSettings frmSettings( ampm, this );
frmSettings.setStartTime( startTime );
@@ -956,12 +956,33 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
dayView->setDate( dtEnd.date().year(), dtEnd.date().month(),
dtEnd.date().day() );
} else {
if ( wrapAround ) {
emit signalWrapAround();
rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) );
nonrev.setStart( rev.start() );
} else
emit signalNotFound();
wrapAround = !wrapAround;
}
}
+
+Event DateBookDBHack::eventByUID(int uid) {
+
+ // FIXME: Dirty Hacks to get hold of the private event lists
+ QDate start;
+ QDate end=start.addDays(-1);
+ QValueList<Event> myEventList=getNonRepeatingEvents(start,end);
+ QValueList<Event> myRepeatEvents=getRawRepeats();
+
+ QValueList<Event>::ConstIterator it;
+
+ for (it = myEventList.begin(); it != myEventList.end(); it++) {
+ if ((*it).uid() == uid) return *it;
+ }
+ for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) {
+ if ((*it).uid() == uid) return *it;
+ }
+
+ qDebug("Event not found: uid=%d\n", uid);
+}
+
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 @@
#include <qmainwindow.h>
class QAction;
class QWidgetStack;
class DateBookDay;
class DateBookWeek;
class DateBookWeekLst;
class DateBookMonth;
class Event;
class QDate;
class Ir;
+class DateBookDBHack : public DateBookDB {
+ public:
+ Event eventByUID(int id);
+};
+
class DateBook : public QMainWindow
{
Q_OBJECT
public:
DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~DateBook();
signals:
void newEvent();
void signalNotFound();
void signalWrapAround();
@@ -90,25 +95,25 @@ private slots:
void beamDone( Ir *ir );
private:
void addEvent( const Event &e );
void initDay();
void initWeek();
void initWeekLst();
void initMonth();
void loadSettings();
void saveSettings();
private:
- DateBookDB *db;
+ DateBookDBHack *db;
QWidgetStack *views;
DateBookDay *dayView;
DateBookWeek *weekView;
DateBookMonth *monthView;
DateBookWeekLst *weekLstView;
QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
bool aPreset; // have everything set to alarm?
int presetTime; // the standard time for the alarm
int startTime;
bool ampm;
bool onMonday;
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)
QValueList<EffectiveEvent> tmpList;
QDateTime dtTmp;
for (it = day.begin(); it != day.end(); ++it ) {
dtTmp = QDateTime( (*it).date(), (*it).start() );
// at the moment we don't have second granularity, be nice about that..
if ( QABS(dt.secsTo(dtTmp)) < 60 )
tmpList.append( *it );
}
return tmpList;
}
-Event DateBookDB::getEvent( int uid ) {
- QValueList<Event>::ConstIterator it;
-
- for (it = eventList.begin(); it != eventList.end(); it++) {
- if ((*it).uid() == uid) return *it;
- }
- for (it = repeatEvents.begin(); it != repeatEvents.end(); it++) {
- if ((*it).uid() == uid) return *it;
- }
-
- qDebug("Event not found: uid=%d\n", uid);
-}
-
-
void DateBookDB::addEvent( const Event &ev, bool doalarm )
{
// write to the journal...
saveJournalEntry( ev, ACTION_ADD, -1, false );
addJFEvent( ev, doalarm );
d->clean = false;
}
void DateBookDB::addJFEvent( const Event &ev, bool doalarm )
{
if ( doalarm && ev.hasAlarm() )
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
public:
DateBookDB();
~DateBookDB();
// very depreciated now!!!
QValueList<Event> getEvents( const QDate &from, const QDate &to );
QValueList<Event> getEvents( const QDateTime &start );
// USE THESE!!!
QValueList<EffectiveEvent> getEffectiveEvents( const QDate &from,
const QDate &to );
QValueList<EffectiveEvent> getEffectiveEvents( const QDateTime &start );
- Event getEvent( int uid );
QValueList<Event> getRawRepeats() const;
QValueList<Event> getNonRepeatingEvents( const QDate &from,
const QDate &to ) const;
// Use these when dealing with adding removing events...
void addEvent( const Event &ev, bool doalarm=TRUE );
void removeEvent( const Event &ev );
void editEvent( const Event &old, Event &ev );
// add/remove event without journaling ( these ended up in public by accident, never
// use them unless you know what you are doing...),
// please put them in private if we ever can change the class...