summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-01 19:05:18 (UTC)
committer zautrix <zautrix>2005-04-01 19:05:18 (UTC)
commit1022d8763a5185c74d1fb1fba9857d6e3afd9ff5 (patch) (unidiff)
tree116b7ac7aef10e27c20ce30f3bae548ebde84da0
parentedc032c21ae3788d02a632ea8066e4ac5a4feedb (diff)
downloadkdepimpi-1022d8763a5185c74d1fb1fba9857d6e3afd9ff5.zip
kdepimpi-1022d8763a5185c74d1fb1fba9857d6e3afd9ff5.tar.gz
kdepimpi-1022d8763a5185c74d1fb1fba9857d6e3afd9ff5.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp30
-rw-r--r--korganizer/kodaymatrix.cpp4
2 files changed, 16 insertions, 18 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 072d464..99f547a 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -120,71 +120,67 @@ void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
120 // these two assignments fix the weird redraw bug 120 // these two assignments fix the weird redraw bug
121 mRedrawNeeded = true; 121 mRedrawNeeded = true;
122 if ( mRedrawNeeded ) { 122 if ( mRedrawNeeded ) {
123 cx = contentsX() + frameWidth()*2; 123 cx = contentsX() + frameWidth()*2;
124 cw = contentsWidth() ; 124 cw = contentsWidth() ;
125 // end of workaround 125 // end of workaround
126 126
127 int cell = ((int)(cy/mCellHeight)); 127 int cell = ((int)(cy/mCellHeight));
128 int y = cell * mCellHeight; 128 int y = cell * mCellHeight;
129 QFontMetrics fm = fontMetrics(); 129 QFontMetrics fm = fontMetrics();
130 QString hour; 130 QString hour;
131 QString suffix; 131 QString suffix;
132 int tW = fm.width("24:00i"); 132 int timeHeight = fm.ascent();
133 int timeHeight = fm.height();
134 //timeHeight -= (timeHeight/4-2);
135 int borderWidth = 0;
136 QFont nFont = p->font(); 133 QFont nFont = p->font();
137 134
138 if (!KGlobal::locale()->use12Clock()) 135 if (!KGlobal::locale()->use12Clock())
139 suffix = "00"; 136 suffix = "00";
140 else 137
141 borderWidth = 0;
142 if ( timeHeight > mCellHeight ) { 138 if ( timeHeight > mCellHeight ) {
143 timeHeight = mCellHeight-1; 139 timeHeight = mCellHeight-1;
144 int pointS = nFont.pointSize(); 140 int pointS = nFont.pointSize();
145 while ( pointS > 4 ) { 141 while ( pointS > 4 ) {
146 nFont.setPointSize( pointS ); 142 nFont.setPointSize( pointS );
147 fm = QFontMetrics( nFont ); 143 fm = QFontMetrics( nFont );
148 if ( fm.height() < mCellHeight ) 144 if ( fm.ascent() < mCellHeight )
149 break; 145 break;
150 -- pointS; 146 -- pointS;
151 } 147 }
152 fm = QFontMetrics( nFont ); 148 fm = QFontMetrics( nFont );
153 borderWidth = 4; 149 timeHeight = fm.ascent();
154 timeHeight = fm.height();
155 } 150 }
156 //timeHeight -= (timeHeight/4-2); 151 //timeHeight -= (timeHeight/4-2);
157 QFont sFont = nFont; 152 QFont sFont = nFont;
158 sFont.setPointSize( sFont.pointSize()/2+2 ); 153 sFont.setPointSize( sFont.pointSize()/2 );
159 QFontMetrics fmS( sFont ); 154 QFontMetrics fmS( sFont );
160 int sHei = fmS.height(); 155 int sHei = fmS.ascent() ;
161 //sHei -= (sHei/4-2); 156 //sHei -= (sHei/4-2);
162 int startW = this->width() - frameWidth()-1; 157 int startW = this->width() - 2*frameWidth()-1;
158 int tw2 = fmS.width(suffix);
163 while (y < cy + ch) { 159 while (y < cy + ch) {
164 p->drawLine(cx,y,cx+tW,y); 160 p->drawLine(cx,y,cw,y);
165 hour.setNum(cell); 161 hour.setNum(cell);
166 162
167 // handle 24h and am/pm time formats 163 // handle 24h and am/pm time formats
168 if (KGlobal::locale()->use12Clock()) { 164 if (KGlobal::locale()->use12Clock()) {
169 if (cell > 11) suffix = "pm"; 165 if (cell > 11) suffix = "pm";
170 else 166 else
171 suffix = "am"; 167 suffix = "am";
172 if (cell == 0) hour.setNum(12); 168 if (cell == 0) hour.setNum(12);
173 if (cell > 12) hour.setNum(cell - 12); 169 if (cell > 12) hour.setNum(cell - 12);
170 tw2 = fmS.width(suffix);
174 } 171 }
175 172
176 // center and draw the time label 173 // center and draw the time label
177 int timeWidth = fm.width(hour); 174 int timeWidth = fm.width(hour);
178 int tw2 = fm.width(suffix);
179 int offset = startW - timeWidth - tw2 ; 175 int offset = startW - timeWidth - tw2 ;
180 p->setFont( nFont ); 176 p->setFont( nFont );
181 p->drawText( offset, y+ timeHeight, hour); 177 p->drawText( offset, y+ timeHeight, hour);
182 p->setFont( sFont ); 178 p->setFont( sFont );
183 offset = startW - tw2+1; 179 offset = startW - tw2+1;
184 p->drawText( offset, y+ sHei, suffix); 180 p->drawText( offset, y+ sHei, suffix);
185 181
186 // increment indices 182 // increment indices
187 y += mCellHeight; 183 y += mCellHeight;
188 cell++; 184 cell++;
189 } 185 }
190 } else { 186 } else {
@@ -202,30 +198,30 @@ int TimeLabels::minimumWidth() const
202{ 198{
203 return mMiniWidth; 199 return mMiniWidth;
204} 200}
205 201
206/** updates widget's internal state */ 202/** updates widget's internal state */
207void TimeLabels::updateConfig() 203void TimeLabels::updateConfig()
208{ 204{
209 mRedrawNeeded = true; 205 mRedrawNeeded = true;
210 // set the font 206 // set the font
211 // config->setGroup("Fonts"); 207 // config->setGroup("Fonts");
212 // QFont font = config->readFontEntry("TimeBar Font"); 208 // QFont font = config->readFontEntry("TimeBar Font");
213 setFont(KOPrefs::instance()->mTimeBarFont); 209 setFont(KOPrefs::instance()->mTimeBarFont);
214 QString test = "88:88"; 210 QString test = "20oo";
215 if (KGlobal::locale()->use12Clock()) 211 if (KGlobal::locale()->use12Clock())
216 test += "i"; 212 test = "12mi";
217 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; 213 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ;
218 // update geometry restrictions based on new settings 214 // update geometry restrictions based on new settings
219 setFixedWidth(minimumWidth()); 215 setFixedWidth( mMiniWidth );
220 216
221 // update HourSize 217 // update HourSize
222 mCellHeight = KOPrefs::instance()->mHourSize*4; 218 mCellHeight = KOPrefs::instance()->mHourSize*4;
223 resizeContents(50,mRows * mCellHeight); 219 resizeContents(50,mRows * mCellHeight);
224} 220}
225 221
226/** update time label positions */ 222/** update time label positions */
227void TimeLabels::positionChanged() 223void TimeLabels::positionChanged()
228{ 224{
229 int adjustment = mAgenda->contentsY(); 225 int adjustment = mAgenda->contentsY();
230 setContentsPos(0, adjustment); 226 setContentsPos(0, adjustment);
231} 227}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c55f7d7..5b5703f 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -868,25 +868,27 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
868 int addCol = 0; 868 int addCol = 0;
869 int addRow = 0; 869 int addRow = 0;
870 if (rowModulo) { 870 if (rowModulo) {
871 if ( row >= 6 - rowModulo ) 871 if ( row >= 6 - rowModulo )
872 addRow = row - 5 + rowModulo; 872 addRow = row - 5 + rowModulo;
873 } 873 }
874 if ( colModulo ) { 874 if ( colModulo ) {
875 if ( col >= 7 - colModulo ) 875 if ( col >= 7 - colModulo )
876 addCol = col - 6 + colModulo-1; 876 addCol = col - 6 + colModulo-1;
877 } 877 }
878 878
879 addCol += 1; 879 addCol += 1;
880 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); 880 if ( row == 0 )
881 addRow = 1;
882 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
881 p.setPen(tmppen); 883 p.setPen(tmppen);
882 } 884 }
883 885
884 // if any events are on that day then draw it using a bold font 886 // if any events are on that day then draw it using a bold font
885 if ( eDays.testBit(i) ) { 887 if ( eDays.testBit(i) ) {
886 QFont myFont = font(); 888 QFont myFont = font();
887 myFont.setBold(true); 889 myFont.setBold(true);
888 p.setFont(myFont); 890 p.setFont(myFont);
889 } 891 }
890 892
891 // if it is a holiday then use the default holiday color 893 // if it is a holiday then use the default holiday color
892 if ( !mHolidays[i].isNull()) { 894 if ( !mHolidays[i].isNull()) {