summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-26 17:14:39 (UTC)
committer zautrix <zautrix>2005-03-26 17:14:39 (UTC)
commite3f00322eb77bd03250eb66a2574b640de9aebb4 (patch) (unidiff)
tree739bb7f27af3dead05659abbb27cafe4da671882
parentc692f6870157f428aebf1dfdab4fbb6e88699c31 (diff)
downloadkdepimpi-e3f00322eb77bd03250eb66a2574b640de9aebb4.zip
kdepimpi-e3f00322eb77bd03250eb66a2574b640de9aebb4.tar.gz
kdepimpi-e3f00322eb77bd03250eb66a2574b640de9aebb4.tar.bz2
fix
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,516 +1,516 @@
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 )));