summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b9c7dec..8001c8f 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -90,96 +90,98 @@ TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
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 = 2;
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
139 borderWidth = 0;
138 QFontMetrics fmS( sFont ); 140 QFontMetrics fmS( sFont );
139 int sHei = fmS.height(); 141 int sHei = fmS.height();
140 if ( timeHeight > mCellHeight ) { 142 if ( timeHeight > mCellHeight ) {
141 timeHeight = mCellHeight-1; 143 timeHeight = mCellHeight-1;
142 sHei -= 2; 144 sHei -= 2;
143 } 145 }
144 146
145 while (y < cy + ch) { 147 while (y < cy + ch) {
146 p->drawLine(cx,y,cx+tW,y); 148 p->drawLine(cx,y,cx+tW,y);
147 hour.setNum(cell); 149 hour.setNum(cell);
148 150
149 // handle 24h and am/pm time formats 151 // handle 24h and am/pm time formats
150 if (KGlobal::locale()->use12Clock()) { 152 if (KGlobal::locale()->use12Clock()) {
151 if (cell > 11) suffix = "pm"; 153 if (cell > 11) suffix = "pm";
152 else 154 else
153 suffix = "am"; 155 suffix = "am";
154 if (cell == 0) hour.setNum(12); 156 if (cell == 0) hour.setNum(12);
155 if (cell > 12) hour.setNum(cell - 12); 157 if (cell > 12) hour.setNum(cell - 12);
156 } 158 }
157 159
158 // create string in format of "XX:XX" or "XXpm/am" 160 // create string in format of "XX:XX" or "XXpm/am"
159 fullTime = hour;// + suffix; 161 fullTime = hour;// + suffix;
160 162
161 // center and draw the time label 163 // center and draw the time label
162 int timeWidth = fm.width(fullTime+"i"); 164 int timeWidth = fm.width(fullTime+"i");
163 int tw2 = fm.width(suffix); 165 int tw2 = fm.width(suffix);
164 int offset = this->width() - timeWidth - tw2; 166 int offset = this->width() - timeWidth - tw2;
165 p->setFont( nFont ); 167 p->setFont( nFont );
166 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); 168 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime);
167 p->setFont( sFont ); 169 p->setFont( sFont );
168 offset += timeWidth; 170 offset += timeWidth;
169 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 171 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
170 172
171 // increment indices 173 // increment indices
172 y += mCellHeight; 174 y += mCellHeight;
173 cell++; 175 cell++;
174 } 176 }
175} 177}
176 178
177/** 179/**
178 Calculates the minimum width. 180 Calculates the minimum width.
179*/ 181*/
180int TimeLabels::minimumWidth() const 182int TimeLabels::minimumWidth() const
181{ 183{
182 return mMiniWidth; 184 return mMiniWidth;
183} 185}
184 186
185/** updates widget's internal state */ 187/** updates widget's internal state */