summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 99e6a3a..c5fae17 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,287 +1,294 @@
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 <kiconloader.h> 39#include <kiconloader.h>
40#include <kmessagebox.h> 40#include <kmessagebox.h>
41 41
42#include <libkcal/icaldrag.h> 42#include <libkcal/icaldrag.h>
43#include <libkcal/vcaldrag.h> 43#include <libkcal/vcaldrag.h>
44#include <libkcal/calfilter.h> 44#include <libkcal/calfilter.h>
45#include <libkcal/dndfactory.h> 45#include <libkcal/dndfactory.h>
46#include <libkcal/calendarresources.h> 46#include <libkcal/calendarresources.h>
47#include <libkcal/resourcecalendar.h> 47#include <libkcal/resourcecalendar.h>
48#include <kresources/resourceselectdialog.h> 48#include <kresources/resourceselectdialog.h>
49#include <libkcal/kincidenceformatter.h> 49#include <libkcal/kincidenceformatter.h>
50#ifndef DESKTOP_VERSION 50#ifndef DESKTOP_VERSION
51#include <qpe/qpeapplication.h> 51#include <qpe/qpeapplication.h>
52#else 52#else
53#include <qapplication.h> 53#include <qapplication.h>
54#endif 54#endif
55#ifndef KORG_NOPRINTER 55#ifndef KORG_NOPRINTER
56#include "calprinter.h" 56#include "calprinter.h"
57#endif 57#endif
58#include "docprefs.h" 58#include "docprefs.h"
59 59
60#include "kotodoview.h" 60#include "kotodoview.h"
61using namespace KOrg; 61using namespace KOrg;
62 62
63 63
64KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 64KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
65 QDialog( parent, name, true ) 65 QDialog( parent, name, true )
66{ 66{
67 mTodo = todo; 67 mTodo = todo;
68 setCaption( i18n("Stop todo") ); 68 setCaption( i18n("Stop todo") );
69 QVBoxLayout* lay = new QVBoxLayout( this ); 69 QVBoxLayout* lay = new QVBoxLayout( this );
70 lay->setSpacing( 3 ); 70 lay->setSpacing( 3 );
71 lay->setMargin( 3 ); 71 lay->setMargin( 3 );
72 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this ); 72 QLabel * lab = new QLabel( i18n("%1\nis running!").arg( todo->summary() ), this );
73 lay->addWidget( lab ); 73 lay->addWidget( lab );
74 lab->setAlignment( AlignHCenter ); 74 lab->setAlignment( AlignHCenter );
75 75
76 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 76 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
77 lay->addWidget( ok ); 77 lay->addWidget( ok );
78 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 78 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
79 lay->addWidget( cancel ); 79 lay->addWidget( cancel );
80 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 80 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
81 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 81 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
82 ok = new QPushButton( i18n("Stop - do not save"), this ); 82 ok = new QPushButton( i18n("Stop - do not save"), this );
83 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 83 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
84 lay->addWidget( ok ); 84 lay->addWidget( ok );
85 resize( 200, 200 ); 85 resize( 200, 200 );
86} 86}
87 87
88void KOStopTodoPrefs::accept() 88void KOStopTodoPrefs::accept()
89{ 89{
90 qDebug("KOStopTodoPrefs::accept() "); 90 qDebug("KOStopTodoPrefs::accept() ");
91
92
93#if 0
94 t->setRunningFalse( comment );
95
96 t->setRunning( false );
97#endif
98
91 QDialog::accept(); 99 QDialog::accept();
92} 100}
93void KOStopTodoPrefs::doNotSave() 101void KOStopTodoPrefs::doNotSave()
94{ 102{
95
96 int result = KMessageBox::warningContinueCancel(this, 103 int result = KMessageBox::warningContinueCancel(this,
97 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() ); 104 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary() );
98 if (result != KMessageBox::Continue) return; 105 if (result != KMessageBox::Continue) return;
99 mTodo->stopRunning(); 106 mTodo->stopRunning();
100 QDialog::accept(); 107 QDialog::accept();
101} 108}
102 109
103 110
104class KOTodoViewWhatsThis :public QWhatsThis 111class KOTodoViewWhatsThis :public QWhatsThis
105{ 112{
106public: 113public:
107 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 114 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
108 115
109protected: 116protected:
110 virtual QString text( const QPoint& p) 117 virtual QString text( const QPoint& p)
111 { 118 {
112 return _view->getWhatsThisText(p) ; 119 return _view->getWhatsThisText(p) ;
113 } 120 }
114private: 121private:
115 QWidget* _wid; 122 QWidget* _wid;
116 KOTodoView * _view; 123 KOTodoView * _view;
117}; 124};
118 125
119KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 126KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
120 const char *name) : 127 const char *name) :
121 KListView(parent,name) 128 KListView(parent,name)
122{ 129{
123 mName = QString ( name ); 130 mName = QString ( name );
124 mCalendar = calendar; 131 mCalendar = calendar;
125#ifndef DESKTOP_VERSION 132#ifndef DESKTOP_VERSION
126 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 133 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
127#endif 134#endif
128 mOldCurrent = 0; 135 mOldCurrent = 0;
129 mMousePressed = false; 136 mMousePressed = false;
130 137
131 setAcceptDrops(true); 138 setAcceptDrops(true);
132 viewport()->setAcceptDrops(true); 139 viewport()->setAcceptDrops(true);
133 int size = 16; 140 int size = 16;
134 if (qApp->desktop()->width() < 300 ) 141 if (qApp->desktop()->width() < 300 )
135 size = 12; 142 size = 12;
136 setTreeStepSize( size + 6 ); 143 setTreeStepSize( size + 6 );
137 144
138} 145}
139 146
140void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 147void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
141{ 148{
142#ifndef KORG_NODND 149#ifndef KORG_NODND
143// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 150// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
144 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 151 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
145 !QTextDrag::canDecode( e ) ) { 152 !QTextDrag::canDecode( e ) ) {
146 e->ignore(); 153 e->ignore();
147 return; 154 return;
148 } 155 }
149 156
150 mOldCurrent = currentItem(); 157 mOldCurrent = currentItem();
151#endif 158#endif
152} 159}
153 160
154 161
155void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 162void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
156{ 163{
157#ifndef KORG_NODND 164#ifndef KORG_NODND
158// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 165// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
159 166
160 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 167 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
161 !QTextDrag::canDecode( e ) ) { 168 !QTextDrag::canDecode( e ) ) {
162 e->ignore(); 169 e->ignore();
163 return; 170 return;
164 } 171 }
165 172
166 e->accept(); 173 e->accept();
167#endif 174#endif
168} 175}
169 176
170void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 177void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
171{ 178{
172#ifndef KORG_NODND 179#ifndef KORG_NODND
173// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 180// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
174 181
175 setCurrentItem(mOldCurrent); 182 setCurrentItem(mOldCurrent);
176 setSelected(mOldCurrent,true); 183 setSelected(mOldCurrent,true);
177#endif 184#endif
178} 185}
179 186
180void KOTodoListView::contentsDropEvent(QDropEvent *e) 187void KOTodoListView::contentsDropEvent(QDropEvent *e)
181{ 188{
182#ifndef KORG_NODND 189#ifndef KORG_NODND
183// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 190// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
184 191
185 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 192 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
186 !QTextDrag::canDecode( e ) ) { 193 !QTextDrag::canDecode( e ) ) {
187 e->ignore(); 194 e->ignore();
188 return; 195 return;
189 } 196 }
190 197
191 DndFactory factory( mCalendar ); 198 DndFactory factory( mCalendar );
192 Todo *todo = factory.createDropTodo(e); 199 Todo *todo = factory.createDropTodo(e);
193 200
194 if (todo) { 201 if (todo) {
195 e->acceptAction(); 202 e->acceptAction();
196 203
197 KOTodoViewItem *destination = 204 KOTodoViewItem *destination =
198 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 205 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
199 Todo *destinationEvent = 0; 206 Todo *destinationEvent = 0;
200 if (destination) destinationEvent = destination->todo(); 207 if (destination) destinationEvent = destination->todo();
201 208
202 Todo *existingTodo = mCalendar->todo(todo->uid()); 209 Todo *existingTodo = mCalendar->todo(todo->uid());
203 210
204 if(existingTodo) { 211 if(existingTodo) {
205 Incidence *to = destinationEvent; 212 Incidence *to = destinationEvent;
206 while(to) { 213 while(to) {
207 if (to->uid() == todo->uid()) { 214 if (to->uid() == todo->uid()) {
208 KMessageBox::sorry(this, 215 KMessageBox::sorry(this,
209 i18n("Cannot move Todo to itself\nor a child of itself"), 216 i18n("Cannot move Todo to itself\nor a child of itself"),
210 i18n("Drop Todo")); 217 i18n("Drop Todo"));
211 delete todo; 218 delete todo;
212 return; 219 return;
213 } 220 }
214 to = to->relatedTo(); 221 to = to->relatedTo();
215 } 222 }
216 internalDrop = true; 223 internalDrop = true;
217 if ( destinationEvent ) 224 if ( destinationEvent )
218 reparentTodoSignal( destinationEvent, existingTodo ); 225 reparentTodoSignal( destinationEvent, existingTodo );
219 else 226 else
220 unparentTodoSignal(existingTodo); 227 unparentTodoSignal(existingTodo);
221 delete todo; 228 delete todo;
222 } else { 229 } else {
223 mCalendar->addTodo(todo); 230 mCalendar->addTodo(todo);
224 emit todoDropped(todo, KOGlobals::EVENTADDED); 231 emit todoDropped(todo, KOGlobals::EVENTADDED);
225 if ( destinationEvent ) 232 if ( destinationEvent )
226 reparentTodoSignal( destinationEvent, todo ); 233 reparentTodoSignal( destinationEvent, todo );
227 } 234 }
228 } 235 }
229 else { 236 else {
230 QString text; 237 QString text;
231 if (QTextDrag::decode(e,text)) { 238 if (QTextDrag::decode(e,text)) {
232 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 239 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
233 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 240 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
234 qDebug("Dropped : " + text); 241 qDebug("Dropped : " + text);
235 QStringList emails = QStringList::split(",",text); 242 QStringList emails = QStringList::split(",",text);
236 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 243 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
237 int pos = (*it).find("<"); 244 int pos = (*it).find("<");
238 QString name = (*it).left(pos); 245 QString name = (*it).left(pos);
239 QString email = (*it).mid(pos); 246 QString email = (*it).mid(pos);
240 if (!email.isEmpty() && todoi) { 247 if (!email.isEmpty() && todoi) {
241 todoi->todo()->addAttendee(new Attendee(name,email)); 248 todoi->todo()->addAttendee(new Attendee(name,email));
242 } 249 }
243 } 250 }
244 } 251 }
245 else { 252 else {
246 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 253 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
247 e->ignore(); 254 e->ignore();
248 } 255 }
249 } 256 }
250#endif 257#endif
251} 258}
252void KOTodoListView::wheelEvent (QWheelEvent *e) 259void KOTodoListView::wheelEvent (QWheelEvent *e)
253{ 260{
254 QListView::wheelEvent (e); 261 QListView::wheelEvent (e);
255} 262}
256 263
257void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 264void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
258{ 265{
259 266
260 QPoint p(contentsToViewport(e->pos())); 267 QPoint p(contentsToViewport(e->pos()));
261 QListViewItem *i = itemAt(p); 268 QListViewItem *i = itemAt(p);
262 bool rootClicked = true; 269 bool rootClicked = true;
263 if (i) { 270 if (i) {
264 // if the user clicked into the root decoration of the item, don't 271 // if the user clicked into the root decoration of the item, don't
265 // try to start a drag! 272 // try to start a drag!
266 int X = p.x(); 273 int X = p.x();
267 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 274 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
268 if (X > header()->sectionPos(0) + 275 if (X > header()->sectionPos(0) +
269 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 276 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
270 itemMargin() +i->height()|| 277 itemMargin() +i->height()||
271 X < header()->sectionPos(0)) { 278 X < header()->sectionPos(0)) {
272 rootClicked = false; 279 rootClicked = false;
273 } 280 }
274 } else { 281 } else {
275 rootClicked = false; 282 rootClicked = false;
276 } 283 }
277#ifndef KORG_NODND 284#ifndef KORG_NODND
278 mMousePressed = false; 285 mMousePressed = false;
279 if (! rootClicked && !( e->button() == RightButton) ) { 286 if (! rootClicked && !( e->button() == RightButton) ) {
280 mPressPos = e->pos(); 287 mPressPos = e->pos();
281 mMousePressed = true; 288 mMousePressed = true;
282 } else { 289 } else {
283 mMousePressed = false; 290 mMousePressed = false;
284 } 291 }
285#endif 292#endif
286 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 293 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
287#ifndef DESKTOP_VERSION 294#ifndef DESKTOP_VERSION