summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebook.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 2c2965e..c0d45c9 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -119,25 +119,25 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
QActionGroup *g = new QActionGroup( this );
g->setExclusive( TRUE );
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
a->addTo( sub_bar );
a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
a->addTo( sub_bar );
a->addTo( view );
-
+
a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
a->addTo( sub_bar );
a->addTo( view );
a->setToggleAction( TRUE );
a->setOn( TRUE );
dayAction = a;
a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
a->addTo( sub_bar );
a->addTo( view );
@@ -164,67 +164,67 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( settings );
QPopupMenu *default_view = new QPopupMenu(this);
settings->insertItem( tr( "Default View" ),default_view );
default_view->setCheckable(TRUE);
Config config("DateBook");
config.setGroup("Main");
int current=config.readNumEntry("defaultview", DAY);
-
+
QActionGroup *ag = new QActionGroup(this);
a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
if (current==DAY) a->setOn(true), viewDay();
ag->insert(a);
a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
if (current==WEEK) a->setOn(true), viewWeek();
ag->insert(a);
a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
if (current==WEEKLST) a->setOn(true), viewWeekLst();
ag->insert(a);
a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
if (current==MONTH) a->setOn(true), viewMonth();
ag->insert(a);
-
+
ag->addTo(default_view);
- connect(ag, SIGNAL( selected ( QAction * ) ),
- this, SLOT( newDefaultView(QAction *) )
+ connect(ag, SIGNAL( selected ( QAction * ) ),
+ this, SLOT( newDefaultView(QAction *) )
);
-
+
connect( qApp, SIGNAL(clockChanged(bool)),
this, SLOT(changeClock(bool)) );
connect( qApp, SIGNAL(weekChanged(bool)),
this, SLOT(changeWeek(bool)) );
-
+
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
this, SLOT(appMessage(const QCString&, const QByteArray&)) );
#endif
-
+
// listen on QPE/System
#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/System", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
channel = new QCopChannel( "QPE/Datebook", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
- qDebug("olle\n");
+ qDebug("olle\n");
#endif
#endif
-
+
qDebug("done t=%d", t.elapsed() );
}
void DateBook::receive( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "timeChange(QString)" ) {
// update active view!
if ( dayAction->isOn() )
viewDay();
else if ( weekAction->isOn() )
@@ -300,25 +300,25 @@ QString DateBook::checkEvent(const Event &e)
}
if(checkFailed)
return tr("Event duration is potentially longer\n"
"than interval between repeats.");
return QString::null;
}
QDate DateBook::currentDate()
{
QDate d = QDate::currentDate();
-
+
if ( dayView && views->visibleWidget() == dayView ) {
d = dayView->date();
} else if ( weekView && views->visibleWidget() == weekView ) {
d = weekView->date();
} else if ( weekLstView && views->visibleWidget() == weekLstView ) {
d = weekLstView->date();
} else if ( monthView && views->visibleWidget() == monthView ) {
d = monthView->selectedDate();
}
return d;
}
@@ -397,25 +397,25 @@ void DateBook::editEvent( const Event &e )
entry->timezone->setEnabled( FALSE );
sv->addChild( entry );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
editDlg.showMaximized();
#endif
while (editDlg.exec() ) {
Event newEv = entry->event();
newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
QString error = checkEvent(newEv);
if (!error.isNull()) {
if (QMessageBox::warning(this, "error box",
- error, "Fix it", "Continue",
+ error, "Fix it", "Continue",
0, 0, 1) == 0)
continue;
}
db->editEvent(e, newEv);
emit newEvent();
break;
}
}
void DateBook::removeEvent( const Event &e )
{
if (syncing) {
@@ -479,46 +479,46 @@ void DateBook::initWeek()
connect( this, SIGNAL( newEvent() ),
weekView, SLOT( redraw() ) );
}
//But also get it right: the year that we display can be different
//from the year of the current date. So, first find the year
//number of the current week.
int yearNumber, totWeeks;
calcWeek( currentDate(), totWeeks, yearNumber, onMonday );
QDate d = QDate( yearNumber, 12, 31 );
calcWeek( d, totWeeks, yearNumber, onMonday );
-
+
while ( totWeeks == 1 ) {
d = d.addDays( -1 );
calcWeek( d, totWeeks, yearNumber, onMonday );
}
if ( totWeeks != weekView->totalWeeks() )
weekView->setTotalWeeks( totWeeks );
}
void DateBook::initWeekLst() {
if ( !weekLstView ) {
- weekLstView = new DateBookWeekLst( ampm, onMonday, db,
+ weekLstView = new DateBookWeekLst( ampm, onMonday, db,
views, "weeklst view" );
views->addWidget( weekLstView, WEEKLST );
-
+
//weekLstView->setStartViewTime( startTime );
connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
this, SLOT( showDay( int, int, int ) ) );
- connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
- const QDateTime &,
+ connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
+ const QDateTime &,
const QString & ) ),
- this, SLOT( slotNewEntry( const QDateTime &,
- const QDateTime &,
+ this, SLOT( slotNewEntry( const QDateTime &,
+ const QDateTime &,
const QString & ) ) );
connect( this, SIGNAL( newEvent() ),
weekLstView, SLOT( redraw() ) );
connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
this, SLOT( editEvent( const Event & ) ) );
}
}
void DateBook::initMonth()
{
if ( !monthView ) {
@@ -531,25 +531,25 @@ void DateBook::initMonth()
qApp->processEvents();
}
}
void DateBook::loadSettings()
{
{
Config config( "qpe" );
config.setGroup("Time");
ampm = config.readBoolEntry( "AMPM", TRUE );
onMonday = config.readBoolEntry( "MONDAY" );
}
-
+
{
Config config("DateBook");
config.setGroup("Main");
startTime = config.readNumEntry("startviewtime", 8);
aPreset = config.readBoolEntry("alarmpreset");
presetTime = config.readNumEntry("presettime");
}
}
void DateBook::saveSettings()
{
Config config( "qpe" );
@@ -557,25 +557,25 @@ void DateBook::saveSettings()
configDB.setGroup( "Main" );
configDB.writeEntry("startviewtime",startTime);
configDB.writeEntry("alarmpreset",aPreset);
configDB.writeEntry("presettime",presetTime);
}
void DateBook::newDefaultView(QAction *a) {
int val=DAY;
if (a->text() == "Day") val=DAY;
if (a->text() == "Week") val=WEEK;
if (a->text() == "WeekLst") val=WEEKLST;
if (a->text() == "Month") val=MONTH;
-
+
Config configDB( "DateBook" );
configDB.setGroup( "Main" );
configDB.writeEntry("defaultview",val);
}
void DateBook::appMessage(const QCString& msg, const QByteArray& data)
{
bool needShow = FALSE;
if ( msg == "alarm(QDateTime,int)" ) {
QDataStream ds(data,IO_ReadOnly);
QDateTime when; int warn;
ds >> when >> warn;
@@ -679,25 +679,25 @@ void DateBook::reload()
void DateBook::flush()
{
syncing = TRUE;
db->save();
}
void DateBook::timerEvent( QTimerEvent *e )
{
if ( alarmCounter < 10 ) {
alarmCounter++;
Sound::soundAlarm();
- }
+ }
else
killTimer( e->timerId() );
}
void DateBook::changeClock( bool newClock )
{
ampm = newClock;
// repaint the affected objects...
if (dayView) dayView->redraw();
if (weekView) weekView->redraw();
if (weekLstView) weekLstView->redraw();
}
@@ -967,23 +967,25 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt,
}
}
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);
+ Event ev;
+ return ev; // return at least
}