From 9b2bf31715226dfa8210f31843616a04f810f012 Mon Sep 17 00:00:00 2001 From: zautrix Date: Mon, 27 Jun 2005 04:48:41 +0000 Subject: strat stop tod fixes --- diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt index 01c707e..6ac79ad 100644 --- a/bin/kdepim/korganizer/germantranslation.txt +++ b/bin/kdepim/korganizer/germantranslation.txt @@ -1457,6 +1457,9 @@ { "This will backup all calendar files to the directory %1 %2","Das schreibt ein Backup aller Kalenderdateien in das Verzeichnis %1 %2" }, { "Birthdays","Geburtstage" }, { "KO/Pi import information!","KO/Pi Import Information!" }, +{ "Start this todo\nand stop all running","Starte dieses Todo\nund stoppe alle Laufenden" }, +{ "Cancel - do not start"," Abbrechen - Todo nicht starten" }, +{ "","" }, { "","" }, { "","" }, { "","" }, diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 7349d20..1bfdef9 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -63,6 +63,36 @@ using namespace KOrg; +KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : + QDialog( parent, name, true ) +{ + mStopAll = true; + setCaption( i18n("Start todo") ); + QVBoxLayout* lay = new QVBoxLayout( this ); + lay->setSpacing( 3 ); + lay->setMargin( 3 ); + QLabel * lab = new QLabel( i18n("%1\n").arg( sum ), this ); + lay->addWidget( lab ); + lab->setAlignment( AlignCenter ); + + QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); + lay->addWidget( ok ); + ok->setDefault( true ); + QPushButton * start = new QPushButton( i18n("Start todo"), this ); + lay->addWidget( start ); + QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); + lay->addWidget( cancel ); + connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); + connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); + connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); + resize( sizeHint() ); + +} +void KOStartTodoPrefs::doStop() +{ + mStopAll = false; + accept(); +} KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : QDialog( parent, name, true ) { @@ -1199,9 +1229,9 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) toggleRunningItem(); return; } else { - t->setRunning( true ); - mActiveItem->construct(); - topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); + t->setRunning( true ); + mActiveItem->construct(); + topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); return; } } @@ -1219,7 +1249,7 @@ void KOTodoView::toggleRunningItem() Todo * t = mActiveItem->todo(); if ( t->isRunning() ) { KOStopTodoPrefs tp ( t, this ); - if (QApplication::desktop()->width() < 800 ){ + if (QApplication::desktop()->width() <= 800 ){ int wid = tp.width(); int hei = tp.height(); int xx = (QApplication::desktop()->width()-wid)/2; @@ -1229,11 +1259,23 @@ void KOTodoView::toggleRunningItem() tp.exec(); mActiveItem->construct(); } else { - int result = KMessageBox::warningContinueCancel(this, - i18n("
%1
is not running. Do you want to set\nthe state to running?
").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(); + KOStartTodoPrefs tp ( t->summary(), this ); + if (QApplication::desktop()->width() <= 800 ){ + int wid = tp.width(); + int hei = tp.height(); + int xx = (QApplication::desktop()->width()-wid)/2; + int yy = (QApplication::desktop()->height()-hei)/2; + tp.setGeometry( xx,yy,wid,hei ); + } + if ( !tp.exec() ) return; + if ( tp.stopAll() ) { + mCalendar->stopAllTodos(); + t->setRunning( true ); + updateView(); + } else { + t->setRunning( true ); + mActiveItem->construct(); + } } } diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 8f0c99e..1b31d0d 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -76,6 +76,20 @@ private: }; +class KOStartTodoPrefs : public QDialog +{ + Q_OBJECT + public: + KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ; + + bool stopAll() { return mStopAll; } +private slots: + void doStop(); +private: + bool mStopAll; + +}; + class KOTodoListView : public KListView { Q_OBJECT diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 3b7b183..2efa355 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -77,6 +77,7 @@ public: virtual void addCalendar( Calendar* ) = 0; virtual bool addCalendarFile( QString name, int id ) = 0; virtual void setSyncEventsReadOnly() = 0; + virtual void stopAllTodos() = 0; /** Sync changes in memory to persistant storage. diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 8c4dde1..18f1af8 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -147,6 +147,12 @@ bool CalendarLocal::save( const QString &fileName, CalFormat *format ) return storage.save(); } +void CalendarLocal::stopAllTodos() +{ + for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) + it->setRunning( false ); + +} void CalendarLocal::close() { diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 0286b48..d32597f 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -46,6 +46,7 @@ class CalendarLocal : public Calendar void addCalendar( Calendar* ); bool addCalendarFile( QString name, int id ); void setSyncEventsReadOnly(); + void stopAllTodos(); /** Loads a calendar on disk in vCalendar or iCalendar format into the current calendar. Any information already present is lost. diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 9a8b6e4..5260051 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -111,8 +111,8 @@ void Todo::saveRunningInfoToFile() void Todo::saveRunningInfoToFile( QString comment ) { //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); - if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) { - qDebug("Running time < 30 seconds. Skipped. "); + if ( mRunStart.secsTo ( mRunEnd) < 15 ) { + qDebug("Running time < 15 seconds. Skipped. "); return; } QString dir = KGlobalSettings::timeTrackerDir(); -- cgit v0.9.0.2