summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-17 09:29:18 (UTC)
committer zautrix <zautrix>2005-06-17 09:29:18 (UTC)
commit160b471e4d254fd45dbbd161178de15a14163a0c (patch) (unidiff)
tree149a5bf6ef1eb0399c46c928a53d31fa298ac383
parentcd71ce2dd43e4cca3b3da3f599616e7b1b6b8deb (diff)
downloadkdepimpi-160b471e4d254fd45dbbd161178de15a14163a0c.zip
kdepimpi-160b471e4d254fd45dbbd161178de15a14163a0c.tar.gz
kdepimpi-160b471e4d254fd45dbbd161178de15a14163a0c.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp49
-rw-r--r--korganizer/kotodoview.h5
-rw-r--r--libkcal/todo.cpp2
-rw-r--r--libkcal/todo.h2
4 files changed, 45 insertions, 13 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index c5fae17..13e88ef 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,146 +1,171 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qinputdialog.h> 32#include <qinputdialog.h>
33 33
34#include <qvbox.h> 34#include <qvbox.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include "koprefs.h" 36#include "koprefs.h"
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kdateedit.h>
40#include "ktimeedit.h"
39#include <kiconloader.h> 41#include <kiconloader.h>
40#include <kmessagebox.h> 42#include <kmessagebox.h>
41 43
42#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
43#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
44#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
45#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
46#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
47#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
48#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
49#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
50#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
51#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
52#else 54#else
53#include <qapplication.h> 55#include <qapplication.h>
54#endif 56#endif
55#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
56#include "calprinter.h" 58#include "calprinter.h"
57#endif 59#endif
58#include "docprefs.h" 60#include "docprefs.h"
59 61
60#include "kotodoview.h" 62#include "kotodoview.h"
61using namespace KOrg; 63using namespace KOrg;
62 64
63 65
64KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 66KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
65 QDialog( parent, name, true ) 67 QDialog( parent, name, true )
66{ 68{
67 mTodo = todo; 69 mTodo = todo;
68 setCaption( i18n("Stop todo") ); 70 setCaption( i18n("Stop todo") );
69 QVBoxLayout* lay = new QVBoxLayout( this ); 71 QVBoxLayout* lay = new QVBoxLayout( this );
70 lay->setSpacing( 3 ); 72 lay->setSpacing( 3 );
71 lay->setMargin( 3 ); 73 lay->setMargin( 3 );
72 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this ); 74 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this );
73 lay->addWidget( lab ); 75 lay->addWidget( lab );
74 lab->setAlignment( AlignHCenter ); 76 lab->setAlignment( AlignHCenter );
75 77 lab = new QLabel( i18n("Additional Comment:"), this );
78 lay->addWidget( lab );
79 mComment = new QLineEdit( this );
80 lay->addWidget( mComment );
81 QHBox * start = new QHBox ( this );
82 lay->addWidget( start );
83 lab = new QLabel( i18n("Start:"), start );
84 QHBox * end = new QHBox ( this );
85 lay->addWidget( end );
86 lab = new QLabel( i18n("End:"), end );
87 sde = new KDateEdit( start );
88 ste = new KOTimeEdit( start );
89 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
90 ede = new KDateEdit( end );
91 ete = new KOTimeEdit(end );
92 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
93 sde->setDate( mTodo->runStart().date() );
94 ste->setTime( mTodo->runStart().time() );
95 ede->setDate( QDate::currentDate());
96 ete->setTime( QTime::currentTime() );
76 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 97 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
77 lay->addWidget( ok ); 98 lay->addWidget( ok );
78 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 99 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
79 lay->addWidget( cancel ); 100 lay->addWidget( cancel );
80 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 101 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
81 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 102 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
82 ok = new QPushButton( i18n("Stop - do not save"), this ); 103 ok = new QPushButton( i18n("Stop - do not save"), this );
83 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 104 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
84 lay->addWidget( ok ); 105 lay->addWidget( ok );
85 resize( 200, 200 ); 106 if (QApplication::desktop()->width() < 320 )
107 resize( 240, 200 );
108 else
109 resize( 320, 200 );
110
86} 111}
87 112
88void KOStopTodoPrefs::accept() 113void KOStopTodoPrefs::accept()
89{ 114{
90 qDebug("KOStopTodoPrefs::accept() "); 115 QDateTime start = QDateTime( sde->date(), ste->getTime() );
91 116 QDateTime stop = QDateTime( ede->date(), ete->getTime() );
92 117 if ( start > stop ) {
93#if 0 118 KMessageBox::sorry(this,
94 t->setRunningFalse( comment ); 119 i18n("The start time is\nafter the end time!"),
95 120 i18n("Time mismatch!"));
96 t->setRunning( false ); 121 return;
97#endif 122 }
98 123 mTodo->saveRunningInfo( mComment->text(), start, stop );
99 QDialog::accept(); 124 QDialog::accept();
100} 125}
101void KOStopTodoPrefs::doNotSave() 126void KOStopTodoPrefs::doNotSave()
102{ 127{
103 int result = KMessageBox::warningContinueCancel(this, 128 int result = KMessageBox::warningContinueCancel(this,
104 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() ); 129 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() );
105 if (result != KMessageBox::Continue) return; 130 if (result != KMessageBox::Continue) return;
106 mTodo->stopRunning(); 131 mTodo->stopRunning();
107 QDialog::accept(); 132 QDialog::accept();
108} 133}
109 134
110 135
111class KOTodoViewWhatsThis :public QWhatsThis 136class KOTodoViewWhatsThis :public QWhatsThis
112{ 137{
113public: 138public:
114 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 139 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
115 140
116protected: 141protected:
117 virtual QString text( const QPoint& p) 142 virtual QString text( const QPoint& p)
118 { 143 {
119 return _view->getWhatsThisText(p) ; 144 return _view->getWhatsThisText(p) ;
120 } 145 }
121private: 146private:
122 QWidget* _wid; 147 QWidget* _wid;
123 KOTodoView * _view; 148 KOTodoView * _view;
124}; 149};
125 150
126KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 151KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
127 const char *name) : 152 const char *name) :
128 KListView(parent,name) 153 KListView(parent,name)
129{ 154{
130 mName = QString ( name ); 155 mName = QString ( name );
131 mCalendar = calendar; 156 mCalendar = calendar;
132#ifndef DESKTOP_VERSION 157#ifndef DESKTOP_VERSION
133 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 158 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
134#endif 159#endif
135 mOldCurrent = 0; 160 mOldCurrent = 0;
136 mMousePressed = false; 161 mMousePressed = false;
137 162
138 setAcceptDrops(true); 163 setAcceptDrops(true);
139 viewport()->setAcceptDrops(true); 164 viewport()->setAcceptDrops(true);
140 int size = 16; 165 int size = 16;
141 if (qApp->desktop()->width() < 300 ) 166 if (qApp->desktop()->width() < 300 )
142 size = 12; 167 size = 12;
143 setTreeStepSize( size + 6 ); 168 setTreeStepSize( size + 6 );
144 169
145} 170}
146 171
@@ -1154,97 +1179,97 @@ void KOTodoView::itemDoubleClicked(QListViewItem *item)
1154 newTodo(); 1179 newTodo();
1155 return; 1180 return;
1156 } else { 1181 } else {
1157 if ( row == 2 || row == 1 ) { 1182 if ( row == 2 || row == 1 ) {
1158 mActiveItem = (KOTodoViewItem *) item; 1183 mActiveItem = (KOTodoViewItem *) item;
1159 newSubTodo(); 1184 newSubTodo();
1160 return; 1185 return;
1161 } 1186 }
1162 if ( row == 5 || row == 6 ) { 1187 if ( row == 5 || row == 6 ) {
1163 mActiveItem = (KOTodoViewItem *) item; 1188 mActiveItem = (KOTodoViewItem *) item;
1164 toggleRunningItem(); 1189 toggleRunningItem();
1165 return; 1190 return;
1166 } 1191 }
1167 } 1192 }
1168 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1193 if ( KOPrefs::instance()->mEditOnDoubleClick )
1169 editItem( item ); 1194 editItem( item );
1170 else 1195 else
1171 showItem( item , QPoint(), 0 ); 1196 showItem( item , QPoint(), 0 );
1172} 1197}
1173void KOTodoView::toggleRunningItem() 1198void KOTodoView::toggleRunningItem()
1174{ 1199{
1175 // qDebug("KOTodoView::toggleRunning() "); 1200 // qDebug("KOTodoView::toggleRunning() ");
1176 if ( ! mActiveItem ) 1201 if ( ! mActiveItem )
1177 return; 1202 return;
1178 Todo * t = mActiveItem->todo(); 1203 Todo * t = mActiveItem->todo();
1179 if ( t->isRunning() ) { 1204 if ( t->isRunning() ) {
1180 1205
1181 1206
1182 KOStopTodoPrefs tp ( t, this ); 1207 KOStopTodoPrefs tp ( t, this );
1183 tp.exec(); 1208 tp.exec();
1184 1209
1185 1210
1186#if 0 1211#if 0
1187 int result = KMessageBox::warningYesNoCancel(this, 1212 int result = KMessageBox::warningYesNoCancel(this,
1188 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note")); 1213 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop"),i18n("Stop+note"));
1189 if (result == KMessageBox::Cancel) return; 1214 if (result == KMessageBox::Cancel) return;
1190 if ( result == KMessageBox::No ) { 1215 if ( result == KMessageBox::No ) {
1191 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") ); 1216 QString comment = QInputDialog::getText(mActiveItem->text(0).left( 25 ),i18n("Comment for todo:") );
1192 t->setRunningFalse( comment ); 1217 t->setRunningFalse( comment );
1193 } else { 1218 } else {
1194 t->setRunning( false ); 1219 t->setRunning( false );
1195 } 1220 }
1196 mActiveItem->construct(); 1221 mActiveItem->construct();
1197 1222
1198 1223
1199#endif 1224#endif
1200 } else { 1225 } else {
1201 int result = KMessageBox::warningContinueCancel(this, 1226 int result = KMessageBox::warningContinueCancel(this,
1202 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); 1227 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);
1203 if (result != KMessageBox::Continue) return; 1228 if (result != KMessageBox::Continue) return;
1204 t->setRunning( true ); 1229 t->setRunning( true );
1205 mActiveItem->construct(); 1230 mActiveItem->construct();
1206 } 1231 }
1207} 1232}
1208 1233
1209void KOTodoView::itemClicked(QListViewItem *item) 1234void KOTodoView::itemClicked(QListViewItem *item)
1210{ 1235{
1211 //qDebug("KOTodoView::itemClicked %d", item); 1236 //qDebug("KOTodoView::itemClicked %d", item);
1212 if (!item) { 1237 if (!item) {
1213 if ( pendingSubtodo != 0 ) { 1238 if ( pendingSubtodo != 0 ) {
1214 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1239 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1215 } 1240 }
1216 pendingSubtodo = 0; 1241 pendingSubtodo = 0;
1217 return; 1242 return;
1218 } 1243 }
1219 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1244 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1220 if ( pendingSubtodo != 0 ) { 1245 if ( pendingSubtodo != 0 ) {
1221 bool allowReparent = true; 1246 bool allowReparent = true;
1222 QListViewItem *par = item; 1247 QListViewItem *par = item;
1223 while ( par ) { 1248 while ( par ) {
1224 if ( par == pendingSubtodo ) { 1249 if ( par == pendingSubtodo ) {
1225 allowReparent = false; 1250 allowReparent = false;
1226 break; 1251 break;
1227 } 1252 }
1228 par = par->parent(); 1253 par = par->parent();
1229 } 1254 }
1230 if ( !allowReparent ) { 1255 if ( !allowReparent ) {
1231 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1256 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1232 pendingSubtodo = 0; 1257 pendingSubtodo = 0;
1233 } else { 1258 } else {
1234 Todo* newParent = todoItem->todo(); 1259 Todo* newParent = todoItem->todo();
1235 Todo* newSub = pendingSubtodo->todo(); 1260 Todo* newSub = pendingSubtodo->todo();
1236 pendingSubtodo = 0; 1261 pendingSubtodo = 0;
1237 emit reparentTodoSignal( newParent,newSub ); 1262 emit reparentTodoSignal( newParent,newSub );
1238 return; 1263 return;
1239 } 1264 }
1240 } 1265 }
1241 1266
1242} 1267}
1243 1268
1244void KOTodoView::setDocumentId( const QString &id ) 1269void KOTodoView::setDocumentId( const QString &id )
1245{ 1270{
1246 1271
1247 mDocPrefs->setDoc( id ); 1272 mDocPrefs->setDoc( id );
1248} 1273}
1249 1274
1250void KOTodoView::itemStateChanged( QListViewItem *item ) 1275void KOTodoView::itemStateChanged( QListViewItem *item )
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index ceabdba..8f0c99e 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -7,112 +7,117 @@
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qdialog.h> 35#include <qdialog.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <klistview.h> 38#include <klistview.h>
39 39
40#include <libkcal/calendar.h> 40#include <libkcal/calendar.h>
41#include <libkcal/todo.h> 41#include <libkcal/todo.h>
42 42
43#include <korganizer/baseview.h> 43#include <korganizer/baseview.h>
44 44
45#include "kotodoviewitem.h" 45#include "kotodoviewitem.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "koglobals.h" 47#include "koglobals.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49 49
50class QDragEnterEvent; 50class QDragEnterEvent;
51class QDragMoveEvent; 51class QDragMoveEvent;
52class QDragLeaveEvent; 52class QDragLeaveEvent;
53class QDropEvent; 53class QDropEvent;
54class KOTodoViewWhatsThis; 54class KOTodoViewWhatsThis;
55class KDateEdit;
56class KOTimeEdit;
55 57
56class DocPrefs; 58class DocPrefs;
57 59
58 60
59class KOStopTodoPrefs : public QDialog 61class KOStopTodoPrefs : public QDialog
60{ 62{
61 Q_OBJECT 63 Q_OBJECT
62 public: 64 public:
63 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; 65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
64 66
65 67
66private slots: 68private slots:
67 void doNotSave(); 69 void doNotSave();
68 void accept(); 70 void accept();
69private: 71private:
70 Todo* mTodo; 72 Todo* mTodo;
73 QLineEdit* mComment;
74 KDateEdit *sde, *ede;
75 KOTimeEdit *ste, *ete;
71 76
72}; 77};
73 78
74class KOTodoListView : public KListView 79class KOTodoListView : public KListView
75{ 80{
76 Q_OBJECT 81 Q_OBJECT
77 public: 82 public:
78 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 83 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
79 virtual ~KOTodoListView() {} 84 virtual ~KOTodoListView() {}
80 85
81 signals: 86 signals:
82 void paintNeeded(); 87 void paintNeeded();
83 void todoDropped(Todo *, int); 88 void todoDropped(Todo *, int);
84 void double_Clicked(QListViewItem *item); 89 void double_Clicked(QListViewItem *item);
85 void reparentTodoSignal( Todo *,Todo * ); 90 void reparentTodoSignal( Todo *,Todo * );
86 void unparentTodoSignal(Todo *); 91 void unparentTodoSignal(Todo *);
87 void deleteTodo( Todo * ); 92 void deleteTodo( Todo * );
88 protected: 93 protected:
89 void wheelEvent (QWheelEvent *e); 94 void wheelEvent (QWheelEvent *e);
90 void contentsDragEnterEvent(QDragEnterEvent *); 95 void contentsDragEnterEvent(QDragEnterEvent *);
91 void contentsDragMoveEvent(QDragMoveEvent *); 96 void contentsDragMoveEvent(QDragMoveEvent *);
92 void contentsDragLeaveEvent(QDragLeaveEvent *); 97 void contentsDragLeaveEvent(QDragLeaveEvent *);
93 void contentsDropEvent(QDropEvent *); 98 void contentsDropEvent(QDropEvent *);
94 99
95 void contentsMousePressEvent(QMouseEvent *); 100 void contentsMousePressEvent(QMouseEvent *);
96 void contentsMouseMoveEvent(QMouseEvent *); 101 void contentsMouseMoveEvent(QMouseEvent *);
97 void contentsMouseReleaseEvent(QMouseEvent *); 102 void contentsMouseReleaseEvent(QMouseEvent *);
98 void contentsMouseDoubleClickEvent(QMouseEvent *); 103 void contentsMouseDoubleClickEvent(QMouseEvent *);
99 104
100 private: 105 private:
101 void paintEvent(QPaintEvent * pevent); 106 void paintEvent(QPaintEvent * pevent);
102 bool internalDrop; 107 bool internalDrop;
103 QString mName; 108 QString mName;
104 Calendar *mCalendar; 109 Calendar *mCalendar;
105 QPoint mPressPos; 110 QPoint mPressPos;
106 bool mMousePressed; 111 bool mMousePressed;
107 QListViewItem *mOldCurrent; 112 QListViewItem *mOldCurrent;
108 bool mFlagKeyPressed; 113 bool mFlagKeyPressed;
109 void keyPressEvent ( QKeyEvent * ) ; 114 void keyPressEvent ( QKeyEvent * ) ;
110 void keyReleaseEvent ( QKeyEvent * ) ; 115 void keyReleaseEvent ( QKeyEvent * ) ;
111}; 116};
112 117
113 118
114/** 119/**
115 This is the line-edit on top of the todoview for fast addition of new todos 120 This is the line-edit on top of the todoview for fast addition of new todos
116*/ 121*/
117class KOQuickTodo : public QLineEdit 122class KOQuickTodo : public QLineEdit
118{ 123{
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 62b74f1..9a8b6e4 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -52,96 +52,98 @@ Todo::Todo(const Todo &t) : QObject(),Incidence(t)
52 mHasCompletedDate = t.mHasCompletedDate; 52 mHasCompletedDate = t.mHasCompletedDate;
53 mPercentComplete = t.mPercentComplete; 53 mPercentComplete = t.mPercentComplete;
54 mRunning = false; 54 mRunning = false;
55 mRunSaveTimer = 0; 55 mRunSaveTimer = 0;
56} 56}
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunningFalse( QString s ) 64void Todo::setRunningFalse( QString s )
65{ 65{
66 if ( ! mRunning ) 66 if ( ! mRunning )
67 return; 67 return;
68 mRunning = false; 68 mRunning = false;
69 mRunSaveTimer->stop(); 69 mRunSaveTimer->stop();
70 saveRunningInfoToFile( s ); 70 saveRunningInfoToFile( s );
71} 71}
72void Todo::stopRunning() 72void Todo::stopRunning()
73{ 73{
74 if ( !mRunning ) 74 if ( !mRunning )
75 return; 75 return;
76 if ( mRunSaveTimer ) 76 if ( mRunSaveTimer )
77 mRunSaveTimer->stop(); 77 mRunSaveTimer->stop();
78 mRunning = false; 78 mRunning = false;
79} 79}
80void Todo::setRunning( bool run ) 80void Todo::setRunning( bool run )
81{ 81{
82 if ( run == mRunning ) 82 if ( run == mRunning )
83 return; 83 return;
84 //qDebug("Todo::setRunning %d ", run); 84 //qDebug("Todo::setRunning %d ", run);
85 if ( !mRunSaveTimer ) { 85 if ( !mRunSaveTimer ) {
86 mRunSaveTimer = new QTimer ( this ); 86 mRunSaveTimer = new QTimer ( this );
87 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 87 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
88 } 88 }
89 mRunning = run; 89 mRunning = run;
90 if ( mRunning ) { 90 if ( mRunning ) {
91 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 91 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
92 mRunStart = QDateTime::currentDateTime(); 92 mRunStart = QDateTime::currentDateTime();
93 } else { 93 } else {
94 mRunSaveTimer->stop(); 94 mRunSaveTimer->stop();
95 saveRunningInfoToFile(); 95 saveRunningInfoToFile();
96 } 96 }
97} 97}
98void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) 98void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end )
99{ 99{
100 if ( !mRunning) return;
101 mRunning = false;
100 mRunStart = start; 102 mRunStart = start;
101 mRunEnd = end; 103 mRunEnd = end;
102 saveRunningInfoToFile( comment ); 104 saveRunningInfoToFile( comment );
103} 105}
104void Todo::saveRunningInfoToFile() 106void Todo::saveRunningInfoToFile()
105{ 107{
106 mRunEnd = QDateTime::currentDateTime(); 108 mRunEnd = QDateTime::currentDateTime();
107 saveRunningInfoToFile( QString::null ); 109 saveRunningInfoToFile( QString::null );
108} 110}
109void Todo::saveRunningInfoToFile( QString comment ) 111void Todo::saveRunningInfoToFile( QString comment )
110{ 112{
111 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 113 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
112 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) { 114 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 10 ) {
113 qDebug("Running time < 30 seconds. Skipped. "); 115 qDebug("Running time < 30 seconds. Skipped. ");
114 return; 116 return;
115 } 117 }
116 QString dir = KGlobalSettings::timeTrackerDir(); 118 QString dir = KGlobalSettings::timeTrackerDir();
117 //qDebug("%s ", dir.latin1()); 119 //qDebug("%s ", dir.latin1());
118 QString file = "%1%2%3-%4%5%6-"; 120 QString file = "%1%2%3-%4%5%6-";
119 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 ); 121 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 );
120 file.replace ( QRegExp (" "), "0" ); 122 file.replace ( QRegExp (" "), "0" );
121 file += uid(); 123 file += uid();
122 //qDebug("File %s ",file.latin1() ); 124 //qDebug("File %s ",file.latin1() );
123 CalendarLocal cal; 125 CalendarLocal cal;
124 cal.setLocalTime(); 126 cal.setLocalTime();
125 Todo * to = (Todo*) clone(); 127 Todo * to = (Todo*) clone();
126 to->setFloats( false ); 128 to->setFloats( false );
127 to->setDtStart( mRunStart ); 129 to->setDtStart( mRunStart );
128 to->setHasStartDate( true ); 130 to->setHasStartDate( true );
129 to->setDtDue( mRunEnd ); 131 to->setDtDue( mRunEnd );
130 to->setHasDueDate( true ); 132 to->setHasDueDate( true );
131 to->setUid( file ); 133 to->setUid( file );
132 if ( !comment.isEmpty() ) { 134 if ( !comment.isEmpty() ) {
133 QString des = to->description(); 135 QString des = to->description();
134 if ( des.isEmpty () ) 136 if ( des.isEmpty () )
135 to->setDescription( "TT-Note: " + comment ); 137 to->setDescription( "TT-Note: " + comment );
136 else 138 else
137 to->setDescription( "TT-Note: " + comment +"\n" + des ); 139 to->setDescription( "TT-Note: " + comment +"\n" + des );
138 } 140 }
139 cal.addIncidence( to ); 141 cal.addIncidence( to );
140 ICalFormat format; 142 ICalFormat format;
141 file = dir +"/" +file +".ics"; 143 file = dir +"/" +file +".ics";
142 format.save( &cal, file ); 144 format.save( &cal, file );
143 saveParents(); 145 saveParents();
144 146
145} 147}
146void Todo::saveParents() 148void Todo::saveParents()
147{ 149{
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 11f848e..425dfad 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,155 +1,155 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 This class provides a Todo in the sense of RFC2445. 33 This class provides a Todo in the sense of RFC2445.
34*/ 34*/
35 class Todo : public QObject,public Incidence 35 class Todo : public QObject,public Incidence
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 Todo(); 39 Todo();
40 Todo(const Todo &); 40 Todo(const Todo &);
41 ~Todo(); 41 ~Todo();
42 typedef ListBase<Todo> List; 42 typedef ListBase<Todo> List;
43 QCString type() const { return "Todo"; } 43 QCString type() const { return "Todo"; }
44 IncTypeID typeID() const { return todoID; } 44 IncTypeID typeID() const { return todoID; }
45 void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
46 45
47 /** Return an exact copy of this todo. */ 46 /** Return an exact copy of this todo. */
48 Incidence *clone(); 47 Incidence *clone();
49 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; 48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
50 49
51 /** for setting the todo's due date/time with a QDateTime. */ 50 /** for setting the todo's due date/time with a QDateTime. */
52 void setDtDue(const QDateTime &dtDue); 51 void setDtDue(const QDateTime &dtDue);
53 /** returns an event's Due date/time as a QDateTime. */ 52 /** returns an event's Due date/time as a QDateTime. */
54 QDateTime dtDue() const; 53 QDateTime dtDue() const;
55 /** returns an event's due time as a string formatted according to the 54 /** returns an event's due time as a string formatted according to the
56 users locale settings */ 55 users locale settings */
57 QString dtDueTimeStr() const; 56 QString dtDueTimeStr() const;
58 /** returns an event's due date as a string formatted according to the 57 /** returns an event's due date as a string formatted according to the
59 users locale settings */ 58 users locale settings */
60 QString dtDueDateStr(bool shortfmt=true) const; 59 QString dtDueDateStr(bool shortfmt=true) const;
61 /** returns an event's due date and time as a string formatted according 60 /** returns an event's due date and time as a string formatted according
62 to the users locale settings */ 61 to the users locale settings */
63 QString dtDueStr(bool shortfmt=true) const; 62 QString dtDueStr(bool shortfmt=true) const;
64 63
65 /** returns TRUE or FALSE depending on whether the todo has a due date */ 64 /** returns TRUE or FALSE depending on whether the todo has a due date */
66 bool hasDueDate() const; 65 bool hasDueDate() const;
67 /** sets the event's hasDueDate value. */ 66 /** sets the event's hasDueDate value. */
68 void setHasDueDate(bool f); 67 void setHasDueDate(bool f);
69 68
70 /* 69 /*
71 Looks for a subtodo (including itself ) which is not complete and is 70 Looks for a subtodo (including itself ) which is not complete and is
72 - overdue, or 71 - overdue, or
73 - due today. 72 - due today.
74 It returns 0 for nothing found, 73 It returns 0 for nothing found,
75 1 for found a todo which is due today and no overdue found 74 1 for found a todo which is due today and no overdue found
76 2 for found a overdue todo 75 2 for found a overdue todo
77 */ 76 */
78 int hasDueSubTodo( bool checkSubtodos = true ); 77 int hasDueSubTodo( bool checkSubtodos = true );
79 /* same as above, but a specific date can be specified*/ 78 /* same as above, but a specific date can be specified*/
80 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); 79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
81 80
82 81
83 /** sets the event's status to the string specified. The string 82 /** sets the event's status to the string specified. The string
84 * must be a recognized value for the status field, i.e. a string 83 * must be a recognized value for the status field, i.e. a string
85 * equivalent of the possible status enumerations previously described. */ 84 * equivalent of the possible status enumerations previously described. */
86// void setStatus(const QString &statStr); 85// void setStatus(const QString &statStr);
87 /** sets the event's status to the value specified. See the enumeration 86 /** sets the event's status to the value specified. See the enumeration
88 * above for possible values. */ 87 * above for possible values. */
89// void setStatus(int); 88// void setStatus(int);
90 /** return the event's status. */ 89 /** return the event's status. */
91// int status() const; 90// int status() const;
92 /** return the event's status in string format. */ 91 /** return the event's status in string format. */
93// QString statusStr() const; 92// QString statusStr() const;
94 93
95 /** return, if this todo is completed */ 94 /** return, if this todo is completed */
96 bool isCompleted() const; 95 bool isCompleted() const;
97 /** set completed state of this todo */ 96 /** set completed state of this todo */
98 void setCompleted(bool); 97 void setCompleted(bool);
99 98
100 /** 99 /**
101 Return how many percent of the task are completed. Returns a value 100 Return how many percent of the task are completed. Returns a value
102 between 0 and 100. 101 between 0 and 100.
103 */ 102 */
104 int percentComplete() const; 103 int percentComplete() const;
105 /** 104 /**
106 Set how many percent of the task are completed. Valid values are in the 105 Set how many percent of the task are completed. Valid values are in the
107 range from 0 to 100. 106 range from 0 to 100.
108 */ 107 */
109 void setPercentComplete(int); 108 void setPercentComplete(int);
110 109
111 /** return date and time when todo was completed */ 110 /** return date and time when todo was completed */
112 QDateTime completed() const; 111 QDateTime completed() const;
113 QString completedStr(bool shortF = true) const; 112 QString completedStr(bool shortF = true) const;
114 /** set date and time of completion */ 113 /** set date and time of completion */
115 void setCompleted(const QDateTime &completed); 114 void setCompleted(const QDateTime &completed);
116 115
117 /** Return true, if todo has a date associated with completion */ 116 /** Return true, if todo has a date associated with completion */
118 bool hasCompletedDate() const; 117 bool hasCompletedDate() const;
119 bool contains ( Todo*); 118 bool contains ( Todo*);
120 void checkSetCompletedFalse(); 119 void checkSetCompletedFalse();
121 bool setRecurDates(); 120 bool setRecurDates();
122 bool isRunning() {return mRunning;} 121 bool isRunning() {return mRunning;}
123 bool hasRunningSub(); 122 bool hasRunningSub();
124 void setRunning( bool ); 123 void setRunning( bool );
125 void setRunningFalse( QString ); 124 void setRunningFalse( QString );
126 void stopRunning(); 125 void stopRunning();
127 int runTime(); 126 int runTime();
128 QDateTime runStart () const { return mRunStart;} 127 QDateTime runStart () const { return mRunStart;}
128 void saveRunningInfo( QString comment, QDateTime start, QDateTime end );
129 public slots: 129 public slots:
130 void saveRunningInfoToFile( QString st ); 130 void saveRunningInfoToFile( QString st );
131 void saveRunningInfoToFile( ); 131 void saveRunningInfoToFile( );
132 void saveParents(); 132 void saveParents();
133 private: 133 private:
134 bool mRunning; 134 bool mRunning;
135 QTimer * mRunSaveTimer; 135 QTimer * mRunSaveTimer;
136 QDateTime mRunStart; 136 QDateTime mRunStart;
137 QDateTime mRunEnd; 137 QDateTime mRunEnd;
138 bool accept(Visitor &v) { return v.visit(this); } 138 bool accept(Visitor &v) { return v.visit(this); }
139 139
140 QDateTime mDtDue; // due date of todo 140 QDateTime mDtDue; // due date of todo
141 141
142 bool mHasDueDate; // if todo has associated due date 142 bool mHasDueDate; // if todo has associated due date
143 143
144// int mStatus; // confirmed/delegated/tentative/etc 144// int mStatus; // confirmed/delegated/tentative/etc
145 145
146 QDateTime mCompleted; 146 QDateTime mCompleted;
147 bool mHasCompletedDate; 147 bool mHasCompletedDate;
148 148
149 int mPercentComplete; 149 int mPercentComplete;
150}; 150};
151 151
152 bool operator==( const Todo&, const Todo& ); 152 bool operator==( const Todo&, const Todo& );
153} 153}
154 154
155#endif 155#endif