summaryrefslogtreecommitdiff
path: root/core
authorzecke <zecke>2002-06-25 19:55:53 (UTC)
committer zecke <zecke>2002-06-25 19:55:53 (UTC)
commitaf4a3940dd672423da28b54e5d955cc5d33cecda (patch) (side-by-side diff)
treecb5fcfe4835c86353e9d54b1050c7dfb23898bf1 /core
parent8635f264c15b05152fc1a44f798c154472a4b227 (diff)
downloadopie-af4a3940dd672423da28b54e5d955cc5d33cecda.zip
opie-af4a3940dd672423da28b54e5d955cc5d33cecda.tar.gz
opie-af4a3940dd672423da28b54e5d955cc5d33cecda.tar.bz2
All day events are not from 00:00 to 23:59 they're all day now.
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp52
-rw-r--r--core/pim/datebook/datebookday.h31
-rw-r--r--core/pim/datebook/datebookweek.cpp52
-rw-r--r--core/pim/datebook/datebookweek.h16
-rw-r--r--core/pim/datebook/datebookweeklst.cpp5
5 files changed, 107 insertions, 49 deletions
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
@@ -545,117 +545,128 @@ void DateBookDay::keyPressEvent(QKeyEvent *e)
switch(e->key()) {
case Key_Up:
view->moveUp();
break;
case Key_Down:
view->moveDown();
break;
case Key_Left:
setDate(QDate(currDate).addDays(-1));
break;
case Key_Right:
setDate(QDate(currDate).addDays(1));
break;
default:
e->ignore();
}
}
//===========================================================================
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...
QString strDesc = ev.description();
int where = strDesc.find( "<" );
while ( where != -1 ) {
strDesc.remove( where, 1 );
strDesc.insert( where, "&#60;" );
where = strDesc.find( "<", where );
}
QString strCat;
// ### Fix later...
// QString strCat = ev.category();
// where = strCat.find( "<" );
// while ( where != -1 ) {
// strCat.remove( where, 1 );
// strCat.insert( where, "&#60;" );
// where = strCat.find( "<", where );
// }
QString strNote = ev.notes();
where = strNote.find( "<" );
while ( where != -1 ) {
strNote.remove( where, 1 );
strNote.insert( where, "&#60;" );
where = strNote.find( "<", where );
}
text = "<b>" + strDesc + "</b><br>" + "<i>"
- + strCat + "</i>"
- + "<br><b>" + tr("Start") + "</b>: ";
-
-
- 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 + "</i><br>";
+ if (ev.event().type() == Event::Normal )
+ setEventText( text );
+ else
+ setAllDayText( text );
- text += "<br><b>" + tr("End") + "</b>: ";
- 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 += "<br><br>" + strNote;
+
setBackgroundMode( PaletteBase );
QTime start = ev.start();
QTime end = ev.end();
int y = start.hour()*60+start.minute();
int h = end.hour()*60+end.minute()-y;
int rh = dateBook->dayView()->rowHeight(0);
y = y*rh/60;
h = h*rh/60;
if ( h < 3 )
h = 3;
geom.setY( y );
geom.setHeight( h );
geom.setX( 0 );
geom.setWidth(dateBook->dayView()->columnWidth(0)-1);
}
+void DateBookDayWidget::setAllDayText( QString &text ) {
+ text += "<b>" + tr("This is an all day event.") + "</b><br>";
+}
+void DateBookDayWidget::setEventText( QString& text ) {
+ bool whichClock = dateBook->dayView()->whichClock();
+ text += "<b>" + tr("Start") + "</b>: ";
+ 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 += "<br><b>" + tr("End") + "</b>: ";
+ 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()
{
}
void DateBookDayWidget::paintEvent( QPaintEvent *e )
{
QPainter p( this );
if (dateBook->getSelectedWidget() == this)
{
p.setBrush( QColor( 155, 240, 230 ) ); // selected item
} else
{
if (dateBook->date() == QDate::currentDate())
{
QTime curTime = QTime::currentTime();
if (ev.end() < curTime)
{
p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive
} else
{
//change color in dependence of the time till the event starts
@@ -668,48 +679,49 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e )
} else
{
p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date)
//perhaps make a distinction between future/past dates
}
}
p.setPen( QColor(100, 100, 100) );
p.drawRect(rect());
// p.drawRect(0,0, 5, height());
int y = 0;
int d = 0;
if ( ev.event().hasAlarm() ) {
p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
y = 20;
d = 20;
}
if ( ev.event().hasRepeat() ) {
p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
d = 20;
+ y += 20;
}
QSimpleRichText rt( text, font() );
rt.setWidth( geom.width() - d - 6 );
rt.draw( &p, 7, 0, e->region(), colorGroup() );
}
void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
{
DateBookDayWidget *item;
item = dateBook->getSelectedWidget();
if (item) item->update();
dateBook->setSelectedWidget(this);
update();
dateBook->repaint();
QPopupMenu m;
m.insertItem( tr( "Edit" ), 1 );
m.insertItem( tr( "Delete" ), 2 );
m.insertItem( tr( "Beam" ), 3 );
int r = m.exec( e->globalPos() );
if ( r == 1 ) {
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
@@ -19,142 +19,153 @@
**********************************************************************/
#ifndef DATEBOOKDAY_H
#define DATEBOOKDAY_H
#include <qpe/event.h>
#include <qdatetime.h>
#include <qtable.h>
#include <qvbox.h>
#include <qlist.h>
class DateBookDayHeader;
class DateBookDB;
class QDateTime;
class QMouseEvent;
class QPaintEvent;
class QResizeEvent;
class DateBookDayView : public QTable
{
Q_OBJECT
public:
DateBookDayView( bool hourClock, QWidget *parent, const char *name );
bool whichClock() const;
-
+
void setRowStyle( int style );
public slots:
void moveUp();
void moveDown();
signals:
void sigColWidthChanged();
void sigCapturedKey( const QString &txt );
protected slots:
void slotChangeClock( bool );
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();
private:
bool ampm;
};
class DateBookDay;
class DateBookDayWidget : public QWidget
{
Q_OBJECT
public:
DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db );
~DateBookDayWidget();
const QRect &geometry() { return geom; }
void setGeometry( const QRect &r );
const EffectiveEvent &event() const { return ev; }
-
+
signals:
void deleteMe( const Event &e );
void editMe( const Event &e );
void beamMe( const Event &e );
protected:
void paintEvent( QPaintEvent *e );
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;
QRect geom;
};
//Marker for current time in the dayview
class DateBookDayTimeMarker : public QWidget
{
Q_OBJECT
public:
DateBookDayTimeMarker( DateBookDay *db );
~DateBookDayTimeMarker();
const QRect &geometry() { return geom; }
void setGeometry( const QRect &r );
void setTime( const QTime &t );
-signals:
+signals:
protected:
void paintEvent( QPaintEvent *e );
private:
QRect geom;
QTime time;
DateBookDay *dateBook;
};
//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
class WidgetListClass : public QList<DateBookDayWidget>
-{
+{
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<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
- {
+ {
return -1;
} else
{
return 1;
}
}
-
+
};
class DateBookDay : public QVBox
{
Q_OBJECT
public:
DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,
QWidget *parent, const char *name );
void selectedDates( QDateTime &start, QDateTime &end );
QDate date() const;
DateBookDayView *dayView() const { return view; }
void setStartViewTime( int startHere );
int startViewTime() const;
void setSelectedWidget( DateBookDayWidget * );
DateBookDayWidget * getSelectedWidget( void );
void setJumpToCurTime( bool bJump );
void setRowStyle( int style );
public slots:
void setDate( int y, int m, int d );
void setDate( QDate );
void redraw();
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
@@ -440,102 +440,118 @@ QDate DateBookWeek::date() const
QDate d;
d = dateFromWeek( _week - 1, year, bStartOnMonday );
if ( bStartOnMonday )
d = d.addDays( 7 + dow - 1 );
else {
if ( dow == 7 )
d = d.addDays( dow );
else
d = d.addDays( 7 + dow );
}
return d;
}
void DateBookWeek::getEvents()
{
QDate startWeek = weekDate();
QDate endWeek = startWeek.addDays( 6 );
QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek,
endWeek);
view->showEvents( eventList );
view->moveToHour( startTime );
}
+void DateBookWeek::generateAllDayTooltext( QString& text ) {
+ text += "<b>" + tr("This is an all day event.") + "</b><br>";
+}
+
+void DateBookWeek::generateNormalTooltext( QString& str,
+ const EffectiveEvent &ev ) {
+ str += "<b>" + QObject::tr("Start") + "</b>: ";
+
+ 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 += "<br><b>" + QObject::tr("End") + "</b>: ";
+ 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() )
tHide->stop();
// why would someone use "<"? Oh well, fix it up...
// I wonder what other things may be messed up...
QString strDesc = ev.description();
int where = strDesc.find( "<" );
while ( where != -1 ) {
strDesc.remove( where, 1 );
strDesc.insert( where, "&#60;" );
where = strDesc.find( "<", where );
}
QString strCat;
// ### FIX later...
// QString strCat = ev.category();
// where = strCat.find( "<" );
// while ( where != -1 ) {
// strCat.remove( where, 1 );
// strCat.insert( where, "&#60;" );
// where = strCat.find( "<", where );
// }
QString strNote = ev.notes();
where = strNote.find( "<" );
while ( where != -1 ) {
strNote.remove( where, 1 );
strNote.insert( where, "&#60;" );
where = strNote.find( "<", where );
}
QString str = "<b>" + strDesc + "</b><br>" + "<i>"
- + strCat + "</i>"
- + "<br>" + TimeString::longDateString( ev.date() )
- + "<br><b>" + QObject::tr("Start") + "</b>: ";
+ + strCat + "</i>"
+ + "<br>" + TimeString::longDateString( ev.date() )
+ + "<br>";
- 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 += "<br><b>" + QObject::tr("End") + "</b>: ";
- 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 += "<br><br>" + strNote;
lblDesc->setText( str );
lblDesc->resize( lblDesc->sizeHint() );
// move the label so it is "centerd" horizontally...
lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 );
lblDesc->show();
}
void DateBookWeek::slotHideEvent()
{
tHide->start( 2000, true );
}
void DateBookWeek::setStartViewTime( int startHere )
{
startTime = startHere;
view->moveToHour( startTime );
}
int DateBookWeek::startViewTime() const
{
return startTime;
}
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
@@ -112,41 +112,57 @@ public:
void setTotalWeeks( int totalWeeks );
int totalWeeks() const;
QDate weekDate() const;
public slots:
void redraw();
void slotWeekChanged( bool bStartOnMonday );
void slotClockChanged( bool a );
signals:
void showDate( int y, int m, int d );
protected slots:
void keyPressEvent(QKeyEvent *);
private slots:
void showDay( int day );
void dateChanged( int y, int w );
void slotShowEvent( const EffectiveEvent & );
void slotHideEvent();
void slotYearChanged( int );
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;
DateBookWeekHeader *header;
DateBookWeekView *view;
DateBookDB *db;
QLabel *lblDesc;
QTimer *tHide;
int startTime;
bool ampm;
bool bStartOnMonday;
};
bool calcWeek( const QDate &d, int &week, int &year,
bool startOnMonday = false );
#endif
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
@@ -133,49 +133,52 @@ void DateBookWeekLstDayHdr::showDay() {
}
void DateBookWeekLstDayHdr::newEvent() {
QDateTime start, stop;
start=stop=date;
start.setTime(QTime(10,0));
stop.setTime(QTime(12,0));
emit addEvent(start,stop,"");
}
DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
QWidget* parent,
const char* name,
WFlags fl) :
OClickableLabel(parent,name,fl),
event(ev)
{
char s[10];
if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
if ( ev.endDate() == ev.date() ) { // last day
strcpy(s, "__|__");
} else {
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()));
setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
}
void DateBookWeekLstEvent::editMe() {
emit editEvent(event.event());
}
DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
const QDate &d, bool onM,
QWidget* parent,
const char* name, WFlags fl)
: QWidget( parent, name, fl )
{
onMonday=onM;
setPalette(white);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
QVBoxLayout *layout = new QVBoxLayout( this );
qBubbleSort(ev);
QValueListIterator<EffectiveEvent> it;