author | eilers <eilers> | 2003-08-01 14:19:44 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-01 14:19:44 (UTC) |
commit | 34991bac7d96b1c17601be6a5607819342571e0c (patch) (side-by-side diff) | |
tree | 65d0bc2db22bcc1dc1b5eafdafd53b9cb08a6395 /core/pim/datebook/datebookday.cpp | |
parent | 5346424fc26bde232a15aa34fbb720f86218b26f (diff) | |
download | opie-34991bac7d96b1c17601be6a5607819342571e0c.zip opie-34991bac7d96b1c17601be6a5607819342571e0c.tar.gz opie-34991bac7d96b1c17601be6a5607819342571e0c.tar.bz2 |
Merging changes from BRANCH_1_0 to HEAD..
Diffstat (limited to 'core/pim/datebook/datebookday.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 127 |
1 files changed, 119 insertions, 8 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 0b213e9..f4008e9 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -23,2 +23,3 @@ #include "datebookdayheaderimpl.h" +#include "datebookdayallday.h" @@ -213,3 +214,7 @@ void DateBookDayViewQuickLineEdit::slotReturnPressed() } - this->close(true); // Close and also delete this widget + /* we need to return to this object.. */ + QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget +} +void DateBookDayViewQuickLineEdit::finallyCallClose() { + close(true); // also deletes this widget... } @@ -229,2 +234,6 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWid header->setDate( currDate.year(), currDate.month(), currDate.day() ); + + m_allDays = new DatebookdayAllday(newDb, this, "all day event list" ); + m_allDays->hide(); + view = new DateBookDayView( ampm, this, "day view" ); @@ -247,2 +256,3 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWid rowStyle = -1; // initialize with bogus values + jumpToCurTime = false; } @@ -345,4 +355,9 @@ void DateBookDay::getEvents() + /* clear the AllDay List */ + m_allDays->hide(); // just in case + m_allDays->removeAllEvents(); + QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); QValueListIterator<EffectiveEvent> it; + QObject* object = 0; for ( it = eventList.begin(); it != eventList.end(); ++it ) { @@ -350,8 +365,17 @@ void DateBookDay::getEvents() if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day. + if (ev.event().type() == Event::AllDay ) { + object = m_allDays->addEvent( ev ); + if (!object) + continue; + }else { DateBookDayWidget* w = new DateBookDayWidget( *it, this ); - connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); - connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); - connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); - connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); - widgetList.append( w ); + widgetList.append( w ); + object = w; + } + + connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); + connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); + connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); + connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); + } @@ -398,5 +422,12 @@ void DateBookDay::relayoutPage( bool fromResize ) setUpdatesEnabled( FALSE ); - if ( !fromResize ) + if ( !fromResize ) { getEvents(); // no need we already have them! + if (m_allDays->items() > 0 ) + m_allDays->show(); + /* + * else if ( m_allDays->items() == 0 ) already hide in getEvents + */ + } + widgetList.sort(); @@ -732,2 +763,24 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e ) +/* + * we need to find the real start date for a uid + * we need to check from one day to another... + */ +QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) { + QDate dt( isIncluded ); + QDate fnd = dt; + + bool doAgain = true; + do{ + dt = dt.addDays( -1 ); + QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt ); + for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) { + EffectiveEvent ev = (*it); + if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) ) + return ev.date(); + } + }while (doAgain ); + + return fnd; +} + void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) @@ -749,2 +802,3 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); + if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 ); int r = m.exec( e->globalPos() ); @@ -758,3 +812,60 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) emit duplicateMe( ev.event() ); - } + } else if ( r == 5 ) { + // create an Event and beam it... + /* + * Start with the easy stuff. If start and end date is the same we can just use + * the values of effective events + * If it is a multi day event we need to find the real start and end date... + */ + if ( ev.event().start().date() == ev.event().end().date() ) { + Event event( ev.event() ); + + QDateTime dt( ev.date(), ev.start() ); + event.setStart( dt ); + + dt.setTime( ev.end() ); + event.setEnd( dt ); + emit beamMe( event ); + }else { + /* + * at least the the Times are right now + */ + QDateTime start( ev.event().start() ); + QDateTime end ( ev.event().end () ); + + + /* + * ok we know the start date or we need to find it + */ + if ( ev.start() != QTime( 0, 0, 0 ) ) { + start.setDate( ev.date() ); + }else { + QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db ); + start.setDate( dt ); + } + + + /* + * ok we know now the end date... + * else + * get to know the offset btw the real start and real end + * and then add it to the new start date... + */ + if ( ev.end() != QTime(23, 59, 59 ) ) { + end.setDate( ev.date() ); + }else{ + int days = ev.event().start().date().daysTo( ev.event().end().date() ); + end.setDate( start.date().addDays( days ) ); + } + + + + Event event( ev.event() ); + event.setStart( start ); + event.setEnd ( end ); + + + emit beamMe( event ); + } + } } |