-rw-r--r-- | korganizer/koprefs.cpp | 7 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/koprefsdialog.cpp | 14 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 30 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 62 |
6 files changed, 86 insertions, 29 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 5879a2d..e8c7c76 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -64,9 +64,5 @@ KOPrefs::KOPrefs() : QColor defaultTodoOverdueColor = QColor(255,153,125); - - + QColor defaultTodoRunColor = QColor(99,194,30); KPrefs::setCurrentGroup("General"); - - addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); - addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); @@ -219,2 +215,3 @@ KOPrefs::KOPrefs() : addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); + addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index cf8dae6..d511faa 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -141,2 +141,3 @@ class KOPrefs : public KPimPrefs QColor mTodoOverdueColor; + QColor mTodoRunColor; QColor mMonthViewEvenColor; diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp index 0bbb3bf..a8943de 100644 --- a/korganizer/koprefsdialog.cpp +++ b/korganizer/koprefsdialog.cpp @@ -897,3 +897,13 @@ dummy = - QWidget* wid = new QWidget( topFrame ); + QWidget* wid = new QWidget( topFrame ); + // Todo run today color + KPrefsDialogWidColor *todoRunColor = + addWidColor(i18n("Color for running todos:"), + &(KOPrefs::instance()->mTodoRunColor),wid); + QHBoxLayout *widLayout = new QHBoxLayout(wid); + widLayout->addWidget( todoRunColor->label() ); + widLayout->addWidget( todoRunColor->button() ); + topLayout->addWidget(wid,ii++,0); + + wid = new QWidget( topFrame ); // Todo due today color @@ -902,3 +912,3 @@ dummy = &(KOPrefs::instance()->mTodoDueTodayColor),wid); - QHBoxLayout *widLayout = new QHBoxLayout(wid); + widLayout = new QHBoxLayout(wid); widLayout->addWidget( todoDueTodayColor->label() ); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 935a5f5..7ee1eef 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -483,2 +483,4 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : + mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, + SLOT (toggleRunningItem())); mItemPopupMenu->insertItem( i18n("New Todo..."), this, @@ -1101,3 +1103,3 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) } else { - if ( row == 1 || row == 2 ) { + if ( row == 2 ) { mActiveItem = (KOTodoViewItem *) item; @@ -1106,2 +1108,7 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) } + if ( row == 1 ) { + mActiveItem = (KOTodoViewItem *) item; + toggleRunningItem(); + return; + } } @@ -1112,2 +1119,23 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) } +void KOTodoView::toggleRunningItem() +{ + qDebug("KOTodoView::toggleRunning() "); + if ( ! mActiveItem ) + return; + Todo * t = mActiveItem->todo(); + if ( t->isRunning() ) { + int result = KMessageBox::warningContinueCancel(this, + i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 20 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); + if (result != KMessageBox::Continue) return; + t->setRunning( false ); + mActiveItem->construct(); + } else { + int result = KMessageBox::warningContinueCancel(this, + i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 20 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); + if (result != KMessageBox::Continue) return; + t->setRunning( true ); + mActiveItem->construct(); + } +} + void KOTodoView::itemClicked(QListViewItem *item) diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index d0788a9..d368513 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -208,2 +208,3 @@ class KOTodoView : public KOrg::BaseView protected slots: + void toggleRunningItem(); void paintNeeded(); diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 6559119..66f8d06 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp @@ -22,2 +22,3 @@ #include <qapp.h> +#include <kglobal.h> @@ -122,20 +123,31 @@ void KOTodoViewItem::construct() - if (mTodo->hasStartDate()) { - setText(5, mTodo->dtStartDateStr()); - QDate d = mTodo->dtStart().date(); - skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); - - if (mTodo->doesFloat()) { - setText(6,""); - } - else { - setText(6,mTodo->dtStartTimeStr()); - QTime t = mTodo->dtStart().time(); + keyd = ""; + keyt = ""; + + if (mTodo->isRunning() ) { + QDate d = mTodo->runStart().date(); + QTime t = mTodo->runStart().time(); skeyt.sprintf("%02d%02d",t.hour(),t.minute()); - - } + skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); + keyd = KGlobal::locale()->formatDate( d ); + keyt = KGlobal::locale()->formatTime( t ); + } else { - setText(5,""); - setText(6,""); + + if (mTodo->hasStartDate()) { + keyd = mTodo->dtStartDateStr(); + QDate d = mTodo->dtStart().date(); + skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); + + if ( !mTodo->doesFloat()) { + keyt = mTodo->dtStartTimeStr(); + QTime t = mTodo->dtStart().time(); + skeyt.sprintf("%02d%02d",t.hour(),t.minute()); + + } + + } } + setText(5,keyd); + setText(6,keyt); setSortKey(5,skeyd); @@ -370,9 +382,17 @@ void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, i openMode = false; - int odue = mTodo->hasDueSubTodo( openMode ); - if (odue == 2) { - colorToSet = KOPrefs::instance()->mTodoOverdueColor; - setColor = true; - } else if ( odue == 1 ) { - colorToSet = KOPrefs::instance()->mTodoDueTodayColor; + bool colorRunning = mTodo->isRunning(); + if ( ! colorRunning && openMode ) + colorRunning = mTodo->hasRunningSub(); + if ( colorRunning ) { setColor = true; + colorToSet = KOPrefs::instance()->mTodoRunColor; + } else { + int odue = mTodo->hasDueSubTodo( openMode ); + if (odue == 2) { + colorToSet = KOPrefs::instance()->mTodoOverdueColor; + setColor = true; + } else if ( odue == 1 ) { + colorToSet = KOPrefs::instance()->mTodoDueTodayColor; + setColor = true; + } } |