summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-05 09:30:00 (UTC)
committer zautrix <zautrix>2005-04-05 09:30:00 (UTC)
commit53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216 (patch) (side-by-side diff)
tree8dfcb059271cbfd4e28425d85dea747aa998594d
parent768858848f466a726e2f50b777345976828cc2ff (diff)
downloadkdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.zip
kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.gz
kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp144
-rw-r--r--korganizer/kodaymatrix.h2
-rw-r--r--korganizer/komonthview.cpp34
-rw-r--r--korganizer/komonthview.h6
4 files changed, 173 insertions, 13 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c7e1b45..322131f 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -119,6 +119,7 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
mouseDown = false;
// initialize dynamic arrays
bDays.resize ( NUMDAYS );
+ pDays.resize ( NUMDAYS );
hDays.resize ( NUMDAYS );
eDays.resize ( NUMDAYS );
days = new QDate[NUMDAYS];
@@ -340,11 +341,44 @@ void KODayMatrix::repaintViewTimed()
{
mRedrawNeeded = true;
bDays.fill( false);
+ pDays.fill( false);
hDays.fill( false);
eDays.fill( false);
mRepaintTimer->stop();
+ int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
+ int i;
+ for(i = 0; i < NUMDAYS; i++) {
+ if ( ( (i+startDay) % 7 == 0 ) ) {
+ pDays.setBit(i);
+ }
+ }
repaint(false);
}
+void KODayMatrix::computeEvent(Event *event, int i )
+{
+ QString holiStr = mHolidays[i];
+ if ( event->isHoliday()) {
+ pDays.setBit(i);
+ hDays.setBit(i);
+ if ( !holiStr.isEmpty() )
+ holiStr += "\n";
+ holiStr += event->summary();
+ if ( !event->location().isEmpty() )
+ holiStr += " (" + event->location() + ")";
+ mHolidays[i] =holiStr ;
+ }
+ if ( event->isBirthday()) {
+ pDays.setBit(i);
+ if ( !holiStr.isEmpty() )
+ holiStr += "\n";
+ holiStr += i18n("Birthday") + ": "+event->summary();
+ if ( !event->location().isEmpty() )
+ holiStr += " (" + event->location() + ")";
+ bDays.setBit(i);
+ mHolidays[i] =holiStr ;
+ }
+ eDays.setBit(i);
+}
void KODayMatrix::updateViewTimed()
{
mUpdateTimer->stop();
@@ -352,6 +386,106 @@ void KODayMatrix::updateViewTimed()
qDebug("NOT CAL ");
return;
}
+#if 1
+
+ int i;
+ int timeSpan = NUMDAYS-1;
+ QPtrList<Event> events = mCalendar->events();
+ Event *event;
+ QDateTime dt;
+ bool ok;
+ bDays.fill( false);
+ pDays.fill( false);
+ hDays.fill( false);
+ eDays.fill( false);
+ mHolidays.clear();
+ QDate mStartDate = days[0];
+ QDate endDate = mStartDate.addDays( timeSpan );
+ for( event = events.first(); event; event = events.next() ) { // for event
+ ushort recurType = event->recurrence()->doesRecur();
+ if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
+ (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
+ continue;
+ }
+ 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) {
+ computeEvent( event, iii );
+ }
+ }
+ }
+ } else {
+ if ( invalid )
+ break;
+ invalid = true;
+ //qDebug("invalid %s", event->summary().latin1());
+ incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
+ }
+ 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)
+ computeEvent( event, iii );
+ }
+ }
+ }
+ }
+ int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
+ for(i = 0; i < NUMDAYS; i++) {
+ if ( ( (i+startDay) % 7 == 0 ) ) {
+ pDays.setBit(i);
+ }
+ }
+
+#if 0
+ // 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 < timeSpan + 1) {
+ (*cells)[day]->insertTodo( todo );
+ }
+ }
+ }
+#endif
+
+#else
//qDebug("KODayMatrix::updateViewTimed ");
for(int i = 0; i < NUMDAYS; i++) {
// if events are set for the day then remember to draw it bold
@@ -363,6 +497,7 @@ void KODayMatrix::updateViewTimed()
hDays.clearBit(i);
eDays.clearBit(i);
for(event=eventlist.first();event != 0;event=eventlist.next()) {
+ qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
ushort recurType = event->recurrence()->doesRecur();
if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
(recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
@@ -395,6 +530,7 @@ void KODayMatrix::updateViewTimed()
mHolidays[i] = QString::null;
}
}
+#endif
mRedrawNeeded = true;
if ( ! mPendingUpdateBeforeRepaint )
repaint(false);
@@ -442,7 +578,7 @@ void KODayMatrix::updateView(QDate actdate)
mUpdateTimer->start( 50 );
#else
mRepaintTimer->start( 350 );
- mUpdateTimer->start( 1200 );
+ mUpdateTimer->start( 800 );
#endif
}
}
@@ -873,7 +1009,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
else
mTodayPen.setWidth(mTodayMarginWidth);
//draw red rectangle for holidays
- if (!mHolidays[i].isNull()) {
+ if (pDays.testBit(i)) {
if (actcol == mDefaultTextColor) {
mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
} else {
@@ -914,7 +1050,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
}
// if it is a holiday then use the default holiday color
- if ( !mHolidays[i].isNull()) {
+ if ( pDays.testBit(i)) {
if ( bDays.testBit(i) ) {
if ( hDays.testBit(i) )
p.setPen(QColor(Qt::green));
@@ -953,7 +1089,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
// reset color to actual color
- if (!mHolidays[i].isNull()) {
+ if (pDays.testBit(i)) {
p.setPen(actcol);
}
// reset bold font to plain font
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index d725ead..b686bd7 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -227,6 +227,7 @@ protected:
void resizeEvent(QResizeEvent *);
private:
+ void computeEvent(Event *even, int dayindex );
int oldW, oldH;
bool mRedrawNeeded;
KODaymatrixWhatsThis* mKODaymatrixWhatsThis;
@@ -234,6 +235,7 @@ private:
QBitArray bDays;
QBitArray hDays;
QBitArray eDays;
+ QBitArray pDays;
QPixmap myPix;
QTimer* mUpdateTimer;
QTimer* mRepaintTimer;
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 1ed288b..425496a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -269,6 +269,7 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
mAlarm = false;
mReply = false;
mInfo = false;
+ mdayPos = 0;
isWeekItem = KOPrefs::instance()->mMonthViewWeek;
//qDebug("NEWWWWWWWWWWWWW ");
}
@@ -281,7 +282,8 @@ void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
mRecur = false;
mAlarm = false;
mReply = false;
- mInfo = false;
+ mInfo = false;
+ mdayPos = 0;
//qDebug("recucleeeeeeeeeeeeeeeee ");
}
@@ -570,7 +572,7 @@ void MonthViewCell::setHoliday( const QString &holiday )
void MonthViewCell::startUpdateCell()
{
-
+ mdayCount = 0;
setFocusPolicy(NoFocus);
if ( !mMonthView->isUpdatePossible() )
return;
@@ -621,16 +623,16 @@ void MonthViewCell::startUpdateCell()
#endif
}
-void MonthViewCell::insertEvent(Event *event)
+int MonthViewCell::insertEvent(Event *event)
{
QString mToolTipText;
setFocusPolicy(WheelFocus);
if ( !(event->doesRecur() == Recurrence::rNone) ) {
if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
- return;
+ return mdayCount;
else
if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
- return;
+ return mdayCount;
}
if ( event->isHoliday()) {
@@ -730,8 +732,24 @@ void MonthViewCell::insertEvent(Event *event)
item->setReply(false);
#endif
item->setMultiDay( multiday );
- insertItem( item );
+ if ( multiday ) {
+ insertItem( item ,mdayCount);
+ ++mdayCount;
+ } else {
+ uint i;
+ int pos = mdayCount;
+ for ( i = mdayCount; i < count();++i ) {
+ QListBoxItem* it = this->item ( i );
+ if ( text < it->text() ) {
+ pos = i;
+ break;
+ }
+ ++pos;
+ }
+ insertItem( item ,pos);
+ }
mToolTip.append( mToolTipText );
+ return mdayCount;
}
void MonthViewCell::insertTodo(Todo *todo)
{
@@ -781,7 +799,7 @@ void MonthViewCell::insertTodo(Todo *todo)
item->setRecur( todo->recurrence()->doesRecur() );
item->setAlarm( todo->isAlarmEnabled() );
item->setMoreInfo( todo->description().length() > 0 );
- insertItem( item );
+ insertItem( item , count());
mToolTip.append( text );
}
void MonthViewCell::repaintfinishUpdateCell()
@@ -804,7 +822,7 @@ void MonthViewCell::finishUpdateCell()
QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
}
#endif
- sort();
+ //sort();
//setMyPalette();
setMyPalette();
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e962756..e39eeb0 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -108,6 +108,8 @@ class MonthViewItem: public QListBoxItem
void setReply(bool on) { mReply = on; }
void setMoreInfo(bool on) { mInfo = on; }
void setMultiDay(int type) { mMultiday = type; }
+ void setMultiDayPos(int type) { mdayPos = type; }
+ int gettMultiDayPos() { return mdayPos; }
void setBlockRepaint(bool on) { mblockRepaint = on; }
@@ -123,6 +125,7 @@ class MonthViewItem: public QListBoxItem
virtual int width(const QListBox *) const;
private:
+ int mdayPos;
bool isWeekItem;
bool mblockRepaint;
int mMultiday;
@@ -160,7 +163,7 @@ class MonthViewCell : public KNoScrollListBox
void startUpdateCell();
void finishUpdateCell();
void repaintfinishUpdateCell();
- void insertEvent(Event *);
+ int insertEvent(Event *);
void insertTodo(Todo *);
void updateConfig( bool bigFont = false );
@@ -197,6 +200,7 @@ public slots:
void newEvent();
private:
+ int mdayCount;
QPtrList <MonthViewItem> mAvailItemList;
KOMonthView *mMonthView;
int currentPalette;