author | zautrix <zautrix> | 2005-01-26 23:12:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-26 23:12:59 (UTC) |
commit | f20b5e71f9ae61b18f0ced792508b40432ad50b6 (patch) (unidiff) | |
tree | 3dde48c6dcecf2e5c19d3e7a62aba57c385e92df | |
parent | 15351333eff09beadb6e691e9f0aab2aaf0a95a0 (diff) | |
download | kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.zip kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.tar.gz kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.tar.bz2 |
fixes
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index b5596d9..05216a7 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,481 +1,483 @@ | |||
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 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 79 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
80 | QScrollView(parent,name,f) | 80 | QScrollView(parent,name,f) |
81 | { | 81 | { |
82 | mRows = rows; | 82 | mRows = rows; |
83 | 83 | ||
84 | setMinimumHeight( 20 ); | 84 | setMinimumHeight( 20 ); |
85 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 85 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
86 | 86 | ||
87 | enableClipper(true); | 87 | enableClipper(true); |
88 | 88 | ||
89 | setHScrollBarMode(AlwaysOff); | 89 | setHScrollBarMode(AlwaysOff); |
90 | setVScrollBarMode(AlwaysOff); | 90 | setVScrollBarMode(AlwaysOff); |
91 | 91 | ||
92 | resizeContents(50,mRows * mCellHeight); | 92 | resizeContents(50,mRows * mCellHeight); |
93 | 93 | ||
94 | viewport()->setBackgroundMode( PaletteBackground ); | 94 | viewport()->setBackgroundMode( PaletteBackground ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void TimeLabels::setCellHeight(int height) | 97 | void TimeLabels::setCellHeight(int height) |
98 | { | 98 | { |
99 | mCellHeight = height; | 99 | mCellHeight = height; |
100 | } | 100 | } |
101 | 101 | ||
102 | /* | 102 | /* |
103 | Optimization so that only the "dirty" portion of the scroll view | 103 | Optimization so that only the "dirty" portion of the scroll view |
104 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 104 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
105 | */ | 105 | */ |
106 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 106 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
107 | { | 107 | { |
108 | 108 | ||
109 | // if ( globalFlagBlockAgenda ) | 109 | // if ( globalFlagBlockAgenda ) |
110 | // return; | 110 | // return; |
111 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 111 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
112 | // redrawn, not the area of the widget. unfortunately, this | 112 | // redrawn, not the area of the widget. unfortunately, this |
113 | // code assumes the latter... | 113 | // code assumes the latter... |
114 | 114 | ||
115 | // now, for a workaround... | 115 | // now, for a workaround... |
116 | // these two assignments fix the weird redraw bug | 116 | // these two assignments fix the weird redraw bug |
117 | cx = contentsX() + 2; | 117 | cx = contentsX() + 2; |
118 | cw = contentsWidth() - 2; | 118 | cw = contentsWidth() - 2; |
119 | // end of workaround | 119 | // end of workaround |
120 | 120 | ||
121 | int cell = ((int)(cy/mCellHeight)); | 121 | int cell = ((int)(cy/mCellHeight)); |
122 | int y = cell * mCellHeight; | 122 | int y = cell * mCellHeight; |
123 | QFontMetrics fm = fontMetrics(); | 123 | QFontMetrics fm = fontMetrics(); |
124 | QString hour; | 124 | QString hour; |
125 | QString suffix; | 125 | QString suffix; |
126 | QString fullTime; | 126 | QString fullTime; |
127 | int tW = fm.width("24:00i"); | 127 | int tW = fm.width("24:00i"); |
128 | 128 | ||
129 | while (y < cy + ch) { | 129 | while (y < cy + ch) { |
130 | p->drawLine(cx,y,cx+tW,y); | 130 | p->drawLine(cx,y,cx+tW,y); |
131 | hour.setNum(cell); | 131 | hour.setNum(cell); |
132 | suffix = "am"; | 132 | suffix = "am"; |
133 | 133 | ||
134 | // handle 24h and am/pm time formats | 134 | // handle 24h and am/pm time formats |
135 | if (KGlobal::locale()->use12Clock()) { | 135 | if (KGlobal::locale()->use12Clock()) { |
136 | if (cell > 11) suffix = "pm"; | 136 | if (cell > 11) suffix = "pm"; |
137 | if (cell == 0) hour.setNum(12); | 137 | if (cell == 0) hour.setNum(12); |
138 | if (cell > 12) hour.setNum(cell - 12); | 138 | if (cell > 12) hour.setNum(cell - 12); |
139 | } else { | 139 | } else { |
140 | suffix = ":00"; | 140 | suffix = ":00"; |
141 | } | 141 | } |
142 | 142 | ||
143 | // create string in format of "XX:XX" or "XXpm/am" | 143 | // create string in format of "XX:XX" or "XXpm/am" |
144 | fullTime = hour + suffix; | 144 | fullTime = hour + suffix; |
145 | 145 | ||
146 | // center and draw the time label | 146 | // center and draw the time label |
147 | int timeWidth = fm.width(fullTime+"i"); | 147 | int timeWidth = fm.width(fullTime+"i"); |
148 | int offset = this->width() - timeWidth; | 148 | int offset = this->width() - timeWidth; |
149 | int borderWidth = 5; | 149 | int borderWidth = 5; |
150 | int timeHeight = fm.height(); | 150 | int timeHeight = fm.height(); |
151 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); | 151 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); |
152 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); | 152 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); |
153 | 153 | ||
154 | // increment indices | 154 | // increment indices |
155 | y += mCellHeight; | 155 | y += mCellHeight; |
156 | cell++; | 156 | cell++; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Calculates the minimum width. | 161 | Calculates the minimum width. |
162 | */ | 162 | */ |
163 | int TimeLabels::minimumWidth() const | 163 | int TimeLabels::minimumWidth() const |
164 | { | 164 | { |
165 | QFontMetrics fm = fontMetrics(); | 165 | QFontMetrics fm = fontMetrics(); |
166 | 166 | ||
167 | //TODO: calculate this value | 167 | //TODO: calculate this value |
168 | int borderWidth = 4; | 168 | int borderWidth = 4; |
169 | 169 | ||
170 | // the maximum width possible | 170 | // the maximum width possible |
171 | int width = fm.width("88:88x") + borderWidth; | 171 | int width = fm.width("88:88x") + borderWidth; |
172 | 172 | ||
173 | return width; | 173 | return width; |
174 | } | 174 | } |
175 | 175 | ||
176 | /** updates widget's internal state */ | 176 | /** updates widget's internal state */ |
177 | void TimeLabels::updateConfig() | 177 | void TimeLabels::updateConfig() |
178 | { | 178 | { |
179 | // set the font | 179 | // set the font |
180 | // config->setGroup("Fonts"); | 180 | // config->setGroup("Fonts"); |
181 | // QFont font = config->readFontEntry("TimeBar Font"); | 181 | // QFont font = config->readFontEntry("TimeBar Font"); |
182 | setFont(KOPrefs::instance()->mTimeBarFont); | 182 | setFont(KOPrefs::instance()->mTimeBarFont); |
183 | 183 | ||
184 | // update geometry restrictions based on new settings | 184 | // update geometry restrictions based on new settings |
185 | setFixedWidth(minimumWidth()); | 185 | setFixedWidth(minimumWidth()); |
186 | 186 | ||
187 | // update HourSize | 187 | // update HourSize |
188 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 188 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
189 | resizeContents(50,mRows * mCellHeight); | 189 | resizeContents(50,mRows * mCellHeight); |
190 | } | 190 | } |
191 | 191 | ||
192 | /** update time label positions */ | 192 | /** update time label positions */ |
193 | void TimeLabels::positionChanged() | 193 | void TimeLabels::positionChanged() |
194 | { | 194 | { |
195 | int adjustment = mAgenda->contentsY(); | 195 | int adjustment = mAgenda->contentsY(); |
196 | setContentsPos(0, adjustment); | 196 | setContentsPos(0, adjustment); |
197 | } | 197 | } |
198 | 198 | ||
199 | /** */ | 199 | /** */ |
200 | void TimeLabels::setAgenda(KOAgenda* agenda) | 200 | void TimeLabels::setAgenda(KOAgenda* agenda) |
201 | { | 201 | { |
202 | mAgenda = agenda; | 202 | mAgenda = agenda; |
203 | } | 203 | } |
204 | 204 | ||
205 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 205 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
206 | { | 206 | { |
207 | mMouseDownY = e->pos().y(); | 207 | mMouseDownY = e->pos().y(); |
208 | mOrgCap = topLevelWidget()->caption(); | ||
208 | } | 209 | } |
209 | 210 | ||
210 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 211 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
211 | { | 212 | { |
212 | int diff = mMouseDownY - e->pos().y(); | 213 | int diff = mMouseDownY - e->pos().y(); |
213 | if ( diff < 10 && diff > -10 ) | 214 | if ( diff < 10 && diff > -10 ) |
214 | return; | 215 | return; |
215 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 216 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
216 | if ( tSize < 4 ) | 217 | if ( tSize < 4 ) |
217 | tSize = 4; | 218 | tSize = 4; |
218 | if ( tSize > 18 ) | 219 | if ( tSize > 18 ) |
219 | tSize = 18; | 220 | tSize = 18; |
220 | tSize = (tSize-2)/2; | 221 | tSize = (tSize-2)/2; |
221 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 222 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
222 | 223 | ||
223 | } | 224 | } |
224 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 225 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
225 | { | 226 | { |
227 | topLevelWidget()->setCaption( mOrgCap ); | ||
226 | int diff = mMouseDownY - e->pos().y(); | 228 | int diff = mMouseDownY - e->pos().y(); |
227 | if ( diff < 10 && diff > -10 ) | 229 | if ( diff < 10 && diff > -10 ) |
228 | return; | 230 | return; |
229 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 231 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
230 | if ( tSize < 4 ) | 232 | if ( tSize < 4 ) |
231 | tSize = 4; | 233 | tSize = 4; |
232 | if ( tSize > 18 ) | 234 | if ( tSize > 18 ) |
233 | tSize = 18; | 235 | tSize = 18; |
234 | tSize = (tSize/2)*2; | 236 | tSize = (tSize/2)*2; |
235 | if ( tSize == KOPrefs::instance()->mHourSize ) | 237 | if ( tSize == KOPrefs::instance()->mHourSize ) |
236 | return; | 238 | return; |
237 | KOPrefs::instance()->mHourSize = tSize; | 239 | KOPrefs::instance()->mHourSize = tSize; |
238 | emit scaleChanged(); | 240 | emit scaleChanged(); |
239 | } | 241 | } |
240 | 242 | ||
241 | /** This is called in response to repaint() */ | 243 | /** This is called in response to repaint() */ |
242 | void TimeLabels::paintEvent(QPaintEvent*) | 244 | void TimeLabels::paintEvent(QPaintEvent*) |
243 | { | 245 | { |
244 | 246 | ||
245 | // kdDebug() << "paintevent..." << endl; | 247 | // kdDebug() << "paintevent..." << endl; |
246 | // this is another hack! | 248 | // this is another hack! |
247 | // QPainter painter(this); | 249 | // QPainter painter(this); |
248 | //QString c | 250 | //QString c |
249 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 251 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
250 | } | 252 | } |
251 | 253 | ||
252 | //////////////////////////////////////////////////////////////////////////// | 254 | //////////////////////////////////////////////////////////////////////////// |
253 | 255 | ||
254 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 256 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
255 | : QFrame(parent,name) | 257 | : QFrame(parent,name) |
256 | { | 258 | { |
257 | mColumns = 1; | 259 | mColumns = 1; |
258 | mTopBox = 0; | 260 | mTopBox = 0; |
259 | mLocation = loc; | 261 | mLocation = loc; |
260 | mTopLayout = 0; | 262 | mTopLayout = 0; |
261 | mPaintWidget = 0; | 263 | mPaintWidget = 0; |
262 | mXOffset = 0; | 264 | mXOffset = 0; |
263 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 265 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
264 | else mPixmap = SmallIcon("1downarrow"); | 266 | else mPixmap = SmallIcon("1downarrow"); |
265 | mEnabled.resize(mColumns); | 267 | mEnabled.resize(mColumns); |
266 | if (mLocation == Top) | 268 | if (mLocation == Top) |
267 | setMaximumHeight(0); | 269 | setMaximumHeight(0); |
268 | else | 270 | else |
269 | setMinimumHeight(mPixmap.height()); | 271 | setMinimumHeight(mPixmap.height()); |
270 | } | 272 | } |
271 | 273 | ||
272 | EventIndicator::~EventIndicator() | 274 | EventIndicator::~EventIndicator() |
273 | { | 275 | { |
274 | } | 276 | } |
275 | 277 | ||
276 | void EventIndicator::drawContents(QPainter *p) | 278 | void EventIndicator::drawContents(QPainter *p) |
277 | { | 279 | { |
278 | 280 | ||
279 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 281 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
280 | KDGanttSplitterHandle* han = 0; | 282 | KDGanttSplitterHandle* han = 0; |
281 | if ( mPaintWidget ) | 283 | if ( mPaintWidget ) |
282 | han = mPaintWidget->firstHandle(); | 284 | han = mPaintWidget->firstHandle(); |
283 | if ( ! han ) { | 285 | if ( ! han ) { |
284 | int i; | 286 | int i; |
285 | for(i=0;i<mColumns;++i) { | 287 | for(i=0;i<mColumns;++i) { |
286 | if (mEnabled[i]) { | 288 | if (mEnabled[i]) { |
287 | int cellWidth = contentsRect().right()/mColumns; | 289 | int cellWidth = contentsRect().right()/mColumns; |
288 | int xOffset = KOGlobals::self()->reverseLayout() ? | 290 | int xOffset = KOGlobals::self()->reverseLayout() ? |
289 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 291 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
290 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 292 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
291 | p->drawPixmap(QPoint(xOffset,0),mPixmap); | 293 | p->drawPixmap(QPoint(xOffset,0),mPixmap); |
292 | } | 294 | } |
293 | } | 295 | } |
294 | } else { | 296 | } else { |
295 | han->repaint(); | 297 | han->repaint(); |
296 | //mPaintWidget->setBackgroundColor( red ); | 298 | //mPaintWidget->setBackgroundColor( red ); |
297 | 299 | ||
298 | QPainter pa( han ); | 300 | QPainter pa( han ); |
299 | int i; | 301 | int i; |
300 | bool setColor = false; | 302 | bool setColor = false; |
301 | for(i=0;i<mColumns;++i) { | 303 | for(i=0;i<mColumns;++i) { |
302 | if (mEnabled[i]) { | 304 | if (mEnabled[i]) { |
303 | setColor = true; | 305 | setColor = true; |
304 | 306 | ||
305 | int cellWidth = contentsRect().right()/mColumns; | 307 | int cellWidth = contentsRect().right()/mColumns; |
306 | int xOffset = KOGlobals::self()->reverseLayout() ? | 308 | int xOffset = KOGlobals::self()->reverseLayout() ? |
307 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 309 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
308 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 310 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
309 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 311 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
310 | //qDebug("222draw pix %d ",xOffset ); | 312 | //qDebug("222draw pix %d ",xOffset ); |
311 | 313 | ||
312 | } | 314 | } |
313 | 315 | ||
314 | } | 316 | } |
315 | pa.end(); | 317 | pa.end(); |
316 | 318 | ||
317 | } | 319 | } |
318 | } | 320 | } |
319 | 321 | ||
320 | void EventIndicator::setXOffset( int x ) | 322 | void EventIndicator::setXOffset( int x ) |
321 | { | 323 | { |
322 | mXOffset = x; | 324 | mXOffset = x; |
323 | } | 325 | } |
324 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 326 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
325 | { | 327 | { |
326 | mPaintWidget = w; | 328 | mPaintWidget = w; |
327 | } | 329 | } |
328 | void EventIndicator::changeColumns(int columns) | 330 | void EventIndicator::changeColumns(int columns) |
329 | { | 331 | { |
330 | mColumns = columns; | 332 | mColumns = columns; |
331 | mEnabled.resize(mColumns); | 333 | mEnabled.resize(mColumns); |
332 | 334 | ||
333 | update(); | 335 | update(); |
334 | } | 336 | } |
335 | 337 | ||
336 | void EventIndicator::enableColumn(int column, bool enable) | 338 | void EventIndicator::enableColumn(int column, bool enable) |
337 | { | 339 | { |
338 | mEnabled[column] = enable; | 340 | mEnabled[column] = enable; |
339 | } | 341 | } |
340 | 342 | ||
341 | 343 | ||
342 | //////////////////////////////////////////////////////////////////////////// | 344 | //////////////////////////////////////////////////////////////////////////// |
343 | //////////////////////////////////////////////////////////////////////////// | 345 | //////////////////////////////////////////////////////////////////////////// |
344 | //////////////////////////////////////////////////////////////////////////// | 346 | //////////////////////////////////////////////////////////////////////////// |
345 | 347 | ||
346 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 348 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
347 | KOEventView (cal,parent,name) | 349 | KOEventView (cal,parent,name) |
348 | { | 350 | { |
349 | mBlockUpdating = true; | 351 | mBlockUpdating = true; |
350 | mStartHour = 8; | 352 | mStartHour = 8; |
351 | mSelectedDates.append(QDate::currentDate()); | 353 | mSelectedDates.append(QDate::currentDate()); |
352 | 354 | ||
353 | mLayoutDayLabels = 0; | 355 | mLayoutDayLabels = 0; |
354 | mDayLabelsFrame = 0; | 356 | mDayLabelsFrame = 0; |
355 | mDayLabels = 0; | 357 | mDayLabels = 0; |
356 | bool isRTL = KOGlobals::self()->reverseLayout(); | 358 | bool isRTL = KOGlobals::self()->reverseLayout(); |
357 | 359 | ||
358 | if ( KOPrefs::instance()->mVerticalScreen ) { | 360 | if ( KOPrefs::instance()->mVerticalScreen ) { |
359 | mExpandedPixmap = SmallIcon( "1downarrow" ); | 361 | mExpandedPixmap = SmallIcon( "1downarrow" ); |
360 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); | 362 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); |
361 | } else { | 363 | } else { |
362 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); | 364 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); |
363 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); | 365 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); |
364 | } | 366 | } |
365 | 367 | ||
366 | QBoxLayout *topLayout = new QVBoxLayout(this); | 368 | QBoxLayout *topLayout = new QVBoxLayout(this); |
367 | 369 | ||
368 | // Create day name labels for agenda columns | 370 | // Create day name labels for agenda columns |
369 | mDayLabelsFrame = new QHBox(this); | 371 | mDayLabelsFrame = new QHBox(this); |
370 | topLayout->addWidget(mDayLabelsFrame); | 372 | topLayout->addWidget(mDayLabelsFrame); |
371 | mDayLabels = new QFrame (mDayLabelsFrame); | 373 | mDayLabels = new QFrame (mDayLabelsFrame); |
372 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 374 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
373 | // Create agenda splitter | 375 | // Create agenda splitter |
374 | #ifndef KORG_NOSPLITTER | 376 | #ifndef KORG_NOSPLITTER |
375 | mSplitterAgenda = new QSplitter(Vertical,this); | 377 | mSplitterAgenda = new QSplitter(Vertical,this); |
376 | topLayout->addWidget(mSplitterAgenda); | 378 | topLayout->addWidget(mSplitterAgenda); |
377 | mSplitterAgenda->setOpaqueResize(); | 379 | mSplitterAgenda->setOpaqueResize(); |
378 | 380 | ||
379 | mAllDayFrame = new QHBox(mSplitterAgenda); | 381 | mAllDayFrame = new QHBox(mSplitterAgenda); |
380 | 382 | ||
381 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 383 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
382 | #else | 384 | #else |
383 | #if 0 | 385 | #if 0 |
384 | QWidget *mainBox = new QWidget( this ); | 386 | QWidget *mainBox = new QWidget( this ); |
385 | topLayout->addWidget( mainBox ); | 387 | topLayout->addWidget( mainBox ); |
386 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); | 388 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); |
387 | mAllDayFrame = new QHBox(mainBox); | 389 | mAllDayFrame = new QHBox(mainBox); |
388 | mainLayout->addWidget(mAllDayFrame); | 390 | mainLayout->addWidget(mAllDayFrame); |
389 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); | 391 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); |
390 | mAllDayFrame->setFocusPolicy(NoFocus); | 392 | mAllDayFrame->setFocusPolicy(NoFocus); |
391 | QWidget *agendaFrame = new QWidget(mainBox); | 393 | QWidget *agendaFrame = new QWidget(mainBox); |
392 | mainLayout->addWidget(agendaFrame); | 394 | mainLayout->addWidget(agendaFrame); |
393 | mainLayout->setStretchFactor( agendaFrame, 10 ); | 395 | mainLayout->setStretchFactor( agendaFrame, 10 ); |
394 | 396 | ||
395 | agendaFrame->setFocusPolicy(NoFocus); | 397 | agendaFrame->setFocusPolicy(NoFocus); |
396 | #endif | 398 | #endif |
397 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 399 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
398 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 400 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
399 | topLayout->addWidget( mSplitterAgenda ); | 401 | topLayout->addWidget( mSplitterAgenda ); |
400 | mAllDayFrame = new QHBox(mSplitterAgenda); | 402 | mAllDayFrame = new QHBox(mSplitterAgenda); |
401 | mAllDayFrame->setFocusPolicy(NoFocus); | 403 | mAllDayFrame->setFocusPolicy(NoFocus); |
402 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 404 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
403 | agendaFrame->setFocusPolicy(NoFocus); | 405 | agendaFrame->setFocusPolicy(NoFocus); |
404 | 406 | ||
405 | #endif | 407 | #endif |
406 | 408 | ||
407 | // Create all-day agenda widget | 409 | // Create all-day agenda widget |
408 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 410 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
409 | 411 | ||
410 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 412 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
411 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 413 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
412 | int widebut = mExpandButton->sizeHint().width(); | 414 | int widebut = mExpandButton->sizeHint().width(); |
413 | if ( QApplication::desktop()->width() < 480 ) | 415 | if ( QApplication::desktop()->width() < 480 ) |
414 | widebut = widebut*2; | 416 | widebut = widebut*2; |
415 | else | 417 | else |
416 | widebut = (widebut*3) / 2; | 418 | widebut = (widebut*3) / 2; |
417 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 419 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
418 | // QSizePolicy::Fixed ) ); | 420 | // QSizePolicy::Fixed ) ); |
419 | mExpandButton->setFixedSize( widebut, widebut); | 421 | mExpandButton->setFixedSize( widebut, widebut); |
420 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 422 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
421 | mExpandButton->setFocusPolicy(NoFocus); | 423 | mExpandButton->setFocusPolicy(NoFocus); |
422 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 424 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
423 | mAllDayAgenda->setFocusPolicy(NoFocus); | 425 | mAllDayAgenda->setFocusPolicy(NoFocus); |
424 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); | 426 | QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); |
425 | 427 | ||
426 | // Create event context menu for all day agenda | 428 | // Create event context menu for all day agenda |
427 | mAllDayAgendaPopup = eventPopup(); | 429 | mAllDayAgendaPopup = eventPopup(); |
428 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 430 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
429 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 431 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
430 | 432 | ||
431 | // Create agenda frame | 433 | // Create agenda frame |
432 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 434 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
433 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 435 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
434 | 436 | ||
435 | // create event indicator bars | 437 | // create event indicator bars |
436 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 438 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
437 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 439 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
438 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 440 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
439 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 441 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
440 | agendaFrame); | 442 | agendaFrame); |
441 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 443 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
442 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 444 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
443 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 445 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
444 | 446 | ||
445 | // Create time labels | 447 | // Create time labels |
446 | mTimeLabels = new TimeLabels(24,agendaFrame); | 448 | mTimeLabels = new TimeLabels(24,agendaFrame); |
447 | agendaLayout->addWidget(mTimeLabels,1,0); | 449 | agendaLayout->addWidget(mTimeLabels,1,0); |
448 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 450 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
449 | this,SLOT(updateConfig())); | 451 | this,SLOT(updateConfig())); |
450 | 452 | ||
451 | // Create agenda | 453 | // Create agenda |
452 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 454 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
453 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 455 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
454 | agendaLayout->setColStretch(1,1); | 456 | agendaLayout->setColStretch(1,1); |
455 | mAgenda->setFocusPolicy(NoFocus); | 457 | mAgenda->setFocusPolicy(NoFocus); |
456 | // Create event context menu for agenda | 458 | // Create event context menu for agenda |
457 | mAgendaPopup = eventPopup(); | 459 | mAgendaPopup = eventPopup(); |
458 | 460 | ||
459 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 461 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
460 | i18n("Toggle Alarm"),mAgenda, | 462 | i18n("Toggle Alarm"),mAgenda, |
461 | SLOT(popupAlarm()),true); | 463 | SLOT(popupAlarm()),true); |
462 | 464 | ||
463 | 465 | ||
464 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 466 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
465 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 467 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
466 | 468 | ||
467 | // make connections between dependent widgets | 469 | // make connections between dependent widgets |
468 | mTimeLabels->setAgenda(mAgenda); | 470 | mTimeLabels->setAgenda(mAgenda); |
469 | 471 | ||
470 | // Update widgets to reflect user preferences | 472 | // Update widgets to reflect user preferences |
471 | // updateConfig(); | 473 | // updateConfig(); |
472 | 474 | ||
473 | // createDayLabels(); | 475 | // createDayLabels(); |
474 | 476 | ||
475 | // these blank widgets make the All Day Event box line up with the agenda | 477 | // these blank widgets make the All Day Event box line up with the agenda |
476 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 478 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
477 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 479 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
478 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 480 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
479 | 481 | ||
480 | // Scrolling | 482 | // Scrolling |
481 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 483 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index 221b0ea..3cf938f 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h | |||
@@ -1,257 +1,258 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 KOAGENDAVIEW_H | 23 | #ifndef KOAGENDAVIEW_H |
24 | #define KOAGENDAVIEW_H | 24 | #define KOAGENDAVIEW_H |
25 | 25 | ||
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef DESKTOP_VERSION | 29 | #ifndef DESKTOP_VERSION |
30 | #include <qksplitter.h> | 30 | #include <qksplitter.h> |
31 | #else | 31 | #else |
32 | #include <qsplitter.h> | 32 | #include <qsplitter.h> |
33 | #endif | 33 | #endif |
34 | #include <qmemarray.h> | 34 | #include <qmemarray.h> |
35 | 35 | ||
36 | #include "koeventview.h" | 36 | #include "koeventview.h" |
37 | 37 | ||
38 | 38 | ||
39 | class QHBox; | 39 | class QHBox; |
40 | class QFrame; | 40 | class QFrame; |
41 | class QLabel; | 41 | class QLabel; |
42 | class QPushButton; | 42 | class QPushButton; |
43 | class CalendarView; | 43 | class CalendarView; |
44 | class KOAgenda; | 44 | class KOAgenda; |
45 | class KOAgendaItem; | 45 | class KOAgendaItem; |
46 | class KConfig; | 46 | class KConfig; |
47 | class KDGanttMinimizeSplitter; | 47 | class KDGanttMinimizeSplitter; |
48 | class TimeLabels : public QScrollView { | 48 | class TimeLabels : public QScrollView { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); | 51 | TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); |
52 | 52 | ||
53 | void setCellHeight(int height); | 53 | void setCellHeight(int height); |
54 | 54 | ||
55 | /** Calculates the minimum width */ | 55 | /** Calculates the minimum width */ |
56 | virtual int minimumWidth() const; | 56 | virtual int minimumWidth() const; |
57 | 57 | ||
58 | /** updates widget's internal state */ | 58 | /** updates widget's internal state */ |
59 | void updateConfig(); | 59 | void updateConfig(); |
60 | 60 | ||
61 | /** */ | 61 | /** */ |
62 | void setAgenda(KOAgenda* agenda); | 62 | void setAgenda(KOAgenda* agenda); |
63 | 63 | ||
64 | /** */ | 64 | /** */ |
65 | virtual void paintEvent(QPaintEvent* e); | 65 | virtual void paintEvent(QPaintEvent* e); |
66 | void contentsMousePressEvent ( QMouseEvent * ) ; | 66 | void contentsMousePressEvent ( QMouseEvent * ) ; |
67 | void contentsMouseReleaseEvent ( QMouseEvent * ); | 67 | void contentsMouseReleaseEvent ( QMouseEvent * ); |
68 | void contentsMouseMoveEvent ( QMouseEvent * ); | 68 | void contentsMouseMoveEvent ( QMouseEvent * ); |
69 | 69 | ||
70 | public slots: | 70 | public slots: |
71 | /** update time label positions */ | 71 | /** update time label positions */ |
72 | void positionChanged(); | 72 | void positionChanged(); |
73 | signals: | 73 | signals: |
74 | void scaleChanged(); | 74 | void scaleChanged(); |
75 | protected: | 75 | protected: |
76 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 76 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
77 | 77 | ||
78 | private: | 78 | private: |
79 | int mMouseDownY; | 79 | int mMouseDownY; |
80 | QString mOrgCap; | ||
80 | int mRows; | 81 | int mRows; |
81 | int mCellHeight; | 82 | int mCellHeight; |
82 | 83 | ||
83 | /** */ | 84 | /** */ |
84 | KOAgenda* mAgenda; | 85 | KOAgenda* mAgenda; |
85 | }; | 86 | }; |
86 | 87 | ||
87 | class EventIndicator : public QFrame { | 88 | class EventIndicator : public QFrame { |
88 | Q_OBJECT | 89 | Q_OBJECT |
89 | public: | 90 | public: |
90 | enum Location { Top, Bottom }; | 91 | enum Location { Top, Bottom }; |
91 | EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); | 92 | EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); |
92 | virtual ~EventIndicator(); | 93 | virtual ~EventIndicator(); |
93 | 94 | ||
94 | void changeColumns(int columns); | 95 | void changeColumns(int columns); |
95 | void setPaintWidget( KDGanttMinimizeSplitter* ); | 96 | void setPaintWidget( KDGanttMinimizeSplitter* ); |
96 | void setXOffset( int ); | 97 | void setXOffset( int ); |
97 | void enableColumn(int column, bool enable); | 98 | void enableColumn(int column, bool enable); |
98 | 99 | ||
99 | protected: | 100 | protected: |
100 | void drawContents(QPainter *); | 101 | void drawContents(QPainter *); |
101 | 102 | ||
102 | private: | 103 | private: |
103 | int mXOffset; | 104 | int mXOffset; |
104 | KDGanttMinimizeSplitter* mPaintWidget; | 105 | KDGanttMinimizeSplitter* mPaintWidget; |
105 | int mColumns; | 106 | int mColumns; |
106 | QHBox *mTopBox; | 107 | QHBox *mTopBox; |
107 | QBoxLayout *mTopLayout; | 108 | QBoxLayout *mTopLayout; |
108 | Location mLocation; | 109 | Location mLocation; |
109 | QPixmap mPixmap; | 110 | QPixmap mPixmap; |
110 | QMemArray<bool> mEnabled; | 111 | QMemArray<bool> mEnabled; |
111 | }; | 112 | }; |
112 | 113 | ||
113 | /** | 114 | /** |
114 | KOAgendaView is the agenda-like view used to display events in an one or | 115 | KOAgendaView is the agenda-like view used to display events in an one or |
115 | multi-day view. | 116 | multi-day view. |
116 | */ | 117 | */ |
117 | class KOAgendaView : public KOEventView { | 118 | class KOAgendaView : public KOEventView { |
118 | Q_OBJECT | 119 | Q_OBJECT |
119 | public: | 120 | public: |
120 | KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); | 121 | KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); |
121 | virtual ~KOAgendaView(); | 122 | virtual ~KOAgendaView(); |
122 | void setStartHour( int ); | 123 | void setStartHour( int ); |
123 | void toggleAllDay(); | 124 | void toggleAllDay(); |
124 | 125 | ||
125 | 126 | ||
126 | /** Returns maximum number of days supported by the koagendaview */ | 127 | /** Returns maximum number of days supported by the koagendaview */ |
127 | virtual int maxDatesHint(); | 128 | virtual int maxDatesHint(); |
128 | 129 | ||
129 | /** Returns number of currently shown dates. */ | 130 | /** Returns number of currently shown dates. */ |
130 | virtual int currentDateCount(); | 131 | virtual int currentDateCount(); |
131 | 132 | ||
132 | /** returns the currently selected events */ | 133 | /** returns the currently selected events */ |
133 | virtual QPtrList<Incidence> selectedIncidences(); | 134 | virtual QPtrList<Incidence> selectedIncidences(); |
134 | 135 | ||
135 | /** returns the currently selected events */ | 136 | /** returns the currently selected events */ |
136 | virtual DateList selectedDates(); | 137 | virtual DateList selectedDates(); |
137 | 138 | ||
138 | /** Remove all events from view */ | 139 | /** Remove all events from view */ |
139 | void clearView(); | 140 | void clearView(); |
140 | KOAgenda *agenda() { return mAgenda;} | 141 | KOAgenda *agenda() { return mAgenda;} |
141 | virtual void printPreview(CalPrinter *calPrinter, | 142 | virtual void printPreview(CalPrinter *calPrinter, |
142 | const QDate &, const QDate &); | 143 | const QDate &, const QDate &); |
143 | 144 | ||
144 | /** start-datetime of selection */ | 145 | /** start-datetime of selection */ |
145 | QDateTime selectionStart() {return mTimeSpanBegin;} | 146 | QDateTime selectionStart() {return mTimeSpanBegin;} |
146 | /** end-datetime of selection */ | 147 | /** end-datetime of selection */ |
147 | QDateTime selectionEnd() {return mTimeSpanEnd;} | 148 | QDateTime selectionEnd() {return mTimeSpanEnd;} |
148 | /** returns true if selection is for whole day */ | 149 | /** returns true if selection is for whole day */ |
149 | bool selectedIsAllDay() {return mTimeSpanInAllDay;} | 150 | bool selectedIsAllDay() {return mTimeSpanInAllDay;} |
150 | /** make selected start/end invalid */ | 151 | /** make selected start/end invalid */ |
151 | void deleteSelectedDateTime(); | 152 | void deleteSelectedDateTime(); |
152 | void repaintAgenda(); | 153 | void repaintAgenda(); |
153 | public slots: | 154 | public slots: |
154 | virtual void updateView(); | 155 | virtual void updateView(); |
155 | virtual void updateConfig(); | 156 | virtual void updateConfig(); |
156 | virtual void showDates(const QDate &start, const QDate &end); | 157 | virtual void showDates(const QDate &start, const QDate &end); |
157 | virtual void showEvents(QPtrList<Event> eventList); | 158 | virtual void showEvents(QPtrList<Event> eventList); |
158 | 159 | ||
159 | void updateTodo( Todo *, int ); | 160 | void updateTodo( Todo *, int ); |
160 | void changeEventDisplay(Event *, int); | 161 | void changeEventDisplay(Event *, int); |
161 | 162 | ||
162 | void clearSelection(); | 163 | void clearSelection(); |
163 | 164 | ||
164 | void newEvent(int gx,int gy); | 165 | void newEvent(int gx,int gy); |
165 | void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); | 166 | void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); |
166 | void newEventAllDay(int gx, int gy); | 167 | void newEventAllDay(int gx, int gy); |
167 | 168 | ||
168 | void startDrag(Event *); | 169 | void startDrag(Event *); |
169 | 170 | ||
170 | void readSettings(); | 171 | void readSettings(); |
171 | void readSettings(KConfig *); | 172 | void readSettings(KConfig *); |
172 | void writeSettings(KConfig *); | 173 | void writeSettings(KConfig *); |
173 | 174 | ||
174 | void setContentsPos(int y); | 175 | void setContentsPos(int y); |
175 | 176 | ||
176 | void setExpandedButton( bool expanded ); | 177 | void setExpandedButton( bool expanded ); |
177 | void scrollOneHourUp(); | 178 | void scrollOneHourUp(); |
178 | void scrollOneHourDown(); | 179 | void scrollOneHourDown(); |
179 | void addToCalSlot(Incidence *, Incidence *); | 180 | void addToCalSlot(Incidence *, Incidence *); |
180 | 181 | ||
181 | signals: | 182 | signals: |
182 | void toggleExpand(); | 183 | void toggleExpand(); |
183 | void todoMoved( Todo *, int ); | 184 | void todoMoved( Todo *, int ); |
184 | void incidenceChanged(Incidence * , int ); | 185 | void incidenceChanged(Incidence * , int ); |
185 | // void cloneIncidenceSignal(Incidence *); | 186 | // void cloneIncidenceSignal(Incidence *); |
186 | 187 | ||
187 | protected: | 188 | protected: |
188 | bool mBlockUpdating; | 189 | bool mBlockUpdating; |
189 | int mUpcomingWidth; | 190 | int mUpcomingWidth; |
190 | /** Fill agenda beginning with date startDate */ | 191 | /** Fill agenda beginning with date startDate */ |
191 | void fillAgenda(const QDate &startDate); | 192 | void fillAgenda(const QDate &startDate); |
192 | void resizeEvent( QResizeEvent* e ); | 193 | void resizeEvent( QResizeEvent* e ); |
193 | /** Fill agenda using the current set value for the start date */ | 194 | /** Fill agenda using the current set value for the start date */ |
194 | void fillAgenda(); | 195 | void fillAgenda(); |
195 | 196 | ||
196 | /** Create labels for the selected dates. */ | 197 | /** Create labels for the selected dates. */ |
197 | void createDayLabels(); | 198 | void createDayLabels(); |
198 | 199 | ||
199 | /** | 200 | /** |
200 | Set the masks on the agenda widgets indicating, which days are holidays. | 201 | Set the masks on the agenda widgets indicating, which days are holidays. |
201 | */ | 202 | */ |
202 | void setHolidayMasks(); | 203 | void setHolidayMasks(); |
203 | 204 | ||
204 | protected slots: | 205 | protected slots: |
205 | /** Update event belonging to agenda item */ | 206 | /** Update event belonging to agenda item */ |
206 | void updateEventDates(KOAgendaItem *item, int mode = -1); | 207 | void updateEventDates(KOAgendaItem *item, int mode = -1); |
207 | //void updateMovedTodo(); | 208 | //void updateMovedTodo(); |
208 | 209 | ||
209 | void updateEventIndicatorTop(int newY); | 210 | void updateEventIndicatorTop(int newY); |
210 | void updateEventIndicatorBottom(int newY); | 211 | void updateEventIndicatorBottom(int newY); |
211 | 212 | ||
212 | /** Updates data for selected timespan */ | 213 | /** Updates data for selected timespan */ |
213 | void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); | 214 | void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); |
214 | /** Updates data for selected timespan for all day event*/ | 215 | /** Updates data for selected timespan for all day event*/ |
215 | void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); | 216 | void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); |
216 | 217 | ||
217 | private: | 218 | private: |
218 | // view widgets | 219 | // view widgets |
219 | QFrame *mDayLabels; | 220 | QFrame *mDayLabels; |
220 | QHBox *mDayLabelsFrame; | 221 | QHBox *mDayLabelsFrame; |
221 | QBoxLayout *mLayoutDayLabels; | 222 | QBoxLayout *mLayoutDayLabels; |
222 | QFrame *mAllDayFrame; | 223 | QFrame *mAllDayFrame; |
223 | KOAgenda *mAllDayAgenda; | 224 | KOAgenda *mAllDayAgenda; |
224 | KOAgenda *mAgenda; | 225 | KOAgenda *mAgenda; |
225 | TimeLabels *mTimeLabels; | 226 | TimeLabels *mTimeLabels; |
226 | QWidget *mDummyAllDayLeft; | 227 | QWidget *mDummyAllDayLeft; |
227 | 228 | ||
228 | KDGanttMinimizeSplitter* mSplitterAgenda; | 229 | KDGanttMinimizeSplitter* mSplitterAgenda; |
229 | QPushButton *mExpandButton; | 230 | QPushButton *mExpandButton; |
230 | 231 | ||
231 | DateList mSelectedDates; // List of dates to be displayed | 232 | DateList mSelectedDates; // List of dates to be displayed |
232 | int mViewType; | 233 | int mViewType; |
233 | 234 | ||
234 | bool mWeekStartsMonday; | 235 | bool mWeekStartsMonday; |
235 | int mStartHour; | 236 | int mStartHour; |
236 | 237 | ||
237 | KOEventPopupMenu *mAgendaPopup; | 238 | KOEventPopupMenu *mAgendaPopup; |
238 | KOEventPopupMenu *mAllDayAgendaPopup; | 239 | KOEventPopupMenu *mAllDayAgendaPopup; |
239 | 240 | ||
240 | EventIndicator *mEventIndicatorTop; | 241 | EventIndicator *mEventIndicatorTop; |
241 | EventIndicator *mEventIndicatorBottom; | 242 | EventIndicator *mEventIndicatorBottom; |
242 | 243 | ||
243 | QMemArray<int> mMinY; | 244 | QMemArray<int> mMinY; |
244 | QMemArray<int> mMaxY; | 245 | QMemArray<int> mMaxY; |
245 | 246 | ||
246 | QMemArray<bool> mHolidayMask; | 247 | QMemArray<bool> mHolidayMask; |
247 | 248 | ||
248 | QPixmap mExpandedPixmap; | 249 | QPixmap mExpandedPixmap; |
249 | QPixmap mNotExpandedPixmap; | 250 | QPixmap mNotExpandedPixmap; |
250 | QPtrList<QLabel> mDayLabelsList; | 251 | QPtrList<QLabel> mDayLabelsList; |
251 | QDateTime mTimeSpanBegin; | 252 | QDateTime mTimeSpanBegin; |
252 | QDateTime mTimeSpanEnd; | 253 | QDateTime mTimeSpanEnd; |
253 | bool mTimeSpanInAllDay; | 254 | bool mTimeSpanInAllDay; |
254 | void keyPressEvent ( QKeyEvent * e ); | 255 | void keyPressEvent ( QKeyEvent * e ); |
255 | }; | 256 | }; |
256 | 257 | ||
257 | #endif // KOAGENDAVIEW_H | 258 | #endif // KOAGENDAVIEW_H |