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
@@ -35,202 +35,205 @@
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));