summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-25 19:49:52 (UTC)
committer zautrix <zautrix>2005-03-25 19:49:52 (UTC)
commit4d93404e3453229e58c2ff9305beae131c9f1af9 (patch) (unidiff)
treeaa5a4664ba2de62fbfe8c43b23e906868da16e86
parentae440bf75e7f74f35f83d082de9c7a34d2d3c65d (diff)
downloadkdepimpi-4d93404e3453229e58c2ff9305beae131c9f1af9.zip
kdepimpi-4d93404e3453229e58c2ff9305beae131c9f1af9.tar.gz
kdepimpi-4d93404e3453229e58c2ff9305beae131c9f1af9.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index f287216..957ac52 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,908 +1,911 @@
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;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 mRows = rows; 84 mRows = rows;
85 85
86 setMinimumHeight( 20 ); 86 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 87 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 88
89 enableClipper(true); 89 enableClipper(true);
90 90
91 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
93 93
94 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
95 95
96 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
97} 97}
98 98
99void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
100{ 100{
101 mCellHeight = height; 101 mCellHeight = height;
102} 102}
103 103
104/* 104/*
105 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 109{
110 110
111 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
112 // return; 112 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 115 // code assumes the latter...
116 116
117 // now, for a workaround... 117 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 119 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
121 // end of workaround 121 // end of workaround
122 122
123 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
126 QString hour; 126 QString hour;
127 QString suffix; 127 QString suffix;
128 QString fullTime; 128 QString fullTime;
129 int tW = fm.width("24:00i"); 129 int tW = fm.width("24:00i");
130 int timeHeight = fm.height(); 130 int timeHeight = fm.height();
131 if ( timeHeight > mCellHeight ) 131 timeHeight -= (timeHeight/4-2);
132 timeHeight = mCellHeight-1;
133 int borderWidth = 5; 132 int borderWidth = 5;
134 QFont nFont = p->font(); 133 QFont nFont = p->font();
135 QFont sFont = nFont; 134 QFont sFont = nFont;
136 sFont.setPointSize( sFont.pointSize()/2+2 ); 135 sFont.setPointSize( sFont.pointSize()/2+2 );
137 if (!KGlobal::locale()->use12Clock()) 136 if (!KGlobal::locale()->use12Clock())
138 suffix = "00"; 137 suffix = "00";
139 QFontMetrics fmS( sFont ); 138 QFontMetrics fmS( sFont );
140 int sHei = fmS.height(); 139 int sHei = fmS.height();
140 if ( timeHeight > mCellHeight ) {
141 timeHeight = mCellHeight-1;
142 sHei -= 2;
143 }
141 144
142 while (y < cy + ch) { 145 while (y < cy + ch) {
143 p->drawLine(cx,y,cx+tW,y); 146 p->drawLine(cx,y,cx+tW,y);
144 hour.setNum(cell); 147 hour.setNum(cell);
145 148
146 // handle 24h and am/pm time formats 149 // handle 24h and am/pm time formats
147 if (KGlobal::locale()->use12Clock()) { 150 if (KGlobal::locale()->use12Clock()) {
148 if (cell > 11) suffix = "pm"; 151 if (cell > 11) suffix = "pm";
149 else 152 else
150 suffix = "am"; 153 suffix = "am";
151 if (cell == 0) hour.setNum(12); 154 if (cell == 0) hour.setNum(12);
152 if (cell > 12) hour.setNum(cell - 12); 155 if (cell > 12) hour.setNum(cell - 12);
153 } 156 }
154 157
155 // create string in format of "XX:XX" or "XXpm/am" 158 // create string in format of "XX:XX" or "XXpm/am"
156 fullTime = hour;// + suffix; 159 fullTime = hour;// + suffix;
157 160
158 // center and draw the time label 161 // center and draw the time label
159 int timeWidth = fm.width(fullTime+"i"); 162 int timeWidth = fm.width(fullTime+"i");
160 int tw2 = fm.width(suffix); 163 int tw2 = fm.width(suffix);
161 int offset = this->width() - timeWidth - tw2; 164 int offset = this->width() - timeWidth - tw2;
162 p->setFont( nFont ); 165 p->setFont( nFont );
163 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); 166 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime);
164 p->setFont( sFont ); 167 p->setFont( sFont );
165 offset += timeWidth; 168 offset += timeWidth;
166 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 169 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
167 170
168 // increment indices 171 // increment indices
169 y += mCellHeight; 172 y += mCellHeight;
170 cell++; 173 cell++;
171 } 174 }
172} 175}
173 176
174/** 177/**
175 Calculates the minimum width. 178 Calculates the minimum width.
176*/ 179*/
177int TimeLabels::minimumWidth() const 180int TimeLabels::minimumWidth() const
178{ 181{
179 QFontMetrics fm = fontMetrics(); 182 QFontMetrics fm = fontMetrics();
180 183
181 //TODO: calculate this value 184 //TODO: calculate this value
182 int borderWidth = 4; 185 int borderWidth = 4;
183 186
184 // the maximum width possible 187 // the maximum width possible
185 int width = fm.width("88:88x") + borderWidth; 188 int width = fm.width("88:88x") + borderWidth;
186 189
187 return width; 190 return width;
188} 191}
189 192
190/** updates widget's internal state */ 193/** updates widget's internal state */
191void TimeLabels::updateConfig() 194void TimeLabels::updateConfig()
192{ 195{
193 // set the font 196 // set the font
194 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
195 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
196 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
197 200
198 // update geometry restrictions based on new settings 201 // update geometry restrictions based on new settings
199 setFixedWidth(minimumWidth()); 202 setFixedWidth(minimumWidth());
200 203
201 // update HourSize 204 // update HourSize
202 mCellHeight = KOPrefs::instance()->mHourSize*4; 205 mCellHeight = KOPrefs::instance()->mHourSize*4;
203 resizeContents(50,mRows * mCellHeight); 206 resizeContents(50,mRows * mCellHeight);
204} 207}
205 208
206/** update time label positions */ 209/** update time label positions */
207void TimeLabels::positionChanged() 210void TimeLabels::positionChanged()
208{ 211{
209 int adjustment = mAgenda->contentsY(); 212 int adjustment = mAgenda->contentsY();
210 setContentsPos(0, adjustment); 213 setContentsPos(0, adjustment);
211} 214}
212 215
213/** */ 216/** */
214void TimeLabels::setAgenda(KOAgenda* agenda) 217void TimeLabels::setAgenda(KOAgenda* agenda)
215{ 218{
216 mAgenda = agenda; 219 mAgenda = agenda;
217} 220}
218 221
219void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 222void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
220{ 223{
221 mMouseDownY = e->pos().y(); 224 mMouseDownY = e->pos().y();
222 mOrgCap = topLevelWidget()->caption(); 225 mOrgCap = topLevelWidget()->caption();
223} 226}
224 227
225void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 228void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
226{ 229{
227 int diff = mMouseDownY - e->pos().y(); 230 int diff = mMouseDownY - e->pos().y();
228 if ( diff < 10 && diff > -10 ) 231 if ( diff < 10 && diff > -10 )
229 return; 232 return;
230 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 233 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
231 if ( tSize < 4 ) 234 if ( tSize < 4 )
232 tSize = 4; 235 tSize = 4;
233 if ( tSize > 22 ) 236 if ( tSize > 22 )
234 tSize = 22; 237 tSize = 22;
235 tSize = (tSize-2)/2; 238 tSize = (tSize-2)/2;
236 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 239 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
237 240
238} 241}
239void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 242void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
240{ 243{
241 topLevelWidget()->setCaption( mOrgCap ); 244 topLevelWidget()->setCaption( mOrgCap );
242 int diff = mMouseDownY - e->pos().y(); 245 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 246 if ( diff < 10 && diff > -10 )
244 return; 247 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 248 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
246 if ( tSize < 4 ) 249 if ( tSize < 4 )
247 tSize = 4; 250 tSize = 4;
248 if ( tSize > 22 ) 251 if ( tSize > 22 )
249 tSize = 22; 252 tSize = 22;
250 tSize = (tSize/2)*2; 253 tSize = (tSize/2)*2;
251 if ( tSize == KOPrefs::instance()->mHourSize ) 254 if ( tSize == KOPrefs::instance()->mHourSize )
252 return; 255 return;
253 KOPrefs::instance()->mHourSize = tSize; 256 KOPrefs::instance()->mHourSize = tSize;
254 emit scaleChanged(); 257 emit scaleChanged();
255} 258}
256 259
257/** This is called in response to repaint() */ 260/** This is called in response to repaint() */
258void TimeLabels::paintEvent(QPaintEvent*) 261void TimeLabels::paintEvent(QPaintEvent*)
259{ 262{
260 263
261 // kdDebug() << "paintevent..." << endl; 264 // kdDebug() << "paintevent..." << endl;
262 // this is another hack! 265 // this is another hack!
263 // QPainter painter(this); 266 // QPainter painter(this);
264 //QString c 267 //QString c
265 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 268 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
266} 269}
267 270
268//////////////////////////////////////////////////////////////////////////// 271////////////////////////////////////////////////////////////////////////////
269 272
270EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 273EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
271 : QFrame(parent,name) 274 : QFrame(parent,name)
272{ 275{
273 mColumns = 1; 276 mColumns = 1;
274 mTopBox = 0; 277 mTopBox = 0;
275 mLocation = loc; 278 mLocation = loc;
276 mTopLayout = 0; 279 mTopLayout = 0;
277 mPaintWidget = 0; 280 mPaintWidget = 0;
278 mXOffset = 0; 281 mXOffset = 0;
279 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 282 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
280 else mPixmap = SmallIcon("1downarrow"); 283 else mPixmap = SmallIcon("1downarrow");
281 mEnabled.resize(mColumns); 284 mEnabled.resize(mColumns);
282 mEnabled.fill( false ); 285 mEnabled.fill( false );
283 setMinimumHeight(mPixmap.height()); 286 setMinimumHeight(mPixmap.height());
284} 287}
285 288
286EventIndicator::~EventIndicator() 289EventIndicator::~EventIndicator()
287{ 290{
288} 291}
289 292
290void EventIndicator::drawContents(QPainter *p) 293void EventIndicator::drawContents(QPainter *p)
291{ 294{
292 295
293 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 296 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
294 KDGanttSplitterHandle* han = 0; 297 KDGanttSplitterHandle* han = 0;
295 if ( mPaintWidget ) 298 if ( mPaintWidget )
296 han = mPaintWidget->firstHandle(); 299 han = mPaintWidget->firstHandle();
297 if ( ! han ) { 300 if ( ! han ) {
298 int i; 301 int i;
299 for(i=0;i<mColumns;++i) { 302 for(i=0;i<mColumns;++i) {
300 if (mEnabled[i]) { 303 if (mEnabled[i]) {
301 int cellWidth = contentsRect().right()/mColumns; 304 int cellWidth = contentsRect().right()/mColumns;
302 int xOffset = KOGlobals::self()->reverseLayout() ? 305 int xOffset = KOGlobals::self()->reverseLayout() ?
303 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 306 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
304 i*cellWidth + (cellWidth -mPixmap.width()) /2; 307 i*cellWidth + (cellWidth -mPixmap.width()) /2;
305 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 308 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
306 } 309 }
307 } 310 }
308 } else { 311 } else {
309 han->repaint(); 312 han->repaint();
310 //mPaintWidget->setBackgroundColor( red ); 313 //mPaintWidget->setBackgroundColor( red );
311 314
312 QPainter pa( han ); 315 QPainter pa( han );
313 int i; 316 int i;
314 bool setColor = false; 317 bool setColor = false;
315 for(i=0;i<mColumns;++i) { 318 for(i=0;i<mColumns;++i) {
316 if (mEnabled[i]) { 319 if (mEnabled[i]) {
317 setColor = true; 320 setColor = true;
318 321
319 int cellWidth = contentsRect().right()/mColumns; 322 int cellWidth = contentsRect().right()/mColumns;
320 int xOffset = KOGlobals::self()->reverseLayout() ? 323 int xOffset = KOGlobals::self()->reverseLayout() ?
321 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 324 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
322 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 325 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
323 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 326 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
324 //qDebug("222draw pix %d ",xOffset ); 327 //qDebug("222draw pix %d ",xOffset );
325 328
326 } 329 }
327 330
328 } 331 }
329 pa.end(); 332 pa.end();
330 333
331 } 334 }
332} 335}
333 336
334void EventIndicator::setXOffset( int x ) 337void EventIndicator::setXOffset( int x )
335{ 338{
336 mXOffset = x; 339 mXOffset = x;
337} 340}
338void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 341void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
339{ 342{
340 mPaintWidget = w; 343 mPaintWidget = w;
341 setMaximumHeight(0); 344 setMaximumHeight(0);
342 setMinimumHeight(0); 345 setMinimumHeight(0);
343} 346}
344void EventIndicator::changeColumns(int columns) 347void EventIndicator::changeColumns(int columns)
345{ 348{
346 mColumns = columns; 349 mColumns = columns;
347 mEnabled.resize(mColumns); 350 mEnabled.resize(mColumns);
348 351
349 update(); 352 update();
350} 353}
351 354
352void EventIndicator::enableColumn(int column, bool enable) 355void EventIndicator::enableColumn(int column, bool enable)
353{ 356{
354 mEnabled[column] = enable; 357 mEnabled[column] = enable;
355} 358}
356 359
357 360
358//////////////////////////////////////////////////////////////////////////// 361////////////////////////////////////////////////////////////////////////////
359//////////////////////////////////////////////////////////////////////////// 362////////////////////////////////////////////////////////////////////////////
360//////////////////////////////////////////////////////////////////////////// 363////////////////////////////////////////////////////////////////////////////
361 364
362KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 365KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
363 KOEventView (cal,parent,name) 366 KOEventView (cal,parent,name)
364{ 367{
365 mBlockUpdating = true; 368 mBlockUpdating = true;
366 mStartHour = 8; 369 mStartHour = 8;
367 mSelectedDates.append(QDate::currentDate()); 370 mSelectedDates.append(QDate::currentDate());
368 371
369 mLayoutDayLabels = 0; 372 mLayoutDayLabels = 0;
370 mDayLabelsFrame = 0; 373 mDayLabelsFrame = 0;
371 mDayLabels = 0; 374 mDayLabels = 0;
372 bool isRTL = KOGlobals::self()->reverseLayout(); 375 bool isRTL = KOGlobals::self()->reverseLayout();
373 376
374 if ( KOPrefs::instance()->mVerticalScreen ) { 377 if ( KOPrefs::instance()->mVerticalScreen ) {
375 mExpandedPixmap = SmallIcon( "1downarrow" ); 378 mExpandedPixmap = SmallIcon( "1downarrow" );
376 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 379 mNotExpandedPixmap = SmallIcon( "1uparrow" );
377 } else { 380 } else {
378 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 381 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
379 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 382 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
380 } 383 }
381 384
382 QBoxLayout *topLayout = new QVBoxLayout(this); 385 QBoxLayout *topLayout = new QVBoxLayout(this);
383 386
384 // Create day name labels for agenda columns 387 // Create day name labels for agenda columns
385 // Create agenda splitter 388 // Create agenda splitter
386 389
387 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 390 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
388 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 391 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
389 topLayout->addWidget( mSplitterAgenda ); 392 topLayout->addWidget( mSplitterAgenda );
390 mAllDayFrame = new QHBox(mSplitterAgenda); 393 mAllDayFrame = new QHBox(mSplitterAgenda);
391 mAllDayFrame->setFocusPolicy(NoFocus); 394 mAllDayFrame->setFocusPolicy(NoFocus);
392 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 395 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
393 agendaFrame->setFocusPolicy(NoFocus); 396 agendaFrame->setFocusPolicy(NoFocus);
394 397
395 // Create all-day agenda widget 398 // Create all-day agenda widget
396 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 399 mDummyAllDayLeft = new QVBox( mAllDayFrame );
397 400
398 mExpandButton = new QPushButton(mDummyAllDayLeft); 401 mExpandButton = new QPushButton(mDummyAllDayLeft);
399 mExpandButton->setPixmap( mNotExpandedPixmap ); 402 mExpandButton->setPixmap( mNotExpandedPixmap );
400 int widebut = mExpandButton->sizeHint().width(); 403 int widebut = mExpandButton->sizeHint().width();
401 if ( QApplication::desktop()->width() < 480 ) 404 if ( QApplication::desktop()->width() < 480 )
402 widebut = widebut*2; 405 widebut = widebut*2;
403 else 406 else
404 widebut = (widebut*3) / 2; 407 widebut = (widebut*3) / 2;
405 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 408 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
406 // QSizePolicy::Fixed ) ); 409 // QSizePolicy::Fixed ) );
407 mExpandButton->setFixedSize( widebut, widebut); 410 mExpandButton->setFixedSize( widebut, widebut);
408 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 411 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
409 mExpandButton->setFocusPolicy(NoFocus); 412 mExpandButton->setFocusPolicy(NoFocus);
410 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 413 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
411 mAllDayAgenda->setFocusPolicy(NoFocus); 414 mAllDayAgenda->setFocusPolicy(NoFocus);
412 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 415 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
413 416
414 // Create event context menu for all day agenda 417 // Create event context menu for all day agenda
415 mAllDayAgendaPopup = eventPopup(); 418 mAllDayAgendaPopup = eventPopup();
416 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 419 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
417 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 420 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
418 421
419 // Create agenda frame 422 // Create agenda frame
420 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 423 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
421 // QHBox *agendaFrame = new QHBox(splitterAgenda); 424 // QHBox *agendaFrame = new QHBox(splitterAgenda);
422 425
423 // create event indicator bars 426 // create event indicator bars
424 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 427 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
425#ifndef DESKTOP_VERSION 428#ifndef DESKTOP_VERSION
426 // FIX 429 // FIX
427 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 430 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
428#endif 431#endif
429 mDayLabelsFrame = new QHBox(agendaFrame); 432 mDayLabelsFrame = new QHBox(agendaFrame);
430 //topLayout->addWidget(mDayLabelsFrame); 433 //topLayout->addWidget(mDayLabelsFrame);
431 mDayLabels = new QFrame (mDayLabelsFrame); 434 mDayLabels = new QFrame (mDayLabelsFrame);
432 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 435 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
433 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 436 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
434 agendaLayout->addWidget(mEventIndicatorTop,1,1); 437 agendaLayout->addWidget(mEventIndicatorTop,1,1);
435 438
436 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 439 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
437 agendaFrame); 440 agendaFrame);
438 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 441 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
439 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 442 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
440 agendaLayout->addWidget(dummyAgendaRight,1,2); 443 agendaLayout->addWidget(dummyAgendaRight,1,2);
441 444
442 // Create time labels 445 // Create time labels
443 mTimeLabels = new TimeLabels(24,agendaFrame); 446 mTimeLabels = new TimeLabels(24,agendaFrame);
444 agendaLayout->addWidget(mTimeLabels,2,0); 447 agendaLayout->addWidget(mTimeLabels,2,0);
445 connect(mTimeLabels,SIGNAL( scaleChanged()), 448 connect(mTimeLabels,SIGNAL( scaleChanged()),
446 this,SLOT(updateConfig())); 449 this,SLOT(updateConfig()));
447 450
448 // Create agenda 451 // Create agenda
449 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 452 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
450 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 453 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
451 agendaLayout->setColStretch(1,1); 454 agendaLayout->setColStretch(1,1);
452 mAgenda->setFocusPolicy(NoFocus); 455 mAgenda->setFocusPolicy(NoFocus);
453 // Create event context menu for agenda 456 // Create event context menu for agenda
454 mAgendaPopup = eventPopup(); 457 mAgendaPopup = eventPopup();
455 458
456 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 459 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
457 i18n("Toggle Alarm"),mAgenda, 460 i18n("Toggle Alarm"),mAgenda,
458 SLOT(popupAlarm()),true); 461 SLOT(popupAlarm()),true);
459 462
460 463
461 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 464 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
462 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 465 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
463 466
464 // make connections between dependent widgets 467 // make connections between dependent widgets
465 mTimeLabels->setAgenda(mAgenda); 468 mTimeLabels->setAgenda(mAgenda);
466 469
467 // Update widgets to reflect user preferences 470 // Update widgets to reflect user preferences
468 // updateConfig(); 471 // updateConfig();
469 472
470 // createDayLabels(); 473 // createDayLabels();
471 474
472 // these blank widgets make the All Day Event box line up with the agenda 475 // these blank widgets make the All Day Event box line up with the agenda
473 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 476 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
474 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 477 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
475 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 478 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
476 479
477 // Scrolling 480 // Scrolling
478 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 481 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
479 mTimeLabels, SLOT(positionChanged())); 482 mTimeLabels, SLOT(positionChanged()));
480 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 483 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
481 SLOT(setContentsPos(int))); 484 SLOT(setContentsPos(int)));
482 485
483 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 486 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
484 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 487 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
485 488
486 // Create/Show/Edit/Delete Event 489 // Create/Show/Edit/Delete Event
487 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 490 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
488 SLOT(newEvent(int,int))); 491 SLOT(newEvent(int,int)));
489 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 492 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
490 SLOT(newTodo(int,int))); 493 SLOT(newTodo(int,int)));
491 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 494 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
492 SLOT(newEvent(int,int,int,int))); 495 SLOT(newEvent(int,int,int,int)));
493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 496 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
494 SLOT(newEventAllDay(int,int))); 497 SLOT(newEventAllDay(int,int)));
495 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 498 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
496 SLOT(newTodoAllDay(int,int))); 499 SLOT(newTodoAllDay(int,int)));
497 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 500 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
498 SLOT(newEventAllDay(int,int))); 501 SLOT(newEventAllDay(int,int)));
499 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 502 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
500 SLOT(newTimeSpanSelected(int,int,int,int))); 503 SLOT(newTimeSpanSelected(int,int,int,int)));
501 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 504 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
502 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 505 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
503 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 506 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
504 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 507 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
505 508
506 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 509 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
507 SIGNAL(editIncidenceSignal(Incidence *))); 510 SIGNAL(editIncidenceSignal(Incidence *)));
508 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 511 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
509 SIGNAL(editIncidenceSignal(Incidence *))); 512 SIGNAL(editIncidenceSignal(Incidence *)));
510 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 513 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
511 SIGNAL(showIncidenceSignal(Incidence *))); 514 SIGNAL(showIncidenceSignal(Incidence *)));
512 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 515 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
513 SIGNAL(showIncidenceSignal(Incidence *))); 516 SIGNAL(showIncidenceSignal(Incidence *)));
514 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 517 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
515 SIGNAL(deleteIncidenceSignal(Incidence *))); 518 SIGNAL(deleteIncidenceSignal(Incidence *)));
516 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 519 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
517 SIGNAL(deleteIncidenceSignal(Incidence *))); 520 SIGNAL(deleteIncidenceSignal(Incidence *)));
518 521
519 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 522 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
520 SLOT(updateEventDates(KOAgendaItem *, int ))); 523 SLOT(updateEventDates(KOAgendaItem *, int )));
521 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 524 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
522 SLOT(updateEventDates(KOAgendaItem *, int))); 525 SLOT(updateEventDates(KOAgendaItem *, int)));
523 526
524 // event indicator update 527 // event indicator update
525 connect(mAgenda,SIGNAL(lowerYChanged(int)), 528 connect(mAgenda,SIGNAL(lowerYChanged(int)),
526 SLOT(updateEventIndicatorTop(int))); 529 SLOT(updateEventIndicatorTop(int)));
527 connect(mAgenda,SIGNAL(upperYChanged(int)), 530 connect(mAgenda,SIGNAL(upperYChanged(int)),
528 SLOT(updateEventIndicatorBottom(int))); 531 SLOT(updateEventIndicatorBottom(int)));
529 // drag signals 532 // drag signals
530 /* 533 /*
531 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 534 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
532 SLOT(startDrag(Event *))); 535 SLOT(startDrag(Event *)));
533 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 536 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
534 SLOT(startDrag(Event *))); 537 SLOT(startDrag(Event *)));
535 */ 538 */
536 // synchronize selections 539 // synchronize selections
537 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 540 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
538 mAllDayAgenda, SLOT( deselectItem() ) ); 541 mAllDayAgenda, SLOT( deselectItem() ) );
539 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 542 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
540 mAgenda, SLOT( deselectItem() ) ); 543 mAgenda, SLOT( deselectItem() ) );
541 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 544 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
542 SIGNAL( incidenceSelected( Incidence * ) ) ); 545 SIGNAL( incidenceSelected( Incidence * ) ) );
543 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 546 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
544 SIGNAL( incidenceSelected( Incidence * ) ) ); 547 SIGNAL( incidenceSelected( Incidence * ) ) );
545 connect( mAgenda, SIGNAL( resizedSignal() ), 548 connect( mAgenda, SIGNAL( resizedSignal() ),
546 SLOT( updateConfig( ) ) ); 549 SLOT( updateConfig( ) ) );
547 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 550 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
548 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 551 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
549 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 552 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
550 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 553 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
551 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 554 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
552 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 555 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
553 556
554 557
555} 558}
556 559
557void KOAgendaView::toggleAllDay() 560void KOAgendaView::toggleAllDay()
558{ 561{
559 if ( mSplitterAgenda->firstHandle() ) 562 if ( mSplitterAgenda->firstHandle() )
560 mSplitterAgenda->firstHandle()->toggle(); 563 mSplitterAgenda->firstHandle()->toggle();
561} 564}
562void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 565void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
563{ 566{
564 calendar()->addIncidence( inc ); 567 calendar()->addIncidence( inc );
565 568
566 if ( incOld ) { 569 if ( incOld ) {
567 if ( incOld->type() == "Todo" ) 570 if ( incOld->type() == "Todo" )
568 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 571 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
569 else 572 else
570 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 573 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
571 } 574 }
572 575
573} 576}
574 577
575KOAgendaView::~KOAgendaView() 578KOAgendaView::~KOAgendaView()
576{ 579{
577 delete mAgendaPopup; 580 delete mAgendaPopup;
578 delete mAllDayAgendaPopup; 581 delete mAllDayAgendaPopup;
579 delete KOAgendaItem::paintPix(); 582 delete KOAgendaItem::paintPix();
580 delete KOAgendaItem::paintPixSel(); 583 delete KOAgendaItem::paintPixSel();
581} 584}
582void KOAgendaView::resizeEvent( QResizeEvent* e ) 585void KOAgendaView::resizeEvent( QResizeEvent* e )
583{ 586{
584 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 587 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
585 bool uc = false; 588 bool uc = false;
586 int ow = e->oldSize().width(); 589 int ow = e->oldSize().width();
587 int oh = e->oldSize().height(); 590 int oh = e->oldSize().height();
588 int w = e->size().width(); 591 int w = e->size().width();
589 int h = e->size().height(); 592 int h = e->size().height();
590 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 593 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
591 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 594 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
592 uc = true; 595 uc = true;
593 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 596 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
594 } 597 }
595 mUpcomingWidth = e->size().width() ; 598 mUpcomingWidth = e->size().width() ;
596 if ( mBlockUpdating || uc ) { 599 if ( mBlockUpdating || uc ) {
597 mBlockUpdating = false; 600 mBlockUpdating = false;
598 //mAgenda->setMinimumSize(800 , 600 ); 601 //mAgenda->setMinimumSize(800 , 600 );
599 //qDebug("mAgenda->resize+++++++++++++++ "); 602 //qDebug("mAgenda->resize+++++++++++++++ ");
600 updateConfig(); 603 updateConfig();
601 //qDebug("KOAgendaView::Updating now possible "); 604 //qDebug("KOAgendaView::Updating now possible ");
602 } else 605 } else
603 createDayLabels(); 606 createDayLabels();
604 //qDebug("resizeEvent end "); 607 //qDebug("resizeEvent end ");
605 608
606} 609}
607void KOAgendaView::slotDaylabelClicked( int num ) 610void KOAgendaView::slotDaylabelClicked( int num )
608{ 611{
609 612
610 QDate firstDate = mSelectedDates.first(); 613 QDate firstDate = mSelectedDates.first();
611 if ( num == -1 ) 614 if ( num == -1 )
612 emit showDateView( 6, firstDate ); 615 emit showDateView( 6, firstDate );
613 else if (num >= 0 ) { 616 else if (num >= 0 ) {
614 if ( mSelectedDates.count() == 1) 617 if ( mSelectedDates.count() == 1)
615 emit showDateView( 9, firstDate.addDays( num ) ); 618 emit showDateView( 9, firstDate.addDays( num ) );
616 else 619 else
617 emit showDateView( 3, firstDate.addDays( num ) ); 620 emit showDateView( 3, firstDate.addDays( num ) );
618 } 621 }
619 else 622 else
620 showDateView( 10, firstDate.addDays(1) ); 623 showDateView( 10, firstDate.addDays(1) );
621} 624}
622 625
623KOAgendaButton* KOAgendaView::getNewDaylabel() 626KOAgendaButton* KOAgendaView::getNewDaylabel()
624{ 627{
625 628
626 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 629 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
627 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 630 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
628 mDayLabelsList.append( dayLabel ); 631 mDayLabelsList.append( dayLabel );
629 mLayoutDayLabels->addWidget(dayLabel); 632 mLayoutDayLabels->addWidget(dayLabel);
630 return dayLabel ; 633 return dayLabel ;
631} 634}
632 635
633void KOAgendaView::createDayLabels() 636void KOAgendaView::createDayLabels()
634{ 637{
635 638
636 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 639 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
637 // qDebug(" KOAgendaView::createDayLabels() blocked "); 640 // qDebug(" KOAgendaView::createDayLabels() blocked ");
638 return; 641 return;
639 642
640 } 643 }
641 int newHight; 644 int newHight;
642 645
643 // ### Before deleting and recreating we could check if mSelectedDates changed... 646 // ### Before deleting and recreating we could check if mSelectedDates changed...
644 // It would remove some flickering and gain speed (since this is called by 647 // It would remove some flickering and gain speed (since this is called by
645 // each updateView() call) 648 // each updateView() call)
646 649
647 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 650 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
648 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 651 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
649 if ( maxWid < 0 ) 652 if ( maxWid < 0 )
650 maxWid = 20; 653 maxWid = 20;
651 654
652 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 655 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
653 QFontMetrics fm ( dlf ); 656 QFontMetrics fm ( dlf );
654 int selCount = mSelectedDates.count(); 657 int selCount = mSelectedDates.count();
655 QString dayTest = "Mon 20"; 658 QString dayTest = "Mon 20";
656 //QString dayTest = "Mon 20"; 659 //QString dayTest = "Mon 20";
657 int wid = fm.width( dayTest ); 660 int wid = fm.width( dayTest );
658 //maxWid -= ( selCount * 3 ); //working for QLabels 661 //maxWid -= ( selCount * 3 ); //working for QLabels
659 maxWid -= ( selCount * 3 ); //working for QPushButton 662 maxWid -= ( selCount * 3 ); //working for QPushButton
660 if ( maxWid < 0 ) 663 if ( maxWid < 0 )
661 maxWid = 20; 664 maxWid = 20;
662 int needWid = wid * selCount; 665 int needWid = wid * selCount;
663 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 666 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
664 //if ( needWid > maxWid ) 667 //if ( needWid > maxWid )
665 // qDebug("DAYLABELS TOOOOOOO BIG "); 668 // qDebug("DAYLABELS TOOOOOOO BIG ");
666 while ( needWid > maxWid ) { 669 while ( needWid > maxWid ) {
667 dayTest = dayTest.left( dayTest.length() - 1 ); 670 dayTest = dayTest.left( dayTest.length() - 1 );
668 wid = fm.width( dayTest ); 671 wid = fm.width( dayTest );
669 needWid = wid * selCount; 672 needWid = wid * selCount;
670 } 673 }
671 int maxLen = dayTest.length(); 674 int maxLen = dayTest.length();
672 int fontPoint = dlf.pointSize(); 675 int fontPoint = dlf.pointSize();
673 if ( maxLen < 2 ) { 676 if ( maxLen < 2 ) {
674 int fontPoint = dlf.pointSize(); 677 int fontPoint = dlf.pointSize();
675 while ( fontPoint > 4 ) { 678 while ( fontPoint > 4 ) {
676 --fontPoint; 679 --fontPoint;
677 dlf.setPointSize( fontPoint ); 680 dlf.setPointSize( fontPoint );
678 QFontMetrics f( dlf ); 681 QFontMetrics f( dlf );
679 wid = f.width( "30" ); 682 wid = f.width( "30" );
680 needWid = wid * selCount; 683 needWid = wid * selCount;
681 if ( needWid < maxWid ) 684 if ( needWid < maxWid )
682 break; 685 break;
683 } 686 }
684 maxLen = 2; 687 maxLen = 2;
685 } 688 }
686 //qDebug("Max len %d ", dayTest.length() ); 689 //qDebug("Max len %d ", dayTest.length() );
687 690
688 QFontMetrics tempF( dlf ); 691 QFontMetrics tempF( dlf );
689 newHight = tempF.height(); 692 newHight = tempF.height();
690 mDayLabels->setFont( dlf ); 693 mDayLabels->setFont( dlf );
691 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 694 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
692 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 695 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
693 //mLayoutDayLabels->addSpacing( 2 ); 696 //mLayoutDayLabels->addSpacing( 2 );
694 // QFont lFont = dlf; 697 // QFont lFont = dlf;
695 bool appendLabels = false; 698 bool appendLabels = false;
696 KOAgendaButton *dayLabel; 699 KOAgendaButton *dayLabel;
697 dayLabel = mDayLabelsList.first(); 700 dayLabel = mDayLabelsList.first();
698 if ( !dayLabel ) { 701 if ( !dayLabel ) {
699 appendLabels = true; 702 appendLabels = true;
700 dayLabel = getNewDaylabel(); 703 dayLabel = getNewDaylabel();
701 } 704 }
702 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 705 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
703 dayLabel->setFont( dlf ); 706 dayLabel->setFont( dlf );
704 dayLabel->setNum( -1 ); 707 dayLabel->setNum( -1 );
705 //dayLabel->setAlignment(QLabel::AlignHCenter); 708 //dayLabel->setAlignment(QLabel::AlignHCenter);
706 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 709 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
707 dayLabel->show(); 710 dayLabel->show();
708 DateList::ConstIterator dit; 711 DateList::ConstIterator dit;
709 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 712 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
710 int counter = -1; 713 int counter = -1;
711 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 714 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
712 ++counter; 715 ++counter;
713 QDate date = *dit; 716 QDate date = *dit;
714 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 717 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
715 if ( ! appendLabels ) { 718 if ( ! appendLabels ) {
716 dayLabel = mDayLabelsList.next(); 719 dayLabel = mDayLabelsList.next();
717 if ( !dayLabel ) 720 if ( !dayLabel )
718 appendLabels = true; 721 appendLabels = true;
719 } 722 }
720 if ( appendLabels ) { 723 if ( appendLabels ) {
721 dayLabel = getNewDaylabel(); 724 dayLabel = getNewDaylabel();
722 } 725 }
723 dayLabel->setMinimumWidth( 1 ); 726 dayLabel->setMinimumWidth( 1 );
724 dayLabel->setMaximumWidth( 10240 ); 727 dayLabel->setMaximumWidth( 10240 );
725 dayLabel->setFont( dlf ); 728 dayLabel->setFont( dlf );
726 dayLabel->show(); 729 dayLabel->show();
727 dayLabel->setNum( counter ); 730 dayLabel->setNum( counter );
728 QString str; 731 QString str;
729 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 732 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
730 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 733 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
731 switch ( maxLen ) { 734 switch ( maxLen ) {
732 case 2: 735 case 2:
733 str = QString::number( date.day() ); 736 str = QString::number( date.day() );
734 break; 737 break;
735 738
736 case 3: 739 case 3:
737 str = dayName.left( 1 ) +QString::number( date.day()); 740 str = dayName.left( 1 ) +QString::number( date.day());
738 741
739 break; 742 break;
740 case 4: 743 case 4:
741 str = dayName.left( 1 ) + " " +QString::number( date.day()); 744 str = dayName.left( 1 ) + " " +QString::number( date.day());
742 745
743 break; 746 break;
744 case 5: 747 case 5:
745 str = dayName.left( 2 ) + " " +QString::number( date.day()); 748 str = dayName.left( 2 ) + " " +QString::number( date.day());
746 749
747 break; 750 break;
748 case 6: 751 case 6:
749 str = dayName.left( 3 ) + " " +QString::number( date.day()); 752 str = dayName.left( 3 ) + " " +QString::number( date.day());
750 break; 753 break;
751 754
752 default: 755 default:
753 break; 756 break;
754 } 757 }
755 if ( oneday ) { 758 if ( oneday ) {
756 QString addString; 759 QString addString;
757 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 760 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
758 addString = i18n("Today"); 761 addString = i18n("Today");
759 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 762 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
760 addString = i18n("Tomorrow"); 763 addString = i18n("Tomorrow");
761 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 764 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
762 addString = i18n("Yesterday"); 765 addString = i18n("Yesterday");
763 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
764 addString = i18n("Day before yesterday"); 767 addString = i18n("Day before yesterday");
765 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
766 addString = i18n("Day after tomorrow"); 769 addString = i18n("Day after tomorrow");
767 if ( !addString.isEmpty() ) { 770 if ( !addString.isEmpty() ) {
768 str = addString+", " + str; 771 str = addString+", " + str;
769 } 772 }
770 } 773 }
771 dayLabel->setText(str); 774 dayLabel->setText(str);
772 //dayLabel->setAlignment(QLabel::AlignHCenter); 775 //dayLabel->setAlignment(QLabel::AlignHCenter);
773 if (date == QDate::currentDate()) { 776 if (date == QDate::currentDate()) {
774 QFont bFont = dlf; 777 QFont bFont = dlf;
775 bFont.setBold( true ); 778 bFont.setBold( true );
776 dayLabel->setFont(bFont); 779 dayLabel->setFont(bFont);
777 } 780 }
778 //dayLayout->addWidget(dayLabel); 781 //dayLayout->addWidget(dayLabel);
779 782
780#ifndef KORG_NOPLUGINS 783#ifndef KORG_NOPLUGINS
781 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 784 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
782 CalendarDecoration *it; 785 CalendarDecoration *it;
783 for(it = cds.first(); it; it = cds.next()) { 786 for(it = cds.first(); it; it = cds.next()) {
784 QString text = it->shortText( date ); 787 QString text = it->shortText( date );
785 if ( !text.isEmpty() ) { 788 if ( !text.isEmpty() ) {
786 QLabel *label = new QLabel(text,mDayLabels); 789 QLabel *label = new QLabel(text,mDayLabels);
787 label->setAlignment(AlignCenter); 790 label->setAlignment(AlignCenter);
788 dayLayout->addWidget(label); 791 dayLayout->addWidget(label);
789 } 792 }
790 } 793 }
791 794
792 for(it = cds.first(); it; it = cds.next()) { 795 for(it = cds.first(); it; it = cds.next()) {
793 QWidget *wid = it->smallWidget(mDayLabels,date); 796 QWidget *wid = it->smallWidget(mDayLabels,date);
794 if ( wid ) { 797 if ( wid ) {
795 // wid->setHeight(20); 798 // wid->setHeight(20);
796 dayLayout->addWidget(wid); 799 dayLayout->addWidget(wid);
797 } 800 }
798 } 801 }
799#endif 802#endif
800 } 803 }
801 if ( ! appendLabels ) { 804 if ( ! appendLabels ) {
802 dayLabel = mDayLabelsList.next(); 805 dayLabel = mDayLabelsList.next();
803 if ( !dayLabel ) 806 if ( !dayLabel )
804 appendLabels = true; 807 appendLabels = true;
805 } 808 }
806 if ( appendLabels ) { 809 if ( appendLabels ) {
807 dayLabel = getNewDaylabel(); 810 dayLabel = getNewDaylabel();
808 } 811 }
809 //dayLabel->hide();//test only 812 //dayLabel->hide();//test only
810 813
811 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 814 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
812 if ( offset < 0 ) offset = 0; 815 if ( offset < 0 ) offset = 0;
813 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 816 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
814 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 817 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
815 dayLabel->setFont( dlf ); 818 dayLabel->setFont( dlf );
816 dayLabel->show(); 819 dayLabel->show();
817 dayLabel->setNum( -2 ); 820 dayLabel->setNum( -2 );
818 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 821 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
819 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 822 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
820 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 823 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
821 if ( !appendLabels ) { 824 if ( !appendLabels ) {
822 dayLabel = mDayLabelsList.next(); 825 dayLabel = mDayLabelsList.next();
823 while ( dayLabel ) { 826 while ( dayLabel ) {
824 //qDebug("!dayLabel %d",dayLabel ); 827 //qDebug("!dayLabel %d",dayLabel );
825 dayLabel->hide(); 828 dayLabel->hide();
826 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
827 } 830 }
828 } 831 }
829 //mDayLabelsFrame->show(); 832 //mDayLabelsFrame->show();
830 //mDayLabels->show(); 833 //mDayLabels->show();
831 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 834 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
832 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 835 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
833 mDayLabelsFrame->setFixedHeight( newHight ); 836 mDayLabelsFrame->setFixedHeight( newHight );
834} 837}
835 838
836int KOAgendaView::maxDatesHint() 839int KOAgendaView::maxDatesHint()
837{ 840{
838 // Not sure about the max number of events, so return 0 for now. 841 // Not sure about the max number of events, so return 0 for now.
839 return 0; 842 return 0;
840} 843}
841 844
842int KOAgendaView::currentDateCount() 845int KOAgendaView::currentDateCount()
843{ 846{
844 return mSelectedDates.count(); 847 return mSelectedDates.count();
845} 848}
846 849
847QPtrList<Incidence> KOAgendaView::selectedIncidences() 850QPtrList<Incidence> KOAgendaView::selectedIncidences()
848{ 851{
849 QPtrList<Incidence> selected; 852 QPtrList<Incidence> selected;
850 Incidence *incidence; 853 Incidence *incidence;
851 854
852 incidence = mAgenda->selectedIncidence(); 855 incidence = mAgenda->selectedIncidence();
853 if (incidence) selected.append(incidence); 856 if (incidence) selected.append(incidence);
854 857
855 incidence = mAllDayAgenda->selectedIncidence(); 858 incidence = mAllDayAgenda->selectedIncidence();
856 if (incidence) selected.append(incidence); 859 if (incidence) selected.append(incidence);
857 860
858 return selected; 861 return selected;
859} 862}
860 863
861DateList KOAgendaView::selectedDates() 864DateList KOAgendaView::selectedDates()
862{ 865{
863 DateList selected; 866 DateList selected;
864 QDate qd; 867 QDate qd;
865 868
866 qd = mAgenda->selectedIncidenceDate(); 869 qd = mAgenda->selectedIncidenceDate();
867 if (qd.isValid()) selected.append(qd); 870 if (qd.isValid()) selected.append(qd);
868 871
869 qd = mAllDayAgenda->selectedIncidenceDate(); 872 qd = mAllDayAgenda->selectedIncidenceDate();
870 if (qd.isValid()) selected.append(qd); 873 if (qd.isValid()) selected.append(qd);
871 874
872 return selected; 875 return selected;
873} 876}
874 877
875 878
876void KOAgendaView::updateView() 879void KOAgendaView::updateView()
877{ 880{
878 if ( mBlockUpdating ) 881 if ( mBlockUpdating )
879 return; 882 return;
880 // kdDebug() << "KOAgendaView::updateView()" << endl; 883 // kdDebug() << "KOAgendaView::updateView()" << endl;
881 fillAgenda(); 884 fillAgenda();
882 885
883} 886}
884 887
885 888
886/* 889/*
887 Update configuration settings for the agenda view. This method is not 890 Update configuration settings for the agenda view. This method is not
888 complete. 891 complete.
889*/ 892*/
890void KOAgendaView::updateConfig() 893void KOAgendaView::updateConfig()
891{ 894{
892 if ( mBlockUpdating ) 895 if ( mBlockUpdating )
893 return; 896 return;
894 897
895 // update config for children 898 // update config for children
896 mTimeLabels->updateConfig(); 899 mTimeLabels->updateConfig();
897 mAgenda->storePosition(); 900 mAgenda->storePosition();
898 mAgenda->updateConfig(); 901 mAgenda->updateConfig();
899 mAllDayAgenda->updateConfig(); 902 mAllDayAgenda->updateConfig();
900 // widget synchronization 903 // widget synchronization
901 //TODO: find a better way, maybe signal/slot 904 //TODO: find a better way, maybe signal/slot
902 mTimeLabels->positionChanged(); 905 mTimeLabels->positionChanged();
903 906
904 // for some reason, this needs to be called explicitly 907 // for some reason, this needs to be called explicitly
905 mTimeLabels->repaint(); 908 mTimeLabels->repaint();
906 909
907 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 910 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
908 911