summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp49
-rw-r--r--korganizer/kotodoview.h5
-rw-r--r--libkcal/todo.cpp2
-rw-r--r--libkcal/todo.h2
4 files changed, 45 insertions, 13 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index c5fae17..13e88ef 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -31,16 +31,18 @@
#include <qinputdialog.h>
#include <qvbox.h>
#include <kdebug.h>
#include "koprefs.h"
#include <klocale.h>
#include <kglobal.h>
+#include <kdateedit.h>
+#include "ktimeedit.h"
#include <kiconloader.h>
#include <kmessagebox.h>
#include <libkcal/icaldrag.h>
#include <libkcal/vcaldrag.h>
#include <libkcal/calfilter.h>
#include <libkcal/dndfactory.h>
#include <libkcal/calendarresources.h>
@@ -67,40 +69,63 @@ KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name
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 );
-
+ lab = new QLabel( i18n("Additional Comment:"), this );
+ lay->addWidget( lab );
+ mComment = new QLineEdit( this );
+ lay->addWidget( mComment );
+ QHBox * start = new QHBox ( this );
+ lay->addWidget( start );
+ lab = new QLabel( i18n("Start:"), start );
+ QHBox * end = new QHBox ( this );
+ lay->addWidget( end );
+ lab = new QLabel( i18n("End:"), end );
+ sde = new KDateEdit( start );
+ ste = new KOTimeEdit( start );
+ connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
+ ede = new KDateEdit( end );
+ ete = new KOTimeEdit(end );
+ connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
+ sde->setDate( mTodo->runStart().date() );
+ ste->setTime( mTodo->runStart().time() );
+ ede->setDate( QDate::currentDate());
+ ete->setTime( QTime::currentTime() );
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 );
+ if (QApplication::desktop()->width() < 320 )
+ resize( 240, 200 );
+ else
+ resize( 320, 200 );
+
}
void KOStopTodoPrefs::accept()
{
- qDebug("KOStopTodoPrefs::accept() ");
-
-
-#if 0
- t->setRunningFalse( comment );
-
- t->setRunning( false );
-#endif
-
+ QDateTime start = QDateTime( sde->date(), ste->getTime() );
+ QDateTime stop = QDateTime( ede->date(), ete->getTime() );
+ if ( start > stop ) {
+ KMessageBox::sorry(this,
+ i18n("The start time is\nafter the end time!"),
+ i18n("Time mismatch!"));
+ return;
+ }
+ mTodo->saveRunningInfo( mComment->text(), start, stop );
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();
@@ -1194,17 +1219,17 @@ void KOTodoView::toggleRunningItem()
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);
+ i18n("<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>").arg(mActiveItem->text(0).left( 25 ) ),i18n("Start todo"),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 ceabdba..8f0c99e 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -47,32 +47,37 @@
#include "koglobals.h"
#include "datenavigator.h"
class QDragEnterEvent;
class QDragMoveEvent;
class QDragLeaveEvent;
class QDropEvent;
class KOTodoViewWhatsThis;
+class KDateEdit;
+class KOTimeEdit;
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;
+ QLineEdit* mComment;
+ KDateEdit *sde, *ede;
+ KOTimeEdit *ste, *ete;
};
class KOTodoListView : public KListView
{
Q_OBJECT
public:
KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 62b74f1..9a8b6e4 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -92,16 +92,18 @@ void Todo::setRunning( bool run )
mRunStart = QDateTime::currentDateTime();
} else {
mRunSaveTimer->stop();
saveRunningInfoToFile();
}
}
void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
{
+ if ( !mRunning) return;
+ mRunning = false;
mRunStart = start;
mRunEnd = end;
saveRunningInfoToFile( comment );
}
void Todo::saveRunningInfoToFile()
{
mRunEnd = QDateTime::currentDateTime();
saveRunningInfoToFile( QString::null );
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 11f848e..425dfad 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -37,17 +37,16 @@ namespace KCal {
Q_OBJECT
public:
Todo();
Todo(const Todo &);
~Todo();
typedef ListBase<Todo> List;
QCString type() const { return "Todo"; }
IncTypeID typeID() const { return todoID; }
- void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
/** Return an exact copy of this todo. */
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
/** for setting the todo's due date/time with a QDateTime. */
void setDtDue(const QDateTime &dtDue);
/** returns an event's Due date/time as a QDateTime. */
@@ -121,16 +120,17 @@ namespace KCal {
bool setRecurDates();
bool isRunning() {return mRunning;}
bool hasRunningSub();
void setRunning( bool );
void setRunningFalse( QString );
void stopRunning();
int runTime();
QDateTime runStart () const { return mRunStart;}
+ void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
public slots:
void saveRunningInfoToFile( QString st );
void saveRunningInfoToFile( );
void saveParents();
private:
bool mRunning;
QTimer * mRunSaveTimer;
QDateTime mRunStart;