author | zautrix <zautrix> | 2005-06-03 11:21:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-03 11:21:25 (UTC) |
commit | dd80f5bb6eee2a924748b7d0acfb4fb892f58b86 (patch) (unidiff) | |
tree | 24f60fbd7cfaf5b4a9f545d4f61a7deebbd7d725 | |
parent | ab0f6af57ebf5b5a6fa2f7e6209fe04aafbfb14f (diff) | |
download | kdepimpi-dd80f5bb6eee2a924748b7d0acfb4fb892f58b86.zip kdepimpi-dd80f5bb6eee2a924748b7d0acfb4fb892f58b86.tar.gz kdepimpi-dd80f5bb6eee2a924748b7d0acfb4fb892f58b86.tar.bz2 |
block move change
-rw-r--r-- | korganizer/koagenda.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 99009a5..cdeeac5 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -32,856 +32,857 @@ | |||
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 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 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 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 455 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
455 | } else { | 456 | } else { |
456 | viewportPos = me->pos(); | 457 | viewportPos = me->pos(); |
457 | } | 458 | } |
458 | 459 | ||
459 | switch (me->type()) { | 460 | switch (me->type()) { |
460 | case QEvent::MouseButtonPress: | 461 | case QEvent::MouseButtonPress: |
461 | if (me->button() == LeftButton) { | 462 | if (me->button() == LeftButton) { |
462 | mPopupTimer->start( 600 ); | 463 | mPopupTimer->start( 600 ); |
463 | mLeftMouseDown = true; | 464 | mLeftMouseDown = true; |
464 | } | 465 | } |
465 | blockMoving = true; | 466 | blockMoving = true; |
466 | startX = viewportPos.x(); | 467 | startX = viewportPos.x(); |
467 | startY = viewportPos.y(); | 468 | startY = viewportPos.y(); |
468 | mPopupPos = me->globalPos(); | 469 | mPopupPos = me->globalPos(); |
469 | if (object != viewport()) { | 470 | if (object != viewport()) { |
470 | mPopupItem = (KOAgendaItem *)object; | 471 | mPopupItem = (KOAgendaItem *)object; |
471 | mPopupKind = 1; | 472 | mPopupKind = 1; |
472 | if (me->button() == RightButton) { | 473 | if (me->button() == RightButton) { |
473 | mPopupKind = 3; | 474 | mPopupKind = 3; |
474 | popupMenu(); | 475 | popupMenu(); |
475 | } else if (me->button() == LeftButton) { | 476 | } else if (me->button() == LeftButton) { |
476 | mActionItem = (KOAgendaItem *)object; | 477 | mActionItem = (KOAgendaItem *)object; |
477 | if (mActionItem) { | 478 | if (mActionItem) { |
478 | emit signalClearSelection(); | 479 | emit signalClearSelection(); |
479 | slotClearSelection(); | 480 | slotClearSelection(); |
480 | selectItem(mActionItem); | 481 | selectItem(mActionItem); |
481 | Incidence *incidence = mActionItem->incidence(); | 482 | Incidence *incidence = mActionItem->incidence(); |
482 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 483 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
483 | mActionItem = 0; | 484 | mActionItem = 0; |
484 | } else { | 485 | } else { |
485 | startItemAction(viewportPos); | 486 | startItemAction(viewportPos); |
486 | } | 487 | } |
487 | } | 488 | } |
488 | } | 489 | } |
489 | } else { // ---------- viewport() | 490 | } else { // ---------- viewport() |
490 | mPopupItem = 0; | 491 | mPopupItem = 0; |
491 | mPopupKind = 2; | 492 | mPopupKind = 2; |
492 | selectItem(0); | 493 | selectItem(0); |
493 | mActionItem = 0; | 494 | mActionItem = 0; |
494 | if (me->button() == RightButton) { | 495 | if (me->button() == RightButton) { |
495 | int x,y; | 496 | int x,y; |
496 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 497 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
497 | int gx,gy; | 498 | int gx,gy; |
498 | contentsToGrid(x,y,gx,gy); | 499 | contentsToGrid(x,y,gx,gy); |
499 | mCurrentCellX = gx; | 500 | mCurrentCellX = gx; |
500 | mCurrentCellY = gy; | 501 | mCurrentCellY = gy; |
501 | mStartCellX = gx; | 502 | mStartCellX = gx; |
502 | mStartCellY = gy; | 503 | mStartCellY = gy; |
503 | mPopupKind = 4; | 504 | mPopupKind = 4; |
504 | popupMenu(); | 505 | popupMenu(); |
505 | } else if (me->button() == LeftButton) { | 506 | } else if (me->button() == LeftButton) { |
506 | setCursor(arrowCursor); | 507 | setCursor(arrowCursor); |
507 | startSelectAction(viewportPos); | 508 | startSelectAction(viewportPos); |
508 | } | 509 | } |
509 | } | 510 | } |
510 | break; | 511 | break; |
511 | 512 | ||
512 | case QEvent::MouseButtonRelease: | 513 | case QEvent::MouseButtonRelease: |
513 | if (me->button() == LeftButton ) { | 514 | if (me->button() == LeftButton ) { |
514 | mPopupTimer->stop(); | 515 | mPopupTimer->stop(); |
515 | } | 516 | } |
516 | if (object != viewport()) { | 517 | if (object != viewport()) { |
517 | if (me->button() == LeftButton && mLeftMouseDown) { | 518 | if (me->button() == LeftButton && mLeftMouseDown) { |
518 | if (mActionItem) { | 519 | if (mActionItem) { |
519 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 520 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
520 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 521 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
521 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 522 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
522 | mScrollUpTimer.stop(); | 523 | mScrollUpTimer.stop(); |
523 | mScrollDownTimer.stop(); | 524 | mScrollDownTimer.stop(); |
524 | mActionItem->resetMove(); | 525 | mActionItem->resetMove(); |
525 | placeSubCells( mActionItem ); | 526 | placeSubCells( mActionItem ); |
526 | // emit startDragSignal( mActionItem->incidence() ); | 527 | // emit startDragSignal( mActionItem->incidence() ); |
527 | setCursor( arrowCursor ); | 528 | setCursor( arrowCursor ); |
528 | mActionItem = 0; | 529 | mActionItem = 0; |
529 | mActionType = NOP; | 530 | mActionType = NOP; |
530 | mItemMoved = 0; | 531 | mItemMoved = 0; |
531 | mLeftMouseDown = false; | 532 | mLeftMouseDown = false; |
532 | return true; | 533 | return true; |
533 | } | 534 | } |
534 | endItemAction(); | 535 | endItemAction(); |
535 | } | 536 | } |
536 | } | 537 | } |
537 | 538 | ||
538 | } else { // ---------- viewport() | 539 | } else { // ---------- viewport() |
539 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 540 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
540 | endSelectAction( true ); // emit new event signal | 541 | endSelectAction( true ); // emit new event signal |
541 | } | 542 | } |
542 | } | 543 | } |
543 | if (me->button() == LeftButton) | 544 | if (me->button() == LeftButton) |
544 | mLeftMouseDown = false; | 545 | mLeftMouseDown = false; |
545 | 546 | ||
546 | break; | 547 | break; |
547 | 548 | ||
548 | case QEvent::MouseMove: | 549 | case QEvent::MouseMove: |
549 | //qDebug("mm "); | 550 | //qDebug("mm "); |
550 | if ( !mLeftMouseDown ) | 551 | if ( !mLeftMouseDown ) |
551 | return false; | 552 | return false; |
552 | if ( blockMoving ) { | 553 | if ( blockMoving ) { |
553 | int dX, dY; | 554 | int dX, dY; |
554 | dX = startX - viewportPos.x(); | 555 | dX = startX - viewportPos.x(); |
555 | if ( dX < 0 ) | 556 | if ( dX < 0 ) |
556 | dX = -dX; | 557 | dX = -dX; |
557 | dY = viewportPos.y() - startY; | 558 | dY = viewportPos.y() - startY; |
558 | if ( dY < 0 ) | 559 | if ( dY < 0 ) |
559 | dY = -dY; | 560 | dY = -dY; |
560 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 561 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
561 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 562 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
562 | blockMoving = false; | 563 | blockMoving = false; |
563 | } | 564 | } |
564 | } | 565 | } |
565 | if ( ! blockMoving ) | 566 | if ( ! blockMoving ) |
566 | mPopupTimer->stop(); | 567 | mPopupTimer->stop(); |
567 | if (object != viewport()) { | 568 | if (object != viewport()) { |
568 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 569 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
569 | if (!moveItem->incidence()->isReadOnly() ) { | 570 | if (!moveItem->incidence()->isReadOnly() ) { |
570 | if (!mActionItem) | 571 | if (!mActionItem) |
571 | setNoActionCursor(moveItem,viewportPos); | 572 | setNoActionCursor(moveItem,viewportPos); |
572 | else { | 573 | else { |
573 | if ( !blockMoving ) | 574 | if ( !blockMoving ) |
574 | performItemAction(viewportPos); | 575 | performItemAction(viewportPos); |
575 | } | 576 | } |
576 | } | 577 | } |
577 | } else { // ---------- viewport() | 578 | } else { // ---------- viewport() |
578 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 579 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
579 | if ( mActionType == SELECT ) { | 580 | if ( mActionType == SELECT ) { |
580 | performSelectAction( viewportPos ); | 581 | performSelectAction( viewportPos ); |
581 | } | 582 | } |
582 | } | 583 | } |
583 | break; | 584 | break; |
584 | 585 | ||
585 | case QEvent::MouseButtonDblClick: | 586 | case QEvent::MouseButtonDblClick: |
586 | mPopupTimer->stop(); | 587 | mPopupTimer->stop(); |
587 | if (object == viewport()) { | 588 | if (object == viewport()) { |
588 | selectItem(0); | 589 | selectItem(0); |
589 | int x,y; | 590 | int x,y; |
590 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 591 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
591 | int gx,gy; | 592 | int gx,gy; |
592 | contentsToGrid(x,y,gx,gy); | 593 | contentsToGrid(x,y,gx,gy); |
593 | emit newEventSignal(gx,gy); | 594 | emit newEventSignal(gx,gy); |
594 | } else { | 595 | } else { |
595 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 596 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
596 | selectItem(doubleClickedItem); | 597 | selectItem(doubleClickedItem); |
597 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 598 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
598 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 599 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
599 | else | 600 | else |
600 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 601 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
601 | } | 602 | } |
602 | break; | 603 | break; |
603 | 604 | ||
604 | default: | 605 | default: |
605 | break; | 606 | break; |
606 | } | 607 | } |
607 | return true; | 608 | return true; |
608 | 609 | ||
609 | } | 610 | } |
610 | 611 | ||
611 | void KOAgenda::newItem( int item ) | 612 | void KOAgenda::newItem( int item ) |
612 | { | 613 | { |
613 | if ( item == 1 ) { //new event | 614 | if ( item == 1 ) { //new event |
614 | newEventSignal(mStartCellX ,mStartCellY ); | 615 | newEventSignal(mStartCellX ,mStartCellY ); |
615 | } else | 616 | } else |
616 | if ( item == 2 ) { //new event | 617 | if ( item == 2 ) { //new event |
617 | newTodoSignal(mStartCellX ,mStartCellY ); | 618 | newTodoSignal(mStartCellX ,mStartCellY ); |
618 | } else | 619 | } else |
619 | { | 620 | { |
620 | emit showDateView( item, mStartCellX ); | 621 | emit showDateView( item, mStartCellX ); |
621 | // 3Day view | 622 | // 3Day view |
622 | // 4Week view | 623 | // 4Week view |
623 | // 5Month view | 624 | // 5Month view |
624 | // 6Journal view | 625 | // 6Journal view |
625 | } | 626 | } |
626 | } | 627 | } |
627 | void KOAgenda::slotClearSelection() | 628 | void KOAgenda::slotClearSelection() |
628 | { | 629 | { |
629 | if (mSelectionHeight) { | 630 | if (mSelectionHeight) { |
630 | int selectionX = mSelectionCellX * mGridSpacingX; | 631 | int selectionX = mSelectionCellX * mGridSpacingX; |
631 | int top = mSelectionYTop - 2 *mGridSpacingY; | 632 | int top = mSelectionYTop - 2 *mGridSpacingY; |
632 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 633 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
633 | clearSelection(); | 634 | clearSelection(); |
634 | repaintContents( selectionX, top, | 635 | repaintContents( selectionX, top, |
635 | mGridSpacingX, hei ,false ); | 636 | mGridSpacingX, hei ,false ); |
636 | } | 637 | } |
637 | 638 | ||
638 | } | 639 | } |
639 | void KOAgenda::startSelectAction(QPoint viewportPos) | 640 | void KOAgenda::startSelectAction(QPoint viewportPos) |
640 | { | 641 | { |
641 | 642 | ||
642 | emit signalClearSelection(); | 643 | emit signalClearSelection(); |
643 | slotClearSelection(); | 644 | slotClearSelection(); |
644 | 645 | ||
645 | mActionType = SELECT; | 646 | mActionType = SELECT; |
646 | 647 | ||
647 | int x,y; | 648 | int x,y; |
648 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 649 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
649 | int gx,gy; | 650 | int gx,gy; |
650 | contentsToGrid(x,y,gx,gy); | 651 | contentsToGrid(x,y,gx,gy); |
651 | 652 | ||
652 | mStartCellX = gx; | 653 | mStartCellX = gx; |
653 | mStartCellY = gy; | 654 | mStartCellY = gy; |
654 | mCurrentCellX = gx; | 655 | mCurrentCellX = gx; |
655 | mCurrentCellY = gy; | 656 | mCurrentCellY = gy; |
656 | 657 | ||
657 | // Store new selection | 658 | // Store new selection |
658 | mSelectionCellX = gx; | 659 | mSelectionCellX = gx; |
659 | mSelectionYTop = gy * mGridSpacingY; | 660 | mSelectionYTop = gy * mGridSpacingY; |
660 | mSelectionHeight = mGridSpacingY; | 661 | mSelectionHeight = mGridSpacingY; |
661 | 662 | ||
662 | // Paint new selection | 663 | // Paint new selection |
663 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 664 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
664 | mGridSpacingX-1, mSelectionHeight ); | 665 | mGridSpacingX-1, mSelectionHeight ); |
665 | } | 666 | } |
666 | 667 | ||
667 | void KOAgenda::performSelectAction(QPoint viewportPos) | 668 | void KOAgenda::performSelectAction(QPoint viewportPos) |
668 | { | 669 | { |
669 | int x,y; | 670 | int x,y; |
670 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 671 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
671 | int gx,gy; | 672 | int gx,gy; |
672 | contentsToGrid(x,y,gx,gy); | 673 | contentsToGrid(x,y,gx,gy); |
673 | 674 | ||
674 | QPoint clipperPos = clipper()-> | 675 | QPoint clipperPos = clipper()-> |
675 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 676 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
676 | 677 | ||
677 | // Scroll if cursor was moved to upper or lower end of agenda. | 678 | // Scroll if cursor was moved to upper or lower end of agenda. |
678 | if (clipperPos.y() < mScrollBorderWidth) { | 679 | if (clipperPos.y() < mScrollBorderWidth) { |
679 | mScrollUpTimer.start(mScrollDelay); | 680 | mScrollUpTimer.start(mScrollDelay); |
680 | } else if (visibleHeight() - clipperPos.y() < | 681 | } else if (visibleHeight() - clipperPos.y() < |
681 | mScrollBorderWidth) { | 682 | mScrollBorderWidth) { |
682 | mScrollDownTimer.start(mScrollDelay); | 683 | mScrollDownTimer.start(mScrollDelay); |
683 | } else { | 684 | } else { |
684 | mScrollUpTimer.stop(); | 685 | mScrollUpTimer.stop(); |
685 | mScrollDownTimer.stop(); | 686 | mScrollDownTimer.stop(); |
686 | } | 687 | } |
687 | 688 | ||
688 | if ( gy > mCurrentCellY ) { | 689 | if ( gy > mCurrentCellY ) { |
689 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 690 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
690 | 691 | ||
691 | 692 | ||
692 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 693 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
693 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 694 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
694 | mGridSpacingX, mSelectionYTop, | 695 | mGridSpacingX, mSelectionYTop, |
695 | mGridSpacingX, mSelectionHeight , false); | 696 | mGridSpacingX, mSelectionHeight , false); |
696 | 697 | ||
697 | mCurrentCellY = gy; | 698 | mCurrentCellY = gy; |
698 | } else if ( gy < mCurrentCellY ) { | 699 | } else if ( gy < mCurrentCellY ) { |
699 | if ( gy >= mStartCellY ) { | 700 | if ( gy >= mStartCellY ) { |
700 | int selectionHeight = mSelectionHeight; | 701 | int selectionHeight = mSelectionHeight; |
701 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 702 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
702 | 703 | ||
703 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 704 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
704 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 705 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
705 | mGridSpacingX, mSelectionYTop, | 706 | mGridSpacingX, mSelectionYTop, |
706 | mGridSpacingX, selectionHeight,false ); | 707 | mGridSpacingX, selectionHeight,false ); |
707 | 708 | ||
708 | mCurrentCellY = gy; | 709 | mCurrentCellY = gy; |
709 | } else { | 710 | } else { |
710 | } | 711 | } |
711 | } | 712 | } |
712 | } | 713 | } |
713 | 714 | ||
714 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 715 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
715 | { | 716 | { |
716 | mActionType = NOP; | 717 | mActionType = NOP; |
717 | mScrollUpTimer.stop(); | 718 | mScrollUpTimer.stop(); |
718 | mScrollDownTimer.stop(); | 719 | mScrollDownTimer.stop(); |
719 | 720 | ||
720 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 721 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
721 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 722 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
722 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 723 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
723 | } | 724 | } |
724 | } | 725 | } |
725 | 726 | ||
726 | void KOAgenda::startItemAction(QPoint viewportPos) | 727 | void KOAgenda::startItemAction(QPoint viewportPos) |
727 | { | 728 | { |
728 | int x,y; | 729 | int x,y; |
729 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 730 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
730 | int gx,gy; | 731 | int gx,gy; |
731 | contentsToGrid(x,y,gx,gy); | 732 | contentsToGrid(x,y,gx,gy); |
732 | 733 | ||
733 | mStartCellX = gx; | 734 | mStartCellX = gx; |
734 | mStartCellY = gy; | 735 | mStartCellY = gy; |
735 | mCurrentCellX = gx; | 736 | mCurrentCellX = gx; |
736 | mCurrentCellY = gy; | 737 | mCurrentCellY = gy; |
737 | 738 | ||
738 | if (mAllDayMode) { | 739 | if (mAllDayMode) { |
739 | int gridDistanceX = (x - gx * mGridSpacingX); | 740 | int gridDistanceX = (x - gx * mGridSpacingX); |
740 | if (gridDistanceX < mResizeBorderWidth && | 741 | if (gridDistanceX < mResizeBorderWidth && |
741 | mActionItem->cellX() == mCurrentCellX) { | 742 | mActionItem->cellX() == mCurrentCellX) { |
742 | mActionType = RESIZELEFT; | 743 | mActionType = RESIZELEFT; |
743 | setCursor(sizeHorCursor); | 744 | setCursor(sizeHorCursor); |
744 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 745 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
745 | mActionItem->cellXWidth() == mCurrentCellX) { | 746 | mActionItem->cellXWidth() == mCurrentCellX) { |
746 | mActionType = RESIZERIGHT; | 747 | mActionType = RESIZERIGHT; |
747 | setCursor(sizeHorCursor); | 748 | setCursor(sizeHorCursor); |
748 | } else { | 749 | } else { |
749 | mActionType = MOVE; | 750 | mActionType = MOVE; |
750 | mActionItem->startMove(); | 751 | mActionItem->startMove(); |
751 | setCursor(sizeAllCursor); | 752 | setCursor(sizeAllCursor); |
752 | } | 753 | } |
753 | } else { | 754 | } else { |
754 | int gridDistanceY = (y - gy * mGridSpacingY); | 755 | int gridDistanceY = (y - gy * mGridSpacingY); |
755 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 756 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
756 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 757 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
757 | mActionItem->cellYTop() == mCurrentCellY && | 758 | mActionItem->cellYTop() == mCurrentCellY && |
758 | !mActionItem->firstMultiItem()) { | 759 | !mActionItem->firstMultiItem()) { |
759 | mActionType = RESIZETOP; | 760 | mActionType = RESIZETOP; |
760 | setCursor(sizeVerCursor); | 761 | setCursor(sizeVerCursor); |
761 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 762 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
762 | mActionItem->cellYBottom() == mCurrentCellY && | 763 | mActionItem->cellYBottom() == mCurrentCellY && |
763 | !mActionItem->lastMultiItem()) { | 764 | !mActionItem->lastMultiItem()) { |
764 | mActionType = RESIZEBOTTOM; | 765 | mActionType = RESIZEBOTTOM; |
765 | setCursor(sizeVerCursor); | 766 | setCursor(sizeVerCursor); |
766 | } else { | 767 | } else { |
767 | mActionType = MOVE; | 768 | mActionType = MOVE; |
768 | mActionItem->startMove(); | 769 | mActionItem->startMove(); |
769 | setCursor(sizeAllCursor); | 770 | setCursor(sizeAllCursor); |
770 | } | 771 | } |
771 | } | 772 | } |
772 | } | 773 | } |
773 | 774 | ||
774 | void KOAgenda::performItemAction(QPoint viewportPos) | 775 | void KOAgenda::performItemAction(QPoint viewportPos) |
775 | { | 776 | { |
776 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 777 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
777 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 778 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
778 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 779 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
779 | // point = clipper()->mapFromGlobal(point); | 780 | // point = clipper()->mapFromGlobal(point); |
780 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 781 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
781 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 782 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
782 | int x,y; | 783 | int x,y; |
783 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 784 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
784 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 785 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
785 | int gx,gy; | 786 | int gx,gy; |
786 | contentsToGrid(x,y,gx,gy); | 787 | contentsToGrid(x,y,gx,gy); |
787 | QPoint clipperPos = clipper()-> | 788 | QPoint clipperPos = clipper()-> |
788 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 789 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
789 | 790 | ||
790 | // Cursor left active agenda area. | 791 | // Cursor left active agenda area. |
791 | // This starts a drag. | 792 | // This starts a drag. |
792 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 793 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
793 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 794 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
794 | if ( mActionType == MOVE ) { | 795 | if ( mActionType == MOVE ) { |
795 | mScrollUpTimer.stop(); | 796 | mScrollUpTimer.stop(); |
796 | mScrollDownTimer.stop(); | 797 | mScrollDownTimer.stop(); |
797 | mActionItem->resetMove(); | 798 | mActionItem->resetMove(); |
798 | placeSubCells( mActionItem ); | 799 | placeSubCells( mActionItem ); |
799 | // emit startDragSignal( mActionItem->incidence() ); | 800 | // emit startDragSignal( mActionItem->incidence() ); |
800 | setCursor( arrowCursor ); | 801 | setCursor( arrowCursor ); |
801 | mActionItem = 0; | 802 | mActionItem = 0; |
802 | mActionType = NOP; | 803 | mActionType = NOP; |
803 | mItemMoved = 0; | 804 | mItemMoved = 0; |
804 | return; | 805 | return; |
805 | } | 806 | } |
806 | } else { | 807 | } else { |
807 | switch ( mActionType ) { | 808 | switch ( mActionType ) { |
808 | case MOVE: | 809 | case MOVE: |
809 | setCursor( sizeAllCursor ); | 810 | setCursor( sizeAllCursor ); |
810 | break; | 811 | break; |
811 | case RESIZETOP: | 812 | case RESIZETOP: |
812 | case RESIZEBOTTOM: | 813 | case RESIZEBOTTOM: |
813 | setCursor( sizeVerCursor ); | 814 | setCursor( sizeVerCursor ); |
814 | break; | 815 | break; |
815 | case RESIZELEFT: | 816 | case RESIZELEFT: |
816 | case RESIZERIGHT: | 817 | case RESIZERIGHT: |
817 | setCursor( sizeHorCursor ); | 818 | setCursor( sizeHorCursor ); |
818 | break; | 819 | break; |
819 | default: | 820 | default: |
820 | setCursor( arrowCursor ); | 821 | setCursor( arrowCursor ); |
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | // Scroll if item was moved to upper or lower end of agenda. | 825 | // Scroll if item was moved to upper or lower end of agenda. |
825 | if (clipperPos.y() < mScrollBorderWidth) { | 826 | if (clipperPos.y() < mScrollBorderWidth) { |
826 | mScrollUpTimer.start(mScrollDelay); | 827 | mScrollUpTimer.start(mScrollDelay); |
827 | } else if (visibleHeight() - clipperPos.y() < | 828 | } else if (visibleHeight() - clipperPos.y() < |
828 | mScrollBorderWidth) { | 829 | mScrollBorderWidth) { |
829 | mScrollDownTimer.start(mScrollDelay); | 830 | mScrollDownTimer.start(mScrollDelay); |
830 | } else { | 831 | } else { |
831 | mScrollUpTimer.stop(); | 832 | mScrollUpTimer.stop(); |
832 | mScrollDownTimer.stop(); | 833 | mScrollDownTimer.stop(); |
833 | } | 834 | } |
834 | 835 | ||
835 | // Move or resize item if necessary | 836 | // Move or resize item if necessary |
836 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 837 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
837 | mItemMoved = true; | 838 | mItemMoved = true; |
838 | mActionItem->raise(); | 839 | mActionItem->raise(); |
839 | if (mActionType == MOVE) { | 840 | if (mActionType == MOVE) { |
840 | // Move all items belonging to a multi item | 841 | // Move all items belonging to a multi item |
841 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 842 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
842 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 843 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
843 | if (!moveItem) moveItem = mActionItem; | 844 | if (!moveItem) moveItem = mActionItem; |
844 | while (moveItem) { | 845 | while (moveItem) { |
845 | int dy; | 846 | int dy; |
846 | if (isMultiItem) dy = 0; | 847 | if (isMultiItem) dy = 0; |
847 | else dy = gy - mCurrentCellY; | 848 | else dy = gy - mCurrentCellY; |
848 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 849 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
849 | int x,y; | 850 | int x,y; |
850 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 851 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
851 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 852 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
852 | mGridSpacingY * moveItem->cellHeight()); | 853 | mGridSpacingY * moveItem->cellHeight()); |
853 | moveChild(moveItem,x,y); | 854 | moveChild(moveItem,x,y); |
854 | moveItem = moveItem->nextMultiItem(); | 855 | moveItem = moveItem->nextMultiItem(); |
855 | } | 856 | } |
856 | } else if (mActionType == RESIZETOP) { | 857 | } else if (mActionType == RESIZETOP) { |
857 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 858 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
858 | mActionItem->expandTop(gy - mCurrentCellY); | 859 | mActionItem->expandTop(gy - mCurrentCellY); |
859 | mActionItem->resize(mActionItem->width(), | 860 | mActionItem->resize(mActionItem->width(), |
860 | mGridSpacingY * mActionItem->cellHeight()); | 861 | mGridSpacingY * mActionItem->cellHeight()); |
861 | int x,y; | 862 | int x,y; |
862 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 863 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
863 | //moveChild(mActionItem,childX(mActionItem),y); | 864 | //moveChild(mActionItem,childX(mActionItem),y); |
864 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 865 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
865 | } | 866 | } |
866 | } else if (mActionType == RESIZEBOTTOM) { | 867 | } else if (mActionType == RESIZEBOTTOM) { |
867 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 868 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
868 | mActionItem->expandBottom(gy - mCurrentCellY); | 869 | mActionItem->expandBottom(gy - mCurrentCellY); |
869 | mActionItem->resize(mActionItem->width(), | 870 | mActionItem->resize(mActionItem->width(), |
870 | mGridSpacingY * mActionItem->cellHeight()); | 871 | mGridSpacingY * mActionItem->cellHeight()); |
871 | } | 872 | } |
872 | } else if (mActionType == RESIZELEFT) { | 873 | } else if (mActionType == RESIZELEFT) { |
873 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 874 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
874 | mActionItem->expandLeft(gx - mCurrentCellX); | 875 | mActionItem->expandLeft(gx - mCurrentCellX); |
875 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 876 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
876 | mActionItem->height()); | 877 | mActionItem->height()); |
877 | int x,y; | 878 | int x,y; |
878 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 879 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
879 | moveChild(mActionItem,x,childY(mActionItem)); | 880 | moveChild(mActionItem,x,childY(mActionItem)); |
880 | } | 881 | } |
881 | } else if (mActionType == RESIZERIGHT) { | 882 | } else if (mActionType == RESIZERIGHT) { |
882 | if (mCurrentCellX >= mActionItem->cellX()) { | 883 | if (mCurrentCellX >= mActionItem->cellX()) { |
883 | mActionItem->expandRight(gx - mCurrentCellX); | 884 | mActionItem->expandRight(gx - mCurrentCellX); |
884 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 885 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
885 | mActionItem->height()); | 886 | mActionItem->height()); |
886 | } | 887 | } |
887 | } | 888 | } |