summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
authorzautrix <zautrix>2005-04-15 20:51:58 (UTC)
committer zautrix <zautrix>2005-04-15 20:51:58 (UTC)
commit85bdc33419eef0ffa9f00eb7222944518fe39b6c (patch) (unidiff)
tree57000de41f5e29c5ebd07f3ed2951a7b89730fb1 /libkcal/todo.cpp
parente1d62b2afac2b625a3e0b8d4df137647de34e04f (diff)
downloadkdepimpi-85bdc33419eef0ffa9f00eb7222944518fe39b6c.zip
kdepimpi-85bdc33419eef0ffa9f00eb7222944518fe39b6c.tar.gz
kdepimpi-85bdc33419eef0ffa9f00eb7222944518fe39b6c.tar.bz2
fixxx
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index b89abce..5e6ac22 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -20,96 +20,97 @@
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27 27
28#include "calendarlocal.h" 28#include "calendarlocal.h"
29#include "icalformat.h" 29#include "icalformat.h"
30#include "todo.h" 30#include "todo.h"
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34Todo::Todo(): QObject(), Incidence() 34Todo::Todo(): QObject(), Incidence()
35{ 35{
36// mStatus = TENTATIVE; 36// mStatus = TENTATIVE;
37 37
38 mHasDueDate = false; 38 mHasDueDate = false;
39 setHasStartDate( false ); 39 setHasStartDate( false );
40 mCompleted = getEvenTime(QDateTime::currentDateTime()); 40 mCompleted = getEvenTime(QDateTime::currentDateTime());
41 mHasCompletedDate = false; 41 mHasCompletedDate = false;
42 mPercentComplete = 0; 42 mPercentComplete = 0;
43 mRunning = false; 43 mRunning = false;
44 mRunSaveTimer = 0; 44 mRunSaveTimer = 0;
45} 45}
46 46
47Todo::Todo(const Todo &t) : QObject(),Incidence(t) 47Todo::Todo(const Todo &t) : QObject(),Incidence(t)
48{ 48{
49 mDtDue = t.mDtDue; 49 mDtDue = t.mDtDue;
50 mHasDueDate = t.mHasDueDate; 50 mHasDueDate = t.mHasDueDate;
51 mCompleted = t.mCompleted; 51 mCompleted = t.mCompleted;
52 mHasCompletedDate = t.mHasCompletedDate; 52 mHasCompletedDate = t.mHasCompletedDate;
53 mPercentComplete = t.mPercentComplete; 53 mPercentComplete = t.mPercentComplete;
54 mRunning = false; 54 mRunning = false;
55 mRunSaveTimer = 0; 55 mRunSaveTimer = 0;
56} 56}
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunning( bool run ) 64void Todo::setRunning( bool run )
65{ 65{
66 if ( run == mRunning ) 66 if ( run == mRunning )
67 return; 67 return;
68 //qDebug("Todo::setRunning %d ", run);
68 if ( !mRunSaveTimer ) { 69 if ( !mRunSaveTimer ) {
69 mRunSaveTimer = new QTimer ( this ); 70 mRunSaveTimer = new QTimer ( this );
70 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 71 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
71 } 72 }
72 mRunning = run; 73 mRunning = run;
73 if ( mRunning ) { 74 if ( mRunning ) {
74 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 75 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
75 mRunStart = QDateTime::currentDateTime(); 76 mRunStart = QDateTime::currentDateTime();
76 } else { 77 } else {
77 mRunSaveTimer->stop(); 78 mRunSaveTimer->stop();
78 saveRunningInfoToFile(); 79 saveRunningInfoToFile();
79 } 80 }
80} 81}
81 82
82void Todo::saveRunningInfoToFile() 83void Todo::saveRunningInfoToFile()
83{ 84{
84 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 85 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
85 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { 86 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
86 qDebug("Running time < 30 seconds. Skipped. "); 87 qDebug("Running time < 30 seconds. Skipped. ");
87 return; 88 return;
88 } 89 }
89 QString dir = KGlobalSettings::timeTrackerDir(); 90 QString dir = KGlobalSettings::timeTrackerDir();
90 //qDebug("%s ", dir.latin1()); 91 //qDebug("%s ", dir.latin1());
91 QString file = "%1%2%3-%4%5%6-"; 92 QString file = "%1%2%3-%4%5%6-";
92 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 ); 93 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 );
93 file.replace ( QRegExp (" "), "0" ); 94 file.replace ( QRegExp (" "), "0" );
94 file += uid(); 95 file += uid();
95 //qDebug("File %s ",file.latin1() ); 96 //qDebug("File %s ",file.latin1() );
96 CalendarLocal cal; 97 CalendarLocal cal;
97 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); 98 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" );
98 Todo * to = (Todo*) clone(); 99 Todo * to = (Todo*) clone();
99 to->setFloats( false ); 100 to->setFloats( false );
100 to->setDtStart( mRunStart ); 101 to->setDtStart( mRunStart );
101 to->setHasStartDate( true ); 102 to->setHasStartDate( true );
102 to->setDtDue( QDateTime::currentDateTime() ); 103 to->setDtDue( QDateTime::currentDateTime() );
103 to->setHasDueDate( true ); 104 to->setHasDueDate( true );
104 to->setUid( file ); 105 to->setUid( file );
105 cal.addIncidence( to ); 106 cal.addIncidence( to );
106 ICalFormat format; 107 ICalFormat format;
107 file = dir +"/" +file +".ics"; 108 file = dir +"/" +file +".ics";
108 format.save( &cal, file ); 109 format.save( &cal, file );
109 saveParents(); 110 saveParents();
110 111
111} 112}
112void Todo::saveParents() 113void Todo::saveParents()
113{ 114{
114 if (!relatedTo() ) 115 if (!relatedTo() )
115 return; 116 return;