summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 8794f7a..7906046 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -15,24 +15,26 @@
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kglobal.h>
#include <kglobalsettings.h>
#include <klocale.h>
#include <kdebug.h>
#include <qregexp.h>
+#include "calendarlocal.h"
+#include "icalformat.h"
#include "todo.h"
using namespace KCal;
Todo::Todo(): Incidence()
{
// mStatus = TENTATIVE;
mHasDueDate = false;
setHasStartDate( false );
mCompleted = getEvenTime(QDateTime::currentDateTime());
mHasCompletedDate = false;
@@ -46,24 +48,25 @@ Todo::Todo(const Todo &t) : Incidence(t)
mDtDue = t.mDtDue;
mHasDueDate = t.mHasDueDate;
mCompleted = t.mCompleted;
mHasCompletedDate = t.mHasCompletedDate;
mPercentComplete = t.mPercentComplete;
mRunning = false;
mRunSaveTimer = 0;
}
Todo::~Todo()
{
setRunning( false );
+ qDebug("Todo::~Todo() ");
}
void Todo::setRunning( bool run )
{
if ( run == mRunning )
return;
if ( !mRunSaveTimer ) {
mRunSaveTimer = new QTimer ( this );
connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
}
mRunning = run;
if ( mRunning ) {
@@ -72,46 +75,41 @@ void Todo::setRunning( bool run )
} else {
mRunSaveTimer->stop();
saveRunningInfoToFile();
}
}
void Todo::saveRunningInfoToFile()
{
qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
QString dir = KGlobalSettings::timeTrackerDir();
qDebug("%s ", dir.latin1());
- QString file = "%1-%2-%3-%4-%5-%6-%7.tt";
-
- 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 ).arg( mRunStart.time().msec(), 3 );
+ QString file = "%1%2%3-%4%5%6-%7%8%9-";
+ int runtime = mRunStart.secsTo( QDateTime::currentDateTime() );
+ runtime = (runtime / 60) +1;
+ int h = runtime / 60;
+ int m = runtime % 60;
+ int d = h / 24;
+ h = h % 24;
+ 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 ).arg( d,3 ).arg( h,2 ).arg( m,2 );
file.replace ( QRegExp (" "), "0" );
- file = dir +"/" +file;
- qDebug("%s ", file.latin1());
- QStringList dataList;
-
- //Summary
- //Category
- //CategoryColor
- //StartRuntime
- //Runtime
- //Due
- //Start
- //Prio
- //Erledigt
- //Uid
- //Parents uids
+ file = dir +"/" +file + uid()+".ics";
+ qDebug("File %s ",file.latin1() );
+ CalendarLocal cal;
+ cal.setTimeZoneId( " 00:00 Europe/London(UTC)" );
+ cal.addIncidence( clone() );
+ ICalFormat format;
+ format.save( &cal, file );
-
-
}
int Todo::runTime()
{
if ( !mRunning )
return 0;
return mRunStart.secsTo( QDateTime::currentDateTime() );
}
bool Todo::hasRunningSub()
{
if ( mRunning )
return true;