karm Library API Documentation

KarmStorage Class Reference

Singleton to store/retrieve KArm data to/from persistent storage. Logic that gets and stores KArm data to disk. More...

#include <karmstorage.h>

List of all members.

Public Methods

QString load (TaskView *taskview, const Preferences *preferences)
void save (TaskView *taskview)
QString loadFromFlatFile (TaskView *taskview, const QString &filename)
QString loadFromFlatFileCumulative (TaskView *taskview, const QString &filename)
void changeTime (const Task *task, const long deltaSeconds)
void setName (const Task *, const QString &)
void startTimer (const Task *)
void stopTimer (const Task *task)
void addComment (const Task *task, const QString &comment)
bool removeTask (Task *task)
QString addTask (const Task *task, const Task *parent)
bool isEmpty ()
bool isNewStorage (const Preferences *preferences) const
QValueList< HistoryEventgetHistory (const QDate &from, const QDate &to)

Static Public Methods

KarmStorage * instance ()


Detailed Description

Singleton to store/retrieve KArm data to/from persistent storage. Logic that gets and stores KArm data to disk.

The storage is an iCalendar file. Also included are methods to import KArm data from the two legacy file formats.

All logic that deals with getting and saving data should go here. The storage logic has changed at least twice already in KArm's history, and chances are good it will change again (for example, allowing KOrganizer and KArm to access the same iCalendar file simultaneously).

Prior to KDE 3.2, KArm just stored totals for each task--a session total and a task total. The session total was reset to zero each time KArm started up or after the user reset the session times to zero. With the release of KDE 3.2, KArm now stores these task totals as well as logging the history of each start/stop event; that is, every time you start a timer and then stop a timer on a task, KArm records this as an iCalendar event.

Author:
Mark Bucciarelli <mark@hubcapconsulting.com>

Definition at line 62 of file karmstorage.h.


Member Function Documentation

QString KarmStorage::loadFromFlatFile TaskView   taskview,
const QString   filename
 

Read tasks and their total times from a text file (legacy storage).

This reads from one of the two legacy file formats. In this version, the parent task times do not include the sum of all their children's times.

The format of the file is zero or more lines of: 1 task id (a number) time in minutes string task name [string] desktops, in which to count. e.g. "1,2,5" (optional)

Definition at line 244 of file karmstorage.cpp.

References addTask(), QString::arg(), QTextStream::atEnd(), Task::changeTimes(), QFile::close(), QPtrStack::count(), QFile::exists(), QString::isNull(), Task::name(), QFile::open(), QPtrStack::pop(), QPtrStack::push(), QTextStream::readLine(), QListViewItem::setOpen(), Task::setUid(), QPtrStack::top(), and Task::uid().

Referenced by TaskView::loadFromFlatFile(), and loadFromFlatFileCumulative().

QString KarmStorage::loadFromFlatFileCumulative TaskView   taskview,
const QString   filename
 

Reads tasks and their total times from text file (legacy).

This is the older legacy format, where the task totals included the children totals.

See also:
loadFromFlatFile

Definition at line 327 of file karmstorage.cpp.

References TaskView::first_child(), loadFromFlatFile(), and Task::nextSibling().

void KarmStorage::setName const Task  ,
const QString  
[inline]
 

Log a change to a task name.

For iCalendar storage, there is no need to log an Event for this event, since unique id's are used to link Events to Todos. No matter how many times you change a task's name, the uid stays the same.

Parameters:
task  The task
oldname  The old name of the task. The new name is in the task object already.

Definition at line 173 of file karmstorage.h.

Referenced by Task::setName().

void KarmStorage::startTimer const Task   [inline]
 

Log the event that a timer has started for a task.

For the iCalendar storage, there is no need to log anything for this event. We log an event when the timer is stopped.

Parameters:
task  The task the timer was started for.

Definition at line 184 of file karmstorage.h.

Referenced by Task::setRunning().

void KarmStorage::stopTimer const Task   task
 

Log the event that the timer has stopped for this task.

The task stores the last time a timer was started, so we log a new iCal Event with the start and end times for this task.

See also:
KarmStorage::changeTime
Parameters:
task  The task the timer was stopped for.

Definition at line 508 of file karmstorage.cpp.

References QDateTime::currentDateTime(), QDateTime::secsTo(), and Task::startTime().

Referenced by Task::setRunning().

void KarmStorage::addComment const Task   task,
const QString   comment
 

Log a new comment for this task.

iCal allows multiple comment tags. So we just add a new comment to the todo for this task and write the calendar.

Parameters:
task  The task that gets the comment
comment  The comment

Definition at line 488 of file karmstorage.cpp.

References Task::comment(), and Task::uid().

Referenced by Task::addComment().

bool KarmStorage::removeTask Task   task
 

Remove this task from iCalendar file.

Removes task as well as all event history for this task.

Parameters:
task  The task to be removed.
Returns:
true if change was saved, false otherwise

Definition at line 457 of file karmstorage.cpp.

References Task::uid().

Referenced by Task::remove().

QString KarmStorage::addTask const Task   task,
const Task   parent
 

Add this task from iCalendar file.

Create a new KCal::Todo object and load with task information. If parent is not zero, then set the RELATED-TO attribute for this Todo.

Parameters:
task  The task to be removed.
parent  The parent of this task. Must have a uid() that is in the existing calendar. If zero, this task is considered a root task.
Returns:
The unique ID for the new VTODO. Return an null QString if there was an error creating the new calendar object.

Definition at line 440 of file karmstorage.cpp.

References Task::asTodo(), and Task::uid().

Referenced by loadFromFlatFile(), and TaskView::newTask().

bool KarmStorage::isEmpty  
 

Check if the iCalendar file currently loaded has any Todos in it.

Returns:
true if the CalendarLocal::rawTodos() list is not empty.

Definition at line 223 of file karmstorage.cpp.

bool KarmStorage::isNewStorage const Preferences   preferences const
 

Check if iCalendar file name in the preferences has changed since the last call to load.

If there is no calendar file currently loaded, return false.

Parameters:
preferences  Set of KArm preferences.
Returns:
true if a previous file has been loaded and the iCalendar file specified in the preferences is different.

Definition at line 231 of file karmstorage.cpp.

References Preferences::iCalFile(), and QString::isNull().

QValueList< HistoryEvent > KarmStorage::getHistory const QDate   from,
const QDate   to
 

Return a list of start/stop events for the given date range.

Definition at line 585 of file karmstorage.cpp.

References QDate::addDays(), QValueList::append(), QString::isNull(), and QString::toLong().

Referenced by TaskView::getHistory().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for karm Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:37:53 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003