summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-19 15:39:43 (UTC)
committer zautrix <zautrix>2005-02-19 15:39:43 (UTC)
commit4858dcb045afc57ce98877cca787c4430146bea8 (patch) (side-by-side diff)
tree9c9ea4b6d93a34d4bea97d7cea0b294c9c8665de
parentd2ed2aaddb88f39f8b2ced18a4ea7f06a63237d3 (diff)
downloadkdepimpi-4858dcb045afc57ce98877cca787c4430146bea8.zip
kdepimpi-4858dcb045afc57ce98877cca787c4430146bea8.tar.gz
kdepimpi-4858dcb045afc57ce98877cca787c4430146bea8.tar.bz2
multiday fixes in monthview
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp91
-rw-r--r--korganizer/komonthview.h2
2 files changed, 69 insertions, 24 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 2fe80af..f558084 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -211,85 +211,124 @@ void MonthViewItem::paint(QPainter *p)
#else
bool sel = selected();
#endif
if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
{
p->setBackgroundColor( palette().color( QPalette::Normal, \
sel ? QColorGroup::Highlight : QColorGroup::Background ) );
p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
}
int x = 1;
- int y = 3;//(height() - mRecurPixmap.height()) /2;
+ //int y = 3;//(height() - mRecurPixmap.height()) /2;
int size = PIXMAP_SIZE;
if ( QApplication::desktop()->width() < 300 )
size = 3;
+ int y = (height( listBox () ) - size -1 ) /2;
+
if ( KOPrefs::instance()->mMonthShowIcons ) {
if ( mInfo ) {
p->fillRect ( x, y,size,size, Qt::darkGreen );
x += size + 1;
}
if ( mRecur ) {
p->fillRect ( x, y,size,size, Qt::blue );
x += size + 1;
}
if ( mAlarm ) {
p->fillRect ( x, y,size,size, Qt::red );
x += size + 1;
}
if ( mReply ) {
p->fillRect ( x, y,size,size, Qt::yellow );
x += size + 1;
}
}
+ if ( mMultiday ) {
+ int yyy = y+(size/2);
+ int sizeM = size+2;
+ p->setBrush( QBrush::SolidPattern );
+ p->drawLine ( x+sizeM/2, yyy, x +sizeM +sizeM/2-2, yyy ) ;
+ if ( mMultiday == 2 || mMultiday == 3 ) {
+ QPointArray pa ( 3 );
+ pa.setPoint (0, x, yyy );
+ pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
+ pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
+ p->drawPolygon( pa );
+ }
+ if ( mMultiday == 2 || mMultiday == 1 ) {
+ QPointArray pa ( 3 );
+ pa.setPoint (0, x+sizeM +sizeM/2, yyy );
+ pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
+ pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
+ p->drawPolygon( pa );
+ }
+ if ( mMultiday == 1 ) {
+ p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
+
+ }
+ if ( mMultiday == 3 ) {
+ p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
+
+ }
+ x += sizeM/2 + 1;
+ x += sizeM + 1;
+ }
QFontMetrics fm = p->fontMetrics();
int yPos;
int pmheight = size;
if( pmheight < fm.height() )
yPos = fm.ascent() + fm.leading()/2;
else
yPos = pmheight/2 - fm.height()/2 + fm.ascent();
p->setPen( palette().color( QPalette::Normal, sel ? \
QColorGroup::HighlightedText : QColorGroup::Foreground ) );
p->drawText( x, yPos, text() );
if ( mIncidence->cancelled() ) {
int wid = fm.width( text() );
p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3);
}
}
int MonthViewItem::height(const QListBox *lb) const
{
- return lb->fontMetrics().lineSpacing()+1;
+ if ( lb )
+ return lb->fontMetrics().lineSpacing()+1;
+ return 10;
}
int MonthViewItem::width(const QListBox *lb) const
{
int size = PIXMAP_SIZE;
if ( QApplication::desktop()->width() < 300 )
size = 3;
int x = 1;
- if ( mInfo ) {
- x += size + 1;
- }
- if( mRecur ) {
- x += size+1;
- }
- if( mAlarm ) {
- x += size+1;
+ if ( KOPrefs::instance()->mMonthShowIcons ) {
+ if ( mInfo ) {
+ x += size + 1;
+ }
+ if( mRecur ) {
+ x += size+1;
+ }
+ if( mAlarm ) {
+ x += size+1;
+ }
+ if( mReply ) {
+ x += size+1;
+ }
}
- if( mReply ) {
- x += size+1;
+ if( mMultiday ) {
+ x += size+1+2+size/2;
}
return( x + lb->fontMetrics().width( text() ) + 1 );
}
MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
: QWidget( par ),
mMonthView( parent )
{
QVBoxLayout *topLayout = new QVBoxLayout( this );
@@ -455,51 +494,54 @@ void MonthViewCell::insertEvent(Event *event)
else
if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
return;
}
if ( event->categories().contains("Holiday") ||
event->categories().contains(i18n("Holiday"))) {
setHoliday( true );
if ( mDate.dayOfWeek() == 7 )
mItemList->setLineWidth( 3 );
}
QString text;
+ int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
if (event->isMultiDay()) {
- QString prefix = "<->";
+ QString prefix = "<->";multiday = 2;
+ QString time;
if ( event->doesRecur() ) {
- if ( event->recursOn( mDate) )
- prefix ="->" ;
+ if ( event->recursOn( mDate) ) {
+ prefix ="->" ;multiday = 1;
+ }
else {
int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
if ( event->recursOn( mDate.addDays( -days)) )
- prefix ="<-" ;
+ prefix ="<-" ;multiday = 3;
}
} else {
if (mDate == event->dtStart().date()) {
- prefix ="->" ;
+ prefix ="->" ;multiday = 1;
} else if (mDate == event->dtEnd().date()) {
- prefix ="<-" ;
+ prefix ="<-" ;multiday = 3;
}
}
if ( !event->doesFloat() ) {
if ( mDate == event->dtStart().date () )
- prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" ";
+ time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
else if ( mDate == event->dtEnd().date () )
- prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
+ time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
}
- text = prefix + event->summary();
- mToolTip += text;
+ text = time + event->summary();
+ mToolTip += prefix + text;
} else {
if (event->doesFloat()) {
text = event->summary();
mToolTip += text;
}
else {
text = KGlobal::locale()->formatTime(event->dtStart().time());
text += " " + event->summary();
mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
}
}
@@ -520,37 +562,38 @@ void MonthViewCell::insertEvent(Event *event)
if (cat.isEmpty()) {
pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
} else {
pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
}
}
} else {
pal = mStandardPalette ;
}
item->setPalette( pal );
item->setRecur( event->recurrence()->doesRecur() );
- item->setAlarm( event->isAlarmEnabled() );
+ item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
item->setMoreInfo( event->description().length() > 0 );
#ifdef DESKTOP_VERSION
Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
KOPrefs::instance()->email());
if ( me != 0 ) {
if ( me->status() == Attendee::NeedsAction && me->RSVP())
- item->setReply(true);
+ item->setReply(true && multiday < 2);
else
item->setReply(false);
} else
item->setReply(false);
#endif
+ item->setMultiDay( multiday );
mItemList->insertItem( item );
mToolTip += "\n";
}
void MonthViewCell::insertTodo(Todo *todo)
{
mItemList->setFocusPolicy(WheelFocus);
QString text;
if (todo->hasDueDate()) {
if (!todo->doesFloat()) {
text += KGlobal::locale()->formatTime(todo->dtDue().time());
text += " ";
}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 2f6f5dc..b79a41f 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -88,38 +88,40 @@ class KNoScrollListBox: public QListBox
};
class MonthViewItem: public QListBoxItem
{
public:
MonthViewItem( Incidence *, QDate qd, const QString & title );
void setRecur(bool on) { mRecur = on; }
void setAlarm(bool on) { mAlarm = on; }
void setReply(bool on) { mReply = on; }
void setMoreInfo(bool on) { mInfo = on; }
+ void setMultiDay(int type) { mMultiday = type; }
void setPalette(const QPalette &p) { mPalette = p; }
QPalette palette() const { return mPalette; }
Incidence *incidence() const { return mIncidence; }
QDate incidenceDate() { return mDate; }
protected:
virtual void paint(QPainter *);
virtual int height(const QListBox *) const;
virtual int width(const QListBox *) const;
private:
+ int mMultiday;
bool mRecur;
bool mAlarm;
bool mReply;
bool mInfo;
QPalette mPalette;
QDate mDate;
Incidence *mIncidence;
};