summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
authorzautrix <zautrix>2005-06-27 19:29:38 (UTC)
committer zautrix <zautrix>2005-06-27 19:29:38 (UTC)
commitd730e4b5cd81965f224b69efcc91dd58253f0b98 (patch) (side-by-side diff)
tree38874ec3d889bee7ab12a79a1ef690e6c47aac5f /korganizer/komonthview.cpp
parent427221638f1e652bd57a37835a1de0134266c3f7 (diff)
downloadkdepimpi-d730e4b5cd81965f224b69efcc91dd58253f0b98.zip
kdepimpi-d730e4b5cd81965f224b69efcc91dd58253f0b98.tar.gz
kdepimpi-d730e4b5cd81965f224b69efcc91dd58253f0b98.tar.bz2
fixes
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp57
1 files changed, 16 insertions, 41 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 00e5a6f..aeb3974 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -257,205 +257,184 @@ void KNoScrollListBox::oneDown()
}
}
}
}
void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Shift:
emit shiftUp();
break;
default:
break;
}
}
void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
{
QListBox::mousePressEvent(e);
if(e->button() == RightButton) {
emit rightClick();
}
}
-MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
+MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s)
: QListBoxItem()
{
- mDisplayHightlighted = false;
mblockRepaint = true;
- setText( s );
- mMultiday = 0;
- mIncidence = incidence;
- mDate = qd;
- mRecur = false;
- mAlarm = false;
- mReply = false;
- mInfo = false;
- mdayPos = 0;
isWeekItem = KOPrefs::instance()->mMonthViewWeek;
+ recycle( incidence, s );
}
-void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
+void MonthViewItem::recycle( Incidence *incidence, const QString & s)
{
mDisplayHightlighted = false;
setText( s );
mMultiday = 0;
mIncidence = incidence;
- mDate = qd;
- mRecur = false;
- mAlarm = false;
- mReply = false;
- mInfo = false;
- mdayPos = 0;
-}
-void MonthViewItem::clearData()
-{
- mDisplayHightlighted = false;
- setText( "" );
- mMultiday = 0;
- mIncidence = 0;
mRecur = false;
mAlarm = false;
mReply = false;
mInfo = false;
mdayPos = 0;
}
+
bool MonthViewItem::setHighlightedFalse()
{
if ( !mDisplayHightlighted )
return false;
mDisplayHightlighted = false;
return true;
}
bool MonthViewItem::setHighlighted( Incidence * inc )
{
if ( inc == mIncidence ) {
if ( mDisplayHightlighted )
return false;
mDisplayHightlighted = true;
return true;
} else {
if ( !mDisplayHightlighted )
return false;
mDisplayHightlighted = false;
return true;
}
return false;
}
void MonthViewItem::paint(QPainter *p)
{
- if ( mblockRepaint ) {
+ if ( mblockRepaint || !mIncidence ) {
return;
}
#if QT_VERSION >= 0x030000
bool sel = isSelected();
#else
bool sel = selected();
#endif
int heihei = height( listBox () );
int x = 1;
- if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted )
+ if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel )
{
if ( mDisplayHightlighted )
sel = true;
p->setBackgroundColor( palette().color( QPalette::Normal, \
sel ? QColorGroup::Highlight : QColorGroup::Background ) );
p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
}
//int y = 3;//(height() - mRecurPixmap.height()) /2;
int size = PIXMAP_SIZE;
if ( QApplication::desktop()->width() < 300 )
size = 3;
int y = (heihei - size -1 ) /2;
if ( mIncidence->calID() > 1 ) {
p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
p->drawRect ( x, y-2,size,size+4);
x += size + 1;
}
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->setBrush( QBrush( p->pen().color() ) );
p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, 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 ) );
p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
}
if ( mMultiday == 3 ) {
// p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
}
x += sizeM/2 + 1;
x += sizeM + 1;
}
if ( mIncidence->typeID() == todoID ){
Todo* td = ( Todo* ) mIncidence;
if ( td->isCompleted() ) {
int half = size/2;
p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
x += half+half + 4;
} else {
int val = td->percentComplete()/20;
- p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
+ p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() );
p->drawRect ( x, y-2,7,size+4);
x += size + 3;
}
}
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 ) );
if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
p->drawText( x, yPos, text() );
if ( mIncidence->cancelled() ) {
int wid = fm.width( text() );
p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
}
} else {
QString pText = text();
if( pText.mid(2,1) == ":" )
pText = pText.mid( 6 );
p->drawText( x, yPos, pText );
@@ -647,49 +626,49 @@ void MonthViewCell::startUpdateCell()
MonthViewItem *mitem = (MonthViewItem*) firstItem ();
while ( mitem ) {
mitem->setBlockRepaint( true );
mitem = (MonthViewItem *)mitem->next();
}
if ( mAvailItemList.count() > 20 ) {
mAvailItemList.setAutoDelete( true );
mAvailItemList.clear();
mAvailItemList.setAutoDelete( false );
clear();
}
setPrimary( mDate.month()%2 );
setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
if ( mDate == QDate::currentDate() ) {
setLineWidth( 3 );
} else {
setLineWidth( 1 );
}
MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
//clear();
while ( CurrentAvailItem ) {
MonthViewItem *item = CurrentAvailItem;
//item->setHighlightedFalse();
- item->clearData();
+ item->recycle( 0, "");
CurrentAvailItem = (MonthViewItem *)item->next();
mAvailItemList.append( item );
takeItem ( item );
}
#ifdef DESKTOP_VERSION
QToolTip::remove(this);
#endif
mToolTip.clear();
//qApp->processEvents();
#if 0
if ( !mHolidayString.isEmpty() ) {
MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
item->setPalette( mHolidayPalette );
insertItem( item );
mToolTip.append ( mHolidayString );
}
#endif
}
int MonthViewCell::insertEvent(Event *event)
{
bool useToolTips = true;
#ifndef DESKTOP_VERSION
@@ -743,78 +722,79 @@ int MonthViewCell::insertEvent(Event *event)
text = time + event->summary();
if ( useToolTips )
mToolTipText += prefix + text;
} else {
if (event->doesFloat()) {
text = event->summary();
if ( useToolTips )
mToolTipText += text;
}
else {
text = KGlobal::locale()->formatTime(event->dtStart().time());
text += " " + event->summary();
if ( useToolTips )
mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
}
}
if ( useToolTips && ! event->location().isEmpty() ) {
mToolTipText += " (" + event->location() +")";
}
MonthViewItem *item ;
if ( mAvailItemList.count() ) {
item = mAvailItemList.first();
mAvailItemList.remove( item );
- item->recycle( event, mDate, text );
+ item->recycle( event, text );
} else {
- item = new MonthViewItem( event, mDate, text );
+ item = new MonthViewItem( event, text );
}
QPalette pal;
if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
QStringList categories = event->categories();
QString cat = categories.first();
if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
pal = getPalette();
if (cat.isEmpty()) {
//pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
} else {
pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
}
} else {
if (cat.isEmpty()) {
//pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
} else {
pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
}
}
} else {
pal = mStandardPalette ;
}
+ pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
item->setPalette( pal );
item->setRecur( event->recurrence()->doesRecur() );
item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
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 && multiday < 2);
else
item->setReply(false);
} else
item->setReply(false);
#endif
item->setMultiDay( multiday );
if ( multiday ) {
insertItem( item ,mdayCount);
++mdayCount;
} else {
uint i = mdayCount;
uint pos = mdayCount;
uint itcount = count();
@@ -832,79 +812,80 @@ int MonthViewCell::insertEvent(Event *event)
++pos;
}
insertItem( item ,pos);
}
if ( useToolTips ) {
mToolTip.append( mToolTipText );
}
return mdayCount;
}
void MonthViewCell::insertTodo(Todo *todo)
{
setFocusPolicy(WheelFocus);
QString text;
if (todo->hasDueDate()) {
if (!todo->doesFloat()) {
text += KGlobal::locale()->formatTime(todo->dtDue().time());
text += " ";
}
}
text += todo->summary();
MonthViewItem *item ;
if ( mAvailItemList.count() ) {
item = mAvailItemList.first();
mAvailItemList.remove( item );
- item->recycle( todo, mDate, text );
+ item->recycle( todo, text );
} else {
- item = new MonthViewItem( todo, mDate, text );
+ item = new MonthViewItem( todo, text );
}
//MonthViewItem *item = new MonthViewItem( todo, mDate, text );
//item->setPalette( mStandardPalette );
QPalette pal;
if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
QStringList categories = todo->categories();
QString cat = categories.first();
if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
pal = getPalette();
if (cat.isEmpty()) {
//pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
} else {
pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
}
} else {
if (cat.isEmpty()) {
//pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
} else {
pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
}
}
} else {
pal = mStandardPalette ;
}
+ pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
item->setPalette( pal );
item->setRecur( todo->recurrence()->doesRecur() );
item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
item->setMoreInfo( todo->description().length() > 0 );
insertItem( item , count());
#ifdef DESKTOP_VERSION
mToolTip.append( text );
#endif
}
void MonthViewCell::repaintfinishUpdateCell()
{
MonthViewItem *mitem = (MonthViewItem*) firstItem ();
while ( mitem ) {
mitem->setBlockRepaint( false );
updateItem ( mitem );
mitem = (MonthViewItem *)mitem->next();
}
}
void MonthViewCell::finishUpdateCell()
{
#ifdef DESKTOP_VERSION
@@ -1002,55 +983,49 @@ void MonthViewCell::enableScrollBars( bool enabled )
} else {
setVScrollBarMode(QScrollView::AlwaysOff);
setHScrollBarMode(QScrollView::AlwaysOff);
}
}
Incidence *MonthViewCell::selectedIncidence()
{
int index = currentItem();
if ( index < 0 ) return 0;
MonthViewItem *mitem =
static_cast<MonthViewItem *>( item( index ) );
if ( !mitem ) return 0;
return mitem->incidence();
}
QDate MonthViewCell::selectedIncidenceDate()
{
QDate qd;
int index = currentItem();
if ( index < 0 ) return qd;
-
- MonthViewItem *mitem =
- static_cast<MonthViewItem *>( item( index ) );
-
- if ( !mitem ) return qd;
-
- return mitem->incidenceDate();
+ return mDate;
}
void MonthViewCell::deselect()
{
clearSelection();
enableScrollBars( false );
// updateCell();
}
void MonthViewCell::select()
{
;// updateCell();
}
void MonthViewCell::resizeEvent ( QResizeEvent * e )
{
if ( !mMonthView->isUpdatePossible() )
return;
//qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
deselect();
mLabel->setMaximumHeight( height() - lineWidth()*2 );
QString text;
mLabel->setText( text );
bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;