-rw-r--r-- | korganizer/koagenda.cpp | 14 | ||||
-rw-r--r-- | korganizer/koagenda.h | 1 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 7e9fa71..7d9d674 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,641 +1,646 @@ | |||
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 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | //delete minutes; | 88 | //delete minutes; |
89 | } | 89 | } |
90 | void MarcusBains::hideMe() | 90 | void MarcusBains::hideMe() |
91 | { | 91 | { |
92 | hide(); mTimeBox->hide(); | 92 | hide(); mTimeBox->hide(); |
93 | } | 93 | } |
94 | int MarcusBains::todayColumn() | 94 | int MarcusBains::todayColumn() |
95 | { | 95 | { |
96 | QDate currentDate = QDate::currentDate(); | 96 | QDate currentDate = QDate::currentDate(); |
97 | 97 | ||
98 | DateList dateList = agenda->dateList(); | 98 | DateList dateList = agenda->dateList(); |
99 | DateList::ConstIterator it; | 99 | DateList::ConstIterator it; |
100 | int col = 0; | 100 | int col = 0; |
101 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 101 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
102 | if((*it) == currentDate) | 102 | if((*it) == currentDate) |
103 | return KOGlobals::self()->reverseLayout() ? | 103 | return KOGlobals::self()->reverseLayout() ? |
104 | agenda->columns() - 1 - col : col; | 104 | agenda->columns() - 1 - col : col; |
105 | ++col; | 105 | ++col; |
106 | } | 106 | } |
107 | 107 | ||
108 | return -1; | 108 | return -1; |
109 | } | 109 | } |
110 | void MarcusBains::updateLoc() | 110 | void MarcusBains::updateLoc() |
111 | { | 111 | { |
112 | updateLocation(); | 112 | if ( !agenda->invalidPixmap() ) |
113 | updateLocation(); | ||
113 | } | 114 | } |
114 | void MarcusBains::updateLocation(bool recalculate) | 115 | void MarcusBains::updateLocation(bool recalculate) |
115 | { | 116 | { |
116 | 117 | ||
117 | QTime tim = QTime::currentTime(); | 118 | QTime tim = QTime::currentTime(); |
118 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 119 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
119 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 120 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
120 | recalculate = true; | 121 | recalculate = true; |
121 | 122 | ||
122 | int mins = tim.hour()*60 + tim.minute(); | 123 | int mins = tim.hour()*60 + tim.minute(); |
123 | int minutesPerCell = 24 * 60 / agenda->rows(); | 124 | int minutesPerCell = 24 * 60 / agenda->rows(); |
124 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 125 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
125 | int today = recalculate ? todayColumn() : oldToday; | 126 | int today = recalculate ? todayColumn() : oldToday; |
126 | int x = agenda->gridSpacingX()*today; | 127 | int x = agenda->gridSpacingX()*today; |
127 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 128 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
128 | 129 | ||
129 | oldTime = tim; | 130 | oldTime = tim; |
130 | oldToday = today; | 131 | oldToday = today; |
131 | 132 | ||
132 | if(disabled || (today<0)) { | 133 | if(disabled || (today<0)) { |
133 | hide(); mTimeBox->hide(); | 134 | hide(); mTimeBox->hide(); |
134 | return; | 135 | return; |
135 | } else { | 136 | } else { |
136 | show(); mTimeBox->show(); | 137 | show(); mTimeBox->show(); |
137 | } | 138 | } |
138 | 139 | ||
139 | if(recalculate) | 140 | if(recalculate) |
140 | setFixedSize(agenda->gridSpacingX(),1); | 141 | setFixedSize(agenda->gridSpacingX(),1); |
141 | agenda->moveChild(this, x, y); | 142 | agenda->moveChild(this, x, y); |
142 | raise(); | 143 | raise(); |
143 | 144 | ||
144 | if(recalculate) | 145 | if(recalculate) |
145 | //mTimeBox->setFont(QFont("helvetica",10)); | 146 | //mTimeBox->setFont(QFont("helvetica",10)); |
146 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 147 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
147 | 148 | ||
148 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 149 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
149 | mTimeBox->adjustSize(); | 150 | mTimeBox->adjustSize(); |
150 | // the -2 below is there because there is a bug in this program | 151 | // the -2 below is there because there is a bug in this program |
151 | // somewhere, where the last column of this widget is a few pixels | 152 | // somewhere, where the last column of this widget is a few pixels |
152 | // narrower than the other columns. | 153 | // narrower than the other columns. |
153 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 154 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
154 | agenda->moveChild(mTimeBox, | 155 | agenda->moveChild(mTimeBox, |
155 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 156 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
156 | y-mTimeBox->height()); | 157 | y-mTimeBox->height()); |
157 | mTimeBox->raise(); | 158 | mTimeBox->raise(); |
158 | //mTimeBox->setAutoMask(true); | 159 | //mTimeBox->setAutoMask(true); |
159 | int secs = QTime::currentTime().second(); | 160 | int secs = QTime::currentTime().second(); |
160 | minutes->start( (60 - secs +1)*1000 ,true); | 161 | minutes->start( (60 - secs +1)*1000 ,true); |
161 | } | 162 | } |
162 | 163 | ||
163 | 164 | ||
164 | //////////////////////////////////////////////////////////////////////////// | 165 | //////////////////////////////////////////////////////////////////////////// |
165 | 166 | ||
166 | 167 | ||
167 | /* | 168 | /* |
168 | Create an agenda widget with rows rows and columns columns. | 169 | Create an agenda widget with rows rows and columns columns. |
169 | */ | 170 | */ |
170 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 171 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
171 | const char *name,WFlags f) : | 172 | const char *name,WFlags f) : |
172 | QScrollView(parent,name,f) | 173 | QScrollView(parent,name,f) |
173 | { | 174 | { |
174 | 175 | ||
175 | mAllAgendaPopup = 0; | 176 | mAllAgendaPopup = 0; |
176 | mColumns = columns; | 177 | mColumns = columns; |
177 | mRows = rows; | 178 | mRows = rows; |
178 | mGridSpacingY = rowSize; | 179 | mGridSpacingY = rowSize; |
179 | mAllDayMode = false; | 180 | mAllDayMode = false; |
180 | #ifndef DESKTOP_VERSION | 181 | #ifndef DESKTOP_VERSION |
181 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 182 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
182 | #endif | 183 | #endif |
183 | mHolidayMask = 0; | 184 | mHolidayMask = 0; |
184 | init(); | 185 | init(); |
185 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 186 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
186 | } | 187 | } |
187 | 188 | ||
188 | /* | 189 | /* |
189 | Create an agenda widget with columns columns and one row. This is used for | 190 | Create an agenda widget with columns columns and one row. This is used for |
190 | all-day events. | 191 | all-day events. |
191 | */ | 192 | */ |
192 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 193 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
193 | QScrollView(parent,name,f) | 194 | QScrollView(parent,name,f) |
194 | { | 195 | { |
195 | mAllAgendaPopup = 0; | 196 | mAllAgendaPopup = 0; |
196 | blockResize = false; | 197 | blockResize = false; |
197 | mColumns = columns; | 198 | mColumns = columns; |
198 | mRows = 1; | 199 | mRows = 1; |
199 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 200 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
200 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 201 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
201 | mAllDayMode = true; | 202 | mAllDayMode = true; |
202 | #ifndef DESKTOP_VERSION | 203 | #ifndef DESKTOP_VERSION |
203 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 204 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
204 | #endif | 205 | #endif |
205 | mHolidayMask = 0; | 206 | mHolidayMask = 0; |
206 | init(); | 207 | init(); |
207 | } | 208 | } |
208 | 209 | ||
209 | 210 | ||
210 | KOAgenda::~KOAgenda() | 211 | KOAgenda::~KOAgenda() |
211 | { | 212 | { |
212 | if(mMarcusBains) delete mMarcusBains; | 213 | if(mMarcusBains) delete mMarcusBains; |
213 | 214 | ||
214 | } | 215 | } |
215 | 216 | ||
216 | Incidence *KOAgenda::selectedIncidence() const | 217 | Incidence *KOAgenda::selectedIncidence() const |
217 | { | 218 | { |
218 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 219 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | QDate KOAgenda::selectedIncidenceDate() const | 223 | QDate KOAgenda::selectedIncidenceDate() const |
223 | { | 224 | { |
224 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 225 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
225 | } | 226 | } |
226 | 227 | ||
227 | 228 | ||
228 | void KOAgenda::init() | 229 | void KOAgenda::init() |
229 | { | 230 | { |
230 | mPopupTimer = new QTimer(this); | 231 | mPopupTimer = new QTimer(this); |
231 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 232 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
232 | 233 | ||
233 | mNewItemPopup = new QPopupMenu( this ); | 234 | mNewItemPopup = new QPopupMenu( this ); |
234 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 235 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
235 | QString pathString = ""; | 236 | QString pathString = ""; |
236 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 237 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
237 | if ( QApplication::desktop()->width() < 480 ) | 238 | if ( QApplication::desktop()->width() < 480 ) |
238 | pathString += "icons16/"; | 239 | pathString += "icons16/"; |
239 | } else | 240 | } else |
240 | pathString += "iconsmini/"; | 241 | pathString += "iconsmini/"; |
241 | 242 | ||
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
244 | mNewItemPopup->insertSeparator ( ); | 245 | mNewItemPopup->insertSeparator ( ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 248 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
248 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 249 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
249 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 250 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
250 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 251 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
251 | #ifndef _WIN32_ | 252 | #ifndef _WIN32_ |
252 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 253 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
253 | viewport()->setWFlags ( wflags); | 254 | viewport()->setWFlags ( wflags); |
254 | #endif | 255 | #endif |
255 | mGridSpacingX = 80; | 256 | mGridSpacingX = 80; |
256 | mResizeBorderWidth = 8; | 257 | mResizeBorderWidth = 8; |
257 | mScrollBorderWidth = 8; | 258 | mScrollBorderWidth = 8; |
258 | mScrollDelay = 30; | 259 | mScrollDelay = 30; |
259 | mScrollOffset = 10; | 260 | mScrollOffset = 10; |
260 | mPaintPixmap.resize( 20,20); | 261 | mPaintPixmap.resize( 20,20); |
261 | //enableClipper(true); | 262 | //enableClipper(true); |
262 | 263 | ||
263 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 264 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
264 | // effect. Has to be fixed. | 265 | // effect. Has to be fixed. |
265 | setFocusPolicy(WheelFocus); | 266 | setFocusPolicy(WheelFocus); |
266 | 267 | ||
267 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 268 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
268 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 269 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
269 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 270 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
270 | 271 | ||
271 | mStartCellX = 0; | 272 | mStartCellX = 0; |
272 | mStartCellY = 0; | 273 | mStartCellY = 0; |
273 | mCurrentCellX = 0; | 274 | mCurrentCellX = 0; |
274 | mCurrentCellY = 0; | 275 | mCurrentCellY = 0; |
275 | 276 | ||
276 | mSelectionCellX = 0; | 277 | mSelectionCellX = 0; |
277 | mSelectionYTop = 0; | 278 | mSelectionYTop = 0; |
278 | mSelectionHeight = 0; | 279 | mSelectionHeight = 0; |
279 | 280 | ||
280 | mOldLowerScrollValue = -1; | 281 | mOldLowerScrollValue = -1; |
281 | mOldUpperScrollValue = -1; | 282 | mOldUpperScrollValue = -1; |
282 | 283 | ||
283 | mClickedItem = 0; | 284 | mClickedItem = 0; |
284 | 285 | ||
285 | mActionItem = 0; | 286 | mActionItem = 0; |
286 | mActionType = NOP; | 287 | mActionType = NOP; |
287 | mItemMoved = false; | 288 | mItemMoved = false; |
288 | 289 | ||
289 | mSelectedItem = 0; | 290 | mSelectedItem = 0; |
290 | 291 | ||
291 | // mItems.setAutoDelete(true); | 292 | // mItems.setAutoDelete(true); |
292 | 293 | ||
293 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 294 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
294 | 295 | ||
295 | viewport()->update(); | 296 | viewport()->update(); |
296 | 297 | ||
297 | setMinimumSize(30, 1); | 298 | setMinimumSize(30, 1); |
298 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 299 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
299 | 300 | ||
300 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 301 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
301 | // controlled in a way that the contents horizontally always fits. Then it is | 302 | // controlled in a way that the contents horizontally always fits. Then it is |
302 | // not necessary to turn off the scrollbar. | 303 | // not necessary to turn off the scrollbar. |
303 | setHScrollBarMode(AlwaysOff); | 304 | setHScrollBarMode(AlwaysOff); |
304 | if ( ! mAllDayMode ) | 305 | if ( ! mAllDayMode ) |
305 | setVScrollBarMode(AlwaysOn); | 306 | setVScrollBarMode(AlwaysOn); |
306 | else | 307 | else |
307 | setVScrollBarMode(AlwaysOff); | 308 | setVScrollBarMode(AlwaysOff); |
308 | 309 | ||
309 | setStartHour(KOPrefs::instance()->mDayBegins); | 310 | setStartHour(KOPrefs::instance()->mDayBegins); |
310 | 311 | ||
311 | calculateWorkingHours(); | 312 | calculateWorkingHours(); |
312 | 313 | ||
313 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 314 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
314 | SLOT(checkScrollBoundaries(int))); | 315 | SLOT(checkScrollBoundaries(int))); |
315 | 316 | ||
316 | // Create the Marcus Bains line. | 317 | // Create the Marcus Bains line. |
317 | if(mAllDayMode) | 318 | if(mAllDayMode) |
318 | mMarcusBains = 0; | 319 | mMarcusBains = 0; |
319 | else { | 320 | else { |
320 | mMarcusBains = new MarcusBains(this); | 321 | mMarcusBains = new MarcusBains(this); |
321 | addChild(mMarcusBains); | 322 | addChild(mMarcusBains); |
322 | } | 323 | } |
323 | mPopupKind = 0; | 324 | mPopupKind = 0; |
324 | mPopupItem = 0; | 325 | mPopupItem = 0; |
325 | mInvalidPixmap = false; | 326 | mInvalidPixmap = false; |
326 | 327 | ||
327 | } | 328 | } |
328 | 329 | ||
329 | void KOAgenda::shrinkPixmap() | 330 | void KOAgenda::shrinkPixmap() |
330 | { | 331 | { |
331 | mPaintPixmap.resize( 20,20); | 332 | mPaintPixmap.resize( 20,20); |
332 | mInvalidPixmap = true; | 333 | mInvalidPixmap = true; |
333 | } | 334 | } |
334 | void KOAgenda::slotContentMove(int,int) | 335 | void KOAgenda::slotContentMove(int,int) |
335 | { | 336 | { |
336 | emit sendPing(); | 337 | emit sendPing(); |
337 | if ( mActionType == NOP ) | 338 | if ( mActionType == NOP ) |
338 | slotClearSelection(); | 339 | slotClearSelection(); |
339 | if ( mSelectedItem && !mActionItem ) { | 340 | if ( mSelectedItem && !mActionItem ) { |
340 | deselectItem(); | 341 | deselectItem(); |
341 | emit incidenceSelected( 0 ); | 342 | emit incidenceSelected( 0 ); |
342 | } | 343 | } |
343 | } | 344 | } |
344 | void KOAgenda::clear() | 345 | void KOAgenda::clear() |
345 | { | 346 | { |
346 | KOAgendaItem *item; | 347 | KOAgendaItem *item; |
347 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 348 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
348 | mUnusedItems.append( item ); | 349 | mUnusedItems.append( item ); |
349 | //item->hide(); | 350 | //item->hide(); |
350 | } | 351 | } |
351 | mItems.clear(); | 352 | mItems.clear(); |
352 | mSelectedItem = 0; | 353 | mSelectedItem = 0; |
353 | clearSelection(); | 354 | clearSelection(); |
354 | } | 355 | } |
355 | 356 | ||
356 | void KOAgenda::clearSelection() | 357 | void KOAgenda::clearSelection() |
357 | { | 358 | { |
358 | mSelectionCellX = 0; | 359 | mSelectionCellX = 0; |
359 | mSelectionYTop = 0; | 360 | mSelectionYTop = 0; |
360 | mSelectionHeight = 0; | 361 | mSelectionHeight = 0; |
361 | } | 362 | } |
362 | 363 | ||
363 | void KOAgenda::marcus_bains() | 364 | void KOAgenda::marcus_bains() |
364 | { | 365 | { |
365 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 366 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
366 | } | 367 | } |
367 | 368 | ||
368 | 369 | ||
369 | void KOAgenda::changeColumns(int columns) | 370 | void KOAgenda::changeColumns(int columns) |
370 | { | 371 | { |
371 | if (columns == 0) { | 372 | if (columns == 0) { |
372 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 373 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
373 | return; | 374 | return; |
374 | } | 375 | } |
375 | clear(); | 376 | clear(); |
376 | mColumns = columns; | 377 | mColumns = columns; |
377 | computeSizes(); | 378 | computeSizes(); |
378 | if(mMarcusBains) mMarcusBains->hideMe(); | 379 | if(mMarcusBains) mMarcusBains->hideMe(); |
379 | } | 380 | } |
380 | 381 | ||
381 | /* | 382 | /* |
382 | This is the eventFilter function, which gets all events from the KOAgendaItems | 383 | This is the eventFilter function, which gets all events from the KOAgendaItems |
383 | contained in the agenda. It has to handle moving and resizing for all items. | 384 | contained in the agenda. It has to handle moving and resizing for all items. |
384 | */ | 385 | */ |
385 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 386 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
386 | { | 387 | { |
387 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 388 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
388 | switch(event->type()) { | 389 | switch(event->type()) { |
389 | case QEvent::MouseButtonPress: | 390 | case QEvent::MouseButtonPress: |
390 | case QEvent::MouseButtonDblClick: | 391 | case QEvent::MouseButtonDblClick: |
391 | case QEvent::MouseButtonRelease: | 392 | case QEvent::MouseButtonRelease: |
392 | case QEvent::MouseMove: | 393 | case QEvent::MouseMove: |
393 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 394 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
394 | 395 | ||
395 | case (QEvent::Leave): | 396 | case (QEvent::Leave): |
396 | if (!mActionItem) | 397 | if (!mActionItem) |
397 | setCursor(arrowCursor); | 398 | setCursor(arrowCursor); |
398 | return true; | 399 | return true; |
399 | 400 | ||
400 | default: | 401 | default: |
401 | return QScrollView::eventFilter(object,event); | 402 | return QScrollView::eventFilter(object,event); |
402 | } | 403 | } |
403 | } | 404 | } |
404 | void KOAgenda::popupMenu() | 405 | void KOAgenda::popupMenu() |
405 | { | 406 | { |
406 | mPopupTimer->stop(); | 407 | mPopupTimer->stop(); |
407 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 408 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
408 | if (mActionItem ) { | 409 | if (mActionItem ) { |
409 | endItemAction(); | 410 | endItemAction(); |
410 | } | 411 | } |
411 | mLeftMouseDown = false; // no more leftMouse computation | 412 | mLeftMouseDown = false; // no more leftMouse computation |
412 | if (mPopupItem) { | 413 | if (mPopupItem) { |
413 | //mClickedItem = mPopupItem; | 414 | //mClickedItem = mPopupItem; |
414 | selectItem(mPopupItem); | 415 | selectItem(mPopupItem); |
415 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 416 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
416 | mAllAgendaPopup->installEventFilter( this ); | 417 | mAllAgendaPopup->installEventFilter( this ); |
417 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 418 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
418 | 419 | ||
419 | } | 420 | } |
420 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 421 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
421 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 422 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
422 | endSelectAction( false ); // do not emit new event signal | 423 | endSelectAction( false ); // do not emit new event signal |
423 | mLeftMouseDown = false; // no more leftMouse computation | 424 | mLeftMouseDown = false; // no more leftMouse computation |
424 | } | 425 | } |
425 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 426 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
426 | mNewItemPopup->installEventFilter( this ); | 427 | mNewItemPopup->installEventFilter( this ); |
427 | mNewItemPopup->popup( mPopupPos); | 428 | mNewItemPopup->popup( mPopupPos); |
428 | 429 | ||
429 | } | 430 | } |
430 | mLeftMouseDown = false; | 431 | mLeftMouseDown = false; |
431 | mPopupItem = 0; | 432 | mPopupItem = 0; |
432 | mPopupKind = 0; | 433 | mPopupKind = 0; |
433 | } | 434 | } |
434 | void KOAgenda::categoryChanged(Incidence * inc) | 435 | void KOAgenda::categoryChanged(Incidence * inc) |
435 | { | 436 | { |
436 | KOAgendaItem *item; | 437 | KOAgendaItem *item; |
437 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 438 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
438 | if ( item->incidence() == inc ) { | 439 | if ( item->incidence() == inc ) { |
439 | item->initColor (); | 440 | item->initColor (); |
440 | item->updateItem(); | 441 | item->updateItem(); |
441 | } | 442 | } |
442 | } | 443 | } |
443 | } | 444 | } |
445 | bool KOAgenda::invalidPixmap() | ||
446 | { | ||
447 | return mInvalidPixmap; | ||
448 | } | ||
444 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 449 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
445 | { | 450 | { |
446 | 451 | ||
447 | if ( mInvalidPixmap ) { | 452 | if ( mInvalidPixmap ) { |
448 | mInvalidPixmap = false; | 453 | mInvalidPixmap = false; |
449 | qDebug("KO: Upsizing Pixmaps "); | 454 | qDebug("KO: efm Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); |
450 | computeSizes(); | 455 | computeSizes(); |
451 | emit updateViewSignal(); | 456 | emit updateViewSignal(); |
452 | return true; | 457 | return true; |
453 | } | 458 | } |
454 | emit sendPing(); | 459 | emit sendPing(); |
455 | static int startX = 0; | 460 | static int startX = 0; |
456 | static int startY = 0; | 461 | static int startY = 0; |
457 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 462 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
458 | static bool blockMoving = true; | 463 | static bool blockMoving = true; |
459 | 464 | ||
460 | //qDebug("KOAgenda::eventFilter_mous "); | 465 | //qDebug("KOAgenda::eventFilter_mous "); |
461 | if ( object == mNewItemPopup ) { | 466 | if ( object == mNewItemPopup ) { |
462 | //qDebug("mNewItemPopup "); | 467 | //qDebug("mNewItemPopup "); |
463 | if ( me->type() == QEvent::MouseButtonRelease ) { | 468 | if ( me->type() == QEvent::MouseButtonRelease ) { |
464 | mNewItemPopup->removeEventFilter( this ); | 469 | mNewItemPopup->removeEventFilter( this ); |
465 | int dX = me->globalPos().x() - mPopupPos.x();; | 470 | int dX = me->globalPos().x() - mPopupPos.x();; |
466 | if ( dX < 0 ) | 471 | if ( dX < 0 ) |
467 | dX = -dX; | 472 | dX = -dX; |
468 | int dY = me->globalPos().y() - mPopupPos.y(); | 473 | int dY = me->globalPos().y() - mPopupPos.y(); |
469 | if ( dY < 0 ) | 474 | if ( dY < 0 ) |
470 | dY = -dY; | 475 | dY = -dY; |
471 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 476 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
472 | mNewItemPopup->hide(); | 477 | mNewItemPopup->hide(); |
473 | } | 478 | } |
474 | } | 479 | } |
475 | return true; | 480 | return true; |
476 | } | 481 | } |
477 | if ( object == mAllAgendaPopup ) { | 482 | if ( object == mAllAgendaPopup ) { |
478 | //qDebug(" mAllAgendaPopup "); | 483 | //qDebug(" mAllAgendaPopup "); |
479 | if ( me->type() == QEvent::MouseButtonRelease ) { | 484 | if ( me->type() == QEvent::MouseButtonRelease ) { |
480 | mAllAgendaPopup->removeEventFilter( this ); | 485 | mAllAgendaPopup->removeEventFilter( this ); |
481 | int dX = me->globalPos().x() - mPopupPos.x();; | 486 | int dX = me->globalPos().x() - mPopupPos.x();; |
482 | if ( dX < 0 ) | 487 | if ( dX < 0 ) |
483 | dX = -dX; | 488 | dX = -dX; |
484 | int dY = me->globalPos().y() - mPopupPos.y(); | 489 | int dY = me->globalPos().y() - mPopupPos.y(); |
485 | if ( dY < 0 ) | 490 | if ( dY < 0 ) |
486 | dY = -dY; | 491 | dY = -dY; |
487 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 492 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
488 | mAllAgendaPopup->hide(); | 493 | mAllAgendaPopup->hide(); |
489 | } | 494 | } |
490 | } | 495 | } |
491 | return true; | 496 | return true; |
492 | } | 497 | } |
493 | QPoint viewportPos; | 498 | QPoint viewportPos; |
494 | if (object != viewport()) { | 499 | if (object != viewport()) { |
495 | blockmoveDist = blockmoveDist*2; | 500 | blockmoveDist = blockmoveDist*2; |
496 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 501 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
497 | } else { | 502 | } else { |
498 | viewportPos = me->pos(); | 503 | viewportPos = me->pos(); |
499 | } | 504 | } |
500 | bool objIsNotViewport = (object != viewport()); | 505 | bool objIsNotViewport = (object != viewport()); |
501 | bool leftButt = false; | 506 | bool leftButt = false; |
502 | #ifdef DESKTOP_VERSION | 507 | #ifdef DESKTOP_VERSION |
503 | leftButt = (me->button() == LeftButton); | 508 | leftButt = (me->button() == LeftButton); |
504 | #endif | 509 | #endif |
505 | switch (me->type()) { | 510 | switch (me->type()) { |
506 | case QEvent::MouseButtonPress: | 511 | case QEvent::MouseButtonPress: |
507 | if (me->button() == LeftButton) { | 512 | if (me->button() == LeftButton) { |
508 | mPopupTimer->start( 600 ); | 513 | mPopupTimer->start( 600 ); |
509 | mLeftMouseDown = true; | 514 | mLeftMouseDown = true; |
510 | } | 515 | } |
511 | blockMoving = true; | 516 | blockMoving = true; |
512 | startX = viewportPos.x(); | 517 | startX = viewportPos.x(); |
513 | startY = viewportPos.y(); | 518 | startY = viewportPos.y(); |
514 | mPopupPos = me->globalPos(); | 519 | mPopupPos = me->globalPos(); |
515 | if ( objIsNotViewport && !leftButt ) { | 520 | if ( objIsNotViewport && !leftButt ) { |
516 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 521 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
517 | if (mAllDayMode) { | 522 | if (mAllDayMode) { |
518 | if ( tempItem->height() > 10 ) { | 523 | if ( tempItem->height() > 10 ) { |
519 | int minV = tempItem->height()/4; | 524 | int minV = tempItem->height()/4; |
520 | if ( minV > (blockmoveDist/2)-2 ) { | 525 | if ( minV > (blockmoveDist/2)-2 ) { |
521 | if ( minV > blockmoveDist ) | 526 | if ( minV > blockmoveDist ) |
522 | minV = blockmoveDist; | 527 | minV = blockmoveDist; |
523 | else | 528 | else |
524 | minV = (blockmoveDist/2); | 529 | minV = (blockmoveDist/2); |
525 | } | 530 | } |
526 | bool border = false; | 531 | bool border = false; |
527 | int diff = tempItem->y() - viewportPos.y(); | 532 | int diff = tempItem->y() - viewportPos.y(); |
528 | if ( diff < 0 ) | 533 | if ( diff < 0 ) |
529 | diff *= -1; | 534 | diff *= -1; |
530 | if ( diff < minV ) { | 535 | if ( diff < minV ) { |
531 | border = true; | 536 | border = true; |
532 | objIsNotViewport = false; | 537 | objIsNotViewport = false; |
533 | } | 538 | } |
534 | if ( ! border ) { | 539 | if ( ! border ) { |
535 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 540 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
536 | if ( diff < 0 ) | 541 | if ( diff < 0 ) |
537 | diff *= -1; | 542 | diff *= -1; |
538 | if ( diff < minV ) { | 543 | if ( diff < minV ) { |
539 | border = true; | 544 | border = true; |
540 | objIsNotViewport = false; | 545 | objIsNotViewport = false; |
541 | } | 546 | } |
542 | } | 547 | } |
543 | } | 548 | } |
544 | } else { // not allday | 549 | } else { // not allday |
545 | if ( tempItem->width() > 10 ) { | 550 | if ( tempItem->width() > 10 ) { |
546 | int minH = tempItem->width()/4; | 551 | int minH = tempItem->width()/4; |
547 | if ( minH > (blockmoveDist/2)-2 ) { | 552 | if ( minH > (blockmoveDist/2)-2 ) { |
548 | if ( minH > blockmoveDist ) | 553 | if ( minH > blockmoveDist ) |
549 | minH = blockmoveDist; | 554 | minH = blockmoveDist; |
550 | else | 555 | else |
551 | minH = (blockmoveDist/2); | 556 | minH = (blockmoveDist/2); |
552 | } | 557 | } |
553 | bool border = false; | 558 | bool border = false; |
554 | int diff = tempItem->x() - viewportPos.x(); | 559 | int diff = tempItem->x() - viewportPos.x(); |
555 | if ( diff < 0 ) | 560 | if ( diff < 0 ) |
556 | diff *= -1; | 561 | diff *= -1; |
557 | if ( diff < minH ) { | 562 | if ( diff < minH ) { |
558 | border = true; | 563 | border = true; |
559 | objIsNotViewport = false; | 564 | objIsNotViewport = false; |
560 | } | 565 | } |
561 | if ( ! border ) { | 566 | if ( ! border ) { |
562 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 567 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
563 | if ( diff < 0 ) | 568 | if ( diff < 0 ) |
564 | diff *= -1; | 569 | diff *= -1; |
565 | if ( diff < minH ) { | 570 | if ( diff < minH ) { |
566 | border = true; | 571 | border = true; |
567 | objIsNotViewport = false; | 572 | objIsNotViewport = false; |
568 | } | 573 | } |
569 | } | 574 | } |
570 | } | 575 | } |
571 | } | 576 | } |
572 | } | 577 | } |
573 | if ( objIsNotViewport ) { | 578 | if ( objIsNotViewport ) { |
574 | mPopupItem = (KOAgendaItem *)object; | 579 | mPopupItem = (KOAgendaItem *)object; |
575 | mPopupKind = 1; | 580 | mPopupKind = 1; |
576 | if (me->button() == RightButton) { | 581 | if (me->button() == RightButton) { |
577 | mPopupKind = 3; | 582 | mPopupKind = 3; |
578 | popupMenu(); | 583 | popupMenu(); |
579 | } else if (me->button() == LeftButton) { | 584 | } else if (me->button() == LeftButton) { |
580 | mActionItem = (KOAgendaItem *)object; | 585 | mActionItem = (KOAgendaItem *)object; |
581 | if (mActionItem) { | 586 | if (mActionItem) { |
582 | emit signalClearSelection(); | 587 | emit signalClearSelection(); |
583 | slotClearSelection(); | 588 | slotClearSelection(); |
584 | selectItem(mActionItem); | 589 | selectItem(mActionItem); |
585 | Incidence *incidence = mActionItem->incidence(); | 590 | Incidence *incidence = mActionItem->incidence(); |
586 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { | 591 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { |
587 | mActionItem = 0; | 592 | mActionItem = 0; |
588 | } else { | 593 | } else { |
589 | startItemAction(viewportPos); | 594 | startItemAction(viewportPos); |
590 | } | 595 | } |
591 | } | 596 | } |
592 | } | 597 | } |
593 | } else { // ---------- viewport() | 598 | } else { // ---------- viewport() |
594 | mPopupItem = 0; | 599 | mPopupItem = 0; |
595 | mPopupKind = 2; | 600 | mPopupKind = 2; |
596 | selectItem(0); | 601 | selectItem(0); |
597 | mActionItem = 0; | 602 | mActionItem = 0; |
598 | if (me->button() == RightButton) { | 603 | if (me->button() == RightButton) { |
599 | int x,y; | 604 | int x,y; |
600 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 605 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
601 | int gx,gy; | 606 | int gx,gy; |
602 | contentsToGrid(x,y,gx,gy); | 607 | contentsToGrid(x,y,gx,gy); |
603 | mCurrentCellX = gx; | 608 | mCurrentCellX = gx; |
604 | mCurrentCellY = gy; | 609 | mCurrentCellY = gy; |
605 | mStartCellX = gx; | 610 | mStartCellX = gx; |
606 | mStartCellY = gy; | 611 | mStartCellY = gy; |
607 | mPopupKind = 4; | 612 | mPopupKind = 4; |
608 | popupMenu(); | 613 | popupMenu(); |
609 | } else if (me->button() == LeftButton) { | 614 | } else if (me->button() == LeftButton) { |
610 | setCursor(arrowCursor); | 615 | setCursor(arrowCursor); |
611 | startSelectAction(viewportPos); | 616 | startSelectAction(viewportPos); |
612 | } | 617 | } |
613 | } | 618 | } |
614 | break; | 619 | break; |
615 | 620 | ||
616 | case QEvent::MouseButtonRelease: | 621 | case QEvent::MouseButtonRelease: |
617 | if (me->button() == LeftButton ) { | 622 | if (me->button() == LeftButton ) { |
618 | mPopupTimer->stop(); | 623 | mPopupTimer->stop(); |
619 | } | 624 | } |
620 | if (object != viewport()) { | 625 | if (object != viewport()) { |
621 | if (me->button() == LeftButton && mLeftMouseDown) { | 626 | if (me->button() == LeftButton && mLeftMouseDown) { |
622 | if (mActionItem) { | 627 | if (mActionItem) { |
623 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 628 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
624 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 629 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
625 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 630 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
626 | mScrollUpTimer.stop(); | 631 | mScrollUpTimer.stop(); |
627 | mScrollDownTimer.stop(); | 632 | mScrollDownTimer.stop(); |
628 | mActionItem->resetMove(); | 633 | mActionItem->resetMove(); |
629 | placeSubCells( mActionItem ); | 634 | placeSubCells( mActionItem ); |
630 | // emit startDragSignal( mActionItem->incidence() ); | 635 | // emit startDragSignal( mActionItem->incidence() ); |
631 | setCursor( arrowCursor ); | 636 | setCursor( arrowCursor ); |
632 | mActionItem = 0; | 637 | mActionItem = 0; |
633 | mActionType = NOP; | 638 | mActionType = NOP; |
634 | mItemMoved = 0; | 639 | mItemMoved = 0; |
635 | mLeftMouseDown = false; | 640 | mLeftMouseDown = false; |
636 | return true; | 641 | return true; |
637 | } | 642 | } |
638 | endItemAction(); | 643 | endItemAction(); |
639 | } | 644 | } |
640 | } | 645 | } |
641 | 646 | ||
@@ -1092,389 +1097,390 @@ void KOAgenda::endItemAction() | |||
1092 | globalFlagBlockAgendaItemUpdate = 0; | 1097 | globalFlagBlockAgendaItemUpdate = 0; |
1093 | item->paintMe(false); | 1098 | item->paintMe(false); |
1094 | globalFlagBlockAgendaItemUpdate = 1; | 1099 | globalFlagBlockAgendaItemUpdate = 1; |
1095 | item->repaint(false); | 1100 | item->repaint(false); |
1096 | } | 1101 | } |
1097 | */ | 1102 | */ |
1098 | 1103 | ||
1099 | 1104 | ||
1100 | } | 1105 | } |
1101 | 1106 | ||
1102 | } | 1107 | } |
1103 | if ( mActionItem ) | 1108 | if ( mActionItem ) |
1104 | emit incidenceSelected( mActionItem->incidence() ); | 1109 | emit incidenceSelected( mActionItem->incidence() ); |
1105 | mScrollUpTimer.stop(); | 1110 | mScrollUpTimer.stop(); |
1106 | mScrollDownTimer.stop(); | 1111 | mScrollDownTimer.stop(); |
1107 | setCursor( arrowCursor ); | 1112 | setCursor( arrowCursor ); |
1108 | mActionItem = 0; | 1113 | mActionItem = 0; |
1109 | mActionType = NOP; | 1114 | mActionType = NOP; |
1110 | mItemMoved = 0; | 1115 | mItemMoved = 0; |
1111 | 1116 | ||
1112 | } | 1117 | } |
1113 | 1118 | ||
1114 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1119 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1115 | { | 1120 | { |
1116 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1121 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1117 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1122 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1118 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1123 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1119 | // point = clipper()->mapFromGlobal(point); | 1124 | // point = clipper()->mapFromGlobal(point); |
1120 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1125 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1121 | 1126 | ||
1122 | int x,y; | 1127 | int x,y; |
1123 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1128 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1124 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1129 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1125 | int gx,gy; | 1130 | int gx,gy; |
1126 | contentsToGrid(x,y,gx,gy); | 1131 | contentsToGrid(x,y,gx,gy); |
1127 | 1132 | ||
1128 | // Change cursor to resize cursor if appropriate | 1133 | // Change cursor to resize cursor if appropriate |
1129 | if (mAllDayMode) { | 1134 | if (mAllDayMode) { |
1130 | int gridDistanceX = (x - gx * mGridSpacingX); | 1135 | int gridDistanceX = (x - gx * mGridSpacingX); |
1131 | if (gridDistanceX < mResizeBorderWidth && | 1136 | if (gridDistanceX < mResizeBorderWidth && |
1132 | moveItem->cellX() == gx) { | 1137 | moveItem->cellX() == gx) { |
1133 | setCursor(sizeHorCursor); | 1138 | setCursor(sizeHorCursor); |
1134 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1139 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1135 | moveItem->cellXWidth() == gx) { | 1140 | moveItem->cellXWidth() == gx) { |
1136 | setCursor(sizeHorCursor); | 1141 | setCursor(sizeHorCursor); |
1137 | } else { | 1142 | } else { |
1138 | setCursor(arrowCursor); | 1143 | setCursor(arrowCursor); |
1139 | } | 1144 | } |
1140 | } else { | 1145 | } else { |
1141 | int gridDistanceY = (y - gy * mGridSpacingY); | 1146 | int gridDistanceY = (y - gy * mGridSpacingY); |
1142 | if (gridDistanceY < mResizeBorderWidth && | 1147 | if (gridDistanceY < mResizeBorderWidth && |
1143 | moveItem->cellYTop() == gy && | 1148 | moveItem->cellYTop() == gy && |
1144 | !moveItem->firstMultiItem()) { | 1149 | !moveItem->firstMultiItem()) { |
1145 | setCursor(sizeVerCursor); | 1150 | setCursor(sizeVerCursor); |
1146 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1151 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1147 | moveItem->cellYBottom() == gy && | 1152 | moveItem->cellYBottom() == gy && |
1148 | !moveItem->lastMultiItem()) { | 1153 | !moveItem->lastMultiItem()) { |
1149 | setCursor(sizeVerCursor); | 1154 | setCursor(sizeVerCursor); |
1150 | } else { | 1155 | } else { |
1151 | setCursor(arrowCursor); | 1156 | setCursor(arrowCursor); |
1152 | } | 1157 | } |
1153 | } | 1158 | } |
1154 | } | 1159 | } |
1155 | 1160 | ||
1156 | 1161 | ||
1157 | /* | 1162 | /* |
1158 | Place item in cell and take care that multiple items using the same cell do | 1163 | Place item in cell and take care that multiple items using the same cell do |
1159 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1164 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1160 | it can get in all cases. | 1165 | it can get in all cases. |
1161 | At the moment the method has a bug: When an item is placed only the sub cell | 1166 | At the moment the method has a bug: When an item is placed only the sub cell |
1162 | widths of the items are changed, which are within the Y region the item to | 1167 | widths of the items are changed, which are within the Y region the item to |
1163 | place spans. When the sub cell width change of one of this items affects a | 1168 | place spans. When the sub cell width change of one of this items affects a |
1164 | cell, where other items are, which do not overlap in Y with the item to place, | 1169 | cell, where other items are, which do not overlap in Y with the item to place, |
1165 | the display gets corrupted, although the corruption looks quite nice. | 1170 | the display gets corrupted, although the corruption looks quite nice. |
1166 | */ | 1171 | */ |
1167 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1172 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1168 | { | 1173 | { |
1169 | 1174 | ||
1170 | QPtrList<KOAgendaItem> conflictItems; | 1175 | QPtrList<KOAgendaItem> conflictItems; |
1171 | int maxSubCells = 0; | 1176 | int maxSubCells = 0; |
1172 | QIntDict<KOAgendaItem> subCellDict(7); | 1177 | QIntDict<KOAgendaItem> subCellDict(7); |
1173 | 1178 | ||
1174 | KOAgendaItem *item; | 1179 | KOAgendaItem *item; |
1175 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1180 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1176 | if (item != placeItem) { | 1181 | if (item != placeItem) { |
1177 | if (placeItem->cellX() <= item->cellXWidth() && | 1182 | if (placeItem->cellX() <= item->cellXWidth() && |
1178 | placeItem->cellXWidth() >= item->cellX()) { | 1183 | placeItem->cellXWidth() >= item->cellX()) { |
1179 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1184 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1180 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1185 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1181 | conflictItems.append(item); | 1186 | conflictItems.append(item); |
1182 | if (item->subCells() > maxSubCells) | 1187 | if (item->subCells() > maxSubCells) |
1183 | maxSubCells = item->subCells(); | 1188 | maxSubCells = item->subCells(); |
1184 | subCellDict.insert(item->subCell(),item); | 1189 | subCellDict.insert(item->subCell(),item); |
1185 | } | 1190 | } |
1186 | } | 1191 | } |
1187 | } | 1192 | } |
1188 | } | 1193 | } |
1189 | 1194 | ||
1190 | if (conflictItems.count() > 0) { | 1195 | if (conflictItems.count() > 0) { |
1191 | // Look for unused sub cell and insert item | 1196 | // Look for unused sub cell and insert item |
1192 | int i; | 1197 | int i; |
1193 | for(i=0;i<maxSubCells;++i) { | 1198 | for(i=0;i<maxSubCells;++i) { |
1194 | if (!subCellDict.find(i)) { | 1199 | if (!subCellDict.find(i)) { |
1195 | placeItem->setSubCell(i); | 1200 | placeItem->setSubCell(i); |
1196 | break; | 1201 | break; |
1197 | } | 1202 | } |
1198 | } | 1203 | } |
1199 | if (i == maxSubCells) { | 1204 | if (i == maxSubCells) { |
1200 | placeItem->setSubCell(maxSubCells); | 1205 | placeItem->setSubCell(maxSubCells); |
1201 | maxSubCells++; // add new item to number of sub cells | 1206 | maxSubCells++; // add new item to number of sub cells |
1202 | } | 1207 | } |
1203 | 1208 | ||
1204 | // Prepare for sub cell geometry adjustment | 1209 | // Prepare for sub cell geometry adjustment |
1205 | int newSubCellWidth; | 1210 | int newSubCellWidth; |
1206 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1211 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1207 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1212 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1208 | conflictItems.append(placeItem); | 1213 | conflictItems.append(placeItem); |
1209 | 1214 | ||
1210 | 1215 | ||
1211 | // Adjust sub cell geometry of all direct conflict items | 1216 | // Adjust sub cell geometry of all direct conflict items |
1212 | for ( item=conflictItems.first(); item != 0; | 1217 | for ( item=conflictItems.first(); item != 0; |
1213 | item=conflictItems.next() ) { | 1218 | item=conflictItems.next() ) { |
1214 | item->setSubCells(maxSubCells); | 1219 | item->setSubCells(maxSubCells); |
1215 | if (mAllDayMode) { | 1220 | if (mAllDayMode) { |
1216 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1221 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1217 | } else { | 1222 | } else { |
1218 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1223 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1219 | } | 1224 | } |
1220 | int x,y; | 1225 | int x,y; |
1221 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1226 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1222 | if (mAllDayMode) { | 1227 | if (mAllDayMode) { |
1223 | y += item->subCell() * newSubCellWidth; | 1228 | y += item->subCell() * newSubCellWidth; |
1224 | } else { | 1229 | } else { |
1225 | x += item->subCell() * newSubCellWidth; | 1230 | x += item->subCell() * newSubCellWidth; |
1226 | } | 1231 | } |
1227 | moveChild(item,x,y); | 1232 | moveChild(item,x,y); |
1228 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1233 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1229 | //item->updateItem(); | 1234 | //item->updateItem(); |
1230 | } | 1235 | } |
1231 | // Adjust sub cell geometry of all conflict items of all conflict items | 1236 | // Adjust sub cell geometry of all conflict items of all conflict items |
1232 | for ( item=conflictItems.first(); item != 0; | 1237 | for ( item=conflictItems.first(); item != 0; |
1233 | item=conflictItems.next() ) { | 1238 | item=conflictItems.next() ) { |
1234 | if ( placeItem != item ) { | 1239 | if ( placeItem != item ) { |
1235 | KOAgendaItem *item2; | 1240 | KOAgendaItem *item2; |
1236 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1241 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1237 | for ( item2=conflictItems2.first(); item2 != 0; | 1242 | for ( item2=conflictItems2.first(); item2 != 0; |
1238 | item2=conflictItems2.next() ) { | 1243 | item2=conflictItems2.next() ) { |
1239 | if ( item2->subCells() != maxSubCells) { | 1244 | if ( item2->subCells() != maxSubCells) { |
1240 | item2->setSubCells(maxSubCells); | 1245 | item2->setSubCells(maxSubCells); |
1241 | if (mAllDayMode) { | 1246 | if (mAllDayMode) { |
1242 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1247 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1243 | } else { | 1248 | } else { |
1244 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1249 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1245 | } | 1250 | } |
1246 | int x,y; | 1251 | int x,y; |
1247 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1252 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1248 | if (mAllDayMode) { | 1253 | if (mAllDayMode) { |
1249 | y += item2->subCell() * newSubCellWidth; | 1254 | y += item2->subCell() * newSubCellWidth; |
1250 | } else { | 1255 | } else { |
1251 | x += item2->subCell() * newSubCellWidth; | 1256 | x += item2->subCell() * newSubCellWidth; |
1252 | } | 1257 | } |
1253 | moveChild(item2,x,y); | 1258 | moveChild(item2,x,y); |
1254 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1259 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1255 | } | 1260 | } |
1256 | } | 1261 | } |
1257 | } | 1262 | } |
1258 | } | 1263 | } |
1259 | } else { | 1264 | } else { |
1260 | placeItem->setSubCell(0); | 1265 | placeItem->setSubCell(0); |
1261 | placeItem->setSubCells(1); | 1266 | placeItem->setSubCells(1); |
1262 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1267 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1263 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1268 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1264 | int x,y; | 1269 | int x,y; |
1265 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1270 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1266 | moveChild(placeItem,x,y); | 1271 | moveChild(placeItem,x,y); |
1267 | } | 1272 | } |
1268 | placeItem->setConflictItems(conflictItems); | 1273 | placeItem->setConflictItems(conflictItems); |
1269 | // for ( item=conflictItems.first(); item != 0; | 1274 | // for ( item=conflictItems.first(); item != 0; |
1270 | // item=conflictItems.next() ) { | 1275 | // item=conflictItems.next() ) { |
1271 | // //item->updateItem(); | 1276 | // //item->updateItem(); |
1272 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1277 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1273 | // } | 1278 | // } |
1274 | // placeItem->updateItem(); | 1279 | // placeItem->updateItem(); |
1275 | } | 1280 | } |
1276 | 1281 | ||
1277 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1282 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1278 | { | 1283 | { |
1279 | if ( globalFlagBlockAgenda ) | 1284 | if ( globalFlagBlockAgenda ) |
1280 | return; | 1285 | return; |
1281 | 1286 | ||
1282 | if ( mInvalidPixmap ) { | 1287 | if ( mInvalidPixmap ) { |
1283 | mInvalidPixmap = false; | 1288 | mInvalidPixmap = false; |
1284 | qDebug("KO: Upsizing Pixmaps "); | 1289 | qDebug("KO: dc Upsizing Pixmaps %s", QDateTime::currentDateTime().toString().latin1()); |
1285 | computeSizes(); | 1290 | computeSizes(); |
1286 | emit updateViewSignal(); | 1291 | emit updateViewSignal(); |
1287 | return; | 1292 | return; |
1288 | } | 1293 | } |
1294 | //qDebug("KOAgenda::drawContents %s", QDateTime::currentDateTime().toString().latin1()); | ||
1289 | if ( ! mAllDayMode ) { | 1295 | if ( ! mAllDayMode ) { |
1290 | // currently not working for | 1296 | // currently not working for |
1291 | 1297 | ||
1292 | //qDebug("KOAgenda::drawContents "); | 1298 | //qDebug("KOAgenda::drawContents "); |
1293 | #if 0 | 1299 | #if 0 |
1294 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1300 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1295 | qDebug("WAU "); | 1301 | qDebug("WAU "); |
1296 | drawContentsToPainter(); | 1302 | drawContentsToPainter(); |
1297 | } | 1303 | } |
1298 | #endif | 1304 | #endif |
1299 | QPaintDevice* pd = p->device(); | 1305 | QPaintDevice* pd = p->device(); |
1300 | p->end(); | 1306 | p->end(); |
1301 | int vx, vy; | 1307 | int vx, vy; |
1302 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1308 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1303 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1309 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1304 | mSelectionCellX * mGridSpacingX; | 1310 | mSelectionCellX * mGridSpacingX; |
1305 | contentsToViewport ( cx, cy, vx,vy); | 1311 | contentsToViewport ( cx, cy, vx,vy); |
1306 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1312 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1307 | 1313 | ||
1308 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1314 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1309 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1315 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1310 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1316 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1311 | 1317 | ||
1312 | int vxSel, vySel; | 1318 | int vxSel, vySel; |
1313 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1319 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1314 | int off = mSelectionHeight; | 1320 | int off = mSelectionHeight; |
1315 | if ( vySel < 0 ) | 1321 | if ( vySel < 0 ) |
1316 | off += vySel; | 1322 | off += vySel; |
1317 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1323 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1318 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1324 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1319 | } else { | 1325 | } else { |
1320 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1326 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1321 | } | 1327 | } |
1322 | } | 1328 | } |
1323 | if ( mSelectionHeight > 0 ) { | 1329 | if ( mSelectionHeight > 0 ) { |
1324 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1330 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1325 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1331 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1326 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1332 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1327 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1333 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1328 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1334 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1329 | int hei = mSelectionHeight; | 1335 | int hei = mSelectionHeight; |
1330 | int offset = 0; | 1336 | int offset = 0; |
1331 | while ( hei > 0 ) { | 1337 | while ( hei > 0 ) { |
1332 | int p_hei = 5; | 1338 | int p_hei = 5; |
1333 | if ( hei < 5 ) p_hei = hei; | 1339 | if ( hei < 5 ) p_hei = hei; |
1334 | hei -= 5; | 1340 | hei -= 5; |
1335 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1341 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1336 | offset += 5; | 1342 | offset += 5; |
1337 | } | 1343 | } |
1338 | } | 1344 | } |
1339 | } | 1345 | } |
1340 | p->begin( pd ); | 1346 | p->begin( pd ); |
1341 | } else { | 1347 | } else { |
1342 | #if 0 | 1348 | #if 0 |
1343 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1349 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1344 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1350 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1345 | qDebug("WAUWAU "); | 1351 | qDebug("WAUWAU "); |
1346 | drawContentsToPainter(); | 1352 | drawContentsToPainter(); |
1347 | } | 1353 | } |
1348 | #endif | 1354 | #endif |
1349 | QPaintDevice* pd = p->device(); | 1355 | QPaintDevice* pd = p->device(); |
1350 | p->end(); | 1356 | p->end(); |
1351 | int vx, vy; | 1357 | int vx, vy; |
1352 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1358 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1353 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1359 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1354 | mSelectionCellX * mGridSpacingX; | 1360 | mSelectionCellX * mGridSpacingX; |
1355 | contentsToViewport ( cx, cy, vx,vy); | 1361 | contentsToViewport ( cx, cy, vx,vy); |
1356 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1362 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1357 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1363 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1358 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1364 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1359 | 1365 | ||
1360 | if ( mSelectionHeight > 0 ) { | 1366 | if ( mSelectionHeight > 0 ) { |
1361 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1367 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1362 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1368 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1363 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1369 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1364 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1370 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1365 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1371 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1366 | int hei = mSelectionHeight; | 1372 | int hei = mSelectionHeight; |
1367 | int offset = 0; | 1373 | int offset = 0; |
1368 | while ( hei > 0 ) { | 1374 | while ( hei > 0 ) { |
1369 | int p_hei = 5; | 1375 | int p_hei = 5; |
1370 | if ( hei < 5 ) p_hei = hei; | 1376 | if ( hei < 5 ) p_hei = hei; |
1371 | hei -= 5; | 1377 | hei -= 5; |
1372 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1378 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1373 | offset += 5; | 1379 | offset += 5; |
1374 | } | 1380 | } |
1375 | } | 1381 | } |
1376 | } | 1382 | } |
1377 | p->begin( pd ); | 1383 | p->begin( pd ); |
1378 | } | 1384 | } |
1379 | 1385 | ||
1380 | } | 1386 | } |
1381 | 1387 | ||
1382 | void KOAgenda::finishUpdate() | 1388 | void KOAgenda::finishUpdate() |
1383 | { | 1389 | { |
1384 | 1390 | ||
1385 | KOAgendaItem *item; | 1391 | KOAgendaItem *item; |
1386 | globalFlagBlockAgendaItemPaint = 1; | 1392 | globalFlagBlockAgendaItemPaint = 1; |
1387 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1393 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1388 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1394 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1389 | if ( !item->checkLayout() ) { | 1395 | if ( !item->checkLayout() ) { |
1390 | //qDebug(" conflictitem found "); | 1396 | //qDebug(" conflictitem found "); |
1391 | int newSubCellWidth; | 1397 | int newSubCellWidth; |
1392 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1398 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1393 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1399 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1394 | 1400 | ||
1395 | if (mAllDayMode) { | 1401 | if (mAllDayMode) { |
1396 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1402 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1397 | } else { | 1403 | } else { |
1398 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1404 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1399 | } | 1405 | } |
1400 | int x,y; | 1406 | int x,y; |
1401 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1407 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1402 | if (mAllDayMode) { | 1408 | if (mAllDayMode) { |
1403 | y += item->subCell() * newSubCellWidth; | 1409 | y += item->subCell() * newSubCellWidth; |
1404 | } else { | 1410 | } else { |
1405 | x += item->subCell() * newSubCellWidth; | 1411 | x += item->subCell() * newSubCellWidth; |
1406 | } | 1412 | } |
1407 | moveChild(item,x,y); | 1413 | moveChild(item,x,y); |
1408 | } | 1414 | } |
1409 | } | 1415 | } |
1410 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1416 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1411 | if ( !item->isVisible() ) | 1417 | if ( !item->isVisible() ) |
1412 | item->show(); | 1418 | item->show(); |
1413 | 1419 | ||
1414 | } | 1420 | } |
1415 | globalFlagBlockAgendaItemUpdate = 0; | 1421 | globalFlagBlockAgendaItemUpdate = 0; |
1416 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1422 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1417 | item->repaintMe( ); | 1423 | item->repaintMe( ); |
1418 | } | 1424 | } |
1419 | globalFlagBlockAgendaItemUpdate = 1; | 1425 | globalFlagBlockAgendaItemUpdate = 1; |
1420 | qApp->processEvents(); | 1426 | qApp->processEvents(); |
1421 | globalFlagBlockAgendaItemPaint = 0; | 1427 | globalFlagBlockAgendaItemPaint = 0; |
1422 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1428 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1423 | item->repaint( false ); | 1429 | item->repaint( false ); |
1424 | } | 1430 | } |
1425 | marcus_bains(); | 1431 | marcus_bains(); |
1426 | } | 1432 | } |
1427 | 1433 | ||
1428 | /* | 1434 | /* |
1429 | Draw grid in the background of the agenda. | 1435 | Draw grid in the background of the agenda. |
1430 | */ | 1436 | */ |
1431 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1437 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1432 | { | 1438 | { |
1433 | 1439 | ||
1434 | 1440 | ||
1435 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1441 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1436 | return; | 1442 | return; |
1437 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1443 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1438 | return; | 1444 | return; |
1439 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1445 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1440 | if ( ch < 1 ) | 1446 | if ( ch < 1 ) |
1441 | ch = 1; | 1447 | ch = 1; |
1442 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1448 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1443 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1449 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1444 | } | 1450 | } |
1445 | mCurPixWid = contentsWidth(); | 1451 | mCurPixWid = contentsWidth(); |
1446 | mCurPixHei = ch; | 1452 | mCurPixHei = ch; |
1447 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1453 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1448 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1454 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1449 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1455 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1450 | } | 1456 | } |
1451 | mPixPainter.begin( &mPaintPixmap) ; | 1457 | mPixPainter.begin( &mPaintPixmap) ; |
1452 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1458 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1453 | QPainter * p ; | 1459 | QPainter * p ; |
1454 | if (paint == 0) { | 1460 | if (paint == 0) { |
1455 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1461 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1456 | p = &mPixPainter; | 1462 | p = &mPixPainter; |
1457 | } | 1463 | } |
1458 | else | 1464 | else |
1459 | p = paint ; | 1465 | p = paint ; |
1460 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1466 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1461 | 1467 | ||
1462 | //--cx;++cw; | 1468 | //--cx;++cw; |
1463 | int lGridSpacingY = mGridSpacingY*2; | 1469 | int lGridSpacingY = mGridSpacingY*2; |
1464 | int selDay; | 1470 | int selDay; |
1465 | QDate curDate = QDate::currentDate(); | 1471 | QDate curDate = QDate::currentDate(); |
1466 | if ( !backgroundOnly ) { | 1472 | if ( !backgroundOnly ) { |
1467 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1473 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1468 | { | 1474 | { |
1469 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1475 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1470 | int x1 = cx; | 1476 | int x1 = cx; |
1471 | int y1 = 0; | 1477 | int y1 = 0; |
1472 | if (y1 < cy) y1 = cy; | 1478 | if (y1 < cy) y1 = cy; |
1473 | int x2 = cx+cw-1; | 1479 | int x2 = cx+cw-1; |
1474 | int y2 = contentsHeight(); | 1480 | int y2 = contentsHeight(); |
1475 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1481 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1476 | if (x2 >= x1 && y2 >= y1) { | 1482 | if (x2 >= x1 && y2 >= y1) { |
1477 | int gxStart = selDay; | 1483 | int gxStart = selDay; |
1478 | int gxEnd = gxStart ; | 1484 | int gxEnd = gxStart ; |
1479 | int xStart = KOGlobals::self()->reverseLayout() ? | 1485 | int xStart = KOGlobals::self()->reverseLayout() ? |
1480 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1486 | (mColumns - 1 - gxStart)*mGridSpacingX : |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 59e7472..380ce62 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -1,307 +1,308 @@ | |||
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 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOAGENDA_H | 23 | #ifndef KOAGENDA_H |
24 | #define KOAGENDA_H | 24 | #define KOAGENDA_H |
25 | 25 | ||
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qmemarray.h> | 28 | #include <qmemarray.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qpixmap.h> | 30 | #include <qpixmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | #include "koagendaitem.h" | 33 | #include "koagendaitem.h" |
34 | #include "koeventview.h" | 34 | #include "koeventview.h" |
35 | 35 | ||
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QTime; | 37 | class QTime; |
38 | class KConfig; | 38 | class KConfig; |
39 | class QFrame; | 39 | class QFrame; |
40 | class KOAgenda; | 40 | class KOAgenda; |
41 | class KCal::Event; | 41 | class KCal::Event; |
42 | class KCal::Todo; | 42 | class KCal::Todo; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class MarcusBains : public QFrame { | 46 | class MarcusBains : public QFrame { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); | 49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); |
50 | virtual ~MarcusBains(); | 50 | virtual ~MarcusBains(); |
51 | void hideMe(); | 51 | void hideMe(); |
52 | public slots: | 52 | public slots: |
53 | void updateLocation(bool recalculate=false); | 53 | void updateLocation(bool recalculate=false); |
54 | void updateLoc(); | 54 | void updateLoc(); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | int todayColumn(); | 57 | int todayColumn(); |
58 | QTimer *minutes; | 58 | QTimer *minutes; |
59 | QLabel *mTimeBox; | 59 | QLabel *mTimeBox; |
60 | KOAgenda *agenda; | 60 | KOAgenda *agenda; |
61 | QTime oldTime; | 61 | QTime oldTime; |
62 | int oldToday; | 62 | int oldToday; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | class KOAgenda : public QScrollView | 66 | class KOAgenda : public QScrollView |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | enum MouseActionType { NOP, MOVE, SELECT, | 70 | enum MouseActionType { NOP, MOVE, SELECT, |
71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; | 71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; |
72 | 72 | ||
73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, | 73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, |
74 | const char * name=0, WFlags f=0 ); | 74 | const char * name=0, WFlags f=0 ); |
75 | KOAgenda ( int columns, QWidget * parent=0, | 75 | KOAgenda ( int columns, QWidget * parent=0, |
76 | const char * name=0, WFlags f=0 ); | 76 | const char * name=0, WFlags f=0 ); |
77 | virtual ~KOAgenda(); | 77 | virtual ~KOAgenda(); |
78 | bool mInvalidPixmap; | 78 | bool mInvalidPixmap; |
79 | 79 | ||
80 | Incidence *selectedIncidence() const; | 80 | Incidence *selectedIncidence() const; |
81 | QDate selectedIncidenceDate() const; | 81 | QDate selectedIncidenceDate() const; |
82 | 82 | ||
83 | virtual bool eventFilter ( QObject *, QEvent * ); | 83 | virtual bool eventFilter ( QObject *, QEvent * ); |
84 | 84 | ||
85 | void contentsToGrid (int x, int y, int& gx, int& gy); | 85 | void contentsToGrid (int x, int y, int& gx, int& gy); |
86 | void gridToContents (int gx, int gy, int& x, int& y); | 86 | void gridToContents (int gx, int gy, int& x, int& y); |
87 | 87 | ||
88 | int timeToY (const QTime &time); | 88 | int timeToY (const QTime &time); |
89 | QTime gyToTime (int y); | 89 | QTime gyToTime (int y); |
90 | 90 | ||
91 | void setStartHour(int startHour); | 91 | void setStartHour(int startHour); |
92 | 92 | ||
93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); | 93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); |
94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | 94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); |
95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
96 | int YTop,int YBottom); | 96 | int YTop,int YBottom); |
97 | 97 | ||
98 | void changeColumns(int columns); | 98 | void changeColumns(int columns); |
99 | 99 | ||
100 | int columns() { return mColumns; } | 100 | int columns() { return mColumns; } |
101 | int rows() { return mRows; } | 101 | int rows() { return mRows; } |
102 | 102 | ||
103 | int gridSpacingX() const { return mGridSpacingX; } | 103 | int gridSpacingX() const { return mGridSpacingX; } |
104 | int gridSpacingY() const { return mGridSpacingY; } | 104 | int gridSpacingY() const { return mGridSpacingY; } |
105 | 105 | ||
106 | // virtual QSizePolicy sizePolicy() const; | 106 | // virtual QSizePolicy sizePolicy() const; |
107 | 107 | ||
108 | void clear(); | 108 | void clear(); |
109 | 109 | ||
110 | void clearSelection(); | 110 | void clearSelection(); |
111 | void hideUnused(); | 111 | void hideUnused(); |
112 | 112 | ||
113 | /** Calculates the minimum width */ | 113 | /** Calculates the minimum width */ |
114 | virtual int minimumWidth() const; | 114 | virtual int minimumWidth() const; |
115 | /** Update configuration from preference settings */ | 115 | /** Update configuration from preference settings */ |
116 | void updateConfig(); | 116 | void updateConfig(); |
117 | 117 | ||
118 | void checkScrollBoundaries(); | 118 | void checkScrollBoundaries(); |
119 | 119 | ||
120 | void setHolidayMask(QMemArray<bool> *); | 120 | void setHolidayMask(QMemArray<bool> *); |
121 | void setDateList(const DateList &selectedDates); | 121 | void setDateList(const DateList &selectedDates); |
122 | DateList dateList() const; | 122 | DateList dateList() const; |
123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | 123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); |
124 | void finishUpdate(); | 124 | void finishUpdate(); |
125 | void printSelection(); | 125 | void printSelection(); |
126 | void storePosition(); | 126 | void storePosition(); |
127 | void restorePosition(); | 127 | void restorePosition(); |
128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } | 128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } |
129 | void shrinkPixmap(); | 129 | void shrinkPixmap(); |
130 | QTime getEndTime(); | 130 | QTime getEndTime(); |
131 | bool invalidPixmap(); | ||
131 | 132 | ||
132 | public slots: | 133 | public slots: |
133 | void slotContentMove(int,int); | 134 | void slotContentMove(int,int); |
134 | void categoryChanged(Incidence * inc); | 135 | void categoryChanged(Incidence * inc); |
135 | void slotClearSelection(); | 136 | void slotClearSelection(); |
136 | void popupMenu(); | 137 | void popupMenu(); |
137 | void newItem( int ); | 138 | void newItem( int ); |
138 | void moveChild( QWidget *, int, int ); | 139 | void moveChild( QWidget *, int, int ); |
139 | void scrollUp(); | 140 | void scrollUp(); |
140 | void scrollDown(); | 141 | void scrollDown(); |
141 | void updateTodo( Todo * t, int , bool ); | 142 | void updateTodo( Todo * t, int , bool ); |
142 | void popupAlarm(); | 143 | void popupAlarm(); |
143 | 144 | ||
144 | void checkScrollBoundaries(int); | 145 | void checkScrollBoundaries(int); |
145 | 146 | ||
146 | /** Deselect selected items. This function does not emit any signals. */ | 147 | /** Deselect selected items. This function does not emit any signals. */ |
147 | void deselectItem(); | 148 | void deselectItem(); |
148 | /** Select item. If the argument is 0, the currently selected item gets | 149 | /** Select item. If the argument is 0, the currently selected item gets |
149 | deselected. This function emits the itemSelected(bool) signal to inform | 150 | deselected. This function emits the itemSelected(bool) signal to inform |
150 | about selection/deseelction of events. */ | 151 | about selection/deseelction of events. */ |
151 | void selectItem(KOAgendaItem *); | 152 | void selectItem(KOAgendaItem *); |
152 | void finishResize(); | 153 | void finishResize(); |
153 | 154 | ||
154 | signals: | 155 | signals: |
155 | void signalClearSelection(); | 156 | void signalClearSelection(); |
156 | void showDateView( int, int); | 157 | void showDateView( int, int); |
157 | void newEventSignal(); | 158 | void newEventSignal(); |
158 | void newEventSignal(int gx,int gy); | 159 | void newEventSignal(int gx,int gy); |
159 | void newTodoSignal(int gx,int gy); | 160 | void newTodoSignal(int gx,int gy); |
160 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 161 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
161 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 162 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
162 | void newStartSelectSignal(); | 163 | void newStartSelectSignal(); |
163 | void showIncidenceSignal(Incidence *); | 164 | void showIncidenceSignal(Incidence *); |
164 | void editIncidenceSignal(Incidence *); | 165 | void editIncidenceSignal(Incidence *); |
165 | void deleteIncidenceSignal(Incidence *); | 166 | void deleteIncidenceSignal(Incidence *); |
166 | void showIncidencePopupSignal(Incidence *); | 167 | void showIncidencePopupSignal(Incidence *); |
167 | 168 | ||
168 | void itemModified(KOAgendaItem *item, int ); | 169 | void itemModified(KOAgendaItem *item, int ); |
169 | void incidenceSelected(Incidence *); | 170 | void incidenceSelected(Incidence *); |
170 | 171 | ||
171 | void lowerYChanged(int); | 172 | void lowerYChanged(int); |
172 | void upperYChanged(int); | 173 | void upperYChanged(int); |
173 | 174 | ||
174 | void startDragSignal(Incidence *); | 175 | void startDragSignal(Incidence *); |
175 | void addToCalSignal(Incidence *, Incidence *); | 176 | void addToCalSignal(Incidence *, Incidence *); |
176 | void resizedSignal(); | 177 | void resizedSignal(); |
177 | void updateViewSignal(); | 178 | void updateViewSignal(); |
178 | void sendPing(); | 179 | void sendPing(); |
179 | 180 | ||
180 | protected: | 181 | protected: |
181 | KOEventPopupMenu * mAllAgendaPopup; | 182 | KOEventPopupMenu * mAllAgendaPopup; |
182 | QPainter mPixPainter; | 183 | QPainter mPixPainter; |
183 | QPixmap mPaintPixmap; | 184 | QPixmap mPaintPixmap; |
184 | QPixmap mHighlightPixmap; | 185 | QPixmap mHighlightPixmap; |
185 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 186 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
186 | virtual void resizeEvent ( QResizeEvent * ); | 187 | virtual void resizeEvent ( QResizeEvent * ); |
187 | 188 | ||
188 | /** Handles mouse events. Called from eventFilter */ | 189 | /** Handles mouse events. Called from eventFilter */ |
189 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | 190 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); |
190 | 191 | ||
191 | /** Start selecting time span. */ | 192 | /** Start selecting time span. */ |
192 | void startSelectAction(QPoint viewportPos); | 193 | void startSelectAction(QPoint viewportPos); |
193 | 194 | ||
194 | /** Select time span. */ | 195 | /** Select time span. */ |
195 | void performSelectAction(QPoint viewportPos); | 196 | void performSelectAction(QPoint viewportPos); |
196 | 197 | ||
197 | /** Emd selecting time span. */ | 198 | /** Emd selecting time span. */ |
198 | void endSelectAction( bool emitNewEvent = false ); | 199 | void endSelectAction( bool emitNewEvent = false ); |
199 | 200 | ||
200 | /** Start moving/resizing agenda item */ | 201 | /** Start moving/resizing agenda item */ |
201 | void startItemAction(QPoint viewportPos); | 202 | void startItemAction(QPoint viewportPos); |
202 | 203 | ||
203 | /** Move/resize agenda item */ | 204 | /** Move/resize agenda item */ |
204 | void performItemAction(QPoint viewportPos); | 205 | void performItemAction(QPoint viewportPos); |
205 | 206 | ||
206 | /** End moving/resizing agenda item */ | 207 | /** End moving/resizing agenda item */ |
207 | void endItemAction(); | 208 | void endItemAction(); |
208 | 209 | ||
209 | /** Set cursor, when no item action is in progress */ | 210 | /** Set cursor, when no item action is in progress */ |
210 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | 211 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); |
211 | 212 | ||
212 | /** Place agenda item in agenda and adjust other cells if necessary */ | 213 | /** Place agenda item in agenda and adjust other cells if necessary */ |
213 | void placeSubCells(KOAgendaItem *placeItem); | 214 | void placeSubCells(KOAgendaItem *placeItem); |
214 | 215 | ||
215 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | 216 | /** Process the keyevent, including the ignored keyevents of eventwidgets. |
216 | * Implements pgup/pgdn and cursor key navigation in the view. | 217 | * Implements pgup/pgdn and cursor key navigation in the view. |
217 | */ | 218 | */ |
218 | void keyPressEvent( QKeyEvent * ); | 219 | void keyPressEvent( QKeyEvent * ); |
219 | 220 | ||
220 | void calculateWorkingHours(); | 221 | void calculateWorkingHours(); |
221 | 222 | ||
222 | virtual void contentsMousePressEvent ( QMouseEvent * ); | 223 | virtual void contentsMousePressEvent ( QMouseEvent * ); |
223 | 224 | ||
224 | private: | 225 | private: |
225 | void init(); | 226 | void init(); |
226 | void marcus_bains(); | 227 | void marcus_bains(); |
227 | bool mAllDayMode; | 228 | bool mAllDayMode; |
228 | bool blockResize; | 229 | bool blockResize; |
229 | bool mLeftMouseDown; | 230 | bool mLeftMouseDown; |
230 | KOAgendaItem *mPopupItem; | 231 | KOAgendaItem *mPopupItem; |
231 | QTimer* mPopupTimer; | 232 | QTimer* mPopupTimer; |
232 | int mPopupKind; | 233 | int mPopupKind; |
233 | QPoint mPopupPos; | 234 | QPoint mPopupPos; |
234 | QTimer mResizeTimer; | 235 | QTimer mResizeTimer; |
235 | double mContentPosition; | 236 | double mContentPosition; |
236 | 237 | ||
237 | // Width and height of agenda cells | 238 | // Width and height of agenda cells |
238 | int mGridSpacingX; | 239 | int mGridSpacingX; |
239 | int mGridSpacingY; | 240 | int mGridSpacingY; |
240 | 241 | ||
241 | // size of border, where mouse action will resize the KOAgendaItem | 242 | // size of border, where mouse action will resize the KOAgendaItem |
242 | int mResizeBorderWidth; | 243 | int mResizeBorderWidth; |
243 | 244 | ||
244 | // size of border, where mouse mve will cause a scroll of the agenda | 245 | // size of border, where mouse mve will cause a scroll of the agenda |
245 | int mScrollBorderWidth; | 246 | int mScrollBorderWidth; |
246 | int mScrollDelay; | 247 | int mScrollDelay; |
247 | int mScrollOffset; | 248 | int mScrollOffset; |
248 | 249 | ||
249 | QTimer mScrollUpTimer; | 250 | QTimer mScrollUpTimer; |
250 | QTimer mScrollDownTimer; | 251 | QTimer mScrollDownTimer; |
251 | 252 | ||
252 | // Number of Columns/Rows of agenda grid | 253 | // Number of Columns/Rows of agenda grid |
253 | int mColumns; | 254 | int mColumns; |
254 | int mRows; | 255 | int mRows; |
255 | 256 | ||
256 | // Cells to store Move and Resize coordiantes | 257 | // Cells to store Move and Resize coordiantes |
257 | int mStartCellX; | 258 | int mStartCellX; |
258 | int mStartCellY; | 259 | int mStartCellY; |
259 | int mCurrentCellX; | 260 | int mCurrentCellX; |
260 | int mCurrentCellY; | 261 | int mCurrentCellY; |
261 | 262 | ||
262 | // Working Hour coordiantes | 263 | // Working Hour coordiantes |
263 | bool mWorkingHoursEnable; | 264 | bool mWorkingHoursEnable; |
264 | int mWorkingHoursYTop; | 265 | int mWorkingHoursYTop; |
265 | int mWorkingHoursYBottom; | 266 | int mWorkingHoursYBottom; |
266 | 267 | ||
267 | // Selection | 268 | // Selection |
268 | int mSelectionCellX; | 269 | int mSelectionCellX; |
269 | int mSelectionYTop; | 270 | int mSelectionYTop; |
270 | int mSelectionHeight; | 271 | int mSelectionHeight; |
271 | 272 | ||
272 | // List of dates to be displayed | 273 | // List of dates to be displayed |
273 | DateList mSelectedDates; | 274 | DateList mSelectedDates; |
274 | 275 | ||
275 | // The KOAgendaItem, which has been right-clicked last | 276 | // The KOAgendaItem, which has been right-clicked last |
276 | KOAgendaItem *mClickedItem; | 277 | KOAgendaItem *mClickedItem; |
277 | 278 | ||
278 | // The KOAgendaItem, which is being moved/resized | 279 | // The KOAgendaItem, which is being moved/resized |
279 | QGuardedPtr<KOAgendaItem> mActionItem; | 280 | QGuardedPtr<KOAgendaItem> mActionItem; |
280 | 281 | ||
281 | // Currently selected item | 282 | // Currently selected item |
282 | QGuardedPtr<KOAgendaItem> mSelectedItem; | 283 | QGuardedPtr<KOAgendaItem> mSelectedItem; |
283 | 284 | ||
284 | // The Marcus Bains Line widget. | 285 | // The Marcus Bains Line widget. |
285 | MarcusBains *mMarcusBains; | 286 | MarcusBains *mMarcusBains; |
286 | void computeSizes(); | 287 | void computeSizes(); |
287 | 288 | ||
288 | MouseActionType mActionType; | 289 | MouseActionType mActionType; |
289 | 290 | ||
290 | bool mItemMoved; | 291 | bool mItemMoved; |
291 | 292 | ||
292 | // List of all Items contained in agenda | 293 | // List of all Items contained in agenda |
293 | QPtrList<KOAgendaItem> mItems; | 294 | QPtrList<KOAgendaItem> mItems; |
294 | QPtrList<KOAgendaItem> mUnusedItems; | 295 | QPtrList<KOAgendaItem> mUnusedItems; |
295 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); | 296 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); |
296 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems | 297 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems |
297 | QPopupMenu *mNewItemPopup; | 298 | QPopupMenu *mNewItemPopup; |
298 | 299 | ||
299 | int mOldLowerScrollValue; | 300 | int mOldLowerScrollValue; |
300 | int mOldUpperScrollValue; | 301 | int mOldUpperScrollValue; |
301 | KOAgendaItem * getItemForTodo ( Todo * todo ); | 302 | KOAgendaItem * getItemForTodo ( Todo * todo ); |
302 | QMemArray<bool> *mHolidayMask; | 303 | QMemArray<bool> *mHolidayMask; |
303 | int mCurPixWid; | 304 | int mCurPixWid; |
304 | int mCurPixHei; | 305 | int mCurPixHei; |
305 | }; | 306 | }; |
306 | 307 | ||
307 | #endif // KOAGENDA_H | 308 | #endif // KOAGENDA_H |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 04f30bb..f5a3a4b 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -414,385 +414,385 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
414 | int heibut = mExpandButton->sizeHint().height()+4; | 414 | int heibut = mExpandButton->sizeHint().height()+4; |
415 | if ( heibut > widebut ) | 415 | if ( heibut > widebut ) |
416 | widebut = heibut ; | 416 | widebut = heibut ; |
417 | 417 | ||
418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
419 | // QSizePolicy::Fixed ) ); | 419 | // QSizePolicy::Fixed ) ); |
420 | mExpandButton->setFixedSize( widebut, widebut); | 420 | mExpandButton->setFixedSize( widebut, widebut); |
421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
422 | mExpandButton->setFocusPolicy(NoFocus); | 422 | mExpandButton->setFocusPolicy(NoFocus); |
423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
424 | mAllDayAgenda->setFocusPolicy(NoFocus); | 424 | mAllDayAgenda->setFocusPolicy(NoFocus); |
425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
426 | 426 | ||
427 | // Create event context menu for all day agenda | 427 | // Create event context menu for all day agenda |
428 | //mAllDayAgendaPopup = eventPopup(); | 428 | //mAllDayAgendaPopup = eventPopup(); |
429 | 429 | ||
430 | // Create agenda frame | 430 | // Create agenda frame |
431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
433 | 433 | ||
434 | // create event indicator bars | 434 | // create event indicator bars |
435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
436 | #ifndef DESKTOP_VERSION | 436 | #ifndef DESKTOP_VERSION |
437 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 437 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
438 | #endif | 438 | #endif |
439 | mDayLabelsFrame = new QHBox(agendaFrame); | 439 | mDayLabelsFrame = new QHBox(agendaFrame); |
440 | //topLayout->addWidget(mDayLabelsFrame); | 440 | //topLayout->addWidget(mDayLabelsFrame); |
441 | mDayLabels = new QFrame (mDayLabelsFrame); | 441 | mDayLabels = new QFrame (mDayLabelsFrame); |
442 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 442 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
443 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 443 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
444 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 444 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
445 | 445 | ||
446 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 446 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
447 | agendaFrame); | 447 | agendaFrame); |
448 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 448 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
449 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 449 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
450 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 450 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
451 | 451 | ||
452 | // Create time labels | 452 | // Create time labels |
453 | mTimeLabels = new TimeLabels(24,agendaFrame); | 453 | mTimeLabels = new TimeLabels(24,agendaFrame); |
454 | agendaLayout->addWidget(mTimeLabels,2,0); | 454 | agendaLayout->addWidget(mTimeLabels,2,0); |
455 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 455 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
456 | this,SLOT(updateConfig())); | 456 | this,SLOT(updateConfig())); |
457 | 457 | ||
458 | // Create agenda | 458 | // Create agenda |
459 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 459 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
460 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 460 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
461 | agendaLayout->setColStretch(1,1); | 461 | agendaLayout->setColStretch(1,1); |
462 | mAgenda->setFocusPolicy(NoFocus); | 462 | mAgenda->setFocusPolicy(NoFocus); |
463 | // Create event context menu for agenda | 463 | // Create event context menu for agenda |
464 | mAllAgendaPopup = eventPopup(); | 464 | mAllAgendaPopup = eventPopup(); |
465 | 465 | ||
466 | #if 0 | 466 | #if 0 |
467 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 467 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
468 | i18n("Toggle Alarm"),mAgenda, | 468 | i18n("Toggle Alarm"),mAgenda, |
469 | SLOT(popupAlarm()),true); | 469 | SLOT(popupAlarm()),true); |
470 | 470 | ||
471 | #endif | 471 | #endif |
472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
474 | 474 | ||
475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
477 | 477 | ||
478 | connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), | 478 | connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), |
479 | this,SLOT(categoryChanged(Incidence *))); | 479 | this,SLOT(categoryChanged(Incidence *))); |
480 | 480 | ||
481 | 481 | ||
482 | mAgenda->setPopup( mAllAgendaPopup ); | 482 | mAgenda->setPopup( mAllAgendaPopup ); |
483 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | 483 | mAllDayAgenda->setPopup( mAllAgendaPopup ); |
484 | // make connections between dependent widgets | 484 | // make connections between dependent widgets |
485 | mTimeLabels->setAgenda(mAgenda); | 485 | mTimeLabels->setAgenda(mAgenda); |
486 | 486 | ||
487 | // Update widgets to reflect user preferences | 487 | // Update widgets to reflect user preferences |
488 | // updateConfig(); | 488 | // updateConfig(); |
489 | 489 | ||
490 | // createDayLabels(); | 490 | // createDayLabels(); |
491 | 491 | ||
492 | // these blank widgets make the All Day Event box line up with the agenda | 492 | // these blank widgets make the All Day Event box line up with the agenda |
493 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 493 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
494 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 494 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
495 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 495 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
496 | 496 | ||
497 | // Scrolling | 497 | // Scrolling |
498 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 498 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
499 | mTimeLabels, SLOT(positionChanged())); | 499 | mTimeLabels, SLOT(positionChanged())); |
500 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 500 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
501 | SLOT(setContentsPos(int))); | 501 | SLOT(setContentsPos(int))); |
502 | 502 | ||
503 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 503 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
504 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 504 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
505 | 505 | ||
506 | // Create/Show/Edit/Delete Event | 506 | // Create/Show/Edit/Delete Event |
507 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 507 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
508 | SLOT(newEvent(int,int))); | 508 | SLOT(newEvent(int,int))); |
509 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 509 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
510 | SLOT(newTodo(int,int))); | 510 | SLOT(newTodo(int,int))); |
511 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 511 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
512 | SLOT(newEvent(int,int,int,int))); | 512 | SLOT(newEvent(int,int,int,int))); |
513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 513 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
514 | SLOT(newEventAllDay(int,int))); | 514 | SLOT(newEventAllDay(int,int))); |
515 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 515 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
516 | SLOT(newTodoAllDay(int,int))); | 516 | SLOT(newTodoAllDay(int,int))); |
517 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 517 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
518 | SLOT(newEventAllDay(int,int))); | 518 | SLOT(newEventAllDay(int,int))); |
519 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 519 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
520 | SLOT(newTimeSpanSelected(int,int,int,int))); | 520 | SLOT(newTimeSpanSelected(int,int,int,int))); |
521 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 521 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
522 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 522 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
523 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 523 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
524 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 524 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
525 | 525 | ||
526 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 526 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
527 | SIGNAL(editIncidenceSignal(Incidence *))); | 527 | SIGNAL(editIncidenceSignal(Incidence *))); |
528 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 528 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
529 | SIGNAL(editIncidenceSignal(Incidence *))); | 529 | SIGNAL(editIncidenceSignal(Incidence *))); |
530 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 530 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
531 | SIGNAL(showIncidenceSignal(Incidence *))); | 531 | SIGNAL(showIncidenceSignal(Incidence *))); |
532 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 532 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
533 | SIGNAL(showIncidenceSignal(Incidence *))); | 533 | SIGNAL(showIncidenceSignal(Incidence *))); |
534 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 534 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
535 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 535 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
536 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 536 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
537 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 537 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
538 | 538 | ||
539 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 539 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
540 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 540 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
541 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 541 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
542 | SLOT(updateEventDates(KOAgendaItem *, int))); | 542 | SLOT(updateEventDates(KOAgendaItem *, int))); |
543 | 543 | ||
544 | // event indicator update | 544 | // event indicator update |
545 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 545 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
546 | SLOT(updateEventIndicatorTop(int))); | 546 | SLOT(updateEventIndicatorTop(int))); |
547 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 547 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
548 | SLOT(updateEventIndicatorBottom(int))); | 548 | SLOT(updateEventIndicatorBottom(int))); |
549 | // drag signals | 549 | // drag signals |
550 | /* | 550 | /* |
551 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 551 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
552 | SLOT(startDrag(Event *))); | 552 | SLOT(startDrag(Event *))); |
553 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 553 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
554 | SLOT(startDrag(Event *))); | 554 | SLOT(startDrag(Event *))); |
555 | */ | 555 | */ |
556 | // synchronize selections | 556 | // synchronize selections |
557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 557 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
558 | mAllDayAgenda, SLOT( deselectItem() ) ); | 558 | mAllDayAgenda, SLOT( deselectItem() ) ); |
559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 559 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
560 | mAgenda, SLOT( deselectItem() ) ); | 560 | mAgenda, SLOT( deselectItem() ) ); |
561 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 561 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
562 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 562 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
563 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 563 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
564 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 564 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
565 | connect( mAgenda, SIGNAL( resizedSignal() ), | 565 | connect( mAgenda, SIGNAL( resizedSignal() ), |
566 | SLOT( updateConfig( ) ) ); | 566 | SLOT( updateConfig( ) ) ); |
567 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 567 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
568 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 568 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
569 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 569 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
570 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 570 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
571 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 571 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
572 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 572 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
573 | 573 | ||
574 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); | 574 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); |
575 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); | 575 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); |
576 | #ifndef DESKTOP_VERSION | 576 | #ifndef DESKTOP_VERSION |
577 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); | 577 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); |
578 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); | 578 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); |
579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); | 579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); |
580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); | 580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); |
581 | mIdleTimer = new QTimer ( this );; | 581 | mIdleTimer = new QTimer ( this );; |
582 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); | 582 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); |
583 | #endif | 583 | #endif |
584 | } | 584 | } |
585 | void KOAgendaView::startIdleTimeout() | 585 | void KOAgendaView::startIdleTimeout() |
586 | { | 586 | { |
587 | #ifndef DESKTOP_VERSION | 587 | #ifndef DESKTOP_VERSION |
588 | mIdleStart = QDateTime::currentDateTime(); | 588 | mIdleStart = QDateTime::currentDateTime(); |
589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); | 589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); |
590 | #endif | 590 | #endif |
591 | } | 591 | } |
592 | void KOAgendaView::slotIdleTimeout() | 592 | void KOAgendaView::slotIdleTimeout() |
593 | { | 593 | { |
594 | #ifndef DESKTOP_VERSION | 594 | #ifndef DESKTOP_VERSION |
595 | //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); | 595 | //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); |
596 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); | 596 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); |
597 | mIdleTimer->stop(); | 597 | mIdleTimer->stop(); |
598 | bool isActice = topLevelWidget()->isActiveWindow(); | 598 | bool isActice = topLevelWidget()->isActiveWindow(); |
599 | //qDebug("KO: Active Window %d %d", isActice, isVisible()); | 599 | //qDebug("KO: Active Window %d %d", isActice, isVisible()); |
600 | // we do nothing if we wake up from a suspend | 600 | // we do nothing if we wake up from a suspend |
601 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { | 601 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { |
602 | qDebug("KO: Wakeup from suspend "); | 602 | qDebug("KO: Wakeup from suspend "); |
603 | startIdleTimeout(); | 603 | startIdleTimeout(); |
604 | return; | 604 | return; |
605 | } | 605 | } |
606 | qDebug("KO: Downsizing Pixmaps "); | 606 | qDebug("KO: Downsizing Pixmaps %s",QDateTime::currentDateTime().toString().latin1()); |
607 | mAgenda->shrinkPixmap(); | 607 | mAgenda->shrinkPixmap(); |
608 | mAllDayAgenda->shrinkPixmap(); | 608 | mAllDayAgenda->shrinkPixmap(); |
609 | KOAgendaItem::paintPix()->resize( 20,20); | 609 | KOAgendaItem::paintPix()->resize( 20,20); |
610 | KOAgendaItem::paintPixAllday()->resize( 20,20); | 610 | KOAgendaItem::paintPixAllday()->resize( 20,20); |
611 | #endif | 611 | #endif |
612 | 612 | ||
613 | } | 613 | } |
614 | void KOAgendaView::toggleAllDay() | 614 | void KOAgendaView::toggleAllDay() |
615 | { | 615 | { |
616 | if ( mSplitterAgenda->firstHandle() ) | 616 | if ( mSplitterAgenda->firstHandle() ) |
617 | mSplitterAgenda->firstHandle()->toggle(); | 617 | mSplitterAgenda->firstHandle()->toggle(); |
618 | } | 618 | } |
619 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 619 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
620 | { | 620 | { |
621 | calendar()->addIncidence( inc ); | 621 | calendar()->addIncidence( inc ); |
622 | 622 | ||
623 | if ( incOld ) { | 623 | if ( incOld ) { |
624 | if ( incOld->typeID() == todoID ) | 624 | if ( incOld->typeID() == todoID ) |
625 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 625 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
626 | else | 626 | else |
627 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 627 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
628 | } | 628 | } |
629 | 629 | ||
630 | } | 630 | } |
631 | void KOAgendaView::categoryChanged(Incidence * inc) | 631 | void KOAgendaView::categoryChanged(Incidence * inc) |
632 | { | 632 | { |
633 | mAgenda->categoryChanged( inc ); | 633 | mAgenda->categoryChanged( inc ); |
634 | mAllDayAgenda->categoryChanged( inc ); | 634 | mAllDayAgenda->categoryChanged( inc ); |
635 | } | 635 | } |
636 | KOAgendaView::~KOAgendaView() | 636 | KOAgendaView::~KOAgendaView() |
637 | { | 637 | { |
638 | delete mAllAgendaPopup; | 638 | delete mAllAgendaPopup; |
639 | //delete mAllDayAgendaPopup; | 639 | //delete mAllDayAgendaPopup; |
640 | delete KOAgendaItem::paintPix(); | 640 | delete KOAgendaItem::paintPix(); |
641 | delete KOAgendaItem::paintPixAllday(); | 641 | delete KOAgendaItem::paintPixAllday(); |
642 | } | 642 | } |
643 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 643 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
644 | { | 644 | { |
645 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 645 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
646 | bool uc = false; | 646 | bool uc = false; |
647 | int ow = e->oldSize().width(); | 647 | int ow = e->oldSize().width(); |
648 | int oh = e->oldSize().height(); | 648 | int oh = e->oldSize().height(); |
649 | int w = e->size().width(); | 649 | int w = e->size().width(); |
650 | int h = e->size().height(); | 650 | int h = e->size().height(); |
651 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 651 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
652 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 652 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
653 | uc = true; | 653 | uc = true; |
654 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 654 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
655 | } | 655 | } |
656 | mUpcomingWidth = e->size().width() ; | 656 | mUpcomingWidth = e->size().width() ; |
657 | if ( mBlockUpdating || uc ) { | 657 | if ( mBlockUpdating || uc ) { |
658 | mBlockUpdating = false; | 658 | mBlockUpdating = false; |
659 | //mAgenda->setMinimumSize(800 , 600 ); | 659 | //mAgenda->setMinimumSize(800 , 600 ); |
660 | //qDebug("mAgenda->resize+++++++++++++++ "); | 660 | //qDebug("mAgenda->resize+++++++++++++++ "); |
661 | updateConfig(); | 661 | updateConfig(); |
662 | //qDebug("KOAgendaView::Updating now possible "); | 662 | //qDebug("KOAgendaView::Updating now possible "); |
663 | } else | 663 | } else |
664 | createDayLabels(); | 664 | createDayLabels(); |
665 | //qDebug("resizeEvent end "); | 665 | //qDebug("resizeEvent end "); |
666 | 666 | ||
667 | } | 667 | } |
668 | void KOAgendaView::slotDaylabelClicked( int num ) | 668 | void KOAgendaView::slotDaylabelClicked( int num ) |
669 | { | 669 | { |
670 | 670 | ||
671 | QDate firstDate = mSelectedDates.first(); | 671 | QDate firstDate = mSelectedDates.first(); |
672 | if ( num == -1 ) | 672 | if ( num == -1 ) |
673 | emit showDateView( 6, firstDate ); | 673 | emit showDateView( 6, firstDate ); |
674 | else if (num >= 0 ) { | 674 | else if (num >= 0 ) { |
675 | if ( mSelectedDates.count() == 1) | 675 | if ( mSelectedDates.count() == 1) |
676 | emit showDateView( 9, firstDate.addDays( num ) ); | 676 | emit showDateView( 9, firstDate.addDays( num ) ); |
677 | else | 677 | else |
678 | emit showDateView( 3, firstDate.addDays( num ) ); | 678 | emit showDateView( 3, firstDate.addDays( num ) ); |
679 | } | 679 | } |
680 | else | 680 | else |
681 | showDateView( 10, firstDate.addDays(1) ); | 681 | showDateView( 10, firstDate.addDays(1) ); |
682 | } | 682 | } |
683 | 683 | ||
684 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 684 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
685 | { | 685 | { |
686 | 686 | ||
687 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 687 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
688 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 688 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
689 | mDayLabelsList.append( dayLabel ); | 689 | mDayLabelsList.append( dayLabel ); |
690 | mLayoutDayLabels->addWidget(dayLabel); | 690 | mLayoutDayLabels->addWidget(dayLabel); |
691 | return dayLabel ; | 691 | return dayLabel ; |
692 | } | 692 | } |
693 | 693 | ||
694 | void KOAgendaView::createDayLabels() | 694 | void KOAgendaView::createDayLabels() |
695 | { | 695 | { |
696 | 696 | ||
697 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 697 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
698 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 698 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
699 | return; | 699 | return; |
700 | 700 | ||
701 | } | 701 | } |
702 | int newHight; | 702 | int newHight; |
703 | if ( !mSelectedDates.count()) | 703 | if ( !mSelectedDates.count()) |
704 | return; | 704 | return; |
705 | 705 | ||
706 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 706 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
707 | // It would remove some flickering and gain speed (since this is called by | 707 | // It would remove some flickering and gain speed (since this is called by |
708 | // each updateView() call) | 708 | // each updateView() call) |
709 | 709 | ||
710 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 710 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
711 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 711 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
712 | if ( maxWid < 20 ) | 712 | if ( maxWid < 20 ) |
713 | maxWid = 20; | 713 | maxWid = 20; |
714 | 714 | ||
715 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 715 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
716 | QFontMetrics fm ( dlf ); | 716 | QFontMetrics fm ( dlf ); |
717 | dlf.setBold( true ); | 717 | dlf.setBold( true ); |
718 | int selCount = mSelectedDates.count(); | 718 | int selCount = mSelectedDates.count(); |
719 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 719 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
720 | QString dayTest = "Mon 20"; | 720 | QString dayTest = "Mon 20"; |
721 | //QString dayTest = "Mon 20"; | 721 | //QString dayTest = "Mon 20"; |
722 | int wid = fm.width( dayTest ); | 722 | int wid = fm.width( dayTest ); |
723 | //maxWid -= ( selCount * 3 ); //working for QLabels | 723 | //maxWid -= ( selCount * 3 ); //working for QLabels |
724 | if ( QApplication::desktop()->width() <= 320 ) | 724 | if ( QApplication::desktop()->width() <= 320 ) |
725 | maxWid -= ( selCount * 3 ); //working for QPushButton | 725 | maxWid -= ( selCount * 3 ); //working for QPushButton |
726 | else | 726 | else |
727 | maxWid -= ( selCount * 4 ); //working for QPushButton | 727 | maxWid -= ( selCount * 4 ); //working for QPushButton |
728 | if ( maxWid < 0 ) | 728 | if ( maxWid < 0 ) |
729 | maxWid = 20; | 729 | maxWid = 20; |
730 | int needWid = wid * selCount; | 730 | int needWid = wid * selCount; |
731 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 731 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
732 | //if ( needWid > maxWid ) | 732 | //if ( needWid > maxWid ) |
733 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 733 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
734 | while ( needWid > maxWid ) { | 734 | while ( needWid > maxWid ) { |
735 | dayTest = dayTest.left( dayTest.length() - 1 ); | 735 | dayTest = dayTest.left( dayTest.length() - 1 ); |
736 | wid = fm.width( dayTest ); | 736 | wid = fm.width( dayTest ); |
737 | needWid = wid * selCount; | 737 | needWid = wid * selCount; |
738 | } | 738 | } |
739 | int maxLen = dayTest.length(); | 739 | int maxLen = dayTest.length(); |
740 | int fontPoint = dlf.pointSize(); | 740 | int fontPoint = dlf.pointSize(); |
741 | if ( maxLen < 2 ) { | 741 | if ( maxLen < 2 ) { |
742 | int fontPoint = dlf.pointSize(); | 742 | int fontPoint = dlf.pointSize(); |
743 | while ( fontPoint > 4 ) { | 743 | while ( fontPoint > 4 ) { |
744 | --fontPoint; | 744 | --fontPoint; |
745 | dlf.setPointSize( fontPoint ); | 745 | dlf.setPointSize( fontPoint ); |
746 | QFontMetrics f( dlf ); | 746 | QFontMetrics f( dlf ); |
747 | wid = f.width( "30" ); | 747 | wid = f.width( "30" ); |
748 | needWid = wid * selCount; | 748 | needWid = wid * selCount; |
749 | if ( needWid < maxWid ) | 749 | if ( needWid < maxWid ) |
750 | break; | 750 | break; |
751 | } | 751 | } |
752 | maxLen = 2; | 752 | maxLen = 2; |
753 | } | 753 | } |
754 | //qDebug("Max len %d ", dayTest.length() ); | 754 | //qDebug("Max len %d ", dayTest.length() ); |
755 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) | 755 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) |
756 | dlf.setBold( false ); | 756 | dlf.setBold( false ); |
757 | QFontMetrics tempF( dlf ); | 757 | QFontMetrics tempF( dlf ); |
758 | newHight = tempF.height(); | 758 | newHight = tempF.height(); |
759 | mDayLabels->setFont( dlf ); | 759 | mDayLabels->setFont( dlf ); |
760 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 760 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
761 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 761 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
762 | //mLayoutDayLabels->addSpacing( 2 ); | 762 | //mLayoutDayLabels->addSpacing( 2 ); |
763 | // QFont lFont = dlf; | 763 | // QFont lFont = dlf; |
764 | bool appendLabels = false; | 764 | bool appendLabels = false; |
765 | KOAgendaButton *dayLabel; | 765 | KOAgendaButton *dayLabel; |
766 | dayLabel = mDayLabelsList.first(); | 766 | dayLabel = mDayLabelsList.first(); |
767 | if ( !dayLabel ) { | 767 | if ( !dayLabel ) { |
768 | appendLabels = true; | 768 | appendLabels = true; |
769 | dayLabel = getNewDaylabel(); | 769 | dayLabel = getNewDaylabel(); |
770 | } | 770 | } |
771 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 771 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
772 | dayLabel->setFont( dlf ); | 772 | dayLabel->setFont( dlf ); |
773 | dayLabel->setNum( -1 ); | 773 | dayLabel->setNum( -1 ); |
774 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 774 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
775 | 775 | ||
776 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 776 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
777 | dayLabel->show(); | 777 | dayLabel->show(); |
778 | DateList::ConstIterator dit; | 778 | DateList::ConstIterator dit; |
779 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 779 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
780 | int counter = -1; | 780 | int counter = -1; |
781 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 781 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
782 | ++counter; | 782 | ++counter; |
783 | QDate date = *dit; | 783 | QDate date = *dit; |
784 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 784 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
785 | if ( ! appendLabels ) { | 785 | if ( ! appendLabels ) { |
786 | dayLabel = mDayLabelsList.next(); | 786 | dayLabel = mDayLabelsList.next(); |
787 | if ( !dayLabel ) | 787 | if ( !dayLabel ) |
788 | appendLabels = true; | 788 | appendLabels = true; |
789 | } | 789 | } |
790 | if ( appendLabels ) { | 790 | if ( appendLabels ) { |
791 | dayLabel = getNewDaylabel(); | 791 | dayLabel = getNewDaylabel(); |
792 | } | 792 | } |
793 | dayLabel->setMinimumWidth( 1 ); | 793 | dayLabel->setMinimumWidth( 1 ); |
794 | dayLabel->setMaximumWidth( 10240 ); | 794 | dayLabel->setMaximumWidth( 10240 ); |
795 | dayLabel->setFont( dlf ); | 795 | dayLabel->setFont( dlf ); |
796 | dayLabel->show(); | 796 | dayLabel->show(); |
797 | dayLabel->setAutoRepeat( false ); | 797 | dayLabel->setAutoRepeat( false ); |
798 | dayLabel->setNum( counter ); | 798 | dayLabel->setNum( counter ); |