-rw-r--r-- | korganizer/komonthview.cpp | 65 | ||||
-rw-r--r-- | korganizer/komonthview.h | 4 |
2 files changed, 54 insertions, 15 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 1c2d6a2..264cf28 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -361,28 +361,42 @@ void MonthViewItem::paint(QPainter *p) 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 ( sel ) p->setPen( Qt::white ); + else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); + +#if 0 + p->setPen( palette().color( QPalette::Normal, sel ? \ + QColorGroup::HighlightedText : QColorGroup::Foreground ) ); +#endif + QColor textColor = p->pen().color(); + + if ( mMultiday ) { int yyy = y+(size/2); int sizeM = size+2; - p->setBrush( QBrush( p->pen().color() ) ); + p->setBrush( QBrush( textColor ) ); 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 ); @@ -403,38 +417,37 @@ void MonthViewItem::paint(QPainter *p) } 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,p->pen().color() ); + p->fillRect ( x+1, y-2, val ,size+4,textColor ); 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 ); if ( mIncidence->cancelled() ) { @@ -608,25 +621,25 @@ void MonthViewCell::setHoliday( bool holiday ) void MonthViewCell::setHoliday( const QString &holiday ) { mHolidayString = holiday; if ( !holiday.isEmpty() ) { setHoliday( true ); } } void MonthViewCell::startUpdateCell() { - + blockSignals( true ); mdayCount = 0; setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) return; MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { mitem->setBlockRepaint( true ); mitem = (MonthViewItem *)mitem->next(); } if ( mAvailItemList.count() > 20 ) { mAvailItemList.setAutoDelete( true ); mAvailItemList.clear(); @@ -872,24 +885,25 @@ void MonthViewCell::insertTodo(Todo *todo) #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(); } + blockSignals( false ); } void MonthViewCell::finishUpdateCell() { #ifdef DESKTOP_VERSION if (mToolTip.count() > 0 ) { mToolTip.sort(); QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); } #endif @@ -1017,33 +1031,32 @@ 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 ); + //mLabel->setText( text ); bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { - text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; + text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); mLabel->resize( mLabelBigSize ); - text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); } else { mLabel->resize( mLabelSize ); - text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); + text = QString::number( mDate.day() ); } mLabel->setText( text ); int size = height() - mLabel->height() - lineWidth()-1; //qDebug("LW %d ", lineWidth()); if ( size > 0 ) verticalScrollBar()->setMaximumHeight( size ); size = width() - mLabel->width() -lineWidth()-1; if ( size > 0 ) horizontalScrollBar()->setMaximumWidth( size ); mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); @@ -1328,71 +1341,96 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) mWidStack->raiseWidget( mWeekView ); else mWidStack->raiseWidget( mMonthView ); } KOMonthView::~KOMonthView() { delete mContextMenu; } void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) { - qDebug("11 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); static Incidence * lastInc = 0; static MonthViewCell * lastCell = 0; if ( lastInc == inc && lastCell == mc ) return; lastInc = inc; lastCell = mc; - qDebug("222 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); + //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); bool weekview = false; int index = 0; for (uint i = 0; i < mCellsW.count(); ++i) { if ( mCellsW[i] == mc ) { weekview = true; index = i; break; } } QPtrVector<MonthViewCell> *cells; if ( weekview ) cells = &mCellsW; else { for (uint i = 0; i < mCells.count(); ++i) { if ( mCells[i] == mc ) { index = i; break; } } cells = &mCells; } for (uint i = 0; i < (*cells).count(); ++i) { - (*cells)[i]->deHighLight(); + (*cells)[i]->deHighLight(); } if ( ! inc ) return; + + int count = (*cells).count(); + bool goLeft = (mday > 1 && index > 0); + bool goRight = (mday < 3 && mday > 0 && index < count -1); + for (uint iii = 1; iii < count; ++iii) { + if ( goLeft ) { + int left = index - iii; + if ( left >= 0 ) { + if ( (*cells)[(uint)left]->doHighLight(inc) ) + goLeft = false; + } else + goLeft = false; + } + if ( goRight ) { + int right = index + iii; + if ( right < count ) { + if ( (*cells)[right]->doHighLight(inc) ) + goRight = false; + + } else + goRight = false; + } + + } +#if 0 if ( mday > 1 && index > 0 ) for (int i = index-1; i >= 0; --i) { //qDebug("index %d iii %d ", index, i); if ( (*cells)[(uint)i]->doHighLight(inc) ) break; } if ( mday < 3 && mday > 0 && index < (*cells).count()-1) for (uint i = index+1; i < (*cells).count(); ++i) { if ( (*cells)[i]->doHighLight(inc) ) break; } +#endif } void KOMonthView::selectInternalWeekNum ( int n ) { switchView(); if ( !KOPrefs::instance()->mMonthViewWeek ) emit selectMonth (); else emit selectWeekNum ( n ); } int KOMonthView::currentWeek() @@ -1712,25 +1750,26 @@ void KOMonthView::updateView() if ( day >= 0 && day < timeSpan + 1) { (*cells)[day]->insertTodo( todo ); } } } for( i = 0; i < timeSpan+1; ++i ) { (*cells)[i]->finishUpdateCell(); } processSelectionChange(); //qApp->processEvents(); for( i = 0; i < timeSpan+1; ++i ) { - (*cells)[i]->repaintfinishUpdateCell(); + //(*cells)[i]->repaintfinishUpdateCell(); + QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); } setKeyBFocus(); #else // old code //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); int i; for( i = 0; i < (*cells).count(); ++i ) { (*cells)[i]->updateCell(); } //qDebug("KOMonthView::updateView() "); processSelectionChange(); diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 0f3aa54..0bd6b1c 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -158,53 +158,53 @@ class MonthViewCell : public KNoScrollListBox void setDate( const QDate & ); QDate date() const; void setPrimary( bool ); bool isPrimary() const; void setHoliday( bool ); void setHoliday( const QString & ); void updateCell(); void startUpdateCell(); void finishUpdateCell(); - void repaintfinishUpdateCell(); int insertEvent(Event *); void insertTodo(Todo *); void updateConfig( bool bigFont = false ); void enableScrollBars( bool ); Incidence *selectedIncidence(); QDate selectedIncidenceDate(); QPushButton * dateLabel() { return mLabel; } - void deHighLight(); bool doHighLight( Incidence *); void deselect(); void select(); #ifdef DESKTOP_VERSION static QToolTipGroup *toolTipGroup(); #endif signals: void defaultAction( Incidence * ); void newEventSignal( QDateTime ); void showDaySignal( QDate ); protected: QStringList mToolTip; void resizeEvent( QResizeEvent * ); public slots: void showDay(); + void deHighLight(); + void repaintfinishUpdateCell(); protected slots: void defaultAction( QListBoxItem * ); void contextMenu( QListBoxItem * ); void selection( QListBoxItem * ); void cellClicked( QListBoxItem * ); void newEvent(); private: int mdayCount; QPtrList <MonthViewItem> mAvailItemList; KOMonthView *mMonthView; int currentPalette; |