summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt12
-rw-r--r--korganizer/koprefs.cpp7
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/koprefsdialog.cpp14
-rw-r--r--korganizer/kotodoview.cpp30
-rw-r--r--korganizer/kotodoview.h1
-rw-r--r--korganizer/kotodoviewitem.cpp62
-rw-r--r--libkcal/todo.cpp44
-rw-r--r--libkcal/todo.h16
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
@@ -1336,4 +1336,16 @@
{ "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
@@ -63,11 +63,7 @@ KOPrefs::KOPrefs() :
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);
@@ -218,4 +214,5 @@ KOPrefs::KOPrefs() :
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 ));
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index cf8dae6..d511faa 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -140,4 +140,5 @@ class KOPrefs : public KPimPrefs
QColor mTodoDueTodayColor;
QColor mTodoOverdueColor;
+ QColor mTodoRunColor;
QColor mMonthViewEvenColor;
QColor mMonthViewOddColor;
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp
index 0bbb3bf..a8943de 100644
--- a/korganizer/koprefsdialog.cpp
+++ b/korganizer/koprefsdialog.cpp
@@ -896,10 +896,20 @@ 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
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() );
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 935a5f5..7ee1eef 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -482,4 +482,6 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
mItemPopupMenu->insertSeparator();
+ mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
+ SLOT (toggleRunningItem()));
mItemPopupMenu->insertItem( i18n("New Todo..."), this,
SLOT (newTodo()));
@@ -1100,9 +1102,14 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
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 )
@@ -1111,4 +1118,25 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
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)
{
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index d0788a9..d368513 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -207,4 +207,5 @@ class KOTodoView : public KOrg::BaseView
protected slots:
+ void toggleRunningItem();
void paintNeeded();
void processSelectionChange();
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 6559119..66f8d06 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -21,4 +21,5 @@
#include <kdebug.h>
#include <qapp.h>
+#include <kglobal.h>
#include <kiconloader.h>
@@ -121,22 +122,33 @@ 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);
setSortKey(6,skeyt);
@@ -369,11 +381,19 @@ void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, i
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;
+ }
}
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index a496404..7dee4cd 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -36,4 +36,6 @@ Todo::Todo(): Incidence()
mHasCompletedDate = false;
mPercentComplete = 0;
+ mRunning = false;
+ mRunSaveTimer = 0;
}
@@ -45,11 +47,53 @@ Todo::Todo(const Todo &t) : Incidence(t)
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()
{
diff --git a/libkcal/todo.h b/libkcal/todo.h
index a22d4b7..fe43357 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -26,4 +26,6 @@
#include "incidence.h"
+#include <qtimer.h>
+
namespace KCal {
@@ -31,6 +33,7 @@ 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();
@@ -115,6 +118,15 @@ class Todo : public Incidence
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); }