author | zautrix <zautrix> | 2005-07-06 21:48:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-06 21:48:53 (UTC) |
commit | 93bc4dbbef774e28672c947281291b12d5971803 (patch) (unidiff) | |
tree | eac12b91fffe75bfd0c40046c7a13cd746fafc6f /korganizer | |
parent | 630904c92dc014538ff0b08731efb10dcc25426f (diff) | |
download | kdepimpi-93bc4dbbef774e28672c947281291b12d5971803.zip kdepimpi-93bc4dbbef774e28672c947281291b12d5971803.tar.gz kdepimpi-93bc4dbbef774e28672c947281291b12d5971803.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/kotodoview.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 06d40b1..2c017e1 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1693 +1,1697 @@ | |||
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> | 39 | #include <kdateedit.h> |
40 | #include "ktimeedit.h" | 40 | #include "ktimeedit.h" |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | #include <libkcal/icaldrag.h> | 44 | #include <libkcal/icaldrag.h> |
45 | #include <libkcal/vcaldrag.h> | 45 | #include <libkcal/vcaldrag.h> |
46 | #include <libkcal/calfilter.h> | 46 | #include <libkcal/calfilter.h> |
47 | #include <libkcal/dndfactory.h> | 47 | #include <libkcal/dndfactory.h> |
48 | #include <libkcal/calendarresources.h> | 48 | #include <libkcal/calendarresources.h> |
49 | #include <libkcal/resourcecalendar.h> | 49 | #include <libkcal/resourcecalendar.h> |
50 | #include <kresources/resourceselectdialog.h> | 50 | #include <kresources/resourceselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | #ifndef KORG_NOPRINTER | 57 | #ifndef KORG_NOPRINTER |
58 | #include "calprinter.h" | 58 | #include "calprinter.h" |
59 | #endif | 59 | #endif |
60 | #include "docprefs.h" | 60 | #include "docprefs.h" |
61 | 61 | ||
62 | #include "kotodoview.h" | 62 | #include "kotodoview.h" |
63 | using namespace KOrg; | 63 | using namespace KOrg; |
64 | 64 | ||
65 | 65 | ||
66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : | 66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : |
67 | QDialog( parent, name, true ) | 67 | QDialog( parent, name, true ) |
68 | { | 68 | { |
69 | mStopAll = true; | 69 | mStopAll = true; |
70 | setCaption( i18n("Start todo") ); | 70 | setCaption( i18n("Start todo") ); |
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | 71 | QVBoxLayout* lay = new QVBoxLayout( this ); |
72 | lay->setSpacing( 3 ); | 72 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 73 | lay->setMargin( 3 ); |
74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); | 74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); |
75 | lay->addWidget( lab ); | 75 | lay->addWidget( lab ); |
76 | lab->setAlignment( AlignCenter ); | 76 | lab->setAlignment( AlignCenter ); |
77 | 77 | ||
78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); | 78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); |
79 | lay->addWidget( ok ); | 79 | lay->addWidget( ok ); |
80 | ok->setDefault( true ); | 80 | ok->setDefault( true ); |
81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); | 81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); |
82 | lay->addWidget( start ); | 82 | lay->addWidget( start ); |
83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); | 83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); |
84 | lay->addWidget( cancel ); | 84 | lay->addWidget( cancel ); |
85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); | 86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); |
87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
88 | resize( sizeHint() ); | 88 | resize( sizeHint() ); |
89 | 89 | ||
90 | } | 90 | } |
91 | void KOStartTodoPrefs::doStop() | 91 | void KOStartTodoPrefs::doStop() |
92 | { | 92 | { |
93 | mStopAll = false; | 93 | mStopAll = false; |
94 | accept(); | 94 | accept(); |
95 | } | 95 | } |
96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : | 96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : |
97 | QDialog( parent, name, true ) | 97 | QDialog( parent, name, true ) |
98 | { | 98 | { |
99 | mTodo = todo; | 99 | mTodo = todo; |
100 | setCaption( i18n("Stop todo") ); | 100 | setCaption( i18n("Stop todo") ); |
101 | QVBoxLayout* lay = new QVBoxLayout( this ); | 101 | QVBoxLayout* lay = new QVBoxLayout( this ); |
102 | lay->setSpacing( 3 ); | 102 | lay->setSpacing( 3 ); |
103 | lay->setMargin( 3 ); | 103 | lay->setMargin( 3 ); |
104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); | 104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); |
105 | lay->addWidget( lab ); | 105 | lay->addWidget( lab ); |
106 | lab->setAlignment( AlignHCenter ); | 106 | lab->setAlignment( AlignHCenter ); |
107 | lab = new QLabel( i18n("Additional Comment:"), this ); | 107 | lab = new QLabel( i18n("Additional Comment:"), this ); |
108 | lay->addWidget( lab ); | 108 | lay->addWidget( lab ); |
109 | mComment = new QLineEdit( this ); | 109 | mComment = new QLineEdit( this ); |
110 | lay->addWidget( mComment ); | 110 | lay->addWidget( mComment ); |
111 | QHBox * start = new QHBox ( this ); | 111 | QHBox * start = new QHBox ( this ); |
112 | lay->addWidget( start ); | 112 | lay->addWidget( start ); |
113 | lab = new QLabel( i18n("Start:"), start ); | 113 | lab = new QLabel( i18n("Start:"), start ); |
114 | QHBox * end = new QHBox ( this ); | 114 | QHBox * end = new QHBox ( this ); |
115 | lay->addWidget( end ); | 115 | lay->addWidget( end ); |
116 | lab = new QLabel( i18n("End:"), end ); | 116 | lab = new QLabel( i18n("End:"), end ); |
117 | sde = new KDateEdit( start ); | 117 | sde = new KDateEdit( start ); |
118 | ste = new KOTimeEdit( start ); | 118 | ste = new KOTimeEdit( start ); |
119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); | 119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); |
120 | ede = new KDateEdit( end ); | 120 | ede = new KDateEdit( end ); |
121 | ete = new KOTimeEdit(end ); | 121 | ete = new KOTimeEdit(end ); |
122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); | 122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); |
123 | sde->setDate( mTodo->runStart().date() ); | 123 | sde->setDate( mTodo->runStart().date() ); |
124 | ste->setTime( mTodo->runStart().time() ); | 124 | ste->setTime( mTodo->runStart().time() ); |
125 | ede->setDate( QDate::currentDate()); | 125 | ede->setDate( QDate::currentDate()); |
126 | ete->setTime( QTime::currentTime() ); | 126 | ete->setTime( QTime::currentTime() ); |
127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
128 | lay->addWidget( ok ); | 128 | lay->addWidget( ok ); |
129 | ok->setDefault( true ); | 129 | ok->setDefault( true ); |
130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
131 | lay->addWidget( cancel ); | 131 | lay->addWidget( cancel ); |
132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
134 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 134 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
136 | lay->addWidget( ok ); | 136 | lay->addWidget( ok ); |
137 | if (QApplication::desktop()->width() < 320 ) | 137 | if (QApplication::desktop()->width() < 320 ) |
138 | resize( 240, sizeHint().height() ); | 138 | resize( 240, sizeHint().height() ); |
139 | else | 139 | else |
140 | resize( 320, sizeHint().height() ); | 140 | resize( 320, sizeHint().height() ); |
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | void KOStopTodoPrefs::accept() | 144 | void KOStopTodoPrefs::accept() |
145 | { | 145 | { |
146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
148 | if ( start > stop ) { | 148 | if ( start > stop ) { |
149 | KMessageBox::sorry(this, | 149 | KMessageBox::sorry(this, |
150 | i18n("The start time is\nafter the end time!"), | 150 | i18n("The start time is\nafter the end time!"), |
151 | i18n("Time mismatch!")); | 151 | i18n("Time mismatch!")); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
155 | QDialog::accept(); | 155 | QDialog::accept(); |
156 | } | 156 | } |
157 | void KOStopTodoPrefs::doNotSave() | 157 | void KOStopTodoPrefs::doNotSave() |
158 | { | 158 | { |
159 | int result = KMessageBox::warningContinueCancel(this, | 159 | int result = KMessageBox::warningContinueCancel(this, |
160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); | 160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); |
161 | if (result != KMessageBox::Continue) return; | 161 | if (result != KMessageBox::Continue) return; |
162 | mTodo->stopRunning(); | 162 | mTodo->stopRunning(); |
163 | QDialog::accept(); | 163 | QDialog::accept(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | class KOTodoViewWhatsThis :public QWhatsThis | 167 | class KOTodoViewWhatsThis :public QWhatsThis |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
171 | 171 | ||
172 | protected: | 172 | protected: |
173 | virtual QString text( const QPoint& p) | 173 | virtual QString text( const QPoint& p) |
174 | { | 174 | { |
175 | return _view->getWhatsThisText(p) ; | 175 | return _view->getWhatsThisText(p) ; |
176 | } | 176 | } |
177 | private: | 177 | private: |
178 | QWidget* _wid; | 178 | QWidget* _wid; |
179 | KOTodoView * _view; | 179 | KOTodoView * _view; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
183 | const char *name) : | 183 | const char *name) : |
184 | KListView(parent,name) | 184 | KListView(parent,name) |
185 | { | 185 | { |
186 | mName = QString ( name ); | 186 | mName = QString ( name ); |
187 | mCalendar = calendar; | 187 | mCalendar = calendar; |
188 | #ifndef DESKTOP_VERSION | 188 | #ifndef DESKTOP_VERSION |
189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
190 | #endif | 190 | #endif |
191 | mOldCurrent = 0; | 191 | mOldCurrent = 0; |
192 | mMousePressed = false; | 192 | mMousePressed = false; |
193 | 193 | ||
194 | setAcceptDrops(true); | 194 | setAcceptDrops(true); |
195 | viewport()->setAcceptDrops(true); | 195 | viewport()->setAcceptDrops(true); |
196 | int size = 16; | 196 | int size = 16; |
197 | if (qApp->desktop()->width() < 300 ) | 197 | if (qApp->desktop()->width() < 300 ) |
198 | size = 12; | 198 | size = 12; |
199 | setTreeStepSize( size + 6 ); | 199 | setTreeStepSize( size + 6 ); |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 208 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 209 | e->ignore(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | mOldCurrent = currentItem(); | 213 | mOldCurrent = currentItem(); |
214 | #endif | 214 | #endif |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 219 | { |
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 222 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 224 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | e->accept(); | 229 | e->accept(); |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | 232 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 234 | { |
235 | #ifndef KORG_NODND | 235 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 237 | ||
238 | setCurrentItem(mOldCurrent); | 238 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 239 | setSelected(mOldCurrent,true); |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 244 | { |
245 | #ifndef KORG_NODND | 245 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 247 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 249 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 250 | e->ignore(); |
251 | return; | 251 | return; |
252 | } | 252 | } |
253 | 253 | ||
254 | DndFactory factory( mCalendar ); | 254 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 255 | Todo *todo = factory.createDropTodo(e); |
256 | 256 | ||
257 | if (todo) { | 257 | if (todo) { |
258 | e->acceptAction(); | 258 | e->acceptAction(); |
259 | 259 | ||
260 | KOTodoViewItem *destination = | 260 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 262 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 263 | if (destination) destinationEvent = destination->todo(); |
264 | 264 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 265 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 266 | ||
267 | if(existingTodo) { | 267 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 268 | Incidence *to = destinationEvent; |
269 | while(to) { | 269 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 270 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 271 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 272 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 273 | i18n("Drop Todo")); |
274 | delete todo; | 274 | delete todo; |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | to = to->relatedTo(); | 277 | to = to->relatedTo(); |
278 | } | 278 | } |
279 | internalDrop = true; | 279 | internalDrop = true; |
280 | if ( destinationEvent ) | 280 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 281 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 282 | else |
283 | unparentTodoSignal(existingTodo); | 283 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 284 | delete todo; |
285 | } else { | 285 | } else { |
286 | mCalendar->addTodo(todo); | 286 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 287 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 288 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 289 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else { | 292 | else { |
293 | QString text; | 293 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 294 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 297 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 298 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 300 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 301 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 302 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 303 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 304 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else { | 308 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 310 | e->ignore(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | } | 314 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 315 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 316 | { |
317 | QListView::wheelEvent (e); | 317 | QListView::wheelEvent (e); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 321 | { |
322 | 322 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 323 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 324 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 325 | bool rootClicked = true; |
326 | if (i) { | 326 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 327 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 328 | // try to start a drag! |
329 | int X = p.x(); | 329 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 331 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 333 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 334 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 335 | rootClicked = false; |
336 | } | 336 | } |
337 | } else { | 337 | } else { |
338 | rootClicked = false; | 338 | rootClicked = false; |
339 | } | 339 | } |
340 | #ifndef KORG_NODND | 340 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 341 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 342 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 343 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 344 | mMousePressed = true; |
345 | } else { | 345 | } else { |
346 | mMousePressed = false; | 346 | mMousePressed = false; |
347 | } | 347 | } |
348 | #endif | 348 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 351 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 352 | QListView::contentsMousePressEvent(e); |
353 | #else | 353 | #else |
354 | QListView::contentsMousePressEvent(e); | 354 | QListView::contentsMousePressEvent(e); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 357 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 358 | { |
359 | emit paintNeeded(); | 359 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 360 | QListView::paintEvent( e); |
361 | } | 361 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 363 | { |
364 | 364 | ||
365 | #ifndef KORG_NODND | 365 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 366 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 368 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 369 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 371 | if (item) { |
372 | DndFactory factory( mCalendar ); | 372 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 373 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 374 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 375 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 376 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 377 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 378 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 380 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 381 | } else |
382 | qDebug("Dnd: Internal move "); | 382 | qDebug("Dnd: Internal move "); |
383 | 383 | ||
384 | } else { | 384 | } else { |
385 | if ( !internalDrop ) { | 385 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 386 | qDebug("Dnd: External Copy"); |
387 | } else | 387 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 388 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | #endif | 392 | #endif |
393 | } | 393 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 395 | { |
396 | if ( !e->isAutoRepeat() ) { | 396 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 397 | mFlagKeyPressed = false; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 403 | { |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 405 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 407 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | if (! e->isAutoRepeat() ) | 410 | if (! e->isAutoRepeat() ) |
411 | mFlagKeyPressed = true; | 411 | mFlagKeyPressed = true; |
412 | QListViewItem* cn; | 412 | QListViewItem* cn; |
413 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 413 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
414 | cn = currentItem(); | 414 | cn = currentItem(); |
415 | if ( cn ) { | 415 | if ( cn ) { |
416 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 416 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
417 | if ( ci ){ | 417 | if ( ci ){ |
418 | if ( e->state() == ShiftButton ) | 418 | if ( e->state() == ShiftButton ) |
419 | ci->setOn( false ); | 419 | ci->setOn( false ); |
420 | else | 420 | else |
421 | ci->setOn( true ); | 421 | ci->setOn( true ); |
422 | cn = cn->itemBelow(); | 422 | cn = cn->itemBelow(); |
423 | if ( cn ) { | 423 | if ( cn ) { |
424 | setCurrentItem ( cn ); | 424 | setCurrentItem ( cn ); |
425 | ensureItemVisible ( cn ); | 425 | ensureItemVisible ( cn ); |
426 | } | 426 | } |
427 | 427 | ||
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | return; | 431 | return; |
432 | } | 432 | } |
433 | 433 | ||
434 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 434 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
435 | switch ( e->key() ) { | 435 | switch ( e->key() ) { |
436 | case Qt::Key_Down: | 436 | case Qt::Key_Down: |
437 | case Qt::Key_Up: | 437 | case Qt::Key_Up: |
438 | QListView::keyPressEvent ( e ); | 438 | QListView::keyPressEvent ( e ); |
439 | break; | 439 | break; |
440 | case Qt::Key_Left: | 440 | case Qt::Key_Left: |
441 | case Qt::Key_Right: | 441 | case Qt::Key_Right: |
442 | QListView::keyPressEvent ( e ); | 442 | QListView::keyPressEvent ( e ); |
443 | e->accept(); | 443 | e->accept(); |
444 | return; | 444 | return; |
445 | break; | 445 | break; |
446 | default: | 446 | default: |
447 | e->ignore(); | 447 | e->ignore(); |
448 | break; | 448 | break; |
449 | } | 449 | } |
450 | return; | 450 | return; |
451 | } | 451 | } |
452 | e->ignore(); | 452 | e->ignore(); |
453 | } | 453 | } |
454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 454 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
455 | { | 455 | { |
456 | QListView::contentsMouseReleaseEvent(e); | 456 | QListView::contentsMouseReleaseEvent(e); |
457 | mMousePressed = false; | 457 | mMousePressed = false; |
458 | } | 458 | } |
459 | 459 | ||
460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 460 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
461 | { | 461 | { |
462 | if (!e) return; | 462 | if (!e) return; |
463 | 463 | ||
464 | QPoint vp = contentsToViewport(e->pos()); | 464 | QPoint vp = contentsToViewport(e->pos()); |
465 | 465 | ||
466 | QListViewItem *item = itemAt(vp); | 466 | QListViewItem *item = itemAt(vp); |
467 | 467 | ||
468 | emit double_Clicked(item); | 468 | emit double_Clicked(item); |
469 | if (!item) return; | 469 | if (!item) return; |
470 | 470 | ||
471 | emit doubleClicked(item,vp,0); | 471 | emit doubleClicked(item,vp,0); |
472 | } | 472 | } |
473 | 473 | ||
474 | ///////////////////////////////////////////////////////////////////////////// | 474 | ///////////////////////////////////////////////////////////////////////////// |
475 | 475 | ||
476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 476 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
477 | QLineEdit(parent) | 477 | QLineEdit(parent) |
478 | { | 478 | { |
479 | setText(i18n("Click to add a new Todo")); | 479 | setText(i18n("Click to add new Todo")); |
480 | } | 480 | } |
481 | 481 | ||
482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 482 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
483 | { | 483 | { |
484 | if ( text()==i18n("Click to add a new Todo") ) | 484 | if ( text()==i18n("Click to add new Todo") ) |
485 | setText(""); | 485 | setText(""); |
486 | QLineEdit::focusInEvent(ev); | 486 | QLineEdit::focusInEvent(ev); |
487 | } | 487 | } |
488 | 488 | ||
489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 489 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
490 | { | 490 | { |
491 | setText(i18n("Click to add a new Todo")); | 491 | setText(i18n("Click to add new Todo")); |
492 | QLineEdit::focusOutEvent(ev); | 492 | QLineEdit::focusOutEvent(ev); |
493 | } | 493 | } |
494 | 494 | ||
495 | ///////////////////////////////////////////////////////////////////////////// | 495 | ///////////////////////////////////////////////////////////////////////////// |
496 | 496 | ||
497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 497 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
498 | KOrg::BaseView(calendar,parent,name) | 498 | KOrg::BaseView(calendar,parent,name) |
499 | { | 499 | { |
500 | mCategoryPopupMenu = 0; | 500 | mCategoryPopupMenu = 0; |
501 | mPendingUpdateBeforeRepaint = false; | 501 | mPendingUpdateBeforeRepaint = false; |
502 | isFlatDisplay = false; | 502 | isFlatDisplay = false; |
503 | mNavigator = 0; | 503 | mNavigator = 0; |
504 | QBoxLayout *topLayout = new QVBoxLayout(this); | 504 | QBoxLayout *topLayout = new QVBoxLayout(this); |
505 | mName = QString ( name ); | 505 | mName = QString ( name ); |
506 | mBlockUpdate = false; | 506 | mBlockUpdate = false; |
507 | mQuickBar = new QWidget( this ); | 507 | mQuickBar = new QWidget( this ); |
508 | topLayout->addWidget(mQuickBar); | 508 | topLayout->addWidget(mQuickBar); |
509 | 509 | ||
510 | mQuickAdd = new KOQuickTodo(mQuickBar); | 510 | mQuickAdd = new KOQuickTodo(mQuickBar); |
511 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 511 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
512 | quickLayout->addWidget( mQuickAdd ); | 512 | quickLayout->addWidget( mQuickAdd ); |
513 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 513 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
514 | int fixwid = flat->sizeHint().height(); | 514 | int fixwid = flat->sizeHint().height(); |
515 | if ( QApplication::desktop()->width() > 320 ) | 515 | if ( QApplication::desktop()->width() > 320 ) |
516 | fixwid *= 2; | 516 | fixwid *= 2; |
517 | flat->setFixedWidth( fixwid ); | 517 | flat->setFixedWidth( fixwid ); |
518 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 518 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
519 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 519 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
520 | allopen->setFixedWidth( fixwid ); | 520 | allopen->setFixedWidth( fixwid ); |
521 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 521 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
522 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 522 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
523 | allclose->setFixedWidth( fixwid ); | 523 | allclose->setFixedWidth( fixwid ); |
524 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 524 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
525 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 525 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
526 | s_done->setPixmap( SmallIcon("greenhook16")); | ||
526 | s_done->setFixedWidth( fixwid ); | 527 | s_done->setFixedWidth( fixwid ); |
528 | s_done->setFixedHeight( flat->sizeHint().height() ); | ||
527 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 529 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
528 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 530 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
531 | s_run->setPixmap( SmallIcon("ko16old")); | ||
529 | s_run->setFixedWidth( fixwid ); | 532 | s_run->setFixedWidth( fixwid ); |
533 | s_run->setFixedHeight( flat->sizeHint().height() ); | ||
530 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 534 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
531 | 535 | ||
532 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 536 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
533 | mNewSubBut->setFixedWidth( fixwid*3/2 ); | 537 | mNewSubBut->setFixedWidth( fixwid*3/2 ); |
534 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 538 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
535 | mNewSubBut->setEnabled( false ); | 539 | mNewSubBut->setEnabled( false ); |
536 | quickLayout->addWidget( mNewSubBut ); | 540 | quickLayout->addWidget( mNewSubBut ); |
537 | quickLayout->addWidget( s_done ); | 541 | quickLayout->addWidget( s_done ); |
538 | quickLayout->addWidget( s_run ); | 542 | quickLayout->addWidget( s_run ); |
539 | 543 | ||
540 | quickLayout->addWidget( allopen ); | 544 | quickLayout->addWidget( allopen ); |
541 | quickLayout->addWidget( allclose ); | 545 | quickLayout->addWidget( allclose ); |
542 | quickLayout->addWidget( flat ); | 546 | quickLayout->addWidget( flat ); |
543 | 547 | ||
544 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); | 548 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); |
545 | 549 | ||
546 | mTodoListView = new KOTodoListView(calendar,this, name ); | 550 | mTodoListView = new KOTodoListView(calendar,this, name ); |
547 | topLayout->addWidget(mTodoListView); | 551 | topLayout->addWidget(mTodoListView); |
548 | //mTodoListView->header()->setMaximumHeight(30); | 552 | //mTodoListView->header()->setMaximumHeight(30); |
549 | mTodoListView->setRootIsDecorated(true); | 553 | mTodoListView->setRootIsDecorated(true); |
550 | mTodoListView->setAllColumnsShowFocus(true); | 554 | mTodoListView->setAllColumnsShowFocus(true); |
551 | 555 | ||
552 | mTodoListView->setShowSortIndicator(true); | 556 | mTodoListView->setShowSortIndicator(true); |
553 | 557 | ||
554 | mTodoListView->addColumn(i18n("Todo")); | 558 | mTodoListView->addColumn(i18n("Todo")); |
555 | mTodoListView->addColumn(i18n("Prio")); | 559 | mTodoListView->addColumn(i18n("Prio")); |
556 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 560 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
557 | mTodoListView->addColumn(i18n("Complete")); | 561 | mTodoListView->addColumn(i18n("Complete")); |
558 | mTodoListView->setColumnAlignment(2,AlignCenter); | 562 | mTodoListView->setColumnAlignment(2,AlignCenter); |
559 | 563 | ||
560 | mTodoListView->addColumn(i18n("Due Date")); | 564 | mTodoListView->addColumn(i18n("Due Date")); |
561 | mTodoListView->setColumnAlignment(3,AlignLeft); | 565 | mTodoListView->setColumnAlignment(3,AlignLeft); |
562 | mTodoListView->addColumn(i18n("Due Time")); | 566 | mTodoListView->addColumn(i18n("Due Time")); |
563 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 567 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
564 | 568 | ||
565 | mTodoListView->addColumn(i18n("Start Date")); | 569 | mTodoListView->addColumn(i18n("Start Date")); |
566 | mTodoListView->setColumnAlignment(5,AlignLeft); | 570 | mTodoListView->setColumnAlignment(5,AlignLeft); |
567 | mTodoListView->addColumn(i18n("Start Time")); | 571 | mTodoListView->addColumn(i18n("Start Time")); |
568 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 572 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
569 | 573 | ||
570 | mTodoListView->addColumn(i18n("Cancelled")); | 574 | mTodoListView->addColumn(i18n("Cancelled")); |
571 | mTodoListView->addColumn(i18n("Categories")); | 575 | mTodoListView->addColumn(i18n("Categories")); |
572 | mTodoListView->addColumn(i18n("Calendar")); | 576 | mTodoListView->addColumn(i18n("Calendar")); |
573 | #if 0 | 577 | #if 0 |
574 | mTodoListView->addColumn(i18n("Sort Id")); | 578 | mTodoListView->addColumn(i18n("Sort Id")); |
575 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 579 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
576 | #endif | 580 | #endif |
577 | 581 | ||
578 | mTodoListView->setMinimumHeight( 60 ); | 582 | mTodoListView->setMinimumHeight( 60 ); |
579 | mTodoListView->setItemsRenameable( true ); | 583 | mTodoListView->setItemsRenameable( true ); |
580 | mTodoListView->setRenameable( 0 ); | 584 | mTodoListView->setRenameable( 0 ); |
581 | mTodoListView->setColumnWidth( 0, 120 ); | 585 | mTodoListView->setColumnWidth( 0, 120 ); |
582 | int iii = 0; | 586 | int iii = 0; |
583 | for ( iii = 0; iii< 10 ; ++iii ) | 587 | for ( iii = 0; iii< 10 ; ++iii ) |
584 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 588 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
585 | 589 | ||
586 | 590 | ||
587 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 591 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
588 | 592 | ||
589 | mPriorityPopupMenu = new QPopupMenu(this); | 593 | mPriorityPopupMenu = new QPopupMenu(this); |
590 | for (int i = 1; i <= 5; i++) { | 594 | for (int i = 1; i <= 5; i++) { |
591 | QString label = QString ("%1").arg (i); | 595 | QString label = QString ("%1").arg (i); |
592 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 596 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
593 | } | 597 | } |
594 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 598 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
595 | 599 | ||
596 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 600 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
597 | for (int i = 0; i <= 100; i+=20) { | 601 | for (int i = 0; i <= 100; i+=20) { |
598 | QString label = QString ("%1 %").arg (i); | 602 | QString label = QString ("%1 %").arg (i); |
599 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 603 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
600 | } | 604 | } |
601 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 605 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
602 | 606 | ||
603 | 607 | ||
604 | mCategoryPopupMenu = new QPopupMenu (this); | 608 | mCategoryPopupMenu = new QPopupMenu (this); |
605 | mCategoryPopupMenu->setCheckable (true); | 609 | mCategoryPopupMenu->setCheckable (true); |
606 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 610 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
607 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 611 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
608 | 612 | ||
609 | mCalPopupMenu = new QPopupMenu (this); | 613 | mCalPopupMenu = new QPopupMenu (this); |
610 | mCalPopupMenu->setCheckable (true); | 614 | mCalPopupMenu->setCheckable (true); |
611 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 615 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
612 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 616 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
613 | 617 | ||
614 | 618 | ||
615 | 619 | ||
616 | 620 | ||
617 | mItemPopupMenu = new QPopupMenu(this); | 621 | mItemPopupMenu = new QPopupMenu(this); |
618 | mItemPopupMenu->insertItem(i18n("Show"), this, | 622 | mItemPopupMenu->insertItem(i18n("Show"), this, |
619 | SLOT (showTodo())); | 623 | SLOT (showTodo())); |
620 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 624 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
621 | SLOT (editTodo())); | 625 | SLOT (editTodo())); |
622 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 626 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
623 | SLOT (deleteTodo())); | 627 | SLOT (deleteTodo())); |
624 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 628 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
625 | SLOT (cloneTodo())); | 629 | SLOT (cloneTodo())); |
626 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 630 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
627 | SLOT (moveTodo())); | 631 | SLOT (moveTodo())); |
628 | #ifndef DESKTOP_VERSION | 632 | #ifndef DESKTOP_VERSION |
629 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 633 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
630 | SLOT (beamTodo())); | 634 | SLOT (beamTodo())); |
631 | #endif | 635 | #endif |
632 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 636 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
633 | SLOT (cancelTodo())); | 637 | SLOT (cancelTodo())); |
634 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 638 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
635 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 639 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
636 | mItemPopupMenu->insertSeparator(); | 640 | mItemPopupMenu->insertSeparator(); |
637 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 641 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
638 | SLOT (toggleRunningItem())); | 642 | SLOT (toggleRunningItem())); |
639 | mItemPopupMenu->insertSeparator(); | 643 | mItemPopupMenu->insertSeparator(); |
640 | /* | 644 | /* |
641 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 645 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
642 | SLOT (newTodo())); | 646 | SLOT (newTodo())); |
643 | */ | 647 | */ |
644 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 648 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
645 | SLOT (newSubTodo())); | 649 | SLOT (newSubTodo())); |
646 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 650 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
647 | SLOT (unparentTodo()),0,21); | 651 | SLOT (unparentTodo()),0,21); |
648 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 652 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
649 | SLOT (reparentTodo()),0,22); | 653 | SLOT (reparentTodo()),0,22); |
650 | mItemPopupMenu->insertSeparator(); | 654 | mItemPopupMenu->insertSeparator(); |
651 | #if 0 | 655 | #if 0 |
652 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 656 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
653 | this, SLOT( purgeCompleted() ) ); | 657 | this, SLOT( purgeCompleted() ) ); |
654 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 658 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
655 | this, SLOT( toggleCompleted() ),0, 33 ); | 659 | this, SLOT( toggleCompleted() ),0, 33 ); |
656 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 660 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
657 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 661 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
658 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 662 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
659 | this, SLOT( toggleRunning() ),0, 35 ); | 663 | this, SLOT( toggleRunning() ),0, 35 ); |
660 | 664 | ||
661 | #endif | 665 | #endif |
662 | mPopupMenu = new QPopupMenu(this); | 666 | mPopupMenu = new QPopupMenu(this); |
663 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 667 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
664 | SLOT (newTodo()),0,1); | 668 | SLOT (newTodo()),0,1); |
665 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 669 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
666 | this, SLOT(purgeCompleted()),0,2); | 670 | this, SLOT(purgeCompleted()),0,2); |
667 | mPopupMenu->insertItem(i18n("Show Completed"), | 671 | mPopupMenu->insertItem(i18n("Show Completed"), |
668 | this, SLOT( toggleCompleted() ),0,3 ); | 672 | this, SLOT( toggleCompleted() ),0,3 ); |
669 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 673 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
670 | this, SLOT( toggleRunning() ),0,5 ); | 674 | this, SLOT( toggleRunning() ),0,5 ); |
671 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 675 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
672 | this, SLOT( setAllOpen() ),0,6 ); | 676 | this, SLOT( setAllOpen() ),0,6 ); |
673 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 677 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
674 | this, SLOT( setAllClose() ),0,7 ); | 678 | this, SLOT( setAllClose() ),0,7 ); |
675 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 679 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
676 | this, SLOT( setAllFlat() ),0,8 ); | 680 | this, SLOT( setAllFlat() ),0,8 ); |
677 | mPopupMenu->insertSeparator(); | 681 | mPopupMenu->insertSeparator(); |
678 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 682 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
679 | this, SLOT( toggleQuickTodo() ),0,4 ); | 683 | this, SLOT( toggleQuickTodo() ),0,4 ); |
680 | mDocPrefs = new DocPrefs( name ); | 684 | mDocPrefs = new DocPrefs( name ); |
681 | 685 | ||
682 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 686 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
683 | mPopupMenu->setCheckable( true ); | 687 | mPopupMenu->setCheckable( true ); |
684 | mItemPopupMenu->setCheckable( true ); | 688 | mItemPopupMenu->setCheckable( true ); |
685 | 689 | ||
686 | 690 | ||
687 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 691 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
688 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 692 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
689 | 693 | ||
690 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 694 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
691 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 695 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
692 | 696 | ||
693 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 697 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
694 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 698 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
695 | 699 | ||
696 | 700 | ||
697 | // Double clicking conflicts with opening/closing the subtree | 701 | // Double clicking conflicts with opening/closing the subtree |
698 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 702 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
699 | SLOT( editItem( QListViewItem *) ) ); | 703 | SLOT( editItem( QListViewItem *) ) ); |
700 | /* | 704 | /* |
701 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 705 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
702 | const QPoint &,int ) ), | 706 | const QPoint &,int ) ), |
703 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 707 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
704 | */ | 708 | */ |
705 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 709 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
706 | const QPoint &,int ) ), | 710 | const QPoint &,int ) ), |
707 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 711 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
708 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 712 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
709 | SLOT( itemClicked( QListViewItem * ) ) ); | 713 | SLOT( itemClicked( QListViewItem * ) ) ); |
710 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 714 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
711 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 715 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
712 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 716 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
713 | SLOT( updateView() ) ); | 717 | SLOT( updateView() ) ); |
714 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 718 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
715 | SLOT( todoModified(Todo *, int) ) ); | 719 | SLOT( todoModified(Todo *, int) ) ); |
716 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 720 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
717 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 721 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
718 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 722 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
719 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 723 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
720 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 724 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
721 | SLOT( paintNeeded()) ); | 725 | SLOT( paintNeeded()) ); |
722 | 726 | ||
723 | #if 0 | 727 | #if 0 |
724 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 728 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
725 | SLOT(selectionChanged(QListViewItem *))); | 729 | SLOT(selectionChanged(QListViewItem *))); |
726 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 730 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
727 | SLOT(selectionChanged(QListViewItem *))); | 731 | SLOT(selectionChanged(QListViewItem *))); |
728 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 732 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
729 | SLOT(selectionChanged(QListViewItem *))); | 733 | SLOT(selectionChanged(QListViewItem *))); |
730 | #endif | 734 | #endif |
731 | 735 | ||
732 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 736 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
733 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 737 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
734 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 738 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
735 | 739 | ||
736 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 740 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
737 | SLOT( processSelectionChange() ) ); | 741 | SLOT( processSelectionChange() ) ); |
738 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 742 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
739 | SLOT( addQuickTodo() ) ); | 743 | SLOT( addQuickTodo() ) ); |
740 | 744 | ||
741 | } | 745 | } |
742 | 746 | ||
743 | KOTodoView::~KOTodoView() | 747 | KOTodoView::~KOTodoView() |
744 | { | 748 | { |
745 | 749 | ||
746 | #if QT_VERSION >= 0x030000 | 750 | #if QT_VERSION >= 0x030000 |
747 | 751 | ||
748 | #else | 752 | #else |
749 | delete mKOTodoViewWhatsThis; | 753 | delete mKOTodoViewWhatsThis; |
750 | #endif | 754 | #endif |
751 | 755 | ||
752 | delete mDocPrefs; | 756 | delete mDocPrefs; |
753 | } | 757 | } |
754 | QString KOTodoView::getWhatsThisText(QPoint p) | 758 | QString KOTodoView::getWhatsThisText(QPoint p) |
755 | { | 759 | { |
756 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 760 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
757 | if ( item ) | 761 | if ( item ) |
758 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 762 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
759 | KOPrefs::instance()->mWTshowDetails, | 763 | KOPrefs::instance()->mWTshowDetails, |
760 | KOPrefs::instance()->mWTshowCreated, | 764 | KOPrefs::instance()->mWTshowCreated, |
761 | KOPrefs::instance()->mWTshowChanged); | 765 | KOPrefs::instance()->mWTshowChanged); |
762 | return i18n("That is the todo view" ); | 766 | return i18n("That is the todo view" ); |
763 | 767 | ||
764 | } | 768 | } |
765 | 769 | ||
766 | void KOTodoView::jumpToDate () | 770 | void KOTodoView::jumpToDate () |
767 | { | 771 | { |
768 | // if (mActiveItem) { | 772 | // if (mActiveItem) { |
769 | // mActiveItem->todo()); | 773 | // mActiveItem->todo()); |
770 | // if ( mActiveItem->todo()->hasDueDate() ) | 774 | // if ( mActiveItem->todo()->hasDueDate() ) |
771 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 775 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
772 | } | 776 | } |
773 | void KOTodoView::paintNeeded() | 777 | void KOTodoView::paintNeeded() |
774 | { | 778 | { |
775 | if ( mPendingUpdateBeforeRepaint ) { | 779 | if ( mPendingUpdateBeforeRepaint ) { |
776 | updateView(); | 780 | updateView(); |
777 | mPendingUpdateBeforeRepaint = false; | 781 | mPendingUpdateBeforeRepaint = false; |
778 | } | 782 | } |
779 | } | 783 | } |
780 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 784 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
781 | { | 785 | { |
782 | if ( mPendingUpdateBeforeRepaint ) { | 786 | if ( mPendingUpdateBeforeRepaint ) { |
783 | updateView(); | 787 | updateView(); |
784 | mPendingUpdateBeforeRepaint = false; | 788 | mPendingUpdateBeforeRepaint = false; |
785 | } | 789 | } |
786 | KOrg::BaseView::paintEvent( pevent); | 790 | KOrg::BaseView::paintEvent( pevent); |
787 | } | 791 | } |
788 | 792 | ||
789 | void KOTodoView::updateView() | 793 | void KOTodoView::updateView() |
790 | { | 794 | { |
791 | pendingSubtodo = 0; | 795 | pendingSubtodo = 0; |
792 | if ( mBlockUpdate ) { | 796 | if ( mBlockUpdate ) { |
793 | return; | 797 | return; |
794 | } | 798 | } |
795 | if ( !isVisible() ) { | 799 | if ( !isVisible() ) { |
796 | mPendingUpdateBeforeRepaint = true; | 800 | mPendingUpdateBeforeRepaint = true; |
797 | return; | 801 | return; |
798 | } | 802 | } |
799 | //qDebug("KOTodoView::updateView() %x", this); | 803 | //qDebug("KOTodoView::updateView() %x", this); |
800 | if ( isFlatDisplay ) { | 804 | if ( isFlatDisplay ) { |
801 | displayAllFlat(); | 805 | displayAllFlat(); |
802 | return; | 806 | return; |
803 | } | 807 | } |
804 | storeCurrentItem(); | 808 | storeCurrentItem(); |
805 | //qDebug("update "); | 809 | //qDebug("update "); |
806 | // kdDebug() << "KOTodoView::updateView()" << endl; | 810 | // kdDebug() << "KOTodoView::updateView()" << endl; |
807 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 811 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
808 | 812 | ||
809 | 813 | ||
810 | mTodoListView->clear(); | 814 | mTodoListView->clear(); |
811 | if ( mName == "todolistsmall" ) { | 815 | if ( mName == "todolistsmall" ) { |
812 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 816 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
813 | int ps = fo.pointSize() -2; | 817 | int ps = fo.pointSize() -2; |
814 | if ( ps > 12 ) | 818 | if ( ps > 12 ) |
815 | ps -= 2; | 819 | ps -= 2; |
816 | fo.setPointSize( ps ); | 820 | fo.setPointSize( ps ); |
817 | } | 821 | } |
818 | } | 822 | } |
819 | 823 | ||
820 | mTodoListView->setFont( fo ); | 824 | mTodoListView->setFont( fo ); |
821 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 825 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
822 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 826 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
823 | QPtrList<Todo> todoList = calendar()->todos(); | 827 | QPtrList<Todo> todoList = calendar()->todos(); |
824 | 828 | ||
825 | /* | 829 | /* |
826 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 830 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
827 | Event *t; | 831 | Event *t; |
828 | for(t = todoList.first(); t; t = todoList.next()) { | 832 | for(t = todoList.first(); t; t = todoList.next()) { |
829 | kdDebug() << " " << t->getSummary() << endl; | 833 | kdDebug() << " " << t->getSummary() << endl; |
830 | 834 | ||
831 | if (t->getRelatedTo()) { | 835 | if (t->getRelatedTo()) { |
832 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 836 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
833 | } | 837 | } |
834 | 838 | ||
835 | QPtrList<Event> l = t->getRelations(); | 839 | QPtrList<Event> l = t->getRelations(); |
836 | Event *c; | 840 | Event *c; |
837 | for(c=l.first();c;c=l.next()) { | 841 | for(c=l.first();c;c=l.next()) { |
838 | kdDebug() << " - relation: " << c->getSummary() << endl; | 842 | kdDebug() << " - relation: " << c->getSummary() << endl; |
839 | } | 843 | } |
840 | } | 844 | } |
841 | */ | 845 | */ |
842 | 846 | ||
843 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 847 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
844 | // specific order of events. That means that we have to generate parent items | 848 | // specific order of events. That means that we have to generate parent items |
845 | // recursively for proper hierarchical display of Todos. | 849 | // recursively for proper hierarchical display of Todos. |
846 | mTodoMap.clear(); | 850 | mTodoMap.clear(); |
847 | Todo *todo; | 851 | Todo *todo; |
848 | todo = todoList.first();// todo; todo = todoList.next()) { | 852 | todo = todoList.first();// todo; todo = todoList.next()) { |
849 | while ( todo ) { | 853 | while ( todo ) { |
850 | bool next = true; | 854 | bool next = true; |
851 | // qDebug("todo %s ", todo->summary().latin1()); | 855 | // qDebug("todo %s ", todo->summary().latin1()); |
852 | Incidence *incidence = todo->relatedTo(); | 856 | Incidence *incidence = todo->relatedTo(); |
853 | while ( incidence ) { | 857 | while ( incidence ) { |
854 | if ( incidence->typeID() == todoID ) { | 858 | if ( incidence->typeID() == todoID ) { |
855 | //qDebug("related %s ",incidence->summary().latin1() ); | 859 | //qDebug("related %s ",incidence->summary().latin1() ); |
856 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 860 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
857 | //qDebug("related not found "); | 861 | //qDebug("related not found "); |
858 | todoList.remove( ); | 862 | todoList.remove( ); |
859 | todo = todoList.current(); | 863 | todo = todoList.current(); |
860 | next = false; | 864 | next = false; |
861 | incidence = 0; | 865 | incidence = 0; |
862 | 866 | ||
863 | } else { | 867 | } else { |
864 | //qDebug("related found "); | 868 | //qDebug("related found "); |
865 | incidence = incidence->relatedTo(); | 869 | incidence = incidence->relatedTo(); |
866 | } | 870 | } |
867 | } else | 871 | } else |
868 | incidence = 0; | 872 | incidence = 0; |
869 | } | 873 | } |
870 | if ( next ) | 874 | if ( next ) |
871 | todo = todoList.next(); | 875 | todo = todoList.next(); |
872 | } | 876 | } |
873 | 877 | ||
874 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 878 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
875 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 879 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
876 | { | 880 | { |
877 | insertTodoItem(todo); | 881 | insertTodoItem(todo); |
878 | } | 882 | } |
879 | } | 883 | } |
880 | // Restore opened/closed state | 884 | // Restore opened/closed state |
881 | mTodoListView->blockSignals( true ); | 885 | mTodoListView->blockSignals( true ); |
882 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 886 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
883 | mTodoListView->blockSignals( false ); | 887 | mTodoListView->blockSignals( false ); |
884 | resetCurrentItem(); | 888 | resetCurrentItem(); |
885 | } | 889 | } |
886 | 890 | ||
887 | void KOTodoView::storeCurrentItem() | 891 | void KOTodoView::storeCurrentItem() |
888 | { | 892 | { |
889 | mCurItem = 0; | 893 | mCurItem = 0; |
890 | mCurItemRootParent = 0; | 894 | mCurItemRootParent = 0; |
891 | mCurItemParent = 0; | 895 | mCurItemParent = 0; |
892 | mCurItemAbove = 0; | 896 | mCurItemAbove = 0; |
893 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 897 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
894 | if (mActiveItem) { | 898 | if (mActiveItem) { |
895 | mCurItem = mActiveItem->todo(); | 899 | mCurItem = mActiveItem->todo(); |
896 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 900 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
897 | if ( activeItemAbove ) | 901 | if ( activeItemAbove ) |
898 | mCurItemAbove = activeItemAbove->todo(); | 902 | mCurItemAbove = activeItemAbove->todo(); |
899 | mCurItemRootParent = mCurItem; | 903 | mCurItemRootParent = mCurItem; |
900 | mCurItemParent = mCurItemRootParent->relatedTo(); | 904 | mCurItemParent = mCurItemRootParent->relatedTo(); |
901 | while ( mCurItemRootParent->relatedTo() != 0 ) | 905 | while ( mCurItemRootParent->relatedTo() != 0 ) |
902 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 906 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
903 | } | 907 | } |
904 | mActiveItem = 0; | 908 | mActiveItem = 0; |
905 | } | 909 | } |
906 | 910 | ||
907 | void KOTodoView::resetCurrentItem() | 911 | void KOTodoView::resetCurrentItem() |
908 | { | 912 | { |
909 | //mTodoListView->setFocus(); | 913 | //mTodoListView->setFocus(); |
910 | KOTodoViewItem* foundItem = 0; | 914 | KOTodoViewItem* foundItem = 0; |
911 | KOTodoViewItem* foundItemRoot = 0; | 915 | KOTodoViewItem* foundItemRoot = 0; |
912 | KOTodoViewItem* foundItemParent = 0; | 916 | KOTodoViewItem* foundItemParent = 0; |
913 | KOTodoViewItem* foundItemAbove = 0; | 917 | KOTodoViewItem* foundItemAbove = 0; |
914 | if ( mTodoListView->firstChild () ) { | 918 | if ( mTodoListView->firstChild () ) { |
915 | if ( mCurItem ) { | 919 | if ( mCurItem ) { |
916 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 920 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
917 | while ( item ) { | 921 | while ( item ) { |
918 | if ( item->todo() == mCurItem ) { | 922 | if ( item->todo() == mCurItem ) { |
919 | foundItem = item; | 923 | foundItem = item; |
920 | break; | 924 | break; |
921 | } else if ( item->todo() == mCurItemAbove ) { | 925 | } else if ( item->todo() == mCurItemAbove ) { |
922 | foundItemAbove = item; | 926 | foundItemAbove = item; |
923 | 927 | ||
924 | } | 928 | } |
925 | if ( item->todo() == mCurItemRootParent ) { | 929 | if ( item->todo() == mCurItemRootParent ) { |
926 | foundItemRoot = item; | 930 | foundItemRoot = item; |
927 | } | 931 | } |
928 | if ( item->todo() == mCurItemParent ) { | 932 | if ( item->todo() == mCurItemParent ) { |
929 | foundItemParent = item; | 933 | foundItemParent = item; |
930 | } | 934 | } |
931 | item = (KOTodoViewItem*)item->itemBelow(); | 935 | item = (KOTodoViewItem*)item->itemBelow(); |
932 | } | 936 | } |
933 | if ( ! foundItem ) { | 937 | if ( ! foundItem ) { |
934 | if ( foundItemParent ) { | 938 | if ( foundItemParent ) { |
935 | foundItem = foundItemParent; | 939 | foundItem = foundItemParent; |
936 | } else { | 940 | } else { |
937 | if ( foundItemRoot ) | 941 | if ( foundItemRoot ) |
938 | foundItem = foundItemRoot; | 942 | foundItem = foundItemRoot; |
939 | else | 943 | else |
940 | foundItem = foundItemAbove; | 944 | foundItem = foundItemAbove; |
941 | } | 945 | } |
942 | } | 946 | } |
943 | } | 947 | } |
944 | if ( foundItem ) { | 948 | if ( foundItem ) { |
945 | mTodoListView->setSelected ( foundItem, true ); | 949 | mTodoListView->setSelected ( foundItem, true ); |
946 | mTodoListView->setCurrentItem( foundItem ); | 950 | mTodoListView->setCurrentItem( foundItem ); |
947 | mTodoListView->ensureItemVisible( foundItem ); | 951 | mTodoListView->ensureItemVisible( foundItem ); |
948 | } else { | 952 | } else { |
949 | if ( mTodoListView->firstChild () ) { | 953 | if ( mTodoListView->firstChild () ) { |
950 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 954 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
951 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 955 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
952 | } | 956 | } |
953 | } | 957 | } |
954 | } | 958 | } |
955 | processSelectionChange(); | 959 | processSelectionChange(); |
956 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 960 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
957 | } | 961 | } |
958 | void KOTodoView::resetFocusToList() | 962 | void KOTodoView::resetFocusToList() |
959 | { | 963 | { |
960 | topLevelWidget()->setActiveWindow(); | 964 | topLevelWidget()->setActiveWindow(); |
961 | mTodoListView->setFocus(); | 965 | mTodoListView->setFocus(); |
962 | } | 966 | } |
963 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 967 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
964 | bool KOTodoView::checkTodo( Todo * todo ) | 968 | bool KOTodoView::checkTodo( Todo * todo ) |
965 | { | 969 | { |
966 | 970 | ||
967 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 971 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
968 | return false; | 972 | return false; |
969 | if ( !todo->isCompleted() ) { | 973 | if ( !todo->isCompleted() ) { |
970 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 974 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
971 | return true; | 975 | return true; |
972 | } | 976 | } |
973 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 977 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
974 | if ( todo->hasStartDate() ) | 978 | if ( todo->hasStartDate() ) |
975 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 979 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
976 | return false; | 980 | return false; |
977 | if ( todo->hasDueDate() ) | 981 | if ( todo->hasDueDate() ) |
978 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 982 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
979 | return false; | 983 | return false; |
980 | } | 984 | } |
981 | return true; | 985 | return true; |
982 | } | 986 | } |
983 | 987 | ||
984 | void KOTodoView::restoreItemState( QListViewItem *item ) | 988 | void KOTodoView::restoreItemState( QListViewItem *item ) |
985 | { | 989 | { |
986 | pendingSubtodo = 0; | 990 | pendingSubtodo = 0; |
987 | while( item ) { | 991 | while( item ) { |
988 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 992 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
989 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 993 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
990 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 994 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
991 | item = item->nextSibling(); | 995 | item = item->nextSibling(); |
992 | } | 996 | } |
993 | } | 997 | } |
994 | 998 | ||
995 | 999 | ||
996 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 1000 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
997 | KOTodoView::insertTodoItem(Todo *todo) | 1001 | KOTodoView::insertTodoItem(Todo *todo) |
998 | { | 1002 | { |
999 | 1003 | ||
1000 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1004 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1001 | // TODO: Check, if dynmaic cast is necessary | 1005 | // TODO: Check, if dynmaic cast is necessary |
1002 | 1006 | ||
1003 | pendingSubtodo = 0; | 1007 | pendingSubtodo = 0; |
1004 | Incidence *incidence = todo->relatedTo(); | 1008 | Incidence *incidence = todo->relatedTo(); |
1005 | while ( incidence && !incidence->calEnabled() ) | 1009 | while ( incidence && !incidence->calEnabled() ) |
1006 | incidence = incidence->relatedTo(); | 1010 | incidence = incidence->relatedTo(); |
1007 | if (incidence && incidence->typeID() == todoID ) { | 1011 | if (incidence && incidence->typeID() == todoID ) { |
1008 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 1012 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
1009 | 1013 | ||
1010 | // kdDebug() << " has Related" << endl; | 1014 | // kdDebug() << " has Related" << endl; |
1011 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1015 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1012 | itemIterator = mTodoMap.find(relatedTodo); | 1016 | itemIterator = mTodoMap.find(relatedTodo); |
1013 | if (itemIterator == mTodoMap.end()) { | 1017 | if (itemIterator == mTodoMap.end()) { |
1014 | // kdDebug() << " related not yet in list" << endl; | 1018 | // kdDebug() << " related not yet in list" << endl; |
1015 | itemIterator = insertTodoItem (relatedTodo); | 1019 | itemIterator = insertTodoItem (relatedTodo); |
1016 | } | 1020 | } |
1017 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 1021 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
1018 | // and one into the map. Sure finding is more easy but why? -zecke | 1022 | // and one into the map. Sure finding is more easy but why? -zecke |
1019 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 1023 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
1020 | return mTodoMap.insert(todo,todoItem); | 1024 | return mTodoMap.insert(todo,todoItem); |
1021 | } else { | 1025 | } else { |
1022 | // kdDebug() << " no Related" << endl; | 1026 | // kdDebug() << " no Related" << endl; |
1023 | // see above -zecke | 1027 | // see above -zecke |
1024 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1028 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1025 | return mTodoMap.insert(todo,todoItem); | 1029 | return mTodoMap.insert(todo,todoItem); |
1026 | } | 1030 | } |
1027 | } | 1031 | } |
1028 | 1032 | ||
1029 | 1033 | ||
1030 | void KOTodoView::updateConfig() | 1034 | void KOTodoView::updateConfig() |
1031 | { | 1035 | { |
1032 | updateView(); | 1036 | updateView(); |
1033 | mTodoListView->repaintContents(); | 1037 | mTodoListView->repaintContents(); |
1034 | } | 1038 | } |
1035 | 1039 | ||
1036 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1040 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1037 | { | 1041 | { |
1038 | QPtrList<Incidence> selected; | 1042 | QPtrList<Incidence> selected; |
1039 | 1043 | ||
1040 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1044 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1041 | // if (!item) item = mActiveItem; | 1045 | // if (!item) item = mActiveItem; |
1042 | if (item) selected.append(item->todo()); | 1046 | if (item) selected.append(item->todo()); |
1043 | 1047 | ||
1044 | return selected; | 1048 | return selected; |
1045 | } | 1049 | } |
1046 | 1050 | ||
1047 | QPtrList<Todo> KOTodoView::selectedTodos() | 1051 | QPtrList<Todo> KOTodoView::selectedTodos() |
1048 | { | 1052 | { |
1049 | QPtrList<Todo> selected; | 1053 | QPtrList<Todo> selected; |
1050 | 1054 | ||
1051 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1055 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1052 | // if (!item) item = mActiveItem; | 1056 | // if (!item) item = mActiveItem; |
1053 | if (item) selected.append(item->todo()); | 1057 | if (item) selected.append(item->todo()); |
1054 | 1058 | ||
1055 | return selected; | 1059 | return selected; |
1056 | } | 1060 | } |
1057 | 1061 | ||
1058 | void KOTodoView::changeEventDisplay(Event *, int) | 1062 | void KOTodoView::changeEventDisplay(Event *, int) |
1059 | { | 1063 | { |
1060 | updateView(); | 1064 | updateView(); |
1061 | } | 1065 | } |
1062 | 1066 | ||
1063 | void KOTodoView::showDates(const QDate &, const QDate &) | 1067 | void KOTodoView::showDates(const QDate &, const QDate &) |
1064 | { | 1068 | { |
1065 | } | 1069 | } |
1066 | 1070 | ||
1067 | void KOTodoView::showEvents(QPtrList<Event>) | 1071 | void KOTodoView::showEvents(QPtrList<Event>) |
1068 | { | 1072 | { |
1069 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1073 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1070 | } | 1074 | } |
1071 | 1075 | ||
1072 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1076 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1073 | const QDate &td) | 1077 | const QDate &td) |
1074 | { | 1078 | { |
1075 | #ifndef KORG_NOPRINTER | 1079 | #ifndef KORG_NOPRINTER |
1076 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1080 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1077 | #endif | 1081 | #endif |
1078 | } | 1082 | } |
1079 | 1083 | ||
1080 | void KOTodoView::editItem(QListViewItem *item ) | 1084 | void KOTodoView::editItem(QListViewItem *item ) |
1081 | { | 1085 | { |
1082 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1086 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1083 | } | 1087 | } |
1084 | 1088 | ||
1085 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1089 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1086 | { | 1090 | { |
1087 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1091 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1088 | } | 1092 | } |
1089 | 1093 | ||
1090 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1094 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1091 | { | 1095 | { |
1092 | pendingSubtodo = 0; | 1096 | pendingSubtodo = 0; |
1093 | mActiveItem = (KOTodoViewItem *)item; | 1097 | mActiveItem = (KOTodoViewItem *)item; |
1094 | if (item) { | 1098 | if (item) { |
1095 | switch (column){ | 1099 | switch (column){ |
1096 | case 1: | 1100 | case 1: |
1097 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1101 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1098 | case 2: | 1102 | case 2: |
1099 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1103 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1100 | case 3: | 1104 | case 3: |
1101 | moveTodo(); | 1105 | moveTodo(); |
1102 | break; | 1106 | break; |
1103 | case 8: | 1107 | case 8: |
1104 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1108 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1105 | case 9: | 1109 | case 9: |
1106 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1110 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1107 | default: | 1111 | default: |
1108 | mItemPopupMenu->popup(QCursor::pos()); | 1112 | mItemPopupMenu->popup(QCursor::pos()); |
1109 | } | 1113 | } |
1110 | } else mPopupMenu->popup(QCursor::pos()); | 1114 | } else mPopupMenu->popup(QCursor::pos()); |
1111 | } | 1115 | } |
1112 | void KOTodoView::newTodo() | 1116 | void KOTodoView::newTodo() |
1113 | { | 1117 | { |
1114 | emit newTodoSignal(); | 1118 | emit newTodoSignal(); |
1115 | } | 1119 | } |
1116 | 1120 | ||
1117 | void KOTodoView::newSubTodo() | 1121 | void KOTodoView::newSubTodo() |
1118 | { | 1122 | { |
1119 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1123 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1120 | if (mActiveItem) { | 1124 | if (mActiveItem) { |
1121 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add a new Todo") ) { | 1125 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { |
1122 | addQuickTodoPar( mActiveItem->todo()); | 1126 | addQuickTodoPar( mActiveItem->todo()); |
1123 | } else | 1127 | } else |
1124 | emit newSubTodoSignal(mActiveItem->todo()); | 1128 | emit newSubTodoSignal(mActiveItem->todo()); |
1125 | } | 1129 | } |
1126 | } | 1130 | } |
1127 | void KOTodoView::unparentTodo() | 1131 | void KOTodoView::unparentTodo() |
1128 | { | 1132 | { |
1129 | if (mActiveItem) { | 1133 | if (mActiveItem) { |
1130 | emit unparentTodoSignal(mActiveItem->todo()); | 1134 | emit unparentTodoSignal(mActiveItem->todo()); |
1131 | } | 1135 | } |
1132 | } | 1136 | } |
1133 | 1137 | ||
1134 | void KOTodoView::reparentTodo() | 1138 | void KOTodoView::reparentTodo() |
1135 | { | 1139 | { |
1136 | if (mActiveItem) { | 1140 | if (mActiveItem) { |
1137 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1141 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1138 | pendingSubtodo = mActiveItem; | 1142 | pendingSubtodo = mActiveItem; |
1139 | } | 1143 | } |
1140 | } | 1144 | } |
1141 | void KOTodoView::editTodo() | 1145 | void KOTodoView::editTodo() |
1142 | { | 1146 | { |
1143 | if (mActiveItem) { | 1147 | if (mActiveItem) { |
1144 | emit editTodoSignal(mActiveItem->todo()); | 1148 | emit editTodoSignal(mActiveItem->todo()); |
1145 | } | 1149 | } |
1146 | } | 1150 | } |
1147 | void KOTodoView::cloneTodo() | 1151 | void KOTodoView::cloneTodo() |
1148 | { | 1152 | { |
1149 | if (mActiveItem) { | 1153 | if (mActiveItem) { |
1150 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1154 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1151 | } | 1155 | } |
1152 | } | 1156 | } |
1153 | void KOTodoView::cancelTodo() | 1157 | void KOTodoView::cancelTodo() |
1154 | { | 1158 | { |
1155 | if (mActiveItem) { | 1159 | if (mActiveItem) { |
1156 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1160 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1157 | } | 1161 | } |
1158 | } | 1162 | } |
1159 | void KOTodoView::moveTodo() | 1163 | void KOTodoView::moveTodo() |
1160 | { | 1164 | { |
1161 | if (mActiveItem) { | 1165 | if (mActiveItem) { |
1162 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1166 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1163 | } | 1167 | } |
1164 | } | 1168 | } |
1165 | void KOTodoView::beamTodo() | 1169 | void KOTodoView::beamTodo() |
1166 | { | 1170 | { |
1167 | if (mActiveItem) { | 1171 | if (mActiveItem) { |
1168 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1172 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1169 | } | 1173 | } |
1170 | } | 1174 | } |
1171 | 1175 | ||
1172 | 1176 | ||
1173 | void KOTodoView::showTodo() | 1177 | void KOTodoView::showTodo() |
1174 | { | 1178 | { |
1175 | if (mActiveItem) { | 1179 | if (mActiveItem) { |
1176 | emit showTodoSignal(mActiveItem->todo()); | 1180 | emit showTodoSignal(mActiveItem->todo()); |
1177 | } | 1181 | } |
1178 | } | 1182 | } |
1179 | 1183 | ||
1180 | void KOTodoView::deleteTodo() | 1184 | void KOTodoView::deleteTodo() |
1181 | { | 1185 | { |
1182 | if (mActiveItem) { | 1186 | if (mActiveItem) { |
1183 | emit deleteTodoSignal(mActiveItem->todo()); | 1187 | emit deleteTodoSignal(mActiveItem->todo()); |
1184 | } | 1188 | } |
1185 | } | 1189 | } |
1186 | 1190 | ||
1187 | void KOTodoView::setNewPriority(int index) | 1191 | void KOTodoView::setNewPriority(int index) |
1188 | { | 1192 | { |
1189 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1193 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1190 | mActiveItem->todo()->setPriority(mPriority[index]); | 1194 | mActiveItem->todo()->setPriority(mPriority[index]); |
1191 | mActiveItem->construct(); | 1195 | mActiveItem->construct(); |
1192 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1196 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1193 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1197 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1194 | } | 1198 | } |
1195 | processSelectionChange(); | 1199 | processSelectionChange(); |
1196 | } | 1200 | } |
1197 | 1201 | ||
1198 | void KOTodoView::setNewPercentage(int index) | 1202 | void KOTodoView::setNewPercentage(int index) |
1199 | { | 1203 | { |
1200 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1204 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1201 | 1205 | ||
1202 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1206 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1203 | mActiveItem->setOn( true ); | 1207 | mActiveItem->setOn( true ); |
1204 | processSelectionChange(); | 1208 | processSelectionChange(); |
1205 | return; | 1209 | return; |
1206 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1210 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1207 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1211 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1208 | if ( par && par->isOn() ) | 1212 | if ( par && par->isOn() ) |
1209 | par->setOn( false ); | 1213 | par->setOn( false ); |
1210 | } | 1214 | } |
1211 | if (mPercentage[index] == 100) { | 1215 | if (mPercentage[index] == 100) { |
1212 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1216 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1213 | } else { | 1217 | } else { |
1214 | mActiveItem->todo()->setCompleted(false); | 1218 | mActiveItem->todo()->setCompleted(false); |
1215 | } | 1219 | } |
1216 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1220 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1217 | mActiveItem->construct(); | 1221 | mActiveItem->construct(); |
1218 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1222 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1219 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1223 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1220 | } | 1224 | } |
1221 | processSelectionChange(); | 1225 | processSelectionChange(); |
1222 | } | 1226 | } |
1223 | 1227 | ||
1224 | void KOTodoView::fillCategories () | 1228 | void KOTodoView::fillCategories () |
1225 | { | 1229 | { |
1226 | mCategoryPopupMenu->clear(); | 1230 | mCategoryPopupMenu->clear(); |
1227 | if ( ! mActiveItem ) return; | 1231 | if ( ! mActiveItem ) return; |
1228 | QStringList checkedCategories = mActiveItem->todo()->categories (); | 1232 | QStringList checkedCategories = mActiveItem->todo()->categories (); |
1229 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1233 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1230 | it != KOPrefs::instance()->mCustomCategories.end (); | 1234 | it != KOPrefs::instance()->mCustomCategories.end (); |
1231 | ++it) { | 1235 | ++it) { |
1232 | int index = mCategoryPopupMenu->insertItem (*it); | 1236 | int index = mCategoryPopupMenu->insertItem (*it); |
1233 | mCategory[index] = *it; | 1237 | mCategory[index] = *it; |
1234 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1238 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1235 | } | 1239 | } |
1236 | } | 1240 | } |
1237 | void KOTodoView::fillCal () | 1241 | void KOTodoView::fillCal () |
1238 | { | 1242 | { |
1239 | mCalPopupMenu->clear(); | 1243 | mCalPopupMenu->clear(); |
1240 | if (!mActiveItem) return; | 1244 | if (!mActiveItem) return; |
1241 | bool readO = mActiveItem->todo()->isReadOnly(); | 1245 | bool readO = mActiveItem->todo()->isReadOnly(); |
1242 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 1246 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
1243 | while ( kkf ) { | 1247 | while ( kkf ) { |
1244 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | 1248 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); |
1245 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | 1249 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) |
1246 | mCalPopupMenu->setItemEnabled( index, false ); | 1250 | mCalPopupMenu->setItemEnabled( index, false ); |
1247 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | 1251 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); |
1248 | kkf = KOPrefs::instance()->mCalendars.next(); | 1252 | kkf = KOPrefs::instance()->mCalendars.next(); |
1249 | } | 1253 | } |
1250 | } | 1254 | } |
1251 | void KOTodoView::changedCal (int index ) | 1255 | void KOTodoView::changedCal (int index ) |
1252 | { | 1256 | { |
1253 | if (!mActiveItem) return; | 1257 | if (!mActiveItem) return; |
1254 | mActiveItem->todo()->setCalID( index ); | 1258 | mActiveItem->todo()->setCalID( index ); |
1255 | mActiveItem->construct(); | 1259 | mActiveItem->construct(); |
1256 | } | 1260 | } |
1257 | void KOTodoView::changedCategories(int index) | 1261 | void KOTodoView::changedCategories(int index) |
1258 | { | 1262 | { |
1259 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1263 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1260 | QStringList categories = mActiveItem->todo()->categories (); | 1264 | QStringList categories = mActiveItem->todo()->categories (); |
1261 | QString colcat = categories.first(); | 1265 | QString colcat = categories.first(); |
1262 | if (categories.find (mCategory[index]) != categories.end ()) | 1266 | if (categories.find (mCategory[index]) != categories.end ()) |
1263 | categories.remove (mCategory[index]); | 1267 | categories.remove (mCategory[index]); |
1264 | else | 1268 | else |
1265 | categories.insert (categories.end(), mCategory[index]); | 1269 | categories.insert (categories.end(), mCategory[index]); |
1266 | categories.sort (); | 1270 | categories.sort (); |
1267 | if ( !colcat.isEmpty() ) { | 1271 | if ( !colcat.isEmpty() ) { |
1268 | if ( categories.find ( colcat ) != categories.end () ) { | 1272 | if ( categories.find ( colcat ) != categories.end () ) { |
1269 | categories.remove( colcat ); | 1273 | categories.remove( colcat ); |
1270 | categories.prepend( colcat ); | 1274 | categories.prepend( colcat ); |
1271 | } | 1275 | } |
1272 | } | 1276 | } |
1273 | mActiveItem->todo()->setCategories (categories); | 1277 | mActiveItem->todo()->setCategories (categories); |
1274 | mActiveItem->construct(); | 1278 | mActiveItem->construct(); |
1275 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1279 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1276 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1280 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1277 | } | 1281 | } |
1278 | } | 1282 | } |
1279 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1283 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1280 | { | 1284 | { |
1281 | if ( pendingSubtodo != 0 ) { | 1285 | if ( pendingSubtodo != 0 ) { |
1282 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1286 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1283 | } | 1287 | } |
1284 | pendingSubtodo = 0; | 1288 | pendingSubtodo = 0; |
1285 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1289 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1286 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1290 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1287 | //qDebug("ROW %d ", row); | 1291 | //qDebug("ROW %d ", row); |
1288 | if (!item) { | 1292 | if (!item) { |
1289 | newTodo(); | 1293 | newTodo(); |
1290 | return; | 1294 | return; |
1291 | } else { | 1295 | } else { |
1292 | if ( row == 1 ) { | 1296 | if ( row == 1 ) { |
1293 | mActiveItem = (KOTodoViewItem *) item; | 1297 | mActiveItem = (KOTodoViewItem *) item; |
1294 | newSubTodo(); | 1298 | newSubTodo(); |
1295 | return; | 1299 | return; |
1296 | } | 1300 | } |
1297 | if ( row == 5 || row == 6 || row == 2) { | 1301 | if ( row == 5 || row == 6 || row == 2) { |
1298 | mActiveItem = (KOTodoViewItem *) item; | 1302 | mActiveItem = (KOTodoViewItem *) item; |
1299 | Todo * t = mActiveItem->todo(); | 1303 | Todo * t = mActiveItem->todo(); |
1300 | if ( t->isRunning() ) { | 1304 | if ( t->isRunning() ) { |
1301 | if ( t->runTime() < 15) { | 1305 | if ( t->runTime() < 15) { |
1302 | t->stopRunning(); | 1306 | t->stopRunning(); |
1303 | mActiveItem->construct(); | 1307 | mActiveItem->construct(); |
1304 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1308 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1305 | return; | 1309 | return; |
1306 | } | 1310 | } |
1307 | else | 1311 | else |
1308 | toggleRunningItem(); | 1312 | toggleRunningItem(); |
1309 | return; | 1313 | return; |
1310 | } else { | 1314 | } else { |
1311 | t->setRunning( true ); | 1315 | t->setRunning( true ); |
1312 | mActiveItem->construct(); | 1316 | mActiveItem->construct(); |
1313 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1317 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1314 | return; | 1318 | return; |
1315 | } | 1319 | } |
1316 | } | 1320 | } |
1317 | } | 1321 | } |
1318 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1322 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1319 | editItem( item ); | 1323 | editItem( item ); |
1320 | else | 1324 | else |
1321 | showItem( item , QPoint(), 0 ); | 1325 | showItem( item , QPoint(), 0 ); |
1322 | } | 1326 | } |
1323 | void KOTodoView::toggleRunningItem() | 1327 | void KOTodoView::toggleRunningItem() |
1324 | { | 1328 | { |
1325 | // qDebug("KOTodoView::toggleRunning() "); | 1329 | // qDebug("KOTodoView::toggleRunning() "); |
1326 | if ( ! mActiveItem ) | 1330 | if ( ! mActiveItem ) |
1327 | return; | 1331 | return; |
1328 | Todo * t = mActiveItem->todo(); | 1332 | Todo * t = mActiveItem->todo(); |
1329 | if ( t->isRunning() ) { | 1333 | if ( t->isRunning() ) { |
1330 | KOStopTodoPrefs tp ( t, this ); | 1334 | KOStopTodoPrefs tp ( t, this ); |
1331 | if (QApplication::desktop()->width() <= 800 ){ | 1335 | if (QApplication::desktop()->width() <= 800 ){ |
1332 | int wid = tp.width(); | 1336 | int wid = tp.width(); |
1333 | int hei = tp.height(); | 1337 | int hei = tp.height(); |
1334 | int xx = (QApplication::desktop()->width()-wid)/2; | 1338 | int xx = (QApplication::desktop()->width()-wid)/2; |
1335 | int yy = (QApplication::desktop()->height()-hei)/2; | 1339 | int yy = (QApplication::desktop()->height()-hei)/2; |
1336 | tp.setGeometry( xx,yy,wid,hei ); | 1340 | tp.setGeometry( xx,yy,wid,hei ); |
1337 | } | 1341 | } |
1338 | tp.exec(); | 1342 | tp.exec(); |
1339 | mActiveItem->construct(); | 1343 | mActiveItem->construct(); |
1340 | } else { | 1344 | } else { |
1341 | KOStartTodoPrefs tp ( t->summary(), this ); | 1345 | KOStartTodoPrefs tp ( t->summary(), this ); |
1342 | if (QApplication::desktop()->width() <= 800 ){ | 1346 | if (QApplication::desktop()->width() <= 800 ){ |
1343 | int wid = tp.width(); | 1347 | int wid = tp.width(); |
1344 | int hei = tp.height(); | 1348 | int hei = tp.height(); |
1345 | int xx = (QApplication::desktop()->width()-wid)/2; | 1349 | int xx = (QApplication::desktop()->width()-wid)/2; |
1346 | int yy = (QApplication::desktop()->height()-hei)/2; | 1350 | int yy = (QApplication::desktop()->height()-hei)/2; |
1347 | tp.setGeometry( xx,yy,wid,hei ); | 1351 | tp.setGeometry( xx,yy,wid,hei ); |
1348 | } | 1352 | } |
1349 | if ( !tp.exec() ) return; | 1353 | if ( !tp.exec() ) return; |
1350 | if ( tp.stopAll() ) { | 1354 | if ( tp.stopAll() ) { |
1351 | mCalendar->stopAllTodos(); | 1355 | mCalendar->stopAllTodos(); |
1352 | t->setRunning( true ); | 1356 | t->setRunning( true ); |
1353 | updateView(); | 1357 | updateView(); |
1354 | } else { | 1358 | } else { |
1355 | t->setRunning( true ); | 1359 | t->setRunning( true ); |
1356 | mActiveItem->construct(); | 1360 | mActiveItem->construct(); |
1357 | } | 1361 | } |
1358 | } | 1362 | } |
1359 | } | 1363 | } |
1360 | 1364 | ||
1361 | void KOTodoView::itemClicked(QListViewItem *item) | 1365 | void KOTodoView::itemClicked(QListViewItem *item) |
1362 | { | 1366 | { |
1363 | //qDebug("KOTodoView::itemClicked %d", item); | 1367 | //qDebug("KOTodoView::itemClicked %d", item); |
1364 | if (!item) { | 1368 | if (!item) { |
1365 | if ( pendingSubtodo != 0 ) { | 1369 | if ( pendingSubtodo != 0 ) { |
1366 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1370 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1367 | } | 1371 | } |
1368 | pendingSubtodo = 0; | 1372 | pendingSubtodo = 0; |
1369 | return; | 1373 | return; |
1370 | } | 1374 | } |
1371 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1375 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1372 | if ( pendingSubtodo != 0 ) { | 1376 | if ( pendingSubtodo != 0 ) { |
1373 | bool allowReparent = true; | 1377 | bool allowReparent = true; |
1374 | QListViewItem *par = item; | 1378 | QListViewItem *par = item; |
1375 | while ( par ) { | 1379 | while ( par ) { |
1376 | if ( par == pendingSubtodo ) { | 1380 | if ( par == pendingSubtodo ) { |
1377 | allowReparent = false; | 1381 | allowReparent = false; |
1378 | break; | 1382 | break; |
1379 | } | 1383 | } |
1380 | par = par->parent(); | 1384 | par = par->parent(); |
1381 | } | 1385 | } |
1382 | if ( !allowReparent ) { | 1386 | if ( !allowReparent ) { |
1383 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1387 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1384 | pendingSubtodo = 0; | 1388 | pendingSubtodo = 0; |
1385 | } else { | 1389 | } else { |
1386 | Todo* newParent = todoItem->todo(); | 1390 | Todo* newParent = todoItem->todo(); |
1387 | Todo* newSub = pendingSubtodo->todo(); | 1391 | Todo* newSub = pendingSubtodo->todo(); |
1388 | pendingSubtodo = 0; | 1392 | pendingSubtodo = 0; |
1389 | emit reparentTodoSignal( newParent,newSub ); | 1393 | emit reparentTodoSignal( newParent,newSub ); |
1390 | return; | 1394 | return; |
1391 | } | 1395 | } |
1392 | } | 1396 | } |
1393 | 1397 | ||
1394 | } | 1398 | } |
1395 | 1399 | ||
1396 | void KOTodoView::setDocumentId( const QString &id ) | 1400 | void KOTodoView::setDocumentId( const QString &id ) |
1397 | { | 1401 | { |
1398 | 1402 | ||
1399 | mDocPrefs->setDoc( id ); | 1403 | mDocPrefs->setDoc( id ); |
1400 | } | 1404 | } |
1401 | 1405 | ||
1402 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1406 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1403 | { | 1407 | { |
1404 | if (!item) return; | 1408 | if (!item) return; |
1405 | 1409 | ||
1406 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1410 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1407 | 1411 | ||
1408 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1412 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1409 | 1413 | ||
1410 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1414 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1411 | } | 1415 | } |
1412 | 1416 | ||
1413 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1417 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1414 | { | 1418 | { |
1415 | mTodoListView->saveLayout(config,group); | 1419 | mTodoListView->saveLayout(config,group); |
1416 | } | 1420 | } |
1417 | 1421 | ||
1418 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1422 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1419 | { | 1423 | { |
1420 | mTodoListView->restoreLayout(config,group); | 1424 | mTodoListView->restoreLayout(config,group); |
1421 | } | 1425 | } |
1422 | 1426 | ||
1423 | void KOTodoView::processSelectionChange() | 1427 | void KOTodoView::processSelectionChange() |
1424 | { | 1428 | { |
1425 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1429 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1426 | 1430 | ||
1427 | KOTodoViewItem *item = | 1431 | KOTodoViewItem *item = |
1428 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1432 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1429 | 1433 | ||
1430 | if ( !item ) { | 1434 | if ( !item ) { |
1431 | emit incidenceSelected( 0 ); | 1435 | emit incidenceSelected( 0 ); |
1432 | mNewSubBut->setEnabled( false ); | 1436 | mNewSubBut->setEnabled( false ); |
1433 | } else { | 1437 | } else { |
1434 | emit incidenceSelected( item->todo() ); | 1438 | emit incidenceSelected( item->todo() ); |
1435 | mNewSubBut->setEnabled( true ); | 1439 | mNewSubBut->setEnabled( true ); |
1436 | } | 1440 | } |
1437 | } | 1441 | } |
1438 | 1442 | ||
1439 | void KOTodoView::modified(bool b) | 1443 | void KOTodoView::modified(bool b) |
1440 | { | 1444 | { |
1441 | emit isModified(b); | 1445 | emit isModified(b); |
1442 | } | 1446 | } |
1443 | void KOTodoView::setTodoModified( Todo* todo ) | 1447 | void KOTodoView::setTodoModified( Todo* todo ) |
1444 | { | 1448 | { |
1445 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1449 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1446 | } | 1450 | } |
1447 | void KOTodoView::clearSelection() | 1451 | void KOTodoView::clearSelection() |
1448 | { | 1452 | { |
1449 | mTodoListView->selectAll( false ); | 1453 | mTodoListView->selectAll( false ); |
1450 | } | 1454 | } |
1451 | void KOTodoView::setAllOpen() | 1455 | void KOTodoView::setAllOpen() |
1452 | { | 1456 | { |
1453 | if ( isFlatDisplay ) { | 1457 | if ( isFlatDisplay ) { |
1454 | isFlatDisplay = false; | 1458 | isFlatDisplay = false; |
1455 | mPopupMenu->setItemChecked( 8,false ); | 1459 | mPopupMenu->setItemChecked( 8,false ); |
1456 | updateView(); | 1460 | updateView(); |
1457 | } else { | 1461 | } else { |
1458 | storeCurrentItem(); | 1462 | storeCurrentItem(); |
1459 | } | 1463 | } |
1460 | setOpen(mTodoListView->firstChild(), true); | 1464 | setOpen(mTodoListView->firstChild(), true); |
1461 | resetCurrentItem(); | 1465 | resetCurrentItem(); |
1462 | } | 1466 | } |
1463 | void KOTodoView::setAllClose() | 1467 | void KOTodoView::setAllClose() |
1464 | { | 1468 | { |
1465 | if ( isFlatDisplay ) { | 1469 | if ( isFlatDisplay ) { |
1466 | isFlatDisplay = false; | 1470 | isFlatDisplay = false; |
1467 | mPopupMenu->setItemChecked( 8,false ); | 1471 | mPopupMenu->setItemChecked( 8,false ); |
1468 | updateView(); | 1472 | updateView(); |
1469 | } else { | 1473 | } else { |
1470 | storeCurrentItem(); | 1474 | storeCurrentItem(); |
1471 | } | 1475 | } |
1472 | setOpen(mTodoListView->firstChild(), false); | 1476 | setOpen(mTodoListView->firstChild(), false); |
1473 | resetCurrentItem(); | 1477 | resetCurrentItem(); |
1474 | } | 1478 | } |
1475 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1479 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1476 | { | 1480 | { |
1477 | 1481 | ||
1478 | while ( item ) { | 1482 | while ( item ) { |
1479 | setOpen( item->firstChild(), setOpenI ); | 1483 | setOpen( item->firstChild(), setOpenI ); |
1480 | item->setOpen( setOpenI ); | 1484 | item->setOpen( setOpenI ); |
1481 | item = item->nextSibling(); | 1485 | item = item->nextSibling(); |
1482 | } | 1486 | } |
1483 | } | 1487 | } |
1484 | 1488 | ||
1485 | void KOTodoView::displayAllFlat() | 1489 | void KOTodoView::displayAllFlat() |
1486 | { | 1490 | { |
1487 | storeCurrentItem(); | 1491 | storeCurrentItem(); |
1488 | pendingSubtodo = 0; | 1492 | pendingSubtodo = 0; |
1489 | if ( mBlockUpdate ) { | 1493 | if ( mBlockUpdate ) { |
1490 | return; | 1494 | return; |
1491 | } | 1495 | } |
1492 | mPopupMenu->setItemChecked( 8,true ); | 1496 | mPopupMenu->setItemChecked( 8,true ); |
1493 | isFlatDisplay = true; | 1497 | isFlatDisplay = true; |
1494 | QPtrList<Todo> todoList = calendar()->todos(); | 1498 | QPtrList<Todo> todoList = calendar()->todos(); |
1495 | mTodoMap.clear(); | 1499 | mTodoMap.clear(); |
1496 | mTodoListView->clear(); | 1500 | mTodoListView->clear(); |
1497 | Todo *todo; | 1501 | Todo *todo; |
1498 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1502 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1499 | if ( checkTodo( todo ) ) { | 1503 | if ( checkTodo( todo ) ) { |
1500 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1504 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1501 | mTodoMap.insert(todo,todoItem); | 1505 | mTodoMap.insert(todo,todoItem); |
1502 | } | 1506 | } |
1503 | } | 1507 | } |
1504 | resetCurrentItem(); | 1508 | resetCurrentItem(); |
1505 | } | 1509 | } |
1506 | 1510 | ||
1507 | void KOTodoView::setAllFlat() | 1511 | void KOTodoView::setAllFlat() |
1508 | { | 1512 | { |
1509 | if ( isFlatDisplay ) { | 1513 | if ( isFlatDisplay ) { |
1510 | isFlatDisplay = false; | 1514 | isFlatDisplay = false; |
1511 | mPopupMenu->setItemChecked( 8,false ); | 1515 | mPopupMenu->setItemChecked( 8,false ); |
1512 | updateView(); | 1516 | updateView(); |
1513 | return; | 1517 | return; |
1514 | } | 1518 | } |
1515 | displayAllFlat(); | 1519 | displayAllFlat(); |
1516 | } | 1520 | } |
1517 | 1521 | ||
1518 | void KOTodoView::purgeCompleted() | 1522 | void KOTodoView::purgeCompleted() |
1519 | { | 1523 | { |
1520 | emit purgeCompletedSignal(); | 1524 | emit purgeCompletedSignal(); |
1521 | 1525 | ||
1522 | } | 1526 | } |
1523 | void KOTodoView::toggleQuickTodo() | 1527 | void KOTodoView::toggleQuickTodo() |
1524 | { | 1528 | { |
1525 | if ( mQuickBar->isVisible() ) { | 1529 | if ( mQuickBar->isVisible() ) { |
1526 | mQuickBar->hide(); | 1530 | mQuickBar->hide(); |
1527 | KOPrefs::instance()->mEnableQuickTodo = false; | 1531 | KOPrefs::instance()->mEnableQuickTodo = false; |
1528 | } | 1532 | } |
1529 | else { | 1533 | else { |
1530 | mQuickBar->show(); | 1534 | mQuickBar->show(); |
1531 | KOPrefs::instance()->mEnableQuickTodo = true; | 1535 | KOPrefs::instance()->mEnableQuickTodo = true; |
1532 | } | 1536 | } |
1533 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1537 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1534 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1538 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1535 | } | 1539 | } |
1536 | 1540 | ||
1537 | void KOTodoView::toggleRunning() | 1541 | void KOTodoView::toggleRunning() |
1538 | { | 1542 | { |
1539 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1543 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1540 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1544 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1541 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1545 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1542 | updateView(); | 1546 | updateView(); |
1543 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 1547 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
1544 | topLevelWidget()->setCaption(i18n("Hide not Running")); | 1548 | topLevelWidget()->setCaption(i18n("Hide not Running")); |
1545 | else | 1549 | else |
1546 | topLevelWidget()->setCaption(i18n("Show not Running")); | 1550 | topLevelWidget()->setCaption(i18n("Show not Running")); |
1547 | } | 1551 | } |
1548 | 1552 | ||
1549 | void KOTodoView::toggleCompleted() | 1553 | void KOTodoView::toggleCompleted() |
1550 | { | 1554 | { |
1551 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1555 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1552 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1556 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1553 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1557 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1554 | updateView(); | 1558 | updateView(); |
1555 | if ( KOPrefs::instance()->mShowCompletedTodo ) | 1559 | if ( KOPrefs::instance()->mShowCompletedTodo ) |
1556 | topLevelWidget()->setCaption(i18n("Show Completed")); | 1560 | topLevelWidget()->setCaption(i18n("Show Completed")); |
1557 | else | 1561 | else |
1558 | topLevelWidget()->setCaption(i18n("Hide Completed")); | 1562 | topLevelWidget()->setCaption(i18n("Hide Completed")); |
1559 | } | 1563 | } |
1560 | 1564 | ||
1561 | void KOTodoView::addQuickTodo() | 1565 | void KOTodoView::addQuickTodo() |
1562 | { | 1566 | { |
1563 | addQuickTodoPar( 0 ); | 1567 | addQuickTodoPar( 0 ); |
1564 | } | 1568 | } |
1565 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) | 1569 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) |
1566 | { | 1570 | { |
1567 | Todo *todo = new Todo(); | 1571 | Todo *todo = new Todo(); |
1568 | todo->setSummary(mQuickAdd->text()); | 1572 | todo->setSummary(mQuickAdd->text()); |
1569 | todo->setOrganizer(KOPrefs::instance()->email()); | 1573 | todo->setOrganizer(KOPrefs::instance()->email()); |
1570 | if ( parentTodo ) { | 1574 | if ( parentTodo ) { |
1571 | todo->setRelatedTo(parentTodo); | 1575 | todo->setRelatedTo(parentTodo); |
1572 | 1576 | ||
1573 | todo->setCategories (parentTodo->categoriesStr ()); | 1577 | todo->setCategories (parentTodo->categoriesStr ()); |
1574 | todo->setSecrecy (parentTodo->secrecy ()); | 1578 | todo->setSecrecy (parentTodo->secrecy ()); |
1575 | if ( parentTodo->priority() < 3 ) | 1579 | if ( parentTodo->priority() < 3 ) |
1576 | todo->setPriority( parentTodo->priority() ); | 1580 | todo->setPriority( parentTodo->priority() ); |
1577 | todo->setCalID( parentTodo->calID() ); | 1581 | todo->setCalID( parentTodo->calID() ); |
1578 | } else { | 1582 | } else { |
1579 | CalFilter * cf = mCalendar->filter(); | 1583 | CalFilter * cf = mCalendar->filter(); |
1580 | if ( cf ) { | 1584 | if ( cf ) { |
1581 | if ( cf->isEnabled()&& cf->showCategories()) { | 1585 | if ( cf->isEnabled()&& cf->showCategories()) { |
1582 | todo->setCategories(cf->categoryList()); | 1586 | todo->setCategories(cf->categoryList()); |
1583 | } | 1587 | } |
1584 | if ( cf->isEnabled() ) | 1588 | if ( cf->isEnabled() ) |
1585 | todo->setSecrecy( cf->getSecrecy()); | 1589 | todo->setSecrecy( cf->getSecrecy()); |
1586 | } | 1590 | } |
1587 | } | 1591 | } |
1588 | mCalendar->addTodo(todo); | 1592 | mCalendar->addTodo(todo); |
1589 | mQuickAdd->setText(""); | 1593 | mQuickAdd->setText(""); |
1590 | todoModified (todo, KOGlobals::EVENTADDED ); | 1594 | todoModified (todo, KOGlobals::EVENTADDED ); |
1591 | updateView(); | 1595 | updateView(); |
1592 | 1596 | ||
1593 | } | 1597 | } |
1594 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1598 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1595 | { | 1599 | { |
1596 | // e->ignore(); | 1600 | // e->ignore(); |
1597 | //return; | 1601 | //return; |
1598 | //qDebug("KOTodoView::keyPressEvent "); | 1602 | //qDebug("KOTodoView::keyPressEvent "); |
1599 | switch ( e->key() ) { | 1603 | switch ( e->key() ) { |
1600 | case Qt::Key_Down: | 1604 | case Qt::Key_Down: |
1601 | case Qt::Key_Up: | 1605 | case Qt::Key_Up: |
1602 | QWidget::keyPressEvent ( e ); | 1606 | QWidget::keyPressEvent ( e ); |
1603 | break; | 1607 | break; |
1604 | 1608 | ||
1605 | case Qt::Key_Q: | 1609 | case Qt::Key_Q: |
1606 | toggleQuickTodo(); | 1610 | toggleQuickTodo(); |
1607 | break; | 1611 | break; |
1608 | case Qt::Key_U: | 1612 | case Qt::Key_U: |
1609 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1613 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1610 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1614 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1611 | unparentTodo(); | 1615 | unparentTodo(); |
1612 | e->accept(); | 1616 | e->accept(); |
1613 | } else | 1617 | } else |
1614 | e->ignore(); | 1618 | e->ignore(); |
1615 | break; | 1619 | break; |
1616 | case Qt::Key_S: | 1620 | case Qt::Key_S: |
1617 | if ( e->state() == Qt::ControlButton ) { | 1621 | if ( e->state() == Qt::ControlButton ) { |
1618 | e->ignore(); | 1622 | e->ignore(); |
1619 | break; | 1623 | break; |
1620 | } | 1624 | } |
1621 | if ( e->state() == Qt::ShiftButton ) { | 1625 | if ( e->state() == Qt::ShiftButton ) { |
1622 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1626 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1623 | reparentTodo(); | 1627 | reparentTodo(); |
1624 | e->accept(); | 1628 | e->accept(); |
1625 | } else | 1629 | } else |
1626 | e->ignore(); | 1630 | e->ignore(); |
1627 | break; | 1631 | break; |
1628 | case Qt::Key_P: | 1632 | case Qt::Key_P: |
1629 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1633 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1630 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1634 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1631 | if ( pendingSubtodo ) | 1635 | if ( pendingSubtodo ) |
1632 | itemClicked(mActiveItem); | 1636 | itemClicked(mActiveItem); |
1633 | e->accept(); | 1637 | e->accept(); |
1634 | } else | 1638 | } else |
1635 | e->ignore(); | 1639 | e->ignore(); |
1636 | break; | 1640 | break; |
1637 | case Qt::Key_Escape: | 1641 | case Qt::Key_Escape: |
1638 | if ( pendingSubtodo ) { | 1642 | if ( pendingSubtodo ) { |
1639 | itemClicked(0); | 1643 | itemClicked(0); |
1640 | e->accept(); | 1644 | e->accept(); |
1641 | } else | 1645 | } else |
1642 | e->ignore(); | 1646 | e->ignore(); |
1643 | break; | 1647 | break; |
1644 | default: | 1648 | default: |
1645 | e->ignore(); | 1649 | e->ignore(); |
1646 | } | 1650 | } |
1647 | 1651 | ||
1648 | if ( true ) { | 1652 | if ( true ) { |
1649 | if ( e->key() == Qt::Key_I ) { | 1653 | if ( e->key() == Qt::Key_I ) { |
1650 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1654 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1651 | if ( cn ) { | 1655 | if ( cn ) { |
1652 | mActiveItem = cn; | 1656 | mActiveItem = cn; |
1653 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1657 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1654 | if ( ci ){ | 1658 | if ( ci ){ |
1655 | showTodo(); | 1659 | showTodo(); |
1656 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1660 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1657 | if ( cn ) { | 1661 | if ( cn ) { |
1658 | mTodoListView->setCurrentItem ( cn ); | 1662 | mTodoListView->setCurrentItem ( cn ); |
1659 | mTodoListView->ensureItemVisible ( cn ); | 1663 | mTodoListView->ensureItemVisible ( cn ); |
1660 | } | 1664 | } |
1661 | 1665 | ||
1662 | } | 1666 | } |
1663 | } | 1667 | } |
1664 | e->accept(); | 1668 | e->accept(); |
1665 | 1669 | ||
1666 | } | 1670 | } |
1667 | 1671 | ||
1668 | } | 1672 | } |
1669 | 1673 | ||
1670 | } | 1674 | } |
1671 | void KOTodoView::updateTodo( Todo * t, int type ) | 1675 | void KOTodoView::updateTodo( Todo * t, int type ) |
1672 | { | 1676 | { |
1673 | if ( mBlockUpdate) | 1677 | if ( mBlockUpdate) |
1674 | return; | 1678 | return; |
1675 | 1679 | ||
1676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1680 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1677 | itemIterator = mTodoMap.find(t); | 1681 | itemIterator = mTodoMap.find(t); |
1678 | if (itemIterator != mTodoMap.end()) { | 1682 | if (itemIterator != mTodoMap.end()) { |
1679 | (*itemIterator)->construct(); | 1683 | (*itemIterator)->construct(); |
1680 | } else { | 1684 | } else { |
1681 | if ( type == KOGlobals::EVENTADDED ) { | 1685 | if ( type == KOGlobals::EVENTADDED ) { |
1682 | insertTodoItem( t ); | 1686 | insertTodoItem( t ); |
1683 | } | 1687 | } |
1684 | } | 1688 | } |
1685 | 1689 | ||
1686 | } | 1690 | } |
1687 | 1691 | ||
1688 | void KOTodoView::todoModified(Todo * t , int p ) | 1692 | void KOTodoView::todoModified(Todo * t , int p ) |
1689 | { | 1693 | { |
1690 | mBlockUpdate = true; | 1694 | mBlockUpdate = true; |
1691 | emit todoModifiedSignal ( t, p ); | 1695 | emit todoModifiedSignal ( t, p ); |
1692 | mBlockUpdate = false; | 1696 | mBlockUpdate = false; |
1693 | } | 1697 | } |