-rw-r--r-- | korganizer/kotodoview.cpp | 26 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 |
2 files changed, 17 insertions, 10 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 8d354c8..e2966f8 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1591 +1,1597 @@ | |||
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 a 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 a 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 a 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 | mQuickAdd = new KOQuickTodo(this); | 507 | mQuickAdd = new KOQuickTodo(this); |
508 | topLayout->addWidget(mQuickAdd); | 508 | topLayout->addWidget(mQuickAdd); |
509 | 509 | ||
510 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 510 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
511 | 511 | ||
512 | mTodoListView = new KOTodoListView(calendar,this, name ); | 512 | mTodoListView = new KOTodoListView(calendar,this, name ); |
513 | topLayout->addWidget(mTodoListView); | 513 | topLayout->addWidget(mTodoListView); |
514 | //mTodoListView->header()->setMaximumHeight(30); | 514 | //mTodoListView->header()->setMaximumHeight(30); |
515 | mTodoListView->setRootIsDecorated(true); | 515 | mTodoListView->setRootIsDecorated(true); |
516 | mTodoListView->setAllColumnsShowFocus(true); | 516 | mTodoListView->setAllColumnsShowFocus(true); |
517 | 517 | ||
518 | mTodoListView->setShowSortIndicator(true); | 518 | mTodoListView->setShowSortIndicator(true); |
519 | 519 | ||
520 | mTodoListView->addColumn(i18n("Todo")); | 520 | mTodoListView->addColumn(i18n("Todo")); |
521 | mTodoListView->addColumn(i18n("Prio")); | 521 | mTodoListView->addColumn(i18n("Prio")); |
522 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 522 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
523 | mTodoListView->addColumn(i18n("Complete")); | 523 | mTodoListView->addColumn(i18n("Complete")); |
524 | mTodoListView->setColumnAlignment(2,AlignCenter); | 524 | mTodoListView->setColumnAlignment(2,AlignCenter); |
525 | 525 | ||
526 | mTodoListView->addColumn(i18n("Due Date")); | 526 | mTodoListView->addColumn(i18n("Due Date")); |
527 | mTodoListView->setColumnAlignment(3,AlignLeft); | 527 | mTodoListView->setColumnAlignment(3,AlignLeft); |
528 | mTodoListView->addColumn(i18n("Due Time")); | 528 | mTodoListView->addColumn(i18n("Due Time")); |
529 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 529 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
530 | 530 | ||
531 | mTodoListView->addColumn(i18n("Start Date")); | 531 | mTodoListView->addColumn(i18n("Start Date")); |
532 | mTodoListView->setColumnAlignment(5,AlignLeft); | 532 | mTodoListView->setColumnAlignment(5,AlignLeft); |
533 | mTodoListView->addColumn(i18n("Start Time")); | 533 | mTodoListView->addColumn(i18n("Start Time")); |
534 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 534 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
535 | 535 | ||
536 | mTodoListView->addColumn(i18n("Cancelled")); | 536 | mTodoListView->addColumn(i18n("Cancelled")); |
537 | mTodoListView->addColumn(i18n("Categories")); | 537 | mTodoListView->addColumn(i18n("Categories")); |
538 | mTodoListView->addColumn(i18n("Calendar")); | 538 | mTodoListView->addColumn(i18n("Calendar")); |
539 | #if 0 | 539 | #if 0 |
540 | mTodoListView->addColumn(i18n("Sort Id")); | 540 | mTodoListView->addColumn(i18n("Sort Id")); |
541 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 541 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
542 | #endif | 542 | #endif |
543 | 543 | ||
544 | mTodoListView->setMinimumHeight( 60 ); | 544 | mTodoListView->setMinimumHeight( 60 ); |
545 | mTodoListView->setItemsRenameable( true ); | 545 | mTodoListView->setItemsRenameable( true ); |
546 | mTodoListView->setRenameable( 0 ); | 546 | mTodoListView->setRenameable( 0 ); |
547 | mTodoListView->setColumnWidth( 0, 120 ); | 547 | mTodoListView->setColumnWidth( 0, 120 ); |
548 | int iii = 0; | 548 | int iii = 0; |
549 | for ( iii = 0; iii< 10 ; ++iii ) | 549 | for ( iii = 0; iii< 10 ; ++iii ) |
550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 550 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
551 | 551 | ||
552 | 552 | ||
553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 553 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
554 | 554 | ||
555 | mPriorityPopupMenu = new QPopupMenu(this); | 555 | mPriorityPopupMenu = new QPopupMenu(this); |
556 | for (int i = 1; i <= 5; i++) { | 556 | for (int i = 1; i <= 5; i++) { |
557 | QString label = QString ("%1").arg (i); | 557 | QString label = QString ("%1").arg (i); |
558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 558 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
559 | } | 559 | } |
560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 560 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
561 | 561 | ||
562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 562 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
563 | for (int i = 0; i <= 100; i+=20) { | 563 | for (int i = 0; i <= 100; i+=20) { |
564 | QString label = QString ("%1 %").arg (i); | 564 | QString label = QString ("%1 %").arg (i); |
565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 565 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
566 | } | 566 | } |
567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 567 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
568 | 568 | ||
569 | 569 | ||
570 | 570 | ||
571 | mItemPopupMenu = new QPopupMenu(this); | 571 | mItemPopupMenu = new QPopupMenu(this); |
572 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 572 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
573 | SLOT (showTodo())); | 573 | SLOT (showTodo())); |
574 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 574 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
575 | SLOT (editTodo())); | 575 | SLOT (editTodo())); |
576 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 576 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
577 | SLOT (deleteTodo())); | 577 | SLOT (deleteTodo())); |
578 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 578 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
579 | SLOT (cloneTodo())); | 579 | SLOT (cloneTodo())); |
580 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 580 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
581 | SLOT (moveTodo())); | 581 | SLOT (moveTodo())); |
582 | #ifndef DESKTOP_VERSION | 582 | #ifndef DESKTOP_VERSION |
583 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 583 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
584 | SLOT (beamTodo())); | 584 | SLOT (beamTodo())); |
585 | #endif | 585 | #endif |
586 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 586 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
587 | SLOT (cancelTodo())); | 587 | SLOT (cancelTodo())); |
588 | mItemPopupMenu->insertSeparator(); | 588 | mItemPopupMenu->insertSeparator(); |
589 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 589 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
590 | SLOT (toggleRunningItem())); | 590 | SLOT (toggleRunningItem())); |
591 | mItemPopupMenu->insertSeparator(); | 591 | mItemPopupMenu->insertSeparator(); |
592 | /* | 592 | /* |
593 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 593 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
594 | SLOT (newTodo())); | 594 | SLOT (newTodo())); |
595 | */ | 595 | */ |
596 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 596 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
597 | SLOT (newSubTodo())); | 597 | SLOT (newSubTodo())); |
598 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 598 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
599 | SLOT (unparentTodo()),0,21); | 599 | SLOT (unparentTodo()),0,21); |
600 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 600 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
601 | SLOT (reparentTodo()),0,22); | 601 | SLOT (reparentTodo()),0,22); |
602 | mItemPopupMenu->insertSeparator(); | 602 | mItemPopupMenu->insertSeparator(); |
603 | #if 0 | 603 | #if 0 |
604 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 604 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
605 | this, SLOT( purgeCompleted() ) ); | 605 | this, SLOT( purgeCompleted() ) ); |
606 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 606 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
607 | this, SLOT( toggleCompleted() ),0, 33 ); | 607 | this, SLOT( toggleCompleted() ),0, 33 ); |
608 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 608 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
609 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 609 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
610 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 610 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
611 | this, SLOT( toggleRunning() ),0, 35 ); | 611 | this, SLOT( toggleRunning() ),0, 35 ); |
612 | 612 | ||
613 | #endif | 613 | #endif |
614 | mPopupMenu = new QPopupMenu(this); | 614 | mPopupMenu = new QPopupMenu(this); |
615 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 615 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
616 | SLOT (newTodo()),0,1); | 616 | SLOT (newTodo()),0,1); |
617 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 617 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
618 | this, SLOT(purgeCompleted()),0,2); | 618 | this, SLOT(purgeCompleted()),0,2); |
619 | mPopupMenu->insertItem(i18n("Show Completed"), | 619 | mPopupMenu->insertItem(i18n("Show Completed"), |
620 | this, SLOT( toggleCompleted() ),0,3 ); | 620 | this, SLOT( toggleCompleted() ),0,3 ); |
621 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 621 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
622 | this, SLOT( toggleRunning() ),0,5 ); | 622 | this, SLOT( toggleRunning() ),0,5 ); |
623 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 623 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
624 | this, SLOT( setAllOpen() ),0,6 ); | 624 | this, SLOT( setAllOpen() ),0,6 ); |
625 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 625 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
626 | this, SLOT( setAllClose() ),0,7 ); | 626 | this, SLOT( setAllClose() ),0,7 ); |
627 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 627 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
628 | this, SLOT( setAllFlat() ),0,8 ); | 628 | this, SLOT( setAllFlat() ),0,8 ); |
629 | mPopupMenu->insertSeparator(); | 629 | mPopupMenu->insertSeparator(); |
630 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 630 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
631 | this, SLOT( toggleQuickTodo() ),0,4 ); | 631 | this, SLOT( toggleQuickTodo() ),0,4 ); |
632 | mDocPrefs = new DocPrefs( name ); | 632 | mDocPrefs = new DocPrefs( name ); |
633 | 633 | ||
634 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 634 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
635 | mPopupMenu->setCheckable( true ); | 635 | mPopupMenu->setCheckable( true ); |
636 | mItemPopupMenu->setCheckable( true ); | 636 | mItemPopupMenu->setCheckable( true ); |
637 | 637 | ||
638 | 638 | ||
639 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 639 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
640 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 640 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
641 | 641 | ||
642 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 642 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
643 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 643 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
644 | 644 | ||
645 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 645 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
646 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 646 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
647 | 647 | ||
648 | 648 | ||
649 | // Double clicking conflicts with opening/closing the subtree | 649 | // Double clicking conflicts with opening/closing the subtree |
650 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 650 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
651 | SLOT( editItem( QListViewItem *) ) ); | 651 | SLOT( editItem( QListViewItem *) ) ); |
652 | /* | 652 | /* |
653 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 653 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
654 | const QPoint &,int ) ), | 654 | const QPoint &,int ) ), |
655 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 655 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
656 | */ | 656 | */ |
657 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 657 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
658 | const QPoint &,int ) ), | 658 | const QPoint &,int ) ), |
659 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 659 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
660 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 660 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
661 | SLOT( itemClicked( QListViewItem * ) ) ); | 661 | SLOT( itemClicked( QListViewItem * ) ) ); |
662 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 662 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
663 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 663 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
664 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 664 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
665 | SLOT( updateView() ) ); | 665 | SLOT( updateView() ) ); |
666 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 666 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
667 | SLOT( todoModified(Todo *, int) ) ); | 667 | SLOT( todoModified(Todo *, int) ) ); |
668 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 668 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
669 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 669 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
670 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 670 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
671 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 671 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
672 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 672 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
673 | SLOT( paintNeeded()) ); | 673 | SLOT( paintNeeded()) ); |
674 | 674 | ||
675 | #if 0 | 675 | #if 0 |
676 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 676 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
677 | SLOT(selectionChanged(QListViewItem *))); | 677 | SLOT(selectionChanged(QListViewItem *))); |
678 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 678 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
679 | SLOT(selectionChanged(QListViewItem *))); | 679 | SLOT(selectionChanged(QListViewItem *))); |
680 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 680 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
681 | SLOT(selectionChanged(QListViewItem *))); | 681 | SLOT(selectionChanged(QListViewItem *))); |
682 | #endif | 682 | #endif |
683 | 683 | ||
684 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 684 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
685 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 685 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
686 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 686 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
687 | 687 | ||
688 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 688 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
689 | SLOT( processSelectionChange() ) ); | 689 | SLOT( processSelectionChange() ) ); |
690 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 690 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
691 | SLOT( addQuickTodo() ) ); | 691 | SLOT( addQuickTodo() ) ); |
692 | 692 | ||
693 | } | 693 | } |
694 | 694 | ||
695 | KOTodoView::~KOTodoView() | 695 | KOTodoView::~KOTodoView() |
696 | { | 696 | { |
697 | 697 | ||
698 | #if QT_VERSION >= 0x030000 | 698 | #if QT_VERSION >= 0x030000 |
699 | 699 | ||
700 | #else | 700 | #else |
701 | delete mKOTodoViewWhatsThis; | 701 | delete mKOTodoViewWhatsThis; |
702 | #endif | 702 | #endif |
703 | 703 | ||
704 | delete mDocPrefs; | 704 | delete mDocPrefs; |
705 | } | 705 | } |
706 | QString KOTodoView::getWhatsThisText(QPoint p) | 706 | QString KOTodoView::getWhatsThisText(QPoint p) |
707 | { | 707 | { |
708 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 708 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
709 | if ( item ) | 709 | if ( item ) |
710 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 710 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
711 | KOPrefs::instance()->mWTshowDetails, | 711 | KOPrefs::instance()->mWTshowDetails, |
712 | KOPrefs::instance()->mWTshowCreated, | 712 | KOPrefs::instance()->mWTshowCreated, |
713 | KOPrefs::instance()->mWTshowChanged); | 713 | KOPrefs::instance()->mWTshowChanged); |
714 | return i18n("That is the todo view" ); | 714 | return i18n("That is the todo view" ); |
715 | 715 | ||
716 | } | 716 | } |
717 | 717 | ||
718 | void KOTodoView::jumpToDate () | 718 | void KOTodoView::jumpToDate () |
719 | { | 719 | { |
720 | // if (mActiveItem) { | 720 | // if (mActiveItem) { |
721 | // mActiveItem->todo()); | 721 | // mActiveItem->todo()); |
722 | // if ( mActiveItem->todo()->hasDueDate() ) | 722 | // if ( mActiveItem->todo()->hasDueDate() ) |
723 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 723 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
724 | } | 724 | } |
725 | void KOTodoView::paintNeeded() | 725 | void KOTodoView::paintNeeded() |
726 | { | 726 | { |
727 | if ( mPendingUpdateBeforeRepaint ) { | 727 | if ( mPendingUpdateBeforeRepaint ) { |
728 | updateView(); | 728 | updateView(); |
729 | mPendingUpdateBeforeRepaint = false; | 729 | mPendingUpdateBeforeRepaint = false; |
730 | } | 730 | } |
731 | } | 731 | } |
732 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 732 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
733 | { | 733 | { |
734 | if ( mPendingUpdateBeforeRepaint ) { | 734 | if ( mPendingUpdateBeforeRepaint ) { |
735 | updateView(); | 735 | updateView(); |
736 | mPendingUpdateBeforeRepaint = false; | 736 | mPendingUpdateBeforeRepaint = false; |
737 | } | 737 | } |
738 | KOrg::BaseView::paintEvent( pevent); | 738 | KOrg::BaseView::paintEvent( pevent); |
739 | } | 739 | } |
740 | 740 | ||
741 | void KOTodoView::updateView() | 741 | void KOTodoView::updateView() |
742 | { | 742 | { |
743 | pendingSubtodo = 0; | 743 | pendingSubtodo = 0; |
744 | if ( mBlockUpdate ) { | 744 | if ( mBlockUpdate ) { |
745 | return; | 745 | return; |
746 | } | 746 | } |
747 | if ( !isVisible() ) { | 747 | if ( !isVisible() ) { |
748 | mPendingUpdateBeforeRepaint = true; | 748 | mPendingUpdateBeforeRepaint = true; |
749 | return; | 749 | return; |
750 | } | 750 | } |
751 | storeCurrentItem(); | ||
752 | //qDebug("KOTodoView::updateView() %x", this); | 751 | //qDebug("KOTodoView::updateView() %x", this); |
753 | if ( isFlatDisplay ) { | 752 | if ( isFlatDisplay ) { |
754 | displayAllFlat(); | 753 | displayAllFlat(); |
755 | resetCurrentItem(); | ||
756 | return; | 754 | return; |
757 | } | 755 | } |
756 | storeCurrentItem(); | ||
758 | //qDebug("update "); | 757 | //qDebug("update "); |
759 | // kdDebug() << "KOTodoView::updateView()" << endl; | 758 | // kdDebug() << "KOTodoView::updateView()" << endl; |
760 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 759 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
761 | 760 | ||
762 | 761 | ||
763 | mTodoListView->clear(); | 762 | mTodoListView->clear(); |
764 | if ( mName == "todolistsmall" ) { | 763 | if ( mName == "todolistsmall" ) { |
765 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 764 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
766 | int ps = fo.pointSize() -2; | 765 | int ps = fo.pointSize() -2; |
767 | if ( ps > 12 ) | 766 | if ( ps > 12 ) |
768 | ps -= 2; | 767 | ps -= 2; |
769 | fo.setPointSize( ps ); | 768 | fo.setPointSize( ps ); |
770 | } | 769 | } |
771 | } | 770 | } |
772 | 771 | ||
773 | mTodoListView->setFont( fo ); | 772 | mTodoListView->setFont( fo ); |
774 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 773 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
775 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 774 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
776 | QPtrList<Todo> todoList = calendar()->todos(); | 775 | QPtrList<Todo> todoList = calendar()->todos(); |
777 | 776 | ||
778 | /* | 777 | /* |
779 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 778 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
780 | Event *t; | 779 | Event *t; |
781 | for(t = todoList.first(); t; t = todoList.next()) { | 780 | for(t = todoList.first(); t; t = todoList.next()) { |
782 | kdDebug() << " " << t->getSummary() << endl; | 781 | kdDebug() << " " << t->getSummary() << endl; |
783 | 782 | ||
784 | if (t->getRelatedTo()) { | 783 | if (t->getRelatedTo()) { |
785 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 784 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
786 | } | 785 | } |
787 | 786 | ||
788 | QPtrList<Event> l = t->getRelations(); | 787 | QPtrList<Event> l = t->getRelations(); |
789 | Event *c; | 788 | Event *c; |
790 | for(c=l.first();c;c=l.next()) { | 789 | for(c=l.first();c;c=l.next()) { |
791 | kdDebug() << " - relation: " << c->getSummary() << endl; | 790 | kdDebug() << " - relation: " << c->getSummary() << endl; |
792 | } | 791 | } |
793 | } | 792 | } |
794 | */ | 793 | */ |
795 | 794 | ||
796 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 795 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
797 | // specific order of events. That means that we have to generate parent items | 796 | // specific order of events. That means that we have to generate parent items |
798 | // recursively for proper hierarchical display of Todos. | 797 | // recursively for proper hierarchical display of Todos. |
799 | mTodoMap.clear(); | 798 | mTodoMap.clear(); |
800 | Todo *todo; | 799 | Todo *todo; |
801 | todo = todoList.first();// todo; todo = todoList.next()) { | 800 | todo = todoList.first();// todo; todo = todoList.next()) { |
802 | while ( todo ) { | 801 | while ( todo ) { |
803 | bool next = true; | 802 | bool next = true; |
804 | // qDebug("todo %s ", todo->summary().latin1()); | 803 | // qDebug("todo %s ", todo->summary().latin1()); |
805 | Incidence *incidence = todo->relatedTo(); | 804 | Incidence *incidence = todo->relatedTo(); |
806 | while ( incidence ) { | 805 | while ( incidence ) { |
807 | if ( incidence->typeID() == todoID ) { | 806 | if ( incidence->typeID() == todoID ) { |
808 | //qDebug("related %s ",incidence->summary().latin1() ); | 807 | //qDebug("related %s ",incidence->summary().latin1() ); |
809 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 808 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
810 | //qDebug("related not found "); | 809 | //qDebug("related not found "); |
811 | todoList.remove( ); | 810 | todoList.remove( ); |
812 | todo = todoList.current(); | 811 | todo = todoList.current(); |
813 | next = false; | 812 | next = false; |
814 | incidence = 0; | 813 | incidence = 0; |
815 | 814 | ||
816 | } else { | 815 | } else { |
817 | //qDebug("related found "); | 816 | //qDebug("related found "); |
818 | incidence = incidence->relatedTo(); | 817 | incidence = incidence->relatedTo(); |
819 | } | 818 | } |
820 | } else | 819 | } else |
821 | incidence = 0; | 820 | incidence = 0; |
822 | } | 821 | } |
823 | if ( next ) | 822 | if ( next ) |
824 | todo = todoList.next(); | 823 | todo = todoList.next(); |
825 | } | 824 | } |
826 | 825 | ||
827 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 826 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
828 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 827 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
829 | { | 828 | { |
830 | insertTodoItem(todo); | 829 | insertTodoItem(todo); |
831 | } | 830 | } |
832 | } | 831 | } |
833 | // Restore opened/closed state | 832 | // Restore opened/closed state |
834 | mTodoListView->blockSignals( true ); | 833 | mTodoListView->blockSignals( true ); |
835 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 834 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
836 | mTodoListView->blockSignals( false ); | 835 | mTodoListView->blockSignals( false ); |
837 | resetCurrentItem(); | 836 | resetCurrentItem(); |
838 | processSelectionChange(); | ||
839 | } | 837 | } |
840 | 838 | ||
841 | void KOTodoView::storeCurrentItem() | 839 | void KOTodoView::storeCurrentItem() |
842 | { | 840 | { |
843 | mCurItem = 0; | 841 | mCurItem = 0; |
844 | mCurItemRootParent = 0; | 842 | mCurItemRootParent = 0; |
845 | mCurItemParent = 0; | 843 | mCurItemParent = 0; |
846 | mCurItemAbove = 0; | 844 | mCurItemAbove = 0; |
847 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 845 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
848 | if (mActiveItem) { | 846 | if (mActiveItem) { |
849 | mCurItem = mActiveItem->todo(); | 847 | mCurItem = mActiveItem->todo(); |
850 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 848 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
851 | if ( activeItemAbove ) | 849 | if ( activeItemAbove ) |
852 | mCurItemAbove = activeItemAbove->todo(); | 850 | mCurItemAbove = activeItemAbove->todo(); |
853 | mCurItemRootParent = mCurItem; | 851 | mCurItemRootParent = mCurItem; |
854 | mCurItemParent = mCurItemRootParent->relatedTo(); | 852 | mCurItemParent = mCurItemRootParent->relatedTo(); |
855 | while ( mCurItemRootParent->relatedTo() != 0 ) | 853 | while ( mCurItemRootParent->relatedTo() != 0 ) |
856 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 854 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
857 | } | 855 | } |
858 | mActiveItem = 0; | 856 | mActiveItem = 0; |
859 | } | 857 | } |
860 | 858 | ||
861 | void KOTodoView::resetCurrentItem() | 859 | void KOTodoView::resetCurrentItem() |
862 | { | 860 | { |
863 | mTodoListView->setFocus(); | 861 | //mTodoListView->setFocus(); |
864 | KOTodoViewItem* foundItem = 0; | 862 | KOTodoViewItem* foundItem = 0; |
865 | KOTodoViewItem* foundItemRoot = 0; | 863 | KOTodoViewItem* foundItemRoot = 0; |
866 | KOTodoViewItem* foundItemParent = 0; | 864 | KOTodoViewItem* foundItemParent = 0; |
867 | KOTodoViewItem* foundItemAbove = 0; | 865 | KOTodoViewItem* foundItemAbove = 0; |
868 | if ( mTodoListView->firstChild () ) { | 866 | if ( mTodoListView->firstChild () ) { |
869 | if ( mCurItem ) { | 867 | if ( mCurItem ) { |
870 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 868 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
871 | while ( item ) { | 869 | while ( item ) { |
872 | if ( item->todo() == mCurItem ) { | 870 | if ( item->todo() == mCurItem ) { |
873 | foundItem = item; | 871 | foundItem = item; |
874 | break; | 872 | break; |
875 | } else if ( item->todo() == mCurItemAbove ) { | 873 | } else if ( item->todo() == mCurItemAbove ) { |
876 | foundItemAbove = item; | 874 | foundItemAbove = item; |
877 | 875 | ||
878 | } | 876 | } |
879 | if ( item->todo() == mCurItemRootParent ) { | 877 | if ( item->todo() == mCurItemRootParent ) { |
880 | foundItemRoot = item; | 878 | foundItemRoot = item; |
881 | } | 879 | } |
882 | if ( item->todo() == mCurItemParent ) { | 880 | if ( item->todo() == mCurItemParent ) { |
883 | foundItemParent = item; | 881 | foundItemParent = item; |
884 | } | 882 | } |
885 | item = (KOTodoViewItem*)item->itemBelow(); | 883 | item = (KOTodoViewItem*)item->itemBelow(); |
886 | } | 884 | } |
887 | if ( ! foundItem ) { | 885 | if ( ! foundItem ) { |
888 | if ( foundItemParent ) { | 886 | if ( foundItemParent ) { |
889 | foundItem = foundItemParent; | 887 | foundItem = foundItemParent; |
890 | } else { | 888 | } else { |
891 | if ( foundItemRoot ) | 889 | if ( foundItemRoot ) |
892 | foundItem = foundItemRoot; | 890 | foundItem = foundItemRoot; |
893 | else | 891 | else |
894 | foundItem = foundItemAbove; | 892 | foundItem = foundItemAbove; |
895 | } | 893 | } |
896 | } | 894 | } |
897 | } | 895 | } |
898 | if ( foundItem ) { | 896 | if ( foundItem ) { |
897 | mTodoListView->setSelected ( foundItem, true ); | ||
899 | mTodoListView->setCurrentItem( foundItem ); | 898 | mTodoListView->setCurrentItem( foundItem ); |
900 | mTodoListView->ensureItemVisible( foundItem ); | 899 | mTodoListView->ensureItemVisible( foundItem ); |
901 | } else { | 900 | } else { |
902 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 901 | if ( mTodoListView->firstChild () ) { |
902 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | ||
903 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | ||
904 | } | ||
903 | } | 905 | } |
904 | } | 906 | } |
907 | processSelectionChange(); | ||
908 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | ||
909 | } | ||
910 | void KOTodoView::resetFocusToList() | ||
911 | { | ||
912 | topLevelWidget()->setActiveWindow(); | ||
905 | mTodoListView->setFocus(); | 913 | mTodoListView->setFocus(); |
906 | } | 914 | } |
907 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 915 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
908 | bool KOTodoView::checkTodo( Todo * todo ) | 916 | bool KOTodoView::checkTodo( Todo * todo ) |
909 | { | 917 | { |
910 | 918 | ||
911 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 919 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
912 | return false; | 920 | return false; |
913 | if ( !todo->isCompleted() ) { | 921 | if ( !todo->isCompleted() ) { |
914 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 922 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
915 | return true; | 923 | return true; |
916 | } | 924 | } |
917 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 925 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
918 | if ( todo->hasStartDate() ) | 926 | if ( todo->hasStartDate() ) |
919 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 927 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
920 | return false; | 928 | return false; |
921 | if ( todo->hasDueDate() ) | 929 | if ( todo->hasDueDate() ) |
922 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 930 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
923 | return false; | 931 | return false; |
924 | } | 932 | } |
925 | return true; | 933 | return true; |
926 | } | 934 | } |
927 | 935 | ||
928 | void KOTodoView::restoreItemState( QListViewItem *item ) | 936 | void KOTodoView::restoreItemState( QListViewItem *item ) |
929 | { | 937 | { |
930 | pendingSubtodo = 0; | 938 | pendingSubtodo = 0; |
931 | while( item ) { | 939 | while( item ) { |
932 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 940 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
933 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 941 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
934 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 942 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
935 | item = item->nextSibling(); | 943 | item = item->nextSibling(); |
936 | } | 944 | } |
937 | } | 945 | } |
938 | 946 | ||
939 | 947 | ||
940 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 948 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
941 | KOTodoView::insertTodoItem(Todo *todo) | 949 | KOTodoView::insertTodoItem(Todo *todo) |
942 | { | 950 | { |
943 | 951 | ||
944 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 952 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
945 | // TODO: Check, if dynmaic cast is necessary | 953 | // TODO: Check, if dynmaic cast is necessary |
946 | 954 | ||
947 | pendingSubtodo = 0; | 955 | pendingSubtodo = 0; |
948 | Incidence *incidence = todo->relatedTo(); | 956 | Incidence *incidence = todo->relatedTo(); |
949 | while ( incidence && !incidence->calEnabled() ) | 957 | while ( incidence && !incidence->calEnabled() ) |
950 | incidence = incidence->relatedTo(); | 958 | incidence = incidence->relatedTo(); |
951 | if (incidence && incidence->typeID() == todoID ) { | 959 | if (incidence && incidence->typeID() == todoID ) { |
952 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 960 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
953 | 961 | ||
954 | // kdDebug() << " has Related" << endl; | 962 | // kdDebug() << " has Related" << endl; |
955 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 963 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
956 | itemIterator = mTodoMap.find(relatedTodo); | 964 | itemIterator = mTodoMap.find(relatedTodo); |
957 | if (itemIterator == mTodoMap.end()) { | 965 | if (itemIterator == mTodoMap.end()) { |
958 | // kdDebug() << " related not yet in list" << endl; | 966 | // kdDebug() << " related not yet in list" << endl; |
959 | itemIterator = insertTodoItem (relatedTodo); | 967 | itemIterator = insertTodoItem (relatedTodo); |
960 | } | 968 | } |
961 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 969 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
962 | // and one into the map. Sure finding is more easy but why? -zecke | 970 | // and one into the map. Sure finding is more easy but why? -zecke |
963 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 971 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
964 | return mTodoMap.insert(todo,todoItem); | 972 | return mTodoMap.insert(todo,todoItem); |
965 | } else { | 973 | } else { |
966 | // kdDebug() << " no Related" << endl; | 974 | // kdDebug() << " no Related" << endl; |
967 | // see above -zecke | 975 | // see above -zecke |
968 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 976 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
969 | return mTodoMap.insert(todo,todoItem); | 977 | return mTodoMap.insert(todo,todoItem); |
970 | } | 978 | } |
971 | } | 979 | } |
972 | 980 | ||
973 | 981 | ||
974 | void KOTodoView::updateConfig() | 982 | void KOTodoView::updateConfig() |
975 | { | 983 | { |
976 | updateView(); | 984 | updateView(); |
977 | mTodoListView->repaintContents(); | 985 | mTodoListView->repaintContents(); |
978 | } | 986 | } |
979 | 987 | ||
980 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 988 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
981 | { | 989 | { |
982 | QPtrList<Incidence> selected; | 990 | QPtrList<Incidence> selected; |
983 | 991 | ||
984 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 992 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
985 | // if (!item) item = mActiveItem; | 993 | // if (!item) item = mActiveItem; |
986 | if (item) selected.append(item->todo()); | 994 | if (item) selected.append(item->todo()); |
987 | 995 | ||
988 | return selected; | 996 | return selected; |
989 | } | 997 | } |
990 | 998 | ||
991 | QPtrList<Todo> KOTodoView::selectedTodos() | 999 | QPtrList<Todo> KOTodoView::selectedTodos() |
992 | { | 1000 | { |
993 | QPtrList<Todo> selected; | 1001 | QPtrList<Todo> selected; |
994 | 1002 | ||
995 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1003 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
996 | // if (!item) item = mActiveItem; | 1004 | // if (!item) item = mActiveItem; |
997 | if (item) selected.append(item->todo()); | 1005 | if (item) selected.append(item->todo()); |
998 | 1006 | ||
999 | return selected; | 1007 | return selected; |
1000 | } | 1008 | } |
1001 | 1009 | ||
1002 | void KOTodoView::changeEventDisplay(Event *, int) | 1010 | void KOTodoView::changeEventDisplay(Event *, int) |
1003 | { | 1011 | { |
1004 | updateView(); | 1012 | updateView(); |
1005 | } | 1013 | } |
1006 | 1014 | ||
1007 | void KOTodoView::showDates(const QDate &, const QDate &) | 1015 | void KOTodoView::showDates(const QDate &, const QDate &) |
1008 | { | 1016 | { |
1009 | } | 1017 | } |
1010 | 1018 | ||
1011 | void KOTodoView::showEvents(QPtrList<Event>) | 1019 | void KOTodoView::showEvents(QPtrList<Event>) |
1012 | { | 1020 | { |
1013 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1021 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1014 | } | 1022 | } |
1015 | 1023 | ||
1016 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1024 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1017 | const QDate &td) | 1025 | const QDate &td) |
1018 | { | 1026 | { |
1019 | #ifndef KORG_NOPRINTER | 1027 | #ifndef KORG_NOPRINTER |
1020 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1028 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1021 | #endif | 1029 | #endif |
1022 | } | 1030 | } |
1023 | 1031 | ||
1024 | void KOTodoView::editItem(QListViewItem *item ) | 1032 | void KOTodoView::editItem(QListViewItem *item ) |
1025 | { | 1033 | { |
1026 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1034 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1027 | } | 1035 | } |
1028 | 1036 | ||
1029 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1037 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1030 | { | 1038 | { |
1031 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1039 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1032 | } | 1040 | } |
1033 | 1041 | ||
1034 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1042 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1035 | { | 1043 | { |
1036 | pendingSubtodo = 0; | 1044 | pendingSubtodo = 0; |
1037 | mActiveItem = (KOTodoViewItem *)item; | 1045 | mActiveItem = (KOTodoViewItem *)item; |
1038 | if (item) { | 1046 | if (item) { |
1039 | switch (column){ | 1047 | switch (column){ |
1040 | case 1: | 1048 | case 1: |
1041 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1049 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1042 | case 2: | 1050 | case 2: |
1043 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1051 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1044 | case 3: | 1052 | case 3: |
1045 | moveTodo(); | 1053 | moveTodo(); |
1046 | break; | 1054 | break; |
1047 | case 8: | 1055 | case 8: |
1048 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 1056 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
1049 | default: | 1057 | default: |
1050 | mItemPopupMenu->popup(QCursor::pos()); | 1058 | mItemPopupMenu->popup(QCursor::pos()); |
1051 | } | 1059 | } |
1052 | } else mPopupMenu->popup(QCursor::pos()); | 1060 | } else mPopupMenu->popup(QCursor::pos()); |
1053 | } | 1061 | } |
1054 | void KOTodoView::newTodo() | 1062 | void KOTodoView::newTodo() |
1055 | { | 1063 | { |
1056 | emit newTodoSignal(); | 1064 | emit newTodoSignal(); |
1057 | } | 1065 | } |
1058 | 1066 | ||
1059 | void KOTodoView::newSubTodo() | 1067 | void KOTodoView::newSubTodo() |
1060 | { | 1068 | { |
1061 | if (mActiveItem) { | 1069 | if (mActiveItem) { |
1062 | emit newSubTodoSignal(mActiveItem->todo()); | 1070 | emit newSubTodoSignal(mActiveItem->todo()); |
1063 | } | 1071 | } |
1064 | } | 1072 | } |
1065 | void KOTodoView::unparentTodo() | 1073 | void KOTodoView::unparentTodo() |
1066 | { | 1074 | { |
1067 | if (mActiveItem) { | 1075 | if (mActiveItem) { |
1068 | emit unparentTodoSignal(mActiveItem->todo()); | 1076 | emit unparentTodoSignal(mActiveItem->todo()); |
1069 | } | 1077 | } |
1070 | } | 1078 | } |
1071 | 1079 | ||
1072 | void KOTodoView::reparentTodo() | 1080 | void KOTodoView::reparentTodo() |
1073 | { | 1081 | { |
1074 | if (mActiveItem) { | 1082 | if (mActiveItem) { |
1075 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1083 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1076 | pendingSubtodo = mActiveItem; | 1084 | pendingSubtodo = mActiveItem; |
1077 | } | 1085 | } |
1078 | } | 1086 | } |
1079 | void KOTodoView::editTodo() | 1087 | void KOTodoView::editTodo() |
1080 | { | 1088 | { |
1081 | if (mActiveItem) { | 1089 | if (mActiveItem) { |
1082 | emit editTodoSignal(mActiveItem->todo()); | 1090 | emit editTodoSignal(mActiveItem->todo()); |
1083 | } | 1091 | } |
1084 | } | 1092 | } |
1085 | void KOTodoView::cloneTodo() | 1093 | void KOTodoView::cloneTodo() |
1086 | { | 1094 | { |
1087 | if (mActiveItem) { | 1095 | if (mActiveItem) { |
1088 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1096 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1089 | } | 1097 | } |
1090 | } | 1098 | } |
1091 | void KOTodoView::cancelTodo() | 1099 | void KOTodoView::cancelTodo() |
1092 | { | 1100 | { |
1093 | if (mActiveItem) { | 1101 | if (mActiveItem) { |
1094 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1102 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1095 | } | 1103 | } |
1096 | } | 1104 | } |
1097 | void KOTodoView::moveTodo() | 1105 | void KOTodoView::moveTodo() |
1098 | { | 1106 | { |
1099 | if (mActiveItem) { | 1107 | if (mActiveItem) { |
1100 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1108 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1101 | } | 1109 | } |
1102 | } | 1110 | } |
1103 | void KOTodoView::beamTodo() | 1111 | void KOTodoView::beamTodo() |
1104 | { | 1112 | { |
1105 | if (mActiveItem) { | 1113 | if (mActiveItem) { |
1106 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1114 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1107 | } | 1115 | } |
1108 | } | 1116 | } |
1109 | 1117 | ||
1110 | 1118 | ||
1111 | void KOTodoView::showTodo() | 1119 | void KOTodoView::showTodo() |
1112 | { | 1120 | { |
1113 | if (mActiveItem) { | 1121 | if (mActiveItem) { |
1114 | emit showTodoSignal(mActiveItem->todo()); | 1122 | emit showTodoSignal(mActiveItem->todo()); |
1115 | } | 1123 | } |
1116 | } | 1124 | } |
1117 | 1125 | ||
1118 | void KOTodoView::deleteTodo() | 1126 | void KOTodoView::deleteTodo() |
1119 | { | 1127 | { |
1120 | if (mActiveItem) { | 1128 | if (mActiveItem) { |
1121 | emit deleteTodoSignal(mActiveItem->todo()); | 1129 | emit deleteTodoSignal(mActiveItem->todo()); |
1122 | } | 1130 | } |
1123 | } | 1131 | } |
1124 | 1132 | ||
1125 | void KOTodoView::setNewPriority(int index) | 1133 | void KOTodoView::setNewPriority(int index) |
1126 | { | 1134 | { |
1127 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1135 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1128 | mActiveItem->todo()->setPriority(mPriority[index]); | 1136 | mActiveItem->todo()->setPriority(mPriority[index]); |
1129 | mActiveItem->construct(); | 1137 | mActiveItem->construct(); |
1130 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1138 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1131 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1139 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1132 | } | 1140 | } |
1133 | } | 1141 | } |
1134 | 1142 | ||
1135 | void KOTodoView::setNewPercentage(int index) | 1143 | void KOTodoView::setNewPercentage(int index) |
1136 | { | 1144 | { |
1137 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1145 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1138 | 1146 | ||
1139 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1147 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1140 | mActiveItem->setOn( true ); | 1148 | mActiveItem->setOn( true ); |
1141 | return; | 1149 | return; |
1142 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1150 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1143 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1151 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1144 | if ( par && par->isOn() ) | 1152 | if ( par && par->isOn() ) |
1145 | par->setOn( false ); | 1153 | par->setOn( false ); |
1146 | } | 1154 | } |
1147 | if (mPercentage[index] == 100) { | 1155 | if (mPercentage[index] == 100) { |
1148 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1156 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1149 | } else { | 1157 | } else { |
1150 | mActiveItem->todo()->setCompleted(false); | 1158 | mActiveItem->todo()->setCompleted(false); |
1151 | } | 1159 | } |
1152 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1160 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1153 | mActiveItem->construct(); | 1161 | mActiveItem->construct(); |
1154 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1162 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1155 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1163 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1156 | } | 1164 | } |
1157 | } | 1165 | } |
1158 | 1166 | ||
1159 | 1167 | ||
1160 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 1168 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
1161 | { | 1169 | { |
1162 | if ( !mCategoryPopupMenu ) { | 1170 | if ( !mCategoryPopupMenu ) { |
1163 | mCategoryPopupMenu = new QPopupMenu (this); | 1171 | mCategoryPopupMenu = new QPopupMenu (this); |
1164 | mCategoryPopupMenu->setCheckable (true); | 1172 | mCategoryPopupMenu->setCheckable (true); |
1165 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 1173 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
1166 | } | 1174 | } |
1167 | mCategoryPopupMenu->clear(); | 1175 | mCategoryPopupMenu->clear(); |
1168 | QStringList checkedCategories = todoItem->todo()->categories (); | 1176 | QStringList checkedCategories = todoItem->todo()->categories (); |
1169 | 1177 | ||
1170 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1178 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1171 | it != KOPrefs::instance()->mCustomCategories.end (); | 1179 | it != KOPrefs::instance()->mCustomCategories.end (); |
1172 | ++it) { | 1180 | ++it) { |
1173 | int index = mCategoryPopupMenu->insertItem (*it); | 1181 | int index = mCategoryPopupMenu->insertItem (*it); |
1174 | mCategory[index] = *it; | 1182 | mCategory[index] = *it; |
1175 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1183 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1176 | } | 1184 | } |
1177 | return mCategoryPopupMenu; | 1185 | return mCategoryPopupMenu; |
1178 | } | 1186 | } |
1179 | void KOTodoView::changedCategories(int index) | 1187 | void KOTodoView::changedCategories(int index) |
1180 | { | 1188 | { |
1181 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1189 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1182 | QStringList categories = mActiveItem->todo()->categories (); | 1190 | QStringList categories = mActiveItem->todo()->categories (); |
1183 | QString colcat = categories.first(); | 1191 | QString colcat = categories.first(); |
1184 | if (categories.find (mCategory[index]) != categories.end ()) | 1192 | if (categories.find (mCategory[index]) != categories.end ()) |
1185 | categories.remove (mCategory[index]); | 1193 | categories.remove (mCategory[index]); |
1186 | else | 1194 | else |
1187 | categories.insert (categories.end(), mCategory[index]); | 1195 | categories.insert (categories.end(), mCategory[index]); |
1188 | categories.sort (); | 1196 | categories.sort (); |
1189 | if ( !colcat.isEmpty() ) { | 1197 | if ( !colcat.isEmpty() ) { |
1190 | if ( categories.find ( colcat ) != categories.end () ) { | 1198 | if ( categories.find ( colcat ) != categories.end () ) { |
1191 | categories.remove( colcat ); | 1199 | categories.remove( colcat ); |
1192 | categories.prepend( colcat ); | 1200 | categories.prepend( colcat ); |
1193 | } | 1201 | } |
1194 | } | 1202 | } |
1195 | mActiveItem->todo()->setCategories (categories); | 1203 | mActiveItem->todo()->setCategories (categories); |
1196 | mActiveItem->construct(); | 1204 | mActiveItem->construct(); |
1197 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1205 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1198 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1206 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1199 | } | 1207 | } |
1200 | } | 1208 | } |
1201 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1209 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1202 | { | 1210 | { |
1203 | if ( pendingSubtodo != 0 ) { | 1211 | if ( pendingSubtodo != 0 ) { |
1204 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1212 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1205 | } | 1213 | } |
1206 | pendingSubtodo = 0; | 1214 | pendingSubtodo = 0; |
1207 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1215 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1208 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1216 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1209 | //qDebug("ROW %d ", row); | 1217 | //qDebug("ROW %d ", row); |
1210 | if (!item) { | 1218 | if (!item) { |
1211 | newTodo(); | 1219 | newTodo(); |
1212 | return; | 1220 | return; |
1213 | } else { | 1221 | } else { |
1214 | if ( row == 1 ) { | 1222 | if ( row == 1 ) { |
1215 | mActiveItem = (KOTodoViewItem *) item; | 1223 | mActiveItem = (KOTodoViewItem *) item; |
1216 | newSubTodo(); | 1224 | newSubTodo(); |
1217 | return; | 1225 | return; |
1218 | } | 1226 | } |
1219 | if ( row == 5 || row == 6 || row == 2) { | 1227 | if ( row == 5 || row == 6 || row == 2) { |
1220 | mActiveItem = (KOTodoViewItem *) item; | 1228 | mActiveItem = (KOTodoViewItem *) item; |
1221 | Todo * t = mActiveItem->todo(); | 1229 | Todo * t = mActiveItem->todo(); |
1222 | if ( t->isRunning() ) { | 1230 | if ( t->isRunning() ) { |
1223 | if ( t->runTime() < 15) { | 1231 | if ( t->runTime() < 15) { |
1224 | t->stopRunning(); | 1232 | t->stopRunning(); |
1225 | mActiveItem->construct(); | 1233 | mActiveItem->construct(); |
1226 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1234 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1227 | return; | 1235 | return; |
1228 | } | 1236 | } |
1229 | else | 1237 | else |
1230 | toggleRunningItem(); | 1238 | toggleRunningItem(); |
1231 | return; | 1239 | return; |
1232 | } else { | 1240 | } else { |
1233 | t->setRunning( true ); | 1241 | t->setRunning( true ); |
1234 | mActiveItem->construct(); | 1242 | mActiveItem->construct(); |
1235 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1243 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1236 | return; | 1244 | return; |
1237 | } | 1245 | } |
1238 | } | 1246 | } |
1239 | } | 1247 | } |
1240 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1248 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1241 | editItem( item ); | 1249 | editItem( item ); |
1242 | else | 1250 | else |
1243 | showItem( item , QPoint(), 0 ); | 1251 | showItem( item , QPoint(), 0 ); |
1244 | } | 1252 | } |
1245 | void KOTodoView::toggleRunningItem() | 1253 | void KOTodoView::toggleRunningItem() |
1246 | { | 1254 | { |
1247 | // qDebug("KOTodoView::toggleRunning() "); | 1255 | // qDebug("KOTodoView::toggleRunning() "); |
1248 | if ( ! mActiveItem ) | 1256 | if ( ! mActiveItem ) |
1249 | return; | 1257 | return; |
1250 | Todo * t = mActiveItem->todo(); | 1258 | Todo * t = mActiveItem->todo(); |
1251 | if ( t->isRunning() ) { | 1259 | if ( t->isRunning() ) { |
1252 | KOStopTodoPrefs tp ( t, this ); | 1260 | KOStopTodoPrefs tp ( t, this ); |
1253 | if (QApplication::desktop()->width() <= 800 ){ | 1261 | if (QApplication::desktop()->width() <= 800 ){ |
1254 | int wid = tp.width(); | 1262 | int wid = tp.width(); |
1255 | int hei = tp.height(); | 1263 | int hei = tp.height(); |
1256 | int xx = (QApplication::desktop()->width()-wid)/2; | 1264 | int xx = (QApplication::desktop()->width()-wid)/2; |
1257 | int yy = (QApplication::desktop()->height()-hei)/2; | 1265 | int yy = (QApplication::desktop()->height()-hei)/2; |
1258 | tp.setGeometry( xx,yy,wid,hei ); | 1266 | tp.setGeometry( xx,yy,wid,hei ); |
1259 | } | 1267 | } |
1260 | tp.exec(); | 1268 | tp.exec(); |
1261 | mActiveItem->construct(); | 1269 | mActiveItem->construct(); |
1262 | } else { | 1270 | } else { |
1263 | KOStartTodoPrefs tp ( t->summary(), this ); | 1271 | KOStartTodoPrefs tp ( t->summary(), this ); |
1264 | if (QApplication::desktop()->width() <= 800 ){ | 1272 | if (QApplication::desktop()->width() <= 800 ){ |
1265 | int wid = tp.width(); | 1273 | int wid = tp.width(); |
1266 | int hei = tp.height(); | 1274 | int hei = tp.height(); |
1267 | int xx = (QApplication::desktop()->width()-wid)/2; | 1275 | int xx = (QApplication::desktop()->width()-wid)/2; |
1268 | int yy = (QApplication::desktop()->height()-hei)/2; | 1276 | int yy = (QApplication::desktop()->height()-hei)/2; |
1269 | tp.setGeometry( xx,yy,wid,hei ); | 1277 | tp.setGeometry( xx,yy,wid,hei ); |
1270 | } | 1278 | } |
1271 | if ( !tp.exec() ) return; | 1279 | if ( !tp.exec() ) return; |
1272 | if ( tp.stopAll() ) { | 1280 | if ( tp.stopAll() ) { |
1273 | mCalendar->stopAllTodos(); | 1281 | mCalendar->stopAllTodos(); |
1274 | t->setRunning( true ); | 1282 | t->setRunning( true ); |
1275 | updateView(); | 1283 | updateView(); |
1276 | } else { | 1284 | } else { |
1277 | t->setRunning( true ); | 1285 | t->setRunning( true ); |
1278 | mActiveItem->construct(); | 1286 | mActiveItem->construct(); |
1279 | } | 1287 | } |
1280 | } | 1288 | } |
1281 | } | 1289 | } |
1282 | 1290 | ||
1283 | void KOTodoView::itemClicked(QListViewItem *item) | 1291 | void KOTodoView::itemClicked(QListViewItem *item) |
1284 | { | 1292 | { |
1285 | //qDebug("KOTodoView::itemClicked %d", item); | 1293 | //qDebug("KOTodoView::itemClicked %d", item); |
1286 | if (!item) { | 1294 | if (!item) { |
1287 | if ( pendingSubtodo != 0 ) { | 1295 | if ( pendingSubtodo != 0 ) { |
1288 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1296 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1289 | } | 1297 | } |
1290 | pendingSubtodo = 0; | 1298 | pendingSubtodo = 0; |
1291 | return; | 1299 | return; |
1292 | } | 1300 | } |
1293 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1301 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1294 | if ( pendingSubtodo != 0 ) { | 1302 | if ( pendingSubtodo != 0 ) { |
1295 | bool allowReparent = true; | 1303 | bool allowReparent = true; |
1296 | QListViewItem *par = item; | 1304 | QListViewItem *par = item; |
1297 | while ( par ) { | 1305 | while ( par ) { |
1298 | if ( par == pendingSubtodo ) { | 1306 | if ( par == pendingSubtodo ) { |
1299 | allowReparent = false; | 1307 | allowReparent = false; |
1300 | break; | 1308 | break; |
1301 | } | 1309 | } |
1302 | par = par->parent(); | 1310 | par = par->parent(); |
1303 | } | 1311 | } |
1304 | if ( !allowReparent ) { | 1312 | if ( !allowReparent ) { |
1305 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1313 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1306 | pendingSubtodo = 0; | 1314 | pendingSubtodo = 0; |
1307 | } else { | 1315 | } else { |
1308 | Todo* newParent = todoItem->todo(); | 1316 | Todo* newParent = todoItem->todo(); |
1309 | Todo* newSub = pendingSubtodo->todo(); | 1317 | Todo* newSub = pendingSubtodo->todo(); |
1310 | pendingSubtodo = 0; | 1318 | pendingSubtodo = 0; |
1311 | emit reparentTodoSignal( newParent,newSub ); | 1319 | emit reparentTodoSignal( newParent,newSub ); |
1312 | return; | 1320 | return; |
1313 | } | 1321 | } |
1314 | } | 1322 | } |
1315 | 1323 | ||
1316 | } | 1324 | } |
1317 | 1325 | ||
1318 | void KOTodoView::setDocumentId( const QString &id ) | 1326 | void KOTodoView::setDocumentId( const QString &id ) |
1319 | { | 1327 | { |
1320 | 1328 | ||
1321 | mDocPrefs->setDoc( id ); | 1329 | mDocPrefs->setDoc( id ); |
1322 | } | 1330 | } |
1323 | 1331 | ||
1324 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1332 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1325 | { | 1333 | { |
1326 | if (!item) return; | 1334 | if (!item) return; |
1327 | 1335 | ||
1328 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1336 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1329 | 1337 | ||
1330 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1338 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1331 | 1339 | ||
1332 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1340 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1333 | } | 1341 | } |
1334 | 1342 | ||
1335 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1343 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1336 | { | 1344 | { |
1337 | mTodoListView->saveLayout(config,group); | 1345 | mTodoListView->saveLayout(config,group); |
1338 | } | 1346 | } |
1339 | 1347 | ||
1340 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1348 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1341 | { | 1349 | { |
1342 | mTodoListView->restoreLayout(config,group); | 1350 | mTodoListView->restoreLayout(config,group); |
1343 | } | 1351 | } |
1344 | 1352 | ||
1345 | void KOTodoView::processSelectionChange() | 1353 | void KOTodoView::processSelectionChange() |
1346 | { | 1354 | { |
1347 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1355 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1348 | 1356 | ||
1349 | KOTodoViewItem *item = | 1357 | KOTodoViewItem *item = |
1350 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1358 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1351 | 1359 | ||
1352 | if ( !item ) { | 1360 | if ( !item ) { |
1353 | emit incidenceSelected( 0 ); | 1361 | emit incidenceSelected( 0 ); |
1354 | } else { | 1362 | } else { |
1355 | emit incidenceSelected( item->todo() ); | 1363 | emit incidenceSelected( item->todo() ); |
1356 | } | 1364 | } |
1357 | } | 1365 | } |
1358 | 1366 | ||
1359 | void KOTodoView::modified(bool b) | 1367 | void KOTodoView::modified(bool b) |
1360 | { | 1368 | { |
1361 | emit isModified(b); | 1369 | emit isModified(b); |
1362 | } | 1370 | } |
1363 | void KOTodoView::setTodoModified( Todo* todo ) | 1371 | void KOTodoView::setTodoModified( Todo* todo ) |
1364 | { | 1372 | { |
1365 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1373 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1366 | } | 1374 | } |
1367 | void KOTodoView::clearSelection() | 1375 | void KOTodoView::clearSelection() |
1368 | { | 1376 | { |
1369 | mTodoListView->selectAll( false ); | 1377 | mTodoListView->selectAll( false ); |
1370 | } | 1378 | } |
1371 | void KOTodoView::setAllOpen() | 1379 | void KOTodoView::setAllOpen() |
1372 | { | 1380 | { |
1373 | if ( isFlatDisplay ) { | 1381 | if ( isFlatDisplay ) { |
1374 | isFlatDisplay = false; | 1382 | isFlatDisplay = false; |
1375 | mPopupMenu->setItemChecked( 8,false ); | 1383 | mPopupMenu->setItemChecked( 8,false ); |
1376 | updateView(); | 1384 | updateView(); |
1377 | } else { | 1385 | } else { |
1378 | storeCurrentItem(); | 1386 | storeCurrentItem(); |
1379 | } | 1387 | } |
1380 | setOpen(mTodoListView->firstChild(), true); | 1388 | setOpen(mTodoListView->firstChild(), true); |
1381 | resetCurrentItem(); | 1389 | resetCurrentItem(); |
1382 | } | 1390 | } |
1383 | void KOTodoView::setAllClose() | 1391 | void KOTodoView::setAllClose() |
1384 | { | 1392 | { |
1385 | if ( isFlatDisplay ) { | 1393 | if ( isFlatDisplay ) { |
1386 | isFlatDisplay = false; | 1394 | isFlatDisplay = false; |
1387 | mPopupMenu->setItemChecked( 8,false ); | 1395 | mPopupMenu->setItemChecked( 8,false ); |
1388 | updateView(); | 1396 | updateView(); |
1389 | } else { | 1397 | } else { |
1390 | storeCurrentItem(); | 1398 | storeCurrentItem(); |
1391 | } | 1399 | } |
1392 | setOpen(mTodoListView->firstChild(), false); | 1400 | setOpen(mTodoListView->firstChild(), false); |
1393 | resetCurrentItem(); | 1401 | resetCurrentItem(); |
1394 | } | 1402 | } |
1395 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1403 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1396 | { | 1404 | { |
1397 | 1405 | ||
1398 | while ( item ) { | 1406 | while ( item ) { |
1399 | setOpen( item->firstChild(), setOpenI ); | 1407 | setOpen( item->firstChild(), setOpenI ); |
1400 | item->setOpen( setOpenI ); | 1408 | item->setOpen( setOpenI ); |
1401 | item = item->nextSibling(); | 1409 | item = item->nextSibling(); |
1402 | } | 1410 | } |
1403 | } | 1411 | } |
1404 | 1412 | ||
1405 | void KOTodoView::displayAllFlat() | 1413 | void KOTodoView::displayAllFlat() |
1406 | { | 1414 | { |
1415 | storeCurrentItem(); | ||
1407 | pendingSubtodo = 0; | 1416 | pendingSubtodo = 0; |
1408 | if ( mBlockUpdate ) { | 1417 | if ( mBlockUpdate ) { |
1409 | return; | 1418 | return; |
1410 | } | 1419 | } |
1411 | mPopupMenu->setItemChecked( 8,true ); | 1420 | mPopupMenu->setItemChecked( 8,true ); |
1412 | isFlatDisplay = true; | 1421 | isFlatDisplay = true; |
1413 | QPtrList<Todo> todoList = calendar()->todos(); | 1422 | QPtrList<Todo> todoList = calendar()->todos(); |
1414 | mTodoMap.clear(); | 1423 | mTodoMap.clear(); |
1415 | mTodoListView->clear(); | 1424 | mTodoListView->clear(); |
1416 | Todo *todo; | 1425 | Todo *todo; |
1417 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1426 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1418 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1427 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1419 | mTodoMap.insert(todo,todoItem); | 1428 | mTodoMap.insert(todo,todoItem); |
1420 | } | 1429 | } |
1421 | mTodoListView->setFocus(); | 1430 | resetCurrentItem(); |
1422 | processSelectionChange(); | ||
1423 | } | 1431 | } |
1424 | 1432 | ||
1425 | void KOTodoView::setAllFlat() | 1433 | void KOTodoView::setAllFlat() |
1426 | { | 1434 | { |
1427 | if ( isFlatDisplay ) { | 1435 | if ( isFlatDisplay ) { |
1428 | isFlatDisplay = false; | 1436 | isFlatDisplay = false; |
1429 | mPopupMenu->setItemChecked( 8,false ); | 1437 | mPopupMenu->setItemChecked( 8,false ); |
1430 | updateView(); | 1438 | updateView(); |
1431 | return; | 1439 | return; |
1432 | } | 1440 | } |
1433 | storeCurrentItem(); | ||
1434 | displayAllFlat(); | 1441 | displayAllFlat(); |
1435 | resetCurrentItem(); | ||
1436 | } | 1442 | } |
1437 | 1443 | ||
1438 | void KOTodoView::purgeCompleted() | 1444 | void KOTodoView::purgeCompleted() |
1439 | { | 1445 | { |
1440 | emit purgeCompletedSignal(); | 1446 | emit purgeCompletedSignal(); |
1441 | 1447 | ||
1442 | } | 1448 | } |
1443 | void KOTodoView::toggleQuickTodo() | 1449 | void KOTodoView::toggleQuickTodo() |
1444 | { | 1450 | { |
1445 | if ( mQuickAdd->isVisible() ) { | 1451 | if ( mQuickAdd->isVisible() ) { |
1446 | mQuickAdd->hide(); | 1452 | mQuickAdd->hide(); |
1447 | KOPrefs::instance()->mEnableQuickTodo = false; | 1453 | KOPrefs::instance()->mEnableQuickTodo = false; |
1448 | } | 1454 | } |
1449 | else { | 1455 | else { |
1450 | mQuickAdd->show(); | 1456 | mQuickAdd->show(); |
1451 | KOPrefs::instance()->mEnableQuickTodo = true; | 1457 | KOPrefs::instance()->mEnableQuickTodo = true; |
1452 | } | 1458 | } |
1453 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1459 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1454 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1460 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1455 | } | 1461 | } |
1456 | 1462 | ||
1457 | void KOTodoView::toggleRunning() | 1463 | void KOTodoView::toggleRunning() |
1458 | { | 1464 | { |
1459 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1465 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1460 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1466 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1461 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1467 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1462 | updateView(); | 1468 | updateView(); |
1463 | } | 1469 | } |
1464 | 1470 | ||
1465 | void KOTodoView::toggleCompleted() | 1471 | void KOTodoView::toggleCompleted() |
1466 | { | 1472 | { |
1467 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1473 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1468 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1474 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1469 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1475 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1470 | updateView(); | 1476 | updateView(); |
1471 | } | 1477 | } |
1472 | 1478 | ||
1473 | void KOTodoView::addQuickTodo() | 1479 | void KOTodoView::addQuickTodo() |
1474 | { | 1480 | { |
1475 | Todo *todo = new Todo(); | 1481 | Todo *todo = new Todo(); |
1476 | todo->setSummary(mQuickAdd->text()); | 1482 | todo->setSummary(mQuickAdd->text()); |
1477 | todo->setOrganizer(KOPrefs::instance()->email()); | 1483 | todo->setOrganizer(KOPrefs::instance()->email()); |
1478 | CalFilter * cf = mCalendar->filter(); | 1484 | CalFilter * cf = mCalendar->filter(); |
1479 | if ( cf ) { | 1485 | if ( cf ) { |
1480 | if ( cf->isEnabled()&& cf->showCategories()) { | 1486 | if ( cf->isEnabled()&& cf->showCategories()) { |
1481 | todo->setCategories(cf->categoryList()); | 1487 | todo->setCategories(cf->categoryList()); |
1482 | } | 1488 | } |
1483 | if ( cf->isEnabled() ) | 1489 | if ( cf->isEnabled() ) |
1484 | todo->setSecrecy( cf->getSecrecy()); | 1490 | todo->setSecrecy( cf->getSecrecy()); |
1485 | } | 1491 | } |
1486 | mCalendar->addTodo(todo); | 1492 | mCalendar->addTodo(todo); |
1487 | mQuickAdd->setText(""); | 1493 | mQuickAdd->setText(""); |
1488 | todoModified (todo, KOGlobals::EVENTADDED ); | 1494 | todoModified (todo, KOGlobals::EVENTADDED ); |
1489 | updateView(); | 1495 | updateView(); |
1490 | } | 1496 | } |
1491 | 1497 | ||
1492 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1498 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1493 | { | 1499 | { |
1494 | // e->ignore(); | 1500 | // e->ignore(); |
1495 | //return; | 1501 | //return; |
1496 | //qDebug("KOTodoView::keyPressEvent "); | 1502 | //qDebug("KOTodoView::keyPressEvent "); |
1497 | switch ( e->key() ) { | 1503 | switch ( e->key() ) { |
1498 | case Qt::Key_Down: | 1504 | case Qt::Key_Down: |
1499 | case Qt::Key_Up: | 1505 | case Qt::Key_Up: |
1500 | QWidget::keyPressEvent ( e ); | 1506 | QWidget::keyPressEvent ( e ); |
1501 | break; | 1507 | break; |
1502 | 1508 | ||
1503 | case Qt::Key_Q: | 1509 | case Qt::Key_Q: |
1504 | toggleQuickTodo(); | 1510 | toggleQuickTodo(); |
1505 | break; | 1511 | break; |
1506 | case Qt::Key_U: | 1512 | case Qt::Key_U: |
1507 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1513 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1508 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1514 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1509 | unparentTodo(); | 1515 | unparentTodo(); |
1510 | e->accept(); | 1516 | e->accept(); |
1511 | } else | 1517 | } else |
1512 | e->ignore(); | 1518 | e->ignore(); |
1513 | break; | 1519 | break; |
1514 | case Qt::Key_S: | 1520 | case Qt::Key_S: |
1515 | if ( e->state() == Qt::ControlButton ) { | 1521 | if ( e->state() == Qt::ControlButton ) { |
1516 | e->ignore(); | 1522 | e->ignore(); |
1517 | break; | 1523 | break; |
1518 | } | 1524 | } |
1519 | if ( e->state() == Qt::ShiftButton ) { | 1525 | if ( e->state() == Qt::ShiftButton ) { |
1520 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1526 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1521 | reparentTodo(); | 1527 | reparentTodo(); |
1522 | e->accept(); | 1528 | e->accept(); |
1523 | } else | 1529 | } else |
1524 | e->ignore(); | 1530 | e->ignore(); |
1525 | break; | 1531 | break; |
1526 | case Qt::Key_P: | 1532 | case Qt::Key_P: |
1527 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1533 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1528 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1534 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1529 | if ( pendingSubtodo ) | 1535 | if ( pendingSubtodo ) |
1530 | itemClicked(mActiveItem); | 1536 | itemClicked(mActiveItem); |
1531 | e->accept(); | 1537 | e->accept(); |
1532 | } else | 1538 | } else |
1533 | e->ignore(); | 1539 | e->ignore(); |
1534 | break; | 1540 | break; |
1535 | case Qt::Key_Escape: | 1541 | case Qt::Key_Escape: |
1536 | if ( pendingSubtodo ) { | 1542 | if ( pendingSubtodo ) { |
1537 | itemClicked(0); | 1543 | itemClicked(0); |
1538 | e->accept(); | 1544 | e->accept(); |
1539 | } else | 1545 | } else |
1540 | e->ignore(); | 1546 | e->ignore(); |
1541 | break; | 1547 | break; |
1542 | default: | 1548 | default: |
1543 | e->ignore(); | 1549 | e->ignore(); |
1544 | } | 1550 | } |
1545 | 1551 | ||
1546 | if ( true ) { | 1552 | if ( true ) { |
1547 | if ( e->key() == Qt::Key_I ) { | 1553 | if ( e->key() == Qt::Key_I ) { |
1548 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1554 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1549 | if ( cn ) { | 1555 | if ( cn ) { |
1550 | mActiveItem = cn; | 1556 | mActiveItem = cn; |
1551 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1557 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1552 | if ( ci ){ | 1558 | if ( ci ){ |
1553 | showTodo(); | 1559 | showTodo(); |
1554 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1560 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1555 | if ( cn ) { | 1561 | if ( cn ) { |
1556 | mTodoListView->setCurrentItem ( cn ); | 1562 | mTodoListView->setCurrentItem ( cn ); |
1557 | mTodoListView->ensureItemVisible ( cn ); | 1563 | mTodoListView->ensureItemVisible ( cn ); |
1558 | } | 1564 | } |
1559 | 1565 | ||
1560 | } | 1566 | } |
1561 | } | 1567 | } |
1562 | e->accept(); | 1568 | e->accept(); |
1563 | 1569 | ||
1564 | } | 1570 | } |
1565 | 1571 | ||
1566 | } | 1572 | } |
1567 | 1573 | ||
1568 | } | 1574 | } |
1569 | void KOTodoView::updateTodo( Todo * t, int type ) | 1575 | void KOTodoView::updateTodo( Todo * t, int type ) |
1570 | { | 1576 | { |
1571 | if ( mBlockUpdate) | 1577 | if ( mBlockUpdate) |
1572 | return; | 1578 | return; |
1573 | 1579 | ||
1574 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1580 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1575 | itemIterator = mTodoMap.find(t); | 1581 | itemIterator = mTodoMap.find(t); |
1576 | if (itemIterator != mTodoMap.end()) { | 1582 | if (itemIterator != mTodoMap.end()) { |
1577 | (*itemIterator)->construct(); | 1583 | (*itemIterator)->construct(); |
1578 | } else { | 1584 | } else { |
1579 | if ( type == KOGlobals::EVENTADDED ) { | 1585 | if ( type == KOGlobals::EVENTADDED ) { |
1580 | insertTodoItem( t ); | 1586 | insertTodoItem( t ); |
1581 | } | 1587 | } |
1582 | } | 1588 | } |
1583 | 1589 | ||
1584 | } | 1590 | } |
1585 | 1591 | ||
1586 | void KOTodoView::todoModified(Todo * t , int p ) | 1592 | void KOTodoView::todoModified(Todo * t , int p ) |
1587 | { | 1593 | { |
1588 | mBlockUpdate = true; | 1594 | mBlockUpdate = true; |
1589 | emit todoModifiedSignal ( t, p ); | 1595 | emit todoModifiedSignal ( t, p ); |
1590 | mBlockUpdate = false; | 1596 | mBlockUpdate = false; |
1591 | } | 1597 | } |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 1b31d0d..9ae7f53 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -1,302 +1,303 @@ | |||
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 | #ifndef KOTODOVIEW_H | 23 | #ifndef KOTODOVIEW_H |
24 | #define KOTODOVIEW_H | 24 | #define KOTODOVIEW_H |
25 | 25 | ||
26 | #include <qfont.h> | 26 | #include <qfont.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qptrlist.h> | 29 | #include <qptrlist.h> |
30 | #include <qstrlist.h> | 30 | #include <qstrlist.h> |
31 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qmap.h> | 34 | #include <qmap.h> |
35 | #include <qdialog.h> | 35 | #include <qdialog.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlistview.h> | 37 | #include <qlistview.h> |
38 | #include <klistview.h> | 38 | #include <klistview.h> |
39 | 39 | ||
40 | #include <libkcal/calendar.h> | 40 | #include <libkcal/calendar.h> |
41 | #include <libkcal/todo.h> | 41 | #include <libkcal/todo.h> |
42 | 42 | ||
43 | #include <korganizer/baseview.h> | 43 | #include <korganizer/baseview.h> |
44 | 44 | ||
45 | #include "kotodoviewitem.h" | 45 | #include "kotodoviewitem.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "koglobals.h" | 47 | #include "koglobals.h" |
48 | #include "datenavigator.h" | 48 | #include "datenavigator.h" |
49 | 49 | ||
50 | class QDragEnterEvent; | 50 | class QDragEnterEvent; |
51 | class QDragMoveEvent; | 51 | class QDragMoveEvent; |
52 | class QDragLeaveEvent; | 52 | class QDragLeaveEvent; |
53 | class QDropEvent; | 53 | class QDropEvent; |
54 | class KOTodoViewWhatsThis; | 54 | class KOTodoViewWhatsThis; |
55 | class KDateEdit; | 55 | class KDateEdit; |
56 | class KOTimeEdit; | 56 | class KOTimeEdit; |
57 | 57 | ||
58 | class DocPrefs; | 58 | class DocPrefs; |
59 | 59 | ||
60 | 60 | ||
61 | class KOStopTodoPrefs : public QDialog | 61 | class KOStopTodoPrefs : public QDialog |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; | 65 | KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; |
66 | 66 | ||
67 | 67 | ||
68 | private slots: | 68 | private slots: |
69 | void doNotSave(); | 69 | void doNotSave(); |
70 | void accept(); | 70 | void accept(); |
71 | private: | 71 | private: |
72 | Todo* mTodo; | 72 | Todo* mTodo; |
73 | QLineEdit* mComment; | 73 | QLineEdit* mComment; |
74 | KDateEdit *sde, *ede; | 74 | KDateEdit *sde, *ede; |
75 | KOTimeEdit *ste, *ete; | 75 | KOTimeEdit *ste, *ete; |
76 | 76 | ||
77 | }; | 77 | }; |
78 | 78 | ||
79 | class KOStartTodoPrefs : public QDialog | 79 | class KOStartTodoPrefs : public QDialog |
80 | { | 80 | { |
81 | Q_OBJECT | 81 | Q_OBJECT |
82 | public: | 82 | public: |
83 | KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ; | 83 | KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ; |
84 | 84 | ||
85 | bool stopAll() { return mStopAll; } | 85 | bool stopAll() { return mStopAll; } |
86 | private slots: | 86 | private slots: |
87 | void doStop(); | 87 | void doStop(); |
88 | private: | 88 | private: |
89 | bool mStopAll; | 89 | bool mStopAll; |
90 | 90 | ||
91 | }; | 91 | }; |
92 | 92 | ||
93 | class KOTodoListView : public KListView | 93 | class KOTodoListView : public KListView |
94 | { | 94 | { |
95 | Q_OBJECT | 95 | Q_OBJECT |
96 | public: | 96 | public: |
97 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); | 97 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); |
98 | virtual ~KOTodoListView() {} | 98 | virtual ~KOTodoListView() {} |
99 | 99 | ||
100 | signals: | 100 | signals: |
101 | void paintNeeded(); | 101 | void paintNeeded(); |
102 | void todoDropped(Todo *, int); | 102 | void todoDropped(Todo *, int); |
103 | void double_Clicked(QListViewItem *item); | 103 | void double_Clicked(QListViewItem *item); |
104 | void reparentTodoSignal( Todo *,Todo * ); | 104 | void reparentTodoSignal( Todo *,Todo * ); |
105 | void unparentTodoSignal(Todo *); | 105 | void unparentTodoSignal(Todo *); |
106 | void deleteTodo( Todo * ); | 106 | void deleteTodo( Todo * ); |
107 | protected: | 107 | protected: |
108 | void wheelEvent (QWheelEvent *e); | 108 | void wheelEvent (QWheelEvent *e); |
109 | void contentsDragEnterEvent(QDragEnterEvent *); | 109 | void contentsDragEnterEvent(QDragEnterEvent *); |
110 | void contentsDragMoveEvent(QDragMoveEvent *); | 110 | void contentsDragMoveEvent(QDragMoveEvent *); |
111 | void contentsDragLeaveEvent(QDragLeaveEvent *); | 111 | void contentsDragLeaveEvent(QDragLeaveEvent *); |
112 | void contentsDropEvent(QDropEvent *); | 112 | void contentsDropEvent(QDropEvent *); |
113 | 113 | ||
114 | void contentsMousePressEvent(QMouseEvent *); | 114 | void contentsMousePressEvent(QMouseEvent *); |
115 | void contentsMouseMoveEvent(QMouseEvent *); | 115 | void contentsMouseMoveEvent(QMouseEvent *); |
116 | void contentsMouseReleaseEvent(QMouseEvent *); | 116 | void contentsMouseReleaseEvent(QMouseEvent *); |
117 | void contentsMouseDoubleClickEvent(QMouseEvent *); | 117 | void contentsMouseDoubleClickEvent(QMouseEvent *); |
118 | 118 | ||
119 | private: | 119 | private: |
120 | void paintEvent(QPaintEvent * pevent); | 120 | void paintEvent(QPaintEvent * pevent); |
121 | bool internalDrop; | 121 | bool internalDrop; |
122 | QString mName; | 122 | QString mName; |
123 | Calendar *mCalendar; | 123 | Calendar *mCalendar; |
124 | QPoint mPressPos; | 124 | QPoint mPressPos; |
125 | bool mMousePressed; | 125 | bool mMousePressed; |
126 | QListViewItem *mOldCurrent; | 126 | QListViewItem *mOldCurrent; |
127 | bool mFlagKeyPressed; | 127 | bool mFlagKeyPressed; |
128 | void keyPressEvent ( QKeyEvent * ) ; | 128 | void keyPressEvent ( QKeyEvent * ) ; |
129 | void keyReleaseEvent ( QKeyEvent * ) ; | 129 | void keyReleaseEvent ( QKeyEvent * ) ; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | 132 | ||
133 | /** | 133 | /** |
134 | This is the line-edit on top of the todoview for fast addition of new todos | 134 | This is the line-edit on top of the todoview for fast addition of new todos |
135 | */ | 135 | */ |
136 | class KOQuickTodo : public QLineEdit | 136 | class KOQuickTodo : public QLineEdit |
137 | { | 137 | { |
138 | public: | 138 | public: |
139 | KOQuickTodo(QWidget *parent=0); | 139 | KOQuickTodo(QWidget *parent=0); |
140 | protected: | 140 | protected: |
141 | void focusInEvent(QFocusEvent *ev); | 141 | void focusInEvent(QFocusEvent *ev); |
142 | void focusOutEvent(QFocusEvent *ev); | 142 | void focusOutEvent(QFocusEvent *ev); |
143 | }; | 143 | }; |
144 | 144 | ||
145 | 145 | ||
146 | /** | 146 | /** |
147 | This class provides a multi-column list view of todo events. | 147 | This class provides a multi-column list view of todo events. |
148 | 148 | ||
149 | @short multi-column list view of todo events. | 149 | @short multi-column list view of todo events. |
150 | @author Cornelius Schumacher <schumacher@kde.org> | 150 | @author Cornelius Schumacher <schumacher@kde.org> |
151 | */ | 151 | */ |
152 | class KOTodoView : public KOrg::BaseView | 152 | class KOTodoView : public KOrg::BaseView |
153 | { | 153 | { |
154 | Q_OBJECT | 154 | Q_OBJECT |
155 | public: | 155 | public: |
156 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); | 156 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); |
157 | ~KOTodoView(); | 157 | ~KOTodoView(); |
158 | 158 | ||
159 | QPtrList<Incidence> selectedIncidences(); | 159 | QPtrList<Incidence> selectedIncidences(); |
160 | QPtrList<Todo> selectedTodos(); | 160 | QPtrList<Todo> selectedTodos(); |
161 | 161 | ||
162 | DateList selectedDates() | 162 | DateList selectedDates() |
163 | {DateList q; | 163 | {DateList q; |
164 | return q;} | 164 | return q;} |
165 | 165 | ||
166 | /** Return number of shown dates. TodoView does not show dates, */ | 166 | /** Return number of shown dates. TodoView does not show dates, */ |
167 | int currentDateCount() { return 0; } | 167 | int currentDateCount() { return 0; } |
168 | 168 | ||
169 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); | 169 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); |
170 | 170 | ||
171 | void setDocumentId( const QString & ); | 171 | void setDocumentId( const QString & ); |
172 | 172 | ||
173 | void saveLayout(KConfig *config, const QString &group) const; | 173 | void saveLayout(KConfig *config, const QString &group) const; |
174 | void restoreLayout(KConfig *config, const QString &group); | 174 | void restoreLayout(KConfig *config, const QString &group); |
175 | /** Create a popup menu to set categories */ | 175 | /** Create a popup menu to set categories */ |
176 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); | 176 | QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); |
177 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} | 177 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} |
178 | QString getWhatsThisText(QPoint p); | 178 | QString getWhatsThisText(QPoint p); |
179 | void clearList() {mTodoListView->clear(); } | 179 | void clearList() {mTodoListView->clear(); } |
180 | 180 | ||
181 | public slots: | 181 | public slots: |
182 | void updateView(); | 182 | void updateView(); |
183 | void updateConfig(); | 183 | void updateConfig(); |
184 | 184 | ||
185 | void changeEventDisplay(Event *, int); | 185 | void changeEventDisplay(Event *, int); |
186 | 186 | ||
187 | void showDates(const QDate &start, const QDate &end); | 187 | void showDates(const QDate &start, const QDate &end); |
188 | void showEvents(QPtrList<Event> eventList); | 188 | void showEvents(QPtrList<Event> eventList); |
189 | 189 | ||
190 | void clearSelection(); | 190 | void clearSelection(); |
191 | void jumpToDate (); | 191 | void jumpToDate (); |
192 | 192 | ||
193 | void editItem(QListViewItem *item); | 193 | void editItem(QListViewItem *item); |
194 | void showItem(QListViewItem *item,const QPoint &,int); | 194 | void showItem(QListViewItem *item,const QPoint &,int); |
195 | void popupMenu(QListViewItem *item,const QPoint &,int); | 195 | void popupMenu(QListViewItem *item,const QPoint &,int); |
196 | void newTodo(); | 196 | void newTodo(); |
197 | void newSubTodo(); | 197 | void newSubTodo(); |
198 | void unparentTodo(); | 198 | void unparentTodo(); |
199 | void reparentTodo(); | 199 | void reparentTodo(); |
200 | void showTodo(); | 200 | void showTodo(); |
201 | void editTodo(); | 201 | void editTodo(); |
202 | void cloneTodo(); | 202 | void cloneTodo(); |
203 | void cancelTodo(); | 203 | void cancelTodo(); |
204 | void moveTodo(); | 204 | void moveTodo(); |
205 | void beamTodo(); | 205 | void beamTodo(); |
206 | void deleteTodo(); | 206 | void deleteTodo(); |
207 | 207 | ||
208 | void setNewPriority(int); | 208 | void setNewPriority(int); |
209 | void setNewPercentage(int); | 209 | void setNewPercentage(int); |
210 | void changedCategories(int); | 210 | void changedCategories(int); |
211 | 211 | ||
212 | void setAllOpen(); | 212 | void setAllOpen(); |
213 | void setAllClose(); | 213 | void setAllClose(); |
214 | void setAllFlat(); | 214 | void setAllFlat(); |
215 | void displayAllFlat(); | 215 | void displayAllFlat(); |
216 | 216 | ||
217 | void purgeCompleted(); | 217 | void purgeCompleted(); |
218 | void toggleCompleted(); | 218 | void toggleCompleted(); |
219 | void toggleRunning(); | 219 | void toggleRunning(); |
220 | void toggleQuickTodo(); | 220 | void toggleQuickTodo(); |
221 | void updateTodo( Todo *, int ); | 221 | void updateTodo( Todo *, int ); |
222 | 222 | ||
223 | void itemClicked(QListViewItem *); | 223 | void itemClicked(QListViewItem *); |
224 | void itemStateChanged(QListViewItem *); | 224 | void itemStateChanged(QListViewItem *); |
225 | void modified(bool); | 225 | void modified(bool); |
226 | void itemDoubleClicked(QListViewItem *item); | 226 | void itemDoubleClicked(QListViewItem *item); |
227 | void resetFocusToList(); | ||
227 | 228 | ||
228 | signals: | 229 | signals: |
229 | void newTodoSignal(); | 230 | void newTodoSignal(); |
230 | void newSubTodoSignal(Todo *); | 231 | void newSubTodoSignal(Todo *); |
231 | void unparentTodoSignal(Todo *); | 232 | void unparentTodoSignal(Todo *); |
232 | void reparentTodoSignal( Todo *,Todo * ); | 233 | void reparentTodoSignal( Todo *,Todo * ); |
233 | void showTodoSignal(Todo *); | 234 | void showTodoSignal(Todo *); |
234 | 235 | ||
235 | void editTodoSignal(Todo *); | 236 | void editTodoSignal(Todo *); |
236 | void deleteTodoSignal(Todo *); | 237 | void deleteTodoSignal(Todo *); |
237 | void todoModifiedSignal (Todo *, int); | 238 | void todoModifiedSignal (Todo *, int); |
238 | 239 | ||
239 | void isModified(bool); | 240 | void isModified(bool); |
240 | void cloneTodoSignal( Incidence * ); | 241 | void cloneTodoSignal( Incidence * ); |
241 | void cancelTodoSignal( Incidence * ); | 242 | void cancelTodoSignal( Incidence * ); |
242 | void moveTodoSignal( Incidence * ); | 243 | void moveTodoSignal( Incidence * ); |
243 | void beamTodoSignal( Incidence * ); | 244 | void beamTodoSignal( Incidence * ); |
244 | void purgeCompletedSignal(); | 245 | void purgeCompletedSignal(); |
245 | 246 | ||
246 | protected slots: | 247 | protected slots: |
247 | void toggleRunningItem(); | 248 | void toggleRunningItem(); |
248 | void paintNeeded(); | 249 | void paintNeeded(); |
249 | void processSelectionChange(); | 250 | void processSelectionChange(); |
250 | void addQuickTodo(); | 251 | void addQuickTodo(); |
251 | void setTodoModified( Todo* ); | 252 | void setTodoModified( Todo* ); |
252 | void todoModified(Todo *, int ); | 253 | void todoModified(Todo *, int ); |
253 | 254 | ||
254 | private: | 255 | private: |
255 | /* | 256 | /* |
256 | * the TodoEditor approach is rather unscaling in the long | 257 | * the TodoEditor approach is rather unscaling in the long |
257 | * run. | 258 | * run. |
258 | * Korganizer keeps it in memory and we need to update | 259 | * Korganizer keeps it in memory and we need to update |
259 | * 1. make KOTodoViewItem a QObject again? | 260 | * 1. make KOTodoViewItem a QObject again? |
260 | * 2. add a public method for setting one todo modified? | 261 | * 2. add a public method for setting one todo modified? |
261 | * 3. add a private method for setting a todo modified + friend here? | 262 | * 3. add a private method for setting a todo modified + friend here? |
262 | * -- zecke 2002-07-08 | 263 | * -- zecke 2002-07-08 |
263 | */ | 264 | */ |
264 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; | 265 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; |
265 | friend class KOTodoListView; | 266 | friend class KOTodoListView; |
266 | void paintEvent(QPaintEvent * pevent); | 267 | void paintEvent(QPaintEvent * pevent); |
267 | bool mPendingUpdateBeforeRepaint; | 268 | bool mPendingUpdateBeforeRepaint; |
268 | friend class KOTodoViewItem; | 269 | friend class KOTodoViewItem; |
269 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 270 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
270 | void restoreItemState( QListViewItem * ); | 271 | void restoreItemState( QListViewItem * ); |
271 | 272 | ||
272 | bool checkTodo( Todo * ); | 273 | bool checkTodo( Todo * ); |
273 | bool isFlatDisplay; | 274 | bool isFlatDisplay; |
274 | void setOpen( QListViewItem*, bool setOpen); | 275 | void setOpen( QListViewItem*, bool setOpen); |
275 | KOTodoListView *mTodoListView; | 276 | KOTodoListView *mTodoListView; |
276 | QPopupMenu *mItemPopupMenu; | 277 | QPopupMenu *mItemPopupMenu; |
277 | QPopupMenu *mPopupMenu; | 278 | QPopupMenu *mPopupMenu; |
278 | QPopupMenu *mPriorityPopupMenu; | 279 | QPopupMenu *mPriorityPopupMenu; |
279 | QPopupMenu *mPercentageCompletedPopupMenu; | 280 | QPopupMenu *mPercentageCompletedPopupMenu; |
280 | QPopupMenu *mCategoryPopupMenu; | 281 | QPopupMenu *mCategoryPopupMenu; |
281 | 282 | ||
282 | QMap<int, int> mPercentage; | 283 | QMap<int, int> mPercentage; |
283 | QMap<int, int> mPriority; | 284 | QMap<int, int> mPriority; |
284 | QMap<int, QString> mCategory; | 285 | QMap<int, QString> mCategory; |
285 | KOTodoViewItem *mActiveItem; | 286 | KOTodoViewItem *mActiveItem; |
286 | 287 | ||
287 | QMap<Todo *,KOTodoViewItem *> mTodoMap; | 288 | QMap<Todo *,KOTodoViewItem *> mTodoMap; |
288 | QString mName; | 289 | QString mName; |
289 | 290 | ||
290 | DocPrefs *mDocPrefs; | 291 | DocPrefs *mDocPrefs; |
291 | QString mCurrentDoc; | 292 | QString mCurrentDoc; |
292 | KOQuickTodo *mQuickAdd; | 293 | KOQuickTodo *mQuickAdd; |
293 | bool mBlockUpdate; | 294 | bool mBlockUpdate; |
294 | void keyPressEvent ( QKeyEvent * ) ; | 295 | void keyPressEvent ( QKeyEvent * ) ; |
295 | KOTodoViewItem * pendingSubtodo; | 296 | KOTodoViewItem * pendingSubtodo; |
296 | DateNavigator* mNavigator; | 297 | DateNavigator* mNavigator; |
297 | void storeCurrentItem(); | 298 | void storeCurrentItem(); |
298 | void resetCurrentItem(); | 299 | void resetCurrentItem(); |
299 | Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; | 300 | Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; |
300 | }; | 301 | }; |
301 | 302 | ||
302 | #endif | 303 | #endif |