summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-31 16:29:05 (UTC)
committer zautrix <zautrix>2005-01-31 16:29:05 (UTC)
commitec037c4616342c1b3976c55db98b775f48e0d455 (patch) (side-by-side diff)
tree9d568c8f6ad6005f822c12644596b7a553837c7f
parent5d52c81be9b43887c13f8534a04164d3b44b821f (diff)
downloadkdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.zip
kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.gz
kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp165
-rw-r--r--korganizer/komonthview.h5
-rw-r--r--libkcal/calendarlocal.cpp1
-rw-r--r--libkcal/incidence.cpp3
4 files changed, 146 insertions, 28 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 770a42b..6646b98 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -393,14 +393,16 @@ void MonthViewCell::clear()
{
mItemList->clear();
QApplication::removePostedEvents ( mItemList );
QApplication::removePostedEvents ( mLabel );
QApplication::removePostedEvents ( this );
}
-void MonthViewCell::updateCell()
+
+void MonthViewCell::startUpdateCell()
{
+
if ( !mMonthView->isUpdatePossible() )
return;
/*
if ( !isVisible() ){
return;
}
@@ -415,31 +417,30 @@ void MonthViewCell::updateCell()
}
mItemList->clear();
#ifdef DESKTOP_VERSION
QToolTip::remove(this);
#endif
- QString tipText("");
+ mToolTip = "";
//qApp->processEvents();
if ( !mHolidayString.isEmpty() ) {
MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
item->setPalette( mHolidayPalette );
mItemList->insertItem( item );
- tipText += mHolidayString+"\n";
+ mToolTip += mHolidayString+"\n";
}
- //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
- QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
- Event *event;
- for( event = events.first(); event; event = events.next() ) { // for event
+}
+void MonthViewCell::insertEvent(Event *event)
+{
if ( !(event->doesRecur() == Recurrence::rNone) ) {
if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
- continue;
+ return;
else
if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
- continue;
+ return;
}
if ( event->categories().contains("Holiday") ||
event->categories().contains(i18n("Holiday"))) {
setHoliday( true );
if ( mDate.dayOfWeek() == 7 )
@@ -462,22 +463,22 @@ void MonthViewCell::updateCell()
prefix ="->" ;
} else if (mDate == event->dtEnd().date()) {
prefix ="<-" ;
}
}
text = prefix + event->summary();
- tipText += text;
+ mToolTip += text;
} else {
if (event->doesFloat()) {
text = event->summary();
- tipText += text;
+ mToolTip += text;
}
else {
text = KGlobal::locale()->formatTime(event->dtStart().time());
text += " " + event->summary();
- tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
+ mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
}
}
MonthViewItem *item = new MonthViewItem( event, mDate, text );
QPalette pal;
if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
@@ -515,21 +516,17 @@ void MonthViewCell::updateCell()
else
item->setReply(false);
} else
item->setReply(false);
#endif
mItemList->insertItem( item );
- tipText += "\n";
-
- }
-
- // insert due todos
- QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
- Todo *todo;
- for(todo = todos.first(); todo; todo = todos.next()) {
- QString text;
+ mToolTip += "\n";
+}
+void MonthViewCell::insertTodo(Todo *todo)
+{
+ QString text;
if (todo->hasDueDate()) {
if (!todo->doesFloat()) {
text += KGlobal::locale()->formatTime(todo->dtDue().time());
text += " ";
}
}
@@ -559,17 +556,19 @@ void MonthViewCell::updateCell()
} else {
pal = mStandardPalette ;
}
item->setPalette( pal );
mItemList->insertItem( item );
- tipText += text+"\n";
- }
+ mToolTip += text+"\n";
+}
+void MonthViewCell::finishUpdateCell()
+{
#ifdef DESKTOP_VERSION
- if (tipText != "")
- QToolTip::add(this,tipText,toolTipGroup(),"");
+ if (mToolTip != "")
+ QToolTip::add(this,mToolTip,toolTipGroup(),"");
#endif
//setMyPalette();
setMyPalette();
QString text;
bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
@@ -581,19 +580,38 @@ void MonthViewCell::updateCell()
mLabel->resize( mLabelSize );
text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
}
mLabel->setText( text );
resizeEvent( 0 );
+}
+void MonthViewCell::updateCell()
+{
+ if ( !mMonthView->isUpdatePossible() )
+ return;
+ startUpdateCell();
+ //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
+ QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
+ Event *event;
+ for( event = events.first(); event; event = events.next() ) { // for event
+ insertEvent(event);
+ }
+ // insert due todos
+ QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
+ Todo *todo;
+ for(todo = todos.first(); todo; todo = todos.next()) {
+ insertTodo( todo );
+ }
+ finishUpdateCell();
// if ( isVisible())
//qApp->processEvents();
}
void MonthViewCell::updateConfig()
{
-
+ qDebug("MonthViewCell::updateConfig() ");
setFont( KOPrefs::instance()->mMonthViewFont );
QFontMetrics fm( font() );
mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
mHolidayPalette = mStandardPalette;
@@ -955,22 +973,117 @@ void KOMonthView::changeEventDisplay(Event *, int)
void KOMonthView::updateView()
{
if ( !updatePossible )
return;
+ QTime ti;
+ ti.start();
+#if 1
+ int i;
+ for( i = 0; i < mCells.count(); ++i ) {
+ mCells[i]->startUpdateCell();
+ }
+
+ QPtrList<Event> events = calendar()->events();
+ Event *event;
+ QDateTime dt;
+ bool ok;
+ int timeSpan = mCells.size()-1;
+ QDate endDate = mStartDate.addDays( timeSpan );
+ for( event = events.first(); event; event = events.next() ) { // for event
+ if ( event->doesRecur() ) {
+ bool last;
+ QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
+ QDateTime incidenceEnd;
+ int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
+ bool invalid = false;
+ while( true ) {
+ if ( incidenceStart.isValid() ) {
+ incidenceEnd = incidenceStart.addDays( eventlen );
+ int st = incidenceStart.date().daysTo( endDate );
+ if ( st >= 0 ) { // start before timeend
+ int end = mStartDate.daysTo( incidenceEnd.date() );
+ if ( end >= 0 ) { // end after timestart --- got one!
+ //normalize
+ st = timeSpan - st;
+ if ( st < 0 ) st = 0;
+ if ( end > timeSpan ) end = timeSpan;
+ int iii;
+ //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
+ for ( iii = st;iii<= end;++iii)
+ mCells[iii]->insertEvent( event );
+ }
+ }
+ } else {
+ if ( invalid )
+ break;
+ invalid = true;
+ //qDebug("invalid %s", event->summary().latin1());
+ incidenceStart = QDateTime( mStartDate );
+ }
+ if ( last )
+ break;
+ bool ok;
+ incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
+ if ( ! ok )
+ break;
+ if ( incidenceStart.date() > endDate )
+ break;
+ }
+ } else { // no recur
+ int st = event->dtStart().date().daysTo( endDate );
+ if ( st >= 0 ) { // start before timeend
+ int end = mStartDate.daysTo( event->dtEnd().date() );
+ if ( end >= 0 ) { // end after timestart --- got one!
+ //normalize
+ st = timeSpan - st;
+ if ( st < 0 ) st = 0;
+ if ( end > timeSpan ) end = timeSpan;
+ int iii;
+ for ( iii = st;iii<= end;++iii)
+ mCells[iii]->insertEvent( event );
+ }
+ }
+ }
+ }
+ // insert due todos
+ QPtrList<Todo> todos = calendar()->todos( );
+ Todo *todo;
+ for(todo = todos.first(); todo; todo = todos.next()) {
+ //insertTodo( todo );
+ if ( todo->hasDueDate() ) {
+ int day = mStartDate.daysTo( todo->dtDue().date() );
+ if ( day >= 0 && day < mCells.size() ) {
+ mCells[day]->insertTodo( todo );
+ }
+ }
+ }
+
+ for( i = 0; i < mCells.count(); ++i ) {
+ mCells[i]->finishUpdateCell();
+ }
+ processSelectionChange();
+ mCells[0]->setFocus();
+
+
+#else
+ // old code
//qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
int i;
for( i = 0; i < mCells.count(); ++i ) {
mCells[i]->updateCell();
}
//qDebug("KOMonthView::updateView() ");
processSelectionChange();
// qDebug("---------------------------------------------------------------------+ ");
mCells[0]->setFocus();
+#endif
+
+ qDebug("update time %d ", ti.elapsed());
}
void KOMonthView::resizeEvent(QResizeEvent * e)
{
computeLayout();
mCells[0]->setFocus();
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 50903b3..b84065e 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -134,12 +134,16 @@ class MonthViewCell : public QWidget
bool isPrimary() const;
void setHoliday( bool );
void setHoliday( const QString & );
void updateCell();
+ void startUpdateCell();
+ void finishUpdateCell();
+ void insertEvent(Event *);
+ void insertTodo(Todo *);
void updateConfig();
void enableScrollBars( bool );
Incidence *selectedIncidence();
@@ -155,12 +159,13 @@ class MonthViewCell : public QWidget
signals:
void defaultAction( Incidence * );
void newEventSignal( QDateTime );
void showDaySignal( QDate );
protected:
+ QString mToolTip;
void resizeEvent( QResizeEvent * );
protected slots:
void defaultAction( QListBoxItem * );
void contextMenu( QListBoxItem * );
void selection( QListBoxItem * );
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 0eba6a9..e75154b 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -584,12 +584,13 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
}
QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
bool inclusive )
{
+ qDebug("CalendarLocal::rawEvents called ");
Event *event = 0;
QPtrList<Event> eventList;
// Get non-recurring events
for( event = mEventList.first(); event; event = mEventList.next() ) {
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 28402ae..f9e1e9e 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -589,13 +589,13 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
} else {
if ( last ) { // no alarm on last recurrence
return QDateTime ();
}
int year = incidenceStart.date().year();
// workaround for bug in recurrence
- if ( count == 100 || year < 1980 || year > 5000 ) {
+ if ( count == 100 || year < 1000 || year > 5000 ) {
return QDateTime ();
}
incidenceStart = incidenceStart.addSecs( 1 );
}
}
} else {
@@ -605,13 +605,12 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
if ( hasStartDate () ) {
incidenceStart = dtStart();
}
if ( type() =="Todo" ) {
if ( ((Todo*)this)->hasDueDate() )
incidenceStart = ((Todo*)this)->dtDue();
-
}
}
if ( incidenceStart > dt )
*ok = true;
return incidenceStart;
}