author | zautrix <zautrix> | 2005-04-09 20:21:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-09 20:21:58 (UTC) |
commit | 9e43ebbe5867b2da957bb17c35bd357715424cba (patch) (side-by-side diff) | |
tree | b506ba029b50fc46a33d35a39e6f1c768c995f22 | |
parent | 2c39ac46121e8796e780a5321ab777f08792e5ba (diff) | |
download | kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.zip kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.gz kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.bz2 |
todo tt
-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 | 12 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 30 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 38 | ||||
-rw-r--r-- | libkcal/todo.cpp | 44 | ||||
-rw-r--r-- | libkcal/todo.h | 16 |
9 files changed, 143 insertions, 18 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 @@ -1337,2 +1337,14 @@ { "<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 @@ -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 @@ -898,2 +898,12 @@ dummy = 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,4 +123,17 @@ void KOTodoViewItem::construct() + 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 { + if (mTodo->hasStartDate()) { - setText(5, mTodo->dtStartDateStr()); + keyd = mTodo->dtStartDateStr(); QDate d = mTodo->dtStart().date(); @@ -127,7 +141,4 @@ void KOTodoViewItem::construct() - if (mTodo->doesFloat()) { - setText(6,""); - } - else { - setText(6,mTodo->dtStartTimeStr()); + if ( !mTodo->doesFloat()) { + keyt = mTodo->dtStartTimeStr(); QTime t = mTodo->dtStart().time(); @@ -136,6 +147,7 @@ void KOTodoViewItem::construct() } - } else { - setText(5,""); - setText(6,""); + } + } + setText(5,keyd); + setText(6,keyt); setSortKey(5,skeyd); @@ -370,2 +382,9 @@ void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, i openMode = false; + bool colorRunning = mTodo->isRunning(); + if ( ! colorRunning && openMode ) + colorRunning = mTodo->hasRunningSub(); + if ( colorRunning ) { + setColor = true; + colorToSet = KOPrefs::instance()->mTodoRunColor; + } else { int odue = mTodo->hasDueSubTodo( openMode ); @@ -378,2 +397,3 @@ void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, i } + } diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index a496404..7dee4cd 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -37,2 +37,4 @@ Todo::Todo(): Incidence() mPercentComplete = 0; + mRunning = false; + mRunSaveTimer = 0; } @@ -46,2 +48,4 @@ Todo::Todo(const Todo &t) : Incidence(t) mPercentComplete = t.mPercentComplete; + mRunning = false; + mRunSaveTimer = 0; } @@ -50,5 +54,45 @@ 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() diff --git a/libkcal/todo.h b/libkcal/todo.h index a22d4b7..fe43357 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -27,2 +27,4 @@ +#include <qtimer.h> + namespace KCal { @@ -32,4 +34,5 @@ namespace KCal { */ -class Todo : public Incidence + class Todo : public QObject,public Incidence { + Q_OBJECT public: @@ -116,4 +119,13 @@ class Todo : public Incidence 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); } |