summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-04-17 08:24:43 (UTC)
committer zautrix <zautrix>2005-04-17 08:24:43 (UTC)
commitfd67a473a94c5a3d63a89c52fb8f612cb19b5363 (patch) (unidiff)
treed5adc24b8c2662118934fb5ab7f6ac690ae21153 /libkcal
parent6cf5cc7d0b12af6bdc722e469f3f5aa293016c7d (diff)
downloadkdepimpi-fd67a473a94c5a3d63a89c52fb8f612cb19b5363.zip
kdepimpi-fd67a473a94c5a3d63a89c52fb8f612cb19b5363.tar.gz
kdepimpi-fd67a473a94c5a3d63a89c52fb8f612cb19b5363.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 6a6c137..002d3f2 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -66,99 +66,99 @@ void Todo::setRunning( bool run )
66 if ( run == mRunning ) 66 if ( run == mRunning )
67 return; 67 return;
68 //qDebug("Todo::setRunning %d ", run); 68 //qDebug("Todo::setRunning %d ", run);
69 if ( !mRunSaveTimer ) { 69 if ( !mRunSaveTimer ) {
70 mRunSaveTimer = new QTimer ( this ); 70 mRunSaveTimer = new QTimer ( this );
71 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 71 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
72 } 72 }
73 mRunning = run; 73 mRunning = run;
74 if ( mRunning ) { 74 if ( mRunning ) {
75 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 75 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
76 mRunStart = QDateTime::currentDateTime(); 76 mRunStart = QDateTime::currentDateTime();
77 } else { 77 } else {
78 mRunSaveTimer->stop(); 78 mRunSaveTimer->stop();
79 saveRunningInfoToFile(); 79 saveRunningInfoToFile();
80 } 80 }
81} 81}
82 82
83void Todo::saveRunningInfoToFile() 83void Todo::saveRunningInfoToFile()
84{ 84{
85 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 85 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
86 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { 86 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
87 qDebug("Running time < 30 seconds. Skipped. "); 87 qDebug("Running time < 30 seconds. Skipped. ");
88 return; 88 return;
89 } 89 }
90 QString dir = KGlobalSettings::timeTrackerDir(); 90 QString dir = KGlobalSettings::timeTrackerDir();
91 //qDebug("%s ", dir.latin1()); 91 //qDebug("%s ", dir.latin1());
92 QString file = "%1%2%3-%4%5%6-"; 92 QString file = "%1%2%3-%4%5%6-";
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 = 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 );
94 file.replace ( QRegExp (" "), "0" ); 94 file.replace ( QRegExp (" "), "0" );
95 file += uid(); 95 file += uid();
96 //qDebug("File %s ",file.latin1() ); 96 //qDebug("File %s ",file.latin1() );
97 CalendarLocal cal; 97 CalendarLocal cal;
98 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); 98 cal.setLocalTime();
99 Todo * to = (Todo*) clone(); 99 Todo * to = (Todo*) clone();
100 to->setFloats( false ); 100 to->setFloats( false );
101 to->setDtStart( mRunStart ); 101 to->setDtStart( mRunStart );
102 to->setHasStartDate( true ); 102 to->setHasStartDate( true );
103 to->setDtDue( QDateTime::currentDateTime() ); 103 to->setDtDue( QDateTime::currentDateTime() );
104 to->setHasDueDate( true ); 104 to->setHasDueDate( true );
105 to->setUid( file ); 105 to->setUid( file );
106 cal.addIncidence( to ); 106 cal.addIncidence( to );
107 ICalFormat format; 107 ICalFormat format;
108 file = dir +"/" +file +".ics"; 108 file = dir +"/" +file +".ics";
109 format.save( &cal, file ); 109 format.save( &cal, file );
110 saveParents(); 110 saveParents();
111 111
112} 112}
113void Todo::saveParents() 113void Todo::saveParents()
114{ 114{
115 if (!relatedTo() ) 115 if (!relatedTo() )
116 return; 116 return;
117 Incidence * inc = relatedTo(); 117 Incidence * inc = relatedTo();
118 if ( inc->type() != "Todo" ) 118 if ( inc->type() != "Todo" )
119 return; 119 return;
120 Todo* to = (Todo*)inc; 120 Todo* to = (Todo*)inc;
121 bool saveTodo = false; 121 bool saveTodo = false;
122 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 122 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
123 QFileInfo fi ( file ); 123 QFileInfo fi ( file );
124 if ( fi.exists() ) { 124 if ( fi.exists() ) {
125 if ( fi.lastModified () < to->lastModified ()) 125 if ( fi.lastModified () < to->lastModified ())
126 saveTodo = true; 126 saveTodo = true;
127 } else { 127 } else {
128 saveTodo = true; 128 saveTodo = true;
129 } 129 }
130 if ( saveTodo ) { 130 if ( saveTodo ) {
131 CalendarLocal cal; 131 CalendarLocal cal;
132 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); 132 cal.setLocalTime();
133 Todo * par = (Todo *) to->clone(); 133 Todo * par = (Todo *) to->clone();
134 cal.addIncidence( par ); 134 cal.addIncidence( par );
135 ICalFormat format; 135 ICalFormat format;
136 format.save( &cal, file ); 136 format.save( &cal, file );
137 } 137 }
138 to->saveParents(); 138 to->saveParents();
139} 139}
140 140
141int Todo::runTime() 141int Todo::runTime()
142{ 142{
143 if ( !mRunning ) 143 if ( !mRunning )
144 return 0; 144 return 0;
145 return mRunStart.secsTo( QDateTime::currentDateTime() ); 145 return mRunStart.secsTo( QDateTime::currentDateTime() );
146} 146}
147bool Todo::hasRunningSub() 147bool Todo::hasRunningSub()
148{ 148{
149 if ( mRunning ) 149 if ( mRunning )
150 return true; 150 return true;
151 Incidence *aTodo; 151 Incidence *aTodo;
152 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 152 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
153 if ( ((Todo*)aTodo)->hasRunningSub() ) 153 if ( ((Todo*)aTodo)->hasRunningSub() )
154 return true; 154 return true;
155 } 155 }
156 return false; 156 return false;
157} 157}
158Incidence *Todo::clone() 158Incidence *Todo::clone()
159{ 159{
160 return new Todo(*this); 160 return new Todo(*this);
161} 161}
162 162
163bool Todo::contains ( Todo* from ) 163bool Todo::contains ( Todo* from )
164{ 164{