author | zautrix <zautrix> | 2005-04-30 07:32:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-30 07:32:03 (UTC) |
commit | 7c31102a00920834ab8e3778f0f459b96b2fb309 (patch) (unidiff) | |
tree | 9f238caaaab4ba150e4f14708d85162af0ea5092 /libkcal | |
parent | bdaded2da25b0ccef80d6e638fa12f92a4f8744d (diff) | |
download | kdepimpi-7c31102a00920834ab8e3778f0f459b96b2fb309.zip kdepimpi-7c31102a00920834ab8e3778f0f459b96b2fb309.tar.gz kdepimpi-7c31102a00920834ab8e3778f0f459b96b2fb309.tar.bz2 |
fixes
-rw-r--r-- | libkcal/todo.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index f7e38a7..d7431c7 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -67,97 +67,101 @@ void Todo::setRunningFalse( QString s ) | |||
67 | return; | 67 | return; |
68 | mRunning = false; | 68 | mRunning = false; |
69 | mRunSaveTimer->stop(); | 69 | mRunSaveTimer->stop(); |
70 | saveRunningInfoToFile( s ); | 70 | saveRunningInfoToFile( s ); |
71 | } | 71 | } |
72 | void Todo::setRunning( bool run ) | 72 | void Todo::setRunning( bool run ) |
73 | { | 73 | { |
74 | if ( run == mRunning ) | 74 | if ( run == mRunning ) |
75 | return; | 75 | return; |
76 | //qDebug("Todo::setRunning %d ", run); | 76 | //qDebug("Todo::setRunning %d ", run); |
77 | if ( !mRunSaveTimer ) { | 77 | if ( !mRunSaveTimer ) { |
78 | mRunSaveTimer = new QTimer ( this ); | 78 | mRunSaveTimer = new QTimer ( this ); |
79 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); | 79 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); |
80 | } | 80 | } |
81 | mRunning = run; | 81 | mRunning = run; |
82 | if ( mRunning ) { | 82 | if ( mRunning ) { |
83 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min | 83 | mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min |
84 | mRunStart = QDateTime::currentDateTime(); | 84 | mRunStart = QDateTime::currentDateTime(); |
85 | } else { | 85 | } else { |
86 | mRunSaveTimer->stop(); | 86 | mRunSaveTimer->stop(); |
87 | saveRunningInfoToFile(); | 87 | saveRunningInfoToFile(); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Todo::saveRunningInfoToFile( QString comment ) | 91 | void Todo::saveRunningInfoToFile( QString comment ) |
92 | { | 92 | { |
93 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 93 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
94 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { | 94 | if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { |
95 | qDebug("Running time < 30 seconds. Skipped. "); | 95 | qDebug("Running time < 30 seconds. Skipped. "); |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | QString dir = KGlobalSettings::timeTrackerDir(); | 98 | QString dir = KGlobalSettings::timeTrackerDir(); |
99 | //qDebug("%s ", dir.latin1()); | 99 | //qDebug("%s ", dir.latin1()); |
100 | QString file = "%1%2%3-%4%5%6-"; | 100 | QString file = "%1%2%3-%4%5%6-"; |
101 | 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 ); | 101 | 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 ); |
102 | file.replace ( QRegExp (" "), "0" ); | 102 | file.replace ( QRegExp (" "), "0" ); |
103 | file += uid(); | 103 | file += uid(); |
104 | //qDebug("File %s ",file.latin1() ); | 104 | //qDebug("File %s ",file.latin1() ); |
105 | CalendarLocal cal; | 105 | CalendarLocal cal; |
106 | cal.setLocalTime(); | 106 | cal.setLocalTime(); |
107 | Todo * to = (Todo*) clone(); | 107 | Todo * to = (Todo*) clone(); |
108 | to->setFloats( false ); | 108 | to->setFloats( false ); |
109 | to->setDtStart( mRunStart ); | 109 | to->setDtStart( mRunStart ); |
110 | to->setHasStartDate( true ); | 110 | to->setHasStartDate( true ); |
111 | to->setDtDue( QDateTime::currentDateTime() ); | 111 | to->setDtDue( QDateTime::currentDateTime() ); |
112 | to->setHasDueDate( true ); | 112 | to->setHasDueDate( true ); |
113 | to->setUid( file ); | 113 | to->setUid( file ); |
114 | if ( !comment.isEmpty() ) { | 114 | if ( !comment.isEmpty() ) { |
115 | to->setDescription( comment ); | 115 | QString des = to->description(); |
116 | if ( des.isEmpty () ) | ||
117 | to->setDescription( "TT-Note: " + comment ); | ||
118 | else | ||
119 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | ||
116 | } | 120 | } |
117 | cal.addIncidence( to ); | 121 | cal.addIncidence( to ); |
118 | ICalFormat format; | 122 | ICalFormat format; |
119 | file = dir +"/" +file +".ics"; | 123 | file = dir +"/" +file +".ics"; |
120 | format.save( &cal, file ); | 124 | format.save( &cal, file ); |
121 | saveParents(); | 125 | saveParents(); |
122 | 126 | ||
123 | } | 127 | } |
124 | void Todo::saveParents() | 128 | void Todo::saveParents() |
125 | { | 129 | { |
126 | if (!relatedTo() ) | 130 | if (!relatedTo() ) |
127 | return; | 131 | return; |
128 | Incidence * inc = relatedTo(); | 132 | Incidence * inc = relatedTo(); |
129 | if ( inc->type() != "Todo" ) | 133 | if ( inc->type() != "Todo" ) |
130 | return; | 134 | return; |
131 | Todo* to = (Todo*)inc; | 135 | Todo* to = (Todo*)inc; |
132 | bool saveTodo = false; | 136 | bool saveTodo = false; |
133 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 137 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
134 | QFileInfo fi ( file ); | 138 | QFileInfo fi ( file ); |
135 | if ( fi.exists() ) { | 139 | if ( fi.exists() ) { |
136 | if ( fi.lastModified () < to->lastModified ()) | 140 | if ( fi.lastModified () < to->lastModified ()) |
137 | saveTodo = true; | 141 | saveTodo = true; |
138 | } else { | 142 | } else { |
139 | saveTodo = true; | 143 | saveTodo = true; |
140 | } | 144 | } |
141 | if ( saveTodo ) { | 145 | if ( saveTodo ) { |
142 | CalendarLocal cal; | 146 | CalendarLocal cal; |
143 | cal.setLocalTime(); | 147 | cal.setLocalTime(); |
144 | Todo * par = (Todo *) to->clone(); | 148 | Todo * par = (Todo *) to->clone(); |
145 | cal.addIncidence( par ); | 149 | cal.addIncidence( par ); |
146 | ICalFormat format; | 150 | ICalFormat format; |
147 | format.save( &cal, file ); | 151 | format.save( &cal, file ); |
148 | } | 152 | } |
149 | to->saveParents(); | 153 | to->saveParents(); |
150 | } | 154 | } |
151 | 155 | ||
152 | int Todo::runTime() | 156 | int Todo::runTime() |
153 | { | 157 | { |
154 | if ( !mRunning ) | 158 | if ( !mRunning ) |
155 | return 0; | 159 | return 0; |
156 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 160 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
157 | } | 161 | } |
158 | bool Todo::hasRunningSub() | 162 | bool Todo::hasRunningSub() |
159 | { | 163 | { |
160 | if ( mRunning ) | 164 | if ( mRunning ) |
161 | return true; | 165 | return true; |
162 | Incidence *aTodo; | 166 | Incidence *aTodo; |
163 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 167 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |