summaryrefslogtreecommitdiffabout
Unidiff
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,524 +1,527 @@
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