-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 12 | ||||
-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 | ||||
-rw-r--r-- | libkcal/todo.cpp | 44 | ||||
-rw-r--r-- | libkcal/todo.h | 16 |
9 files changed, 156 insertions, 31 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt index b4e26c2..5257bff 100644 --- a/bin/kdepim/korganizer/germantranslation.txt +++ b/bin/kdepim/korganizer/germantranslation.txt @@ -1334,7 +1334,19 @@ { "Number of max.displayed todo prios:","Anzahl max.angezeigter Todo-Prios:" }, { " on "," am " }, { "On: ","Am: " }, { "<i>The recurrence is computed from the start datetime!</i>","<i>Die Wiederholung wird vom Startwert aus berechnet!</i>" }, +{ "Start/Stop todo...","Starte/Stoppe Todo..." }, +{ "Color for running todos:","Farbe für laufende Todos:" }, +{ "The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?","Das Todo\n%1\nist gestartet.\nWollen Sie es\nauf gestoppt setzen?" }, +{ "Todo is started","Todo is gestarted" }, +{ "Stop todo","Stoppe Todo" }, +{ "Todo is stopped","Todo ist gestoppt" }, +{ "Start todo","Starte Todo" }, +{ "The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?","Das Todo\n%1\nist gestoppt.\nWollen Sie es auf\ngestartet setzen?" }, +{ "","" }, +{ "","" }, +{ "","" }, +{ "","" }, { "","" }, { "","" }, { "","" }, diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 5879a2d..e8c7c76 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -61,15 +61,11 @@ KOPrefs::KOPrefs() : QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); QColor defaultTodoDueTodayColor = QColor(255,220,100); 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); addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); addItemBool("ShowIconSearch",&mShowIconSearch,true); addItemBool("ShowIconList",&mShowIconList,true); @@ -216,8 +212,9 @@ KOPrefs::KOPrefs() : addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); + addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index cf8dae6..d511faa 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -138,8 +138,9 @@ class KOPrefs : public KPimPrefs QColor mAgendaBgColor; QColor mWorkingHoursColor; QColor mTodoDueTodayColor; QColor mTodoOverdueColor; + QColor mTodoRunColor; QColor mMonthViewEvenColor; QColor mMonthViewOddColor; QColor mMonthViewHolidayColor; bool mMonthViewUsesDayColors; diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp index 0bbb3bf..a8943de 100644 --- a/korganizer/koprefsdialog.cpp +++ b/korganizer/koprefsdialog.cpp @@ -894,14 +894,24 @@ dummy = &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); topLayout->addWidget(dummy->checkBox(),ii++,0); - 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 KPrefsDialogWidColor *todoDueTodayColor = addWidColor(i18n("Todo due today color:"), &(KOPrefs::instance()->mTodoDueTodayColor),wid); - QHBoxLayout *widLayout = new QHBoxLayout(wid); + widLayout = new QHBoxLayout(wid); widLayout->addWidget( todoDueTodayColor->label() ); widLayout->addWidget( todoDueTodayColor->button() ); topLayout->addWidget(wid,ii++,0); //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 935a5f5..7ee1eef 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -480,8 +480,10 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, SLOT (cancelTodo())); mItemPopupMenu->insertSeparator(); + mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, + SLOT (toggleRunningItem())); mItemPopupMenu->insertItem( i18n("New Todo..."), this, SLOT (newTodo())); mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, SLOT (newSubTodo())); @@ -1098,19 +1100,45 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) if (!item) { newTodo(); return; } else { - if ( row == 1 || row == 2 ) { + if ( row == 2 ) { mActiveItem = (KOTodoViewItem *) item; newSubTodo(); return; } + if ( row == 1 ) { + mActiveItem = (KOTodoViewItem *) item; + toggleRunningItem(); + return; + } } if ( KOPrefs::instance()->mEditOnDoubleClick ) editItem( item ); else showItem( item , QPoint(), 0 ); } +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) { //qDebug("KOTodoView::itemClicked %d", item); if (!item) { diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index d0788a9..d368513 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -205,8 +205,9 @@ class KOTodoView : public KOrg::BaseView void beamTodoSignal( Incidence * ); void purgeCompletedSignal(); protected slots: + void toggleRunningItem(); void paintNeeded(); void processSelectionChange(); void addQuickTodo(); void setTodoModified( Todo* ); diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 6559119..66f8d06 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp @@ -19,8 +19,9 @@ #include <klocale.h> #include <kdebug.h> #include <qapp.h> +#include <kglobal.h> #include <kiconloader.h> #include "kotodoviewitem.h" #include "kotodoview.h" @@ -119,26 +120,37 @@ void KOTodoViewItem::construct() else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); - 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); setSortKey(6,skeyt); setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); @@ -367,15 +379,23 @@ void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, i bool openMode = !isOpen(); // maybe we are in flat-display-mode if ( !firstChild() ) 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; + } } if ( setColor ) { diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index a496404..7dee4cd 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -34,8 +34,10 @@ Todo::Todo(): Incidence() setHasStartDate( false ); mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; mPercentComplete = 0; + mRunning = false; + mRunSaveTimer = 0; } Todo::Todo(const Todo &t) : Incidence(t) { @@ -43,15 +45,57 @@ Todo::Todo(const Todo &t) : Incidence(t) mHasDueDate = t.mHasDueDate; mCompleted = t.mCompleted; mHasCompletedDate = t.mHasCompletedDate; mPercentComplete = t.mPercentComplete; + mRunning = false; + mRunSaveTimer = 0; } Todo::~Todo() { + setRunning( false ); +} + +void Todo::setRunning( bool run ) +{ + if ( run == mRunning ) + return; + if ( !mRunSaveTimer ) { + mRunSaveTimer = new QTimer ( this ); + connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); + } + mRunning = run; + if ( mRunning ) { + mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min + mRunStart = QDateTime::currentDateTime(); + } else { + mRunSaveTimer->stop(); + saveRunningInfoToFile(); + } +} +void Todo::saveRunningInfoToFile() +{ + qDebug("Todo::saveRunningInfoToFile() "); } +int Todo::runTime() +{ + if ( !mRunning ) + return 0; + return mRunStart.secsTo( QDateTime::currentDateTime() ); +} +bool Todo::hasRunningSub() +{ + if ( mRunning ) + return true; + Incidence *aTodo; + for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { + if ( ((Todo*)aTodo)->hasRunningSub() ) + return true; + } + return false; +} Incidence *Todo::clone() { return new Todo(*this); } diff --git a/libkcal/todo.h b/libkcal/todo.h index a22d4b7..fe43357 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -24,15 +24,18 @@ // #include "incidence.h" +#include <qtimer.h> + namespace KCal { /** This class provides a Todo in the sense of RFC2445. */ -class Todo : public Incidence + class Todo : public QObject,public Incidence { + Q_OBJECT public: Todo(); Todo(const Todo &); ~Todo(); @@ -113,10 +116,19 @@ class Todo : public Incidence bool hasCompletedDate() const; bool contains ( Todo*); void checkSetCompletedFalse(); bool setRecurDates(); - + bool isRunning() {return mRunning;} + bool hasRunningSub(); + void setRunning( bool ); + int runTime(); + QDateTime runStart () const { return mRunStart;} + public slots: + void saveRunningInfoToFile(); private: + bool mRunning; + QTimer * mRunSaveTimer; + QDateTime mRunStart; bool accept(Visitor &v) { return v.visit(this); } QDateTime mDtDue; // due date of todo |