From af4a3940dd672423da28b54e5d955cc5d33cecda Mon Sep 17 00:00:00 2001 From: zecke Date: Tue, 25 Jun 2002 19:55:53 +0000 Subject: All day events are not from 00:00 to 23:59 they're all day now. --- diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 9cc5fcd..5474cfc 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -566,7 +566,7 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) { - bool whichClock = db->dayView()->whichClock(); + // why would someone use "<"? Oh well, fix it up... // I wonder what other things may be messed up... @@ -597,27 +597,14 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, } text = "" + strDesc + "
" + "" - + strCat + "" - + "
" + tr("Start") + ": "; - - - if ( e.startDate() != ev.date() ) { - // multi-day event. Show start date - text += TimeString::longDateString( e.startDate() ); - } else { - // Show start time. - text += TimeString::timeString( ev.start(), whichClock, FALSE ); - } + + strCat + "
"; + if (ev.event().type() == Event::Normal ) + setEventText( text ); + else + setAllDayText( text ); - text += "
" + tr("End") + ": "; - if ( e.endDate() != ev.date() ) { - // multi-day event. Show end date - text += TimeString::longDateString( e.endDate() ); - } else { - // Show end time. - text += TimeString::timeString( ev.end(), whichClock, FALSE ); - } text += "

" + strNote; + setBackgroundMode( PaletteBase ); QTime start = ev.start(); @@ -635,6 +622,30 @@ DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, geom.setWidth(dateBook->dayView()->columnWidth(0)-1); } +void DateBookDayWidget::setAllDayText( QString &text ) { + text += "" + tr("This is an all day event.") + "
"; +} +void DateBookDayWidget::setEventText( QString& text ) { + bool whichClock = dateBook->dayView()->whichClock(); + text += "" + tr("Start") + ": "; + if ( ev.startDate() != ev.date() ) { + // multi-day event. Show start date + text += TimeString::longDateString( ev.startDate() ); + } else { + // Show start time. + text += TimeString::timeString( ev.start(), whichClock, FALSE ); + } + + text += "
" + tr("End") + ": "; + if ( ev.endDate() != ev.date() ) { + // multi-day event. Show end date + text += TimeString::longDateString( ev.endDate() ); + } else { + // Show end time. + text += TimeString::timeString( ev.end(), whichClock, FALSE ); + } + +} DateBookDayWidget::~DateBookDayWidget() { @@ -689,6 +700,7 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) if ( ev.event().hasRepeat() ) { p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); d = 20; + y += 20; } QSimpleRichText rt( text, font() ); diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h index be7cc45..db1cd04 100644 --- a/core/pim/datebook/datebookday.h +++ b/core/pim/datebook/datebookday.h @@ -40,7 +40,7 @@ class DateBookDayView : public QTable public: DateBookDayView( bool hourClock, QWidget *parent, const char *name ); bool whichClock() const; - + void setRowStyle( int style ); public slots: @@ -55,7 +55,7 @@ protected slots: protected: virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); virtual void paintFocus( QPainter *p, const QRect &cr ); - + virtual void resizeEvent( QResizeEvent *e ); void keyPressEvent( QKeyEvent *e ); void initHeader(); @@ -76,7 +76,7 @@ public: void setGeometry( const QRect &r ); const EffectiveEvent &event() const { return ev; } - + signals: void deleteMe( const Event &e ); void editMe( const Event &e ); @@ -87,6 +87,17 @@ protected: void mousePressEvent( QMouseEvent *e ); private: + /** + * Sets the text for an all day Event + * All day events have no time associated + */ + void setAllDayText( QString& text ); + + /** + * Sets the EventText + * it got a start and an end Time + */ + void setEventText( QString& text ); const EffectiveEvent ev; DateBookDay *dateBook; QString text; @@ -106,7 +117,7 @@ public: void setGeometry( const QRect &r ); void setTime( const QTime &t ); -signals: +signals: protected: void paintEvent( QPaintEvent *e ); @@ -119,21 +130,21 @@ private: //reimplemented the compareItems function so that it sorts DayWidgets by geometry heights class WidgetListClass : public QList -{ +{ private: - - int compareItems( QCollection::Item s1, QCollection::Item s2 ) - { + + int compareItems( QCollection::Item s1, QCollection::Item s2 ) + { //hmm, don't punish me for that ;) if (reinterpret_cast(s1)->geometry().height() > reinterpret_cast(s2)->geometry().height()) - { + { return -1; } else { return 1; } } - + }; diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 6532ba4..e16f516 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp @@ -461,6 +461,33 @@ void DateBookWeek::getEvents() view->moveToHour( startTime ); } +void DateBookWeek::generateAllDayTooltext( QString& text ) { + text += "" + tr("This is an all day event.") + "
"; +} + +void DateBookWeek::generateNormalTooltext( QString& str, + const EffectiveEvent &ev ) { + str += "" + QObject::tr("Start") + ": "; + + if ( ev.startDate() != ev.date() ) { + // multi-day event. Show start date + str += TimeString::longDateString( ev.startDate() ); + } else { + // Show start time. + str += TimeString::timeString(ev.start(), ampm, FALSE ); + } + + + str += "
" + QObject::tr("End") + ": "; + if ( ev.endDate() != ev.date() ) { + // multi-day event. Show end date + str += TimeString::longDateString( ev.endDate() ); + } else { + // Show end time. + str += TimeString::timeString( ev.end(), ampm, FALSE ); + } +} + void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) { if ( tHide->isActive() ) @@ -495,26 +522,15 @@ void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) } QString str = "" + strDesc + "
" + "" - + strCat + "" - + "
" + TimeString::longDateString( ev.date() ) - + "
" + QObject::tr("Start") + ": "; + + strCat + "" + + "
" + TimeString::longDateString( ev.date() ) + + "
"; - if ( ev.startDate() != ev.date() ) { - // multi-day event. Show start date - str += TimeString::longDateString( ev.startDate() ); - } else { - // Show start time. - str += TimeString::timeString(ev.start(), ampm, FALSE ); - } + if (ev.event().type() == Event::Normal ) + generateNormalTooltext( str, ev ); + else + generateAllDayTooltext( str ); - str += "
" + QObject::tr("End") + ": "; - if ( ev.endDate() != ev.date() ) { - // multi-day event. Show end date - str += TimeString::longDateString( ev.endDate() ); - } else { - // Show end time. - str += TimeString::timeString( ev.end(), ampm, FALSE ); - } str += "

" + strNote; lblDesc->setText( str ); diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h index 6e675f1..acbc2c7 100644 --- a/core/pim/datebook/datebookweek.h +++ b/core/pim/datebook/datebookweek.h @@ -133,6 +133,22 @@ private slots: private: void getEvents(); + + /** + * Wow that's a hell lot of code duplication + * in datebook. I vote for a common base class + * but never the less. This add a note + * that the Event is an all day event + * + */ + void generateAllDayTooltext( QString& text ); + + /** + * This will add the times to the text + * It will be shown in the Tooltip bubble + */ + void generateNormalTooltext( QString& text, + const EffectiveEvent &ev); int year; int _week; int dow; diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 29519c1..5eefc27 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -154,7 +154,10 @@ DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, strcpy(s, " |---"); } } else { - sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); + if(ev.event().type() == Event::Normal ) + sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); + else + sprintf(s," "); } setText(QString(s) + " " + ev.description()); connect(this, SIGNAL(clicked()), this, SLOT(editMe())); -- cgit v0.9.0.2