-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 3 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 50 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 14 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 6 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/todo.cpp | 4 |
7 files changed, 73 insertions, 6 deletions
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 @@ -1436,29 +1436,32 @@ { "Todo stopped - no data saved because runtime was < 15 sec!","Todo gestoppt - nichts gespeichert da Laufzeit < 15 sec!" }, { "Todo started! Double click again to stop!","Todo gestartet! Doppelklicke um es zu stoppen!" }, { "Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.","Bitte wählen Sie den <b>Default-Kalender</b> in dieser Spalte. Neu angelegte oder importierte Einträge werden dem Default-Kalender hinzugefügt." }, { "Spouse","Ehegatte" }, { "Notes","Notizen" }, { "Messanger","Messanger" }, { "Assistant","Assistent" }, { "Manager","Manager" }, { "Secrecy","Sichtbar" }, { "male","männlich" }, { "female","weiblich" }, { "Hide!","Verbergen!" }, { "Show!","Anzeigen!" }, { "Details","Details" }, { "Profession","Beruf" }, { "Children","Kinder" }, { "Department","Abteilung" }, { "Backup cancelled","Backup abgebrochen" }, { "Backup globally disabled","Backup global abgeschaltet" }, { "Backup succesfully finished","Backup erfolgreich beendet" }, { "(Hint: You can enable automatic backup in the global settings!)","(Hinweis: Sie können ein automatisches Backup in den globalen Einstellungen konfigurieren!)" }, { "This will <b>backup all calendar files</b> to the directory %1 %2","Das schreibt ein <b>Backup aller Kalenderdateien</b> 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" }, +{ "","" }, { "","" }, { "","" }, { "","" }, { "","" }, { "","" },
\ No newline at end of file diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 7349d20..1bfdef9 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -42,48 +42,78 @@ #include <kmessagebox.h> #include <libkcal/icaldrag.h> #include <libkcal/vcaldrag.h> #include <libkcal/calfilter.h> #include <libkcal/dndfactory.h> #include <libkcal/calendarresources.h> #include <libkcal/resourcecalendar.h> #include <kresources/resourceselectdialog.h> #include <libkcal/kincidenceformatter.h> #ifndef DESKTOP_VERSION #include <qpe/qpeapplication.h> #else #include <qapplication.h> #endif #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "docprefs.h" #include "kotodoview.h" 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("<b>%1\n</b>").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 ) { mTodo = todo; setCaption( i18n("Stop todo") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("<b>%1\n</b>").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 ) ) ); @@ -1198,65 +1228,77 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item) else toggleRunningItem(); return; } else { t->setRunning( true ); mActiveItem->construct(); topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); return; } } } if ( KOPrefs::instance()->mEditOnDoubleClick ) editItem( item ); else showItem( item , QPoint(), 0 ); } void KOTodoView::toggleRunningItem() { // qDebug("KOTodoView::toggleRunning() "); if ( ! mActiveItem ) return; 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; int yy = (QApplication::desktop()->height()-hei)/2; tp.setGeometry( xx,yy,wid,hei ); } tp.exec(); mActiveItem->construct(); } else { - int result = KMessageBox::warningContinueCancel(this, - 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; + 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(); } } +} void KOTodoView::itemClicked(QListViewItem *item) { //qDebug("KOTodoView::itemClicked %d", item); if (!item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; return; } KOTodoViewItem *todoItem = (KOTodoViewItem *)item; if ( pendingSubtodo != 0 ) { bool allowReparent = true; QListViewItem *par = item; while ( par ) { if ( par == pendingSubtodo ) { allowReparent = false; break; } par = par->parent(); } if ( !allowReparent ) { topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 8f0c99e..1b31d0d 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -55,48 +55,62 @@ 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 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 public: KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); virtual ~KOTodoListView() {} signals: void paintNeeded(); void todoDropped(Todo *, int); void double_Clicked(QListViewItem *item); void reparentTodoSignal( Todo *,Todo * ); void unparentTodoSignal(Todo *); void deleteTodo( Todo * ); protected: void wheelEvent (QWheelEvent *e); void contentsDragEnterEvent(QDragEnterEvent *); void contentsDragMoveEvent(QDragMoveEvent *); void contentsDragLeaveEvent(QDragLeaveEvent *); void contentsDropEvent(QDropEvent *); void contentsMousePressEvent(QMouseEvent *); void contentsMouseMoveEvent(QMouseEvent *); void contentsMouseReleaseEvent(QMouseEvent *); diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 3b7b183..2efa355 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -56,48 +56,49 @@ namespace KCal { as pointers, that means all changes to the returned events are immediately visible in the Calendar. You shouldn't delete any Event object you get from Calendar. */ class Calendar : public QObject, public CustomProperties, public IncidenceBase::Observer { Q_OBJECT public: Calendar(); Calendar(const QString &timeZoneId); virtual ~Calendar(); Incidence * undoIncidence() { return mUndoIncidence; }; bool undoDeleteIncidence(); void deleteIncidence(Incidence *in); void resetTempSyncStat(); void resetPilotStat(int id); /** Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; 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. */ virtual void save() = 0; virtual QPtrList<Event> getExternLastSyncEvents() = 0; virtual void removeSyncInfo( QString syncProfile) = 0; virtual bool isSaving() { return false; } /** Return the owner of the calendar's full name. */ const QString &getOwner() const; /** Set the owner of the calendar. Should be owner's full name. */ void setOwner( const QString &os ); /** Return the email address of the calendar owner. */ const QString &getEmail(); /** Set the email address of the calendar owner. */ diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 8c4dde1..18f1af8 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -126,48 +126,54 @@ void CalendarLocal::addCalendar( Calendar* cal ) { QPtrList<Journal> JournalList = cal->journals(); Journal * ev = JournalList.first(); while ( ev ) { ev->unRegisterObserver( cal ); ev->registerObserver( this ); mJournalList.append( ev ); ev = JournalList.next(); } } setModified( true ); } bool CalendarLocal::load( const QString &fileName ) { FileStorage storage( this, fileName ); return storage.load(); } bool CalendarLocal::save( const QString &fileName, CalFormat *format ) { FileStorage storage( this, fileName, format ); return storage.save(); } +void CalendarLocal::stopAllTodos() +{ + for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) + it->setRunning( false ); + +} void CalendarLocal::close() { Todo * i; for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); mEventList.setAutoDelete( true ); mTodoList.setAutoDelete( true ); mJournalList.setAutoDelete( false ); mEventList.clear(); mTodoList.clear(); mJournalList.clear(); mEventList.setAutoDelete( false ); mTodoList.setAutoDelete( false ); mJournalList.setAutoDelete( false ); setModified( false ); } bool CalendarLocal::addAnniversaryNoDup( Event *event ) { QString cat; diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 0286b48..d32597f 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -25,48 +25,49 @@ #include "calendar.h" namespace KCal { class CalFormat; /** This class provides a calendar stored as a local file. */ class CalendarLocal : public Calendar { public: /** Constructs a new calendar, with variables initialized to sane values. */ CalendarLocal(); /** Constructs a new calendar, with variables initialized to sane values. */ CalendarLocal( const QString &timeZoneId ); ~CalendarLocal(); 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. @return true, if successfull, false on error. @param fileName the name of the calendar on disk. */ bool load( const QString &fileName ); /** Writes out the calendar to disk in the specified \a format. CalendarLocal takes ownership of the CalFormat object. @return true, if successfull, false on error. @param fileName the name of the file */ bool save( const QString &fileName, CalFormat *format = 0 ); /** Clears out the current calendar, freeing all used memory etc. etc. */ void close(); void save() {} /** Add Event to calendar. diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 9a8b6e4..5260051 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -90,50 +90,50 @@ void Todo::setRunning( bool run ) if ( mRunning ) { mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 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 ); } 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(); //qDebug("%s ", dir.latin1()); QString file = "%1%2%3-%4%5%6-"; file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); file.replace ( QRegExp (" "), "0" ); file += uid(); //qDebug("File %s ",file.latin1() ); CalendarLocal cal; cal.setLocalTime(); Todo * to = (Todo*) clone(); to->setFloats( false ); to->setDtStart( mRunStart ); to->setHasStartDate( true ); to->setDtDue( mRunEnd ); to->setHasDueDate( true ); to->setUid( file ); if ( !comment.isEmpty() ) { QString des = to->description(); if ( des.isEmpty () ) to->setDescription( "TT-Note: " + comment ); else to->setDescription( "TT-Note: " + comment +"\n" + des ); |