-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,537 +1,546 @@ | |||
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())); |
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 |