author | zautrix <zautrix> | 2005-03-25 19:49:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-25 19:49:52 (UTC) |
commit | 4d93404e3453229e58c2ff9305beae131c9f1af9 (patch) (unidiff) | |
tree | aa5a4664ba2de62fbfe8c43b23e906868da16e86 | |
parent | ae440bf75e7f74f35f83d082de9c7a34d2d3c65d (diff) | |
download | kdepimpi-4d93404e3453229e58c2ff9305beae131c9f1af9.zip kdepimpi-4d93404e3453229e58c2ff9305beae131c9f1af9.tar.gz kdepimpi-4d93404e3453229e58c2ff9305beae131c9f1af9.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagendaview.cpp | 7 |
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 | |||
@@ -83,106 +83,109 @@ TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags 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 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void 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 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void 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 | */ |
177 | int TimeLabels::minimumWidth() const | 180 | int 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 | } |