-rw-r--r-- | korganizer/koagenda.cpp | 30 | ||||
-rw-r--r-- | korganizer/koagenda.h | 4 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 5 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 31 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 5 |
5 files changed, 65 insertions, 10 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0280c74..c339b57 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,417 +1,435 @@ | |||
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 | bool KOAgenda::mInvalidPixmap = false; | ||
63 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 67 | { |
67 | setLineWidth(0); | 68 | setLineWidth(0); |
68 | setMargin(0); | 69 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 73 | minutes->start(0, true); |
73 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
75 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
76 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
77 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
78 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
79 | 80 | ||
80 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
81 | 82 | ||
82 | oldToday = -1; | 83 | oldToday = -1; |
83 | } | 84 | } |
84 | 85 | ||
85 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
86 | { | 87 | { |
87 | delete minutes; | 88 | delete minutes; |
88 | } | 89 | } |
89 | 90 | ||
90 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
91 | { | 92 | { |
92 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
93 | 94 | ||
94 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
95 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
96 | int col = 0; | 97 | int col = 0; |
97 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
98 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
99 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
100 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
101 | ++col; | 102 | ++col; |
102 | } | 103 | } |
103 | 104 | ||
104 | return -1; | 105 | return -1; |
105 | } | 106 | } |
106 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
107 | { | 108 | { |
108 | updateLocation(); | 109 | updateLocation(); |
109 | } | 110 | } |
110 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
111 | { | 112 | { |
112 | 113 | ||
113 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
115 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
116 | recalculate = true; | 117 | recalculate = true; |
117 | 118 | ||
118 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
119 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
121 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
122 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
124 | 125 | ||
125 | oldTime = tim; | 126 | oldTime = tim; |
126 | oldToday = today; | 127 | oldToday = today; |
127 | 128 | ||
128 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
129 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
130 | return; | 131 | return; |
131 | } else { | 132 | } else { |
132 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
133 | } | 134 | } |
134 | 135 | ||
135 | if(recalculate) | 136 | if(recalculate) |
136 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
137 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
138 | raise(); | 139 | raise(); |
139 | 140 | ||
140 | if(recalculate) | 141 | if(recalculate) |
141 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
143 | 144 | ||
144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
145 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
146 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
147 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
148 | // narrower than the other columns. | 149 | // narrower than the other columns. |
149 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
150 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
152 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
153 | 154 | ||
154 | mTimeBox->raise(); | 155 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 156 | //mTimeBox->setAutoMask(true); |
156 | minutes->start(5000,true); | 157 | minutes->start(5000,true); |
157 | } | 158 | } |
158 | 159 | ||
159 | 160 | ||
160 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
161 | 162 | ||
162 | 163 | ||
163 | /* | 164 | /* |
164 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
165 | */ | 166 | */ |
166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
167 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
168 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
169 | { | 170 | { |
170 | 171 | ||
171 | mAllAgendaPopup = 0; | 172 | mAllAgendaPopup = 0; |
172 | mColumns = columns; | 173 | mColumns = columns; |
173 | mRows = rows; | 174 | mRows = rows; |
174 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
175 | mAllDayMode = false; | 176 | mAllDayMode = false; |
176 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
178 | #endif | 179 | #endif |
179 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
180 | init(); | 181 | init(); |
182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | ||
181 | } | 183 | } |
182 | 184 | ||
183 | /* | 185 | /* |
184 | Create an agenda widget with columns columns and one row. This is used for | 186 | Create an agenda widget with columns columns and one row. This is used for |
185 | all-day events. | 187 | all-day events. |
186 | */ | 188 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
188 | QScrollView(parent,name,f) | 190 | QScrollView(parent,name,f) |
189 | { | 191 | { |
190 | mAllAgendaPopup = 0; | 192 | mAllAgendaPopup = 0; |
191 | blockResize = false; | 193 | blockResize = false; |
192 | mColumns = columns; | 194 | mColumns = columns; |
193 | mRows = 1; | 195 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 198 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 199 | #ifndef DESKTOP_VERSION |
198 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 201 | #endif |
200 | mHolidayMask = 0; | 202 | mHolidayMask = 0; |
201 | init(); | 203 | init(); |
202 | } | 204 | } |
203 | 205 | ||
204 | 206 | ||
205 | KOAgenda::~KOAgenda() | 207 | KOAgenda::~KOAgenda() |
206 | { | 208 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 209 | if(mMarcusBains) delete mMarcusBains; |
208 | 210 | ||
209 | } | 211 | } |
210 | 212 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 213 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 214 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 216 | } |
215 | 217 | ||
216 | 218 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 219 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 220 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 222 | } |
221 | 223 | ||
222 | 224 | ||
223 | void KOAgenda::init() | 225 | void KOAgenda::init() |
224 | { | 226 | { |
225 | mPopupTimer = new QTimer(this); | 227 | mPopupTimer = new QTimer(this); |
226 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
227 | 229 | ||
228 | mNewItemPopup = new QPopupMenu( this ); | 230 | mNewItemPopup = new QPopupMenu( this ); |
229 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
230 | QString pathString = ""; | 232 | QString pathString = ""; |
231 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
232 | if ( QApplication::desktop()->width() < 480 ) | 234 | if ( QApplication::desktop()->width() < 480 ) |
233 | pathString += "icons16/"; | 235 | pathString += "icons16/"; |
234 | } else | 236 | } else |
235 | pathString += "iconsmini/"; | 237 | pathString += "iconsmini/"; |
236 | 238 | ||
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
239 | mNewItemPopup->insertSeparator ( ); | 241 | mNewItemPopup->insertSeparator ( ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
246 | #ifndef _WIN32_ | 248 | #ifndef _WIN32_ |
247 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
248 | viewport()->setWFlags ( wflags); | 250 | viewport()->setWFlags ( wflags); |
249 | #endif | 251 | #endif |
250 | mGridSpacingX = 80; | 252 | mGridSpacingX = 80; |
251 | mResizeBorderWidth = 8; | 253 | mResizeBorderWidth = 8; |
252 | mScrollBorderWidth = 8; | 254 | mScrollBorderWidth = 8; |
253 | mScrollDelay = 30; | 255 | mScrollDelay = 30; |
254 | mScrollOffset = 10; | 256 | mScrollOffset = 10; |
255 | mPaintPixmap.resize( 20,20); | 257 | mPaintPixmap.resize( 20,20); |
256 | //enableClipper(true); | 258 | //enableClipper(true); |
257 | 259 | ||
258 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
259 | // effect. Has to be fixed. | 261 | // effect. Has to be fixed. |
260 | setFocusPolicy(WheelFocus); | 262 | setFocusPolicy(WheelFocus); |
261 | 263 | ||
262 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
263 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
264 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
265 | 267 | ||
266 | mStartCellX = 0; | 268 | mStartCellX = 0; |
267 | mStartCellY = 0; | 269 | mStartCellY = 0; |
268 | mCurrentCellX = 0; | 270 | mCurrentCellX = 0; |
269 | mCurrentCellY = 0; | 271 | mCurrentCellY = 0; |
270 | 272 | ||
271 | mSelectionCellX = 0; | 273 | mSelectionCellX = 0; |
272 | mSelectionYTop = 0; | 274 | mSelectionYTop = 0; |
273 | mSelectionHeight = 0; | 275 | mSelectionHeight = 0; |
274 | 276 | ||
275 | mOldLowerScrollValue = -1; | 277 | mOldLowerScrollValue = -1; |
276 | mOldUpperScrollValue = -1; | 278 | mOldUpperScrollValue = -1; |
277 | 279 | ||
278 | mClickedItem = 0; | 280 | mClickedItem = 0; |
279 | 281 | ||
280 | mActionItem = 0; | 282 | mActionItem = 0; |
281 | mActionType = NOP; | 283 | mActionType = NOP; |
282 | mItemMoved = false; | 284 | mItemMoved = false; |
283 | 285 | ||
284 | mSelectedItem = 0; | 286 | mSelectedItem = 0; |
285 | 287 | ||
286 | // mItems.setAutoDelete(true); | 288 | // mItems.setAutoDelete(true); |
287 | 289 | ||
288 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
289 | 291 | ||
290 | viewport()->update(); | 292 | viewport()->update(); |
291 | 293 | ||
292 | setMinimumSize(30, 1); | 294 | setMinimumSize(30, 1); |
293 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 295 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
294 | 296 | ||
295 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 297 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
296 | // controlled in a way that the contents horizontally always fits. Then it is | 298 | // controlled in a way that the contents horizontally always fits. Then it is |
297 | // not necessary to turn off the scrollbar. | 299 | // not necessary to turn off the scrollbar. |
298 | setHScrollBarMode(AlwaysOff); | 300 | setHScrollBarMode(AlwaysOff); |
299 | if ( ! mAllDayMode ) | 301 | if ( ! mAllDayMode ) |
300 | setVScrollBarMode(AlwaysOn); | 302 | setVScrollBarMode(AlwaysOn); |
301 | else | 303 | else |
302 | setVScrollBarMode(AlwaysOff); | 304 | setVScrollBarMode(AlwaysOff); |
303 | 305 | ||
304 | setStartHour(KOPrefs::instance()->mDayBegins); | 306 | setStartHour(KOPrefs::instance()->mDayBegins); |
305 | 307 | ||
306 | calculateWorkingHours(); | 308 | calculateWorkingHours(); |
307 | 309 | ||
308 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
309 | SLOT(checkScrollBoundaries(int))); | 311 | SLOT(checkScrollBoundaries(int))); |
310 | 312 | ||
311 | // Create the Marcus Bains line. | 313 | // Create the Marcus Bains line. |
312 | if(mAllDayMode) | 314 | if(mAllDayMode) |
313 | mMarcusBains = 0; | 315 | mMarcusBains = 0; |
314 | else { | 316 | else { |
315 | mMarcusBains = new MarcusBains(this); | 317 | mMarcusBains = new MarcusBains(this); |
316 | addChild(mMarcusBains); | 318 | addChild(mMarcusBains); |
317 | } | 319 | } |
318 | mPopupKind = 0; | 320 | mPopupKind = 0; |
319 | mPopupItem = 0; | 321 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | ||
323 | |||
320 | } | 324 | } |
321 | 325 | ||
326 | void KOAgenda::shrinkPixmap() | ||
327 | { | ||
328 | mPaintPixmap.resize( 20,20); | ||
329 | mInvalidPixmap = true; | ||
330 | } | ||
331 | void KOAgenda::slotContentMove(int,int) | ||
332 | { | ||
333 | if ( mActionType == NOP ) | ||
334 | slotClearSelection(); | ||
335 | if ( mSelectedItem && !mActionItem ) { | ||
336 | deselectItem(); | ||
337 | emit incidenceSelected( 0 ); | ||
338 | } | ||
339 | } | ||
322 | void KOAgenda::clear() | 340 | void KOAgenda::clear() |
323 | { | 341 | { |
324 | KOAgendaItem *item; | 342 | KOAgendaItem *item; |
325 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 343 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
326 | mUnusedItems.append( item ); | 344 | mUnusedItems.append( item ); |
327 | //item->hide(); | 345 | //item->hide(); |
328 | } | 346 | } |
329 | mItems.clear(); | 347 | mItems.clear(); |
330 | mSelectedItem = 0; | 348 | mSelectedItem = 0; |
331 | clearSelection(); | 349 | clearSelection(); |
332 | } | 350 | } |
333 | 351 | ||
334 | void KOAgenda::clearSelection() | 352 | void KOAgenda::clearSelection() |
335 | { | 353 | { |
336 | mSelectionCellX = 0; | 354 | mSelectionCellX = 0; |
337 | mSelectionYTop = 0; | 355 | mSelectionYTop = 0; |
338 | mSelectionHeight = 0; | 356 | mSelectionHeight = 0; |
339 | } | 357 | } |
340 | 358 | ||
341 | void KOAgenda::marcus_bains() | 359 | void KOAgenda::marcus_bains() |
342 | { | 360 | { |
343 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 361 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
344 | } | 362 | } |
345 | 363 | ||
346 | 364 | ||
347 | void KOAgenda::changeColumns(int columns) | 365 | void KOAgenda::changeColumns(int columns) |
348 | { | 366 | { |
349 | if (columns == 0) { | 367 | if (columns == 0) { |
350 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 368 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
351 | return; | 369 | return; |
352 | } | 370 | } |
353 | clear(); | 371 | clear(); |
354 | mColumns = columns; | 372 | mColumns = columns; |
355 | computeSizes(); | 373 | computeSizes(); |
356 | } | 374 | } |
357 | 375 | ||
358 | /* | 376 | /* |
359 | This is the eventFilter function, which gets all events from the KOAgendaItems | 377 | This is the eventFilter function, which gets all events from the KOAgendaItems |
360 | contained in the agenda. It has to handle moving and resizing for all items. | 378 | contained in the agenda. It has to handle moving and resizing for all items. |
361 | */ | 379 | */ |
362 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 380 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
363 | { | 381 | { |
364 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 382 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
365 | switch(event->type()) { | 383 | switch(event->type()) { |
366 | case QEvent::MouseButtonPress: | 384 | case QEvent::MouseButtonPress: |
367 | case QEvent::MouseButtonDblClick: | 385 | case QEvent::MouseButtonDblClick: |
368 | case QEvent::MouseButtonRelease: | 386 | case QEvent::MouseButtonRelease: |
369 | case QEvent::MouseMove: | 387 | case QEvent::MouseMove: |
370 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 388 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
371 | 389 | ||
372 | case (QEvent::Leave): | 390 | case (QEvent::Leave): |
373 | if (!mActionItem) | 391 | if (!mActionItem) |
374 | setCursor(arrowCursor); | 392 | setCursor(arrowCursor); |
375 | return true; | 393 | return true; |
376 | 394 | ||
377 | default: | 395 | default: |
378 | return QScrollView::eventFilter(object,event); | 396 | return QScrollView::eventFilter(object,event); |
379 | } | 397 | } |
380 | } | 398 | } |
381 | void KOAgenda::popupMenu() | 399 | void KOAgenda::popupMenu() |
382 | { | 400 | { |
383 | mPopupTimer->stop(); | 401 | mPopupTimer->stop(); |
384 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 402 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
385 | if (mActionItem ) { | 403 | if (mActionItem ) { |
386 | endItemAction(); | 404 | endItemAction(); |
387 | } | 405 | } |
388 | mLeftMouseDown = false; // no more leftMouse computation | 406 | mLeftMouseDown = false; // no more leftMouse computation |
389 | if (mPopupItem) { | 407 | if (mPopupItem) { |
390 | //mClickedItem = mPopupItem; | 408 | //mClickedItem = mPopupItem; |
391 | selectItem(mPopupItem); | 409 | selectItem(mPopupItem); |
392 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 410 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
393 | mAllAgendaPopup->installEventFilter( this ); | 411 | mAllAgendaPopup->installEventFilter( this ); |
394 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 412 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
395 | 413 | ||
396 | } | 414 | } |
397 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 415 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
398 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 416 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
399 | endSelectAction( false ); // do not emit new event signal | 417 | endSelectAction( false ); // do not emit new event signal |
400 | mLeftMouseDown = false; // no more leftMouse computation | 418 | mLeftMouseDown = false; // no more leftMouse computation |
401 | } | 419 | } |
402 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 420 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
403 | mNewItemPopup->installEventFilter( this ); | 421 | mNewItemPopup->installEventFilter( this ); |
404 | mNewItemPopup->popup( mPopupPos); | 422 | mNewItemPopup->popup( mPopupPos); |
405 | 423 | ||
406 | } | 424 | } |
407 | mLeftMouseDown = false; | 425 | mLeftMouseDown = false; |
408 | mPopupItem = 0; | 426 | mPopupItem = 0; |
409 | mPopupKind = 0; | 427 | mPopupKind = 0; |
410 | } | 428 | } |
411 | void KOAgenda::categoryChanged(Incidence * inc) | 429 | void KOAgenda::categoryChanged(Incidence * inc) |
412 | { | 430 | { |
413 | KOAgendaItem *item; | 431 | KOAgendaItem *item; |
414 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 432 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
415 | if ( item->incidence() == inc ) { | 433 | if ( item->incidence() == inc ) { |
416 | item->initColor (); | 434 | item->initColor (); |
417 | item->updateItem(); | 435 | item->updateItem(); |
@@ -829,192 +847,193 @@ void KOAgenda::startItemAction(QPoint viewportPos) | |||
829 | mActionItem->cellYTop() == mCurrentCellY && | 847 | mActionItem->cellYTop() == mCurrentCellY && |
830 | !mActionItem->firstMultiItem()) { | 848 | !mActionItem->firstMultiItem()) { |
831 | mActionType = RESIZETOP; | 849 | mActionType = RESIZETOP; |
832 | setCursor(sizeVerCursor); | 850 | setCursor(sizeVerCursor); |
833 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 851 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
834 | mActionItem->cellYBottom() == mCurrentCellY && | 852 | mActionItem->cellYBottom() == mCurrentCellY && |
835 | !mActionItem->lastMultiItem()) { | 853 | !mActionItem->lastMultiItem()) { |
836 | mActionType = RESIZEBOTTOM; | 854 | mActionType = RESIZEBOTTOM; |
837 | setCursor(sizeVerCursor); | 855 | setCursor(sizeVerCursor); |
838 | } else { | 856 | } else { |
839 | mActionType = MOVE; | 857 | mActionType = MOVE; |
840 | mActionItem->startMove(); | 858 | mActionItem->startMove(); |
841 | setCursor(sizeAllCursor); | 859 | setCursor(sizeAllCursor); |
842 | } | 860 | } |
843 | } | 861 | } |
844 | } | 862 | } |
845 | 863 | ||
846 | void KOAgenda::performItemAction(QPoint viewportPos) | 864 | void KOAgenda::performItemAction(QPoint viewportPos) |
847 | { | 865 | { |
848 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 866 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
849 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 867 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
850 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 868 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
851 | // point = clipper()->mapFromGlobal(point); | 869 | // point = clipper()->mapFromGlobal(point); |
852 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 870 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
853 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 871 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
854 | int x,y; | 872 | int x,y; |
855 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 873 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
856 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 874 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
857 | int gx,gy; | 875 | int gx,gy; |
858 | contentsToGrid(x,y,gx,gy); | 876 | contentsToGrid(x,y,gx,gy); |
859 | QPoint clipperPos = clipper()-> | 877 | QPoint clipperPos = clipper()-> |
860 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 878 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
861 | 879 | ||
862 | // Cursor left active agenda area. | 880 | // Cursor left active agenda area. |
863 | // This starts a drag. | 881 | // This starts a drag. |
864 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 882 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
865 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 883 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
866 | if ( mActionType == MOVE ) { | 884 | if ( mActionType == MOVE ) { |
867 | mScrollUpTimer.stop(); | 885 | mScrollUpTimer.stop(); |
868 | mScrollDownTimer.stop(); | 886 | mScrollDownTimer.stop(); |
869 | mActionItem->resetMove(); | 887 | mActionItem->resetMove(); |
870 | placeSubCells( mActionItem ); | 888 | placeSubCells( mActionItem ); |
871 | // emit startDragSignal( mActionItem->incidence() ); | 889 | // emit startDragSignal( mActionItem->incidence() ); |
872 | setCursor( arrowCursor ); | 890 | setCursor( arrowCursor ); |
873 | mActionItem = 0; | 891 | mActionItem = 0; |
874 | mActionType = NOP; | 892 | mActionType = NOP; |
875 | mItemMoved = 0; | 893 | mItemMoved = 0; |
876 | return; | 894 | return; |
877 | } | 895 | } |
878 | } else { | 896 | } else { |
879 | switch ( mActionType ) { | 897 | switch ( mActionType ) { |
880 | case MOVE: | 898 | case MOVE: |
881 | setCursor( sizeAllCursor ); | 899 | setCursor( sizeAllCursor ); |
882 | break; | 900 | break; |
883 | case RESIZETOP: | 901 | case RESIZETOP: |
884 | case RESIZEBOTTOM: | 902 | case RESIZEBOTTOM: |
885 | setCursor( sizeVerCursor ); | 903 | setCursor( sizeVerCursor ); |
886 | break; | 904 | break; |
887 | case RESIZELEFT: | 905 | case RESIZELEFT: |
888 | case RESIZERIGHT: | 906 | case RESIZERIGHT: |
889 | setCursor( sizeHorCursor ); | 907 | setCursor( sizeHorCursor ); |
890 | break; | 908 | break; |
891 | default: | 909 | default: |
892 | setCursor( arrowCursor ); | 910 | setCursor( arrowCursor ); |
893 | } | 911 | } |
894 | } | 912 | } |
895 | 913 | ||
896 | // Scroll if item was moved to upper or lower end of agenda. | 914 | // Scroll if item was moved to upper or lower end of agenda. |
897 | if (clipperPos.y() < mScrollBorderWidth) { | 915 | if (clipperPos.y() < mScrollBorderWidth) { |
898 | mScrollUpTimer.start(mScrollDelay); | 916 | mScrollUpTimer.start(mScrollDelay); |
899 | } else if (visibleHeight() - clipperPos.y() < | 917 | } else if (visibleHeight() - clipperPos.y() < |
900 | mScrollBorderWidth) { | 918 | mScrollBorderWidth) { |
901 | mScrollDownTimer.start(mScrollDelay); | 919 | mScrollDownTimer.start(mScrollDelay); |
902 | } else { | 920 | } else { |
903 | mScrollUpTimer.stop(); | 921 | mScrollUpTimer.stop(); |
904 | mScrollDownTimer.stop(); | 922 | mScrollDownTimer.stop(); |
905 | } | 923 | } |
906 | 924 | ||
907 | // Move or resize item if necessary | 925 | // Move or resize item if necessary |
908 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 926 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
909 | mItemMoved = true; | 927 | mItemMoved = true; |
910 | mActionItem->raise(); | 928 | mActionItem->raise(); |
911 | if (mActionType == MOVE) { | 929 | if (mActionType == MOVE) { |
912 | // Move all items belonging to a multi item | 930 | // Move all items belonging to a multi item |
913 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 931 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
914 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 932 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
915 | if (!moveItem) moveItem = mActionItem; | 933 | if (!moveItem) moveItem = mActionItem; |
916 | while (moveItem) { | 934 | while (moveItem) { |
917 | int dy; | 935 | int dy; |
918 | if (isMultiItem) dy = 0; | 936 | if (isMultiItem) dy = 0; |
919 | else dy = gy - mCurrentCellY; | 937 | else dy = gy - mCurrentCellY; |
920 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 938 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
921 | int x,y; | 939 | int x,y; |
922 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 940 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
923 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 941 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
924 | mGridSpacingY * moveItem->cellHeight()); | 942 | mGridSpacingY * moveItem->cellHeight()); |
943 | moveItem->raise(); | ||
925 | moveChild(moveItem,x,y); | 944 | moveChild(moveItem,x,y); |
926 | moveItem = moveItem->nextMultiItem(); | 945 | moveItem = moveItem->nextMultiItem(); |
927 | } | 946 | } |
928 | } else if (mActionType == RESIZETOP) { | 947 | } else if (mActionType == RESIZETOP) { |
929 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 948 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
930 | mActionItem->expandTop(gy - mCurrentCellY); | 949 | mActionItem->expandTop(gy - mCurrentCellY); |
931 | mActionItem->resize(mActionItem->width(), | 950 | mActionItem->resize(mActionItem->width(), |
932 | mGridSpacingY * mActionItem->cellHeight()); | 951 | mGridSpacingY * mActionItem->cellHeight()); |
933 | int x,y; | 952 | int x,y; |
934 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 953 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
935 | //moveChild(mActionItem,childX(mActionItem),y); | 954 | //moveChild(mActionItem,childX(mActionItem),y); |
936 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 955 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
937 | } | 956 | } |
938 | } else if (mActionType == RESIZEBOTTOM) { | 957 | } else if (mActionType == RESIZEBOTTOM) { |
939 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 958 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
940 | mActionItem->expandBottom(gy - mCurrentCellY); | 959 | mActionItem->expandBottom(gy - mCurrentCellY); |
941 | mActionItem->resize(mActionItem->width(), | 960 | mActionItem->resize(mActionItem->width(), |
942 | mGridSpacingY * mActionItem->cellHeight()); | 961 | mGridSpacingY * mActionItem->cellHeight()); |
943 | } | 962 | } |
944 | } else if (mActionType == RESIZELEFT) { | 963 | } else if (mActionType == RESIZELEFT) { |
945 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 964 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
946 | mActionItem->expandLeft(gx - mCurrentCellX); | 965 | mActionItem->expandLeft(gx - mCurrentCellX); |
947 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 966 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
948 | mActionItem->height()); | 967 | mActionItem->height()); |
949 | int x,y; | 968 | int x,y; |
950 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 969 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
951 | moveChild(mActionItem,x,childY(mActionItem)); | 970 | moveChild(mActionItem,x,childY(mActionItem)); |
952 | } | 971 | } |
953 | } else if (mActionType == RESIZERIGHT) { | 972 | } else if (mActionType == RESIZERIGHT) { |
954 | if (mCurrentCellX >= mActionItem->cellX()) { | 973 | if (mCurrentCellX >= mActionItem->cellX()) { |
955 | mActionItem->expandRight(gx - mCurrentCellX); | 974 | mActionItem->expandRight(gx - mCurrentCellX); |
956 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 975 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
957 | mActionItem->height()); | 976 | mActionItem->height()); |
958 | } | 977 | } |
959 | } | 978 | } |
960 | mCurrentCellX = gx; | 979 | mCurrentCellX = gx; |
961 | mCurrentCellY = gy; | 980 | mCurrentCellY = gy; |
962 | } | 981 | } |
963 | } | 982 | } |
964 | 983 | ||
965 | void KOAgenda::endItemAction() | 984 | void KOAgenda::endItemAction() |
966 | { | 985 | { |
967 | 986 | ||
968 | if ( mItemMoved ) { | 987 | if ( mItemMoved ) { |
969 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 988 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
970 | if ( !placeItem ) { | 989 | if ( !placeItem ) { |
971 | placeItem = mActionItem; | 990 | placeItem = mActionItem; |
972 | } | 991 | } |
973 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 992 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
974 | Incidence* oldInc = placeItem->incidence(); | 993 | Incidence* oldInc = placeItem->incidence(); |
975 | placeItem->recreateIncidence(); | 994 | placeItem->recreateIncidence(); |
976 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 995 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
977 | } | 996 | } |
978 | int type = mActionType; | 997 | int type = mActionType; |
979 | if ( mAllDayMode ) | 998 | if ( mAllDayMode ) |
980 | type = -1; | 999 | type = -1; |
981 | KOAgendaItem *modifiedItem = placeItem; | 1000 | KOAgendaItem *modifiedItem = placeItem; |
982 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1001 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
983 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1002 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
984 | KOAgendaItem *item; | 1003 | KOAgendaItem *item; |
985 | 1004 | ||
986 | if ( placeItem->incidence()->typeID() == todoID ) { | 1005 | if ( placeItem->incidence()->typeID() == todoID ) { |
987 | mSelectedItem = 0; | 1006 | mSelectedItem = 0; |
988 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1007 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
989 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1008 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
990 | emit itemModified( modifiedItem, mActionType ); | 1009 | emit itemModified( modifiedItem, mActionType ); |
991 | } | 1010 | } |
992 | else { | 1011 | else { |
993 | 1012 | ||
994 | 1013 | ||
995 | globalFlagBlockAgendaItemPaint = 1; | 1014 | globalFlagBlockAgendaItemPaint = 1; |
996 | for ( item=oldconflictItems.first(); item != 0; | 1015 | for ( item=oldconflictItems.first(); item != 0; |
997 | item=oldconflictItems.next() ) { | 1016 | item=oldconflictItems.next() ) { |
998 | placeSubCells(item); | 1017 | placeSubCells(item); |
999 | } | 1018 | } |
1000 | while ( placeItem ) { | 1019 | while ( placeItem ) { |
1001 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1020 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1002 | oldconflictItems = placeItem->conflictItems(); | 1021 | oldconflictItems = placeItem->conflictItems(); |
1003 | for ( item=oldconflictItems.first(); item != 0; | 1022 | for ( item=oldconflictItems.first(); item != 0; |
1004 | item=oldconflictItems.next() ) { | 1023 | item=oldconflictItems.next() ) { |
1005 | placeSubCells(item); | 1024 | placeSubCells(item); |
1006 | } | 1025 | } |
1007 | placeSubCells( placeItem ); | 1026 | placeSubCells( placeItem ); |
1008 | placeItem = placeItem->nextMultiItem(); | 1027 | placeItem = placeItem->nextMultiItem(); |
1009 | } | 1028 | } |
1010 | globalFlagBlockAgendaItemPaint = 0; | 1029 | globalFlagBlockAgendaItemPaint = 0; |
1011 | for ( item=oldconflictItems.first(); item != 0; | 1030 | for ( item=oldconflictItems.first(); item != 0; |
1012 | item=oldconflictItems.next() ) { | 1031 | item=oldconflictItems.next() ) { |
1013 | globalFlagBlockAgendaItemUpdate = 0; | 1032 | globalFlagBlockAgendaItemUpdate = 0; |
1014 | item->repaintMe(); | 1033 | item->repaintMe(); |
1015 | globalFlagBlockAgendaItemUpdate = 1; | 1034 | globalFlagBlockAgendaItemUpdate = 1; |
1016 | item->repaint( false ); | 1035 | item->repaint( false ); |
1017 | } | 1036 | } |
1018 | placeItem = modifiedItem; | 1037 | placeItem = modifiedItem; |
1019 | 1038 | ||
1020 | while ( placeItem ) { | 1039 | while ( placeItem ) { |
@@ -1151,192 +1170,199 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | |||
1151 | } | 1170 | } |
1152 | } | 1171 | } |
1153 | } | 1172 | } |
1154 | } | 1173 | } |
1155 | 1174 | ||
1156 | if (conflictItems.count() > 0) { | 1175 | if (conflictItems.count() > 0) { |
1157 | // Look for unused sub cell and insert item | 1176 | // Look for unused sub cell and insert item |
1158 | int i; | 1177 | int i; |
1159 | for(i=0;i<maxSubCells;++i) { | 1178 | for(i=0;i<maxSubCells;++i) { |
1160 | if (!subCellDict.find(i)) { | 1179 | if (!subCellDict.find(i)) { |
1161 | placeItem->setSubCell(i); | 1180 | placeItem->setSubCell(i); |
1162 | break; | 1181 | break; |
1163 | } | 1182 | } |
1164 | } | 1183 | } |
1165 | if (i == maxSubCells) { | 1184 | if (i == maxSubCells) { |
1166 | placeItem->setSubCell(maxSubCells); | 1185 | placeItem->setSubCell(maxSubCells); |
1167 | maxSubCells++; // add new item to number of sub cells | 1186 | maxSubCells++; // add new item to number of sub cells |
1168 | } | 1187 | } |
1169 | 1188 | ||
1170 | // Prepare for sub cell geometry adjustment | 1189 | // Prepare for sub cell geometry adjustment |
1171 | int newSubCellWidth; | 1190 | int newSubCellWidth; |
1172 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1191 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1173 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1192 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1174 | conflictItems.append(placeItem); | 1193 | conflictItems.append(placeItem); |
1175 | 1194 | ||
1176 | 1195 | ||
1177 | // Adjust sub cell geometry of all direct conflict items | 1196 | // Adjust sub cell geometry of all direct conflict items |
1178 | for ( item=conflictItems.first(); item != 0; | 1197 | for ( item=conflictItems.first(); item != 0; |
1179 | item=conflictItems.next() ) { | 1198 | item=conflictItems.next() ) { |
1180 | item->setSubCells(maxSubCells); | 1199 | item->setSubCells(maxSubCells); |
1181 | if (mAllDayMode) { | 1200 | if (mAllDayMode) { |
1182 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1201 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1183 | } else { | 1202 | } else { |
1184 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1203 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1185 | } | 1204 | } |
1186 | int x,y; | 1205 | int x,y; |
1187 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1206 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1188 | if (mAllDayMode) { | 1207 | if (mAllDayMode) { |
1189 | y += item->subCell() * newSubCellWidth; | 1208 | y += item->subCell() * newSubCellWidth; |
1190 | } else { | 1209 | } else { |
1191 | x += item->subCell() * newSubCellWidth; | 1210 | x += item->subCell() * newSubCellWidth; |
1192 | } | 1211 | } |
1193 | moveChild(item,x,y); | 1212 | moveChild(item,x,y); |
1194 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1213 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1195 | //item->updateItem(); | 1214 | //item->updateItem(); |
1196 | } | 1215 | } |
1197 | // Adjust sub cell geometry of all conflict items of all conflict items | 1216 | // Adjust sub cell geometry of all conflict items of all conflict items |
1198 | for ( item=conflictItems.first(); item != 0; | 1217 | for ( item=conflictItems.first(); item != 0; |
1199 | item=conflictItems.next() ) { | 1218 | item=conflictItems.next() ) { |
1200 | if ( placeItem != item ) { | 1219 | if ( placeItem != item ) { |
1201 | KOAgendaItem *item2; | 1220 | KOAgendaItem *item2; |
1202 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1221 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1203 | for ( item2=conflictItems2.first(); item2 != 0; | 1222 | for ( item2=conflictItems2.first(); item2 != 0; |
1204 | item2=conflictItems2.next() ) { | 1223 | item2=conflictItems2.next() ) { |
1205 | if ( item2->subCells() != maxSubCells) { | 1224 | if ( item2->subCells() != maxSubCells) { |
1206 | item2->setSubCells(maxSubCells); | 1225 | item2->setSubCells(maxSubCells); |
1207 | if (mAllDayMode) { | 1226 | if (mAllDayMode) { |
1208 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1227 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1209 | } else { | 1228 | } else { |
1210 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1229 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1211 | } | 1230 | } |
1212 | int x,y; | 1231 | int x,y; |
1213 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1232 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1214 | if (mAllDayMode) { | 1233 | if (mAllDayMode) { |
1215 | y += item2->subCell() * newSubCellWidth; | 1234 | y += item2->subCell() * newSubCellWidth; |
1216 | } else { | 1235 | } else { |
1217 | x += item2->subCell() * newSubCellWidth; | 1236 | x += item2->subCell() * newSubCellWidth; |
1218 | } | 1237 | } |
1219 | moveChild(item2,x,y); | 1238 | moveChild(item2,x,y); |
1220 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1239 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1221 | } | 1240 | } |
1222 | } | 1241 | } |
1223 | } | 1242 | } |
1224 | } | 1243 | } |
1225 | } else { | 1244 | } else { |
1226 | placeItem->setSubCell(0); | 1245 | placeItem->setSubCell(0); |
1227 | placeItem->setSubCells(1); | 1246 | placeItem->setSubCells(1); |
1228 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1247 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1229 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1248 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1230 | int x,y; | 1249 | int x,y; |
1231 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1250 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1232 | moveChild(placeItem,x,y); | 1251 | moveChild(placeItem,x,y); |
1233 | } | 1252 | } |
1234 | placeItem->setConflictItems(conflictItems); | 1253 | placeItem->setConflictItems(conflictItems); |
1235 | // for ( item=conflictItems.first(); item != 0; | 1254 | // for ( item=conflictItems.first(); item != 0; |
1236 | // item=conflictItems.next() ) { | 1255 | // item=conflictItems.next() ) { |
1237 | // //item->updateItem(); | 1256 | // //item->updateItem(); |
1238 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1257 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1239 | // } | 1258 | // } |
1240 | // placeItem->updateItem(); | 1259 | // placeItem->updateItem(); |
1241 | } | 1260 | } |
1242 | 1261 | ||
1243 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1262 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1244 | { | 1263 | { |
1245 | if ( globalFlagBlockAgenda ) | 1264 | if ( globalFlagBlockAgenda ) |
1246 | return; | 1265 | return; |
1266 | |||
1267 | if ( mInvalidPixmap ) { | ||
1268 | mInvalidPixmap = false; | ||
1269 | qDebug("InvalidPixmap "); | ||
1270 | QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() )); | ||
1271 | return; | ||
1272 | } | ||
1247 | if ( ! mAllDayMode ) { | 1273 | if ( ! mAllDayMode ) { |
1248 | // currently not working for | 1274 | // currently not working for |
1249 | 1275 | ||
1250 | //qDebug("KOAgenda::drawContents "); | 1276 | //qDebug("KOAgenda::drawContents "); |
1251 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1277 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1252 | ;//drawContentsToPainter(); | 1278 | ;//drawContentsToPainter(); |
1253 | 1279 | ||
1254 | QPaintDevice* pd = p->device(); | 1280 | QPaintDevice* pd = p->device(); |
1255 | p->end(); | 1281 | p->end(); |
1256 | int vx, vy; | 1282 | int vx, vy; |
1257 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1283 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1258 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1284 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1259 | mSelectionCellX * mGridSpacingX; | 1285 | mSelectionCellX * mGridSpacingX; |
1260 | contentsToViewport ( cx, cy, vx,vy); | 1286 | contentsToViewport ( cx, cy, vx,vy); |
1261 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1287 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1262 | 1288 | ||
1263 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1289 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1264 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1290 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1265 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1291 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1266 | 1292 | ||
1267 | int vxSel, vySel; | 1293 | int vxSel, vySel; |
1268 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1294 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1269 | int off = mSelectionHeight; | 1295 | int off = mSelectionHeight; |
1270 | if ( vySel < 0 ) | 1296 | if ( vySel < 0 ) |
1271 | off += vySel; | 1297 | off += vySel; |
1272 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1298 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1273 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1299 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1274 | } else { | 1300 | } else { |
1275 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1301 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1276 | } | 1302 | } |
1277 | } | 1303 | } |
1278 | if ( mSelectionHeight > 0 ) { | 1304 | if ( mSelectionHeight > 0 ) { |
1279 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1305 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1280 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1306 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1281 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1307 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1282 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1308 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1283 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1309 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1284 | int hei = mSelectionHeight; | 1310 | int hei = mSelectionHeight; |
1285 | int offset = 0; | 1311 | int offset = 0; |
1286 | while ( hei > 0 ) { | 1312 | while ( hei > 0 ) { |
1287 | int p_hei = 5; | 1313 | int p_hei = 5; |
1288 | if ( hei < 5 ) p_hei = hei; | 1314 | if ( hei < 5 ) p_hei = hei; |
1289 | hei -= 5; | 1315 | hei -= 5; |
1290 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1316 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1291 | offset += 5; | 1317 | offset += 5; |
1292 | } | 1318 | } |
1293 | } | 1319 | } |
1294 | } | 1320 | } |
1295 | p->begin( pd ); | 1321 | p->begin( pd ); |
1296 | } else { | 1322 | } else { |
1297 | 1323 | ||
1298 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1324 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1299 | ;//drawContentsToPainter(); | 1325 | ;//drawContentsToPainter(); |
1300 | 1326 | ||
1301 | QPaintDevice* pd = p->device(); | 1327 | QPaintDevice* pd = p->device(); |
1302 | p->end(); | 1328 | p->end(); |
1303 | int vx, vy; | 1329 | int vx, vy; |
1304 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1330 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1305 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1331 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1306 | mSelectionCellX * mGridSpacingX; | 1332 | mSelectionCellX * mGridSpacingX; |
1307 | contentsToViewport ( cx, cy, vx,vy); | 1333 | contentsToViewport ( cx, cy, vx,vy); |
1308 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1334 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1309 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1335 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1310 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1336 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1311 | 1337 | ||
1312 | if ( mSelectionHeight > 0 ) { | 1338 | if ( mSelectionHeight > 0 ) { |
1313 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1339 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1314 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1340 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1315 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1341 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1316 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1342 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1317 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1343 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1318 | int hei = mSelectionHeight; | 1344 | int hei = mSelectionHeight; |
1319 | int offset = 0; | 1345 | int offset = 0; |
1320 | while ( hei > 0 ) { | 1346 | while ( hei > 0 ) { |
1321 | int p_hei = 5; | 1347 | int p_hei = 5; |
1322 | if ( hei < 5 ) p_hei = hei; | 1348 | if ( hei < 5 ) p_hei = hei; |
1323 | hei -= 5; | 1349 | hei -= 5; |
1324 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1350 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1325 | offset += 5; | 1351 | offset += 5; |
1326 | } | 1352 | } |
1327 | } | 1353 | } |
1328 | } | 1354 | } |
1329 | p->begin( pd ); | 1355 | p->begin( pd ); |
1330 | } | 1356 | } |
1331 | 1357 | ||
1332 | } | 1358 | } |
1333 | 1359 | ||
1334 | void KOAgenda::finishUpdate() | 1360 | void KOAgenda::finishUpdate() |
1335 | { | 1361 | { |
1336 | 1362 | ||
1337 | KOAgendaItem *item; | 1363 | KOAgendaItem *item; |
1338 | globalFlagBlockAgendaItemPaint = 1; | 1364 | globalFlagBlockAgendaItemPaint = 1; |
1339 | // 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 | 1365 | // 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 |
1340 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1366 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1341 | if ( !item->checkLayout() ) { | 1367 | if ( !item->checkLayout() ) { |
1342 | //qDebug(" conflictitem found "); | 1368 | //qDebug(" conflictitem found "); |
@@ -1823,199 +1849,199 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | |||
1823 | while (current) { | 1849 | while (current) { |
1824 | next = multiItems.next(); | 1850 | next = multiItems.next(); |
1825 | if (current == first) setFirst = 0; | 1851 | if (current == first) setFirst = 0; |
1826 | else setFirst = first; | 1852 | else setFirst = first; |
1827 | if (current == last) setLast = 0; | 1853 | if (current == last) setLast = 0; |
1828 | else setLast = last; | 1854 | else setLast = last; |
1829 | 1855 | ||
1830 | current->setMultiItem(setFirst,next,setLast); | 1856 | current->setMultiItem(setFirst,next,setLast); |
1831 | current = next; | 1857 | current = next; |
1832 | } | 1858 | } |
1833 | 1859 | ||
1834 | marcus_bains(); | 1860 | marcus_bains(); |
1835 | } | 1861 | } |
1836 | 1862 | ||
1837 | 1863 | ||
1838 | //QSizePolicy KOAgenda::sizePolicy() const | 1864 | //QSizePolicy KOAgenda::sizePolicy() const |
1839 | //{ | 1865 | //{ |
1840 | // Thought this would make the all-day event agenda minimum size and the | 1866 | // Thought this would make the all-day event agenda minimum size and the |
1841 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1867 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1842 | // don´t seem to think that an Expanding widget needs more space than a | 1868 | // don´t seem to think that an Expanding widget needs more space than a |
1843 | // Preferred one. | 1869 | // Preferred one. |
1844 | // But it doesn´t hurt, so it stays. | 1870 | // But it doesn´t hurt, so it stays. |
1845 | // if (mAllDayMode) { | 1871 | // if (mAllDayMode) { |
1846 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1872 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1847 | // } else { | 1873 | // } else { |
1848 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1874 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1849 | // } | 1875 | // } |
1850 | //} | 1876 | //} |
1851 | void KOAgenda::finishResize ( ) | 1877 | void KOAgenda::finishResize ( ) |
1852 | { | 1878 | { |
1853 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1879 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1854 | if ( globalFlagBlockAgenda == 0 ) { | 1880 | if ( globalFlagBlockAgenda == 0 ) { |
1855 | finishUpdate(); | 1881 | finishUpdate(); |
1856 | //qDebug("finishUpdate() called "); | 1882 | //qDebug("finishUpdate() called "); |
1857 | } | 1883 | } |
1858 | } | 1884 | } |
1859 | /* | 1885 | /* |
1860 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1886 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1861 | */ | 1887 | */ |
1862 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1888 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1863 | { | 1889 | { |
1864 | mSelectionHeight = 0; | 1890 | mSelectionHeight = 0; |
1865 | mResizeTimer.start( 150 , true ); | 1891 | mResizeTimer.start( 150 , true ); |
1866 | computeSizes(); | 1892 | computeSizes(); |
1867 | return; | 1893 | return; |
1868 | 1894 | ||
1869 | } | 1895 | } |
1870 | void KOAgenda::computeSizes() | 1896 | void KOAgenda::computeSizes() |
1871 | { | 1897 | { |
1872 | if ( globalFlagBlockStartup ) | 1898 | if ( globalFlagBlockStartup ) |
1873 | return; | 1899 | return; |
1874 | int frameOffset = frameWidth() * 2 +1; | 1900 | int frameOffset = frameWidth() * 2 +1; |
1875 | if (mAllDayMode) { | 1901 | if (mAllDayMode) { |
1876 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1902 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1877 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1903 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1878 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1904 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1879 | // mGridSpacingY = height(); | 1905 | // mGridSpacingY = height(); |
1880 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1906 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1881 | 1907 | ||
1882 | KOAgendaItem *item; | 1908 | KOAgendaItem *item; |
1883 | int subCellWidth; | 1909 | int subCellWidth; |
1884 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1910 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1885 | subCellWidth = mGridSpacingY / item->subCells(); | 1911 | subCellWidth = mGridSpacingY / item->subCells(); |
1886 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1912 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1887 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1913 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1888 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1914 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1889 | item->cellX() * mGridSpacingX, | 1915 | item->cellX() * mGridSpacingX, |
1890 | item->subCell() * subCellWidth); | 1916 | item->subCell() * subCellWidth); |
1891 | } | 1917 | } |
1892 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1918 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1893 | } else { | 1919 | } else { |
1894 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1920 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1895 | if (height() > mGridSpacingY * mRows + 1 ) { | 1921 | if (height() > mGridSpacingY * mRows + 1 ) { |
1896 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1922 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1897 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1923 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1898 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1924 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1899 | emit resizedSignal(); | 1925 | emit resizedSignal(); |
1900 | } else | 1926 | } else |
1901 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1927 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1902 | KOAgendaItem *item; | 1928 | KOAgendaItem *item; |
1903 | int subCellWidth; | 1929 | int subCellWidth; |
1904 | 1930 | ||
1905 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1931 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1906 | subCellWidth = mGridSpacingX / item->subCells(); | 1932 | subCellWidth = mGridSpacingX / item->subCells(); |
1907 | item->resize(subCellWidth,item->height()); | 1933 | item->resize(subCellWidth,item->height()); |
1908 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1934 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1909 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1935 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1910 | item->cellX() * mGridSpacingX) + | 1936 | item->cellX() * mGridSpacingX) + |
1911 | item->subCell() * subCellWidth,childY(item)); | 1937 | item->subCell() * subCellWidth,childY(item)); |
1912 | } | 1938 | } |
1913 | } | 1939 | } |
1914 | int cw = contentsWidth(); | 1940 | int cw = contentsWidth(); |
1915 | int ch = contentsHeight(); | 1941 | int ch = contentsHeight(); |
1916 | if ( mAllDayMode ) { | 1942 | if ( mAllDayMode ) { |
1917 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1943 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1918 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1944 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1919 | //qDebug("paintPixAll->resize "); | 1945 | qDebug("paintPixAll->resize "); |
1920 | paintPixAll->resize( cw, ch ); | 1946 | paintPixAll->resize( cw, ch ); |
1921 | } | 1947 | } |
1922 | } else { | 1948 | } else { |
1923 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1949 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1924 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1950 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1925 | //qDebug("paintPix->resize "); | 1951 | qDebug("paintPix->resize "); |
1926 | paintPix->resize( cw , ch ); | 1952 | paintPix->resize( cw , ch ); |
1927 | } | 1953 | } |
1928 | } | 1954 | } |
1929 | 1955 | ||
1930 | checkScrollBoundaries(); | 1956 | checkScrollBoundaries(); |
1931 | marcus_bains(); | 1957 | marcus_bains(); |
1932 | drawContentsToPainter(); | 1958 | drawContentsToPainter(); |
1933 | viewport()->repaint(false); | 1959 | viewport()->repaint(false); |
1934 | } | 1960 | } |
1935 | 1961 | ||
1936 | void KOAgenda::scrollUp() | 1962 | void KOAgenda::scrollUp() |
1937 | { | 1963 | { |
1938 | scrollBy(0,-mScrollOffset); | 1964 | scrollBy(0,-mScrollOffset); |
1939 | } | 1965 | } |
1940 | 1966 | ||
1941 | 1967 | ||
1942 | void KOAgenda::scrollDown() | 1968 | void KOAgenda::scrollDown() |
1943 | { | 1969 | { |
1944 | scrollBy(0,mScrollOffset); | 1970 | scrollBy(0,mScrollOffset); |
1945 | } | 1971 | } |
1946 | 1972 | ||
1947 | void KOAgenda::popupAlarm() | 1973 | void KOAgenda::popupAlarm() |
1948 | { | 1974 | { |
1949 | if (!mClickedItem) { | 1975 | if (!mClickedItem) { |
1950 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1976 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1951 | return; | 1977 | return; |
1952 | } | 1978 | } |
1953 | // TODO: deal correctly with multiple alarms | 1979 | // TODO: deal correctly with multiple alarms |
1954 | Alarm* alarm; | 1980 | Alarm* alarm; |
1955 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1981 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1956 | for(alarm=list.first();alarm;alarm=list.next()) { | 1982 | for(alarm=list.first();alarm;alarm=list.next()) { |
1957 | alarm->toggleAlarm(); | 1983 | alarm->toggleAlarm(); |
1958 | } | 1984 | } |
1959 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1985 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1960 | mClickedItem->paintMe( true ); | 1986 | mClickedItem->paintMe( true ); |
1961 | mClickedItem->repaint( false ); | 1987 | mClickedItem->repaint( false ); |
1962 | } | 1988 | } |
1963 | 1989 | ||
1964 | /* | 1990 | /* |
1965 | Calculates the minimum width | 1991 | Calculates the minimum width |
1966 | */ | 1992 | */ |
1967 | int KOAgenda::minimumWidth() const | 1993 | int KOAgenda::minimumWidth() const |
1968 | { | 1994 | { |
1969 | // TODO:: develop a way to dynamically determine the minimum width | 1995 | // TODO:: develop a way to dynamically determine the minimum width |
1970 | int min = 100; | 1996 | int min = 100; |
1971 | 1997 | ||
1972 | return min; | 1998 | return min; |
1973 | } | 1999 | } |
1974 | 2000 | ||
1975 | void KOAgenda::updateConfig() | 2001 | void KOAgenda::updateConfig() |
1976 | { | 2002 | { |
1977 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2003 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1978 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2004 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1979 | if ( mAllDayMode ) { | 2005 | if ( mAllDayMode ) { |
1980 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2006 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1981 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2007 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1982 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2008 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1983 | // setMaximumHeight( mGridSpacingY+1 ); | 2009 | // setMaximumHeight( mGridSpacingY+1 ); |
1984 | viewport()->repaint( false ); | 2010 | viewport()->repaint( false ); |
1985 | //setFixedHeight( mGridSpacingY+1 ); | 2011 | //setFixedHeight( mGridSpacingY+1 ); |
1986 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2012 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1987 | } | 2013 | } |
1988 | else { | 2014 | else { |
1989 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2015 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1990 | calculateWorkingHours(); | 2016 | calculateWorkingHours(); |
1991 | marcus_bains(); | 2017 | marcus_bains(); |
1992 | } | 2018 | } |
1993 | } | 2019 | } |
1994 | 2020 | ||
1995 | void KOAgenda::checkScrollBoundaries() | 2021 | void KOAgenda::checkScrollBoundaries() |
1996 | { | 2022 | { |
1997 | // Invalidate old values to force update | 2023 | // Invalidate old values to force update |
1998 | mOldLowerScrollValue = -1; | 2024 | mOldLowerScrollValue = -1; |
1999 | mOldUpperScrollValue = -1; | 2025 | mOldUpperScrollValue = -1; |
2000 | 2026 | ||
2001 | checkScrollBoundaries(verticalScrollBar()->value()); | 2027 | checkScrollBoundaries(verticalScrollBar()->value()); |
2002 | } | 2028 | } |
2003 | 2029 | ||
2004 | void KOAgenda::checkScrollBoundaries(int v) | 2030 | void KOAgenda::checkScrollBoundaries(int v) |
2005 | { | 2031 | { |
2006 | if ( mGridSpacingY == 0 ) | 2032 | if ( mGridSpacingY == 0 ) |
2007 | return; | 2033 | return; |
2008 | int yMin = v/mGridSpacingY; | 2034 | int yMin = v/mGridSpacingY; |
2009 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2035 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2010 | 2036 | ||
2011 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2037 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2012 | 2038 | ||
2013 | if (yMin != mOldLowerScrollValue) { | 2039 | if (yMin != mOldLowerScrollValue) { |
2014 | mOldLowerScrollValue = yMin; | 2040 | mOldLowerScrollValue = yMin; |
2015 | emit lowerYChanged(yMin); | 2041 | emit lowerYChanged(yMin); |
2016 | } | 2042 | } |
2017 | if (yMax != mOldUpperScrollValue) { | 2043 | if (yMax != mOldUpperScrollValue) { |
2018 | mOldUpperScrollValue = yMax; | 2044 | mOldUpperScrollValue = yMax; |
2019 | emit upperYChanged(yMax); | 2045 | emit upperYChanged(yMax); |
2020 | } | 2046 | } |
2021 | } | 2047 | } |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index de6acac..5d813b2 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -1,268 +1,272 @@ | |||
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 | 51 | ||
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 | static bool mInvalidPixmap; | ||
78 | 79 | ||
79 | Incidence *selectedIncidence() const; | 80 | Incidence *selectedIncidence() const; |
80 | QDate selectedIncidenceDate() const; | 81 | QDate selectedIncidenceDate() const; |
81 | 82 | ||
82 | virtual bool eventFilter ( QObject *, QEvent * ); | 83 | virtual bool eventFilter ( QObject *, QEvent * ); |
83 | 84 | ||
84 | void contentsToGrid (int x, int y, int& gx, int& gy); | 85 | void contentsToGrid (int x, int y, int& gx, int& gy); |
85 | void gridToContents (int gx, int gy, int& x, int& y); | 86 | void gridToContents (int gx, int gy, int& x, int& y); |
86 | 87 | ||
87 | int timeToY (const QTime &time); | 88 | int timeToY (const QTime &time); |
88 | QTime gyToTime (int y); | 89 | QTime gyToTime (int y); |
89 | 90 | ||
90 | void setStartHour(int startHour); | 91 | void setStartHour(int startHour); |
91 | 92 | ||
92 | 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); |
93 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | 94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); |
94 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
95 | int YTop,int YBottom); | 96 | int YTop,int YBottom); |
96 | 97 | ||
97 | void changeColumns(int columns); | 98 | void changeColumns(int columns); |
98 | 99 | ||
99 | int columns() { return mColumns; } | 100 | int columns() { return mColumns; } |
100 | int rows() { return mRows; } | 101 | int rows() { return mRows; } |
101 | 102 | ||
102 | int gridSpacingX() const { return mGridSpacingX; } | 103 | int gridSpacingX() const { return mGridSpacingX; } |
103 | int gridSpacingY() const { return mGridSpacingY; } | 104 | int gridSpacingY() const { return mGridSpacingY; } |
104 | 105 | ||
105 | // virtual QSizePolicy sizePolicy() const; | 106 | // virtual QSizePolicy sizePolicy() const; |
106 | 107 | ||
107 | void clear(); | 108 | void clear(); |
108 | 109 | ||
109 | void clearSelection(); | 110 | void clearSelection(); |
110 | void hideUnused(); | 111 | void hideUnused(); |
111 | 112 | ||
112 | /** Calculates the minimum width */ | 113 | /** Calculates the minimum width */ |
113 | virtual int minimumWidth() const; | 114 | virtual int minimumWidth() const; |
114 | /** Update configuration from preference settings */ | 115 | /** Update configuration from preference settings */ |
115 | void updateConfig(); | 116 | void updateConfig(); |
116 | 117 | ||
117 | void checkScrollBoundaries(); | 118 | void checkScrollBoundaries(); |
118 | 119 | ||
119 | void setHolidayMask(QMemArray<bool> *); | 120 | void setHolidayMask(QMemArray<bool> *); |
120 | void setDateList(const DateList &selectedDates); | 121 | void setDateList(const DateList &selectedDates); |
121 | DateList dateList() const; | 122 | DateList dateList() const; |
122 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | 123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); |
123 | void finishUpdate(); | 124 | void finishUpdate(); |
124 | void printSelection(); | 125 | void printSelection(); |
125 | void storePosition(); | 126 | void storePosition(); |
126 | void restorePosition(); | 127 | void restorePosition(); |
127 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } | 128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } |
129 | void shrinkPixmap(); | ||
128 | 130 | ||
129 | public slots: | 131 | public slots: |
132 | void slotContentMove(int,int); | ||
130 | void categoryChanged(Incidence * inc); | 133 | void categoryChanged(Incidence * inc); |
131 | void slotClearSelection(); | 134 | void slotClearSelection(); |
132 | void popupMenu(); | 135 | void popupMenu(); |
133 | void newItem( int ); | 136 | void newItem( int ); |
134 | void moveChild( QWidget *, int, int ); | 137 | void moveChild( QWidget *, int, int ); |
135 | void scrollUp(); | 138 | void scrollUp(); |
136 | void scrollDown(); | 139 | void scrollDown(); |
137 | void updateTodo( Todo * t, int , bool ); | 140 | void updateTodo( Todo * t, int , bool ); |
138 | void popupAlarm(); | 141 | void popupAlarm(); |
139 | 142 | ||
140 | void checkScrollBoundaries(int); | 143 | void checkScrollBoundaries(int); |
141 | 144 | ||
142 | /** Deselect selected items. This function does not emit any signals. */ | 145 | /** Deselect selected items. This function does not emit any signals. */ |
143 | void deselectItem(); | 146 | void deselectItem(); |
144 | /** Select item. If the argument is 0, the currently selected item gets | 147 | /** Select item. If the argument is 0, the currently selected item gets |
145 | deselected. This function emits the itemSelected(bool) signal to inform | 148 | deselected. This function emits the itemSelected(bool) signal to inform |
146 | about selection/deseelction of events. */ | 149 | about selection/deseelction of events. */ |
147 | void selectItem(KOAgendaItem *); | 150 | void selectItem(KOAgendaItem *); |
148 | void finishResize(); | 151 | void finishResize(); |
149 | 152 | ||
150 | signals: | 153 | signals: |
151 | void signalClearSelection(); | 154 | void signalClearSelection(); |
152 | void showDateView( int, int); | 155 | void showDateView( int, int); |
153 | void newEventSignal(); | 156 | void newEventSignal(); |
154 | void newEventSignal(int gx,int gy); | 157 | void newEventSignal(int gx,int gy); |
155 | void newTodoSignal(int gx,int gy); | 158 | void newTodoSignal(int gx,int gy); |
156 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 159 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
157 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 160 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
158 | void newStartSelectSignal(); | 161 | void newStartSelectSignal(); |
159 | void showIncidenceSignal(Incidence *); | 162 | void showIncidenceSignal(Incidence *); |
160 | void editIncidenceSignal(Incidence *); | 163 | void editIncidenceSignal(Incidence *); |
161 | void deleteIncidenceSignal(Incidence *); | 164 | void deleteIncidenceSignal(Incidence *); |
162 | void showIncidencePopupSignal(Incidence *); | 165 | void showIncidencePopupSignal(Incidence *); |
163 | 166 | ||
164 | void itemModified(KOAgendaItem *item, int ); | 167 | void itemModified(KOAgendaItem *item, int ); |
165 | void incidenceSelected(Incidence *); | 168 | void incidenceSelected(Incidence *); |
166 | 169 | ||
167 | void lowerYChanged(int); | 170 | void lowerYChanged(int); |
168 | void upperYChanged(int); | 171 | void upperYChanged(int); |
169 | 172 | ||
170 | void startDragSignal(Incidence *); | 173 | void startDragSignal(Incidence *); |
171 | void addToCalSignal(Incidence *, Incidence *); | 174 | void addToCalSignal(Incidence *, Incidence *); |
172 | void resizedSignal(); | 175 | void resizedSignal(); |
176 | void updateViewSignal(); | ||
173 | 177 | ||
174 | protected: | 178 | protected: |
175 | KOEventPopupMenu * mAllAgendaPopup; | 179 | KOEventPopupMenu * mAllAgendaPopup; |
176 | QPainter mPixPainter; | 180 | QPainter mPixPainter; |
177 | QPixmap mPaintPixmap; | 181 | QPixmap mPaintPixmap; |
178 | QPixmap mHighlightPixmap; | 182 | QPixmap mHighlightPixmap; |
179 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 183 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
180 | virtual void resizeEvent ( QResizeEvent * ); | 184 | virtual void resizeEvent ( QResizeEvent * ); |
181 | 185 | ||
182 | /** Handles mouse events. Called from eventFilter */ | 186 | /** Handles mouse events. Called from eventFilter */ |
183 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | 187 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); |
184 | 188 | ||
185 | /** Start selecting time span. */ | 189 | /** Start selecting time span. */ |
186 | void startSelectAction(QPoint viewportPos); | 190 | void startSelectAction(QPoint viewportPos); |
187 | 191 | ||
188 | /** Select time span. */ | 192 | /** Select time span. */ |
189 | void performSelectAction(QPoint viewportPos); | 193 | void performSelectAction(QPoint viewportPos); |
190 | 194 | ||
191 | /** Emd selecting time span. */ | 195 | /** Emd selecting time span. */ |
192 | void endSelectAction( bool emitNewEvent = false ); | 196 | void endSelectAction( bool emitNewEvent = false ); |
193 | 197 | ||
194 | /** Start moving/resizing agenda item */ | 198 | /** Start moving/resizing agenda item */ |
195 | void startItemAction(QPoint viewportPos); | 199 | void startItemAction(QPoint viewportPos); |
196 | 200 | ||
197 | /** Move/resize agenda item */ | 201 | /** Move/resize agenda item */ |
198 | void performItemAction(QPoint viewportPos); | 202 | void performItemAction(QPoint viewportPos); |
199 | 203 | ||
200 | /** End moving/resizing agenda item */ | 204 | /** End moving/resizing agenda item */ |
201 | void endItemAction(); | 205 | void endItemAction(); |
202 | 206 | ||
203 | /** Set cursor, when no item action is in progress */ | 207 | /** Set cursor, when no item action is in progress */ |
204 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | 208 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); |
205 | 209 | ||
206 | /** Place agenda item in agenda and adjust other cells if necessary */ | 210 | /** Place agenda item in agenda and adjust other cells if necessary */ |
207 | void placeSubCells(KOAgendaItem *placeItem); | 211 | void placeSubCells(KOAgendaItem *placeItem); |
208 | 212 | ||
209 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | 213 | /** Process the keyevent, including the ignored keyevents of eventwidgets. |
210 | * Implements pgup/pgdn and cursor key navigation in the view. | 214 | * Implements pgup/pgdn and cursor key navigation in the view. |
211 | */ | 215 | */ |
212 | void keyPressEvent( QKeyEvent * ); | 216 | void keyPressEvent( QKeyEvent * ); |
213 | 217 | ||
214 | void calculateWorkingHours(); | 218 | void calculateWorkingHours(); |
215 | 219 | ||
216 | virtual void contentsMousePressEvent ( QMouseEvent * ); | 220 | virtual void contentsMousePressEvent ( QMouseEvent * ); |
217 | 221 | ||
218 | private: | 222 | private: |
219 | void init(); | 223 | void init(); |
220 | void marcus_bains(); | 224 | void marcus_bains(); |
221 | bool mAllDayMode; | 225 | bool mAllDayMode; |
222 | bool blockResize; | 226 | bool blockResize; |
223 | bool mLeftMouseDown; | 227 | bool mLeftMouseDown; |
224 | KOAgendaItem *mPopupItem; | 228 | KOAgendaItem *mPopupItem; |
225 | QTimer* mPopupTimer; | 229 | QTimer* mPopupTimer; |
226 | int mPopupKind; | 230 | int mPopupKind; |
227 | QPoint mPopupPos; | 231 | QPoint mPopupPos; |
228 | QTimer mResizeTimer; | 232 | QTimer mResizeTimer; |
229 | double mContentPosition; | 233 | double mContentPosition; |
230 | 234 | ||
231 | // Width and height of agenda cells | 235 | // Width and height of agenda cells |
232 | int mGridSpacingX; | 236 | int mGridSpacingX; |
233 | int mGridSpacingY; | 237 | int mGridSpacingY; |
234 | 238 | ||
235 | // size of border, where mouse action will resize the KOAgendaItem | 239 | // size of border, where mouse action will resize the KOAgendaItem |
236 | int mResizeBorderWidth; | 240 | int mResizeBorderWidth; |
237 | 241 | ||
238 | // size of border, where mouse mve will cause a scroll of the agenda | 242 | // size of border, where mouse mve will cause a scroll of the agenda |
239 | int mScrollBorderWidth; | 243 | int mScrollBorderWidth; |
240 | int mScrollDelay; | 244 | int mScrollDelay; |
241 | int mScrollOffset; | 245 | int mScrollOffset; |
242 | 246 | ||
243 | QTimer mScrollUpTimer; | 247 | QTimer mScrollUpTimer; |
244 | QTimer mScrollDownTimer; | 248 | QTimer mScrollDownTimer; |
245 | 249 | ||
246 | // Number of Columns/Rows of agenda grid | 250 | // Number of Columns/Rows of agenda grid |
247 | int mColumns; | 251 | int mColumns; |
248 | int mRows; | 252 | int mRows; |
249 | 253 | ||
250 | // Cells to store Move and Resize coordiantes | 254 | // Cells to store Move and Resize coordiantes |
251 | int mStartCellX; | 255 | int mStartCellX; |
252 | int mStartCellY; | 256 | int mStartCellY; |
253 | int mCurrentCellX; | 257 | int mCurrentCellX; |
254 | int mCurrentCellY; | 258 | int mCurrentCellY; |
255 | 259 | ||
256 | // Working Hour coordiantes | 260 | // Working Hour coordiantes |
257 | bool mWorkingHoursEnable; | 261 | bool mWorkingHoursEnable; |
258 | int mWorkingHoursYTop; | 262 | int mWorkingHoursYTop; |
259 | int mWorkingHoursYBottom; | 263 | int mWorkingHoursYBottom; |
260 | 264 | ||
261 | // Selection | 265 | // Selection |
262 | int mSelectionCellX; | 266 | int mSelectionCellX; |
263 | int mSelectionYTop; | 267 | int mSelectionYTop; |
264 | int mSelectionHeight; | 268 | int mSelectionHeight; |
265 | 269 | ||
266 | // List of dates to be displayed | 270 | // List of dates to be displayed |
267 | DateList mSelectedDates; | 271 | DateList mSelectedDates; |
268 | 272 | ||
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 8675ff6..303a92a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -403,204 +403,201 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | |||
403 | if ( ! small || w > 3 * h || h > 3* w ) | 403 | if ( ! small || w > 3 * h || h > 3* w ) |
404 | addIcon = updateIcons( paint, horLayout ); | 404 | addIcon = updateIcons( paint, horLayout ); |
405 | 405 | ||
406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); | 407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); |
408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
409 | if ( ! small ) { | 409 | if ( ! small ) { |
410 | x += 3; yy += 3;w -= 6; h-= 5; | 410 | x += 3; yy += 3;w -= 6; h-= 5; |
411 | } else { | 411 | } else { |
412 | x += 2; yy += 1;w -= 4; h-= 4; | 412 | x += 2; yy += 1;w -= 4; h-= 4; |
413 | if ( nfh < 6.01 ) { | 413 | if ( nfh < 6.01 ) { |
414 | yy -= 2; | 414 | yy -= 2; |
415 | h += 4; | 415 | h += 4; |
416 | } | 416 | } |
417 | else | 417 | else |
418 | if ( nfh < h -2 ) | 418 | if ( nfh < h -2 ) |
419 | ++yy; | 419 | ++yy; |
420 | } | 420 | } |
421 | int align; | 421 | int align; |
422 | #ifndef DESKTOP_VERSION | 422 | #ifndef DESKTOP_VERSION |
423 | align = ( AlignLeft|WordBreak|AlignTop); | 423 | align = ( AlignLeft|WordBreak|AlignTop); |
424 | #else | 424 | #else |
425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
426 | #endif | 426 | #endif |
427 | if ( addIcon ) { | 427 | if ( addIcon ) { |
428 | if ( ! horLayout ) { | 428 | if ( ! horLayout ) { |
429 | x += AGENDA_ICON_SIZE+3; | 429 | x += AGENDA_ICON_SIZE+3; |
430 | w -= (AGENDA_ICON_SIZE+3); | 430 | w -= (AGENDA_ICON_SIZE+3); |
431 | } | 431 | } |
432 | else { | 432 | else { |
433 | yy+= AGENDA_ICON_SIZE+2; | 433 | yy+= AGENDA_ICON_SIZE+2; |
434 | h -=(AGENDA_ICON_SIZE+3); | 434 | h -=(AGENDA_ICON_SIZE+3); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | if ( mWhiteText ) | 437 | if ( mWhiteText ) |
438 | paint->setPen ( white); | 438 | paint->setPen ( white); |
439 | if ( x < 0 ) { | 439 | if ( x < 0 ) { |
440 | w = w+x-3; | 440 | w = w+x-3; |
441 | x = 3; | 441 | x = 3; |
442 | if ( !horLayout && addIcon ) | 442 | if ( !horLayout && addIcon ) |
443 | x += AGENDA_ICON_SIZE+3; | 443 | x += AGENDA_ICON_SIZE+3; |
444 | if ( w > parentWidget()->width() ){ | 444 | if ( w > parentWidget()->width() ){ |
445 | w = parentWidget()->width() - 6; | 445 | w = parentWidget()->width() - 6; |
446 | #ifndef DESKTOP_VERSION | 446 | #ifndef DESKTOP_VERSION |
447 | align = ( AlignHCenter|WordBreak|AlignTop); | 447 | align = ( AlignHCenter|WordBreak|AlignTop); |
448 | #else | 448 | #else |
449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
450 | #endif | 450 | #endif |
451 | 451 | ||
452 | } | 452 | } |
453 | } | 453 | } |
454 | QRect dr; | 454 | QRect dr; |
455 | if ( w + x > parentWidget()->width() ) | 455 | if ( w + x > parentWidget()->width() ) |
456 | w = parentWidget()->width()-x; | 456 | w = parentWidget()->width()-x; |
457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
458 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 458 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
459 | if ( mIncidence->cancelled() ){ | 459 | if ( mIncidence->cancelled() ){ |
460 | 460 | ||
461 | 461 | ||
462 | small = ( height() < 20 ); | 462 | small = ( height() < 20 ); |
463 | 463 | ||
464 | if ( ! small ) { | 464 | if ( ! small ) { |
465 | QFontMetrics fm ( paint->font() ); | 465 | QFontMetrics fm ( paint->font() ); |
466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
467 | } | 467 | } |
468 | 468 | ||
469 | } | 469 | } |
470 | pa.end(); | 470 | pa.end(); |
471 | 471 | ||
472 | } | 472 | } |
473 | 473 | ||
474 | QPixmap * KOAgendaItem::paintPix() | 474 | QPixmap * KOAgendaItem::paintPix() |
475 | { | 475 | { |
476 | static QPixmap* mPaintPix = 0; | 476 | static QPixmap* mPaintPix = 0; |
477 | if ( ! mPaintPix ) { | 477 | if ( ! mPaintPix ) { |
478 | int w = QApplication::desktop()->width(); | 478 | int w = QApplication::desktop()->width(); |
479 | int h = QApplication::desktop()->height(); | 479 | int h = QApplication::desktop()->height(); |
480 | mPaintPix = new QPixmap(w,h); | 480 | mPaintPix = new QPixmap(w,h); |
481 | } | 481 | } |
482 | return mPaintPix ; | 482 | return mPaintPix ; |
483 | } | 483 | } |
484 | QPixmap * KOAgendaItem::paintPixAllday() | 484 | QPixmap * KOAgendaItem::paintPixAllday() |
485 | { | 485 | { |
486 | static QPixmap* mPaintPixA = 0; | 486 | static QPixmap* mPaintPixA = 0; |
487 | if ( ! mPaintPixA ) { | 487 | if ( ! mPaintPixA ) { |
488 | int w = QApplication::desktop()->width(); | 488 | int w = QApplication::desktop()->width(); |
489 | int h = QApplication::desktop()->height()/5; | 489 | int h = QApplication::desktop()->height()/5; |
490 | mPaintPixA = new QPixmap(w,h); | 490 | mPaintPixA = new QPixmap(w,h); |
491 | } | 491 | } |
492 | return mPaintPixA ; | 492 | return mPaintPixA ; |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOAgendaItem::repaintItem() | 495 | void KOAgendaItem::repaintItem() |
496 | { | 496 | { |
497 | globalFlagBlockAgendaItemPaint = 0; | 497 | globalFlagBlockAgendaItemPaint = 0; |
498 | globalFlagBlockAgenda = 0; | 498 | globalFlagBlockAgenda = 0; |
499 | //qDebug("AAA "); | ||
500 | repaint( false ); | 499 | repaint( false ); |
501 | //qDebug("BBB "); | ||
502 | } | 500 | } |
503 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
504 | { | 502 | { |
505 | qDebug("CCC "); | 503 | |
506 | if ( globalFlagBlockAgendaItemPaint ) | 504 | if ( globalFlagBlockAgendaItemPaint ) |
507 | return; | 505 | return; |
508 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
509 | return; | 507 | return; |
510 | qDebug("DDD "); | ||
511 | int yy; | 508 | int yy; |
512 | if ( mAllDay ) | 509 | if ( mAllDay ) |
513 | yy = y(); | 510 | yy = y(); |
514 | else | 511 | else |
515 | yy = mCellYTop * ( height() / cellHeight() ); | 512 | yy = mCellYTop * ( height() / cellHeight() ); |
516 | int xx = x(); | 513 | int xx = x(); |
517 | 514 | ||
518 | if ( xPaintCoord != xx || yPaintCoord != yy || | 515 | if ( xPaintCoord != xx || yPaintCoord != yy || |
519 | wPaintCoord != width() || hPaintCoord != height()) { | 516 | wPaintCoord != width() || hPaintCoord != height()) { |
520 | xPaintCoord= xx; | 517 | xPaintCoord= xx; |
521 | yPaintCoord = yy; | 518 | yPaintCoord = yy; |
522 | wPaintCoord = width(); | 519 | wPaintCoord = width(); |
523 | hPaintCoord = height(); | 520 | hPaintCoord = height(); |
524 | globalFlagBlockAgendaItemUpdate = 0; | 521 | globalFlagBlockAgendaItemUpdate = 0; |
525 | paintMe( mSelected ); | 522 | paintMe( mSelected ); |
526 | //qDebug("calling paintMe "); | 523 | //qDebug("calling paintMe "); |
527 | globalFlagBlockAgendaItemUpdate = 1; | 524 | globalFlagBlockAgendaItemUpdate = 1; |
528 | if ( mSelected ) | 525 | if ( mSelected ) |
529 | return; | 526 | return; |
530 | } | 527 | } |
531 | int rx, ry, rw, rh; | 528 | int rx, ry, rw, rh; |
532 | rx = e->rect().x(); | 529 | rx = e->rect().x(); |
533 | ry = e->rect().y(); | 530 | ry = e->rect().y(); |
534 | rw = e->rect().width(); | 531 | rw = e->rect().width(); |
535 | rh = e->rect().height(); | 532 | rh = e->rect().height(); |
536 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
537 | 534 | ||
538 | QPixmap* paintFrom ; | 535 | QPixmap* paintFrom ; |
539 | if ( mSelected ) { | 536 | if ( mSelected ) { |
540 | paintMe( mSelected ); | 537 | paintMe( mSelected ); |
541 | return; | 538 | return; |
542 | } else { | 539 | } else { |
543 | if ( mAllDay ) | 540 | if ( mAllDay ) |
544 | paintFrom = paintPixAllday(); | 541 | paintFrom = paintPixAllday(); |
545 | else | 542 | else |
546 | paintFrom = paintPix(); | 543 | paintFrom = paintPix(); |
547 | } | 544 | } |
548 | xx += rx; | 545 | xx += rx; |
549 | 546 | ||
550 | if ( xx < 0 ) { | 547 | if ( xx < 0 ) { |
551 | rw = rw + xx; | 548 | rw = rw + xx; |
552 | rx -= xx; | 549 | rx -= xx; |
553 | xx = 0; | 550 | xx = 0; |
554 | if ( rw <= 1 ) { | 551 | if ( rw <= 1 ) { |
555 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
556 | return; | 553 | return; |
557 | } | 554 | } |
558 | } | 555 | } |
559 | if ( paintFrom->width() < xx+rw ) { | 556 | if ( paintFrom->width() < xx+rw ) { |
560 | rw = paintFrom->width() - xx; | 557 | rw = paintFrom->width() - xx; |
561 | if ( rw <= 1 ) { | 558 | if ( rw <= 1 ) { |
562 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
563 | return; | 560 | return; |
564 | } | 561 | } |
565 | } | 562 | } |
566 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
567 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
568 | } | 565 | } |
569 | void KOAgendaItem::computeText() | 566 | void KOAgendaItem::computeText() |
570 | { | 567 | { |
571 | mDisplayedText = mIncidence->summary(); | 568 | mDisplayedText = mIncidence->summary(); |
572 | if ( (mIncidence->typeID() == todoID ) ) { | 569 | if ( (mIncidence->typeID() == todoID ) ) { |
573 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
574 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
575 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
576 | else if ( !(mIncidence->doesFloat())) | 573 | else if ( !(mIncidence->doesFloat())) |
577 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
578 | } | 575 | } |
579 | } else { | 576 | } else { |
580 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
581 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
582 | 579 | ||
583 | if ( mAllDay ) { | 580 | if ( mAllDay ) { |
584 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
585 | if ( mIncidence->doesRecur() ) { | 582 | if ( mIncidence->doesRecur() ) { |
586 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
587 | } else { | 584 | } else { |
588 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 585 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
589 | } | 586 | } |
590 | } | 587 | } |
591 | } | 588 | } |
592 | } | 589 | } |
593 | 590 | ||
594 | if ( !mIncidence->location().isEmpty() ) { | 591 | if ( !mIncidence->location().isEmpty() ) { |
595 | if ( mAllDay ) | 592 | if ( mAllDay ) |
596 | mDisplayedText += " ("; | 593 | mDisplayedText += " ("; |
597 | else | 594 | else |
598 | mDisplayedText += "\n("; | 595 | mDisplayedText += "\n("; |
599 | mDisplayedText += mIncidence->location() +")"; | 596 | mDisplayedText += mIncidence->location() +")"; |
600 | } | 597 | } |
601 | #ifdef DESKTOP_VERSION | 598 | #ifdef DESKTOP_VERSION |
602 | QString tipText = mIncidence->summary(); | 599 | QString tipText = mIncidence->summary(); |
603 | if ( !mIncidence->doesFloat() ) { | 600 | if ( !mIncidence->doesFloat() ) { |
604 | if ( mIncidence->typeID() == eventID ) { | 601 | if ( mIncidence->typeID() == eventID ) { |
605 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
606 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f811fba..488d9d4 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,175 +1,175 @@ | |||
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 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | #define IDLETIMEOUT 3 | |
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | myPix.resize( 1, 1 ); | 84 | myPix.resize( 1, 1 ); |
85 | mRows = rows; | 85 | mRows = rows; |
86 | 86 | ||
87 | mRedrawNeeded = true; | 87 | mRedrawNeeded = true; |
88 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
89 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
90 | 90 | ||
91 | enableClipper(true); | 91 | enableClipper(true); |
92 | 92 | ||
93 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
94 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
95 | 95 | ||
96 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
97 | 97 | ||
98 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void TimeLabels::setCellHeight(int height) | 101 | void TimeLabels::setCellHeight(int height) |
102 | { | 102 | { |
103 | mCellHeight = height; | 103 | mCellHeight = height; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | Optimization so that only the "dirty" portion of the scroll view | 107 | Optimization so that only the "dirty" portion of the scroll view |
108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | cx = contentsX() + frameWidth()*2; | 113 | cx = contentsX() + frameWidth()*2; |
114 | cw = contentsWidth() ; | 114 | cw = contentsWidth() ; |
115 | // end of workaround | 115 | // end of workaround |
116 | 116 | ||
117 | int cell = ((int)(cy/mCellHeight)); | 117 | int cell = ((int)(cy/mCellHeight)); |
118 | int y = cell * mCellHeight; | 118 | int y = cell * mCellHeight; |
119 | QFontMetrics fm = fontMetrics(); | 119 | QFontMetrics fm = fontMetrics(); |
120 | QString hour; | 120 | QString hour; |
121 | QString suffix = "am"; | 121 | QString suffix = "am"; |
122 | int timeHeight = fm.ascent(); | 122 | int timeHeight = fm.ascent(); |
123 | QFont nFont = font(); | 123 | QFont nFont = font(); |
124 | p->setFont( font()); | 124 | p->setFont( font()); |
125 | 125 | ||
126 | if (!KGlobal::locale()->use12Clock()) { | 126 | if (!KGlobal::locale()->use12Clock()) { |
127 | suffix = "00"; | 127 | suffix = "00"; |
128 | } else | 128 | } else |
129 | if (cell > 11) suffix = "pm"; | 129 | if (cell > 11) suffix = "pm"; |
130 | 130 | ||
131 | if ( timeHeight > mCellHeight ) { | 131 | if ( timeHeight > mCellHeight ) { |
132 | timeHeight = mCellHeight-1; | 132 | timeHeight = mCellHeight-1; |
133 | int pointS = nFont.pointSize(); | 133 | int pointS = nFont.pointSize(); |
134 | while ( pointS > 4 ) { | 134 | while ( pointS > 4 ) { |
135 | nFont.setPointSize( pointS ); | 135 | nFont.setPointSize( pointS ); |
136 | fm = QFontMetrics( nFont ); | 136 | fm = QFontMetrics( nFont ); |
137 | if ( fm.ascent() < mCellHeight ) | 137 | if ( fm.ascent() < mCellHeight ) |
138 | break; | 138 | break; |
139 | -- pointS; | 139 | -- pointS; |
140 | } | 140 | } |
141 | fm = QFontMetrics( nFont ); | 141 | fm = QFontMetrics( nFont ); |
142 | timeHeight = fm.ascent(); | 142 | timeHeight = fm.ascent(); |
143 | } | 143 | } |
144 | //timeHeight -= (timeHeight/4-2); | 144 | //timeHeight -= (timeHeight/4-2); |
145 | QFont sFont = nFont; | 145 | QFont sFont = nFont; |
146 | sFont.setPointSize( sFont.pointSize()/2 ); | 146 | sFont.setPointSize( sFont.pointSize()/2 ); |
147 | QFontMetrics fmS( sFont ); | 147 | QFontMetrics fmS( sFont ); |
148 | int sHei = fmS.ascent() ; | 148 | int sHei = fmS.ascent() ; |
149 | //sHei -= (sHei/4-2); | 149 | //sHei -= (sHei/4-2); |
150 | int startW = mMiniWidth - frameWidth()-2 ; | 150 | int startW = mMiniWidth - frameWidth()-2 ; |
151 | int tw2 = fmS.width(suffix); | 151 | int tw2 = fmS.width(suffix); |
152 | timeHeight = (timeHeight-1) /2 -1; | 152 | timeHeight = (timeHeight-1) /2 -1; |
153 | //testline | 153 | //testline |
154 | //p->drawLine(0,0,0,contentsHeight()); | 154 | //p->drawLine(0,0,0,contentsHeight()); |
155 | while (y < cy + ch+mCellHeight) { | 155 | while (y < cy + ch+mCellHeight) { |
156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); | 156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); |
157 | hour.setNum(cell); | 157 | hour.setNum(cell); |
158 | // handle 24h and am/pm time formats | 158 | // handle 24h and am/pm time formats |
159 | if (KGlobal::locale()->use12Clock()) { | 159 | if (KGlobal::locale()->use12Clock()) { |
160 | if (cell == 12) suffix = "pm"; | 160 | if (cell == 12) suffix = "pm"; |
161 | if (cell == 0) hour.setNum(12); | 161 | if (cell == 0) hour.setNum(12); |
162 | if (cell > 12) hour.setNum(cell - 12); | 162 | if (cell > 12) hour.setNum(cell - 12); |
163 | } | 163 | } |
164 | 164 | ||
165 | // center and draw the time label | 165 | // center and draw the time label |
166 | int timeWidth = fm.width(hour); | 166 | int timeWidth = fm.width(hour); |
167 | int offset = startW - timeWidth - tw2 -1 ; | 167 | int offset = startW - timeWidth - tw2 -1 ; |
168 | p->setFont( nFont ); | 168 | p->setFont( nFont ); |
169 | p->drawText( offset, y+ timeHeight, hour); | 169 | p->drawText( offset, y+ timeHeight, hour); |
170 | p->setFont( sFont ); | 170 | p->setFont( sFont ); |
171 | offset = startW - tw2; | 171 | offset = startW - tw2; |
172 | p->drawText( offset, y -1, suffix); | 172 | p->drawText( offset, y -1, suffix); |
173 | 173 | ||
174 | // increment indices | 174 | // increment indices |
175 | y += mCellHeight; | 175 | y += mCellHeight; |
@@ -480,195 +480,218 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
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 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); | ||
577 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); | ||
576 | 578 | ||
579 | mIdleTimer = new QTimer ( this );; | ||
580 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); | ||
581 | } | ||
582 | void KOAgendaView::slotIdleTimeout() | ||
583 | { | ||
584 | qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); | ||
585 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); | ||
586 | mIdleTimer->stop(); | ||
587 | bool isActice = topLevelWidget()->isActiveWindow(); | ||
588 | qDebug("KO: Active Window %d ", isActice); | ||
589 | // we do nothing if we wake up from a suspend | ||
590 | if ( secsfromstart > IDLETIMEOUT + 50 && isActice ) { | ||
591 | qDebug("KO: Wakeup from suspend "); | ||
592 | mIdleTimer->start( IDLETIMEOUT * 1000 ); | ||
593 | return; | ||
594 | } | ||
595 | qDebug("KO: Downsizing Pixmaps "); | ||
596 | mAgenda->shrinkPixmap(); | ||
597 | mAllDayAgenda->shrinkPixmap(); | ||
598 | KOAgendaItem::paintPix()->resize( 20,20); | ||
599 | KOAgendaItem::paintPixAllday()->resize( 20,20); | ||
600 | |||
577 | } | 601 | } |
578 | |||
579 | void KOAgendaView::toggleAllDay() | 602 | void KOAgendaView::toggleAllDay() |
580 | { | 603 | { |
581 | if ( mSplitterAgenda->firstHandle() ) | 604 | if ( mSplitterAgenda->firstHandle() ) |
582 | mSplitterAgenda->firstHandle()->toggle(); | 605 | mSplitterAgenda->firstHandle()->toggle(); |
583 | } | 606 | } |
584 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 607 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
585 | { | 608 | { |
586 | calendar()->addIncidence( inc ); | 609 | calendar()->addIncidence( inc ); |
587 | 610 | ||
588 | if ( incOld ) { | 611 | if ( incOld ) { |
589 | if ( incOld->typeID() == todoID ) | 612 | if ( incOld->typeID() == todoID ) |
590 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 613 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
591 | else | 614 | else |
592 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 615 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
593 | } | 616 | } |
594 | 617 | ||
595 | } | 618 | } |
596 | void KOAgendaView::categoryChanged(Incidence * inc) | 619 | void KOAgendaView::categoryChanged(Incidence * inc) |
597 | { | 620 | { |
598 | mAgenda->categoryChanged( inc ); | 621 | mAgenda->categoryChanged( inc ); |
599 | mAllDayAgenda->categoryChanged( inc ); | 622 | mAllDayAgenda->categoryChanged( inc ); |
600 | } | 623 | } |
601 | KOAgendaView::~KOAgendaView() | 624 | KOAgendaView::~KOAgendaView() |
602 | { | 625 | { |
603 | delete mAllAgendaPopup; | 626 | delete mAllAgendaPopup; |
604 | //delete mAllDayAgendaPopup; | 627 | //delete mAllDayAgendaPopup; |
605 | delete KOAgendaItem::paintPix(); | 628 | delete KOAgendaItem::paintPix(); |
606 | delete KOAgendaItem::paintPixAllday(); | 629 | delete KOAgendaItem::paintPixAllday(); |
607 | } | 630 | } |
608 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 631 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
609 | { | 632 | { |
610 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 633 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
611 | bool uc = false; | 634 | bool uc = false; |
612 | int ow = e->oldSize().width(); | 635 | int ow = e->oldSize().width(); |
613 | int oh = e->oldSize().height(); | 636 | int oh = e->oldSize().height(); |
614 | int w = e->size().width(); | 637 | int w = e->size().width(); |
615 | int h = e->size().height(); | 638 | int h = e->size().height(); |
616 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 639 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
617 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 640 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
618 | uc = true; | 641 | uc = true; |
619 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 642 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
620 | } | 643 | } |
621 | mUpcomingWidth = e->size().width() ; | 644 | mUpcomingWidth = e->size().width() ; |
622 | if ( mBlockUpdating || uc ) { | 645 | if ( mBlockUpdating || uc ) { |
623 | mBlockUpdating = false; | 646 | mBlockUpdating = false; |
624 | //mAgenda->setMinimumSize(800 , 600 ); | 647 | //mAgenda->setMinimumSize(800 , 600 ); |
625 | //qDebug("mAgenda->resize+++++++++++++++ "); | 648 | //qDebug("mAgenda->resize+++++++++++++++ "); |
626 | updateConfig(); | 649 | updateConfig(); |
627 | //qDebug("KOAgendaView::Updating now possible "); | 650 | //qDebug("KOAgendaView::Updating now possible "); |
628 | } else | 651 | } else |
629 | createDayLabels(); | 652 | createDayLabels(); |
630 | //qDebug("resizeEvent end "); | 653 | //qDebug("resizeEvent end "); |
631 | 654 | ||
632 | } | 655 | } |
633 | void KOAgendaView::slotDaylabelClicked( int num ) | 656 | void KOAgendaView::slotDaylabelClicked( int num ) |
634 | { | 657 | { |
635 | 658 | ||
636 | QDate firstDate = mSelectedDates.first(); | 659 | QDate firstDate = mSelectedDates.first(); |
637 | if ( num == -1 ) | 660 | if ( num == -1 ) |
638 | emit showDateView( 6, firstDate ); | 661 | emit showDateView( 6, firstDate ); |
639 | else if (num >= 0 ) { | 662 | else if (num >= 0 ) { |
640 | if ( mSelectedDates.count() == 1) | 663 | if ( mSelectedDates.count() == 1) |
641 | emit showDateView( 9, firstDate.addDays( num ) ); | 664 | emit showDateView( 9, firstDate.addDays( num ) ); |
642 | else | 665 | else |
643 | emit showDateView( 3, firstDate.addDays( num ) ); | 666 | emit showDateView( 3, firstDate.addDays( num ) ); |
644 | } | 667 | } |
645 | else | 668 | else |
646 | showDateView( 10, firstDate.addDays(1) ); | 669 | showDateView( 10, firstDate.addDays(1) ); |
647 | } | 670 | } |
648 | 671 | ||
649 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 672 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
650 | { | 673 | { |
651 | 674 | ||
652 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 675 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
653 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 676 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
654 | mDayLabelsList.append( dayLabel ); | 677 | mDayLabelsList.append( dayLabel ); |
655 | mLayoutDayLabels->addWidget(dayLabel); | 678 | mLayoutDayLabels->addWidget(dayLabel); |
656 | return dayLabel ; | 679 | return dayLabel ; |
657 | } | 680 | } |
658 | 681 | ||
659 | void KOAgendaView::createDayLabels() | 682 | void KOAgendaView::createDayLabels() |
660 | { | 683 | { |
661 | 684 | ||
662 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 685 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
663 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 686 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
664 | return; | 687 | return; |
665 | 688 | ||
666 | } | 689 | } |
667 | int newHight; | 690 | int newHight; |
668 | if ( !mSelectedDates.count()) | 691 | if ( !mSelectedDates.count()) |
669 | return; | 692 | return; |
670 | 693 | ||
671 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 694 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
672 | // It would remove some flickering and gain speed (since this is called by | 695 | // It would remove some flickering and gain speed (since this is called by |
673 | // each updateView() call) | 696 | // each updateView() call) |
674 | 697 | ||
@@ -1205,236 +1228,238 @@ void KOAgendaView::fillAgenda() | |||
1205 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1228 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1206 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1229 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1207 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1230 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1208 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1231 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1209 | 1232 | ||
1210 | } | 1233 | } |
1211 | } | 1234 | } |
1212 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1235 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1213 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1236 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1214 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1237 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1215 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1238 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1216 | //qDebug("insert!!! "); | 1239 | //qDebug("insert!!! "); |
1217 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1240 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1218 | } | 1241 | } |
1219 | if (beginX == curCol) { | 1242 | if (beginX == curCol) { |
1220 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1243 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1221 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1244 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1222 | } else if (endX == curCol) { | 1245 | } else if (endX == curCol) { |
1223 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1246 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1224 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1247 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1225 | } else { | 1248 | } else { |
1226 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1249 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1227 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1250 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1228 | } | 1251 | } |
1229 | } else { | 1252 | } else { |
1230 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1253 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1231 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1254 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1232 | if (endY < startY) endY = startY; | 1255 | if (endY < startY) endY = startY; |
1233 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1256 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1234 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1257 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1235 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1258 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1236 | } | 1259 | } |
1237 | } | 1260 | } |
1238 | // ---------- [display Todos -------------- | 1261 | // ---------- [display Todos -------------- |
1239 | unsigned int numTodo; | 1262 | unsigned int numTodo; |
1240 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1263 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1241 | Todo *todo = todos.at(numTodo); | 1264 | Todo *todo = todos.at(numTodo); |
1242 | 1265 | ||
1243 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1266 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1244 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; | 1267 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; |
1245 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1268 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1246 | // Already completed items can be displayed on their original due date | 1269 | // Already completed items can be displayed on their original due date |
1247 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1270 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1248 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1271 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1249 | bool fillIn = false; | 1272 | bool fillIn = false; |
1250 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1273 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1251 | fillIn = true; | 1274 | fillIn = true; |
1252 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1275 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1253 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1276 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1254 | if ( fillIn ) { | 1277 | if ( fillIn ) { |
1255 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1278 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1256 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1279 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1257 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1280 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1258 | } | 1281 | } |
1259 | else { | 1282 | else { |
1260 | QDateTime dt; | 1283 | QDateTime dt; |
1261 | if ( todo->hasCompletedDate() ) | 1284 | if ( todo->hasCompletedDate() ) |
1262 | dt = todo->completed(); | 1285 | dt = todo->completed(); |
1263 | else | 1286 | else |
1264 | dt = todo->dtDue();; | 1287 | dt = todo->dtDue();; |
1265 | 1288 | ||
1266 | 1289 | ||
1267 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1290 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1268 | int hi = (18/KOPrefs::instance()->mHourSize); | 1291 | int hi = (18/KOPrefs::instance()->mHourSize); |
1269 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1292 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1270 | int startY = endY -hi; | 1293 | int startY = endY -hi; |
1271 | 1294 | ||
1272 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1295 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1273 | 1296 | ||
1274 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1297 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1275 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1298 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1276 | } | 1299 | } |
1277 | } | 1300 | } |
1278 | } | 1301 | } |
1279 | // ---------- display Todos] -------------- | 1302 | // ---------- display Todos] -------------- |
1280 | 1303 | ||
1281 | ++curCol; | 1304 | ++curCol; |
1282 | } | 1305 | } |
1283 | mAgenda->hideUnused(); | 1306 | mAgenda->hideUnused(); |
1284 | mAllDayAgenda->hideUnused(); | 1307 | mAllDayAgenda->hideUnused(); |
1285 | mAgenda->checkScrollBoundaries(); | 1308 | mAgenda->checkScrollBoundaries(); |
1286 | deleteSelectedDateTime(); | 1309 | deleteSelectedDateTime(); |
1287 | createDayLabels(); | 1310 | createDayLabels(); |
1288 | emit incidenceSelected( 0 ); | 1311 | emit incidenceSelected( 0 ); |
1289 | 1312 | ||
1290 | if ( globalFlagBlockAgenda == 2 ) { | 1313 | if ( globalFlagBlockAgenda == 2 ) { |
1291 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1314 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1292 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1315 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1293 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1316 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1294 | setStartHour( QTime::currentTime ().hour() ); | 1317 | setStartHour( QTime::currentTime ().hour() ); |
1295 | } | 1318 | } |
1296 | qApp->processEvents(); | 1319 | qApp->processEvents(); |
1297 | globalFlagBlockAgenda = 0; | 1320 | globalFlagBlockAgenda = 0; |
1298 | mAllDayAgenda->drawContentsToPainter(); | 1321 | mAllDayAgenda->drawContentsToPainter(); |
1299 | mAgenda->drawContentsToPainter(); | 1322 | mAgenda->drawContentsToPainter(); |
1300 | repaintAgenda(); | 1323 | repaintAgenda(); |
1324 | mIdleTimer->start ( IDLETIMEOUT *1000 ); | ||
1325 | mIdleStart = QDateTime::currentDateTime(); | ||
1301 | onlyOne = false; | 1326 | onlyOne = false; |
1302 | } | 1327 | } |
1303 | void KOAgendaView::repaintAgenda() | 1328 | void KOAgendaView::repaintAgenda() |
1304 | { | 1329 | { |
1305 | mAgenda->viewport()->repaint( false ); | 1330 | mAgenda->viewport()->repaint( false ); |
1306 | mAllDayAgenda->viewport()->repaint( false ); | 1331 | mAllDayAgenda->viewport()->repaint( false ); |
1307 | mAgenda->finishUpdate(); | 1332 | mAgenda->finishUpdate(); |
1308 | mAllDayAgenda->finishUpdate(); | 1333 | mAllDayAgenda->finishUpdate(); |
1309 | } | 1334 | } |
1310 | 1335 | ||
1311 | 1336 | ||
1312 | void KOAgendaView::clearView() | 1337 | void KOAgendaView::clearView() |
1313 | { | 1338 | { |
1314 | mAllDayAgenda->clear(); | 1339 | mAllDayAgenda->clear(); |
1315 | mAgenda->clear(); | 1340 | mAgenda->clear(); |
1316 | } | 1341 | } |
1317 | void KOAgendaView::clearList() | 1342 | void KOAgendaView::clearList() |
1318 | { | 1343 | { |
1319 | clearView(); | 1344 | clearView(); |
1320 | mAllDayAgenda->hideUnused(); | 1345 | mAllDayAgenda->hideUnused(); |
1321 | mAgenda->hideUnused(); | 1346 | mAgenda->hideUnused(); |
1322 | } | 1347 | } |
1323 | 1348 | ||
1324 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1349 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1325 | const QDate &td) | 1350 | const QDate &td) |
1326 | { | 1351 | { |
1327 | #ifndef KORG_NOPRINTER | 1352 | #ifndef KORG_NOPRINTER |
1328 | if (fd == td) | 1353 | if (fd == td) |
1329 | calPrinter->preview(CalPrinter::Day, fd, td); | 1354 | calPrinter->preview(CalPrinter::Day, fd, td); |
1330 | else | 1355 | else |
1331 | calPrinter->preview(CalPrinter::Week, fd, td); | 1356 | calPrinter->preview(CalPrinter::Week, fd, td); |
1332 | #endif | 1357 | #endif |
1333 | } | 1358 | } |
1334 | 1359 | ||
1335 | // void KOAgendaView::updateMovedTodo() | 1360 | // void KOAgendaView::updateMovedTodo() |
1336 | // { | 1361 | // { |
1337 | // // updateConfig(); | 1362 | // // updateConfig(); |
1338 | // // emit updateTodoViews(); | 1363 | // // emit updateTodoViews(); |
1339 | // } | 1364 | // } |
1340 | 1365 | ||
1341 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1366 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1342 | { | 1367 | { |
1343 | if ( d >= mSelectedDates.count() ) { | 1368 | if ( d >= mSelectedDates.count() ) { |
1344 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1369 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); |
1345 | 1370 | ||
1346 | } else { | 1371 | } else { |
1347 | QDate day = mSelectedDates[d]; | 1372 | QDate day = mSelectedDates[d]; |
1348 | emit showDateView(mode , day ); | 1373 | emit showDateView(mode , day ); |
1349 | } | 1374 | } |
1350 | 1375 | ||
1351 | } | 1376 | } |
1352 | void KOAgendaView::newEvent(int gx, int gy) | 1377 | void KOAgendaView::newEvent(int gx, int gy) |
1353 | { | 1378 | { |
1354 | if (!mSelectedDates.count()) return; | 1379 | if (!mSelectedDates.count()) return; |
1355 | 1380 | ||
1356 | QDate day = mSelectedDates[gx]; | 1381 | QDate day = mSelectedDates[gx]; |
1357 | 1382 | ||
1358 | QTime time = mAgenda->gyToTime(gy); | 1383 | QTime time = mAgenda->gyToTime(gy); |
1359 | QDateTime dt(day,time); | 1384 | QDateTime dt(day,time); |
1360 | // if ( dt < QDateTime::currentDateTime () ) | 1385 | // if ( dt < QDateTime::currentDateTime () ) |
1361 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1386 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1362 | emit newEventSignal(dt); | 1387 | emit newEventSignal(dt); |
1363 | } | 1388 | } |
1364 | 1389 | ||
1365 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1390 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1366 | { | 1391 | { |
1367 | if (!mSelectedDates.count()) return; | 1392 | if (!mSelectedDates.count()) return; |
1368 | 1393 | ||
1369 | QDate dayStart = mSelectedDates[gxStart]; | 1394 | QDate dayStart = mSelectedDates[gxStart]; |
1370 | QDate dayEnd = mSelectedDates[gxEnd]; | 1395 | QDate dayEnd = mSelectedDates[gxEnd]; |
1371 | 1396 | ||
1372 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1397 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1373 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1398 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1374 | 1399 | ||
1375 | QDateTime dtStart(dayStart,timeStart); | 1400 | QDateTime dtStart(dayStart,timeStart); |
1376 | QDateTime dtEnd(dayEnd,timeEnd); | 1401 | QDateTime dtEnd(dayEnd,timeEnd); |
1377 | 1402 | ||
1378 | emit newEventSignal(dtStart,dtEnd); | 1403 | emit newEventSignal(dtStart,dtEnd); |
1379 | } | 1404 | } |
1380 | 1405 | ||
1381 | void KOAgendaView::newEventAllDay(int gx, int ) | 1406 | void KOAgendaView::newEventAllDay(int gx, int ) |
1382 | { | 1407 | { |
1383 | if (!mSelectedDates.count()) return; | 1408 | if (!mSelectedDates.count()) return; |
1384 | 1409 | ||
1385 | QDate day = mSelectedDates[gx]; | 1410 | QDate day = mSelectedDates[gx]; |
1386 | 1411 | ||
1387 | emit newEventSignal(day); | 1412 | emit newEventSignal(day); |
1388 | } | 1413 | } |
1389 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1414 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1390 | { | 1415 | { |
1391 | if (!mSelectedDates.count()) return; | 1416 | if (!mSelectedDates.count()) return; |
1392 | 1417 | ||
1393 | QDateTime day (mSelectedDates[gx] ); | 1418 | QDateTime day (mSelectedDates[gx] ); |
1394 | emit newTodoSignal(day, true); | 1419 | emit newTodoSignal(day, true); |
1395 | } | 1420 | } |
1396 | void KOAgendaView::newTodo(int gx, int gy ) | 1421 | void KOAgendaView::newTodo(int gx, int gy ) |
1397 | { | 1422 | { |
1398 | if (!mSelectedDates.count()) return; | 1423 | if (!mSelectedDates.count()) return; |
1399 | QDate dayStart = mSelectedDates[gx]; | 1424 | QDate dayStart = mSelectedDates[gx]; |
1400 | QTime timeStart = mAgenda->gyToTime(gy); | 1425 | QTime timeStart = mAgenda->gyToTime(gy); |
1401 | QDateTime dt (dayStart,timeStart); | 1426 | QDateTime dt (dayStart,timeStart); |
1402 | emit newTodoSignal( dt, false ); | 1427 | emit newTodoSignal( dt, false ); |
1403 | } | 1428 | } |
1404 | 1429 | ||
1405 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1430 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1406 | { | 1431 | { |
1407 | uint i; | 1432 | uint i; |
1408 | for(i=0;i<mMinY.size();++i) { | 1433 | for(i=0;i<mMinY.size();++i) { |
1409 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1434 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1410 | else mEventIndicatorTop->enableColumn(i,false); | 1435 | else mEventIndicatorTop->enableColumn(i,false); |
1411 | } | 1436 | } |
1412 | 1437 | ||
1413 | mEventIndicatorTop->update(); | 1438 | mEventIndicatorTop->update(); |
1414 | } | 1439 | } |
1415 | 1440 | ||
1416 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1441 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1417 | { | 1442 | { |
1418 | uint i; | 1443 | uint i; |
1419 | for(i=0;i<mMaxY.size();++i) { | 1444 | for(i=0;i<mMaxY.size();++i) { |
1420 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1445 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1421 | else mEventIndicatorBottom->enableColumn(i,false); | 1446 | else mEventIndicatorBottom->enableColumn(i,false); |
1422 | } | 1447 | } |
1423 | 1448 | ||
1424 | mEventIndicatorBottom->update(); | 1449 | mEventIndicatorBottom->update(); |
1425 | } | 1450 | } |
1426 | 1451 | ||
1427 | void KOAgendaView::startDrag(Event *event) | 1452 | void KOAgendaView::startDrag(Event *event) |
1428 | { | 1453 | { |
1429 | #ifndef KORG_NODND | 1454 | #ifndef KORG_NODND |
1430 | DndFactory factory( calendar() ); | 1455 | DndFactory factory( calendar() ); |
1431 | ICalDrag *vd = factory.createDrag(event,this); | 1456 | ICalDrag *vd = factory.createDrag(event,this); |
1432 | if (vd->drag()) { | 1457 | if (vd->drag()) { |
1433 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1458 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1434 | } | 1459 | } |
1435 | #endif | 1460 | #endif |
1436 | } | 1461 | } |
1437 | 1462 | ||
1438 | void KOAgendaView::readSettings() | 1463 | void KOAgendaView::readSettings() |
1439 | { | 1464 | { |
1440 | readSettings(KOGlobals::config()); | 1465 | readSettings(KOGlobals::config()); |
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index a1cf308..effd7a3 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h | |||
@@ -117,178 +117,181 @@ class EventIndicator : public QFrame { | |||
117 | Q_OBJECT | 117 | Q_OBJECT |
118 | public: | 118 | public: |
119 | enum Location { Top, Bottom }; | 119 | enum Location { Top, Bottom }; |
120 | EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); | 120 | EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); |
121 | virtual ~EventIndicator(); | 121 | virtual ~EventIndicator(); |
122 | 122 | ||
123 | void changeColumns(int columns); | 123 | void changeColumns(int columns); |
124 | void setPaintWidget( KDGanttMinimizeSplitter* ); | 124 | void setPaintWidget( KDGanttMinimizeSplitter* ); |
125 | void setXOffset( int ); | 125 | void setXOffset( int ); |
126 | void enableColumn(int column, bool enable); | 126 | void enableColumn(int column, bool enable); |
127 | 127 | ||
128 | protected: | 128 | protected: |
129 | void drawContents(QPainter *); | 129 | void drawContents(QPainter *); |
130 | 130 | ||
131 | private: | 131 | private: |
132 | int mXOffset; | 132 | int mXOffset; |
133 | KDGanttMinimizeSplitter* mPaintWidget; | 133 | KDGanttMinimizeSplitter* mPaintWidget; |
134 | int mColumns; | 134 | int mColumns; |
135 | QHBox *mTopBox; | 135 | QHBox *mTopBox; |
136 | QBoxLayout *mTopLayout; | 136 | QBoxLayout *mTopLayout; |
137 | Location mLocation; | 137 | Location mLocation; |
138 | QPixmap mPixmap; | 138 | QPixmap mPixmap; |
139 | QMemArray<bool> mEnabled; | 139 | QMemArray<bool> mEnabled; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | /** | 142 | /** |
143 | KOAgendaView is the agenda-like view used to display events in an one or | 143 | KOAgendaView is the agenda-like view used to display events in an one or |
144 | multi-day view. | 144 | multi-day view. |
145 | */ | 145 | */ |
146 | class KOAgendaView : public KOEventView { | 146 | class KOAgendaView : public KOEventView { |
147 | Q_OBJECT | 147 | Q_OBJECT |
148 | public: | 148 | public: |
149 | KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); | 149 | KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); |
150 | virtual ~KOAgendaView(); | 150 | virtual ~KOAgendaView(); |
151 | void setStartHour( int ); | 151 | void setStartHour( int ); |
152 | void toggleAllDay(); | 152 | void toggleAllDay(); |
153 | 153 | ||
154 | 154 | ||
155 | /** Returns maximum number of days supported by the koagendaview */ | 155 | /** Returns maximum number of days supported by the koagendaview */ |
156 | virtual int maxDatesHint(); | 156 | virtual int maxDatesHint(); |
157 | 157 | ||
158 | /** Returns number of currently shown dates. */ | 158 | /** Returns number of currently shown dates. */ |
159 | virtual int currentDateCount(); | 159 | virtual int currentDateCount(); |
160 | 160 | ||
161 | /** returns the currently selected events */ | 161 | /** returns the currently selected events */ |
162 | virtual QPtrList<Incidence> selectedIncidences(); | 162 | virtual QPtrList<Incidence> selectedIncidences(); |
163 | 163 | ||
164 | /** returns the currently selected events */ | 164 | /** returns the currently selected events */ |
165 | virtual DateList selectedDates(); | 165 | virtual DateList selectedDates(); |
166 | 166 | ||
167 | /** Remove all events from view */ | 167 | /** Remove all events from view */ |
168 | void clearView(); | 168 | void clearView(); |
169 | void clearList(); | 169 | void clearList(); |
170 | KOAgenda *agenda() { return mAgenda;} | 170 | KOAgenda *agenda() { return mAgenda;} |
171 | virtual void printPreview(CalPrinter *calPrinter, | 171 | virtual void printPreview(CalPrinter *calPrinter, |
172 | const QDate &, const QDate &); | 172 | const QDate &, const QDate &); |
173 | 173 | ||
174 | /** start-datetime of selection */ | 174 | /** start-datetime of selection */ |
175 | QDateTime selectionStart() {return mTimeSpanBegin;} | 175 | QDateTime selectionStart() {return mTimeSpanBegin;} |
176 | /** end-datetime of selection */ | 176 | /** end-datetime of selection */ |
177 | QDateTime selectionEnd() {return mTimeSpanEnd;} | 177 | QDateTime selectionEnd() {return mTimeSpanEnd;} |
178 | /** returns true if selection is for whole day */ | 178 | /** returns true if selection is for whole day */ |
179 | bool selectedIsAllDay() {return mTimeSpanInAllDay;} | 179 | bool selectedIsAllDay() {return mTimeSpanInAllDay;} |
180 | /** make selected start/end invalid */ | 180 | /** make selected start/end invalid */ |
181 | void deleteSelectedDateTime(); | 181 | void deleteSelectedDateTime(); |
182 | void repaintAgenda(); | 182 | void repaintAgenda(); |
183 | public slots: | 183 | public slots: |
184 | void setInitStartHour(); | 184 | void setInitStartHour(); |
185 | virtual void updateView(); | 185 | virtual void updateView(); |
186 | virtual void updateConfig(); | 186 | virtual void updateConfig(); |
187 | virtual void showDates(const QDate &start, const QDate &end); | 187 | virtual void showDates(const QDate &start, const QDate &end); |
188 | virtual void showEvents(QPtrList<Event> eventList); | 188 | virtual void showEvents(QPtrList<Event> eventList); |
189 | 189 | ||
190 | void updateTodo( Todo *, int ); | 190 | void updateTodo( Todo *, int ); |
191 | void changeEventDisplay(Event *, int); | 191 | void changeEventDisplay(Event *, int); |
192 | 192 | ||
193 | void clearSelection(); | 193 | void clearSelection(); |
194 | 194 | ||
195 | void newTodo(int gx,int gy); | 195 | void newTodo(int gx,int gy); |
196 | void newEvent(int gx,int gy); | 196 | void newEvent(int gx,int gy); |
197 | void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); | 197 | void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); |
198 | void newEventAllDay(int gx, int gy); | 198 | void newEventAllDay(int gx, int gy); |
199 | void newTodoAllDay(int gx, int gy); | 199 | void newTodoAllDay(int gx, int gy); |
200 | 200 | ||
201 | void startDrag(Event *); | 201 | void startDrag(Event *); |
202 | 202 | ||
203 | void readSettings(); | 203 | void readSettings(); |
204 | void readSettings(KConfig *); | 204 | void readSettings(KConfig *); |
205 | void writeSettings(KConfig *); | 205 | void writeSettings(KConfig *); |
206 | 206 | ||
207 | void setContentsPos(int y); | 207 | void setContentsPos(int y); |
208 | 208 | ||
209 | void scrollOneHourUp(); | 209 | void scrollOneHourUp(); |
210 | void scrollOneHourDown(); | 210 | void scrollOneHourDown(); |
211 | void addToCalSlot(Incidence *, Incidence *); | 211 | void addToCalSlot(Incidence *, Incidence *); |
212 | void slotShowDateView( int, int ); | 212 | void slotShowDateView( int, int ); |
213 | void fillAgenda(); | ||
213 | 214 | ||
214 | signals: | 215 | signals: |
215 | void showDateView( int, QDate ); | 216 | void showDateView( int, QDate ); |
216 | void newTodoSignal( QDateTime ,bool ); | 217 | void newTodoSignal( QDateTime ,bool ); |
217 | void toggleExpand(); | 218 | void toggleExpand(); |
218 | void selectWeekNum( int ); | 219 | void selectWeekNum( int ); |
219 | void todoMoved( Todo *, int ); | 220 | void todoMoved( Todo *, int ); |
220 | void incidenceChanged(Incidence * , int ); | 221 | void incidenceChanged(Incidence * , int ); |
221 | // void cloneIncidenceSignal(Incidence *); | 222 | // void cloneIncidenceSignal(Incidence *); |
222 | 223 | ||
223 | protected: | 224 | protected: |
224 | KOAgendaButton* getNewDaylabel(); | 225 | KOAgendaButton* getNewDaylabel(); |
225 | bool mBlockUpdating; | 226 | bool mBlockUpdating; |
226 | int mUpcomingWidth; | 227 | int mUpcomingWidth; |
227 | /** Fill agenda beginning with date startDate */ | 228 | /** Fill agenda beginning with date startDate */ |
228 | void fillAgenda(const QDate &startDate); | 229 | void fillAgenda(const QDate &startDate); |
229 | void resizeEvent( QResizeEvent* e ); | 230 | void resizeEvent( QResizeEvent* e ); |
230 | /** Fill agenda using the current set value for the start date */ | 231 | /** Fill agenda using the current set value for the start date */ |
231 | void fillAgenda(); | ||
232 | 232 | ||
233 | /** Create labels for the selected dates. */ | 233 | /** Create labels for the selected dates. */ |
234 | void createDayLabels(); | 234 | void createDayLabels(); |
235 | 235 | ||
236 | /** | 236 | /** |
237 | Set the masks on the agenda widgets indicating, which days are holidays. | 237 | Set the masks on the agenda widgets indicating, which days are holidays. |
238 | */ | 238 | */ |
239 | void setHolidayMasks(); | 239 | void setHolidayMasks(); |
240 | 240 | ||
241 | protected slots: | 241 | protected slots: |
242 | void slotIdleTimeout(); | ||
242 | void categoryChanged( Incidence * ); | 243 | void categoryChanged( Incidence * ); |
243 | void slotDaylabelClicked( int ); | 244 | void slotDaylabelClicked( int ); |
244 | /** Update event belonging to agenda item */ | 245 | /** Update event belonging to agenda item */ |
245 | void updateEventDates(KOAgendaItem *item, int mode = -1); | 246 | void updateEventDates(KOAgendaItem *item, int mode = -1); |
246 | //void updateMovedTodo(); | 247 | //void updateMovedTodo(); |
247 | 248 | ||
248 | void updateEventIndicatorTop(int newY); | 249 | void updateEventIndicatorTop(int newY); |
249 | void updateEventIndicatorBottom(int newY); | 250 | void updateEventIndicatorBottom(int newY); |
250 | 251 | ||
251 | /** Updates data for selected timespan */ | 252 | /** Updates data for selected timespan */ |
252 | void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); | 253 | void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); |
253 | /** Updates data for selected timespan for all day event*/ | 254 | /** Updates data for selected timespan for all day event*/ |
254 | void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); | 255 | void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); |
255 | 256 | ||
256 | private: | 257 | private: |
258 | QTimer* mIdleTimer; | ||
259 | QDateTime mIdleStart; | ||
257 | // view widgets | 260 | // view widgets |
258 | QFrame *mDayLabels; | 261 | QFrame *mDayLabels; |
259 | QHBox *mDayLabelsFrame; | 262 | QHBox *mDayLabelsFrame; |
260 | QBoxLayout *mLayoutDayLabels; | 263 | QBoxLayout *mLayoutDayLabels; |
261 | QFrame *mAllDayFrame; | 264 | QFrame *mAllDayFrame; |
262 | KOAgenda *mAllDayAgenda; | 265 | KOAgenda *mAllDayAgenda; |
263 | KOAgenda *mAgenda; | 266 | KOAgenda *mAgenda; |
264 | TimeLabels *mTimeLabels; | 267 | TimeLabels *mTimeLabels; |
265 | QWidget *mDummyAllDayLeft; | 268 | QWidget *mDummyAllDayLeft; |
266 | 269 | ||
267 | KDGanttMinimizeSplitter* mSplitterAgenda; | 270 | KDGanttMinimizeSplitter* mSplitterAgenda; |
268 | QPushButton *mExpandButton; | 271 | QPushButton *mExpandButton; |
269 | 272 | ||
270 | DateList mSelectedDates; // List of dates to be displayed | 273 | DateList mSelectedDates; // List of dates to be displayed |
271 | int mViewType; | 274 | int mViewType; |
272 | 275 | ||
273 | bool mWeekStartsMonday; | 276 | bool mWeekStartsMonday; |
274 | int mStartHour; | 277 | int mStartHour; |
275 | 278 | ||
276 | KOEventPopupMenu *mAllAgendaPopup; | 279 | KOEventPopupMenu *mAllAgendaPopup; |
277 | //KOEventPopupMenu *mAllDayAgendaPopup; | 280 | //KOEventPopupMenu *mAllDayAgendaPopup; |
278 | 281 | ||
279 | EventIndicator *mEventIndicatorTop; | 282 | EventIndicator *mEventIndicatorTop; |
280 | EventIndicator *mEventIndicatorBottom; | 283 | EventIndicator *mEventIndicatorBottom; |
281 | 284 | ||
282 | QMemArray<int> mMinY; | 285 | QMemArray<int> mMinY; |
283 | QMemArray<int> mMaxY; | 286 | QMemArray<int> mMaxY; |
284 | 287 | ||
285 | QMemArray<bool> mHolidayMask; | 288 | QMemArray<bool> mHolidayMask; |
286 | 289 | ||
287 | QPtrList<KOAgendaButton> mDayLabelsList; | 290 | QPtrList<KOAgendaButton> mDayLabelsList; |
288 | QDateTime mTimeSpanBegin; | 291 | QDateTime mTimeSpanBegin; |
289 | QDateTime mTimeSpanEnd; | 292 | QDateTime mTimeSpanEnd; |
290 | bool mTimeSpanInAllDay; | 293 | bool mTimeSpanInAllDay; |
291 | void keyPressEvent ( QKeyEvent * e ); | 294 | void keyPressEvent ( QKeyEvent * e ); |
292 | }; | 295 | }; |
293 | 296 | ||
294 | #endif // KOAGENDAVIEW_H | 297 | #endif // KOAGENDAVIEW_H |