-rw-r--r-- | korganizer/komonthview.cpp | 30 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 32 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index f983ff9..4bf9dea 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -264,32 +264,48 @@ void MonthViewItem::paint(QPainter *p) 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->type() == "Todo" ){ + 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-1, val ,size+2,Qt::black ); + p->drawRect ( x, y-1,7,size+2); + 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 ) ); p->drawText( x, yPos, text() ); if ( mIncidence->cancelled() ) { int wid = fm.width( text() ); p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); } } @@ -589,33 +605,33 @@ void MonthViewCell::insertEvent(Event *event) 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 += " "; } } - text += i18n("T: %1").arg(todo->summary()); + text += todo->summary(); 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); } else { pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); } } else { @@ -648,33 +664,33 @@ void MonthViewCell::finishUpdateCell() QString 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 ) + " "; mLabel->resize( mLabelBigSize ); text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); } else { mLabel->resize( mLabelSize ); text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); } mLabel->setText( text ); resizeEvent( 0 ); } void MonthViewCell::updateCell() { - qDebug("MonthViewCell::updateCell() "); + //qDebug("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(); @@ -1205,32 +1221,33 @@ void KOMonthView::showEvents(QPtrList<Event>) } void KOMonthView::changeEventDisplay(Event *, int) { // this should be re-written to be much more efficient, but this // quick-and-dirty-hack gets the job done for right now. updateView(); } void KOMonthView::updateView() { if ( !updatePossible ) return; //QTime ti; //ti.start(); + clearSelection(); QPtrVector<MonthViewCell> *cells; if ( mShowWeekView ) { cells = &mCellsW; } else { cells = &mCells; } #if 1 int i; int timeSpan = (*cells).size()-1; if ( KOPrefs::instance()->mMonthViewWeek ) timeSpan = 6; for( i = 0; i < timeSpan + 1; ++i ) { (*cells)[i]->startUpdateCell(); } QPtrList<Event> events = calendar()->events(); @@ -1602,32 +1619,33 @@ void KOMonthView::setSelectedCell( MonthViewCell *cell ) mSelectedCell = cell; // if ( mSelectedCell ) // mSelectedCell->select(); if ( !mSelectedCell ) emit incidenceSelected( 0 ); else emit incidenceSelected( mSelectedCell->selectedIncidence() ); } void KOMonthView::processSelectionChange() { QPtrList<Incidence> incidences = selectedIncidences(); if (incidences.count() > 0) { emit incidenceSelected( incidences.first() ); } else { emit incidenceSelected( 0 ); + clearSelection(); } } void KOMonthView::clearSelection() { if ( mSelectedCell ) { mSelectedCell->deselect(); mSelectedCell = 0; } } void KOMonthView::keyPressEvent ( QKeyEvent * e ) { //qDebug("KOMonthView::keyPressEvent "); switch(e->key()) { case Key_Up: { @@ -1650,21 +1668,29 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) } else { mCells[0]->setFocus(); emit nextMonth(); } } e->accept(); break; case Key_Return: case Key_Enter: { selectInternalWeekNum ( currentWeek() ); } e->accept(); break; + case Key_D: + if ( mSelectedCell ) { + mSelectedCell->showDay(); + e->accept(); + } else { + e->ignore(); + } + break; default: e->ignore(); break; } } diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index f92a69a..fd8cbf2 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -157,39 +157,42 @@ class MonthViewCell : public QWidget void deselect(); void select(); #ifdef DESKTOP_VERSION static QToolTipGroup *toolTipGroup(); #endif signals: void defaultAction( Incidence * ); void newEventSignal( QDateTime ); void showDaySignal( QDate ); protected: QString mToolTip; void resizeEvent( QResizeEvent * ); + +public slots: + void showDay(); + protected slots: void defaultAction( QListBoxItem * ); void contextMenu( QListBoxItem * ); void selection( QListBoxItem * ); void cellClicked( QListBoxItem * ); void newEvent(); - void showDay(); private: KOMonthView *mMonthView; QDate mDate; bool mPrimary; bool mHoliday; QString mHolidayString; //QLabel *mLabel; QPushButton *mLabel; QListBox *mItemList; #ifdef DESKTOP_VERSION static QToolTipGroup *mToolTipGroup; #endif QSize mLabelSize; |