summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp56
-rw-r--r--korganizer/kotodoview.h18
-rw-r--r--korganizer/kotodoviewitem.cpp2
-rw-r--r--libkcal/todo.cpp10
-rw-r--r--libkcal/todo.h1
5 files changed, 81 insertions, 6 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index b2ff33b..99e6a3a 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -22,12 +22,15 @@
*/
#include <qlayout.h>
#include <qheader.h>
#include <qcursor.h>
#include <qwhatsthis.h>
+#include <qdialog.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
#include <qinputdialog.h>
#include <qvbox.h>
#include <kdebug.h>
#include "koprefs.h"
@@ -55,12 +58,52 @@
#include "docprefs.h"
#include "kotodoview.h"
using namespace KOrg;
+KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
+ QDialog( parent, name, true )
+{
+ mTodo = todo;
+ setCaption( i18n("Stop todo") );
+ QVBoxLayout* lay = new QVBoxLayout( this );
+ lay->setSpacing( 3 );
+ lay->setMargin( 3 );
+ QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this );
+ lay->addWidget( lab );
+ lab->setAlignment( AlignHCenter );
+
+ QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
+ lay->addWidget( ok );
+ QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
+ lay->addWidget( cancel );
+ connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
+ connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
+ ok = new QPushButton( i18n("Stop - do not save"), this );
+ connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
+ lay->addWidget( ok );
+ resize( 200, 200 );
+}
+
+void KOStopTodoPrefs::accept()
+{
+ qDebug("KOStopTodoPrefs::accept() ");
+ QDialog::accept();
+}
+void KOStopTodoPrefs::doNotSave()
+{
+
+ int result = KMessageBox::warningContinueCancel(this,
+ i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() );
+ if (result != KMessageBox::Continue) return;
+ mTodo->stopRunning();
+ QDialog::accept();
+}
+
+
class KOTodoViewWhatsThis :public QWhatsThis
{
public:
KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
protected:
@@ -1124,27 +1167,32 @@ void KOTodoView::toggleRunningItem()
{
// qDebug("KOTodoView::toggleRunning() ");
if ( ! mActiveItem )
return;
Todo * t = mActiveItem->todo();
if ( t->isRunning() ) {
-#if 0
- 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( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
-#endif
+
+ KOStopTodoPrefs tp ( t, this );
+ tp.exec();
+
+
+#if 0
int result = KMessageBox::warningYesNoCancel(this,
i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note"));
if (result == KMessageBox::Cancel) return;
if ( result == KMessageBox::No ) {
QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") );
t->setRunningFalse( comment );
} else {
t->setRunning( false );
}
mActiveItem->construct();
+
+
+#endif
} 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( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
if (result != KMessageBox::Continue) return;
t->setRunning( true );
mActiveItem->construct();
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 1ffc34a..ceabdba 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -29,12 +29,14 @@
#include <qptrlist.h>
#include <qstrlist.h>
#include <qlistbox.h>
#include <qpopupmenu.h>
#include <qlabel.h>
#include <qmap.h>
+#include <qdialog.h>
+#include <qlabel.h>
#include <qlistview.h>
#include <klistview.h>
#include <libkcal/calendar.h>
#include <libkcal/todo.h>
@@ -50,12 +52,28 @@ class QDragMoveEvent;
class QDragLeaveEvent;
class QDropEvent;
class KOTodoViewWhatsThis;
class DocPrefs;
+
+class KOStopTodoPrefs : public QDialog
+{
+ Q_OBJECT
+ public:
+ KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
+
+
+private slots:
+ void doNotSave();
+ void accept();
+private:
+ Todo* mTodo;
+
+};
+
class KOTodoListView : public KListView
{
Q_OBJECT
public:
KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
virtual ~KOTodoListView() {}
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index f62aab8..0cf6e4c 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -357,13 +357,13 @@ bool KOTodoViewItem::isAlternate()
}
void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
{
QColorGroup _cg = cg;
QColorGroup::ColorRole role;
- if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
+ if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning())
role = QColorGroup::Text;
else
role = QColorGroup::Base;
//#ifndef KORG_NOLVALTERNATION
if (isAlternate())
_cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index e98af3c..d062492 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -66,12 +66,20 @@ void Todo::setRunningFalse( QString s )
if ( ! mRunning )
return;
mRunning = false;
mRunSaveTimer->stop();
saveRunningInfoToFile( s );
}
+void Todo::stopRunning()
+{
+ if ( !mRunning )
+ return;
+ if ( mRunSaveTimer )
+ mRunSaveTimer->stop();
+ mRunning = false;
+}
void Todo::setRunning( bool run )
{
if ( run == mRunning )
return;
//qDebug("Todo::setRunning %d ", run);
if ( !mRunSaveTimer ) {
@@ -92,13 +100,13 @@ void Todo::saveRunningInfoToFile()
{
saveRunningInfoToFile( QString::null );
}
void Todo::saveRunningInfoToFile( QString comment )
{
//qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
- if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
+ if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) {
qDebug("Running time < 30 seconds. Skipped. ");
return;
}
QString dir = KGlobalSettings::timeTrackerDir();
//qDebug("%s ", dir.latin1());
QString file = "%1%2%3-%4%5%6-";
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 6fc4d4b..42db025 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -119,12 +119,13 @@ namespace KCal {
void checkSetCompletedFalse();
bool setRecurDates();
bool isRunning() {return mRunning;}
bool hasRunningSub();
void setRunning( bool );
void setRunningFalse( QString );
+ void stopRunning();
int runTime();
QDateTime runStart () const { return mRunStart;}
public slots:
void saveRunningInfoToFile( QString st );
void saveRunningInfoToFile( );
void saveParents();