summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt12
-rw-r--r--korganizer/koprefs.cpp7
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/koprefsdialog.cpp14
-rw-r--r--korganizer/kotodoview.cpp30
-rw-r--r--korganizer/kotodoview.h1
-rw-r--r--korganizer/kotodoviewitem.cpp62
-rw-r--r--libkcal/todo.cpp44
-rw-r--r--libkcal/todo.h16
9 files changed, 156 insertions, 31 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index b4e26c2..5257bff 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1314,27 +1314,39 @@
{ "\n\nDo you really want to print this item?","\n\nMöchten Sie wirklich diesen Eintrag ausdrucken? " },
{ "KO/Pi Print Confirmation","KO/Pi Druckbestätigung" },
{ "This prints the view as you see it.\n(With the complete content, of course.)\nYou may change the print layout by resizing the view.\nPrint unscaled may print several pages\ndepending on the amount of data.\nPrint scaled down will print all on one page.\nPrint scaled up/down will print all on one page,\nbut will scale up the text to page boundaries,\nif the text is smaller than the page.\nYou can select page geometry setup in the next dialog.\n","Dies druckt die Ansicht wie man sie sieht.\n(Mit dem kompletten Inhalt natürlich.)\nMan kann das Layout ändern durch ändern der Fenstergröße.\nDrucke unskaliert druckt ggf. mehrere Seiten\nabhängig von der Menge der Daten.\nDrucke runterskaliert um auf eine Seite zu passen\ndruckt alles auf eine Seite.\nDrucke hoch/runterskaliert um genau auf eine Seite zu passen\nvergrößert den Text gegebenenfalls.\nDas Seitenlayout kann im nächsten Dialog gewählt werden.\n" },
{ "KO/Pi Printout","KO/Pi Ausdruck" },
{ "Print unscaled","Drucke unskaliert" },
{ "Print scaled down to fit one page","Drucke runterskaliert um auf eine Seite zu passen." },
{ "Print scaled up/down to fit one page","Drucke hoch/runterskaliert um genau auf eine Seite zu passen." },
{ "Printout Mode","Druck Modus" },
{ "Filter menu icon","Filtermenu Icon" },
{ "<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n","<p><b>A+(shift oder ctrl)</b>: Zeige Zeit bis zum nächsten Alarm</p>\n" },
{ "<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n","<p><b>N</b>: Wechsle zur nächsten Ansicht, die ein Icon in der Toolbar hat</p>\n" },
{ "%1d","%1t" },
{ "%1h","%1std" },
{ "%1min","%1min" },
{ "( %1 before )","( %1 vorher )" },
{ "The next alarm is in\nless than one minute!","Der nächste Alarm kommt in\nweniger als einer Minute!" },
{ "\nThe internal alarm notification is disabled!\n","\nDie interne Alarmbenachrichtigung ist ausgeschaltet!\n" },
{ "Enable it in the settings menu, TAB alarm.","Schalten Sie sie an im Menu Einstellungen, TAB Alarm." },
{ "Show Sync Events in WN+Agenda","Zeige Sync-Ereignisse in WN+Agenda" },
{ "Use short date in WN+Event view","Zeige Kurzdatum in WN+Terminanzeige" },
{ "Number of max.displayed todo prios:","Anzahl max.angezeigter Todo-Prios:" },
{ " on "," am " },
{ "On: ","Am: " },
{ "<i>The recurrence is computed from the start datetime!</i>","<i>Die Wiederholung wird vom Startwert aus berechnet!</i>" },
+{ "Start/Stop todo...","Starte/Stoppe Todo..." },
+{ "Color for running todos:","Farbe für laufende Todos:" },
+{ "The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?","Das Todo\n%1\nist gestartet.\nWollen Sie es\nauf gestoppt setzen?" },
+{ "Todo is started","Todo is gestarted" },
+{ "Stop todo","Stoppe Todo" },
+{ "Todo is stopped","Todo ist gestoppt" },
+{ "Start todo","Starte Todo" },
+{ "The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?","Das Todo\n%1\nist gestoppt.\nWollen Sie es auf\ngestartet setzen?" },
+{ "","" },
+{ "","" },
+{ "","" },
+{ "","" },
{ "","" },
{ "","" },
{ "","" },
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 5879a2d..e8c7c76 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -41,55 +41,51 @@
#include <klocale.h>
#include <kdebug.h>
#include <kemailsettings.h>
#include <kstaticdeleter.h>
#include <libkdepim/kpimglobalprefs.h>
#include "koprefs.h"
#include "mainwindow.h"
KOPrefs *KOPrefs::mInstance = 0;
static KStaticDeleter<KOPrefs> insd;
KOPrefs::KOPrefs() :
KPimPrefs("korganizerrc")
{
mCategoryColors.setAutoDelete(true);
fillMailDefaults();
mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
QColor defaultHolidayColor = QColor(255,0,0);
QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
QColor defaultTodoDueTodayColor = QColor(255,220,100);
QColor defaultTodoOverdueColor = QColor(255,153,125);
-
-
+ QColor defaultTodoRunColor = QColor(99,194,30);
KPrefs::setCurrentGroup("General");
-
-
addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
-
addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
addItemBool("ShowIconSearch",&mShowIconSearch,true);
addItemBool("ShowIconList",&mShowIconList,true);
addItemBool("ShowIconDay1",&mShowIconDay1,true);
addItemBool("ShowIconDay5",&mShowIconDay5,true);
addItemBool("ShowIconDay6",&mShowIconDay6,true);
addItemBool("ShowIconDay7",&mShowIconDay7,true);
addItemBool("ShowIconMonth",&mShowIconMonth,true);
addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
addItemBool("ShowIconBack",&mShowIconBack,true);
addItemBool("ShowIconToday",&mShowIconToday,true);
addItemBool("ShowIconForward",&mShowIconForward,true);
addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
addItemBool("ShowIconNext",&mShowIconNext,true);
addItemBool("ShowIconJournal",&mShowIconJournal,true);
addItemBool("ShowIconStretch",&mShowIconStretch,true);
addItemBool("ShowIconFilter",&mShowIconFilter,false);
addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
@@ -196,48 +192,49 @@ KOPrefs::KOPrefs() :
QString hdp= locateLocal("data","korganizer")+"/";
#endif
KPrefs::setCurrentGroup("LoadSaveFileNames");
addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
KPrefs::setCurrentGroup("Locale");
addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
KPrefs::setCurrentGroup("Colors");
addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
+ addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
addItemBool("MonthViewWeek",&mMonthViewWeek,false);
addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
addItemBool("UseAppColors",&mUseAppColors,false);
KPrefs::setCurrentGroup("Views");
addItemBool("Show Date Navigator",&mShowDateNavigator,true);
addItemInt("Hour Size",&mHourSize,8);
addItemBool("Show Daily Recurrences",&mDailyRecur,true);
addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
addItemBool("ShowShortMonthName",&mMonthShowShort,false);
addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
#ifdef DESKTOP_VERION
addItemBool("Enable ToolTips",&mEnableToolTips,true);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index cf8dae6..d511faa 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -118,48 +118,49 @@ class KOPrefs : public KPimPrefs
QFont mTimeBarFont;
QFont mMonthViewFont;
QFont mAgendaViewFont;
QFont mMarcusBainsFont;
QFont mTimeLabelsFont;
QFont mTodoViewFont;
QFont mListViewFont;
QFont mDateNavigatorFont;
QFont mEditBoxFont;
QFont mJornalViewFont;
QFont mWhatsNextFont;
QFont mEventViewFont;
QColor mHolidayColor;
QColor mHighlightColor;
QColor mEventColor;
QColor mTodoDoneColor;
QColor mAgendaBgColor;
QColor mWorkingHoursColor;
QColor mTodoDueTodayColor;
QColor mTodoOverdueColor;
+ QColor mTodoRunColor;
QColor mMonthViewEvenColor;
QColor mMonthViewOddColor;
QColor mMonthViewHolidayColor;
bool mMonthViewUsesDayColors;
bool mMonthViewSatSunTog;
bool mMonthViewWeek;
QColor mAppColor1;
QColor mAppColor2;
bool mUseAppColors;
int mDayBegins;
int mHourSize;
int mAllDaySize;
bool mShowFullMenu;
bool mDailyRecur;
bool mWeeklyRecur;
bool mMonthDailyRecur;
bool mMonthWeeklyRecur;
bool mMonthShowIcons;
bool mMonthShowShort;
bool mEnableToolTips;
bool mEnableMonthScroll;
bool mFullViewMonth;
bool mMonthViewUsesCategoryColor;
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp
index 0bbb3bf..a8943de 100644
--- a/korganizer/koprefsdialog.cpp
+++ b/korganizer/koprefsdialog.cpp
@@ -874,54 +874,64 @@ dummy =
KPrefsDialogWidBool *showCompletedTodo =
addWidBool(i18n("To-do view shows completed Todos"),
&(KOPrefs::instance()->mShowCompletedTodo),topFrame);
topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0);
dummy =
addWidBool(i18n("To-do view shows complete as 'xx %'"),
&(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame);
topLayout->addWidget(dummy->checkBox(),ii++,0);
dummy =
addWidBool(i18n("Small To-do view uses smaller font"),
&(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame);
topLayout->addWidget(dummy->checkBox(),ii++,0);
dummy =
addWidBool(i18n("Todo view uses category colors"),
&(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame);
topLayout->addWidget(dummy->checkBox(),ii++,0);
- QWidget* wid = new QWidget( topFrame );
+ QWidget* wid = new QWidget( topFrame );
+ // Todo run today color
+ KPrefsDialogWidColor *todoRunColor =
+ addWidColor(i18n("Color for running todos:"),
+ &(KOPrefs::instance()->mTodoRunColor),wid);
+ QHBoxLayout *widLayout = new QHBoxLayout(wid);
+ widLayout->addWidget( todoRunColor->label() );
+ widLayout->addWidget( todoRunColor->button() );
+ topLayout->addWidget(wid,ii++,0);
+
+ wid = new QWidget( topFrame );
// Todo due today color
KPrefsDialogWidColor *todoDueTodayColor =
addWidColor(i18n("Todo due today color:"),
&(KOPrefs::instance()->mTodoDueTodayColor),wid);
- QHBoxLayout *widLayout = new QHBoxLayout(wid);
+ widLayout = new QHBoxLayout(wid);
widLayout->addWidget( todoDueTodayColor->label() );
widLayout->addWidget( todoDueTodayColor->button() );
topLayout->addWidget(wid,ii++,0);
//topLayout->addWidget(todoDueTodayColor->button(),ii++,1);
// Todo overdue color
wid = new QWidget( topFrame );
widLayout = new QHBoxLayout(wid);
KPrefsDialogWidColor *todoOverdueColor =
addWidColor(i18n("Todo overdue color:"),
&(KOPrefs::instance()->mTodoOverdueColor),wid);
widLayout->addWidget(todoOverdueColor->label());
widLayout->addWidget(todoOverdueColor->button());
topLayout->addWidget(wid,ii++,0);
dummy =
addWidBool(i18n("Colors are applied to text"),
&(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame);
topLayout->addWidget(dummy->checkBox(),ii++,0);
dummy =
addWidBool(i18n("Allday Agenda view shows todos"),
&(KOPrefs::instance()->mShowTodoInAgenda),topFrame);
topLayout->addWidget(dummy->checkBox(),ii++,0);
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 935a5f5..7ee1eef 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -460,48 +460,50 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
QString label = QString ("%1 %").arg (i);
mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
}
connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
mItemPopupMenu = new QPopupMenu(this);
mItemPopupMenu->insertItem(i18n("Show..."), this,
SLOT (showTodo()));
mItemPopupMenu->insertItem(i18n("Edit..."), this,
SLOT (editTodo()));
mItemPopupMenu->insertItem( i18n("Delete"), this,
SLOT (deleteTodo()));
mItemPopupMenu->insertItem( i18n("Clone..."), this,
SLOT (cloneTodo()));
mItemPopupMenu->insertItem( i18n("Move..."), this,
SLOT (moveTodo()));
mItemPopupMenu->insertItem( i18n("Beam..."), this,
SLOT (beamTodo()));
mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
SLOT (cancelTodo()));
mItemPopupMenu->insertSeparator();
+ mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
+ SLOT (toggleRunningItem()));
mItemPopupMenu->insertItem( i18n("New Todo..."), this,
SLOT (newTodo()));
mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
SLOT (newSubTodo()));
mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
SLOT (unparentTodo()),0,21);
mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
SLOT (reparentTodo()),0,22);
mItemPopupMenu->insertSeparator();
#if 0
mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
this, SLOT( purgeCompleted() ) );
mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
this, SLOT( toggleCompleted() ),0, 33 );
mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
this, SLOT( toggleQuickTodo() ),0, 34 );
mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
this, SLOT( toggleRunning() ),0, 35 );
#endif
mPopupMenu = new QPopupMenu(this);
mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
SLOT (newTodo()),0,1);
mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
@@ -1078,59 +1080,85 @@ void KOTodoView::changedCategories(int index)
if ( !colcat.isEmpty() ) {
if ( categories.find ( colcat ) != categories.end () ) {
categories.remove( colcat );
categories.prepend( colcat );
}
}
mActiveItem->todo()->setCategories (categories);
mActiveItem->construct();
mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
}
}
void KOTodoView::itemDoubleClicked(QListViewItem *item)
{
if ( pendingSubtodo != 0 ) {
topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
}
pendingSubtodo = 0;
int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
//qDebug("ROW %d ", row);
if (!item) {
newTodo();
return;
} else {
- if ( row == 1 || row == 2 ) {
+ if ( row == 2 ) {
mActiveItem = (KOTodoViewItem *) item;
newSubTodo();
return;
}
+ if ( row == 1 ) {
+ mActiveItem = (KOTodoViewItem *) item;
+ toggleRunningItem();
+ 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() ) {
+ int result = KMessageBox::warningContinueCancel(this,
+ i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 20 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
+ if (result != KMessageBox::Continue) return;
+ t->setRunning( false );
+ mActiveItem->construct();
+ } else {
+ int result = KMessageBox::warningContinueCancel(this,
+ i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 20 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
+ if (result != KMessageBox::Continue) return;
+ 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!"));
qDebug("Recursive reparenting not possible ");
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index d0788a9..d368513 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -185,48 +185,49 @@ class KOTodoView : public KOrg::BaseView
void itemClicked(QListViewItem *);
void itemStateChanged(QListViewItem *);
void modified(bool);
void itemDoubleClicked(QListViewItem *item);
signals:
void newTodoSignal();
void newSubTodoSignal(Todo *);
void unparentTodoSignal(Todo *);
void reparentTodoSignal( Todo *,Todo * );
void showTodoSignal(Todo *);
void editTodoSignal(Todo *);
void deleteTodoSignal(Todo *);
void todoModifiedSignal (Todo *, int);
void isModified(bool);
void cloneTodoSignal( Incidence * );
void cancelTodoSignal( Incidence * );
void moveTodoSignal( Incidence * );
void beamTodoSignal( Incidence * );
void purgeCompletedSignal();
protected slots:
+ void toggleRunningItem();
void paintNeeded();
void processSelectionChange();
void addQuickTodo();
void setTodoModified( Todo* );
void todoModified(Todo *, int );
private:
/*
* the TodoEditor approach is rather unscaling in the long
* run.
* Korganizer keeps it in memory and we need to update
* 1. make KOTodoViewItem a QObject again?
* 2. add a public method for setting one todo modified?
* 3. add a private method for setting a todo modified + friend here?
* -- zecke 2002-07-08
*/
KOTodoViewWhatsThis* mKOTodoViewWhatsThis;
friend class KOTodoListView;
void paintEvent(QPaintEvent * pevent);
bool mPendingUpdateBeforeRepaint;
friend class KOTodoViewItem;
QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
void restoreItemState( QListViewItem * );
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 6559119..66f8d06 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,46 +1,47 @@
/*
This file is part of KOrganizer.
Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <klocale.h>
#include <kdebug.h>
#include <qapp.h>
+#include <kglobal.h>
#include <kiconloader.h>
#include "kotodoviewitem.h"
#include "kotodoview.h"
#include "koprefs.h"
KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
: QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
{
construct();
}
KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
: QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
{
construct();
}
QString KOTodoViewItem::key(int column,bool) const
{
QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
if (it == mKeyMap.end()) {
return text(column).lower();
} else {
@@ -99,66 +100,77 @@ void KOTodoViewItem::construct()
QDate d = mTodo->dtDue().date();
keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
// setSortKey(3,keyd);
if (mTodo->doesFloat()) {
setText(4,"");
}
else {
setText(4,mTodo->dtDueTimeStr());
QTime t = mTodo->dtDue().time();
keyt.sprintf("%02d%02d",t.hour(),t.minute());
//setSortKey(4,keyt);
}
} else {
setText(3,"");
setText(4,"");
}
setSortKey(3,keyd);
setSortKey(4,keyt);
if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
- if (mTodo->hasStartDate()) {
- setText(5, mTodo->dtStartDateStr());
- QDate d = mTodo->dtStart().date();
- skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
-
- if (mTodo->doesFloat()) {
- setText(6,"");
- }
- else {
- setText(6,mTodo->dtStartTimeStr());
- QTime t = mTodo->dtStart().time();
+ keyd = "";
+ keyt = "";
+
+ if (mTodo->isRunning() ) {
+ QDate d = mTodo->runStart().date();
+ QTime t = mTodo->runStart().time();
skeyt.sprintf("%02d%02d",t.hour(),t.minute());
-
- }
+ skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
+ keyd = KGlobal::locale()->formatDate( d );
+ keyt = KGlobal::locale()->formatTime( t );
+
} else {
- setText(5,"");
- setText(6,"");
+
+ if (mTodo->hasStartDate()) {
+ keyd = mTodo->dtStartDateStr();
+ QDate d = mTodo->dtStart().date();
+ skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
+
+ if ( !mTodo->doesFloat()) {
+ keyt = mTodo->dtStartTimeStr();
+ QTime t = mTodo->dtStart().time();
+ skeyt.sprintf("%02d%02d",t.hour(),t.minute());
+
+ }
+
+ }
}
+ setText(5,keyd);
+ setText(6,keyt);
setSortKey(5,skeyd);
setSortKey(6,skeyt);
setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
setText(8,mTodo->categoriesStr());
#if 0
// Find sort id in description. It's the text behind the last '#' character
// found in the description. White spaces are removed from beginning and end
// of sort id.
int pos = mTodo->description().findRev('#');
if (pos < 0) {
setText(6,"");
} else {
QString str = mTodo->description().mid(pos+1);
str.stripWhiteSpace();
setText(6,str);
}
#endif
m_known = false;
m_init = false;
setMyPixmap();
@@ -347,55 +359,63 @@ void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, i
{
QColorGroup _cg = cg;
QColorGroup::ColorRole role;
if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
role = QColorGroup::Text;
else
role = QColorGroup::Base;
//#ifndef KORG_NOLVALTERNATION
if (isAlternate())
_cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
QColor colorToSet;
if ( setColor ) {
QStringList categories = mTodo->categories();
QString cat = categories.first();
if ( !cat.isEmpty()) {
colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
} else
setColor = false;
}
bool openMode = !isOpen();
// maybe we are in flat-display-mode
if ( !firstChild() )
openMode = false;
- int odue = mTodo->hasDueSubTodo( openMode );
- if (odue == 2) {
- colorToSet = KOPrefs::instance()->mTodoOverdueColor;
- setColor = true;
- } else if ( odue == 1 ) {
- colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
+ bool colorRunning = mTodo->isRunning();
+ if ( ! colorRunning && openMode )
+ colorRunning = mTodo->hasRunningSub();
+ if ( colorRunning ) {
setColor = true;
+ colorToSet = KOPrefs::instance()->mTodoRunColor;
+ } else {
+ int odue = mTodo->hasDueSubTodo( openMode );
+ if (odue == 2) {
+ colorToSet = KOPrefs::instance()->mTodoOverdueColor;
+ setColor = true;
+ } else if ( odue == 1 ) {
+ colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
+ setColor = true;
+ }
}
if ( setColor ) {
_cg.setColor(role,colorToSet );
if ( role == QColorGroup::Base) {
int rgb = colorToSet.red();
rgb += colorToSet.blue()/2;
rgb += colorToSet.green();
if ( rgb < 200 )
_cg.setColor(QColorGroup::Text,Qt::white );
}
}
//#endif
if ( column > 0 ){
if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
p->save();
int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
p->fillRect( 0, 0, width, height(), _cg.base() ); // background
// p->setPen(Qt::black ); //border
// p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
QColor fc = KOPrefs::instance()->mHighlightColor;
if ( mTodo->percentComplete() == 100 )
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index a496404..7dee4cd 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -14,64 +14,108 @@
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 <klocale.h>
#include <kdebug.h>
#include "todo.h"
using namespace KCal;
Todo::Todo(): Incidence()
{
// mStatus = TENTATIVE;
mHasDueDate = false;
setHasStartDate( false );
mCompleted = getEvenTime(QDateTime::currentDateTime());
mHasCompletedDate = false;
mPercentComplete = 0;
+ mRunning = false;
+ mRunSaveTimer = 0;
}
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 );
+}
+
+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 ) {
+ mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
+ mRunStart = QDateTime::currentDateTime();
+ } else {
+ mRunSaveTimer->stop();
+ saveRunningInfoToFile();
+ }
+}
+void Todo::saveRunningInfoToFile()
+{
+ qDebug("Todo::saveRunningInfoToFile() ");
}
+int Todo::runTime()
+{
+ if ( !mRunning )
+ return 0;
+ return mRunStart.secsTo( QDateTime::currentDateTime() );
+}
+bool Todo::hasRunningSub()
+{
+ if ( mRunning )
+ return true;
+ Incidence *aTodo;
+ for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
+ if ( ((Todo*)aTodo)->hasRunningSub() )
+ return true;
+ }
+ return false;
+}
Incidence *Todo::clone()
{
return new Todo(*this);
}
bool Todo::contains ( Todo* from )
{
if ( !from->summary().isEmpty() )
if ( !summary().startsWith( from->summary() ))
return false;
if ( from->hasStartDate() ) {
if ( !hasStartDate() )
return false;
if ( from->dtStart() != dtStart())
return false;
}
if ( from->hasDueDate() ){
if ( !hasDueDate() )
return false;
if ( from->dtDue() != dtDue())
return false;
}
if ( !from->location().isEmpty() )
diff --git a/libkcal/todo.h b/libkcal/todo.h
index a22d4b7..fe43357 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -4,55 +4,58 @@
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 TODO_H
#define TODO_H
//
// Todo component, representing a VTODO object
//
#include "incidence.h"
+#include <qtimer.h>
+
namespace KCal {
/**
This class provides a Todo in the sense of RFC2445.
*/
-class Todo : public Incidence
+ class Todo : public QObject,public Incidence
{
+ Q_OBJECT
public:
Todo();
Todo(const Todo &);
~Todo();
typedef ListBase<Todo> List;
QCString type() const { return "Todo"; }
/** Return an exact copy of this todo. */
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;
/** for setting the todo's due date/time with a QDateTime. */
void setDtDue(const QDateTime &dtDue);
/** returns an event's Due date/time as a QDateTime. */
QDateTime dtDue() const;
/** returns an event's due time as a string formatted according to the
users locale settings */
QString dtDueTimeStr() const;
/** returns an event's due date as a string formatted according to the
users locale settings */
QString dtDueDateStr(bool shortfmt=true) const;
/** returns an event's due date and time as a string formatted according
to the users locale settings */
QString dtDueStr(bool shortfmt=true) const;
@@ -93,44 +96,53 @@ class Todo : public Incidence
void setCompleted(bool);
/**
Return how many percent of the task are completed. Returns a value
between 0 and 100.
*/
int percentComplete() const;
/**
Set how many percent of the task are completed. Valid values are in the
range from 0 to 100.
*/
void setPercentComplete(int);
/** return date and time when todo was completed */
QDateTime completed() const;
QString completedStr(bool shortF = true) const;
/** set date and time of completion */
void setCompleted(const QDateTime &completed);
/** Return true, if todo has a date associated with completion */
bool hasCompletedDate() const;
bool contains ( Todo*);
void checkSetCompletedFalse();
bool setRecurDates();
-
+ bool isRunning() {return mRunning;}
+ bool hasRunningSub();
+ void setRunning( bool );
+ int runTime();
+ QDateTime runStart () const { return mRunStart;}
+ public slots:
+ void saveRunningInfoToFile();
private:
+ bool mRunning;
+ QTimer * mRunSaveTimer;
+ QDateTime mRunStart;
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtDue; // due date of todo
bool mHasDueDate; // if todo has associated due date
// int mStatus; // confirmed/delegated/tentative/etc
QDateTime mCompleted;
bool mHasCompletedDate;
int mPercentComplete;
};
bool operator==( const Todo&, const Todo& );
}
#endif