-rw-r--r-- | korganizer/kotodoview.cpp | 13 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 07bfdbf..a12c43e 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,921 +1,930 @@ | |||
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 | mStop = QDateTime::currentDateTime(); |
126 | ete->setTime( QTime::currentTime() ); | 126 | ede->setDate( mStop.date()); |
127 | ete->setTime( mStop.time() ); | ||
127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 128 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
128 | lay->addWidget( ok ); | 129 | lay->addWidget( ok ); |
129 | ok->setDefault( true ); | 130 | ok->setDefault( true ); |
130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 131 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
131 | lay->addWidget( cancel ); | 132 | lay->addWidget( cancel ); |
132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 133 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 134 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
134 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 135 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 136 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
136 | lay->addWidget( ok ); | 137 | lay->addWidget( ok ); |
137 | if (QApplication::desktop()->width() < 320 ) | 138 | if (QApplication::desktop()->width() < 320 ) |
138 | resize( 240, sizeHint().height() ); | 139 | resize( 240, sizeHint().height() ); |
139 | else | 140 | else |
140 | resize( 320, sizeHint().height() ); | 141 | resize( 320, sizeHint().height() ); |
141 | 142 | ||
142 | } | 143 | } |
143 | 144 | ||
144 | void KOStopTodoPrefs::accept() | 145 | void KOStopTodoPrefs::accept() |
145 | { | 146 | { |
146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 147 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 148 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
148 | if ( start > stop ) { | 149 | if ( start > stop ) { |
149 | KMessageBox::sorry(this, | 150 | KMessageBox::sorry(this, |
150 | i18n("The start time is\nafter the end time!"), | 151 | i18n("The start time is\nafter the end time!"), |
151 | i18n("Time mismatch!")); | 152 | i18n("Time mismatch!")); |
152 | return; | 153 | return; |
153 | } | 154 | } |
155 | // restoring the seconds | ||
156 | if ( start == QDateTime( mTodo->runStart().date(), | ||
157 | QTime(mTodo->runStart().time().hour() , mTodo->runStart().time().minute() ) ) ) | ||
158 | start = mTodo->runStart(); | ||
159 | if ( stop == QDateTime( mStop.date(), | ||
160 | QTime( mStop.time().hour() , mStop.time().minute() ) ) ) | ||
161 | stop = mStop; | ||
162 | |||
154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 163 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
155 | QDialog::accept(); | 164 | QDialog::accept(); |
156 | } | 165 | } |
157 | void KOStopTodoPrefs::doNotSave() | 166 | void KOStopTodoPrefs::doNotSave() |
158 | { | 167 | { |
159 | int result = KMessageBox::warningContinueCancel(this, | 168 | 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") ); | 169 | 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; | 170 | if (result != KMessageBox::Continue) return; |
162 | mTodo->stopRunning(); | 171 | mTodo->stopRunning(); |
163 | QDialog::accept(); | 172 | QDialog::accept(); |
164 | } | 173 | } |
165 | 174 | ||
166 | 175 | ||
167 | class KOTodoViewWhatsThis :public QWhatsThis | 176 | class KOTodoViewWhatsThis :public QWhatsThis |
168 | { | 177 | { |
169 | public: | 178 | public: |
170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 179 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
171 | 180 | ||
172 | protected: | 181 | protected: |
173 | virtual QString text( const QPoint& p) | 182 | virtual QString text( const QPoint& p) |
174 | { | 183 | { |
175 | return _view->getWhatsThisText(p) ; | 184 | return _view->getWhatsThisText(p) ; |
176 | } | 185 | } |
177 | private: | 186 | private: |
178 | QWidget* _wid; | 187 | QWidget* _wid; |
179 | KOTodoView * _view; | 188 | KOTodoView * _view; |
180 | }; | 189 | }; |
181 | 190 | ||
182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 191 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
183 | const char *name) : | 192 | const char *name) : |
184 | KListView(parent,name) | 193 | KListView(parent,name) |
185 | { | 194 | { |
186 | mName = QString ( name ); | 195 | mName = QString ( name ); |
187 | mCalendar = calendar; | 196 | mCalendar = calendar; |
188 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 198 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
190 | #endif | 199 | #endif |
191 | mOldCurrent = 0; | 200 | mOldCurrent = 0; |
192 | mMousePressed = false; | 201 | mMousePressed = false; |
193 | 202 | ||
194 | setAcceptDrops(true); | 203 | setAcceptDrops(true); |
195 | viewport()->setAcceptDrops(true); | 204 | viewport()->setAcceptDrops(true); |
196 | int size = 16; | 205 | int size = 16; |
197 | if (qApp->desktop()->width() < 300 ) | 206 | if (qApp->desktop()->width() < 300 ) |
198 | size = 12; | 207 | size = 12; |
199 | setTreeStepSize( size + 6 ); | 208 | setTreeStepSize( size + 6 ); |
200 | 209 | ||
201 | } | 210 | } |
202 | 211 | ||
203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 212 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
204 | { | 213 | { |
205 | #ifndef KORG_NODND | 214 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 215 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 216 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 217 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 218 | e->ignore(); |
210 | return; | 219 | return; |
211 | } | 220 | } |
212 | 221 | ||
213 | mOldCurrent = currentItem(); | 222 | mOldCurrent = currentItem(); |
214 | #endif | 223 | #endif |
215 | } | 224 | } |
216 | 225 | ||
217 | 226 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 227 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 228 | { |
220 | #ifndef KORG_NODND | 229 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 230 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 231 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 232 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 233 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 234 | e->ignore(); |
226 | return; | 235 | return; |
227 | } | 236 | } |
228 | 237 | ||
229 | e->accept(); | 238 | e->accept(); |
230 | #endif | 239 | #endif |
231 | } | 240 | } |
232 | 241 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 242 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 243 | { |
235 | #ifndef KORG_NODND | 244 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 245 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 246 | ||
238 | setCurrentItem(mOldCurrent); | 247 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 248 | setSelected(mOldCurrent,true); |
240 | #endif | 249 | #endif |
241 | } | 250 | } |
242 | 251 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 252 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 253 | { |
245 | #ifndef KORG_NODND | 254 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 255 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 256 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 257 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 258 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 259 | e->ignore(); |
251 | return; | 260 | return; |
252 | } | 261 | } |
253 | 262 | ||
254 | DndFactory factory( mCalendar ); | 263 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 264 | Todo *todo = factory.createDropTodo(e); |
256 | 265 | ||
257 | if (todo) { | 266 | if (todo) { |
258 | e->acceptAction(); | 267 | e->acceptAction(); |
259 | 268 | ||
260 | KOTodoViewItem *destination = | 269 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 270 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 271 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 272 | if (destination) destinationEvent = destination->todo(); |
264 | 273 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 274 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 275 | ||
267 | if(existingTodo) { | 276 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 277 | Incidence *to = destinationEvent; |
269 | while(to) { | 278 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 279 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 280 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 281 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 282 | i18n("Drop Todo")); |
274 | delete todo; | 283 | delete todo; |
275 | return; | 284 | return; |
276 | } | 285 | } |
277 | to = to->relatedTo(); | 286 | to = to->relatedTo(); |
278 | } | 287 | } |
279 | internalDrop = true; | 288 | internalDrop = true; |
280 | if ( destinationEvent ) | 289 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 290 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 291 | else |
283 | unparentTodoSignal(existingTodo); | 292 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 293 | delete todo; |
285 | } else { | 294 | } else { |
286 | mCalendar->addTodo(todo); | 295 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 296 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 297 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 298 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 299 | } |
291 | } | 300 | } |
292 | else { | 301 | else { |
293 | QString text; | 302 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 303 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 304 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 305 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 306 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 307 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 308 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 309 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 310 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 311 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 312 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 313 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 314 | } |
306 | } | 315 | } |
307 | } | 316 | } |
308 | else { | 317 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 318 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 319 | e->ignore(); |
311 | } | 320 | } |
312 | } | 321 | } |
313 | #endif | 322 | #endif |
314 | } | 323 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 324 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 325 | { |
317 | QListView::wheelEvent (e); | 326 | QListView::wheelEvent (e); |
318 | } | 327 | } |
319 | 328 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 329 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 330 | { |
322 | 331 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 332 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 333 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 334 | bool rootClicked = true; |
326 | if (i) { | 335 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 336 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 337 | // try to start a drag! |
329 | int X = p.x(); | 338 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 339 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 340 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 341 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 342 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 343 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 344 | rootClicked = false; |
336 | } | 345 | } |
337 | } else { | 346 | } else { |
338 | rootClicked = false; | 347 | rootClicked = false; |
339 | } | 348 | } |
340 | #ifndef KORG_NODND | 349 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 350 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 351 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 352 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 353 | mMousePressed = true; |
345 | } else { | 354 | } else { |
346 | mMousePressed = false; | 355 | mMousePressed = false; |
347 | } | 356 | } |
348 | #endif | 357 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 358 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 359 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 360 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 361 | QListView::contentsMousePressEvent(e); |
353 | #else | 362 | #else |
354 | QListView::contentsMousePressEvent(e); | 363 | QListView::contentsMousePressEvent(e); |
355 | #endif | 364 | #endif |
356 | } | 365 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 366 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 367 | { |
359 | emit paintNeeded(); | 368 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 369 | QListView::paintEvent( e); |
361 | } | 370 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 371 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 372 | { |
364 | 373 | ||
365 | #ifndef KORG_NODND | 374 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 375 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 376 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 377 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 378 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 379 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 380 | if (item) { |
372 | DndFactory factory( mCalendar ); | 381 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 382 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 383 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 384 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 385 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 386 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 387 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 388 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 389 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 390 | } else |
382 | qDebug("Dnd: Internal move "); | 391 | qDebug("Dnd: Internal move "); |
383 | 392 | ||
384 | } else { | 393 | } else { |
385 | if ( !internalDrop ) { | 394 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 395 | qDebug("Dnd: External Copy"); |
387 | } else | 396 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 397 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 398 | } |
390 | } | 399 | } |
391 | } | 400 | } |
392 | #endif | 401 | #endif |
393 | } | 402 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 403 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 404 | { |
396 | if ( !e->isAutoRepeat() ) { | 405 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 406 | mFlagKeyPressed = false; |
398 | } | 407 | } |
399 | } | 408 | } |
400 | 409 | ||
401 | 410 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 411 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 412 | { |
404 | qApp->processEvents(); | 413 | qApp->processEvents(); |
405 | if ( !isVisible() ) { | 414 | if ( !isVisible() ) { |
406 | e->ignore(); | 415 | e->ignore(); |
407 | return; | 416 | return; |
408 | } | 417 | } |
409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 418 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
410 | e->ignore(); | 419 | e->ignore(); |
411 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 420 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
412 | return; | 421 | return; |
413 | } | 422 | } |
414 | if (! e->isAutoRepeat() ) | 423 | if (! e->isAutoRepeat() ) |
415 | mFlagKeyPressed = true; | 424 | mFlagKeyPressed = true; |
416 | QListViewItem* cn; | 425 | QListViewItem* cn; |
417 | if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { | 426 | if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { |
418 | cn = currentItem(); | 427 | cn = currentItem(); |
419 | if ( cn ) { | 428 | if ( cn ) { |
420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 429 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
421 | if ( ci ){ | 430 | if ( ci ){ |
422 | if ( e->state() == ShiftButton ) | 431 | if ( e->state() == ShiftButton ) |
423 | ci->setOn( false ); | 432 | ci->setOn( false ); |
424 | else | 433 | else |
425 | ci->setOn( true ); | 434 | ci->setOn( true ); |
426 | cn = cn->itemBelow(); | 435 | cn = cn->itemBelow(); |
427 | if ( cn ) { | 436 | if ( cn ) { |
428 | setCurrentItem ( cn ); | 437 | setCurrentItem ( cn ); |
429 | ensureItemVisible ( cn ); | 438 | ensureItemVisible ( cn ); |
430 | } | 439 | } |
431 | 440 | ||
432 | } | 441 | } |
433 | } | 442 | } |
434 | 443 | ||
435 | e->accept(); | 444 | e->accept(); |
436 | return; | 445 | return; |
437 | } | 446 | } |
438 | 447 | ||
439 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 448 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
440 | switch ( e->key() ) { | 449 | switch ( e->key() ) { |
441 | case Qt::Key_Down: | 450 | case Qt::Key_Down: |
442 | case Qt::Key_Up: | 451 | case Qt::Key_Up: |
443 | QListView::keyPressEvent ( e ); | 452 | QListView::keyPressEvent ( e ); |
444 | e->accept(); | 453 | e->accept(); |
445 | break; | 454 | break; |
446 | case Qt::Key_Left: | 455 | case Qt::Key_Left: |
447 | case Qt::Key_Right: | 456 | case Qt::Key_Right: |
448 | QListView::keyPressEvent ( e ); | 457 | QListView::keyPressEvent ( e ); |
449 | e->accept(); | 458 | e->accept(); |
450 | return; | 459 | return; |
451 | break; | 460 | break; |
452 | default: | 461 | default: |
453 | e->ignore(); | 462 | e->ignore(); |
454 | break; | 463 | break; |
455 | } | 464 | } |
456 | return; | 465 | return; |
457 | } | 466 | } |
458 | e->ignore(); | 467 | e->ignore(); |
459 | } | 468 | } |
460 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 469 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
461 | { | 470 | { |
462 | QListView::contentsMouseReleaseEvent(e); | 471 | QListView::contentsMouseReleaseEvent(e); |
463 | mMousePressed = false; | 472 | mMousePressed = false; |
464 | } | 473 | } |
465 | 474 | ||
466 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 475 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
467 | { | 476 | { |
468 | if (!e) return; | 477 | if (!e) return; |
469 | 478 | ||
470 | QPoint vp = contentsToViewport(e->pos()); | 479 | QPoint vp = contentsToViewport(e->pos()); |
471 | 480 | ||
472 | QListViewItem *item = itemAt(vp); | 481 | QListViewItem *item = itemAt(vp); |
473 | 482 | ||
474 | emit double_Clicked(item); | 483 | emit double_Clicked(item); |
475 | if (!item) return; | 484 | if (!item) return; |
476 | 485 | ||
477 | emit doubleClicked(item,vp,0); | 486 | emit doubleClicked(item,vp,0); |
478 | } | 487 | } |
479 | 488 | ||
480 | ///////////////////////////////////////////////////////////////////////////// | 489 | ///////////////////////////////////////////////////////////////////////////// |
481 | 490 | ||
482 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 491 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
483 | QLineEdit(parent) | 492 | QLineEdit(parent) |
484 | { | 493 | { |
485 | setText(i18n("Click to add new Todo")); | 494 | setText(i18n("Click to add new Todo")); |
486 | setFocusPolicy ( QWidget::ClickFocus ); | 495 | setFocusPolicy ( QWidget::ClickFocus ); |
487 | } | 496 | } |
488 | 497 | ||
489 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 498 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
490 | { | 499 | { |
491 | if ( text()==i18n("Click to add new Todo") ) | 500 | if ( text()==i18n("Click to add new Todo") ) |
492 | setText(""); | 501 | setText(""); |
493 | QLineEdit::focusInEvent(ev); | 502 | QLineEdit::focusInEvent(ev); |
494 | } | 503 | } |
495 | 504 | ||
496 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 505 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
497 | { | 506 | { |
498 | setText(i18n("Click to add new Todo")); | 507 | setText(i18n("Click to add new Todo")); |
499 | QLineEdit::focusOutEvent(ev); | 508 | QLineEdit::focusOutEvent(ev); |
500 | } | 509 | } |
501 | 510 | ||
502 | ///////////////////////////////////////////////////////////////////////////// | 511 | ///////////////////////////////////////////////////////////////////////////// |
503 | 512 | ||
504 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 513 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
505 | KOrg::BaseView(calendar,parent,name) | 514 | KOrg::BaseView(calendar,parent,name) |
506 | { | 515 | { |
507 | 516 | ||
508 | mCurItem = 0; | 517 | mCurItem = 0; |
509 | mCurItemRootParent = 0; | 518 | mCurItemRootParent = 0; |
510 | mCurItemParent = 0; | 519 | mCurItemParent = 0; |
511 | mCurItemAbove = 0; | 520 | mCurItemAbove = 0; |
512 | mActiveItem = 0; | 521 | mActiveItem = 0; |
513 | mCategoryPopupMenu = 0; | 522 | mCategoryPopupMenu = 0; |
514 | mPendingUpdateBeforeRepaint = false; | 523 | mPendingUpdateBeforeRepaint = false; |
515 | isFlatDisplay = false; | 524 | isFlatDisplay = false; |
516 | mNavigator = 0; | 525 | mNavigator = 0; |
517 | QBoxLayout *topLayout = new QVBoxLayout(this); | 526 | QBoxLayout *topLayout = new QVBoxLayout(this); |
518 | mName = QString ( name ); | 527 | mName = QString ( name ); |
519 | mBlockUpdate = false; | 528 | mBlockUpdate = false; |
520 | mQuickBar = new QWidget( this ); | 529 | mQuickBar = new QWidget( this ); |
521 | topLayout->addWidget(mQuickBar); | 530 | topLayout->addWidget(mQuickBar); |
522 | 531 | ||
523 | mQuickAdd = new KOQuickTodo(mQuickBar); | 532 | mQuickAdd = new KOQuickTodo(mQuickBar); |
524 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 533 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
525 | quickLayout->addWidget( mQuickAdd ); | 534 | quickLayout->addWidget( mQuickAdd ); |
526 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 535 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
527 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 536 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
528 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 537 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
529 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 538 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
530 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 539 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
531 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 540 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
532 | 541 | ||
533 | int fixwid = mQuickAdd->sizeHint().height(); | 542 | int fixwid = mQuickAdd->sizeHint().height(); |
534 | int fixhei = fixwid; | 543 | int fixhei = fixwid; |
535 | if ( QApplication::desktop()->width() > 800 ) | 544 | if ( QApplication::desktop()->width() > 800 ) |
536 | fixwid = (fixwid*3)/2; | 545 | fixwid = (fixwid*3)/2; |
537 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 546 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
538 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 547 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
539 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 548 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
540 | s_done->setPixmap( SmallIcon("greenhook16")); | 549 | s_done->setPixmap( SmallIcon("greenhook16")); |
541 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 550 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
542 | s_run->setPixmap( SmallIcon("ko16old")); | 551 | s_run->setPixmap( SmallIcon("ko16old")); |
543 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 552 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
544 | 553 | ||
545 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 554 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
546 | 555 | ||
547 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); | 556 | mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); |
548 | mNewSubBut->setEnabled( false ); | 557 | mNewSubBut->setEnabled( false ); |
549 | flat->setFixedWidth( fixwid ); | 558 | flat->setFixedWidth( fixwid ); |
550 | s_done->setFixedWidth( fixwid ); | 559 | s_done->setFixedWidth( fixwid ); |
551 | allopen->setFixedWidth( fixwid ); | 560 | allopen->setFixedWidth( fixwid ); |
552 | allclose->setFixedWidth( fixwid ); | 561 | allclose->setFixedWidth( fixwid ); |
553 | s_run->setFixedWidth( fixwid ); | 562 | s_run->setFixedWidth( fixwid ); |
554 | 563 | ||
555 | flat->setFixedHeight(fixhei ); | 564 | flat->setFixedHeight(fixhei ); |
556 | s_done->setFixedHeight(fixhei ); | 565 | s_done->setFixedHeight(fixhei ); |
557 | allopen->setFixedHeight(fixhei ); | 566 | allopen->setFixedHeight(fixhei ); |
558 | allclose->setFixedHeight(fixhei ); | 567 | allclose->setFixedHeight(fixhei ); |
559 | s_run->setFixedHeight(fixhei ); | 568 | s_run->setFixedHeight(fixhei ); |
560 | mNewSubBut->setFixedHeight(fixhei ); | 569 | mNewSubBut->setFixedHeight(fixhei ); |
561 | 570 | ||
562 | flat->setFocusPolicy( NoFocus ); | 571 | flat->setFocusPolicy( NoFocus ); |
563 | s_done->setFocusPolicy( NoFocus ); | 572 | s_done->setFocusPolicy( NoFocus ); |
564 | allopen->setFocusPolicy( NoFocus ); | 573 | allopen->setFocusPolicy( NoFocus ); |
565 | allclose->setFocusPolicy( NoFocus ); | 574 | allclose->setFocusPolicy( NoFocus ); |
566 | s_run->setFocusPolicy( NoFocus ); | 575 | s_run->setFocusPolicy( NoFocus ); |
567 | mNewSubBut->setFocusPolicy( NoFocus ); | 576 | mNewSubBut->setFocusPolicy( NoFocus ); |
568 | 577 | ||
569 | QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) ); | 578 | QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) ); |
570 | QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) ); | 579 | QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) ); |
571 | QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) ); | 580 | QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) ); |
572 | QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) ); | 581 | QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) ); |
573 | QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) ); | 582 | QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) ); |
574 | QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) ); | 583 | QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) ); |
575 | 584 | ||
576 | quickLayout->addWidget( mNewSubBut ); | 585 | quickLayout->addWidget( mNewSubBut ); |
577 | quickLayout->addWidget( s_done ); | 586 | quickLayout->addWidget( s_done ); |
578 | quickLayout->addWidget( s_run ); | 587 | quickLayout->addWidget( s_run ); |
579 | quickLayout->addWidget( allopen ); | 588 | quickLayout->addWidget( allopen ); |
580 | quickLayout->addWidget( allclose ); | 589 | quickLayout->addWidget( allclose ); |
581 | quickLayout->addWidget( flat ); | 590 | quickLayout->addWidget( flat ); |
582 | 591 | ||
583 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); | 592 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); |
584 | 593 | ||
585 | mTodoListView = new KOTodoListView(calendar,this, name ); | 594 | mTodoListView = new KOTodoListView(calendar,this, name ); |
586 | topLayout->addWidget(mTodoListView); | 595 | topLayout->addWidget(mTodoListView); |
587 | //mTodoListView->header()->setMaximumHeight(30); | 596 | //mTodoListView->header()->setMaximumHeight(30); |
588 | mTodoListView->setRootIsDecorated(true); | 597 | mTodoListView->setRootIsDecorated(true); |
589 | mTodoListView->setAllColumnsShowFocus(true); | 598 | mTodoListView->setAllColumnsShowFocus(true); |
590 | 599 | ||
591 | mTodoListView->setShowSortIndicator(true); | 600 | mTodoListView->setShowSortIndicator(true); |
592 | 601 | ||
593 | mTodoListView->addColumn(i18n("Todo")); | 602 | mTodoListView->addColumn(i18n("Todo")); |
594 | mTodoListView->addColumn(i18n("Prio")); | 603 | mTodoListView->addColumn(i18n("Prio")); |
595 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 604 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
596 | mTodoListView->addColumn(i18n("Complete")); | 605 | mTodoListView->addColumn(i18n("Complete")); |
597 | mTodoListView->setColumnAlignment(2,AlignCenter); | 606 | mTodoListView->setColumnAlignment(2,AlignCenter); |
598 | 607 | ||
599 | mTodoListView->addColumn(i18n("Due Date")); | 608 | mTodoListView->addColumn(i18n("Due Date")); |
600 | mTodoListView->setColumnAlignment(3,AlignLeft); | 609 | mTodoListView->setColumnAlignment(3,AlignLeft); |
601 | mTodoListView->addColumn(i18n("Due Time")); | 610 | mTodoListView->addColumn(i18n("Due Time")); |
602 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 611 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
603 | 612 | ||
604 | mTodoListView->addColumn(i18n("Start Date")); | 613 | mTodoListView->addColumn(i18n("Start Date")); |
605 | mTodoListView->setColumnAlignment(5,AlignLeft); | 614 | mTodoListView->setColumnAlignment(5,AlignLeft); |
606 | mTodoListView->addColumn(i18n("Start Time")); | 615 | mTodoListView->addColumn(i18n("Start Time")); |
607 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 616 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
608 | 617 | ||
609 | //mTodoListView->addColumn(i18n("Cancelled")); | 618 | //mTodoListView->addColumn(i18n("Cancelled")); |
610 | mTodoListView->addColumn(i18n("Categories")); | 619 | mTodoListView->addColumn(i18n("Categories")); |
611 | mTodoListView->addColumn(i18n("Calendar")); | 620 | mTodoListView->addColumn(i18n("Calendar")); |
612 | mTodoListView->addColumn(i18n("Last Modified")); | 621 | mTodoListView->addColumn(i18n("Last Modified")); |
613 | mTodoListView->addColumn(i18n("Created")); | 622 | mTodoListView->addColumn(i18n("Created")); |
614 | mTodoListView->addColumn(i18n("Last Modified Sub")); | 623 | mTodoListView->addColumn(i18n("Last Modified Sub")); |
615 | #if 0 | 624 | #if 0 |
616 | mTodoListView->addColumn(i18n("Sort Id")); | 625 | mTodoListView->addColumn(i18n("Sort Id")); |
617 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 626 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
618 | #endif | 627 | #endif |
619 | 628 | ||
620 | mTodoListView->setMinimumHeight( 60 ); | 629 | mTodoListView->setMinimumHeight( 60 ); |
621 | mTodoListView->setItemsRenameable( true ); | 630 | mTodoListView->setItemsRenameable( true ); |
622 | mTodoListView->setRenameable( 0 ); | 631 | mTodoListView->setRenameable( 0 ); |
623 | mTodoListView->setColumnWidth( 0, 120 ); | 632 | mTodoListView->setColumnWidth( 0, 120 ); |
624 | int iii = 0; | 633 | int iii = 0; |
625 | for ( iii = 0; iii< 12 ; ++iii ) | 634 | for ( iii = 0; iii< 12 ; ++iii ) |
626 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 635 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
627 | 636 | ||
628 | 637 | ||
629 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 638 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
630 | 639 | ||
631 | mPriorityPopupMenu = new QPopupMenu(this); | 640 | mPriorityPopupMenu = new QPopupMenu(this); |
632 | for (int i = 1; i <= 5; i++) { | 641 | for (int i = 1; i <= 5; i++) { |
633 | QString label = QString ("%1").arg (i); | 642 | QString label = QString ("%1").arg (i); |
634 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 643 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
635 | } | 644 | } |
636 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 645 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
637 | 646 | ||
638 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 647 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
639 | for (int i = 0; i <= 100; i+=20) { | 648 | for (int i = 0; i <= 100; i+=20) { |
640 | QString label = QString ("%1 %").arg (i); | 649 | QString label = QString ("%1 %").arg (i); |
641 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 650 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
642 | } | 651 | } |
643 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 652 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
644 | 653 | ||
645 | 654 | ||
646 | mCategoryPopupMenu = new QPopupMenu (this); | 655 | mCategoryPopupMenu = new QPopupMenu (this); |
647 | mCategoryPopupMenu->setCheckable (true); | 656 | mCategoryPopupMenu->setCheckable (true); |
648 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 657 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
649 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 658 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
650 | 659 | ||
651 | mCalPopupMenu = new QPopupMenu (this); | 660 | mCalPopupMenu = new QPopupMenu (this); |
652 | mCalPopupMenu->setCheckable (true); | 661 | mCalPopupMenu->setCheckable (true); |
653 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 662 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
654 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 663 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
655 | 664 | ||
656 | 665 | ||
657 | 666 | ||
658 | 667 | ||
659 | mItemPopupMenu = new QPopupMenu(this); | 668 | mItemPopupMenu = new QPopupMenu(this); |
660 | mItemPopupMenu->insertItem(i18n("Show"), this, | 669 | mItemPopupMenu->insertItem(i18n("Show"), this, |
661 | SLOT (showTodo())); | 670 | SLOT (showTodo())); |
662 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 671 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
663 | SLOT (editTodo())); | 672 | SLOT (editTodo())); |
664 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 673 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
665 | SLOT (deleteTodo())); | 674 | SLOT (deleteTodo())); |
666 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 675 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
667 | SLOT (cloneTodo())); | 676 | SLOT (cloneTodo())); |
668 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 677 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
669 | SLOT (moveTodo())); | 678 | SLOT (moveTodo())); |
670 | #ifndef DESKTOP_VERSION | 679 | #ifndef DESKTOP_VERSION |
671 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 680 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
672 | SLOT (beamTodo())); | 681 | SLOT (beamTodo())); |
673 | #endif | 682 | #endif |
674 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 683 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
675 | SLOT (cancelTodo())); | 684 | SLOT (cancelTodo())); |
676 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 685 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
677 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 686 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
678 | mItemPopupMenu->insertSeparator(); | 687 | mItemPopupMenu->insertSeparator(); |
679 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 688 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
680 | SLOT (toggleRunningItem())); | 689 | SLOT (toggleRunningItem())); |
681 | mItemPopupMenu->insertSeparator(); | 690 | mItemPopupMenu->insertSeparator(); |
682 | /* | 691 | /* |
683 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 692 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
684 | SLOT (newTodo())); | 693 | SLOT (newTodo())); |
685 | */ | 694 | */ |
686 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 695 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
687 | SLOT (newSubTodo())); | 696 | SLOT (newSubTodo())); |
688 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 697 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
689 | SLOT (unparentTodo()),0,21); | 698 | SLOT (unparentTodo()),0,21); |
690 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 699 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
691 | SLOT (reparentTodo()),0,22); | 700 | SLOT (reparentTodo()),0,22); |
692 | mItemPopupMenu->insertSeparator(); | 701 | mItemPopupMenu->insertSeparator(); |
693 | #if 0 | 702 | #if 0 |
694 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 703 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
695 | this, SLOT( purgeCompleted() ) ); | 704 | this, SLOT( purgeCompleted() ) ); |
696 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 705 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
697 | this, SLOT( toggleCompleted() ),0, 33 ); | 706 | this, SLOT( toggleCompleted() ),0, 33 ); |
698 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 707 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
699 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 708 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
700 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 709 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
701 | this, SLOT( toggleRunning() ),0, 35 ); | 710 | this, SLOT( toggleRunning() ),0, 35 ); |
702 | 711 | ||
703 | #endif | 712 | #endif |
704 | mPopupMenu = new QPopupMenu(this); | 713 | mPopupMenu = new QPopupMenu(this); |
705 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 714 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
706 | SLOT (newTodo()),0,1); | 715 | SLOT (newTodo()),0,1); |
707 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 716 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
708 | this, SLOT(purgeCompleted()),0,2); | 717 | this, SLOT(purgeCompleted()),0,2); |
709 | mPopupMenu->insertItem(i18n("Show Completed"), | 718 | mPopupMenu->insertItem(i18n("Show Completed"), |
710 | this, SLOT( toggleCompleted() ),0,3 ); | 719 | this, SLOT( toggleCompleted() ),0,3 ); |
711 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 720 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
712 | this, SLOT( toggleRunning() ),0,5 ); | 721 | this, SLOT( toggleRunning() ),0,5 ); |
713 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 722 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
714 | this, SLOT( setAllOpen() ),0,6 ); | 723 | this, SLOT( setAllOpen() ),0,6 ); |
715 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 724 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
716 | this, SLOT( setAllClose() ),0,7 ); | 725 | this, SLOT( setAllClose() ),0,7 ); |
717 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 726 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
718 | this, SLOT( setAllFlat() ),0,8 ); | 727 | this, SLOT( setAllFlat() ),0,8 ); |
719 | mPopupMenu->insertSeparator(); | 728 | mPopupMenu->insertSeparator(); |
720 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 729 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
721 | this, SLOT( toggleQuickTodo() ),0,4 ); | 730 | this, SLOT( toggleQuickTodo() ),0,4 ); |
722 | mDocPrefs = new DocPrefs( name ); | 731 | mDocPrefs = new DocPrefs( name ); |
723 | 732 | ||
724 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 733 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
725 | mPopupMenu->setCheckable( true ); | 734 | mPopupMenu->setCheckable( true ); |
726 | mItemPopupMenu->setCheckable( true ); | 735 | mItemPopupMenu->setCheckable( true ); |
727 | 736 | ||
728 | 737 | ||
729 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 738 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
730 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 739 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
731 | 740 | ||
732 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 741 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
733 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 742 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
734 | 743 | ||
735 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 744 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
736 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 745 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
737 | 746 | ||
738 | 747 | ||
739 | // Double clicking conflicts with opening/closing the subtree | 748 | // Double clicking conflicts with opening/closing the subtree |
740 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 749 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
741 | SLOT( editItem( QListViewItem *) ) ); | 750 | SLOT( editItem( QListViewItem *) ) ); |
742 | /* | 751 | /* |
743 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 752 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
744 | const QPoint &,int ) ), | 753 | const QPoint &,int ) ), |
745 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 754 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
746 | */ | 755 | */ |
747 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 756 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
748 | const QPoint &,int ) ), | 757 | const QPoint &,int ) ), |
749 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 758 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
750 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 759 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
751 | SLOT( itemClicked( QListViewItem * ) ) ); | 760 | SLOT( itemClicked( QListViewItem * ) ) ); |
752 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 761 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
753 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 762 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
754 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 763 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
755 | SLOT( updateView() ) ); | 764 | SLOT( updateView() ) ); |
756 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 765 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
757 | SLOT( todoModified(Todo *, int) ) ); | 766 | SLOT( todoModified(Todo *, int) ) ); |
758 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 767 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
759 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 768 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
760 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 769 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
761 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 770 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
762 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 771 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
763 | SLOT( paintNeeded()) ); | 772 | SLOT( paintNeeded()) ); |
764 | 773 | ||
765 | #if 0 | 774 | #if 0 |
766 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 775 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
767 | SLOT(selectionChanged(QListViewItem *))); | 776 | SLOT(selectionChanged(QListViewItem *))); |
768 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 777 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
769 | SLOT(selectionChanged(QListViewItem *))); | 778 | SLOT(selectionChanged(QListViewItem *))); |
770 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 779 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
771 | SLOT(selectionChanged(QListViewItem *))); | 780 | SLOT(selectionChanged(QListViewItem *))); |
772 | #endif | 781 | #endif |
773 | 782 | ||
774 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 783 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
775 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 784 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
776 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 785 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
777 | 786 | ||
778 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 787 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
779 | SLOT( processSelectionChange() ) ); | 788 | SLOT( processSelectionChange() ) ); |
780 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 789 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
781 | SLOT( addQuickTodo() ) ); | 790 | SLOT( addQuickTodo() ) ); |
782 | 791 | ||
783 | } | 792 | } |
784 | 793 | ||
785 | KOTodoView::~KOTodoView() | 794 | KOTodoView::~KOTodoView() |
786 | { | 795 | { |
787 | 796 | ||
788 | #if QT_VERSION >= 0x030000 | 797 | #if QT_VERSION >= 0x030000 |
789 | 798 | ||
790 | #else | 799 | #else |
791 | delete mKOTodoViewWhatsThis; | 800 | delete mKOTodoViewWhatsThis; |
792 | #endif | 801 | #endif |
793 | 802 | ||
794 | delete mDocPrefs; | 803 | delete mDocPrefs; |
795 | } | 804 | } |
796 | QString KOTodoView::getWhatsThisText(QPoint p) | 805 | QString KOTodoView::getWhatsThisText(QPoint p) |
797 | { | 806 | { |
798 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 807 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
799 | if ( item ) | 808 | if ( item ) |
800 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 809 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
801 | KOPrefs::instance()->mWTshowDetails, | 810 | KOPrefs::instance()->mWTshowDetails, |
802 | KOPrefs::instance()->mWTshowCreated, | 811 | KOPrefs::instance()->mWTshowCreated, |
803 | KOPrefs::instance()->mWTshowChanged); | 812 | KOPrefs::instance()->mWTshowChanged); |
804 | return i18n("That is the todo view" ); | 813 | return i18n("That is the todo view" ); |
805 | 814 | ||
806 | } | 815 | } |
807 | 816 | ||
808 | void KOTodoView::jumpToDate () | 817 | void KOTodoView::jumpToDate () |
809 | { | 818 | { |
810 | // if (mActiveItem) { | 819 | // if (mActiveItem) { |
811 | // mActiveItem->todo()); | 820 | // mActiveItem->todo()); |
812 | // if ( mActiveItem->todo()->hasDueDate() ) | 821 | // if ( mActiveItem->todo()->hasDueDate() ) |
813 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 822 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
814 | } | 823 | } |
815 | void KOTodoView::paintNeeded() | 824 | void KOTodoView::paintNeeded() |
816 | { | 825 | { |
817 | if ( mPendingUpdateBeforeRepaint ) { | 826 | if ( mPendingUpdateBeforeRepaint ) { |
818 | updateView(); | 827 | updateView(); |
819 | mPendingUpdateBeforeRepaint = false; | 828 | mPendingUpdateBeforeRepaint = false; |
820 | } | 829 | } |
821 | } | 830 | } |
822 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 831 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
823 | { | 832 | { |
824 | if ( mPendingUpdateBeforeRepaint ) { | 833 | if ( mPendingUpdateBeforeRepaint ) { |
825 | updateView(); | 834 | updateView(); |
826 | mPendingUpdateBeforeRepaint = false; | 835 | mPendingUpdateBeforeRepaint = false; |
827 | } | 836 | } |
828 | KOrg::BaseView::paintEvent( pevent); | 837 | KOrg::BaseView::paintEvent( pevent); |
829 | } | 838 | } |
830 | 839 | ||
831 | void KOTodoView::clearList( bool saveCurrentItem ) // default true | 840 | void KOTodoView::clearList( bool saveCurrentItem ) // default true |
832 | { | 841 | { |
833 | if ( mTodoListView->childCount() ) { | 842 | if ( mTodoListView->childCount() ) { |
834 | if ( saveCurrentItem ) | 843 | if ( saveCurrentItem ) |
835 | storeCurrentItem(); | 844 | storeCurrentItem(); |
836 | mTodoListView->clear(); | 845 | mTodoListView->clear(); |
837 | mTodoMap.clear(); | 846 | mTodoMap.clear(); |
838 | } | 847 | } |
839 | } | 848 | } |
840 | void KOTodoView::updateView() | 849 | void KOTodoView::updateView() |
841 | { | 850 | { |
842 | mActiveItem = 0; | 851 | mActiveItem = 0; |
843 | pendingSubtodo = 0; | 852 | pendingSubtodo = 0; |
844 | if ( mBlockUpdate ) { | 853 | if ( mBlockUpdate ) { |
845 | return; | 854 | return; |
846 | } | 855 | } |
847 | if ( !isVisible() ) { | 856 | if ( !isVisible() ) { |
848 | clearList (); | 857 | clearList (); |
849 | mPendingUpdateBeforeRepaint = true; | 858 | mPendingUpdateBeforeRepaint = true; |
850 | return; | 859 | return; |
851 | } | 860 | } |
852 | //qDebug("KOTodoView::updateView() %x", this); | 861 | //qDebug("KOTodoView::updateView() %x", this); |
853 | if ( isFlatDisplay ) { | 862 | if ( isFlatDisplay ) { |
854 | displayAllFlat(); | 863 | displayAllFlat(); |
855 | return; | 864 | return; |
856 | } | 865 | } |
857 | //qDebug("update "); | 866 | //qDebug("update "); |
858 | // kdDebug() << "KOTodoView::updateView()" << endl; | 867 | // kdDebug() << "KOTodoView::updateView()" << endl; |
859 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 868 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
860 | 869 | ||
861 | clearList (); | 870 | clearList (); |
862 | 871 | ||
863 | if ( mName == "todolistsmall" ) { | 872 | if ( mName == "todolistsmall" ) { |
864 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 873 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
865 | int ps = fo.pointSize() -2; | 874 | int ps = fo.pointSize() -2; |
866 | if ( ps > 12 ) | 875 | if ( ps > 12 ) |
867 | ps -= 2; | 876 | ps -= 2; |
868 | fo.setPointSize( ps ); | 877 | fo.setPointSize( ps ); |
869 | } | 878 | } |
870 | } | 879 | } |
871 | 880 | ||
872 | mTodoListView->setFont( fo ); | 881 | mTodoListView->setFont( fo ); |
873 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 882 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
874 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 883 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
875 | QPtrList<Todo> todoList = calendar()->todos(); | 884 | QPtrList<Todo> todoList = calendar()->todos(); |
876 | 885 | ||
877 | /* | 886 | /* |
878 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 887 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
879 | Event *t; | 888 | Event *t; |
880 | for(t = todoList.first(); t; t = todoList.next()) { | 889 | for(t = todoList.first(); t; t = todoList.next()) { |
881 | kdDebug() << " " << t->getSummary() << endl; | 890 | kdDebug() << " " << t->getSummary() << endl; |
882 | 891 | ||
883 | if (t->getRelatedTo()) { | 892 | if (t->getRelatedTo()) { |
884 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 893 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
885 | } | 894 | } |
886 | 895 | ||
887 | QPtrList<Event> l = t->getRelations(); | 896 | QPtrList<Event> l = t->getRelations(); |
888 | Event *c; | 897 | Event *c; |
889 | for(c=l.first();c;c=l.next()) { | 898 | for(c=l.first();c;c=l.next()) { |
890 | kdDebug() << " - relation: " << c->getSummary() << endl; | 899 | kdDebug() << " - relation: " << c->getSummary() << endl; |
891 | } | 900 | } |
892 | } | 901 | } |
893 | */ | 902 | */ |
894 | 903 | ||
895 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 904 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
896 | // specific order of events. That means that we have to generate parent items | 905 | // specific order of events. That means that we have to generate parent items |
897 | // recursively for proper hierarchical display of Todos. | 906 | // recursively for proper hierarchical display of Todos. |
898 | Todo *todo; | 907 | Todo *todo; |
899 | todo = todoList.first();// todo; todo = todoList.next()) { | 908 | todo = todoList.first();// todo; todo = todoList.next()) { |
900 | while ( todo ) { | 909 | while ( todo ) { |
901 | bool next = true; | 910 | bool next = true; |
902 | // qDebug("todo %s ", todo->summary().latin1()); | 911 | // qDebug("todo %s ", todo->summary().latin1()); |
903 | Incidence *incidence = todo->relatedTo(); | 912 | Incidence *incidence = todo->relatedTo(); |
904 | while ( incidence ) { | 913 | while ( incidence ) { |
905 | if ( incidence->typeID() == todoID ) { | 914 | if ( incidence->typeID() == todoID ) { |
906 | //qDebug("related %s ",incidence->summary().latin1() ); | 915 | //qDebug("related %s ",incidence->summary().latin1() ); |
907 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 916 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
908 | //qDebug("related not found "); | 917 | //qDebug("related not found "); |
909 | todoList.remove( ); | 918 | todoList.remove( ); |
910 | todo = todoList.current(); | 919 | todo = todoList.current(); |
911 | next = false; | 920 | next = false; |
912 | incidence = 0; | 921 | incidence = 0; |
913 | 922 | ||
914 | } else { | 923 | } else { |
915 | //qDebug("related found "); | 924 | //qDebug("related found "); |
916 | incidence = incidence->relatedTo(); | 925 | incidence = incidence->relatedTo(); |
917 | } | 926 | } |
918 | } else | 927 | } else |
919 | incidence = 0; | 928 | incidence = 0; |
920 | } | 929 | } |
921 | if ( next ) | 930 | if ( next ) |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index 9180015..ecd0ad9 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -1,308 +1,309 @@ | |||
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 | QDateTime mStop; | ||
74 | KDateEdit *sde, *ede; | 75 | KDateEdit *sde, *ede; |
75 | KOTimeEdit *ste, *ete; | 76 | KOTimeEdit *ste, *ete; |
76 | 77 | ||
77 | }; | 78 | }; |
78 | 79 | ||
79 | class KOStartTodoPrefs : public QDialog | 80 | class KOStartTodoPrefs : public QDialog |
80 | { | 81 | { |
81 | Q_OBJECT | 82 | Q_OBJECT |
82 | public: | 83 | public: |
83 | KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ; | 84 | KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ; |
84 | 85 | ||
85 | bool stopAll() { return mStopAll; } | 86 | bool stopAll() { return mStopAll; } |
86 | private slots: | 87 | private slots: |
87 | void doStop(); | 88 | void doStop(); |
88 | private: | 89 | private: |
89 | bool mStopAll; | 90 | bool mStopAll; |
90 | 91 | ||
91 | }; | 92 | }; |
92 | 93 | ||
93 | class KOTodoListView : public KListView | 94 | class KOTodoListView : public KListView |
94 | { | 95 | { |
95 | Q_OBJECT | 96 | Q_OBJECT |
96 | public: | 97 | public: |
97 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); | 98 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); |
98 | virtual ~KOTodoListView() {} | 99 | virtual ~KOTodoListView() {} |
99 | 100 | ||
100 | signals: | 101 | signals: |
101 | void paintNeeded(); | 102 | void paintNeeded(); |
102 | void todoDropped(Todo *, int); | 103 | void todoDropped(Todo *, int); |
103 | void double_Clicked(QListViewItem *item); | 104 | void double_Clicked(QListViewItem *item); |
104 | void reparentTodoSignal( Todo *,Todo * ); | 105 | void reparentTodoSignal( Todo *,Todo * ); |
105 | void unparentTodoSignal(Todo *); | 106 | void unparentTodoSignal(Todo *); |
106 | void deleteTodo( Todo * ); | 107 | void deleteTodo( Todo * ); |
107 | protected: | 108 | protected: |
108 | void wheelEvent (QWheelEvent *e); | 109 | void wheelEvent (QWheelEvent *e); |
109 | void contentsDragEnterEvent(QDragEnterEvent *); | 110 | void contentsDragEnterEvent(QDragEnterEvent *); |
110 | void contentsDragMoveEvent(QDragMoveEvent *); | 111 | void contentsDragMoveEvent(QDragMoveEvent *); |
111 | void contentsDragLeaveEvent(QDragLeaveEvent *); | 112 | void contentsDragLeaveEvent(QDragLeaveEvent *); |
112 | void contentsDropEvent(QDropEvent *); | 113 | void contentsDropEvent(QDropEvent *); |
113 | 114 | ||
114 | void contentsMousePressEvent(QMouseEvent *); | 115 | void contentsMousePressEvent(QMouseEvent *); |
115 | void contentsMouseMoveEvent(QMouseEvent *); | 116 | void contentsMouseMoveEvent(QMouseEvent *); |
116 | void contentsMouseReleaseEvent(QMouseEvent *); | 117 | void contentsMouseReleaseEvent(QMouseEvent *); |
117 | void contentsMouseDoubleClickEvent(QMouseEvent *); | 118 | void contentsMouseDoubleClickEvent(QMouseEvent *); |
118 | 119 | ||
119 | private: | 120 | private: |
120 | void paintEvent(QPaintEvent * pevent); | 121 | void paintEvent(QPaintEvent * pevent); |
121 | bool internalDrop; | 122 | bool internalDrop; |
122 | QString mName; | 123 | QString mName; |
123 | Calendar *mCalendar; | 124 | Calendar *mCalendar; |
124 | QPoint mPressPos; | 125 | QPoint mPressPos; |
125 | bool mMousePressed; | 126 | bool mMousePressed; |
126 | QListViewItem *mOldCurrent; | 127 | QListViewItem *mOldCurrent; |
127 | bool mFlagKeyPressed; | 128 | bool mFlagKeyPressed; |
128 | void keyPressEvent ( QKeyEvent * ) ; | 129 | void keyPressEvent ( QKeyEvent * ) ; |
129 | void keyReleaseEvent ( QKeyEvent * ) ; | 130 | void keyReleaseEvent ( QKeyEvent * ) ; |
130 | }; | 131 | }; |
131 | 132 | ||
132 | 133 | ||
133 | /** | 134 | /** |
134 | This is the line-edit on top of the todoview for fast addition of new todos | 135 | This is the line-edit on top of the todoview for fast addition of new todos |
135 | */ | 136 | */ |
136 | class KOQuickTodo : public QLineEdit | 137 | class KOQuickTodo : public QLineEdit |
137 | { | 138 | { |
138 | public: | 139 | public: |
139 | KOQuickTodo(QWidget *parent=0); | 140 | KOQuickTodo(QWidget *parent=0); |
140 | protected: | 141 | protected: |
141 | void focusInEvent(QFocusEvent *ev); | 142 | void focusInEvent(QFocusEvent *ev); |
142 | void focusOutEvent(QFocusEvent *ev); | 143 | void focusOutEvent(QFocusEvent *ev); |
143 | }; | 144 | }; |
144 | 145 | ||
145 | 146 | ||
146 | /** | 147 | /** |
147 | This class provides a multi-column list view of todo events. | 148 | This class provides a multi-column list view of todo events. |
148 | 149 | ||
149 | @short multi-column list view of todo events. | 150 | @short multi-column list view of todo events. |
150 | @author Cornelius Schumacher <schumacher@kde.org> | 151 | @author Cornelius Schumacher <schumacher@kde.org> |
151 | */ | 152 | */ |
152 | class KOTodoView : public KOrg::BaseView | 153 | class KOTodoView : public KOrg::BaseView |
153 | { | 154 | { |
154 | Q_OBJECT | 155 | Q_OBJECT |
155 | public: | 156 | public: |
156 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); | 157 | KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); |
157 | ~KOTodoView(); | 158 | ~KOTodoView(); |
158 | 159 | ||
159 | QPtrList<Incidence> selectedIncidences(); | 160 | QPtrList<Incidence> selectedIncidences(); |
160 | QPtrList<Todo> selectedTodos(); | 161 | QPtrList<Todo> selectedTodos(); |
161 | 162 | ||
162 | DateList selectedDates() | 163 | DateList selectedDates() |
163 | {DateList q; | 164 | {DateList q; |
164 | return q;} | 165 | return q;} |
165 | 166 | ||
166 | /** Return number of shown dates. TodoView does not show dates, */ | 167 | /** Return number of shown dates. TodoView does not show dates, */ |
167 | int currentDateCount() { return 0; } | 168 | int currentDateCount() { return 0; } |
168 | 169 | ||
169 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); | 170 | void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); |
170 | 171 | ||
171 | void setDocumentId( const QString & ); | 172 | void setDocumentId( const QString & ); |
172 | 173 | ||
173 | void saveLayout(KConfig *config, const QString &group) const; | 174 | void saveLayout(KConfig *config, const QString &group) const; |
174 | void restoreLayout(KConfig *config, const QString &group); | 175 | void restoreLayout(KConfig *config, const QString &group); |
175 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} | 176 | void setNavigator( DateNavigator* nav ) {mNavigator = nav;} |
176 | QString getWhatsThisText(QPoint p); | 177 | QString getWhatsThisText(QPoint p); |
177 | void clearList( bool saveCurrentItem = true ); | 178 | void clearList( bool saveCurrentItem = true ); |
178 | 179 | ||
179 | public slots: | 180 | public slots: |
180 | void updateView(); | 181 | void updateView(); |
181 | void updateConfig(); | 182 | void updateConfig(); |
182 | 183 | ||
183 | void changeEventDisplay(Event *, int); | 184 | void changeEventDisplay(Event *, int); |
184 | 185 | ||
185 | void showDates(const QDate &start, const QDate &end); | 186 | void showDates(const QDate &start, const QDate &end); |
186 | void showEvents(QPtrList<Event> eventList); | 187 | void showEvents(QPtrList<Event> eventList); |
187 | 188 | ||
188 | void clearSelection(); | 189 | void clearSelection(); |
189 | void jumpToDate (); | 190 | void jumpToDate (); |
190 | 191 | ||
191 | void editItem(QListViewItem *item); | 192 | void editItem(QListViewItem *item); |
192 | void showItem(QListViewItem *item,const QPoint &,int); | 193 | void showItem(QListViewItem *item,const QPoint &,int); |
193 | void popupMenu(QListViewItem *item,const QPoint &,int); | 194 | void popupMenu(QListViewItem *item,const QPoint &,int); |
194 | void newTodo(); | 195 | void newTodo(); |
195 | void newSubTodo(); | 196 | void newSubTodo(); |
196 | void unparentTodo(); | 197 | void unparentTodo(); |
197 | void reparentTodo(); | 198 | void reparentTodo(); |
198 | void showTodo(); | 199 | void showTodo(); |
199 | void editTodo(); | 200 | void editTodo(); |
200 | void cloneTodo(); | 201 | void cloneTodo(); |
201 | void cancelTodo(); | 202 | void cancelTodo(); |
202 | void moveTodo(); | 203 | void moveTodo(); |
203 | void beamTodo(); | 204 | void beamTodo(); |
204 | void deleteTodo(); | 205 | void deleteTodo(); |
205 | 206 | ||
206 | void setNewPriority(int); | 207 | void setNewPriority(int); |
207 | void setNewPercentage(int); | 208 | void setNewPercentage(int); |
208 | void changedCategories(int); | 209 | void changedCategories(int); |
209 | 210 | ||
210 | void setAllOpen(); | 211 | void setAllOpen(); |
211 | void setAllClose(); | 212 | void setAllClose(); |
212 | void setAllFlat(); | 213 | void setAllFlat(); |
213 | void displayAllFlat(); | 214 | void displayAllFlat(); |
214 | 215 | ||
215 | void purgeCompleted(); | 216 | void purgeCompleted(); |
216 | void toggleCompleted(); | 217 | void toggleCompleted(); |
217 | void toggleRunning(); | 218 | void toggleRunning(); |
218 | void toggleQuickTodo(); | 219 | void toggleQuickTodo(); |
219 | void updateTodo( Todo *, int ); | 220 | void updateTodo( Todo *, int ); |
220 | 221 | ||
221 | void itemClicked(QListViewItem *); | 222 | void itemClicked(QListViewItem *); |
222 | void itemStateChanged(QListViewItem *); | 223 | void itemStateChanged(QListViewItem *); |
223 | void modified(bool); | 224 | void modified(bool); |
224 | void itemDoubleClicked(QListViewItem *item); | 225 | void itemDoubleClicked(QListViewItem *item); |
225 | void resetFocusToList(); | 226 | void resetFocusToList(); |
226 | void fillCategories (); | 227 | void fillCategories (); |
227 | void fillCal (); | 228 | void fillCal (); |
228 | void changedCal (int); | 229 | void changedCal (int); |
229 | 230 | ||
230 | signals: | 231 | signals: |
231 | void newTodoSignal(); | 232 | void newTodoSignal(); |
232 | void newSubTodoSignal(Todo *); | 233 | void newSubTodoSignal(Todo *); |
233 | void unparentTodoSignal(Todo *); | 234 | void unparentTodoSignal(Todo *); |
234 | void reparentTodoSignal( Todo *,Todo * ); | 235 | void reparentTodoSignal( Todo *,Todo * ); |
235 | void showTodoSignal(Todo *); | 236 | void showTodoSignal(Todo *); |
236 | 237 | ||
237 | void editTodoSignal(Todo *); | 238 | void editTodoSignal(Todo *); |
238 | void deleteTodoSignal(Todo *); | 239 | void deleteTodoSignal(Todo *); |
239 | void todoModifiedSignal (Todo *, int); | 240 | void todoModifiedSignal (Todo *, int); |
240 | 241 | ||
241 | void isModified(bool); | 242 | void isModified(bool); |
242 | void cloneTodoSignal( Incidence * ); | 243 | void cloneTodoSignal( Incidence * ); |
243 | void cancelTodoSignal( Incidence * ); | 244 | void cancelTodoSignal( Incidence * ); |
244 | void moveTodoSignal( Incidence * ); | 245 | void moveTodoSignal( Incidence * ); |
245 | void beamTodoSignal( Incidence * ); | 246 | void beamTodoSignal( Incidence * ); |
246 | void purgeCompletedSignal(); | 247 | void purgeCompletedSignal(); |
247 | 248 | ||
248 | protected slots: | 249 | protected slots: |
249 | void toggleRunningItem(); | 250 | void toggleRunningItem(); |
250 | void paintNeeded(); | 251 | void paintNeeded(); |
251 | void processSelectionChange(); | 252 | void processSelectionChange(); |
252 | void addQuickTodo(); | 253 | void addQuickTodo(); |
253 | void setTodoModified( Todo* ); | 254 | void setTodoModified( Todo* ); |
254 | void todoModified(Todo *, int ); | 255 | void todoModified(Todo *, int ); |
255 | 256 | ||
256 | private: | 257 | private: |
257 | void addQuickTodoPar( Todo * parentTodo); | 258 | void addQuickTodoPar( Todo * parentTodo); |
258 | /* | 259 | /* |
259 | * the TodoEditor approach is rather unscaling in the long | 260 | * the TodoEditor approach is rather unscaling in the long |
260 | * run. | 261 | * run. |
261 | * Korganizer keeps it in memory and we need to update | 262 | * Korganizer keeps it in memory and we need to update |
262 | * 1. make KOTodoViewItem a QObject again? | 263 | * 1. make KOTodoViewItem a QObject again? |
263 | * 2. add a public method for setting one todo modified? | 264 | * 2. add a public method for setting one todo modified? |
264 | * 3. add a private method for setting a todo modified + friend here? | 265 | * 3. add a private method for setting a todo modified + friend here? |
265 | * -- zecke 2002-07-08 | 266 | * -- zecke 2002-07-08 |
266 | */ | 267 | */ |
267 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; | 268 | KOTodoViewWhatsThis* mKOTodoViewWhatsThis; |
268 | friend class KOTodoListView; | 269 | friend class KOTodoListView; |
269 | void paintEvent(QPaintEvent * pevent); | 270 | void paintEvent(QPaintEvent * pevent); |
270 | bool mPendingUpdateBeforeRepaint; | 271 | bool mPendingUpdateBeforeRepaint; |
271 | friend class KOTodoViewItem; | 272 | friend class KOTodoViewItem; |
272 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 273 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
273 | void restoreItemState( QListViewItem * ); | 274 | void restoreItemState( QListViewItem * ); |
274 | 275 | ||
275 | bool checkTodo( Todo * ); | 276 | bool checkTodo( Todo * ); |
276 | bool isFlatDisplay; | 277 | bool isFlatDisplay; |
277 | void setOpen( QListViewItem*, bool setOpen); | 278 | void setOpen( QListViewItem*, bool setOpen); |
278 | KOTodoListView *mTodoListView; | 279 | KOTodoListView *mTodoListView; |
279 | QPopupMenu *mItemPopupMenu; | 280 | QPopupMenu *mItemPopupMenu; |
280 | QPopupMenu *mPopupMenu; | 281 | QPopupMenu *mPopupMenu; |
281 | QPopupMenu *mPriorityPopupMenu; | 282 | QPopupMenu *mPriorityPopupMenu; |
282 | QPopupMenu *mPercentageCompletedPopupMenu; | 283 | QPopupMenu *mPercentageCompletedPopupMenu; |
283 | QPopupMenu *mCategoryPopupMenu; | 284 | QPopupMenu *mCategoryPopupMenu; |
284 | QPopupMenu *mCalPopupMenu; | 285 | QPopupMenu *mCalPopupMenu; |
285 | 286 | ||
286 | QMap<int, int> mPercentage; | 287 | QMap<int, int> mPercentage; |
287 | QMap<int, int> mPriority; | 288 | QMap<int, int> mPriority; |
288 | QMap<int, QString> mCategory; | 289 | QMap<int, QString> mCategory; |
289 | KOTodoViewItem *mActiveItem; | 290 | KOTodoViewItem *mActiveItem; |
290 | 291 | ||
291 | QMap<Todo *,KOTodoViewItem *> mTodoMap; | 292 | QMap<Todo *,KOTodoViewItem *> mTodoMap; |
292 | QString mName; | 293 | QString mName; |
293 | QWidget* mQuickBar; | 294 | QWidget* mQuickBar; |
294 | 295 | ||
295 | DocPrefs *mDocPrefs; | 296 | DocPrefs *mDocPrefs; |
296 | QString mCurrentDoc; | 297 | QString mCurrentDoc; |
297 | KOQuickTodo *mQuickAdd; | 298 | KOQuickTodo *mQuickAdd; |
298 | bool mBlockUpdate; | 299 | bool mBlockUpdate; |
299 | void keyPressEvent ( QKeyEvent * ) ; | 300 | void keyPressEvent ( QKeyEvent * ) ; |
300 | KOTodoViewItem * pendingSubtodo; | 301 | KOTodoViewItem * pendingSubtodo; |
301 | DateNavigator* mNavigator; | 302 | DateNavigator* mNavigator; |
302 | void storeCurrentItem(); | 303 | void storeCurrentItem(); |
303 | void resetCurrentItem(); | 304 | void resetCurrentItem(); |
304 | Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; | 305 | Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; |
305 | QPushButton * mNewSubBut; | 306 | QPushButton * mNewSubBut; |
306 | }; | 307 | }; |
307 | 308 | ||
308 | #endif | 309 | #endif |