author | zautrix <zautrix> | 2005-03-26 17:14:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-26 17:14:39 (UTC) |
commit | e3f00322eb77bd03250eb66a2574b640de9aebb4 (patch) (unidiff) | |
tree | 739bb7f27af3dead05659abbb27cafe4da671882 | |
parent | c692f6870157f428aebf1dfdab4fbb6e88699c31 (diff) | |
download | kdepimpi-e3f00322eb77bd03250eb66a2574b640de9aebb4.zip kdepimpi-e3f00322eb77bd03250eb66a2574b640de9aebb4.tar.gz kdepimpi-e3f00322eb77bd03250eb66a2574b640de9aebb4.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagendaview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index acf43bd..a32333c 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -68,129 +68,129 @@ | |||
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; |
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 | 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 | timeHeight -= (timeHeight/4-2); | 131 | timeHeight -= (timeHeight/4-2); |
132 | int borderWidth = 2; | 132 | int borderWidth = 0; |
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 | 138 | else |
139 | borderWidth = 0; | 139 | borderWidth = 0; |
140 | QFontMetrics fmS( sFont ); | 140 | QFontMetrics fmS( sFont ); |
141 | int sHei = fmS.height(); | 141 | int sHei = fmS.height(); |
142 | if ( timeHeight > mCellHeight ) { | 142 | if ( timeHeight > mCellHeight ) { |
143 | timeHeight = mCellHeight-1; | 143 | timeHeight = mCellHeight-1; |
144 | sHei -= 2; | 144 | sHei -= 2; |
145 | } | 145 | } |
146 | 146 | ||
147 | while (y < cy + ch) { | 147 | while (y < cy + ch) { |
148 | p->drawLine(cx,y,cx+tW,y); | 148 | p->drawLine(cx,y,cx+tW,y); |
149 | hour.setNum(cell); | 149 | hour.setNum(cell); |
150 | 150 | ||
151 | // handle 24h and am/pm time formats | 151 | // handle 24h and am/pm time formats |
152 | if (KGlobal::locale()->use12Clock()) { | 152 | if (KGlobal::locale()->use12Clock()) { |
153 | if (cell > 11) suffix = "pm"; | 153 | if (cell > 11) suffix = "pm"; |
154 | else | 154 | else |
155 | suffix = "am"; | 155 | suffix = "am"; |
156 | if (cell == 0) hour.setNum(12); | 156 | if (cell == 0) hour.setNum(12); |
157 | if (cell > 12) hour.setNum(cell - 12); | 157 | if (cell > 12) hour.setNum(cell - 12); |
158 | } | 158 | } |
159 | 159 | ||
160 | // create string in format of "XX:XX" or "XXpm/am" | 160 | // create string in format of "XX:XX" or "XXpm/am" |
161 | fullTime = hour;// + suffix; | 161 | fullTime = hour;// + suffix; |
162 | 162 | ||
163 | // center and draw the time label | 163 | // center and draw the time label |
164 | int timeWidth = fm.width(fullTime+"i"); | 164 | int timeWidth = fm.width(fullTime+"i"); |
165 | int tw2 = fm.width(suffix); | 165 | int tw2 = fm.width(suffix); |
166 | int offset = this->width() - timeWidth - tw2; | 166 | int offset = this->width() - timeWidth - tw2; |
167 | p->setFont( nFont ); | 167 | p->setFont( nFont ); |
168 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); | 168 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); |
169 | p->setFont( sFont ); | 169 | p->setFont( sFont ); |
170 | offset += timeWidth; | 170 | offset += timeWidth; |
171 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 171 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); |
172 | 172 | ||
173 | // increment indices | 173 | // increment indices |
174 | y += mCellHeight; | 174 | y += mCellHeight; |
175 | cell++; | 175 | cell++; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | /** | 179 | /** |
180 | Calculates the minimum width. | 180 | Calculates the minimum width. |
181 | */ | 181 | */ |
182 | int TimeLabels::minimumWidth() const | 182 | int TimeLabels::minimumWidth() const |
183 | { | 183 | { |
184 | return mMiniWidth; | 184 | return mMiniWidth; |
185 | } | 185 | } |
186 | 186 | ||
187 | /** updates widget's internal state */ | 187 | /** updates widget's internal state */ |
188 | void TimeLabels::updateConfig() | 188 | void TimeLabels::updateConfig() |
189 | { | 189 | { |
190 | // set the font | 190 | // set the font |
191 | // config->setGroup("Fonts"); | 191 | // config->setGroup("Fonts"); |
192 | // QFont font = config->readFontEntry("TimeBar Font"); | 192 | // QFont font = config->readFontEntry("TimeBar Font"); |
193 | setFont(KOPrefs::instance()->mTimeBarFont); | 193 | setFont(KOPrefs::instance()->mTimeBarFont); |
194 | mMiniWidth = fontMetrics().width("88:88") + 2 ; | 194 | mMiniWidth = fontMetrics().width("88:88") + 2 ; |
195 | // update geometry restrictions based on new settings | 195 | // update geometry restrictions based on new settings |
196 | setFixedWidth(minimumWidth()); | 196 | setFixedWidth(minimumWidth()); |