author | zautrix <zautrix> | 2005-04-01 14:41:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-01 14:41:00 (UTC) |
commit | e5ec0ef6a256b96a758815ef861526f53d1ad7a5 (patch) (unidiff) | |
tree | 3fa188da9108c867c1437157731c7b7a3d4e641d /korganizer/koagendaview.cpp | |
parent | 93003b1f8348f112648d3cc20acb21b062220e21 (diff) | |
download | kdepimpi-e5ec0ef6a256b96a758815ef861526f53d1ad7a5.zip kdepimpi-e5ec0ef6a256b96a758815ef861526f53d1ad7a5.tar.gz kdepimpi-e5ec0ef6a256b96a758815ef861526f53d1ad7a5.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagendaview.cpp | 134 |
1 files changed, 72 insertions, 62 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 2996acb..218396d 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -72,26 +72,28 @@ | |||
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | myPix.resize( 1, 1 ); | ||
84 | mRows = rows; | 85 | mRows = rows; |
85 | 86 | ||
87 | mRedrawNeeded = true; | ||
86 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
87 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
88 | 90 | ||
89 | enableClipper(true); | 91 | enableClipper(true); |
90 | 92 | ||
91 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
92 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
93 | 95 | ||
94 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
95 | 97 | ||
96 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
97 | } | 99 | } |
@@ -107,104 +109,112 @@ void TimeLabels::setCellHeight(int height) | |||
107 | */ | 109 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
109 | { | 111 | { |
110 | 112 | ||
111 | // if ( globalFlagBlockAgenda ) | 113 | // if ( globalFlagBlockAgenda ) |
112 | // return; | 114 | // return; |
113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 115 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
114 | // redrawn, not the area of the widget. unfortunately, this | 116 | // redrawn, not the area of the widget. unfortunately, this |
115 | // code assumes the latter... | 117 | // code assumes the latter... |
116 | 118 | ||
117 | // now, for a workaround... | 119 | // now, for a workaround... |
118 | // these two assignments fix the weird redraw bug | 120 | // these two assignments fix the weird redraw bug |
119 | cx = contentsX() + 2; | 121 | if ( mRedrawNeeded ) { |
120 | cw = contentsWidth() - 2; | 122 | cx = contentsX() + 2; |
121 | // end of workaround | 123 | cw = contentsWidth() - 2; |
122 | 124 | // end of workaround | |
123 | int cell = ((int)(cy/mCellHeight)); | 125 | |
124 | int y = cell * mCellHeight; | 126 | int cell = ((int)(cy/mCellHeight)); |
125 | QFontMetrics fm = fontMetrics(); | 127 | int y = cell * mCellHeight; |
126 | QString hour; | 128 | QFontMetrics fm = fontMetrics(); |
127 | QString suffix; | 129 | QString hour; |
128 | int tW = fm.width("24:00i"); | 130 | QString suffix; |
129 | int timeHeight = fm.height(); | 131 | int tW = fm.width("24:00i"); |
130 | //timeHeight -= (timeHeight/4-2); | 132 | int timeHeight = fm.height(); |
131 | int borderWidth = 0; | 133 | //timeHeight -= (timeHeight/4-2); |
132 | QFont nFont = p->font(); | 134 | int borderWidth = 0; |
135 | QFont nFont = p->font(); | ||
133 | 136 | ||
134 | if (!KGlobal::locale()->use12Clock()) | 137 | if (!KGlobal::locale()->use12Clock()) |
135 | suffix = "00"; | 138 | suffix = "00"; |
136 | else | 139 | else |
137 | borderWidth = 0; | 140 | borderWidth = 0; |
138 | if ( timeHeight > mCellHeight ) { | 141 | if ( timeHeight > mCellHeight ) { |
139 | timeHeight = mCellHeight-1; | 142 | timeHeight = mCellHeight-1; |
140 | int pointS = nFont.pointSize(); | 143 | int pointS = nFont.pointSize(); |
141 | while ( pointS > 4 ) { | 144 | while ( pointS > 4 ) { |
142 | nFont.setPointSize( pointS ); | 145 | nFont.setPointSize( pointS ); |
146 | fm = QFontMetrics( nFont ); | ||
147 | if ( fm.height() < mCellHeight ) | ||
148 | break; | ||
149 | -- pointS; | ||
150 | } | ||
143 | fm = QFontMetrics( nFont ); | 151 | fm = QFontMetrics( nFont ); |
144 | if ( fm.height() < mCellHeight ) | 152 | borderWidth = 4; |
145 | break; | 153 | timeHeight = fm.height(); |
146 | -- pointS; | ||
147 | } | ||
148 | fm = QFontMetrics( nFont ); | ||
149 | borderWidth = 4; | ||
150 | timeHeight = fm.height(); | ||
151 | } | ||
152 | timeHeight -= (timeHeight/4-2); | ||
153 | QFont sFont = nFont; | ||
154 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
155 | QFontMetrics fmS( sFont ); | ||
156 | int sHei = fmS.height(); | ||
157 | sHei -= (sHei/4-2); | ||
158 | int startW = this->width() - frameWidth(); | ||
159 | while (y < cy + ch) { | ||
160 | p->drawLine(cx,y,cx+tW,y); | ||
161 | hour.setNum(cell); | ||
162 | |||
163 | // handle 24h and am/pm time formats | ||
164 | if (KGlobal::locale()->use12Clock()) { | ||
165 | if (cell > 11) suffix = "pm"; | ||
166 | else | ||
167 | suffix = "am"; | ||
168 | if (cell == 0) hour.setNum(12); | ||
169 | if (cell > 12) hour.setNum(cell - 12); | ||
170 | } | 154 | } |
155 | timeHeight -= (timeHeight/4-2); | ||
156 | QFont sFont = nFont; | ||
157 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
158 | QFontMetrics fmS( sFont ); | ||
159 | int sHei = fmS.height(); | ||
160 | sHei -= (sHei/4-2); | ||
161 | int startW = this->width() - frameWidth(); | ||
162 | while (y < cy + ch) { | ||
163 | p->drawLine(cx,y,cx+tW,y); | ||
164 | hour.setNum(cell); | ||
165 | |||
166 | // handle 24h and am/pm time formats | ||
167 | if (KGlobal::locale()->use12Clock()) { | ||
168 | if (cell > 11) suffix = "pm"; | ||
169 | else | ||
170 | suffix = "am"; | ||
171 | if (cell == 0) hour.setNum(12); | ||
172 | if (cell > 12) hour.setNum(cell - 12); | ||
173 | } | ||
171 | 174 | ||
172 | // center and draw the time label | 175 | // center and draw the time label |
173 | int timeWidth = fm.width(hour+"i"); | 176 | int timeWidth = fm.width(hour+"i"); |
174 | int tw2 = fm.width(suffix); | 177 | int tw2 = fm.width(suffix); |
175 | int offset = startW - timeWidth - tw2 ; | 178 | int offset = startW - timeWidth - tw2 ; |
176 | p->setFont( nFont ); | 179 | p->setFont( nFont ); |
177 | p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); | 180 | p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); |
178 | p->setFont( sFont ); | 181 | p->setFont( sFont ); |
179 | offset = startW - tw2-1; | 182 | offset = startW - tw2-1; |
180 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 183 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); |
181 | 184 | ||
182 | // increment indices | 185 | // increment indices |
183 | y += mCellHeight; | 186 | y += mCellHeight; |
184 | cell++; | 187 | cell++; |
188 | } | ||
189 | } else { | ||
190 | //qDebug("NO redraw "); | ||
185 | } | 191 | } |
192 | // double buffer not yet implemented | ||
193 | //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | ||
194 | //mRedrawNeeded = false; | ||
186 | } | 195 | } |
187 | 196 | ||
188 | /** | 197 | /** |
189 | Calculates the minimum width. | 198 | Calculates the minimum width. |
190 | */ | 199 | */ |
191 | int TimeLabels::minimumWidth() const | 200 | int TimeLabels::minimumWidth() const |
192 | { | 201 | { |
193 | return mMiniWidth; | 202 | return mMiniWidth; |
194 | } | 203 | } |
195 | 204 | ||
196 | /** updates widget's internal state */ | 205 | /** updates widget's internal state */ |
197 | void TimeLabels::updateConfig() | 206 | void TimeLabels::updateConfig() |
198 | { | 207 | { |
208 | mRedrawNeeded = true; | ||
199 | // set the font | 209 | // set the font |
200 | // config->setGroup("Fonts"); | 210 | // config->setGroup("Fonts"); |
201 | // QFont font = config->readFontEntry("TimeBar Font"); | 211 | // QFont font = config->readFontEntry("TimeBar Font"); |
202 | setFont(KOPrefs::instance()->mTimeBarFont); | 212 | setFont(KOPrefs::instance()->mTimeBarFont); |
203 | QString test = "88:88"; | 213 | QString test = "88:88"; |
204 | if (KGlobal::locale()->use12Clock()) | 214 | if (KGlobal::locale()->use12Clock()) |
205 | test += "i"; | 215 | test += "i"; |
206 | mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; | 216 | mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; |
207 | // update geometry restrictions based on new settings | 217 | // update geometry restrictions based on new settings |
208 | setFixedWidth(minimumWidth()); | 218 | setFixedWidth(minimumWidth()); |
209 | 219 | ||
210 | // update HourSize | 220 | // update HourSize |