-rw-r--r-- | core/pim/datebook/datebook.cpp | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 706cc08..832b2f8 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -165,49 +165,48 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); a->addTo( sub_bar ); if(defaultView==DAY) viewDay(); if(defaultView==WEEK) needEvilHack=true; // viewWeek(); if(defaultView==WEEKLST) viewWeekLst(); if(defaultView==MONTH) viewMonth(); 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"); #endif #endif qDebug("done t=%d", t.elapsed() ); connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); /* * Here is a problem description: * When Weekview is the default view * a DateBookWeekView get's created * redraw() get's called. So what? * Remember that we're still in the c'tor * and no final layout has happened? Ok * now all Events get arranged. Their x * position get's determined by a QHeader * position. But the QHeader isn't layouted or * at the right position. redraw() is a slot * so we'll call it then via a singleShot * from view() */ if( needEvilHack ){ QTimer::singleShot( 500, this, SLOT(viewWeek()) ); } @@ -388,49 +387,48 @@ void DateBook::viewWeek() { view(WEEK,currentDate()); } void DateBook::viewWeekLst() { view(WEEKLST,currentDate()); } void DateBook::viewMonth() { view(MONTH,currentDate()); } void DateBook::insertEvent( const Event &e ) { Event dupEvent=e; if(!dupEvent.isValidUid() ) // tkcRom seems to be different dupEvent.assignUid(); dupEvent.setLocation(defaultLocation); dupEvent.setCategories(defaultCategories); db->addEvent(dupEvent); emit newEvent(); } void DateBook::duplicateEvent( const Event &e ) { - qWarning("Hmmm..."); // Alot of code duplication, as this is almost like editEvent(); if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } Event dupevent(e); // Make a duplicate. // workaround added for text input. QDialog editDlg( this, 0, TRUE ); DateEntry *entry; editDlg.setCaption( tr("Duplicate Event") ); QVBoxLayout *vb = new QVBoxLayout( &editDlg ); QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); sv->setResizePolicy( QScrollView::AutoOneFit ); // KLUDGE!!! sv->setHScrollBarMode( QScrollView::AlwaysOff ); vb->addWidget( sv ); entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" ); entry->timezone->setEnabled( FALSE ); sv->addChild( entry ); while ( QPEApplication::execDialog( &editDlg ) ) { Event newEv = entry->event(); @@ -487,48 +485,49 @@ void DateBook::editEvent( const Event &e ) if (!error.isNull()) { if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue; } db->editEvent(e, newEv); emit newEvent(); break; } } void DateBook::removeEvent( const Event &e ) { if (syncing) { QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") ); return; } QString strName = e.description(); if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) return; db->removeEvent( e ); if ( views->visibleWidget() == dayView && dayView ) dayView->redraw(); + } void DateBook::addEvent( const Event &e ) { QDate d = e.start().date(); initDay(); dayView->setDate( d ); } void DateBook::showDay( int year, int month, int day ) { QDate d(year, month, day); view(DAY,d); } void DateBook::initDay() { if ( !dayView ) { dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); views->addWidget( dayView, DAY ); dayView->setJumpToCurTime( bJumpToCurTime ); dayView->setStartViewTime( startTime ); dayView->setRowStyle( rowStyle ); connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) ); @@ -970,82 +969,78 @@ bool catComp( QArray<int> cats, int category ) returnMe = true; else { for ( i = 0; i < count; i++ ) { if ( category == cats[i] ) { returnMe = true; break; } } } return returnMe; } void DateBook::slotDoFind( const QString& txt, const QDate &dt, bool caseSensitive, bool /*backwards*/, int category ) { QDateTime dtEnd( QDate(3001, 1, 1), QTime(0, 0, 0) ), next; QRegExp r( txt ); r.setCaseSensitive( caseSensitive ); - static Event rev, - nonrev; + static Event rev, nonrev; if ( !inSearch ) { rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); nonrev.setStart( rev.start() ); inSearch = true; } static QDate searchDate = dt; static bool wrapAround = true; bool candidtate; candidtate = false; QValueList<Event> repeats = db->getRawRepeats(); // find the candidate for the first repeat that matches... QValueListConstIterator<Event> it; QDate start = dt; for ( it = repeats.begin(); it != repeats.end(); ++it ) { if ( catComp( (*it).categories(), category ) ) { - while ( nextOccurance( *it, start, next ) ) { - if ( next < dtEnd ) { - if ( (*it).match( r ) && !(next <= rev.start()) ) { - rev = *it; - dtEnd = next; - rev.setStart( next ); - candidtate = true; - wrapAround = true; - start = dt; - break; - } else - start = next.date().addDays( 1 ); - } - } - } + if ( (*it).match( r ) ) { + if ( nextOccurance( *it, start, next ) ) { + if ( next < dtEnd && !(next <= rev.start() ) ) { + rev = *it; + dtEnd = next; + rev.setStart( next ); + candidtate = true; + wrapAround = true; + } + } + } + } } // now the for first non repeat... QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); qHeapSort( nonRepeats.begin(), nonRepeats.end() ); for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { if ( catComp( (*it).categories(), category ) ) { if ( (*it).start() < dtEnd ) { if ( (*it).match( r ) && !(*it <= nonrev) ) { nonrev = *it; dtEnd = nonrev.start(); candidtate = true; wrapAround = true; break; } } } } if ( candidtate ) { dayView->setStartViewTime( dtEnd.time().hour() ); dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), dtEnd.date().day() ); } else { if ( wrapAround ) { @@ -1054,29 +1049,27 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt, nonrev.setStart( rev.start() ); } else emit signalNotFound(); wrapAround = !wrapAround; } } 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 } - |