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