summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookday.cpp
authoreilers <eilers>2003-08-01 14:19:44 (UTC)
committer eilers <eilers>2003-08-01 14:19:44 (UTC)
commit34991bac7d96b1c17601be6a5607819342571e0c (patch) (unidiff)
tree65d0bc2db22bcc1dc1b5eafdafd53b9cb08a6395 /core/pim/datebook/datebookday.cpp
parent5346424fc26bde232a15aa34fbb720f86218b26f (diff)
downloadopie-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.cpp127
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 @@
23#include "datebookdayheaderimpl.h" 23#include "datebookdayheaderimpl.h"
24#include "datebookdayallday.h"
24 25
@@ -213,3 +214,7 @@ void DateBookDayViewQuickLineEdit::slotReturnPressed()
213 } 214 }
214 this->close(true);// Close and also delete this widget 215 /* we need to return to this object.. */
216 QTimer::singleShot(500, this, SLOT(finallyCallClose()) );// Close and also delete this widget
217}
218void DateBookDayViewQuickLineEdit::finallyCallClose() {
219 close(true); // also deletes this widget...
215} 220}
@@ -229,2 +234,6 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWid
229 header->setDate( currDate.year(), currDate.month(), currDate.day() ); 234 header->setDate( currDate.year(), currDate.month(), currDate.day() );
235
236 m_allDays = new DatebookdayAllday(newDb, this, "all day event list" );
237 m_allDays->hide();
238
230 view = new DateBookDayView( ampm, this, "day view" ); 239 view = new DateBookDayView( ampm, this, "day view" );
@@ -247,2 +256,3 @@ DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWid
247 rowStyle = -1; // initialize with bogus values 256 rowStyle = -1; // initialize with bogus values
257 jumpToCurTime = false;
248} 258}
@@ -345,4 +355,9 @@ void DateBookDay::getEvents()
345 355
356 /* clear the AllDay List */
357 m_allDays->hide(); // just in case
358 m_allDays->removeAllEvents();
359
346 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); 360 QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
347 QValueListIterator<EffectiveEvent> it; 361 QValueListIterator<EffectiveEvent> it;
362 QObject* object = 0;
348 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 363 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
@@ -350,8 +365,17 @@ void DateBookDay::getEvents()
350 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day. 365 if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) {// Skip events ending at 00:00 starting at another day.
366 if (ev.event().type() == Event::AllDay ) {
367 object = m_allDays->addEvent( ev );
368 if (!object)
369 continue;
370 }else {
351 DateBookDayWidget* w = new DateBookDayWidget( *it, this ); 371 DateBookDayWidget* w = new DateBookDayWidget( *it, this );
352 connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); 372 widgetList.append( w );
353 connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); 373 object = w;
354 connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); 374 }
355 connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); 375
356 widgetList.append( w ); 376 connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) );
377 connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) );
378 connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) );
379 connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) );
380
357 } 381 }
@@ -398,5 +422,12 @@ void DateBookDay::relayoutPage( bool fromResize )
398 setUpdatesEnabled( FALSE ); 422 setUpdatesEnabled( FALSE );
399 if ( !fromResize ) 423 if ( !fromResize ) {
400 getEvents(); // no need we already have them! 424 getEvents(); // no need we already have them!
401 425
426 if (m_allDays->items() > 0 )
427 m_allDays->show();
428 /*
429 * else if ( m_allDays->items() == 0 ) already hide in getEvents
430 */
431 }
432
402 widgetList.sort(); 433 widgetList.sort();
@@ -732,2 +763,24 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e )
732 763
764/*
765 * we need to find the real start date for a uid
766 * we need to check from one day to another...
767 */
768QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) {
769 QDate dt( isIncluded );
770 QDate fnd = dt;
771
772 bool doAgain = true;
773 do{
774 dt = dt.addDays( -1 );
775 QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt );
776 for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) {
777 EffectiveEvent ev = (*it);
778 if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) )
779 return ev.date();
780 }
781 }while (doAgain );
782
783 return fnd;
784}
785
733void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) 786void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
@@ -749,2 +802,3 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
749 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); 802 if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
803 if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 );
750 int r = m.exec( e->globalPos() ); 804 int r = m.exec( e->globalPos() );
@@ -758,3 +812,60 @@ void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
758 emit duplicateMe( ev.event() ); 812 emit duplicateMe( ev.event() );
759 } 813 } else if ( r == 5 ) {
814 // create an Event and beam it...
815 /*
816 * Start with the easy stuff. If start and end date is the same we can just use
817 * the values of effective events
818 * If it is a multi day event we need to find the real start and end date...
819 */
820 if ( ev.event().start().date() == ev.event().end().date() ) {
821 Event event( ev.event() );
822
823 QDateTime dt( ev.date(), ev.start() );
824 event.setStart( dt );
825
826 dt.setTime( ev.end() );
827 event.setEnd( dt );
828 emit beamMe( event );
829 }else {
830 /*
831 * at least the the Times are right now
832 */
833 QDateTime start( ev.event().start() );
834 QDateTime end ( ev.event().end () );
835
836
837 /*
838 * ok we know the start date or we need to find it
839 */
840 if ( ev.start() != QTime( 0, 0, 0 ) ) {
841 start.setDate( ev.date() );
842 }else {
843 QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db );
844 start.setDate( dt );
845 }
846
847
848 /*
849 * ok we know now the end date...
850 * else
851 * get to know the offset btw the real start and real end
852 * and then add it to the new start date...
853 */
854 if ( ev.end() != QTime(23, 59, 59 ) ) {
855 end.setDate( ev.date() );
856 }else{
857 int days = ev.event().start().date().daysTo( ev.event().end().date() );
858 end.setDate( start.date().addDays( days ) );
859 }
860
861
862
863 Event event( ev.event() );
864 event.setStart( start );
865 event.setEnd ( end );
866
867
868 emit beamMe( event );
869 }
870 }
760} 871}