summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt3
-rw-r--r--korganizer/kotodoview.cpp50
-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, 73 insertions, 6 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
@@ -1412,53 +1412,56 @@
{ "Global application font for all apps:","Globale Schriftart:" },
{ "Application Font","Applikationsschriftart" },
{ "Kx/Pi","Kx/Pi" },
{ "Backup","Backup" },
{ "KDE-Pim Global Settings","KDE-Pim Globale Einstellungen" },
{ "Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!","Sorry, der Kalendername \n%1\nist schon in Benutzung!\nBitte wählen Sie einen anderen!" },
{ "Sorry, the file \n%1\nis already loaded!\nPlease choose another file!","Sorry, die Datei \n%1\nist schon geladen!\nBitte wählen Sie eine andere!" },
{ "Choose Color","Wähle Farbe" },
{ " OK "," OK " },
{ " Cancel "," Abbrechen " },
{ "Matching items will be added to list","Passende werden zur Liste hinzugefügt" },
{ "Matching items will be removed from list","Passende werden von der Liste entfernt" },
{ "Search on displayed list only","Suche auf der dargestellten Liste" },
{ "List will be cleared before search","Liste wird vor der Suche gelöscht" },
{ "<center>%1</center> <center>is not running. Do you want to set\nthe state to running?</center>","<center>%1</center> <center>ist nicht am Laufen. Möchten Sie den Zustand auf "laufend" setzen?</center>" },
{ "%1\nis running!","%1\nist am Laufen!" },
{ "Additional Comment:","Zusätzlicher Kommentar:" },
{ "Stop and save","Stopp und Speichern" },
{ "Continue running","Weiter laufen lassen" },
{ "Stop - do not save","Stopp - nicht Speichern" },
{ "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?" },
{ "Time mismatch!","Zeiten stimmen nicht!" },
{ "The start time is\nafter the end time!","Die Startzeit ist\nhinter der Endzeit!" },
{ "Yes, stop todo","Ja, stoppe Todo" },
{ "Todo stopped - no data saved because runtime was < 15 sec!","Todo gestoppt - nichts gespeichert da Laufzeit < 15 sec!" },
{ "Todo started! Double click again to stop!","Todo gestartet! Doppelklicke um es zu stoppen!" },
{ "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." },
{ "Spouse","Ehegatte" },
{ "Notes","Notizen" },
{ "Messanger","Messanger" },
{ "Assistant","Assistent" },
{ "Manager","Manager" },
{ "Secrecy","Sichtbar" },
{ "male","männlich" },
{ "female","weiblich" },
{ "Hide!","Verbergen!" },
{ "Show!","Anzeigen!" },
{ "Details","Details" },
{ "Profession","Beruf" },
{ "Children","Kinder" },
{ "Department","Abteilung" },
{ "Backup cancelled","Backup abgebrochen" },
{ "Backup globally disabled","Backup global abgeschaltet" },
{ "Backup succesfully finished","Backup erfolgreich beendet" },
{ "(Hint: You can enable automatic backup in the global settings!)","(Hinweis: Sie können ein automatisches Backup in den globalen Einstellungen konfigurieren!)" },
{ "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" },
{ "Birthdays","Geburtstage" },
{ "KO/Pi import information!","KO/Pi Import Information!" },
+{ "Start this todo\nand stop all running","Starte dieses Todo\nund stoppe alle Laufenden" },
+{ "Cancel - do not start"," Abbrechen - Todo nicht starten" },
+{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" }, \ 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
@@ -18,96 +18,126 @@
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qlayout.h>
#include <qheader.h>
#include <qcursor.h>
#include <qwhatsthis.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qinputdialog.h>
#include <qvbox.h>
#include <kdebug.h>
#include "koprefs.h"
#include <klocale.h>
#include <kglobal.h>
#include <kdateedit.h>
#include "ktimeedit.h"
#include <kiconloader.h>
#include <kmessagebox.h>
#include <libkcal/icaldrag.h>
#include <libkcal/vcaldrag.h>
#include <libkcal/calfilter.h>
#include <libkcal/dndfactory.h>
#include <libkcal/calendarresources.h>
#include <libkcal/resourcecalendar.h>
#include <kresources/resourceselectdialog.h>
#include <libkcal/kincidenceformatter.h>
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#else
#include <qapplication.h>
#endif
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
#include "docprefs.h"
#include "kotodoview.h"
using namespace KOrg;
+KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) :
+ QDialog( parent, name, true )
+{
+ mStopAll = true;
+ setCaption( i18n("Start todo") );
+ QVBoxLayout* lay = new QVBoxLayout( this );
+ lay->setSpacing( 3 );
+ lay->setMargin( 3 );
+ QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this );
+ lay->addWidget( lab );
+ lab->setAlignment( AlignCenter );
+
+ QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this );
+ lay->addWidget( ok );
+ ok->setDefault( true );
+ QPushButton * start = new QPushButton( i18n("Start todo"), this );
+ lay->addWidget( start );
+ QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this );
+ lay->addWidget( cancel );
+ connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
+ connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) );
+ connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
+ resize( sizeHint() );
+
+}
+void KOStartTodoPrefs::doStop()
+{
+ mStopAll = false;
+ accept();
+}
KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
QDialog( parent, name, true )
{
mTodo = todo;
setCaption( i18n("Stop todo") );
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setSpacing( 3 );
lay->setMargin( 3 );
QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this );
lay->addWidget( lab );
lab->setAlignment( AlignHCenter );
lab = new QLabel( i18n("Additional Comment:"), this );
lay->addWidget( lab );
mComment = new QLineEdit( this );
lay->addWidget( mComment );
QHBox * start = new QHBox ( this );
lay->addWidget( start );
lab = new QLabel( i18n("Start:"), start );
QHBox * end = new QHBox ( this );
lay->addWidget( end );
lab = new QLabel( i18n("End:"), end );
sde = new KDateEdit( start );
ste = new KOTimeEdit( start );
connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
ede = new KDateEdit( end );
ete = new KOTimeEdit(end );
connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
sde->setDate( mTodo->runStart().date() );
ste->setTime( mTodo->runStart().time() );
ede->setDate( QDate::currentDate());
ete->setTime( QTime::currentTime() );
QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
lay->addWidget( ok );
ok->setDefault( true );
QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
lay->addWidget( cancel );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
ok = new QPushButton( i18n("Stop - do not save"), this );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
lay->addWidget( ok );
if (QApplication::desktop()->width() < 320 )
resize( 240, sizeHint().height() );
else
resize( 320, sizeHint().height() );
}
@@ -1174,113 +1204,125 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
}
pendingSubtodo = 0;
//int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
//qDebug("ROW %d ", row);
if (!item) {
newTodo();
return;
} else {
if ( row == 1 ) {
mActiveItem = (KOTodoViewItem *) item;
newSubTodo();
return;
}
if ( row == 5 || row == 6 || row == 2) {
mActiveItem = (KOTodoViewItem *) item;
Todo * t = mActiveItem->todo();
if ( t->isRunning() ) {
if ( t->runTime() < 15) {
t->stopRunning();
mActiveItem->construct();
topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
return;
}
else
toggleRunningItem();
return;
} else {
t->setRunning( true );
mActiveItem->construct();
topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
return;
}
}
}
if ( KOPrefs::instance()->mEditOnDoubleClick )
editItem( item );
else
showItem( item , QPoint(), 0 );
}
void KOTodoView::toggleRunningItem()
{
// qDebug("KOTodoView::toggleRunning() ");
if ( ! mActiveItem )
return;
Todo * t = mActiveItem->todo();
if ( t->isRunning() ) {
KOStopTodoPrefs tp ( t, this );
- if (QApplication::desktop()->width() < 800 ){
+ if (QApplication::desktop()->width() <= 800 ){
int wid = tp.width();
int hei = tp.height();
int xx = (QApplication::desktop()->width()-wid)/2;
int yy = (QApplication::desktop()->height()-hei)/2;
tp.setGeometry( xx,yy,wid,hei );
}
tp.exec();
mActiveItem->construct();
} else {
- int result = KMessageBox::warningContinueCancel(this,
- 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);
- if (result != KMessageBox::Continue) return;
+ KOStartTodoPrefs tp ( t->summary(), this );
+ if (QApplication::desktop()->width() <= 800 ){
+ int wid = tp.width();
+ int hei = tp.height();
+ int xx = (QApplication::desktop()->width()-wid)/2;
+ int yy = (QApplication::desktop()->height()-hei)/2;
+ tp.setGeometry( xx,yy,wid,hei );
+ }
+ if ( !tp.exec() ) return;
+ if ( tp.stopAll() ) {
+ mCalendar->stopAllTodos();
+ t->setRunning( true );
+ updateView();
+ } else {
t->setRunning( true );
mActiveItem->construct();
}
}
+}
void KOTodoView::itemClicked(QListViewItem *item)
{
//qDebug("KOTodoView::itemClicked %d", item);
if (!item) {
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
return;
}
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
if ( pendingSubtodo != 0 ) {
bool allowReparent = true;
QListViewItem *par = item;
while ( par ) {
if ( par == pendingSubtodo ) {
allowReparent = false;
break;
}
par = par->parent();
}
if ( !allowReparent ) {
topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
pendingSubtodo = 0;
} else {
Todo* newParent = todoItem->todo();
Todo* newSub = pendingSubtodo->todo();
pendingSubtodo = 0;
emit reparentTodoSignal( newParent,newSub );
return;
}
}
}
void KOTodoView::setDocumentId( const QString &id )
{
mDocPrefs->setDoc( id );
}
void KOTodoView::itemStateChanged( QListViewItem *item )
{
if (!item) return;
KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 8f0c99e..1b31d0d 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -31,96 +31,110 @@
#include <qlistbox.h>
#include <qpopupmenu.h>
#include <qlabel.h>
#include <qmap.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qlistview.h>
#include <klistview.h>
#include <libkcal/calendar.h>
#include <libkcal/todo.h>
#include <korganizer/baseview.h>
#include "kotodoviewitem.h"
#include "koprefs.h"
#include "koglobals.h"
#include "datenavigator.h"
class QDragEnterEvent;
class QDragMoveEvent;
class QDragLeaveEvent;
class QDropEvent;
class KOTodoViewWhatsThis;
class KDateEdit;
class KOTimeEdit;
class DocPrefs;
class KOStopTodoPrefs : public QDialog
{
Q_OBJECT
public:
KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
private slots:
void doNotSave();
void accept();
private:
Todo* mTodo;
QLineEdit* mComment;
KDateEdit *sde, *ede;
KOTimeEdit *ste, *ete;
};
+class KOStartTodoPrefs : public QDialog
+{
+ Q_OBJECT
+ public:
+ KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ;
+
+ bool stopAll() { return mStopAll; }
+private slots:
+ void doStop();
+private:
+ bool mStopAll;
+
+};
+
class KOTodoListView : public KListView
{
Q_OBJECT
public:
KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
virtual ~KOTodoListView() {}
signals:
void paintNeeded();
void todoDropped(Todo *, int);
void double_Clicked(QListViewItem *item);
void reparentTodoSignal( Todo *,Todo * );
void unparentTodoSignal(Todo *);
void deleteTodo( Todo * );
protected:
void wheelEvent (QWheelEvent *e);
void contentsDragEnterEvent(QDragEnterEvent *);
void contentsDragMoveEvent(QDragMoveEvent *);
void contentsDragLeaveEvent(QDragLeaveEvent *);
void contentsDropEvent(QDropEvent *);
void contentsMousePressEvent(QMouseEvent *);
void contentsMouseMoveEvent(QMouseEvent *);
void contentsMouseReleaseEvent(QMouseEvent *);
void contentsMouseDoubleClickEvent(QMouseEvent *);
private:
void paintEvent(QPaintEvent * pevent);
bool internalDrop;
QString mName;
Calendar *mCalendar;
QPoint mPressPos;
bool mMousePressed;
QListViewItem *mOldCurrent;
bool mFlagKeyPressed;
void keyPressEvent ( QKeyEvent * ) ;
void keyReleaseEvent ( QKeyEvent * ) ;
};
/**
This is the line-edit on top of the todoview for fast addition of new todos
*/
class KOQuickTodo : public QLineEdit
{
public:
KOQuickTodo(QWidget *parent=0);
protected:
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 3b7b183..2efa355 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -32,96 +32,97 @@
#include "event.h"
#include "todo.h"
#include "journal.h"
#include "calfilter.h"
//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
class KConfig;
namespace KCal {
/**
This is the main "calendar" object class for KOrganizer. It holds
information like all appointments/events, user information, etc. etc.
one calendar is associated with each CalendarView (@see calendarview.h).
This is an abstract base class defining the interface to a calendar. It is
implemented by subclasses like @see CalendarLocal, which use different
methods to store and access the data.
Ownership of events etc. is handled by the following policy: As soon as an
event (or any other subclass of IncidenceBase) object is added to the
Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
care of deleting it. All Events returned by the query functions are returned
as pointers, that means all changes to the returned events are immediately
visible in the Calendar. You shouldn't delete any Event object you get from
Calendar.
*/
class Calendar : public QObject, public CustomProperties,
public IncidenceBase::Observer
{
Q_OBJECT
public:
Calendar();
Calendar(const QString &timeZoneId);
virtual ~Calendar();
Incidence * undoIncidence() { return mUndoIncidence; };
bool undoDeleteIncidence();
void deleteIncidence(Incidence *in);
void resetTempSyncStat();
void resetPilotStat(int id);
/**
Clears out the current calendar, freeing all used memory etc.
*/
virtual void close() = 0;
virtual void addCalendar( Calendar* ) = 0;
virtual bool addCalendarFile( QString name, int id ) = 0;
virtual void setSyncEventsReadOnly() = 0;
+ virtual void stopAllTodos() = 0;
/**
Sync changes in memory to persistant storage.
*/
virtual void save() = 0;
virtual QPtrList<Event> getExternLastSyncEvents() = 0;
virtual void removeSyncInfo( QString syncProfile) = 0;
virtual bool isSaving() { return false; }
/**
Return the owner of the calendar's full name.
*/
const QString &getOwner() const;
/**
Set the owner of the calendar. Should be owner's full name.
*/
void setOwner( const QString &os );
/**
Return the email address of the calendar owner.
*/
const QString &getEmail();
/**
Set the email address of the calendar owner.
*/
void setEmail( const QString & );
/**
Set time zone from a timezone string (e.g. -2:00)
*/
void setTimeZone( const QString &tz );
/**
Set time zone from a minutes value (e.g. -60)
*/
void setTimeZone( int tz );
/**
Return time zone as offest in minutes.
*/
int getTimeZone() const;
/**
Compute an ISO 8601 format string from the time zone.
*/
QString getTimeZoneStr() const;
/**
Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
values).
*/
void setTimeZoneId( const QString & );
/**
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 8c4dde1..18f1af8 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -102,96 +102,102 @@ void CalendarLocal::addCalendar( Calendar* cal )
}
}
{
QPtrList<Todo> TodoList = cal->rawTodos();
Todo * ev = TodoList.first();
while ( ev ) {
QString rel = ev->relatedToUid();
if ( !rel.isEmpty() ){
ev->setRelatedTo ( 0 );
ev->setRelatedToUid( rel );
}
ev = TodoList.next();
}
//TodoList = cal->rawTodos();
ev = TodoList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mTodoList.append( ev );
setupRelations( ev );
ev = TodoList.next();
}
}
{
QPtrList<Journal> JournalList = cal->journals();
Journal * ev = JournalList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mJournalList.append( ev );
ev = JournalList.next();
}
}
setModified( true );
}
bool CalendarLocal::load( const QString &fileName )
{
FileStorage storage( this, fileName );
return storage.load();
}
bool CalendarLocal::save( const QString &fileName, CalFormat *format )
{
FileStorage storage( this, fileName, format );
return storage.save();
}
+void CalendarLocal::stopAllTodos()
+{
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ it->setRunning( false );
+
+}
void CalendarLocal::close()
{
Todo * i;
for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
mEventList.setAutoDelete( true );
mTodoList.setAutoDelete( true );
mJournalList.setAutoDelete( false );
mEventList.clear();
mTodoList.clear();
mJournalList.clear();
mEventList.setAutoDelete( false );
mTodoList.setAutoDelete( false );
mJournalList.setAutoDelete( false );
setModified( false );
}
bool CalendarLocal::addAnniversaryNoDup( Event *event )
{
QString cat;
bool isBirthday = true;
if( event->categoriesStr() == i18n( "Anniversary" ) ) {
isBirthday = false;
cat = i18n( "Anniversary" );
} else if( event->categoriesStr() == i18n( "Birthday" ) ) {
isBirthday = true;
cat = i18n( "Birthday" );
} else {
qDebug("addAnniversaryNoDup called without fitting category! ");
return false;
}
Event * eve;
for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
if ( !(eve->categories().contains( cat ) ))
continue;
// now we have an event with fitting category
if ( eve->dtStart().date() != event->dtStart().date() )
continue;
// now we have an event with fitting category+date
if ( eve->summary() != event->summary() )
continue;
// now we have an event with fitting category+date+summary
return false;
}
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 0286b48..d32597f 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,96 +1,97 @@
/*
This file is part of libkcal.
Copyright (c) 1998 Preston Brown
Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
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.
*/
#ifndef KCAL_CALENDARLOCAL_H
#define KCAL_CALENDARLOCAL_H
#include "calendar.h"
namespace KCal {
class CalFormat;
/**
This class provides a calendar stored as a local file.
*/
class CalendarLocal : public Calendar
{
public:
/**
Constructs a new calendar, with variables initialized to sane values.
*/
CalendarLocal();
/**
Constructs a new calendar, with variables initialized to sane values.
*/
CalendarLocal( const QString &timeZoneId );
~CalendarLocal();
void addCalendar( Calendar* );
bool addCalendarFile( QString name, int id );
void setSyncEventsReadOnly();
+ void stopAllTodos();
/**
Loads a calendar on disk in vCalendar or iCalendar format into the current
calendar. Any information already present is lost.
@return true, if successfull, false on error.
@param fileName the name of the calendar on disk.
*/
bool load( const QString &fileName );
/**
Writes out the calendar to disk in the specified \a format.
CalendarLocal takes ownership of the CalFormat object.
@return true, if successfull, false on error.
@param fileName the name of the file
*/
bool save( const QString &fileName, CalFormat *format = 0 );
/**
Clears out the current calendar, freeing all used memory etc. etc.
*/
void close();
void save() {}
/**
Add Event to calendar.
*/
void removeSyncInfo( QString syncProfile);
bool addAnniversaryNoDup( Event *event );
bool addEventNoDup( Event *event );
bool addEvent( Event *event );
/**
Deletes an event from this calendar.
*/
void deleteEvent( Event *event );
/**
Retrieves an event on the basis of the unique string ID.
*/
Event *event( const QString &uid );
/**
Return unfiltered list of all events in calendar.
*/
QPtrList<Event> rawEvents();
QPtrList<Event> getExternLastSyncEvents();
/**
Add a todo to the todolist.
*/
bool addTodo( Todo *todo );
bool addTodoNoDup( Todo *todo );
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 9a8b6e4..5260051 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -66,98 +66,98 @@ void Todo::setRunningFalse( QString s )
if ( ! mRunning )
return;
mRunning = false;
mRunSaveTimer->stop();
saveRunningInfoToFile( s );
}
void Todo::stopRunning()
{
if ( !mRunning )
return;
if ( mRunSaveTimer )
mRunSaveTimer->stop();
mRunning = false;
}
void Todo::setRunning( bool run )
{
if ( run == mRunning )
return;
//qDebug("Todo::setRunning %d ", run);
if ( !mRunSaveTimer ) {
mRunSaveTimer = new QTimer ( this );
connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
}
mRunning = run;
if ( mRunning ) {
mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
mRunStart = QDateTime::currentDateTime();
} else {
mRunSaveTimer->stop();
saveRunningInfoToFile();
}
}
void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
{
if ( !mRunning) return;
mRunning = false;
mRunStart = start;
mRunEnd = end;
saveRunningInfoToFile( comment );
}
void Todo::saveRunningInfoToFile()
{
mRunEnd = QDateTime::currentDateTime();
saveRunningInfoToFile( QString::null );
}
void Todo::saveRunningInfoToFile( QString comment )
{
//qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
- if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) {
- qDebug("Running time < 30 seconds. Skipped. ");
+ if ( mRunStart.secsTo ( mRunEnd) < 15 ) {
+ qDebug("Running time < 15 seconds. Skipped. ");
return;
}
QString dir = KGlobalSettings::timeTrackerDir();
//qDebug("%s ", dir.latin1());
QString file = "%1%2%3-%4%5%6-";
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 );
file.replace ( QRegExp (" "), "0" );
file += uid();
//qDebug("File %s ",file.latin1() );
CalendarLocal cal;
cal.setLocalTime();
Todo * to = (Todo*) clone();
to->setFloats( false );
to->setDtStart( mRunStart );
to->setHasStartDate( true );
to->setDtDue( mRunEnd );
to->setHasDueDate( true );
to->setUid( file );
if ( !comment.isEmpty() ) {
QString des = to->description();
if ( des.isEmpty () )
to->setDescription( "TT-Note: " + comment );
else
to->setDescription( "TT-Note: " + comment +"\n" + des );
}
cal.addIncidence( to );
ICalFormat format;
file = dir +"/" +file +".ics";
format.save( &cal, file );
saveParents();
}
void Todo::saveParents()
{
if (!relatedTo() )
return;
Incidence * inc = relatedTo();
if ( inc->typeID() != todoID )
return;
Todo* to = (Todo*)inc;
bool saveTodo = false;
QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
QFileInfo fi ( file );
if ( fi.exists() ) {
if ( fi.lastModified () < to->lastModified ())
saveTodo = true;
} else {
saveTodo = true;