author | zautrix <zautrix> | 2005-06-28 11:19:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-28 11:19:58 (UTC) |
commit | 5861dc779cce151b7a05f3295ca11ffbf39e5a20 (patch) (unidiff) | |
tree | f9d2a06cd171f4269e7597fbc44afb76b8ff76b1 | |
parent | c26c9e0aa8c8a3b1d3e8dba018d56dbdb67c65b4 (diff) | |
download | kdepimpi-5861dc779cce151b7a05f3295ca11ffbf39e5a20.zip kdepimpi-5861dc779cce151b7a05f3295ca11ffbf39e5a20.tar.gz kdepimpi-5861dc779cce151b7a05f3295ca11ffbf39e5a20.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagenda.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index faddac4..ce73168 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,1015 +1,1023 @@ | |||
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 | mTimeBox = new QLabel(this); | 73 | mTimeBox = new QLabel(this); |
74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
75 | QPalette pal = mTimeBox->palette(); | 75 | QPalette pal = mTimeBox->palette(); |
76 | pal.setColor(QColorGroup::Foreground, Qt::red); | 76 | pal.setColor(QColorGroup::Foreground, Qt::red); |
77 | mTimeBox->setPalette(pal); | 77 | mTimeBox->setPalette(pal); |
78 | //mTimeBox->setAutoMask(true); | 78 | //mTimeBox->setAutoMask(true); |
79 | 79 | ||
80 | agenda->addChild(mTimeBox); | 80 | agenda->addChild(mTimeBox); |
81 | 81 | ||
82 | oldToday = -1; | 82 | oldToday = -1; |
83 | } | 83 | } |
84 | 84 | ||
85 | MarcusBains::~MarcusBains() | 85 | MarcusBains::~MarcusBains() |
86 | { | 86 | { |
87 | delete minutes; | 87 | delete minutes; |
88 | } | 88 | } |
89 | 89 | ||
90 | int MarcusBains::todayColumn() | 90 | int MarcusBains::todayColumn() |
91 | { | 91 | { |
92 | QDate currentDate = QDate::currentDate(); | 92 | QDate currentDate = QDate::currentDate(); |
93 | 93 | ||
94 | DateList dateList = agenda->dateList(); | 94 | DateList dateList = agenda->dateList(); |
95 | DateList::ConstIterator it; | 95 | DateList::ConstIterator it; |
96 | int col = 0; | 96 | int col = 0; |
97 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 97 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
98 | if((*it) == currentDate) | 98 | if((*it) == currentDate) |
99 | return KOGlobals::self()->reverseLayout() ? | 99 | return KOGlobals::self()->reverseLayout() ? |
100 | agenda->columns() - 1 - col : col; | 100 | agenda->columns() - 1 - col : col; |
101 | ++col; | 101 | ++col; |
102 | } | 102 | } |
103 | 103 | ||
104 | return -1; | 104 | return -1; |
105 | } | 105 | } |
106 | void MarcusBains::updateLoc() | 106 | void MarcusBains::updateLoc() |
107 | { | 107 | { |
108 | updateLocation(); | 108 | updateLocation(); |
109 | } | 109 | } |
110 | void MarcusBains::updateLocation(bool recalculate) | 110 | void MarcusBains::updateLocation(bool recalculate) |
111 | { | 111 | { |
112 | 112 | ||
113 | QTime tim = QTime::currentTime(); | 113 | QTime tim = QTime::currentTime(); |
114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
115 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 115 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
116 | recalculate = true; | 116 | recalculate = true; |
117 | 117 | ||
118 | int mins = tim.hour()*60 + tim.minute(); | 118 | int mins = tim.hour()*60 + tim.minute(); |
119 | int minutesPerCell = 24 * 60 / agenda->rows(); | 119 | int minutesPerCell = 24 * 60 / agenda->rows(); |
120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
121 | int today = recalculate ? todayColumn() : oldToday; | 121 | int today = recalculate ? todayColumn() : oldToday; |
122 | int x = agenda->gridSpacingX()*today; | 122 | int x = agenda->gridSpacingX()*today; |
123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
124 | 124 | ||
125 | oldTime = tim; | 125 | oldTime = tim; |
126 | oldToday = today; | 126 | oldToday = today; |
127 | 127 | ||
128 | if(disabled || (today<0)) { | 128 | if(disabled || (today<0)) { |
129 | hide(); mTimeBox->hide(); | 129 | hide(); mTimeBox->hide(); |
130 | return; | 130 | return; |
131 | } else { | 131 | } else { |
132 | show(); mTimeBox->show(); | 132 | show(); mTimeBox->show(); |
133 | } | 133 | } |
134 | 134 | ||
135 | if(recalculate) | 135 | if(recalculate) |
136 | setFixedSize(agenda->gridSpacingX(),1); | 136 | setFixedSize(agenda->gridSpacingX(),1); |
137 | agenda->moveChild(this, x, y); | 137 | agenda->moveChild(this, x, y); |
138 | raise(); | 138 | raise(); |
139 | 139 | ||
140 | if(recalculate) | 140 | if(recalculate) |
141 | //mTimeBox->setFont(QFont("helvetica",10)); | 141 | //mTimeBox->setFont(QFont("helvetica",10)); |
142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
143 | 143 | ||
144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
145 | mTimeBox->adjustSize(); | 145 | mTimeBox->adjustSize(); |
146 | // the -2 below is there because there is a bug in this program | 146 | // the -2 below is there because there is a bug in this program |
147 | // somewhere, where the last column of this widget is a few pixels | 147 | // somewhere, where the last column of this widget is a few pixels |
148 | // narrower than the other columns. | 148 | // narrower than the other columns. |
149 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 149 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
150 | agenda->moveChild(mTimeBox, | 150 | agenda->moveChild(mTimeBox, |
151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
152 | y-mTimeBox->height()); | 152 | y-mTimeBox->height()); |
153 | 153 | ||
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | minutes->start(5000,true); | 156 | minutes->start(5000,true); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | //////////////////////////////////////////////////////////////////////////// | 160 | //////////////////////////////////////////////////////////////////////////// |
161 | 161 | ||
162 | 162 | ||
163 | /* | 163 | /* |
164 | Create an agenda widget with rows rows and columns columns. | 164 | Create an agenda widget with rows rows and columns columns. |
165 | */ | 165 | */ |
166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
167 | const char *name,WFlags f) : | 167 | const char *name,WFlags f) : |
168 | QScrollView(parent,name,f) | 168 | QScrollView(parent,name,f) |
169 | { | 169 | { |
170 | 170 | ||
171 | mAllAgendaPopup = 0; | 171 | mAllAgendaPopup = 0; |
172 | mColumns = columns; | 172 | mColumns = columns; |
173 | mRows = rows; | 173 | mRows = rows; |
174 | mGridSpacingY = rowSize; | 174 | mGridSpacingY = rowSize; |
175 | mAllDayMode = false; | 175 | mAllDayMode = false; |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
178 | #endif | 178 | #endif |
179 | mHolidayMask = 0; | 179 | mHolidayMask = 0; |
180 | init(); | 180 | init(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /* | 183 | /* |
184 | Create an agenda widget with columns columns and one row. This is used for | 184 | Create an agenda widget with columns columns and one row. This is used for |
185 | all-day events. | 185 | all-day events. |
186 | */ | 186 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
188 | QScrollView(parent,name,f) | 188 | QScrollView(parent,name,f) |
189 | { | 189 | { |
190 | mAllAgendaPopup = 0; | 190 | mAllAgendaPopup = 0; |
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 | mPopupTimer = new QTimer(this); | 225 | mPopupTimer = new QTimer(this); |
226 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 226 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
227 | 227 | ||
228 | mNewItemPopup = new QPopupMenu( this ); | 228 | mNewItemPopup = new QPopupMenu( this ); |
229 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 229 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
230 | QString pathString = ""; | 230 | QString pathString = ""; |
231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
232 | if ( QApplication::desktop()->width() < 480 ) | 232 | if ( QApplication::desktop()->width() < 480 ) |
233 | pathString += "icons16/"; | 233 | pathString += "icons16/"; |
234 | } else | 234 | } else |
235 | pathString += "iconsmini/"; | 235 | pathString += "iconsmini/"; |
236 | 236 | ||
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
239 | mNewItemPopup->insertSeparator ( ); | 239 | mNewItemPopup->insertSeparator ( ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
246 | #ifndef _WIN32_ | 246 | #ifndef _WIN32_ |
247 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 247 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
248 | viewport()->setWFlags ( wflags); | 248 | viewport()->setWFlags ( wflags); |
249 | #endif | 249 | #endif |
250 | mGridSpacingX = 80; | 250 | mGridSpacingX = 80; |
251 | mResizeBorderWidth = 8; | 251 | mResizeBorderWidth = 8; |
252 | mScrollBorderWidth = 8; | 252 | mScrollBorderWidth = 8; |
253 | mScrollDelay = 30; | 253 | mScrollDelay = 30; |
254 | mScrollOffset = 10; | 254 | mScrollOffset = 10; |
255 | mPaintPixmap.resize( 20,20); | 255 | mPaintPixmap.resize( 20,20); |
256 | //enableClipper(true); | 256 | //enableClipper(true); |
257 | 257 | ||
258 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 258 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
259 | // effect. Has to be fixed. | 259 | // effect. Has to be fixed. |
260 | setFocusPolicy(WheelFocus); | 260 | setFocusPolicy(WheelFocus); |
261 | 261 | ||
262 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 262 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
263 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 263 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
264 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 264 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
265 | 265 | ||
266 | mStartCellX = 0; | 266 | mStartCellX = 0; |
267 | mStartCellY = 0; | 267 | mStartCellY = 0; |
268 | mCurrentCellX = 0; | 268 | mCurrentCellX = 0; |
269 | mCurrentCellY = 0; | 269 | mCurrentCellY = 0; |
270 | 270 | ||
271 | mSelectionCellX = 0; | 271 | mSelectionCellX = 0; |
272 | mSelectionYTop = 0; | 272 | mSelectionYTop = 0; |
273 | mSelectionHeight = 0; | 273 | mSelectionHeight = 0; |
274 | 274 | ||
275 | mOldLowerScrollValue = -1; | 275 | mOldLowerScrollValue = -1; |
276 | mOldUpperScrollValue = -1; | 276 | mOldUpperScrollValue = -1; |
277 | 277 | ||
278 | mClickedItem = 0; | 278 | mClickedItem = 0; |
279 | 279 | ||
280 | mActionItem = 0; | 280 | mActionItem = 0; |
281 | mActionType = NOP; | 281 | mActionType = NOP; |
282 | mItemMoved = false; | 282 | mItemMoved = false; |
283 | 283 | ||
284 | mSelectedItem = 0; | 284 | mSelectedItem = 0; |
285 | 285 | ||
286 | // mItems.setAutoDelete(true); | 286 | // mItems.setAutoDelete(true); |
287 | 287 | ||
288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
289 | 289 | ||
290 | viewport()->update(); | 290 | viewport()->update(); |
291 | 291 | ||
292 | setMinimumSize(30, 1); | 292 | setMinimumSize(30, 1); |
293 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 293 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
294 | 294 | ||
295 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 295 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
296 | // controlled in a way that the contents horizontally always fits. Then it is | 296 | // controlled in a way that the contents horizontally always fits. Then it is |
297 | // not necessary to turn off the scrollbar. | 297 | // not necessary to turn off the scrollbar. |
298 | setHScrollBarMode(AlwaysOff); | 298 | setHScrollBarMode(AlwaysOff); |
299 | if ( ! mAllDayMode ) | 299 | if ( ! mAllDayMode ) |
300 | setVScrollBarMode(AlwaysOn); | 300 | setVScrollBarMode(AlwaysOn); |
301 | else | 301 | else |
302 | setVScrollBarMode(AlwaysOff); | 302 | setVScrollBarMode(AlwaysOff); |
303 | 303 | ||
304 | setStartHour(KOPrefs::instance()->mDayBegins); | 304 | setStartHour(KOPrefs::instance()->mDayBegins); |
305 | 305 | ||
306 | calculateWorkingHours(); | 306 | calculateWorkingHours(); |
307 | 307 | ||
308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
309 | SLOT(checkScrollBoundaries(int))); | 309 | SLOT(checkScrollBoundaries(int))); |
310 | 310 | ||
311 | // Create the Marcus Bains line. | 311 | // Create the Marcus Bains line. |
312 | if(mAllDayMode) | 312 | if(mAllDayMode) |
313 | mMarcusBains = 0; | 313 | mMarcusBains = 0; |
314 | else { | 314 | else { |
315 | mMarcusBains = new MarcusBains(this); | 315 | mMarcusBains = new MarcusBains(this); |
316 | addChild(mMarcusBains); | 316 | addChild(mMarcusBains); |
317 | } | 317 | } |
318 | mPopupKind = 0; | 318 | mPopupKind = 0; |
319 | mPopupItem = 0; | 319 | mPopupItem = 0; |
320 | } | 320 | } |
321 | 321 | ||
322 | void KOAgenda::clear() | 322 | void KOAgenda::clear() |
323 | { | 323 | { |
324 | KOAgendaItem *item; | 324 | KOAgendaItem *item; |
325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
326 | mUnusedItems.append( item ); | 326 | mUnusedItems.append( item ); |
327 | //item->hide(); | 327 | //item->hide(); |
328 | } | 328 | } |
329 | mItems.clear(); | 329 | mItems.clear(); |
330 | mSelectedItem = 0; | 330 | mSelectedItem = 0; |
331 | clearSelection(); | 331 | clearSelection(); |
332 | } | 332 | } |
333 | 333 | ||
334 | void KOAgenda::clearSelection() | 334 | void KOAgenda::clearSelection() |
335 | { | 335 | { |
336 | mSelectionCellX = 0; | 336 | mSelectionCellX = 0; |
337 | mSelectionYTop = 0; | 337 | mSelectionYTop = 0; |
338 | mSelectionHeight = 0; | 338 | mSelectionHeight = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | void KOAgenda::marcus_bains() | 341 | void KOAgenda::marcus_bains() |
342 | { | 342 | { |
343 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 343 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | void KOAgenda::changeColumns(int columns) | 347 | void KOAgenda::changeColumns(int columns) |
348 | { | 348 | { |
349 | if (columns == 0) { | 349 | if (columns == 0) { |
350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | clear(); | 353 | clear(); |
354 | mColumns = columns; | 354 | mColumns = columns; |
355 | computeSizes(); | 355 | computeSizes(); |
356 | } | 356 | } |
357 | 357 | ||
358 | /* | 358 | /* |
359 | This is the eventFilter function, which gets all events from the KOAgendaItems | 359 | This is the eventFilter function, which gets all events from the KOAgendaItems |
360 | contained in the agenda. It has to handle moving and resizing for all items. | 360 | contained in the agenda. It has to handle moving and resizing for all items. |
361 | */ | 361 | */ |
362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
363 | { | 363 | { |
364 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 364 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
365 | switch(event->type()) { | 365 | switch(event->type()) { |
366 | case QEvent::MouseButtonPress: | 366 | case QEvent::MouseButtonPress: |
367 | case QEvent::MouseButtonDblClick: | 367 | case QEvent::MouseButtonDblClick: |
368 | case QEvent::MouseButtonRelease: | 368 | case QEvent::MouseButtonRelease: |
369 | case QEvent::MouseMove: | 369 | case QEvent::MouseMove: |
370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
371 | 371 | ||
372 | case (QEvent::Leave): | 372 | case (QEvent::Leave): |
373 | if (!mActionItem) | 373 | if (!mActionItem) |
374 | setCursor(arrowCursor); | 374 | setCursor(arrowCursor); |
375 | return true; | 375 | return true; |
376 | 376 | ||
377 | default: | 377 | default: |
378 | return QScrollView::eventFilter(object,event); | 378 | return QScrollView::eventFilter(object,event); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | void KOAgenda::popupMenu() | 381 | void KOAgenda::popupMenu() |
382 | { | 382 | { |
383 | mPopupTimer->stop(); | 383 | mPopupTimer->stop(); |
384 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 384 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
385 | if (mActionItem ) { | 385 | if (mActionItem ) { |
386 | endItemAction(); | 386 | endItemAction(); |
387 | } | 387 | } |
388 | mLeftMouseDown = false; // no more leftMouse computation | 388 | mLeftMouseDown = false; // no more leftMouse computation |
389 | if (mPopupItem) { | 389 | if (mPopupItem) { |
390 | //mClickedItem = mPopupItem; | 390 | //mClickedItem = mPopupItem; |
391 | selectItem(mPopupItem); | 391 | selectItem(mPopupItem); |
392 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 392 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
393 | mAllAgendaPopup->installEventFilter( this ); | 393 | mAllAgendaPopup->installEventFilter( this ); |
394 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 394 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
395 | 395 | ||
396 | } | 396 | } |
397 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 397 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
398 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 398 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
399 | endSelectAction( false ); // do not emit new event signal | 399 | endSelectAction( false ); // do not emit new event signal |
400 | mLeftMouseDown = false; // no more leftMouse computation | 400 | mLeftMouseDown = false; // no more leftMouse computation |
401 | } | 401 | } |
402 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 402 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
403 | mNewItemPopup->installEventFilter( this ); | 403 | mNewItemPopup->installEventFilter( this ); |
404 | mNewItemPopup->popup( mPopupPos); | 404 | mNewItemPopup->popup( mPopupPos); |
405 | 405 | ||
406 | } | 406 | } |
407 | mLeftMouseDown = false; | 407 | mLeftMouseDown = false; |
408 | mPopupItem = 0; | 408 | mPopupItem = 0; |
409 | mPopupKind = 0; | 409 | mPopupKind = 0; |
410 | } | 410 | } |
411 | 411 | ||
412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 412 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
413 | { | 413 | { |
414 | static int startX = 0; | 414 | static int startX = 0; |
415 | static int startY = 0; | 415 | static int startY = 0; |
416 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 416 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
417 | static bool blockMoving = true; | 417 | static bool blockMoving = true; |
418 | 418 | ||
419 | //qDebug("KOAgenda::eventFilter_mous "); | 419 | //qDebug("KOAgenda::eventFilter_mous "); |
420 | if ( object == mNewItemPopup ) { | 420 | if ( object == mNewItemPopup ) { |
421 | //qDebug("mNewItemPopup "); | 421 | //qDebug("mNewItemPopup "); |
422 | if ( me->type() == QEvent::MouseButtonRelease ) { | 422 | if ( me->type() == QEvent::MouseButtonRelease ) { |
423 | mNewItemPopup->removeEventFilter( this ); | 423 | mNewItemPopup->removeEventFilter( this ); |
424 | int dX = me->globalPos().x() - mPopupPos.x();; | 424 | int dX = me->globalPos().x() - mPopupPos.x();; |
425 | if ( dX < 0 ) | 425 | if ( dX < 0 ) |
426 | dX = -dX; | 426 | dX = -dX; |
427 | int dY = me->globalPos().y() - mPopupPos.y(); | 427 | int dY = me->globalPos().y() - mPopupPos.y(); |
428 | if ( dY < 0 ) | 428 | if ( dY < 0 ) |
429 | dY = -dY; | 429 | dY = -dY; |
430 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 430 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
431 | mNewItemPopup->hide(); | 431 | mNewItemPopup->hide(); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | return true; | 434 | return true; |
435 | } | 435 | } |
436 | if ( object == mAllAgendaPopup ) { | 436 | if ( object == mAllAgendaPopup ) { |
437 | //qDebug(" mAllAgendaPopup "); | 437 | //qDebug(" mAllAgendaPopup "); |
438 | if ( me->type() == QEvent::MouseButtonRelease ) { | 438 | if ( me->type() == QEvent::MouseButtonRelease ) { |
439 | mAllAgendaPopup->removeEventFilter( this ); | 439 | mAllAgendaPopup->removeEventFilter( this ); |
440 | int dX = me->globalPos().x() - mPopupPos.x();; | 440 | int dX = me->globalPos().x() - mPopupPos.x();; |
441 | if ( dX < 0 ) | 441 | if ( dX < 0 ) |
442 | dX = -dX; | 442 | dX = -dX; |
443 | int dY = me->globalPos().y() - mPopupPos.y(); | 443 | int dY = me->globalPos().y() - mPopupPos.y(); |
444 | if ( dY < 0 ) | 444 | if ( dY < 0 ) |
445 | dY = -dY; | 445 | dY = -dY; |
446 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 446 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
447 | mAllAgendaPopup->hide(); | 447 | mAllAgendaPopup->hide(); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | return true; | 450 | return true; |
451 | } | 451 | } |
452 | QPoint viewportPos; | 452 | QPoint viewportPos; |
453 | if (object != viewport()) { | 453 | if (object != viewport()) { |
454 | blockmoveDist = blockmoveDist*2; | 454 | blockmoveDist = blockmoveDist*2; |
455 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 455 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
456 | } else { | 456 | } else { |
457 | viewportPos = me->pos(); | 457 | viewportPos = me->pos(); |
458 | } | 458 | } |
459 | bool objIsNotViewport = (object != viewport()); | 459 | bool objIsNotViewport = (object != viewport()); |
460 | bool leftButt = false; | 460 | bool leftButt = false; |
461 | #ifdef DESKTOP_VERSION | 461 | #ifdef DESKTOP_VERSION |
462 | leftButt = (me->button() == LeftButton); | 462 | leftButt = (me->button() == LeftButton); |
463 | #endif | 463 | #endif |
464 | switch (me->type()) { | 464 | switch (me->type()) { |
465 | case QEvent::MouseButtonPress: | 465 | case QEvent::MouseButtonPress: |
466 | if (me->button() == LeftButton) { | 466 | if (me->button() == LeftButton) { |
467 | mPopupTimer->start( 600 ); | 467 | mPopupTimer->start( 600 ); |
468 | mLeftMouseDown = true; | 468 | mLeftMouseDown = true; |
469 | } | 469 | } |
470 | blockMoving = true; | 470 | blockMoving = true; |
471 | startX = viewportPos.x(); | 471 | startX = viewportPos.x(); |
472 | startY = viewportPos.y(); | 472 | startY = viewportPos.y(); |
473 | mPopupPos = me->globalPos(); | 473 | mPopupPos = me->globalPos(); |
474 | if ( objIsNotViewport && !leftButt ) { | 474 | if ( objIsNotViewport && !leftButt ) { |
475 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 475 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
476 | if (mAllDayMode) { | 476 | if (mAllDayMode) { |
477 | if ( tempItem->height() > 10 ) { | 477 | if ( tempItem->height() > 10 ) { |
478 | int minV = tempItem->height()/4; | 478 | int minV = tempItem->height()/4; |
479 | if ( minV > (blockmoveDist/2)-2 ) | 479 | if ( minV > (blockmoveDist/2)-2 ) { |
480 | minV = (blockmoveDist/2)-2; | 480 | if ( minV > blockmoveDist ) |
481 | minV = blockmoveDist; | ||
482 | else | ||
483 | minV = (blockmoveDist/2); | ||
484 | } | ||
481 | bool border = false; | 485 | bool border = false; |
482 | int diff = tempItem->y() - viewportPos.y(); | 486 | int diff = tempItem->y() - viewportPos.y(); |
483 | if ( diff < 0 ) | 487 | if ( diff < 0 ) |
484 | diff *= -1; | 488 | diff *= -1; |
485 | if ( diff < minV ) { | 489 | if ( diff < minV ) { |
486 | border = true; | 490 | border = true; |
487 | objIsNotViewport = false; | 491 | objIsNotViewport = false; |
488 | } | 492 | } |
489 | if ( ! border ) { | 493 | if ( ! border ) { |
490 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 494 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
491 | if ( diff < 0 ) | 495 | if ( diff < 0 ) |
492 | diff *= -1; | 496 | diff *= -1; |
493 | if ( diff < minV ) { | 497 | if ( diff < minV ) { |
494 | border = true; | 498 | border = true; |
495 | objIsNotViewport = false; | 499 | objIsNotViewport = false; |
496 | } | 500 | } |
497 | } | 501 | } |
498 | } | 502 | } |
499 | } else { // not allday | 503 | } else { // not allday |
500 | if ( tempItem->width() > 10 ) { | 504 | if ( tempItem->width() > 10 ) { |
501 | int minH = tempItem->width()/4; | 505 | int minH = tempItem->width()/4; |
502 | if ( minH > (blockmoveDist/2)-2 ) | 506 | if ( minH > (blockmoveDist/2)-2 ) { |
503 | minH = (blockmoveDist/2)-2; | 507 | if ( minH > blockmoveDist ) |
508 | minH = blockmoveDist; | ||
509 | else | ||
510 | minH = (blockmoveDist/2); | ||
511 | } | ||
504 | bool border = false; | 512 | bool border = false; |
505 | int diff = tempItem->x() - viewportPos.x(); | 513 | int diff = tempItem->x() - viewportPos.x(); |
506 | if ( diff < 0 ) | 514 | if ( diff < 0 ) |
507 | diff *= -1; | 515 | diff *= -1; |
508 | if ( diff < minH ) { | 516 | if ( diff < minH ) { |
509 | border = true; | 517 | border = true; |
510 | objIsNotViewport = false; | 518 | objIsNotViewport = false; |
511 | } | 519 | } |
512 | if ( ! border ) { | 520 | if ( ! border ) { |
513 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 521 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
514 | if ( diff < 0 ) | 522 | if ( diff < 0 ) |
515 | diff *= -1; | 523 | diff *= -1; |
516 | if ( diff < minH ) { | 524 | if ( diff < minH ) { |
517 | border = true; | 525 | border = true; |
518 | objIsNotViewport = false; | 526 | objIsNotViewport = false; |
519 | } | 527 | } |
520 | } | 528 | } |
521 | } | 529 | } |
522 | } | 530 | } |
523 | } | 531 | } |
524 | if ( objIsNotViewport ) { | 532 | if ( objIsNotViewport ) { |
525 | mPopupItem = (KOAgendaItem *)object; | 533 | mPopupItem = (KOAgendaItem *)object; |
526 | mPopupKind = 1; | 534 | mPopupKind = 1; |
527 | if (me->button() == RightButton) { | 535 | if (me->button() == RightButton) { |
528 | mPopupKind = 3; | 536 | mPopupKind = 3; |
529 | popupMenu(); | 537 | popupMenu(); |
530 | } else if (me->button() == LeftButton) { | 538 | } else if (me->button() == LeftButton) { |
531 | mActionItem = (KOAgendaItem *)object; | 539 | mActionItem = (KOAgendaItem *)object; |
532 | if (mActionItem) { | 540 | if (mActionItem) { |
533 | emit signalClearSelection(); | 541 | emit signalClearSelection(); |
534 | slotClearSelection(); | 542 | slotClearSelection(); |
535 | selectItem(mActionItem); | 543 | selectItem(mActionItem); |
536 | Incidence *incidence = mActionItem->incidence(); | 544 | Incidence *incidence = mActionItem->incidence(); |
537 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 545 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
538 | mActionItem = 0; | 546 | mActionItem = 0; |
539 | } else { | 547 | } else { |
540 | startItemAction(viewportPos); | 548 | startItemAction(viewportPos); |
541 | } | 549 | } |
542 | } | 550 | } |
543 | } | 551 | } |
544 | } else { // ---------- viewport() | 552 | } else { // ---------- viewport() |
545 | mPopupItem = 0; | 553 | mPopupItem = 0; |
546 | mPopupKind = 2; | 554 | mPopupKind = 2; |
547 | selectItem(0); | 555 | selectItem(0); |
548 | mActionItem = 0; | 556 | mActionItem = 0; |
549 | if (me->button() == RightButton) { | 557 | if (me->button() == RightButton) { |
550 | int x,y; | 558 | int x,y; |
551 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 559 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
552 | int gx,gy; | 560 | int gx,gy; |
553 | contentsToGrid(x,y,gx,gy); | 561 | contentsToGrid(x,y,gx,gy); |
554 | mCurrentCellX = gx; | 562 | mCurrentCellX = gx; |
555 | mCurrentCellY = gy; | 563 | mCurrentCellY = gy; |
556 | mStartCellX = gx; | 564 | mStartCellX = gx; |
557 | mStartCellY = gy; | 565 | mStartCellY = gy; |
558 | mPopupKind = 4; | 566 | mPopupKind = 4; |
559 | popupMenu(); | 567 | popupMenu(); |
560 | } else if (me->button() == LeftButton) { | 568 | } else if (me->button() == LeftButton) { |
561 | setCursor(arrowCursor); | 569 | setCursor(arrowCursor); |
562 | startSelectAction(viewportPos); | 570 | startSelectAction(viewportPos); |
563 | } | 571 | } |
564 | } | 572 | } |
565 | break; | 573 | break; |
566 | 574 | ||
567 | case QEvent::MouseButtonRelease: | 575 | case QEvent::MouseButtonRelease: |
568 | if (me->button() == LeftButton ) { | 576 | if (me->button() == LeftButton ) { |
569 | mPopupTimer->stop(); | 577 | mPopupTimer->stop(); |
570 | } | 578 | } |
571 | if (object != viewport()) { | 579 | if (object != viewport()) { |
572 | if (me->button() == LeftButton && mLeftMouseDown) { | 580 | if (me->button() == LeftButton && mLeftMouseDown) { |
573 | if (mActionItem) { | 581 | if (mActionItem) { |
574 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 582 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
575 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 583 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
576 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 584 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
577 | mScrollUpTimer.stop(); | 585 | mScrollUpTimer.stop(); |
578 | mScrollDownTimer.stop(); | 586 | mScrollDownTimer.stop(); |
579 | mActionItem->resetMove(); | 587 | mActionItem->resetMove(); |
580 | placeSubCells( mActionItem ); | 588 | placeSubCells( mActionItem ); |
581 | // emit startDragSignal( mActionItem->incidence() ); | 589 | // emit startDragSignal( mActionItem->incidence() ); |
582 | setCursor( arrowCursor ); | 590 | setCursor( arrowCursor ); |
583 | mActionItem = 0; | 591 | mActionItem = 0; |
584 | mActionType = NOP; | 592 | mActionType = NOP; |
585 | mItemMoved = 0; | 593 | mItemMoved = 0; |
586 | mLeftMouseDown = false; | 594 | mLeftMouseDown = false; |
587 | return true; | 595 | return true; |
588 | } | 596 | } |
589 | endItemAction(); | 597 | endItemAction(); |
590 | } | 598 | } |
591 | } | 599 | } |
592 | 600 | ||
593 | } else { // ---------- viewport() | 601 | } else { // ---------- viewport() |
594 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 602 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
595 | endSelectAction( true ); // emit new event signal | 603 | endSelectAction( true ); // emit new event signal |
596 | } | 604 | } |
597 | } | 605 | } |
598 | if (me->button() == LeftButton) | 606 | if (me->button() == LeftButton) |
599 | mLeftMouseDown = false; | 607 | mLeftMouseDown = false; |
600 | 608 | ||
601 | break; | 609 | break; |
602 | 610 | ||
603 | case QEvent::MouseMove: | 611 | case QEvent::MouseMove: |
604 | //qDebug("mm "); | 612 | //qDebug("mm "); |
605 | if ( !mLeftMouseDown ) | 613 | if ( !mLeftMouseDown ) |
606 | return false; | 614 | return false; |
607 | if ( blockMoving ) { | 615 | if ( blockMoving ) { |
608 | int dX, dY; | 616 | int dX, dY; |
609 | dX = startX - viewportPos.x(); | 617 | dX = startX - viewportPos.x(); |
610 | if ( dX < 0 ) | 618 | if ( dX < 0 ) |
611 | dX = -dX; | 619 | dX = -dX; |
612 | dY = viewportPos.y() - startY; | 620 | dY = viewportPos.y() - startY; |
613 | if ( dY < 0 ) | 621 | if ( dY < 0 ) |
614 | dY = -dY; | 622 | dY = -dY; |
615 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 623 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
616 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 624 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
617 | blockMoving = false; | 625 | blockMoving = false; |
618 | } | 626 | } |
619 | } | 627 | } |
620 | if ( ! blockMoving ) | 628 | if ( ! blockMoving ) |
621 | mPopupTimer->stop(); | 629 | mPopupTimer->stop(); |
622 | if (object != viewport()) { | 630 | if (object != viewport()) { |
623 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 631 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
624 | if (!moveItem->incidence()->isReadOnly() ) { | 632 | if (!moveItem->incidence()->isReadOnly() ) { |
625 | if (!mActionItem) | 633 | if (!mActionItem) |
626 | setNoActionCursor(moveItem,viewportPos); | 634 | setNoActionCursor(moveItem,viewportPos); |
627 | else { | 635 | else { |
628 | if ( !blockMoving ) | 636 | if ( !blockMoving ) |
629 | performItemAction(viewportPos); | 637 | performItemAction(viewportPos); |
630 | } | 638 | } |
631 | } | 639 | } |
632 | } else { // ---------- viewport() | 640 | } else { // ---------- viewport() |
633 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 641 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
634 | if ( mActionType == SELECT ) { | 642 | if ( mActionType == SELECT ) { |
635 | performSelectAction( viewportPos ); | 643 | performSelectAction( viewportPos ); |
636 | } | 644 | } |
637 | } | 645 | } |
638 | break; | 646 | break; |
639 | 647 | ||
640 | case QEvent::MouseButtonDblClick: | 648 | case QEvent::MouseButtonDblClick: |
641 | mPopupTimer->stop(); | 649 | mPopupTimer->stop(); |
642 | if (object == viewport()) { | 650 | if (object == viewport()) { |
643 | selectItem(0); | 651 | selectItem(0); |
644 | int x,y; | 652 | int x,y; |
645 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 653 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
646 | int gx,gy; | 654 | int gx,gy; |
647 | contentsToGrid(x,y,gx,gy); | 655 | contentsToGrid(x,y,gx,gy); |
648 | emit newEventSignal(gx,gy); | 656 | emit newEventSignal(gx,gy); |
649 | } else { | 657 | } else { |
650 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 658 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
651 | selectItem(doubleClickedItem); | 659 | selectItem(doubleClickedItem); |
652 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 660 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
653 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 661 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
654 | else | 662 | else |
655 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 663 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
656 | } | 664 | } |
657 | break; | 665 | break; |
658 | 666 | ||
659 | default: | 667 | default: |
660 | break; | 668 | break; |
661 | } | 669 | } |
662 | return true; | 670 | return true; |
663 | 671 | ||
664 | } | 672 | } |
665 | 673 | ||
666 | void KOAgenda::newItem( int item ) | 674 | void KOAgenda::newItem( int item ) |
667 | { | 675 | { |
668 | if ( item == 1 ) { //new event | 676 | if ( item == 1 ) { //new event |
669 | newEventSignal(mStartCellX ,mStartCellY ); | 677 | newEventSignal(mStartCellX ,mStartCellY ); |
670 | } else | 678 | } else |
671 | if ( item == 2 ) { //new event | 679 | if ( item == 2 ) { //new event |
672 | newTodoSignal(mStartCellX ,mStartCellY ); | 680 | newTodoSignal(mStartCellX ,mStartCellY ); |
673 | } else | 681 | } else |
674 | { | 682 | { |
675 | emit showDateView( item, mStartCellX ); | 683 | emit showDateView( item, mStartCellX ); |
676 | // 3Day view | 684 | // 3Day view |
677 | // 4Week view | 685 | // 4Week view |
678 | // 5Month view | 686 | // 5Month view |
679 | // 6Journal view | 687 | // 6Journal view |
680 | } | 688 | } |
681 | } | 689 | } |
682 | void KOAgenda::slotClearSelection() | 690 | void KOAgenda::slotClearSelection() |
683 | { | 691 | { |
684 | if (mSelectionHeight) { | 692 | if (mSelectionHeight) { |
685 | int selectionX = mSelectionCellX * mGridSpacingX; | 693 | int selectionX = mSelectionCellX * mGridSpacingX; |
686 | int top = mSelectionYTop - 2 *mGridSpacingY; | 694 | int top = mSelectionYTop - 2 *mGridSpacingY; |
687 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 695 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
688 | clearSelection(); | 696 | clearSelection(); |
689 | repaintContents( selectionX, top, | 697 | repaintContents( selectionX, top, |
690 | mGridSpacingX, hei ,false ); | 698 | mGridSpacingX, hei ,false ); |
691 | } | 699 | } |
692 | 700 | ||
693 | } | 701 | } |
694 | void KOAgenda::startSelectAction(QPoint viewportPos) | 702 | void KOAgenda::startSelectAction(QPoint viewportPos) |
695 | { | 703 | { |
696 | 704 | ||
697 | emit signalClearSelection(); | 705 | emit signalClearSelection(); |
698 | slotClearSelection(); | 706 | slotClearSelection(); |
699 | 707 | ||
700 | mActionType = SELECT; | 708 | mActionType = SELECT; |
701 | 709 | ||
702 | int x,y; | 710 | int x,y; |
703 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 711 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
704 | int gx,gy; | 712 | int gx,gy; |
705 | contentsToGrid(x,y,gx,gy); | 713 | contentsToGrid(x,y,gx,gy); |
706 | 714 | ||
707 | mStartCellX = gx; | 715 | mStartCellX = gx; |
708 | mStartCellY = gy; | 716 | mStartCellY = gy; |
709 | mCurrentCellX = gx; | 717 | mCurrentCellX = gx; |
710 | mCurrentCellY = gy; | 718 | mCurrentCellY = gy; |
711 | 719 | ||
712 | // Store new selection | 720 | // Store new selection |
713 | mSelectionCellX = gx; | 721 | mSelectionCellX = gx; |
714 | mSelectionYTop = gy * mGridSpacingY; | 722 | mSelectionYTop = gy * mGridSpacingY; |
715 | mSelectionHeight = mGridSpacingY; | 723 | mSelectionHeight = mGridSpacingY; |
716 | 724 | ||
717 | // Paint new selection | 725 | // Paint new selection |
718 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 726 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
719 | mGridSpacingX-1, mSelectionHeight ); | 727 | mGridSpacingX-1, mSelectionHeight ); |
720 | } | 728 | } |
721 | 729 | ||
722 | void KOAgenda::performSelectAction(QPoint viewportPos) | 730 | void KOAgenda::performSelectAction(QPoint viewportPos) |
723 | { | 731 | { |
724 | int x,y; | 732 | int x,y; |
725 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 733 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
726 | int gx,gy; | 734 | int gx,gy; |
727 | contentsToGrid(x,y,gx,gy); | 735 | contentsToGrid(x,y,gx,gy); |
728 | 736 | ||
729 | QPoint clipperPos = clipper()-> | 737 | QPoint clipperPos = clipper()-> |
730 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 738 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
731 | 739 | ||
732 | // Scroll if cursor was moved to upper or lower end of agenda. | 740 | // Scroll if cursor was moved to upper or lower end of agenda. |
733 | if (clipperPos.y() < mScrollBorderWidth) { | 741 | if (clipperPos.y() < mScrollBorderWidth) { |
734 | mScrollUpTimer.start(mScrollDelay); | 742 | mScrollUpTimer.start(mScrollDelay); |
735 | } else if (visibleHeight() - clipperPos.y() < | 743 | } else if (visibleHeight() - clipperPos.y() < |
736 | mScrollBorderWidth) { | 744 | mScrollBorderWidth) { |
737 | mScrollDownTimer.start(mScrollDelay); | 745 | mScrollDownTimer.start(mScrollDelay); |
738 | } else { | 746 | } else { |
739 | mScrollUpTimer.stop(); | 747 | mScrollUpTimer.stop(); |
740 | mScrollDownTimer.stop(); | 748 | mScrollDownTimer.stop(); |
741 | } | 749 | } |
742 | 750 | ||
743 | if ( gy > mCurrentCellY ) { | 751 | if ( gy > mCurrentCellY ) { |
744 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 752 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
745 | 753 | ||
746 | 754 | ||
747 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 755 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
748 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 756 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
749 | mGridSpacingX, mSelectionYTop, | 757 | mGridSpacingX, mSelectionYTop, |
750 | mGridSpacingX, mSelectionHeight , false); | 758 | mGridSpacingX, mSelectionHeight , false); |
751 | 759 | ||
752 | mCurrentCellY = gy; | 760 | mCurrentCellY = gy; |
753 | } else if ( gy < mCurrentCellY ) { | 761 | } else if ( gy < mCurrentCellY ) { |
754 | if ( gy >= mStartCellY ) { | 762 | if ( gy >= mStartCellY ) { |
755 | int selectionHeight = mSelectionHeight; | 763 | int selectionHeight = mSelectionHeight; |
756 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 764 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
757 | 765 | ||
758 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 766 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
759 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 767 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
760 | mGridSpacingX, mSelectionYTop, | 768 | mGridSpacingX, mSelectionYTop, |
761 | mGridSpacingX, selectionHeight,false ); | 769 | mGridSpacingX, selectionHeight,false ); |
762 | 770 | ||
763 | mCurrentCellY = gy; | 771 | mCurrentCellY = gy; |
764 | } else { | 772 | } else { |
765 | } | 773 | } |
766 | } | 774 | } |
767 | } | 775 | } |
768 | 776 | ||
769 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 777 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
770 | { | 778 | { |
771 | mActionType = NOP; | 779 | mActionType = NOP; |
772 | mScrollUpTimer.stop(); | 780 | mScrollUpTimer.stop(); |
773 | mScrollDownTimer.stop(); | 781 | mScrollDownTimer.stop(); |
774 | 782 | ||
775 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 783 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
776 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 784 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
777 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 785 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
778 | } | 786 | } |
779 | } | 787 | } |
780 | 788 | ||
781 | void KOAgenda::startItemAction(QPoint viewportPos) | 789 | void KOAgenda::startItemAction(QPoint viewportPos) |
782 | { | 790 | { |
783 | int x,y; | 791 | int x,y; |
784 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 792 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
785 | int gx,gy; | 793 | int gx,gy; |
786 | contentsToGrid(x,y,gx,gy); | 794 | contentsToGrid(x,y,gx,gy); |
787 | 795 | ||
788 | mStartCellX = gx; | 796 | mStartCellX = gx; |
789 | mStartCellY = gy; | 797 | mStartCellY = gy; |
790 | mCurrentCellX = gx; | 798 | mCurrentCellX = gx; |
791 | mCurrentCellY = gy; | 799 | mCurrentCellY = gy; |
792 | 800 | ||
793 | if (mAllDayMode) { | 801 | if (mAllDayMode) { |
794 | int gridDistanceX = (x - gx * mGridSpacingX); | 802 | int gridDistanceX = (x - gx * mGridSpacingX); |
795 | if (gridDistanceX < mResizeBorderWidth && | 803 | if (gridDistanceX < mResizeBorderWidth && |
796 | mActionItem->cellX() == mCurrentCellX) { | 804 | mActionItem->cellX() == mCurrentCellX) { |
797 | mActionType = RESIZELEFT; | 805 | mActionType = RESIZELEFT; |
798 | setCursor(sizeHorCursor); | 806 | setCursor(sizeHorCursor); |
799 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 807 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
800 | mActionItem->cellXWidth() == mCurrentCellX) { | 808 | mActionItem->cellXWidth() == mCurrentCellX) { |
801 | mActionType = RESIZERIGHT; | 809 | mActionType = RESIZERIGHT; |
802 | setCursor(sizeHorCursor); | 810 | setCursor(sizeHorCursor); |
803 | } else { | 811 | } else { |
804 | mActionType = MOVE; | 812 | mActionType = MOVE; |
805 | mActionItem->startMove(); | 813 | mActionItem->startMove(); |
806 | setCursor(sizeAllCursor); | 814 | setCursor(sizeAllCursor); |
807 | } | 815 | } |
808 | } else { | 816 | } else { |
809 | int gridDistanceY = (y - gy * mGridSpacingY); | 817 | int gridDistanceY = (y - gy * mGridSpacingY); |
810 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 818 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
811 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 819 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
812 | mActionItem->cellYTop() == mCurrentCellY && | 820 | mActionItem->cellYTop() == mCurrentCellY && |
813 | !mActionItem->firstMultiItem()) { | 821 | !mActionItem->firstMultiItem()) { |
814 | mActionType = RESIZETOP; | 822 | mActionType = RESIZETOP; |
815 | setCursor(sizeVerCursor); | 823 | setCursor(sizeVerCursor); |
816 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 824 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
817 | mActionItem->cellYBottom() == mCurrentCellY && | 825 | mActionItem->cellYBottom() == mCurrentCellY && |
818 | !mActionItem->lastMultiItem()) { | 826 | !mActionItem->lastMultiItem()) { |
819 | mActionType = RESIZEBOTTOM; | 827 | mActionType = RESIZEBOTTOM; |
820 | setCursor(sizeVerCursor); | 828 | setCursor(sizeVerCursor); |
821 | } else { | 829 | } else { |
822 | mActionType = MOVE; | 830 | mActionType = MOVE; |
823 | mActionItem->startMove(); | 831 | mActionItem->startMove(); |
824 | setCursor(sizeAllCursor); | 832 | setCursor(sizeAllCursor); |
825 | } | 833 | } |
826 | } | 834 | } |
827 | } | 835 | } |
828 | 836 | ||
829 | void KOAgenda::performItemAction(QPoint viewportPos) | 837 | void KOAgenda::performItemAction(QPoint viewportPos) |
830 | { | 838 | { |
831 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 839 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
832 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 840 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
833 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 841 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
834 | // point = clipper()->mapFromGlobal(point); | 842 | // point = clipper()->mapFromGlobal(point); |
835 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 843 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
836 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 844 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
837 | int x,y; | 845 | int x,y; |
838 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 846 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
839 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 847 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
840 | int gx,gy; | 848 | int gx,gy; |
841 | contentsToGrid(x,y,gx,gy); | 849 | contentsToGrid(x,y,gx,gy); |
842 | QPoint clipperPos = clipper()-> | 850 | QPoint clipperPos = clipper()-> |
843 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 851 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
844 | 852 | ||
845 | // Cursor left active agenda area. | 853 | // Cursor left active agenda area. |
846 | // This starts a drag. | 854 | // This starts a drag. |
847 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 855 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
848 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 856 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
849 | if ( mActionType == MOVE ) { | 857 | if ( mActionType == MOVE ) { |
850 | mScrollUpTimer.stop(); | 858 | mScrollUpTimer.stop(); |
851 | mScrollDownTimer.stop(); | 859 | mScrollDownTimer.stop(); |
852 | mActionItem->resetMove(); | 860 | mActionItem->resetMove(); |
853 | placeSubCells( mActionItem ); | 861 | placeSubCells( mActionItem ); |
854 | // emit startDragSignal( mActionItem->incidence() ); | 862 | // emit startDragSignal( mActionItem->incidence() ); |
855 | setCursor( arrowCursor ); | 863 | setCursor( arrowCursor ); |
856 | mActionItem = 0; | 864 | mActionItem = 0; |
857 | mActionType = NOP; | 865 | mActionType = NOP; |
858 | mItemMoved = 0; | 866 | mItemMoved = 0; |
859 | return; | 867 | return; |
860 | } | 868 | } |
861 | } else { | 869 | } else { |
862 | switch ( mActionType ) { | 870 | switch ( mActionType ) { |
863 | case MOVE: | 871 | case MOVE: |
864 | setCursor( sizeAllCursor ); | 872 | setCursor( sizeAllCursor ); |
865 | break; | 873 | break; |
866 | case RESIZETOP: | 874 | case RESIZETOP: |
867 | case RESIZEBOTTOM: | 875 | case RESIZEBOTTOM: |
868 | setCursor( sizeVerCursor ); | 876 | setCursor( sizeVerCursor ); |
869 | break; | 877 | break; |
870 | case RESIZELEFT: | 878 | case RESIZELEFT: |
871 | case RESIZERIGHT: | 879 | case RESIZERIGHT: |
872 | setCursor( sizeHorCursor ); | 880 | setCursor( sizeHorCursor ); |
873 | break; | 881 | break; |
874 | default: | 882 | default: |
875 | setCursor( arrowCursor ); | 883 | setCursor( arrowCursor ); |
876 | } | 884 | } |
877 | } | 885 | } |
878 | 886 | ||
879 | // Scroll if item was moved to upper or lower end of agenda. | 887 | // Scroll if item was moved to upper or lower end of agenda. |
880 | if (clipperPos.y() < mScrollBorderWidth) { | 888 | if (clipperPos.y() < mScrollBorderWidth) { |
881 | mScrollUpTimer.start(mScrollDelay); | 889 | mScrollUpTimer.start(mScrollDelay); |
882 | } else if (visibleHeight() - clipperPos.y() < | 890 | } else if (visibleHeight() - clipperPos.y() < |
883 | mScrollBorderWidth) { | 891 | mScrollBorderWidth) { |
884 | mScrollDownTimer.start(mScrollDelay); | 892 | mScrollDownTimer.start(mScrollDelay); |
885 | } else { | 893 | } else { |
886 | mScrollUpTimer.stop(); | 894 | mScrollUpTimer.stop(); |
887 | mScrollDownTimer.stop(); | 895 | mScrollDownTimer.stop(); |
888 | } | 896 | } |
889 | 897 | ||
890 | // Move or resize item if necessary | 898 | // Move or resize item if necessary |
891 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 899 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
892 | mItemMoved = true; | 900 | mItemMoved = true; |
893 | mActionItem->raise(); | 901 | mActionItem->raise(); |
894 | if (mActionType == MOVE) { | 902 | if (mActionType == MOVE) { |
895 | // Move all items belonging to a multi item | 903 | // Move all items belonging to a multi item |
896 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 904 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
897 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 905 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
898 | if (!moveItem) moveItem = mActionItem; | 906 | if (!moveItem) moveItem = mActionItem; |
899 | while (moveItem) { | 907 | while (moveItem) { |
900 | int dy; | 908 | int dy; |
901 | if (isMultiItem) dy = 0; | 909 | if (isMultiItem) dy = 0; |
902 | else dy = gy - mCurrentCellY; | 910 | else dy = gy - mCurrentCellY; |
903 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 911 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
904 | int x,y; | 912 | int x,y; |
905 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 913 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
906 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 914 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
907 | mGridSpacingY * moveItem->cellHeight()); | 915 | mGridSpacingY * moveItem->cellHeight()); |
908 | moveChild(moveItem,x,y); | 916 | moveChild(moveItem,x,y); |
909 | moveItem = moveItem->nextMultiItem(); | 917 | moveItem = moveItem->nextMultiItem(); |
910 | } | 918 | } |
911 | } else if (mActionType == RESIZETOP) { | 919 | } else if (mActionType == RESIZETOP) { |
912 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 920 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
913 | mActionItem->expandTop(gy - mCurrentCellY); | 921 | mActionItem->expandTop(gy - mCurrentCellY); |
914 | mActionItem->resize(mActionItem->width(), | 922 | mActionItem->resize(mActionItem->width(), |
915 | mGridSpacingY * mActionItem->cellHeight()); | 923 | mGridSpacingY * mActionItem->cellHeight()); |
916 | int x,y; | 924 | int x,y; |
917 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 925 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
918 | //moveChild(mActionItem,childX(mActionItem),y); | 926 | //moveChild(mActionItem,childX(mActionItem),y); |
919 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 927 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
920 | } | 928 | } |
921 | } else if (mActionType == RESIZEBOTTOM) { | 929 | } else if (mActionType == RESIZEBOTTOM) { |
922 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 930 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
923 | mActionItem->expandBottom(gy - mCurrentCellY); | 931 | mActionItem->expandBottom(gy - mCurrentCellY); |
924 | mActionItem->resize(mActionItem->width(), | 932 | mActionItem->resize(mActionItem->width(), |
925 | mGridSpacingY * mActionItem->cellHeight()); | 933 | mGridSpacingY * mActionItem->cellHeight()); |
926 | } | 934 | } |
927 | } else if (mActionType == RESIZELEFT) { | 935 | } else if (mActionType == RESIZELEFT) { |
928 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 936 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
929 | mActionItem->expandLeft(gx - mCurrentCellX); | 937 | mActionItem->expandLeft(gx - mCurrentCellX); |
930 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 938 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
931 | mActionItem->height()); | 939 | mActionItem->height()); |
932 | int x,y; | 940 | int x,y; |
933 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 941 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
934 | moveChild(mActionItem,x,childY(mActionItem)); | 942 | moveChild(mActionItem,x,childY(mActionItem)); |
935 | } | 943 | } |
936 | } else if (mActionType == RESIZERIGHT) { | 944 | } else if (mActionType == RESIZERIGHT) { |
937 | if (mCurrentCellX >= mActionItem->cellX()) { | 945 | if (mCurrentCellX >= mActionItem->cellX()) { |
938 | mActionItem->expandRight(gx - mCurrentCellX); | 946 | mActionItem->expandRight(gx - mCurrentCellX); |
939 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 947 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
940 | mActionItem->height()); | 948 | mActionItem->height()); |
941 | } | 949 | } |
942 | } | 950 | } |
943 | mCurrentCellX = gx; | 951 | mCurrentCellX = gx; |
944 | mCurrentCellY = gy; | 952 | mCurrentCellY = gy; |
945 | } | 953 | } |
946 | } | 954 | } |
947 | 955 | ||
948 | void KOAgenda::endItemAction() | 956 | void KOAgenda::endItemAction() |
949 | { | 957 | { |
950 | 958 | ||
951 | if ( mItemMoved ) { | 959 | if ( mItemMoved ) { |
952 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 960 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
953 | if ( !placeItem ) { | 961 | if ( !placeItem ) { |
954 | placeItem = mActionItem; | 962 | placeItem = mActionItem; |
955 | } | 963 | } |
956 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 964 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
957 | Incidence* oldInc = placeItem->incidence(); | 965 | Incidence* oldInc = placeItem->incidence(); |
958 | placeItem->recreateIncidence(); | 966 | placeItem->recreateIncidence(); |
959 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 967 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
960 | } | 968 | } |
961 | int type = mActionType; | 969 | int type = mActionType; |
962 | if ( mAllDayMode ) | 970 | if ( mAllDayMode ) |
963 | type = -1; | 971 | type = -1; |
964 | KOAgendaItem *modifiedItem = placeItem; | 972 | KOAgendaItem *modifiedItem = placeItem; |
965 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 973 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
966 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 974 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
967 | KOAgendaItem *item; | 975 | KOAgendaItem *item; |
968 | 976 | ||
969 | if ( placeItem->incidence()->typeID() == todoID ) { | 977 | if ( placeItem->incidence()->typeID() == todoID ) { |
970 | mSelectedItem = 0; | 978 | mSelectedItem = 0; |
971 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 979 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
972 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 980 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
973 | emit itemModified( modifiedItem, mActionType ); | 981 | emit itemModified( modifiedItem, mActionType ); |
974 | } | 982 | } |
975 | else { | 983 | else { |
976 | 984 | ||
977 | 985 | ||
978 | globalFlagBlockAgendaItemPaint = 1; | 986 | globalFlagBlockAgendaItemPaint = 1; |
979 | for ( item=oldconflictItems.first(); item != 0; | 987 | for ( item=oldconflictItems.first(); item != 0; |
980 | item=oldconflictItems.next() ) { | 988 | item=oldconflictItems.next() ) { |
981 | placeSubCells(item); | 989 | placeSubCells(item); |
982 | } | 990 | } |
983 | while ( placeItem ) { | 991 | while ( placeItem ) { |
984 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 992 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
985 | oldconflictItems = placeItem->conflictItems(); | 993 | oldconflictItems = placeItem->conflictItems(); |
986 | for ( item=oldconflictItems.first(); item != 0; | 994 | for ( item=oldconflictItems.first(); item != 0; |
987 | item=oldconflictItems.next() ) { | 995 | item=oldconflictItems.next() ) { |
988 | placeSubCells(item); | 996 | placeSubCells(item); |
989 | } | 997 | } |
990 | placeSubCells( placeItem ); | 998 | placeSubCells( placeItem ); |
991 | placeItem = placeItem->nextMultiItem(); | 999 | placeItem = placeItem->nextMultiItem(); |
992 | } | 1000 | } |
993 | globalFlagBlockAgendaItemPaint = 0; | 1001 | globalFlagBlockAgendaItemPaint = 0; |
994 | for ( item=oldconflictItems.first(); item != 0; | 1002 | for ( item=oldconflictItems.first(); item != 0; |
995 | item=oldconflictItems.next() ) { | 1003 | item=oldconflictItems.next() ) { |
996 | globalFlagBlockAgendaItemUpdate = 0; | 1004 | globalFlagBlockAgendaItemUpdate = 0; |
997 | item->repaintMe(); | 1005 | item->repaintMe(); |
998 | globalFlagBlockAgendaItemUpdate = 1; | 1006 | globalFlagBlockAgendaItemUpdate = 1; |
999 | item->repaint( false ); | 1007 | item->repaint( false ); |
1000 | } | 1008 | } |
1001 | placeItem = modifiedItem; | 1009 | placeItem = modifiedItem; |
1002 | 1010 | ||
1003 | while ( placeItem ) { | 1011 | while ( placeItem ) { |
1004 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1012 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1005 | globalFlagBlockAgendaItemUpdate = 0; | 1013 | globalFlagBlockAgendaItemUpdate = 0; |
1006 | placeItem->repaintMe(); | 1014 | placeItem->repaintMe(); |
1007 | globalFlagBlockAgendaItemUpdate = 1; | 1015 | globalFlagBlockAgendaItemUpdate = 1; |
1008 | placeItem->repaint(false); | 1016 | placeItem->repaint(false); |
1009 | placeItem = placeItem->nextMultiItem(); | 1017 | placeItem = placeItem->nextMultiItem(); |
1010 | } | 1018 | } |
1011 | emit itemModified( modifiedItem, mActionType ); | 1019 | emit itemModified( modifiedItem, mActionType ); |
1012 | 1020 | ||
1013 | 1021 | ||
1014 | placeItem = modifiedItem; | 1022 | placeItem = modifiedItem; |
1015 | while ( placeItem ) { | 1023 | while ( placeItem ) { |