summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt3
-rw-r--r--korganizer/kotodoview.cpp60
-rw-r--r--korganizer/kotodoview.h14
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp6
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/todo.cpp4
7 files changed, 78 insertions, 11 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
@@ -1428,37 +1428,40 @@
1428{ "Additional Comment:","Zusätzlicher Kommentar:" }, 1428{ "Additional Comment:","Zusätzlicher Kommentar:" },
1429{ "Stop and save","Stopp und Speichern" }, 1429{ "Stop and save","Stopp und Speichern" },
1430{ "Continue running","Weiter laufen lassen" }, 1430{ "Continue running","Weiter laufen lassen" },
1431{ "Stop - do not save","Stopp - nicht Speichern" }, 1431{ "Stop - do not save","Stopp - nicht Speichern" },
1432{ "Do you really want to set\nthe state to stopped\nwithout saving the data?","Möchten sie den Zustand\nwirklich auf gestoppt setzen\nohne die Daten abzuspeichern?" }, 1432{ "Do you really want to set\nthe state to stopped\nwithout saving the data?","Möchten sie den Zustand\nwirklich auf gestoppt setzen\nohne die Daten abzuspeichern?" },
1433{ "Time mismatch!","Zeiten stimmen nicht!" }, 1433{ "Time mismatch!","Zeiten stimmen nicht!" },
1434{ "The start time is\nafter the end time!","Die Startzeit ist\nhinter der Endzeit!" }, 1434{ "The start time is\nafter the end time!","Die Startzeit ist\nhinter der Endzeit!" },
1435{ "Yes, stop todo","Ja, stoppe Todo" }, 1435{ "Yes, stop todo","Ja, stoppe Todo" },
1436{ "Todo stopped - no data saved because runtime was < 15 sec!","Todo gestoppt - nichts gespeichert da Laufzeit < 15 sec!" }, 1436{ "Todo stopped - no data saved because runtime was < 15 sec!","Todo gestoppt - nichts gespeichert da Laufzeit < 15 sec!" },
1437{ "Todo started! Double click again to stop!","Todo gestartet! Doppelklicke um es zu stoppen!" }, 1437{ "Todo started! Double click again to stop!","Todo gestartet! Doppelklicke um es zu stoppen!" },
1438{ "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." }, 1438{ "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." },
1439{ "Spouse","Ehegatte" }, 1439{ "Spouse","Ehegatte" },
1440{ "Notes","Notizen" }, 1440{ "Notes","Notizen" },
1441{ "Messanger","Messanger" }, 1441{ "Messanger","Messanger" },
1442{ "Assistant","Assistent" }, 1442{ "Assistant","Assistent" },
1443{ "Manager","Manager" }, 1443{ "Manager","Manager" },
1444{ "Secrecy","Sichtbar" }, 1444{ "Secrecy","Sichtbar" },
1445{ "male","männlich" }, 1445{ "male","männlich" },
1446{ "female","weiblich" }, 1446{ "female","weiblich" },
1447{ "Hide!","Verbergen!" }, 1447{ "Hide!","Verbergen!" },
1448{ "Show!","Anzeigen!" }, 1448{ "Show!","Anzeigen!" },
1449{ "Details","Details" }, 1449{ "Details","Details" },
1450{ "Profession","Beruf" }, 1450{ "Profession","Beruf" },
1451{ "Children","Kinder" }, 1451{ "Children","Kinder" },
1452{ "Department","Abteilung" }, 1452{ "Department","Abteilung" },
1453{ "Backup cancelled","Backup abgebrochen" }, 1453{ "Backup cancelled","Backup abgebrochen" },
1454{ "Backup globally disabled","Backup global abgeschaltet" }, 1454{ "Backup globally disabled","Backup global abgeschaltet" },
1455{ "Backup succesfully finished","Backup erfolgreich beendet" }, 1455{ "Backup succesfully finished","Backup erfolgreich beendet" },
1456{ "(Hint: You can enable automatic backup in the global settings!)","(Hinweis: Sie können ein automatisches Backup in den globalen Einstellungen konfigurieren!)" }, 1456{ "(Hint: You can enable automatic backup in the global settings!)","(Hinweis: Sie können ein automatisches Backup in den globalen Einstellungen konfigurieren!)" },
1457{ "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" }, 1457{ "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" },
1458{ "Birthdays","Geburtstage" }, 1458{ "Birthdays","Geburtstage" },
1459{ "KO/Pi import information!","KO/Pi Import Information!" }, 1459{ "KO/Pi import information!","KO/Pi Import Information!" },
1460{ "Start this todo\nand stop all running","Starte dieses Todo\nund stoppe alle Laufenden" },
1461{ "Cancel - do not start"," Abbrechen - Todo nicht starten" },
1462{ "","" },
1460{ "","" }, 1463{ "","" },
1461{ "","" }, 1464{ "","" },
1462{ "","" }, 1465{ "","" },
1463{ "","" }, 1466{ "","" },
1464{ "","" }, \ No newline at end of file 1467{ "","" }, \ 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
@@ -34,64 +34,94 @@
34#include <qvbox.h> 34#include <qvbox.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include "koprefs.h" 36#include "koprefs.h"
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kdateedit.h> 39#include <kdateedit.h>
40#include "ktimeedit.h" 40#include "ktimeedit.h"
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43 43
44#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
45#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
46#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
47#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
48#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
49#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
50#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
58#include "calprinter.h" 58#include "calprinter.h"
59#endif 59#endif
60#include "docprefs.h" 60#include "docprefs.h"
61 61
62#include "kotodoview.h" 62#include "kotodoview.h"
63using namespace KOrg; 63using namespace KOrg;
64 64
65 65
66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) :
67 QDialog( parent, name, true )
68{
69 mStopAll = true;
70 setCaption( i18n("Start todo") );
71 QVBoxLayout* lay = new QVBoxLayout( this );
72 lay->setSpacing( 3 );
73 lay->setMargin( 3 );
74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this );
75 lay->addWidget( lab );
76 lab->setAlignment( AlignCenter );
77
78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this );
79 lay->addWidget( ok );
80 ok->setDefault( true );
81 QPushButton * start = new QPushButton( i18n("Start todo"), this );
82 lay->addWidget( start );
83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this );
84 lay->addWidget( cancel );
85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) );
87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
88 resize( sizeHint() );
89
90}
91void KOStartTodoPrefs::doStop()
92{
93 mStopAll = false;
94 accept();
95}
66KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
67 QDialog( parent, name, true ) 97 QDialog( parent, name, true )
68{ 98{
69 mTodo = todo; 99 mTodo = todo;
70 setCaption( i18n("Stop todo") ); 100 setCaption( i18n("Stop todo") );
71 QVBoxLayout* lay = new QVBoxLayout( this ); 101 QVBoxLayout* lay = new QVBoxLayout( this );
72 lay->setSpacing( 3 ); 102 lay->setSpacing( 3 );
73 lay->setMargin( 3 ); 103 lay->setMargin( 3 );
74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); 104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this );
75 lay->addWidget( lab ); 105 lay->addWidget( lab );
76 lab->setAlignment( AlignHCenter ); 106 lab->setAlignment( AlignHCenter );
77 lab = new QLabel( i18n("Additional Comment:"), this ); 107 lab = new QLabel( i18n("Additional Comment:"), this );
78 lay->addWidget( lab ); 108 lay->addWidget( lab );
79 mComment = new QLineEdit( this ); 109 mComment = new QLineEdit( this );
80 lay->addWidget( mComment ); 110 lay->addWidget( mComment );
81 QHBox * start = new QHBox ( this ); 111 QHBox * start = new QHBox ( this );
82 lay->addWidget( start ); 112 lay->addWidget( start );
83 lab = new QLabel( i18n("Start:"), start ); 113 lab = new QLabel( i18n("Start:"), start );
84 QHBox * end = new QHBox ( this ); 114 QHBox * end = new QHBox ( this );
85 lay->addWidget( end ); 115 lay->addWidget( end );
86 lab = new QLabel( i18n("End:"), end ); 116 lab = new QLabel( i18n("End:"), end );
87 sde = new KDateEdit( start ); 117 sde = new KDateEdit( start );
88 ste = new KOTimeEdit( start ); 118 ste = new KOTimeEdit( start );
89 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); 119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
90 ede = new KDateEdit( end ); 120 ede = new KDateEdit( end );
91 ete = new KOTimeEdit(end ); 121 ete = new KOTimeEdit(end );
92 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); 122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
93 sde->setDate( mTodo->runStart().date() ); 123 sde->setDate( mTodo->runStart().date() );
94 ste->setTime( mTodo->runStart().time() ); 124 ste->setTime( mTodo->runStart().time() );
95 ede->setDate( QDate::currentDate()); 125 ede->setDate( QDate::currentDate());
96 ete->setTime( QTime::currentTime() ); 126 ete->setTime( QTime::currentTime() );
97 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 127 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
@@ -1170,99 +1200,111 @@ void KOTodoView::changedCategories(int index)
1170void KOTodoView::itemDoubleClicked(QListViewItem *item) 1200void KOTodoView::itemDoubleClicked(QListViewItem *item)
1171{ 1201{
1172 if ( pendingSubtodo != 0 ) { 1202 if ( pendingSubtodo != 0 ) {
1173 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1203 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1174 } 1204 }
1175 pendingSubtodo = 0; 1205 pendingSubtodo = 0;
1176 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1206 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1177 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1207 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1178 //qDebug("ROW %d ", row); 1208 //qDebug("ROW %d ", row);
1179 if (!item) { 1209 if (!item) {
1180 newTodo(); 1210 newTodo();
1181 return; 1211 return;
1182 } else { 1212 } else {
1183 if ( row == 1 ) { 1213 if ( row == 1 ) {
1184 mActiveItem = (KOTodoViewItem *) item; 1214 mActiveItem = (KOTodoViewItem *) item;
1185 newSubTodo(); 1215 newSubTodo();
1186 return; 1216 return;
1187 } 1217 }
1188 if ( row == 5 || row == 6 || row == 2) { 1218 if ( row == 5 || row == 6 || row == 2) {
1189 mActiveItem = (KOTodoViewItem *) item; 1219 mActiveItem = (KOTodoViewItem *) item;
1190 Todo * t = mActiveItem->todo(); 1220 Todo * t = mActiveItem->todo();
1191 if ( t->isRunning() ) { 1221 if ( t->isRunning() ) {
1192 if ( t->runTime() < 15) { 1222 if ( t->runTime() < 15) {
1193 t->stopRunning(); 1223 t->stopRunning();
1194 mActiveItem->construct(); 1224 mActiveItem->construct();
1195 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1225 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1196 return; 1226 return;
1197 } 1227 }
1198 else 1228 else
1199 toggleRunningItem(); 1229 toggleRunningItem();
1200 return; 1230 return;
1201 } else { 1231 } else {
1202 t->setRunning( true ); 1232 t->setRunning( true );
1203 mActiveItem->construct(); 1233 mActiveItem->construct();
1204 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1234 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1205 return; 1235 return;
1206 } 1236 }
1207 } 1237 }
1208 } 1238 }
1209 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1239 if ( KOPrefs::instance()->mEditOnDoubleClick )
1210 editItem( item ); 1240 editItem( item );
1211 else 1241 else
1212 showItem( item , QPoint(), 0 ); 1242 showItem( item , QPoint(), 0 );
1213} 1243}
1214void KOTodoView::toggleRunningItem() 1244void KOTodoView::toggleRunningItem()
1215{ 1245{
1216 // qDebug("KOTodoView::toggleRunning() "); 1246 // qDebug("KOTodoView::toggleRunning() ");
1217 if ( ! mActiveItem ) 1247 if ( ! mActiveItem )
1218 return; 1248 return;
1219 Todo * t = mActiveItem->todo(); 1249 Todo * t = mActiveItem->todo();
1220 if ( t->isRunning() ) { 1250 if ( t->isRunning() ) {
1221 KOStopTodoPrefs tp ( t, this ); 1251 KOStopTodoPrefs tp ( t, this );
1222 if (QApplication::desktop()->width() < 800 ){ 1252 if (QApplication::desktop()->width() <= 800 ){
1223 int wid = tp.width(); 1253 int wid = tp.width();
1224 int hei = tp.height(); 1254 int hei = tp.height();
1225 int xx = (QApplication::desktop()->width()-wid)/2; 1255 int xx = (QApplication::desktop()->width()-wid)/2;
1226 int yy = (QApplication::desktop()->height()-hei)/2; 1256 int yy = (QApplication::desktop()->height()-hei)/2;
1227 tp.setGeometry( xx,yy,wid,hei ); 1257 tp.setGeometry( xx,yy,wid,hei );
1228 } 1258 }
1229 tp.exec(); 1259 tp.exec();
1230 mActiveItem->construct(); 1260 mActiveItem->construct();
1231 } else { 1261 } else {
1232 int result = KMessageBox::warningContinueCancel(this, 1262 KOStartTodoPrefs tp ( t->summary(), this );
1233 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); 1263 if (QApplication::desktop()->width() <= 800 ){
1234 if (result != KMessageBox::Continue) return; 1264 int wid = tp.width();
1235 t->setRunning( true ); 1265 int hei = tp.height();
1236 mActiveItem->construct(); 1266 int xx = (QApplication::desktop()->width()-wid)/2;
1267 int yy = (QApplication::desktop()->height()-hei)/2;
1268 tp.setGeometry( xx,yy,wid,hei );
1269 }
1270 if ( !tp.exec() ) return;
1271 if ( tp.stopAll() ) {
1272 mCalendar->stopAllTodos();
1273 t->setRunning( true );
1274 updateView();
1275 } else {
1276 t->setRunning( true );
1277 mActiveItem->construct();
1278 }
1237 } 1279 }
1238} 1280}
1239 1281
1240void KOTodoView::itemClicked(QListViewItem *item) 1282void KOTodoView::itemClicked(QListViewItem *item)
1241{ 1283{
1242 //qDebug("KOTodoView::itemClicked %d", item); 1284 //qDebug("KOTodoView::itemClicked %d", item);
1243 if (!item) { 1285 if (!item) {
1244 if ( pendingSubtodo != 0 ) { 1286 if ( pendingSubtodo != 0 ) {
1245 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1287 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1246 } 1288 }
1247 pendingSubtodo = 0; 1289 pendingSubtodo = 0;
1248 return; 1290 return;
1249 } 1291 }
1250 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1292 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1251 if ( pendingSubtodo != 0 ) { 1293 if ( pendingSubtodo != 0 ) {
1252 bool allowReparent = true; 1294 bool allowReparent = true;
1253 QListViewItem *par = item; 1295 QListViewItem *par = item;
1254 while ( par ) { 1296 while ( par ) {
1255 if ( par == pendingSubtodo ) { 1297 if ( par == pendingSubtodo ) {
1256 allowReparent = false; 1298 allowReparent = false;
1257 break; 1299 break;
1258 } 1300 }
1259 par = par->parent(); 1301 par = par->parent();
1260 } 1302 }
1261 if ( !allowReparent ) { 1303 if ( !allowReparent ) {
1262 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1304 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1263 pendingSubtodo = 0; 1305 pendingSubtodo = 0;
1264 } else { 1306 } else {
1265 Todo* newParent = todoItem->todo(); 1307 Todo* newParent = todoItem->todo();
1266 Todo* newSub = pendingSubtodo->todo(); 1308 Todo* newSub = pendingSubtodo->todo();
1267 pendingSubtodo = 0; 1309 pendingSubtodo = 0;
1268 emit reparentTodoSignal( newParent,newSub ); 1310 emit reparentTodoSignal( newParent,newSub );
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 8f0c99e..1b31d0d 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -47,64 +47,78 @@
47#include "koglobals.h" 47#include "koglobals.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49 49
50class QDragEnterEvent; 50class QDragEnterEvent;
51class QDragMoveEvent; 51class QDragMoveEvent;
52class QDragLeaveEvent; 52class QDragLeaveEvent;
53class QDropEvent; 53class QDropEvent;
54class KOTodoViewWhatsThis; 54class KOTodoViewWhatsThis;
55class KDateEdit; 55class KDateEdit;
56class KOTimeEdit; 56class KOTimeEdit;
57 57
58class DocPrefs; 58class DocPrefs;
59 59
60 60
61class KOStopTodoPrefs : public QDialog 61class KOStopTodoPrefs : public QDialog
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 public: 64 public:
65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; 65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
66 66
67 67
68private slots: 68private slots:
69 void doNotSave(); 69 void doNotSave();
70 void accept(); 70 void accept();
71private: 71private:
72 Todo* mTodo; 72 Todo* mTodo;
73 QLineEdit* mComment; 73 QLineEdit* mComment;
74 KDateEdit *sde, *ede; 74 KDateEdit *sde, *ede;
75 KOTimeEdit *ste, *ete; 75 KOTimeEdit *ste, *ete;
76 76
77}; 77};
78 78
79class KOStartTodoPrefs : public QDialog
80{
81 Q_OBJECT
82 public:
83 KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ;
84
85 bool stopAll() { return mStopAll; }
86private slots:
87 void doStop();
88private:
89 bool mStopAll;
90
91};
92
79class KOTodoListView : public KListView 93class KOTodoListView : public KListView
80{ 94{
81 Q_OBJECT 95 Q_OBJECT
82 public: 96 public:
83 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 97 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
84 virtual ~KOTodoListView() {} 98 virtual ~KOTodoListView() {}
85 99
86 signals: 100 signals:
87 void paintNeeded(); 101 void paintNeeded();
88 void todoDropped(Todo *, int); 102 void todoDropped(Todo *, int);
89 void double_Clicked(QListViewItem *item); 103 void double_Clicked(QListViewItem *item);
90 void reparentTodoSignal( Todo *,Todo * ); 104 void reparentTodoSignal( Todo *,Todo * );
91 void unparentTodoSignal(Todo *); 105 void unparentTodoSignal(Todo *);
92 void deleteTodo( Todo * ); 106 void deleteTodo( Todo * );
93 protected: 107 protected:
94 void wheelEvent (QWheelEvent *e); 108 void wheelEvent (QWheelEvent *e);
95 void contentsDragEnterEvent(QDragEnterEvent *); 109 void contentsDragEnterEvent(QDragEnterEvent *);
96 void contentsDragMoveEvent(QDragMoveEvent *); 110 void contentsDragMoveEvent(QDragMoveEvent *);
97 void contentsDragLeaveEvent(QDragLeaveEvent *); 111 void contentsDragLeaveEvent(QDragLeaveEvent *);
98 void contentsDropEvent(QDropEvent *); 112 void contentsDropEvent(QDropEvent *);
99 113
100 void contentsMousePressEvent(QMouseEvent *); 114 void contentsMousePressEvent(QMouseEvent *);
101 void contentsMouseMoveEvent(QMouseEvent *); 115 void contentsMouseMoveEvent(QMouseEvent *);
102 void contentsMouseReleaseEvent(QMouseEvent *); 116 void contentsMouseReleaseEvent(QMouseEvent *);
103 void contentsMouseDoubleClickEvent(QMouseEvent *); 117 void contentsMouseDoubleClickEvent(QMouseEvent *);
104 118
105 private: 119 private:
106 void paintEvent(QPaintEvent * pevent); 120 void paintEvent(QPaintEvent * pevent);
107 bool internalDrop; 121 bool internalDrop;
108 QString mName; 122 QString mName;
109 Calendar *mCalendar; 123 Calendar *mCalendar;
110 QPoint mPressPos; 124 QPoint mPressPos;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 3b7b183..2efa355 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -48,64 +48,65 @@ namespace KCal {
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0; 77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0; 78 virtual bool addCalendarFile( QString name, int id ) = 0;
79 virtual void setSyncEventsReadOnly() = 0; 79 virtual void setSyncEventsReadOnly() = 0;
80 virtual void stopAllTodos() = 0;
80 81
81 /** 82 /**
82 Sync changes in memory to persistant storage. 83 Sync changes in memory to persistant storage.
83 */ 84 */
84 virtual void save() = 0; 85 virtual void save() = 0;
85 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 86 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
86 virtual void removeSyncInfo( QString syncProfile) = 0; 87 virtual void removeSyncInfo( QString syncProfile) = 0;
87 virtual bool isSaving() { return false; } 88 virtual bool isSaving() { return false; }
88 89
89 /** 90 /**
90 Return the owner of the calendar's full name. 91 Return the owner of the calendar's full name.
91 */ 92 */
92 const QString &getOwner() const; 93 const QString &getOwner() const;
93 /** 94 /**
94 Set the owner of the calendar. Should be owner's full name. 95 Set the owner of the calendar. Should be owner's full name.
95 */ 96 */
96 void setOwner( const QString &os ); 97 void setOwner( const QString &os );
97 /** 98 /**
98 Return the email address of the calendar owner. 99 Return the email address of the calendar owner.
99 */ 100 */
100 const QString &getEmail(); 101 const QString &getEmail();
101 /** 102 /**
102 Set the email address of the calendar owner. 103 Set the email address of the calendar owner.
103 */ 104 */
104 void setEmail( const QString & ); 105 void setEmail( const QString & );
105 106
106 /** 107 /**
107 Set time zone from a timezone string (e.g. -2:00) 108 Set time zone from a timezone string (e.g. -2:00)
108 */ 109 */
109 void setTimeZone( const QString &tz ); 110 void setTimeZone( const QString &tz );
110 /** 111 /**
111 Set time zone from a minutes value (e.g. -60) 112 Set time zone from a minutes value (e.g. -60)
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 8c4dde1..18f1af8 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -118,64 +118,70 @@ void CalendarLocal::addCalendar( Calendar* cal )
118 while ( ev ) { 118 while ( ev ) {
119 ev->unRegisterObserver( cal ); 119 ev->unRegisterObserver( cal );
120 ev->registerObserver( this ); 120 ev->registerObserver( this );
121 mTodoList.append( ev ); 121 mTodoList.append( ev );
122 setupRelations( ev ); 122 setupRelations( ev );
123 ev = TodoList.next(); 123 ev = TodoList.next();
124 } 124 }
125 } 125 }
126 { 126 {
127 QPtrList<Journal> JournalList = cal->journals(); 127 QPtrList<Journal> JournalList = cal->journals();
128 Journal * ev = JournalList.first(); 128 Journal * ev = JournalList.first();
129 while ( ev ) { 129 while ( ev ) {
130 ev->unRegisterObserver( cal ); 130 ev->unRegisterObserver( cal );
131 ev->registerObserver( this ); 131 ev->registerObserver( this );
132 mJournalList.append( ev ); 132 mJournalList.append( ev );
133 ev = JournalList.next(); 133 ev = JournalList.next();
134 } 134 }
135 } 135 }
136 setModified( true ); 136 setModified( true );
137} 137}
138bool CalendarLocal::load( const QString &fileName ) 138bool CalendarLocal::load( const QString &fileName )
139{ 139{
140 FileStorage storage( this, fileName ); 140 FileStorage storage( this, fileName );
141 return storage.load(); 141 return storage.load();
142} 142}
143 143
144bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 144bool CalendarLocal::save( const QString &fileName, CalFormat *format )
145{ 145{
146 FileStorage storage( this, fileName, format ); 146 FileStorage storage( this, fileName, format );
147 return storage.save(); 147 return storage.save();
148} 148}
149 149
150void CalendarLocal::stopAllTodos()
151{
152 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
153 it->setRunning( false );
154
155}
150void CalendarLocal::close() 156void CalendarLocal::close()
151{ 157{
152 158
153 Todo * i; 159 Todo * i;
154 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 160 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
155 161
156 mEventList.setAutoDelete( true ); 162 mEventList.setAutoDelete( true );
157 mTodoList.setAutoDelete( true ); 163 mTodoList.setAutoDelete( true );
158 mJournalList.setAutoDelete( false ); 164 mJournalList.setAutoDelete( false );
159 165
160 mEventList.clear(); 166 mEventList.clear();
161 mTodoList.clear(); 167 mTodoList.clear();
162 mJournalList.clear(); 168 mJournalList.clear();
163 169
164 mEventList.setAutoDelete( false ); 170 mEventList.setAutoDelete( false );
165 mTodoList.setAutoDelete( false ); 171 mTodoList.setAutoDelete( false );
166 mJournalList.setAutoDelete( false ); 172 mJournalList.setAutoDelete( false );
167 173
168 setModified( false ); 174 setModified( false );
169} 175}
170 176
171bool CalendarLocal::addAnniversaryNoDup( Event *event ) 177bool CalendarLocal::addAnniversaryNoDup( Event *event )
172{ 178{
173 QString cat; 179 QString cat;
174 bool isBirthday = true; 180 bool isBirthday = true;
175 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 181 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
176 isBirthday = false; 182 isBirthday = false;
177 cat = i18n( "Anniversary" ); 183 cat = i18n( "Anniversary" );
178 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 184 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
179 isBirthday = true; 185 isBirthday = true;
180 cat = i18n( "Birthday" ); 186 cat = i18n( "Birthday" );
181 } else { 187 } else {
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 0286b48..d32597f 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -17,64 +17,65 @@
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 void addCalendar( Calendar* ); 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id ); 47 bool addCalendarFile( QString name, int id );
48 void setSyncEventsReadOnly(); 48 void setSyncEventsReadOnly();
49 void stopAllTodos();
49 /** 50 /**
50 Loads a calendar on disk in vCalendar or iCalendar format into the current 51 Loads a calendar on disk in vCalendar or iCalendar format into the current
51 calendar. Any information already present is lost. 52 calendar. Any information already present is lost.
52 @return true, if successfull, false on error. 53 @return true, if successfull, false on error.
53 @param fileName the name of the calendar on disk. 54 @param fileName the name of the calendar on disk.
54 */ 55 */
55 bool load( const QString &fileName ); 56 bool load( const QString &fileName );
56 /** 57 /**
57 Writes out the calendar to disk in the specified \a format. 58 Writes out the calendar to disk in the specified \a format.
58 CalendarLocal takes ownership of the CalFormat object. 59 CalendarLocal takes ownership of the CalFormat object.
59 @return true, if successfull, false on error. 60 @return true, if successfull, false on error.
60 @param fileName the name of the file 61 @param fileName the name of the file
61 */ 62 */
62 bool save( const QString &fileName, CalFormat *format = 0 ); 63 bool save( const QString &fileName, CalFormat *format = 0 );
63 64
64 /** 65 /**
65 Clears out the current calendar, freeing all used memory etc. etc. 66 Clears out the current calendar, freeing all used memory etc. etc.
66 */ 67 */
67 void close(); 68 void close();
68 69
69 void save() {} 70 void save() {}
70 71
71 /** 72 /**
72 Add Event to calendar. 73 Add Event to calendar.
73 */ 74 */
74 void removeSyncInfo( QString syncProfile); 75 void removeSyncInfo( QString syncProfile);
75 bool addAnniversaryNoDup( Event *event ); 76 bool addAnniversaryNoDup( Event *event );
76 bool addEventNoDup( Event *event ); 77 bool addEventNoDup( Event *event );
77 bool addEvent( Event *event ); 78 bool addEvent( Event *event );
78 /** 79 /**
79 Deletes an event from this calendar. 80 Deletes an event from this calendar.
80 */ 81 */
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 9a8b6e4..5260051 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -82,66 +82,66 @@ void Todo::setRunning( bool run )
82 if ( run == mRunning ) 82 if ( run == mRunning )
83 return; 83 return;
84 //qDebug("Todo::setRunning %d ", run); 84 //qDebug("Todo::setRunning %d ", run);
85 if ( !mRunSaveTimer ) { 85 if ( !mRunSaveTimer ) {
86 mRunSaveTimer = new QTimer ( this ); 86 mRunSaveTimer = new QTimer ( this );
87 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 87 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
88 } 88 }
89 mRunning = run; 89 mRunning = run;
90 if ( mRunning ) { 90 if ( mRunning ) {
91 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 91 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
92 mRunStart = QDateTime::currentDateTime(); 92 mRunStart = QDateTime::currentDateTime();
93 } else { 93 } else {
94 mRunSaveTimer->stop(); 94 mRunSaveTimer->stop();
95 saveRunningInfoToFile(); 95 saveRunningInfoToFile();
96 } 96 }
97} 97}
98void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) 98void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
99{ 99{
100 if ( !mRunning) return; 100 if ( !mRunning) return;
101 mRunning = false; 101 mRunning = false;
102 mRunStart = start; 102 mRunStart = start;
103 mRunEnd = end; 103 mRunEnd = end;
104 saveRunningInfoToFile( comment ); 104 saveRunningInfoToFile( comment );
105} 105}
106void Todo::saveRunningInfoToFile() 106void Todo::saveRunningInfoToFile()
107{ 107{
108 mRunEnd = QDateTime::currentDateTime(); 108 mRunEnd = QDateTime::currentDateTime();
109 saveRunningInfoToFile( QString::null ); 109 saveRunningInfoToFile( QString::null );
110} 110}
111void Todo::saveRunningInfoToFile( QString comment ) 111void Todo::saveRunningInfoToFile( QString comment )
112{ 112{
113 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 113 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
114 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) { 114 if ( mRunStart.secsTo ( mRunEnd) < 15 ) {
115 qDebug("Running time < 30 seconds. Skipped. "); 115 qDebug("Running time < 15 seconds. Skipped. ");
116 return; 116 return;
117 } 117 }
118 QString dir = KGlobalSettings::timeTrackerDir(); 118 QString dir = KGlobalSettings::timeTrackerDir();
119 //qDebug("%s ", dir.latin1()); 119 //qDebug("%s ", dir.latin1());
120 QString file = "%1%2%3-%4%5%6-"; 120 QString file = "%1%2%3-%4%5%6-";
121 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 ); 121 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 );
122 file.replace ( QRegExp (" "), "0" ); 122 file.replace ( QRegExp (" "), "0" );
123 file += uid(); 123 file += uid();
124 //qDebug("File %s ",file.latin1() ); 124 //qDebug("File %s ",file.latin1() );
125 CalendarLocal cal; 125 CalendarLocal cal;
126 cal.setLocalTime(); 126 cal.setLocalTime();
127 Todo * to = (Todo*) clone(); 127 Todo * to = (Todo*) clone();
128 to->setFloats( false ); 128 to->setFloats( false );
129 to->setDtStart( mRunStart ); 129 to->setDtStart( mRunStart );
130 to->setHasStartDate( true ); 130 to->setHasStartDate( true );
131 to->setDtDue( mRunEnd ); 131 to->setDtDue( mRunEnd );
132 to->setHasDueDate( true ); 132 to->setHasDueDate( true );
133 to->setUid( file ); 133 to->setUid( file );
134 if ( !comment.isEmpty() ) { 134 if ( !comment.isEmpty() ) {
135 QString des = to->description(); 135 QString des = to->description();
136 if ( des.isEmpty () ) 136 if ( des.isEmpty () )
137 to->setDescription( "TT-Note: " + comment ); 137 to->setDescription( "TT-Note: " + comment );
138 else 138 else
139 to->setDescription( "TT-Note: " + comment +"\n" + des ); 139 to->setDescription( "TT-Note: " + comment +"\n" + des );
140 } 140 }
141 cal.addIncidence( to ); 141 cal.addIncidence( to );
142 ICalFormat format; 142 ICalFormat format;
143 file = dir +"/" +file +".ics"; 143 file = dir +"/" +file +".ics";
144 format.save( &cal, file ); 144 format.save( &cal, file );
145 saveParents(); 145 saveParents();
146 146
147} 147}