-rw-r--r-- | korganizer/koagenda.cpp | 77 |
1 files changed, 32 insertions, 45 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 2820ca2..66ad4ec 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,937 +1,924 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 66 | { |
67 | setLineWidth(0); | 67 | setLineWidth(0); |
68 | setMargin(0); | 68 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 72 | minutes->start(0, true); |
73 | 73 | ||
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | delete minutes; | 88 | delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | 154 | ||
155 | mTimeBox->raise(); | 155 | mTimeBox->raise(); |
156 | //mTimeBox->setAutoMask(true); | 156 | //mTimeBox->setAutoMask(true); |
157 | minutes->start(5000,true); | 157 | minutes->start(5000,true); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | 172 | ||
173 | mColumns = columns; | 173 | mColumns = columns; |
174 | mRows = rows; | 174 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 176 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 179 | #endif |
180 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
181 | init(); | 181 | init(); |
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
185 | Create an agenda widget with columns columns and one row. This is used for | 185 | Create an agenda widget with columns columns and one row. This is used for |
186 | all-day events. | 186 | all-day events. |
187 | */ | 187 | */ |
188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
189 | QScrollView(parent,name,f) | 189 | QScrollView(parent,name,f) |
190 | { | 190 | { |
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | mNewItemPopup = new QPopupMenu( this ); | 225 | mNewItemPopup = new QPopupMenu( this ); |
226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
227 | QString pathString = ""; | 227 | QString pathString = ""; |
228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
229 | if ( QApplication::desktop()->width() < 480 ) | 229 | if ( QApplication::desktop()->width() < 480 ) |
230 | pathString += "icons16/"; | 230 | pathString += "icons16/"; |
231 | } else | 231 | } else |
232 | pathString += "iconsmini/"; | 232 | pathString += "iconsmini/"; |
233 | 233 | ||
234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
236 | mNewItemPopup->insertSeparator ( ); | 236 | mNewItemPopup->insertSeparator ( ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
243 | #ifndef _WIN32_ | 243 | #ifndef _WIN32_ |
244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
245 | viewport()->setWFlags ( wflags); | 245 | viewport()->setWFlags ( wflags); |
246 | #endif | 246 | #endif |
247 | mGridSpacingX = 80; | 247 | mGridSpacingX = 80; |
248 | mResizeBorderWidth = 8; | 248 | mResizeBorderWidth = 8; |
249 | mScrollBorderWidth = 8; | 249 | mScrollBorderWidth = 8; |
250 | mScrollDelay = 30; | 250 | mScrollDelay = 30; |
251 | mScrollOffset = 10; | 251 | mScrollOffset = 10; |
252 | mPaintPixmap.resize( 20,20); | 252 | mPaintPixmap.resize( 20,20); |
253 | //enableClipper(true); | 253 | //enableClipper(true); |
254 | 254 | ||
255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
256 | // effect. Has to be fixed. | 256 | // effect. Has to be fixed. |
257 | setFocusPolicy(WheelFocus); | 257 | setFocusPolicy(WheelFocus); |
258 | 258 | ||
259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
262 | 262 | ||
263 | mStartCellX = 0; | 263 | mStartCellX = 0; |
264 | mStartCellY = 0; | 264 | mStartCellY = 0; |
265 | mCurrentCellX = 0; | 265 | mCurrentCellX = 0; |
266 | mCurrentCellY = 0; | 266 | mCurrentCellY = 0; |
267 | 267 | ||
268 | mSelectionCellX = 0; | 268 | mSelectionCellX = 0; |
269 | mSelectionYTop = 0; | 269 | mSelectionYTop = 0; |
270 | mSelectionHeight = 0; | 270 | mSelectionHeight = 0; |
271 | 271 | ||
272 | mOldLowerScrollValue = -1; | 272 | mOldLowerScrollValue = -1; |
273 | mOldUpperScrollValue = -1; | 273 | mOldUpperScrollValue = -1; |
274 | 274 | ||
275 | mClickedItem = 0; | 275 | mClickedItem = 0; |
276 | 276 | ||
277 | mActionItem = 0; | 277 | mActionItem = 0; |
278 | mActionType = NOP; | 278 | mActionType = NOP; |
279 | mItemMoved = false; | 279 | mItemMoved = false; |
280 | 280 | ||
281 | mSelectedItem = 0; | 281 | mSelectedItem = 0; |
282 | 282 | ||
283 | // mItems.setAutoDelete(true); | 283 | // mItems.setAutoDelete(true); |
284 | 284 | ||
285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
286 | 286 | ||
287 | viewport()->update(); | 287 | viewport()->update(); |
288 | 288 | ||
289 | setMinimumSize(30, 1); | 289 | setMinimumSize(30, 1); |
290 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 290 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
291 | 291 | ||
292 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 292 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
293 | // controlled in a way that the contents horizontally always fits. Then it is | 293 | // controlled in a way that the contents horizontally always fits. Then it is |
294 | // not necessary to turn off the scrollbar. | 294 | // not necessary to turn off the scrollbar. |
295 | setHScrollBarMode(AlwaysOff); | 295 | setHScrollBarMode(AlwaysOff); |
296 | if ( ! mAllDayMode ) | 296 | if ( ! mAllDayMode ) |
297 | setVScrollBarMode(AlwaysOn); | 297 | setVScrollBarMode(AlwaysOn); |
298 | else | 298 | else |
299 | setVScrollBarMode(AlwaysOff); | 299 | setVScrollBarMode(AlwaysOff); |
300 | 300 | ||
301 | setStartHour(KOPrefs::instance()->mDayBegins); | 301 | setStartHour(KOPrefs::instance()->mDayBegins); |
302 | 302 | ||
303 | calculateWorkingHours(); | 303 | calculateWorkingHours(); |
304 | 304 | ||
305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
306 | SLOT(checkScrollBoundaries(int))); | 306 | SLOT(checkScrollBoundaries(int))); |
307 | 307 | ||
308 | // Create the Marcus Bains line. | 308 | // Create the Marcus Bains line. |
309 | if(mAllDayMode) | 309 | if(mAllDayMode) |
310 | mMarcusBains = 0; | 310 | mMarcusBains = 0; |
311 | else { | 311 | else { |
312 | mMarcusBains = new MarcusBains(this); | 312 | mMarcusBains = new MarcusBains(this); |
313 | addChild(mMarcusBains); | 313 | addChild(mMarcusBains); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOAgenda::clear() | 317 | void KOAgenda::clear() |
318 | { | 318 | { |
319 | KOAgendaItem *item; | 319 | KOAgendaItem *item; |
320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
321 | mUnusedItems.append( item ); | 321 | mUnusedItems.append( item ); |
322 | //item->hide(); | 322 | //item->hide(); |
323 | } | 323 | } |
324 | mItems.clear(); | 324 | mItems.clear(); |
325 | mSelectedItem = 0; | 325 | mSelectedItem = 0; |
326 | clearSelection(); | 326 | clearSelection(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KOAgenda::clearSelection() | 329 | void KOAgenda::clearSelection() |
330 | { | 330 | { |
331 | mSelectionCellX = 0; | 331 | mSelectionCellX = 0; |
332 | mSelectionYTop = 0; | 332 | mSelectionYTop = 0; |
333 | mSelectionHeight = 0; | 333 | mSelectionHeight = 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | void KOAgenda::marcus_bains() | 336 | void KOAgenda::marcus_bains() |
337 | { | 337 | { |
338 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 338 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void KOAgenda::changeColumns(int columns) | 342 | void KOAgenda::changeColumns(int columns) |
343 | { | 343 | { |
344 | if (columns == 0) { | 344 | if (columns == 0) { |
345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | 348 | ||
349 | clear(); | 349 | clear(); |
350 | 350 | ||
351 | mColumns = columns; | 351 | mColumns = columns; |
352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | 352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); |
353 | // init(); | 353 | // init(); |
354 | // update(); | 354 | // update(); |
355 | //qDebug("KOAgenda::changeColumns "); | 355 | //qDebug("KOAgenda::changeColumns "); |
356 | computeSizes(); | 356 | computeSizes(); |
357 | // QResizeEvent event( size(), size() ); | 357 | // QResizeEvent event( size(), size() ); |
358 | 358 | ||
359 | //QApplication::sendEvent( this, &event ); | 359 | //QApplication::sendEvent( this, &event ); |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | This is the eventFilter function, which gets all events from the KOAgendaItems | 363 | This is the eventFilter function, which gets all events from the KOAgendaItems |
364 | contained in the agenda. It has to handle moving and resizing for all items. | 364 | contained in the agenda. It has to handle moving and resizing for all items. |
365 | */ | 365 | */ |
366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
367 | { | 367 | { |
368 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 368 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
369 | switch(event->type()) { | 369 | switch(event->type()) { |
370 | case QEvent::MouseButtonPress: | 370 | case QEvent::MouseButtonPress: |
371 | case QEvent::MouseButtonDblClick: | 371 | case QEvent::MouseButtonDblClick: |
372 | case QEvent::MouseButtonRelease: | 372 | case QEvent::MouseButtonRelease: |
373 | case QEvent::MouseMove: | 373 | case QEvent::MouseMove: |
374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
375 | 375 | ||
376 | case (QEvent::Leave): | 376 | case (QEvent::Leave): |
377 | if (!mActionItem) | 377 | if (!mActionItem) |
378 | setCursor(arrowCursor); | 378 | setCursor(arrowCursor); |
379 | return true; | 379 | return true; |
380 | 380 | ||
381 | default: | 381 | default: |
382 | return QScrollView::eventFilter(object,event); | 382 | return QScrollView::eventFilter(object,event); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
388 | { | 388 | { |
389 | //qDebug("KOAgenda::eventFilter_mous "); | 389 | //qDebug("KOAgenda::eventFilter_mous "); |
390 | QPoint viewportPos; | 390 | QPoint viewportPos; |
391 | if (object != viewport()) { | 391 | if (object != viewport()) { |
392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
393 | } else { | 393 | } else { |
394 | viewportPos = me->pos(); | 394 | viewportPos = me->pos(); |
395 | } | 395 | } |
396 | static int startX = 0; | 396 | static int startX = 0; |
397 | static int startY = 0; | 397 | static int startY = 0; |
398 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 398 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
399 | static bool blockMoving = true; | 399 | static bool blockMoving = true; |
400 | static bool leftMouseDown = false; | 400 | static bool leftMouseDown = false; |
401 | static bool rightMouseDown = false; | ||
402 | static QTime rightClickTime; | ||
403 | bool rightButtonPressed = false; | 401 | bool rightButtonPressed = false; |
404 | switch (me->type()) { | 402 | switch (me->type()) { |
405 | case QEvent::MouseButtonPress: | 403 | case QEvent::MouseButtonPress: |
406 | rightClickTime.restart(); | ||
407 | if (me->button() == LeftButton) { | 404 | if (me->button() == LeftButton) { |
408 | leftMouseDown = true; | 405 | leftMouseDown = true; |
409 | } | 406 | } |
410 | else if (me->button() == RightButton) | 407 | else if (me->button() == RightButton) { |
411 | rightMouseDown = true; | 408 | leftMouseDown = false; |
409 | } | ||
412 | blockMoving = true; | 410 | blockMoving = true; |
413 | startX = viewportPos.x(); | 411 | startX = viewportPos.x(); |
414 | startY = viewportPos.y(); | 412 | startY = viewportPos.y(); |
415 | if (object != viewport()) { | 413 | if (object != viewport()) { // item clicked ************** |
416 | if (me->button() == RightButton) { | 414 | if (me->button() == RightButton) { |
415 | leftMouseDown = false; | ||
417 | mClickedItem = (KOAgendaItem *)object; | 416 | mClickedItem = (KOAgendaItem *)object; |
417 | if (mActionItem ) { | ||
418 | endItemAction(); | ||
419 | } | ||
418 | if (mClickedItem) { | 420 | if (mClickedItem) { |
419 | selectItem(mClickedItem); | 421 | selectItem(mClickedItem); |
420 | } | 422 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
423 | } | ||
424 | return true; | ||
421 | } else if (me->button() == LeftButton) { | 425 | } else if (me->button() == LeftButton) { |
422 | mActionItem = (KOAgendaItem *)object; | 426 | mActionItem = (KOAgendaItem *)object; |
423 | if (mActionItem) { | 427 | if (mActionItem) { |
424 | if ( mSelectionHeight > 0 ) { | 428 | if ( mSelectionHeight > 0 ) { |
425 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 429 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
426 | int selectionYTop = mSelectionYTop; | 430 | int selectionYTop = mSelectionYTop; |
427 | int gridSpacingX = mGridSpacingX; | 431 | int gridSpacingX = mGridSpacingX; |
428 | int selectionHeight = mSelectionHeight; | 432 | int selectionHeight = mSelectionHeight; |
429 | clearSelection(); | 433 | clearSelection(); |
430 | repaintContents( selectionCellX, selectionYTop, | 434 | repaintContents( selectionCellX, selectionYTop, |
431 | gridSpacingX, selectionHeight,false ); | 435 | gridSpacingX, selectionHeight,false ); |
432 | } | 436 | } |
433 | selectItem(mActionItem); | 437 | selectItem(mActionItem); |
434 | Incidence *incidence = mActionItem->incidence(); | 438 | Incidence *incidence = mActionItem->incidence(); |
435 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 439 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
436 | mActionItem = 0; | 440 | mActionItem = 0; |
437 | } else { | 441 | } else { |
438 | startItemAction(viewportPos); | 442 | startItemAction(viewportPos); |
439 | } | 443 | } |
440 | } | 444 | } |
441 | } | 445 | } |
442 | } else { // ---------- viewport() | 446 | } else { // ---------- viewport() |
443 | selectItem(0); | 447 | selectItem(0); |
444 | mActionItem = 0; | 448 | mActionItem = 0; |
445 | if (me->button() == LeftButton ) { | 449 | if (me->button() == LeftButton ) { |
446 | setCursor(arrowCursor); | 450 | setCursor(arrowCursor); |
447 | startSelectAction(viewportPos); | 451 | startSelectAction(viewportPos); |
452 | } else if (me->button() == RightButton ) { | ||
453 | setCursor(arrowCursor); | ||
454 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | ||
455 | endSelectAction( false ); // do not emit new event signal | ||
456 | leftMouseDown = false; // no more leftMouse computation | ||
457 | } | ||
458 | int x,y; | ||
459 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
460 | int gx,gy; | ||
461 | contentsToGrid(x,y,gx,gy); | ||
462 | mCurrentCellX = gx; | ||
463 | mCurrentCellY = gy; | ||
464 | mStartCellX = gx; | ||
465 | mStartCellY = gy; | ||
466 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | ||
448 | } | 467 | } |
449 | } | 468 | } |
450 | break; | 469 | break; |
451 | 470 | ||
452 | case QEvent::MouseButtonRelease: | 471 | case QEvent::MouseButtonRelease: |
453 | if ( rightClickTime.elapsed() > 500 && blockMoving ) | 472 | |
454 | rightButtonPressed = true; | ||
455 | if (object != viewport()) { | 473 | if (object != viewport()) { |
456 | if (me->button() == RightButton || rightButtonPressed ) { | 474 | if (me->button() == LeftButton && leftMouseDown) { |
457 | if ( blockMoving ) { | ||
458 | mClickedItem = (KOAgendaItem *)object; | ||
459 | if (mActionItem ) { | ||
460 | endItemAction(); | ||
461 | } | ||
462 | leftMouseDown = false; // no more leftMouse computation | ||
463 | if (mClickedItem) { | ||
464 | selectItem(mClickedItem); | ||
465 | emit showIncidencePopupSignal(mClickedItem->incidence()); | ||
466 | } | ||
467 | } | ||
468 | } else if (me->button() == LeftButton && leftMouseDown) { | ||
469 | if (mActionItem) { | 475 | if (mActionItem) { |
470 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 476 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
471 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 477 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
472 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 478 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
473 | mScrollUpTimer.stop(); | 479 | mScrollUpTimer.stop(); |
474 | mScrollDownTimer.stop(); | 480 | mScrollDownTimer.stop(); |
475 | mActionItem->resetMove(); | 481 | mActionItem->resetMove(); |
476 | placeSubCells( mActionItem ); | 482 | placeSubCells( mActionItem ); |
477 | // emit startDragSignal( mActionItem->incidence() ); | 483 | // emit startDragSignal( mActionItem->incidence() ); |
478 | setCursor( arrowCursor ); | 484 | setCursor( arrowCursor ); |
479 | mActionItem = 0; | 485 | mActionItem = 0; |
480 | mActionType = NOP; | 486 | mActionType = NOP; |
481 | mItemMoved = 0; | 487 | mItemMoved = 0; |
482 | leftMouseDown = false; | 488 | leftMouseDown = false; |
483 | return true; | 489 | return true; |
484 | } | 490 | } |
485 | endItemAction(); | 491 | endItemAction(); |
486 | } | 492 | } |
487 | } | 493 | } |
488 | 494 | ||
489 | } else { // ---------- viewport() | 495 | } else { // ---------- viewport() |
490 | if (me->button() == RightButton || rightButtonPressed ) { //right click | 496 | if (me->button() == LeftButton && leftMouseDown ) { //left click |
491 | if ( blockMoving ) { // we did mot moved the mouse much - popup menu | ||
492 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | ||
493 | endSelectAction( false ); // do not emit new event signal | ||
494 | leftMouseDown = false; // no more leftMouse computation | ||
495 | } | ||
496 | int x,y; | ||
497 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
498 | int gx,gy; | ||
499 | contentsToGrid(x,y,gx,gy); | ||
500 | mCurrentCellX = gx; | ||
501 | mCurrentCellY = gy; | ||
502 | mStartCellX = gx; | ||
503 | mStartCellY = gy; | ||
504 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | ||
505 | } | ||
506 | } | ||
507 | else if (me->button() == LeftButton && leftMouseDown ) { //left click | ||
508 | endSelectAction( true ); // emit new event signal | 497 | endSelectAction( true ); // emit new event signal |
509 | } | 498 | } |
510 | } | 499 | } |
511 | if (me->button() == LeftButton) | 500 | if (me->button() == LeftButton) |
512 | leftMouseDown = false; | 501 | leftMouseDown = false; |
513 | else if (me->button() == RightButton) | 502 | |
514 | rightMouseDown = false; | ||
515 | break; | 503 | break; |
516 | 504 | ||
517 | case QEvent::MouseMove: | 505 | case QEvent::MouseMove: |
518 | if ( !rightMouseDown && !leftMouseDown ) | 506 | if ( !leftMouseDown ) |
519 | return true; | 507 | return true; |
520 | if ( blockMoving ) { | 508 | if ( blockMoving ) { |
521 | int dX, dY; | 509 | int dX, dY; |
522 | dX = startX - viewportPos.x(); | 510 | dX = startX - viewportPos.x(); |
523 | if ( dX < 0 ) | 511 | if ( dX < 0 ) |
524 | dX = -dX; | 512 | dX = -dX; |
525 | dY = viewportPos.y() - startY; | 513 | dY = viewportPos.y() - startY; |
526 | if ( dY < 0 ) | 514 | if ( dY < 0 ) |
527 | dY = -dY; | 515 | dY = -dY; |
528 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 516 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
529 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 517 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
530 | blockMoving = false; | 518 | blockMoving = false; |
531 | } | 519 | } |
532 | } | 520 | } |
533 | if (object != viewport()) { | 521 | if (object != viewport()) { |
534 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 522 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
535 | if (!moveItem->incidence()->isReadOnly() ) { | 523 | if (!moveItem->incidence()->isReadOnly() ) { |
536 | if (!mActionItem) | 524 | if (!mActionItem) |
537 | setNoActionCursor(moveItem,viewportPos); | 525 | setNoActionCursor(moveItem,viewportPos); |
538 | else { | 526 | else { |
539 | if ( !blockMoving ) | 527 | if ( !blockMoving ) |
540 | performItemAction(viewportPos); | 528 | performItemAction(viewportPos); |
541 | } | 529 | } |
542 | } | 530 | } |
543 | } else { // ---------- viewport() | 531 | } else { // ---------- viewport() |
544 | if ( mActionType == SELECT ) { | 532 | if ( mActionType == SELECT ) { |
545 | performSelectAction( viewportPos ); | 533 | performSelectAction( viewportPos ); |
546 | } | 534 | } |
547 | } | 535 | } |
548 | break; | 536 | break; |
549 | 537 | ||
550 | case QEvent::MouseButtonDblClick: | 538 | case QEvent::MouseButtonDblClick: |
551 | blockMoving = false; | 539 | blockMoving = false; |
552 | leftMouseDown = false; | 540 | leftMouseDown = false; |
553 | rightMouseDown = false; | ||
554 | if (object == viewport()) { | 541 | if (object == viewport()) { |
555 | selectItem(0); | 542 | selectItem(0); |
556 | int x,y; | 543 | int x,y; |
557 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 544 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
558 | int gx,gy; | 545 | int gx,gy; |
559 | contentsToGrid(x,y,gx,gy); | 546 | contentsToGrid(x,y,gx,gy); |
560 | emit newEventSignal(gx,gy); | 547 | emit newEventSignal(gx,gy); |
561 | } else { | 548 | } else { |
562 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 549 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
563 | selectItem(doubleClickedItem); | 550 | selectItem(doubleClickedItem); |
564 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 551 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
565 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 552 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
566 | else | 553 | else |
567 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 554 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
568 | } | 555 | } |
569 | break; | 556 | break; |
570 | 557 | ||
571 | default: | 558 | default: |
572 | break; | 559 | break; |
573 | } | 560 | } |
574 | return true; | 561 | return true; |
575 | } | 562 | } |
576 | 563 | ||
577 | void KOAgenda::newItem( int item ) | 564 | void KOAgenda::newItem( int item ) |
578 | { | 565 | { |
579 | if ( item == 1 ) { //new event | 566 | if ( item == 1 ) { //new event |
580 | newEventSignal(mStartCellX ,mStartCellY ); | 567 | newEventSignal(mStartCellX ,mStartCellY ); |
581 | } else | 568 | } else |
582 | if ( item == 2 ) { //new event | 569 | if ( item == 2 ) { //new event |
583 | newTodoSignal(mStartCellX ,mStartCellY ); | 570 | newTodoSignal(mStartCellX ,mStartCellY ); |
584 | } else | 571 | } else |
585 | { | 572 | { |
586 | QDate day = mSelectedDates[mStartCellX]; | 573 | QDate day = mSelectedDates[mStartCellX]; |
587 | emit showDateView( item, day ); | 574 | emit showDateView( item, day ); |
588 | // 3Day view | 575 | // 3Day view |
589 | // 4Week view | 576 | // 4Week view |
590 | // 5Month view | 577 | // 5Month view |
591 | // 6Journal view | 578 | // 6Journal view |
592 | } | 579 | } |
593 | } | 580 | } |
594 | void KOAgenda::startSelectAction(QPoint viewportPos) | 581 | void KOAgenda::startSelectAction(QPoint viewportPos) |
595 | { | 582 | { |
596 | //emit newStartSelectSignal(); | 583 | //emit newStartSelectSignal(); |
597 | 584 | ||
598 | mActionType = SELECT; | 585 | mActionType = SELECT; |
599 | 586 | ||
600 | int x,y; | 587 | int x,y; |
601 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 588 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
602 | int gx,gy; | 589 | int gx,gy; |
603 | contentsToGrid(x,y,gx,gy); | 590 | contentsToGrid(x,y,gx,gy); |
604 | 591 | ||
605 | mStartCellX = gx; | 592 | mStartCellX = gx; |
606 | mStartCellY = gy; | 593 | mStartCellY = gy; |
607 | mCurrentCellX = gx; | 594 | mCurrentCellX = gx; |
608 | mCurrentCellY = gy; | 595 | mCurrentCellY = gy; |
609 | 596 | ||
610 | // Store coordinates of old selection | 597 | // Store coordinates of old selection |
611 | int selectionX = mSelectionCellX * mGridSpacingX; | 598 | int selectionX = mSelectionCellX * mGridSpacingX; |
612 | int selectionYTop = mSelectionYTop; | 599 | int selectionYTop = mSelectionYTop; |
613 | int selectionHeight = mSelectionHeight; | 600 | int selectionHeight = mSelectionHeight; |
614 | 601 | ||
615 | // Store new selection | 602 | // Store new selection |
616 | mSelectionCellX = gx; | 603 | mSelectionCellX = gx; |
617 | mSelectionYTop = gy * mGridSpacingY; | 604 | mSelectionYTop = gy * mGridSpacingY; |
618 | mSelectionHeight = mGridSpacingY; | 605 | mSelectionHeight = mGridSpacingY; |
619 | 606 | ||
620 | // Clear old selection | 607 | // Clear old selection |
621 | repaintContents( selectionX, selectionYTop, | 608 | repaintContents( selectionX, selectionYTop, |
622 | mGridSpacingX, selectionHeight,false ); | 609 | mGridSpacingX, selectionHeight,false ); |
623 | 610 | ||
624 | // Paint new selection | 611 | // Paint new selection |
625 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 612 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
626 | // mGridSpacingX, mSelectionHeight ); | 613 | // mGridSpacingX, mSelectionHeight ); |
627 | } | 614 | } |
628 | 615 | ||
629 | void KOAgenda::performSelectAction(QPoint viewportPos) | 616 | void KOAgenda::performSelectAction(QPoint viewportPos) |
630 | { | 617 | { |
631 | int x,y; | 618 | int x,y; |
632 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 619 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
633 | int gx,gy; | 620 | int gx,gy; |
634 | contentsToGrid(x,y,gx,gy); | 621 | contentsToGrid(x,y,gx,gy); |
635 | 622 | ||
636 | QPoint clipperPos = clipper()-> | 623 | QPoint clipperPos = clipper()-> |
637 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 624 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
638 | 625 | ||
639 | // Scroll if cursor was moved to upper or lower end of agenda. | 626 | // Scroll if cursor was moved to upper or lower end of agenda. |
640 | if (clipperPos.y() < mScrollBorderWidth) { | 627 | if (clipperPos.y() < mScrollBorderWidth) { |
641 | mScrollUpTimer.start(mScrollDelay); | 628 | mScrollUpTimer.start(mScrollDelay); |
642 | } else if (visibleHeight() - clipperPos.y() < | 629 | } else if (visibleHeight() - clipperPos.y() < |
643 | mScrollBorderWidth) { | 630 | mScrollBorderWidth) { |
644 | mScrollDownTimer.start(mScrollDelay); | 631 | mScrollDownTimer.start(mScrollDelay); |
645 | } else { | 632 | } else { |
646 | mScrollUpTimer.stop(); | 633 | mScrollUpTimer.stop(); |
647 | mScrollDownTimer.stop(); | 634 | mScrollDownTimer.stop(); |
648 | } | 635 | } |
649 | 636 | ||
650 | if ( gy > mCurrentCellY ) { | 637 | if ( gy > mCurrentCellY ) { |
651 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 638 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
652 | 639 | ||
653 | #if 0 | 640 | #if 0 |
654 | // FIXME: Repaint only the newly selected region | 641 | // FIXME: Repaint only the newly selected region |
655 | repaintContents( mSelectionCellX * mGridSpacingX, | 642 | repaintContents( mSelectionCellX * mGridSpacingX, |
656 | mCurrentCellY + mGridSpacingY, | 643 | mCurrentCellY + mGridSpacingY, |
657 | mGridSpacingX, | 644 | mGridSpacingX, |
658 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 645 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
659 | #else | 646 | #else |
660 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 647 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
661 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 648 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
662 | mGridSpacingX, mSelectionYTop, | 649 | mGridSpacingX, mSelectionYTop, |
663 | mGridSpacingX, mSelectionHeight , false); | 650 | mGridSpacingX, mSelectionHeight , false); |
664 | #endif | 651 | #endif |
665 | 652 | ||
666 | mCurrentCellY = gy; | 653 | mCurrentCellY = gy; |
667 | } else if ( gy < mCurrentCellY ) { | 654 | } else if ( gy < mCurrentCellY ) { |
668 | if ( gy >= mStartCellY ) { | 655 | if ( gy >= mStartCellY ) { |
669 | int selectionHeight = mSelectionHeight; | 656 | int selectionHeight = mSelectionHeight; |
670 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 657 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
671 | 658 | ||
672 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 659 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
673 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 660 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
674 | mGridSpacingX, mSelectionYTop, | 661 | mGridSpacingX, mSelectionYTop, |
675 | mGridSpacingX, selectionHeight,false ); | 662 | mGridSpacingX, selectionHeight,false ); |
676 | 663 | ||
677 | mCurrentCellY = gy; | 664 | mCurrentCellY = gy; |
678 | } else { | 665 | } else { |
679 | } | 666 | } |
680 | } | 667 | } |
681 | } | 668 | } |
682 | 669 | ||
683 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 670 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
684 | { | 671 | { |
685 | mActionType = NOP; | 672 | mActionType = NOP; |
686 | mScrollUpTimer.stop(); | 673 | mScrollUpTimer.stop(); |
687 | mScrollDownTimer.stop(); | 674 | mScrollDownTimer.stop(); |
688 | 675 | ||
689 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 676 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
690 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 677 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
691 | qDebug("ew event signal "); | 678 | qDebug("ew event signal "); |
692 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 679 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
693 | } | 680 | } |
694 | } | 681 | } |
695 | 682 | ||
696 | void KOAgenda::startItemAction(QPoint viewportPos) | 683 | void KOAgenda::startItemAction(QPoint viewportPos) |
697 | { | 684 | { |
698 | int x,y; | 685 | int x,y; |
699 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 686 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
700 | int gx,gy; | 687 | int gx,gy; |
701 | contentsToGrid(x,y,gx,gy); | 688 | contentsToGrid(x,y,gx,gy); |
702 | 689 | ||
703 | mStartCellX = gx; | 690 | mStartCellX = gx; |
704 | mStartCellY = gy; | 691 | mStartCellY = gy; |
705 | mCurrentCellX = gx; | 692 | mCurrentCellX = gx; |
706 | mCurrentCellY = gy; | 693 | mCurrentCellY = gy; |
707 | 694 | ||
708 | if (mAllDayMode) { | 695 | if (mAllDayMode) { |
709 | int gridDistanceX = (x - gx * mGridSpacingX); | 696 | int gridDistanceX = (x - gx * mGridSpacingX); |
710 | if (gridDistanceX < mResizeBorderWidth && | 697 | if (gridDistanceX < mResizeBorderWidth && |
711 | mActionItem->cellX() == mCurrentCellX) { | 698 | mActionItem->cellX() == mCurrentCellX) { |
712 | mActionType = RESIZELEFT; | 699 | mActionType = RESIZELEFT; |
713 | setCursor(sizeHorCursor); | 700 | setCursor(sizeHorCursor); |
714 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 701 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
715 | mActionItem->cellXWidth() == mCurrentCellX) { | 702 | mActionItem->cellXWidth() == mCurrentCellX) { |
716 | mActionType = RESIZERIGHT; | 703 | mActionType = RESIZERIGHT; |
717 | setCursor(sizeHorCursor); | 704 | setCursor(sizeHorCursor); |
718 | } else { | 705 | } else { |
719 | mActionType = MOVE; | 706 | mActionType = MOVE; |
720 | mActionItem->startMove(); | 707 | mActionItem->startMove(); |
721 | setCursor(sizeAllCursor); | 708 | setCursor(sizeAllCursor); |
722 | } | 709 | } |
723 | } else { | 710 | } else { |
724 | int gridDistanceY = (y - gy * mGridSpacingY); | 711 | int gridDistanceY = (y - gy * mGridSpacingY); |
725 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 712 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
726 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 713 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
727 | mActionItem->cellYTop() == mCurrentCellY && | 714 | mActionItem->cellYTop() == mCurrentCellY && |
728 | !mActionItem->firstMultiItem()) { | 715 | !mActionItem->firstMultiItem()) { |
729 | mActionType = RESIZETOP; | 716 | mActionType = RESIZETOP; |
730 | setCursor(sizeVerCursor); | 717 | setCursor(sizeVerCursor); |
731 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 718 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
732 | mActionItem->cellYBottom() == mCurrentCellY && | 719 | mActionItem->cellYBottom() == mCurrentCellY && |
733 | !mActionItem->lastMultiItem()) { | 720 | !mActionItem->lastMultiItem()) { |
734 | mActionType = RESIZEBOTTOM; | 721 | mActionType = RESIZEBOTTOM; |
735 | setCursor(sizeVerCursor); | 722 | setCursor(sizeVerCursor); |
736 | } else { | 723 | } else { |
737 | mActionType = MOVE; | 724 | mActionType = MOVE; |
738 | mActionItem->startMove(); | 725 | mActionItem->startMove(); |
739 | setCursor(sizeAllCursor); | 726 | setCursor(sizeAllCursor); |
740 | } | 727 | } |
741 | } | 728 | } |
742 | } | 729 | } |
743 | 730 | ||
744 | void KOAgenda::performItemAction(QPoint viewportPos) | 731 | void KOAgenda::performItemAction(QPoint viewportPos) |
745 | { | 732 | { |
746 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 733 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
747 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 734 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
748 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 735 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
749 | // point = clipper()->mapFromGlobal(point); | 736 | // point = clipper()->mapFromGlobal(point); |
750 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 737 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
751 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 738 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
752 | int x,y; | 739 | int x,y; |
753 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 740 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
754 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 741 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
755 | int gx,gy; | 742 | int gx,gy; |
756 | contentsToGrid(x,y,gx,gy); | 743 | contentsToGrid(x,y,gx,gy); |
757 | QPoint clipperPos = clipper()-> | 744 | QPoint clipperPos = clipper()-> |
758 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 745 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
759 | 746 | ||
760 | // Cursor left active agenda area. | 747 | // Cursor left active agenda area. |
761 | // This starts a drag. | 748 | // This starts a drag. |
762 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 749 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
763 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 750 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
764 | if ( mActionType == MOVE ) { | 751 | if ( mActionType == MOVE ) { |
765 | mScrollUpTimer.stop(); | 752 | mScrollUpTimer.stop(); |
766 | mScrollDownTimer.stop(); | 753 | mScrollDownTimer.stop(); |
767 | mActionItem->resetMove(); | 754 | mActionItem->resetMove(); |
768 | placeSubCells( mActionItem ); | 755 | placeSubCells( mActionItem ); |
769 | // emit startDragSignal( mActionItem->incidence() ); | 756 | // emit startDragSignal( mActionItem->incidence() ); |
770 | setCursor( arrowCursor ); | 757 | setCursor( arrowCursor ); |
771 | mActionItem = 0; | 758 | mActionItem = 0; |
772 | mActionType = NOP; | 759 | mActionType = NOP; |
773 | mItemMoved = 0; | 760 | mItemMoved = 0; |
774 | return; | 761 | return; |
775 | } | 762 | } |
776 | } else { | 763 | } else { |
777 | switch ( mActionType ) { | 764 | switch ( mActionType ) { |
778 | case MOVE: | 765 | case MOVE: |
779 | setCursor( sizeAllCursor ); | 766 | setCursor( sizeAllCursor ); |
780 | break; | 767 | break; |
781 | case RESIZETOP: | 768 | case RESIZETOP: |
782 | case RESIZEBOTTOM: | 769 | case RESIZEBOTTOM: |
783 | setCursor( sizeVerCursor ); | 770 | setCursor( sizeVerCursor ); |
784 | break; | 771 | break; |
785 | case RESIZELEFT: | 772 | case RESIZELEFT: |
786 | case RESIZERIGHT: | 773 | case RESIZERIGHT: |
787 | setCursor( sizeHorCursor ); | 774 | setCursor( sizeHorCursor ); |
788 | break; | 775 | break; |
789 | default: | 776 | default: |
790 | setCursor( arrowCursor ); | 777 | setCursor( arrowCursor ); |
791 | } | 778 | } |
792 | } | 779 | } |
793 | 780 | ||
794 | // Scroll if item was moved to upper or lower end of agenda. | 781 | // Scroll if item was moved to upper or lower end of agenda. |
795 | if (clipperPos.y() < mScrollBorderWidth) { | 782 | if (clipperPos.y() < mScrollBorderWidth) { |
796 | mScrollUpTimer.start(mScrollDelay); | 783 | mScrollUpTimer.start(mScrollDelay); |
797 | } else if (visibleHeight() - clipperPos.y() < | 784 | } else if (visibleHeight() - clipperPos.y() < |
798 | mScrollBorderWidth) { | 785 | mScrollBorderWidth) { |
799 | mScrollDownTimer.start(mScrollDelay); | 786 | mScrollDownTimer.start(mScrollDelay); |
800 | } else { | 787 | } else { |
801 | mScrollUpTimer.stop(); | 788 | mScrollUpTimer.stop(); |
802 | mScrollDownTimer.stop(); | 789 | mScrollDownTimer.stop(); |
803 | } | 790 | } |
804 | 791 | ||
805 | // Move or resize item if necessary | 792 | // Move or resize item if necessary |
806 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 793 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
807 | mItemMoved = true; | 794 | mItemMoved = true; |
808 | mActionItem->raise(); | 795 | mActionItem->raise(); |
809 | if (mActionType == MOVE) { | 796 | if (mActionType == MOVE) { |
810 | // Move all items belonging to a multi item | 797 | // Move all items belonging to a multi item |
811 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 798 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
812 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 799 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
813 | if (!moveItem) moveItem = mActionItem; | 800 | if (!moveItem) moveItem = mActionItem; |
814 | while (moveItem) { | 801 | while (moveItem) { |
815 | int dy; | 802 | int dy; |
816 | if (isMultiItem) dy = 0; | 803 | if (isMultiItem) dy = 0; |
817 | else dy = gy - mCurrentCellY; | 804 | else dy = gy - mCurrentCellY; |
818 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 805 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
819 | int x,y; | 806 | int x,y; |
820 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 807 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
821 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 808 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
822 | mGridSpacingY * moveItem->cellHeight()); | 809 | mGridSpacingY * moveItem->cellHeight()); |
823 | moveChild(moveItem,x,y); | 810 | moveChild(moveItem,x,y); |
824 | moveItem = moveItem->nextMultiItem(); | 811 | moveItem = moveItem->nextMultiItem(); |
825 | } | 812 | } |
826 | } else if (mActionType == RESIZETOP) { | 813 | } else if (mActionType == RESIZETOP) { |
827 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 814 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
828 | mActionItem->expandTop(gy - mCurrentCellY); | 815 | mActionItem->expandTop(gy - mCurrentCellY); |
829 | mActionItem->resize(mActionItem->width(), | 816 | mActionItem->resize(mActionItem->width(), |
830 | mGridSpacingY * mActionItem->cellHeight()); | 817 | mGridSpacingY * mActionItem->cellHeight()); |
831 | int x,y; | 818 | int x,y; |
832 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 819 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
833 | //moveChild(mActionItem,childX(mActionItem),y); | 820 | //moveChild(mActionItem,childX(mActionItem),y); |
834 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 821 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
835 | } | 822 | } |
836 | } else if (mActionType == RESIZEBOTTOM) { | 823 | } else if (mActionType == RESIZEBOTTOM) { |
837 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 824 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
838 | mActionItem->expandBottom(gy - mCurrentCellY); | 825 | mActionItem->expandBottom(gy - mCurrentCellY); |
839 | mActionItem->resize(mActionItem->width(), | 826 | mActionItem->resize(mActionItem->width(), |
840 | mGridSpacingY * mActionItem->cellHeight()); | 827 | mGridSpacingY * mActionItem->cellHeight()); |
841 | } | 828 | } |
842 | } else if (mActionType == RESIZELEFT) { | 829 | } else if (mActionType == RESIZELEFT) { |
843 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 830 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
844 | mActionItem->expandLeft(gx - mCurrentCellX); | 831 | mActionItem->expandLeft(gx - mCurrentCellX); |
845 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 832 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
846 | mActionItem->height()); | 833 | mActionItem->height()); |
847 | int x,y; | 834 | int x,y; |
848 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 835 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
849 | moveChild(mActionItem,x,childY(mActionItem)); | 836 | moveChild(mActionItem,x,childY(mActionItem)); |
850 | } | 837 | } |
851 | } else if (mActionType == RESIZERIGHT) { | 838 | } else if (mActionType == RESIZERIGHT) { |
852 | if (mCurrentCellX >= mActionItem->cellX()) { | 839 | if (mCurrentCellX >= mActionItem->cellX()) { |
853 | mActionItem->expandRight(gx - mCurrentCellX); | 840 | mActionItem->expandRight(gx - mCurrentCellX); |
854 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 841 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
855 | mActionItem->height()); | 842 | mActionItem->height()); |
856 | } | 843 | } |
857 | } | 844 | } |
858 | mCurrentCellX = gx; | 845 | mCurrentCellX = gx; |
859 | mCurrentCellY = gy; | 846 | mCurrentCellY = gy; |
860 | } | 847 | } |
861 | } | 848 | } |
862 | 849 | ||
863 | void KOAgenda::endItemAction() | 850 | void KOAgenda::endItemAction() |
864 | { | 851 | { |
865 | 852 | ||
866 | if ( mItemMoved ) { | 853 | if ( mItemMoved ) { |
867 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 854 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
868 | if ( !placeItem ) { | 855 | if ( !placeItem ) { |
869 | placeItem = mActionItem; | 856 | placeItem = mActionItem; |
870 | } | 857 | } |
871 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 858 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
872 | Incidence* oldInc = placeItem->incidence(); | 859 | Incidence* oldInc = placeItem->incidence(); |
873 | placeItem->recreateIncidence(); | 860 | placeItem->recreateIncidence(); |
874 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 861 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
875 | } | 862 | } |
876 | int type = mActionType; | 863 | int type = mActionType; |
877 | if ( mAllDayMode ) | 864 | if ( mAllDayMode ) |
878 | type = -1; | 865 | type = -1; |
879 | KOAgendaItem *modifiedItem = placeItem; | 866 | KOAgendaItem *modifiedItem = placeItem; |
880 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 867 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
881 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 868 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
882 | KOAgendaItem *item; | 869 | KOAgendaItem *item; |
883 | 870 | ||
884 | if ( placeItem->incidence()->type() == "Todo" ) { | 871 | if ( placeItem->incidence()->type() == "Todo" ) { |
885 | mSelectedItem = 0; | 872 | mSelectedItem = 0; |
886 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 873 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
887 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 874 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
888 | emit itemModified( modifiedItem, mActionType ); | 875 | emit itemModified( modifiedItem, mActionType ); |
889 | } | 876 | } |
890 | else { | 877 | else { |
891 | #if 0 | 878 | #if 0 |
892 | for ( item=oldconflictItems.first(); item != 0; | 879 | for ( item=oldconflictItems.first(); item != 0; |
893 | item=oldconflictItems.next() ) { | 880 | item=oldconflictItems.next() ) { |
894 | placeSubCells(item); | 881 | placeSubCells(item); |
895 | } | 882 | } |
896 | while ( placeItem ) { | 883 | while ( placeItem ) { |
897 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 884 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
898 | placeSubCells( placeItem ); | 885 | placeSubCells( placeItem ); |
899 | placeItem = placeItem->nextMultiItem(); | 886 | placeItem = placeItem->nextMultiItem(); |
900 | } | 887 | } |
901 | #endif | 888 | #endif |
902 | 889 | ||
903 | globalFlagBlockAgendaItemPaint = 1; | 890 | globalFlagBlockAgendaItemPaint = 1; |
904 | for ( item=oldconflictItems.first(); item != 0; | 891 | for ( item=oldconflictItems.first(); item != 0; |
905 | item=oldconflictItems.next() ) { | 892 | item=oldconflictItems.next() ) { |
906 | placeSubCells(item); | 893 | placeSubCells(item); |
907 | } | 894 | } |
908 | while ( placeItem ) { | 895 | while ( placeItem ) { |
909 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 896 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
910 | oldconflictItems = placeItem->conflictItems(); | 897 | oldconflictItems = placeItem->conflictItems(); |
911 | for ( item=oldconflictItems.first(); item != 0; | 898 | for ( item=oldconflictItems.first(); item != 0; |
912 | item=oldconflictItems.next() ) { | 899 | item=oldconflictItems.next() ) { |
913 | placeSubCells(item); | 900 | placeSubCells(item); |
914 | } | 901 | } |
915 | placeSubCells( placeItem ); | 902 | placeSubCells( placeItem ); |
916 | placeItem = placeItem->nextMultiItem(); | 903 | placeItem = placeItem->nextMultiItem(); |
917 | } | 904 | } |
918 | globalFlagBlockAgendaItemPaint = 0; | 905 | globalFlagBlockAgendaItemPaint = 0; |
919 | for ( item=oldconflictItems.first(); item != 0; | 906 | for ( item=oldconflictItems.first(); item != 0; |
920 | item=oldconflictItems.next() ) { | 907 | item=oldconflictItems.next() ) { |
921 | globalFlagBlockAgendaItemUpdate = 0; | 908 | globalFlagBlockAgendaItemUpdate = 0; |
922 | item->repaintMe(); | 909 | item->repaintMe(); |
923 | globalFlagBlockAgendaItemUpdate = 1; | 910 | globalFlagBlockAgendaItemUpdate = 1; |
924 | item->repaint( false ); | 911 | item->repaint( false ); |
925 | } | 912 | } |
926 | placeItem = modifiedItem; | 913 | placeItem = modifiedItem; |
927 | 914 | ||
928 | while ( placeItem ) { | 915 | while ( placeItem ) { |
929 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 916 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
930 | globalFlagBlockAgendaItemUpdate = 0; | 917 | globalFlagBlockAgendaItemUpdate = 0; |
931 | placeItem->repaintMe(); | 918 | placeItem->repaintMe(); |
932 | globalFlagBlockAgendaItemUpdate = 1; | 919 | globalFlagBlockAgendaItemUpdate = 1; |
933 | placeItem->repaint(false); | 920 | placeItem->repaint(false); |
934 | placeItem = placeItem->nextMultiItem(); | 921 | placeItem = placeItem->nextMultiItem(); |
935 | } | 922 | } |
936 | emit itemModified( modifiedItem, mActionType ); | 923 | emit itemModified( modifiedItem, mActionType ); |
937 | 924 | ||