author | zautrix <zautrix> | 2005-03-27 10:47:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-27 10:47:39 (UTC) |
commit | 1800cf5f3af1f666dddcbfffe3171adcd467ae3d (patch) (unidiff) | |
tree | 64b69e4bfbeacf5a036f027dd099c82c6c77e299 | |
parent | b170a7414ff72016285ea207caa7ccf786530e77 (diff) | |
download | kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.zip kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.tar.gz kdepimpi-1800cf5f3af1f666dddcbfffe3171adcd467ae3d.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/koagendaview.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index fa6b951..18f242c 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -3,271 +3,283 @@ | |||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
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 = 0; | 132 | int borderWidth = 0; |
133 | QFont nFont = p->font(); | 133 | QFont nFont = p->font(); |
134 | QFont sFont = nFont; | 134 | |
135 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
136 | if (!KGlobal::locale()->use12Clock()) | 135 | if (!KGlobal::locale()->use12Clock()) |
137 | suffix = "00"; | 136 | suffix = "00"; |
138 | else | 137 | else |
139 | borderWidth = 0; | 138 | borderWidth = 0; |
140 | QFontMetrics fmS( sFont ); | ||
141 | int sHei = fmS.height(); | ||
142 | if ( timeHeight > mCellHeight ) { | 139 | if ( timeHeight > mCellHeight ) { |
143 | timeHeight = mCellHeight-1; | 140 | timeHeight = mCellHeight-1; |
144 | sHei -= 2; | 141 | int pointS = nFont.pointSize(); |
142 | while ( pointS > 4 ) { | ||
143 | nFont.setPointSize( pointS ); | ||
144 | fm = QFontMetrics( nFont ); | ||
145 | if ( fm.height() < mCellHeight ) | ||
146 | break; | ||
147 | -- pointS; | ||
148 | } | ||
149 | fm = QFontMetrics( nFont ); | ||
150 | borderWidth = 4; | ||
151 | timeHeight = fm.height(); | ||
145 | } | 152 | } |
153 | timeHeight -= (timeHeight/4-2); | ||
154 | QFont sFont = nFont; | ||
155 | sFont.setPointSize( sFont.pointSize()/2+2 ); | ||
156 | QFontMetrics fmS( sFont ); | ||
157 | int sHei = fmS.height(); | ||
146 | 158 | ||
147 | while (y < cy + ch) { | 159 | while (y < cy + ch) { |
148 | p->drawLine(cx,y,cx+tW,y); | 160 | p->drawLine(cx,y,cx+tW,y); |
149 | hour.setNum(cell); | 161 | hour.setNum(cell); |
150 | 162 | ||
151 | // handle 24h and am/pm time formats | 163 | // handle 24h and am/pm time formats |
152 | if (KGlobal::locale()->use12Clock()) { | 164 | if (KGlobal::locale()->use12Clock()) { |
153 | if (cell > 11) suffix = "pm"; | 165 | if (cell > 11) suffix = "pm"; |
154 | else | 166 | else |
155 | suffix = "am"; | 167 | suffix = "am"; |
156 | if (cell == 0) hour.setNum(12); | 168 | if (cell == 0) hour.setNum(12); |
157 | if (cell > 12) hour.setNum(cell - 12); | 169 | if (cell > 12) hour.setNum(cell - 12); |
158 | } | 170 | } |
159 | 171 | ||
160 | // create string in format of "XX:XX" or "XXpm/am" | 172 | // create string in format of "XX:XX" or "XXpm/am" |
161 | fullTime = hour;// + suffix; | 173 | fullTime = hour;// + suffix; |
162 | 174 | ||
163 | // center and draw the time label | 175 | // center and draw the time label |
164 | int timeWidth = fm.width(fullTime+"i"); | 176 | int timeWidth = fm.width(fullTime+"i"); |
165 | int tw2 = fm.width(suffix); | 177 | int tw2 = fm.width(suffix); |
166 | int offset = this->width() - timeWidth - tw2; | 178 | int offset = this->width() - timeWidth - tw2; |
167 | p->setFont( nFont ); | 179 | p->setFont( nFont ); |
168 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); | 180 | p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); |
169 | p->setFont( sFont ); | 181 | p->setFont( sFont ); |
170 | offset += timeWidth; | 182 | offset += timeWidth; |
171 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 183 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); |
172 | 184 | ||
173 | // increment indices | 185 | // increment indices |
174 | y += mCellHeight; | 186 | y += mCellHeight; |
175 | cell++; | 187 | cell++; |
176 | } | 188 | } |
177 | } | 189 | } |
178 | 190 | ||
179 | /** | 191 | /** |
180 | Calculates the minimum width. | 192 | Calculates the minimum width. |
181 | */ | 193 | */ |
182 | int TimeLabels::minimumWidth() const | 194 | int TimeLabels::minimumWidth() const |
183 | { | 195 | { |
184 | return mMiniWidth; | 196 | return mMiniWidth; |
185 | } | 197 | } |
186 | 198 | ||
187 | /** updates widget's internal state */ | 199 | /** updates widget's internal state */ |
188 | void TimeLabels::updateConfig() | 200 | void TimeLabels::updateConfig() |
189 | { | 201 | { |
190 | // set the font | 202 | // set the font |
191 | // config->setGroup("Fonts"); | 203 | // config->setGroup("Fonts"); |
192 | // QFont font = config->readFontEntry("TimeBar Font"); | 204 | // QFont font = config->readFontEntry("TimeBar Font"); |
193 | setFont(KOPrefs::instance()->mTimeBarFont); | 205 | setFont(KOPrefs::instance()->mTimeBarFont); |
194 | mMiniWidth = fontMetrics().width("88:88") + 2 ; | 206 | mMiniWidth = fontMetrics().width("88:88") + 2 ; |
195 | // update geometry restrictions based on new settings | 207 | // update geometry restrictions based on new settings |
196 | setFixedWidth(minimumWidth()); | 208 | setFixedWidth(minimumWidth()); |
197 | 209 | ||
198 | // update HourSize | 210 | // update HourSize |
199 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 211 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
200 | resizeContents(50,mRows * mCellHeight); | 212 | resizeContents(50,mRows * mCellHeight); |
201 | } | 213 | } |
202 | 214 | ||
203 | /** update time label positions */ | 215 | /** update time label positions */ |
204 | void TimeLabels::positionChanged() | 216 | void TimeLabels::positionChanged() |
205 | { | 217 | { |
206 | int adjustment = mAgenda->contentsY(); | 218 | int adjustment = mAgenda->contentsY(); |
207 | setContentsPos(0, adjustment); | 219 | setContentsPos(0, adjustment); |
208 | } | 220 | } |
209 | 221 | ||
210 | /** */ | 222 | /** */ |
211 | void TimeLabels::setAgenda(KOAgenda* agenda) | 223 | void TimeLabels::setAgenda(KOAgenda* agenda) |
212 | { | 224 | { |
213 | mAgenda = agenda; | 225 | mAgenda = agenda; |
214 | } | 226 | } |
215 | 227 | ||
216 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 228 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
217 | { | 229 | { |
218 | mMouseDownY = e->pos().y(); | 230 | mMouseDownY = e->pos().y(); |
219 | mOrgCap = topLevelWidget()->caption(); | 231 | mOrgCap = topLevelWidget()->caption(); |
220 | } | 232 | } |
221 | 233 | ||
222 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 234 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
223 | { | 235 | { |
224 | int diff = mMouseDownY - e->pos().y(); | 236 | int diff = mMouseDownY - e->pos().y(); |
225 | if ( diff < 10 && diff > -10 ) | 237 | if ( diff < 10 && diff > -10 ) |
226 | return; | 238 | return; |
227 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 239 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
228 | if ( tSize < 4 ) | 240 | if ( tSize < 4 ) |
229 | tSize = 4; | 241 | tSize = 4; |
230 | if ( tSize > 22 ) | 242 | if ( tSize > 22 ) |
231 | tSize = 22; | 243 | tSize = 22; |
232 | tSize = (tSize-2)/2; | 244 | tSize = (tSize-2)/2; |
233 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 245 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
234 | 246 | ||
235 | } | 247 | } |
236 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 248 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
237 | { | 249 | { |
238 | topLevelWidget()->setCaption( mOrgCap ); | 250 | topLevelWidget()->setCaption( mOrgCap ); |
239 | int diff = mMouseDownY - e->pos().y(); | 251 | int diff = mMouseDownY - e->pos().y(); |
240 | if ( diff < 10 && diff > -10 ) | 252 | if ( diff < 10 && diff > -10 ) |
241 | return; | 253 | return; |
242 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 254 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
243 | if ( tSize < 4 ) | 255 | if ( tSize < 4 ) |
244 | tSize = 4; | 256 | tSize = 4; |
245 | if ( tSize > 22 ) | 257 | if ( tSize > 22 ) |
246 | tSize = 22; | 258 | tSize = 22; |
247 | tSize = (tSize/2)*2; | 259 | tSize = (tSize/2)*2; |
248 | if ( tSize == KOPrefs::instance()->mHourSize ) | 260 | if ( tSize == KOPrefs::instance()->mHourSize ) |
249 | return; | 261 | return; |
250 | KOPrefs::instance()->mHourSize = tSize; | 262 | KOPrefs::instance()->mHourSize = tSize; |
251 | emit scaleChanged(); | 263 | emit scaleChanged(); |
252 | } | 264 | } |
253 | 265 | ||
254 | /** This is called in response to repaint() */ | 266 | /** This is called in response to repaint() */ |
255 | void TimeLabels::paintEvent(QPaintEvent*) | 267 | void TimeLabels::paintEvent(QPaintEvent*) |
256 | { | 268 | { |
257 | 269 | ||
258 | // kdDebug() << "paintevent..." << endl; | 270 | // kdDebug() << "paintevent..." << endl; |
259 | // this is another hack! | 271 | // this is another hack! |
260 | // QPainter painter(this); | 272 | // QPainter painter(this); |
261 | //QString c | 273 | //QString c |
262 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 274 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
263 | } | 275 | } |
264 | 276 | ||
265 | //////////////////////////////////////////////////////////////////////////// | 277 | //////////////////////////////////////////////////////////////////////////// |
266 | 278 | ||
267 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 279 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
268 | : QFrame(parent,name) | 280 | : QFrame(parent,name) |
269 | { | 281 | { |
270 | mColumns = 1; | 282 | mColumns = 1; |
271 | mTopBox = 0; | 283 | mTopBox = 0; |
272 | mLocation = loc; | 284 | mLocation = loc; |
273 | mTopLayout = 0; | 285 | mTopLayout = 0; |
@@ -764,256 +776,262 @@ void KOAgendaView::createDayLabels() | |||
764 | str = addString+", " + str; | 776 | str = addString+", " + str; |
765 | } else { | 777 | } else { |
766 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 778 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
767 | } | 779 | } |
768 | } | 780 | } |
769 | dayLabel->setText(str); | 781 | dayLabel->setText(str); |
770 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 782 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
771 | if (date == QDate::currentDate()) { | 783 | if (date == QDate::currentDate()) { |
772 | QFont bFont = dlf; | 784 | QFont bFont = dlf; |
773 | bFont.setBold( true ); | 785 | bFont.setBold( true ); |
774 | dayLabel->setFont(bFont); | 786 | dayLabel->setFont(bFont); |
775 | } | 787 | } |
776 | //dayLayout->addWidget(dayLabel); | 788 | //dayLayout->addWidget(dayLabel); |
777 | 789 | ||
778 | #ifndef KORG_NOPLUGINS | 790 | #ifndef KORG_NOPLUGINS |
779 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 791 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
780 | CalendarDecoration *it; | 792 | CalendarDecoration *it; |
781 | for(it = cds.first(); it; it = cds.next()) { | 793 | for(it = cds.first(); it; it = cds.next()) { |
782 | QString text = it->shortText( date ); | 794 | QString text = it->shortText( date ); |
783 | if ( !text.isEmpty() ) { | 795 | if ( !text.isEmpty() ) { |
784 | QLabel *label = new QLabel(text,mDayLabels); | 796 | QLabel *label = new QLabel(text,mDayLabels); |
785 | label->setAlignment(AlignCenter); | 797 | label->setAlignment(AlignCenter); |
786 | dayLayout->addWidget(label); | 798 | dayLayout->addWidget(label); |
787 | } | 799 | } |
788 | } | 800 | } |
789 | 801 | ||
790 | for(it = cds.first(); it; it = cds.next()) { | 802 | for(it = cds.first(); it; it = cds.next()) { |
791 | QWidget *wid = it->smallWidget(mDayLabels,date); | 803 | QWidget *wid = it->smallWidget(mDayLabels,date); |
792 | if ( wid ) { | 804 | if ( wid ) { |
793 | // wid->setHeight(20); | 805 | // wid->setHeight(20); |
794 | dayLayout->addWidget(wid); | 806 | dayLayout->addWidget(wid); |
795 | } | 807 | } |
796 | } | 808 | } |
797 | #endif | 809 | #endif |
798 | } | 810 | } |
799 | if ( ! appendLabels ) { | 811 | if ( ! appendLabels ) { |
800 | dayLabel = mDayLabelsList.next(); | 812 | dayLabel = mDayLabelsList.next(); |
801 | if ( !dayLabel ) | 813 | if ( !dayLabel ) |
802 | appendLabels = true; | 814 | appendLabels = true; |
803 | } | 815 | } |
804 | if ( appendLabels ) { | 816 | if ( appendLabels ) { |
805 | dayLabel = getNewDaylabel(); | 817 | dayLabel = getNewDaylabel(); |
806 | } | 818 | } |
807 | //dayLabel->hide();//test only | 819 | //dayLabel->hide();//test only |
808 | 820 | ||
809 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 821 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
810 | if ( offset < 0 ) offset = 0; | 822 | if ( offset < 0 ) offset = 0; |
811 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 823 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
812 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 824 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
813 | dayLabel->setFont( dlf ); | 825 | dayLabel->setFont( dlf ); |
814 | dayLabel->show(); | 826 | dayLabel->show(); |
815 | dayLabel->setNum( -2 ); | 827 | dayLabel->setNum( -2 ); |
816 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 828 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
817 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 829 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
818 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 830 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
819 | if ( !appendLabels ) { | 831 | if ( !appendLabels ) { |
820 | dayLabel = mDayLabelsList.next(); | 832 | dayLabel = mDayLabelsList.next(); |
821 | while ( dayLabel ) { | 833 | while ( dayLabel ) { |
822 | //qDebug("!dayLabel %d",dayLabel ); | 834 | //qDebug("!dayLabel %d",dayLabel ); |
823 | dayLabel->hide(); | 835 | dayLabel->hide(); |
824 | dayLabel = mDayLabelsList.next(); | 836 | dayLabel = mDayLabelsList.next(); |
825 | } | 837 | } |
826 | } | 838 | } |
827 | //mDayLabelsFrame->show(); | 839 | //mDayLabelsFrame->show(); |
828 | //mDayLabels->show(); | 840 | //mDayLabels->show(); |
829 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 841 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
830 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 842 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
831 | mDayLabelsFrame->setFixedHeight( newHight ); | 843 | mDayLabelsFrame->setFixedHeight( newHight ); |
832 | } | 844 | } |
833 | 845 | ||
834 | int KOAgendaView::maxDatesHint() | 846 | int KOAgendaView::maxDatesHint() |
835 | { | 847 | { |
836 | // Not sure about the max number of events, so return 0 for now. | 848 | // Not sure about the max number of events, so return 0 for now. |
837 | return 0; | 849 | return 0; |
838 | } | 850 | } |
839 | 851 | ||
840 | int KOAgendaView::currentDateCount() | 852 | int KOAgendaView::currentDateCount() |
841 | { | 853 | { |
842 | return mSelectedDates.count(); | 854 | return mSelectedDates.count(); |
843 | } | 855 | } |
844 | 856 | ||
845 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 857 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
846 | { | 858 | { |
847 | QPtrList<Incidence> selected; | 859 | QPtrList<Incidence> selected; |
848 | Incidence *incidence; | 860 | Incidence *incidence; |
849 | 861 | ||
850 | incidence = mAgenda->selectedIncidence(); | 862 | incidence = mAgenda->selectedIncidence(); |
851 | if (incidence) selected.append(incidence); | 863 | if (incidence) selected.append(incidence); |
852 | 864 | ||
853 | incidence = mAllDayAgenda->selectedIncidence(); | 865 | incidence = mAllDayAgenda->selectedIncidence(); |
854 | if (incidence) selected.append(incidence); | 866 | if (incidence) selected.append(incidence); |
855 | 867 | ||
856 | return selected; | 868 | return selected; |
857 | } | 869 | } |
858 | 870 | ||
859 | DateList KOAgendaView::selectedDates() | 871 | DateList KOAgendaView::selectedDates() |
860 | { | 872 | { |
861 | DateList selected; | 873 | DateList selected; |
862 | QDate qd; | 874 | QDate qd; |
863 | 875 | ||
864 | qd = mAgenda->selectedIncidenceDate(); | 876 | qd = mAgenda->selectedIncidenceDate(); |
865 | if (qd.isValid()) selected.append(qd); | 877 | if (qd.isValid()) selected.append(qd); |
866 | 878 | ||
867 | qd = mAllDayAgenda->selectedIncidenceDate(); | 879 | qd = mAllDayAgenda->selectedIncidenceDate(); |
868 | if (qd.isValid()) selected.append(qd); | 880 | if (qd.isValid()) selected.append(qd); |
869 | 881 | ||
870 | return selected; | 882 | return selected; |
871 | } | 883 | } |
872 | 884 | ||
873 | 885 | ||
874 | void KOAgendaView::updateView() | 886 | void KOAgendaView::updateView() |
875 | { | 887 | { |
876 | if ( mBlockUpdating ) | 888 | if ( mBlockUpdating ) |
877 | return; | 889 | return; |
878 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 890 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
879 | fillAgenda(); | 891 | fillAgenda(); |
880 | 892 | ||
881 | } | 893 | } |
882 | 894 | ||
883 | 895 | ||
884 | /* | 896 | /* |
885 | Update configuration settings for the agenda view. This method is not | 897 | Update configuration settings for the agenda view. This method is not |
886 | complete. | 898 | complete. |
887 | */ | 899 | */ |
888 | void KOAgendaView::updateConfig() | 900 | void KOAgendaView::updateConfig() |
889 | { | 901 | { |
890 | if ( mBlockUpdating ) | 902 | if ( mBlockUpdating ) |
891 | return; | 903 | return; |
904 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | ||
905 | int old = KOPrefs::instance()->mHourSize; | ||
906 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | ||
907 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | ||
908 | } | ||
909 | |||
892 | 910 | ||
893 | // update config for children | 911 | // update config for children |
894 | mTimeLabels->updateConfig(); | 912 | mTimeLabels->updateConfig(); |
895 | mAgenda->storePosition(); | 913 | mAgenda->storePosition(); |
896 | mAgenda->updateConfig(); | 914 | mAgenda->updateConfig(); |
897 | mAllDayAgenda->updateConfig(); | 915 | mAllDayAgenda->updateConfig(); |
898 | // widget synchronization | 916 | // widget synchronization |
899 | //TODO: find a better way, maybe signal/slot | 917 | //TODO: find a better way, maybe signal/slot |
900 | mTimeLabels->positionChanged(); | 918 | mTimeLabels->positionChanged(); |
901 | 919 | ||
902 | // for some reason, this needs to be called explicitly | 920 | // for some reason, this needs to be called explicitly |
903 | mTimeLabels->repaint(); | 921 | mTimeLabels->repaint(); |
904 | 922 | ||
905 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 923 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
906 | 924 | ||
907 | // ToolTips displaying summary of events | 925 | // ToolTips displaying summary of events |
908 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 926 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
909 | ->mEnableToolTips); | 927 | ->mEnableToolTips); |
910 | 928 | ||
911 | //setHolidayMasks(); | 929 | //setHolidayMasks(); |
912 | 930 | ||
913 | //createDayLabels(); called by via updateView(); | 931 | //createDayLabels(); called by via updateView(); |
914 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 932 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
915 | updateView(); | 933 | updateView(); |
916 | mAgenda->restorePosition(); | 934 | mAgenda->restorePosition(); |
917 | } | 935 | } |
918 | 936 | ||
919 | 937 | ||
920 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 938 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
921 | { | 939 | { |
922 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 940 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
923 | //qDebug("KOAgendaView::updateEventDates "); | 941 | //qDebug("KOAgendaView::updateEventDates "); |
924 | QDateTime startDt,endDt; | 942 | QDateTime startDt,endDt; |
925 | QDate startDate; | 943 | QDate startDate; |
926 | int lenInSecs; | 944 | int lenInSecs; |
927 | // if ( type == KOAgenda::RESIZETOP ) | 945 | // if ( type == KOAgenda::RESIZETOP ) |
928 | // qDebug("RESIZETOP "); | 946 | // qDebug("RESIZETOP "); |
929 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 947 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
930 | // qDebug("RESIZEBOTTOM "); | 948 | // qDebug("RESIZEBOTTOM "); |
931 | // if ( type == KOAgenda::MOVE ) | 949 | // if ( type == KOAgenda::MOVE ) |
932 | // qDebug("MOVE "); | 950 | // qDebug("MOVE "); |
933 | if ( item->incidence()->type() == "Event" ) { | 951 | if ( item->incidence()->type() == "Event" ) { |
934 | startDt =item->incidence()->dtStart(); | 952 | startDt =item->incidence()->dtStart(); |
935 | endDt = item->incidence()->dtEnd(); | 953 | endDt = item->incidence()->dtEnd(); |
936 | lenInSecs = startDt.secsTo( endDt ); | 954 | lenInSecs = startDt.secsTo( endDt ); |
937 | } | 955 | } |
938 | 956 | ||
939 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 957 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
940 | 958 | ||
941 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 959 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
942 | startDate = mSelectedDates[item->mLastMoveXPos]; | 960 | startDate = mSelectedDates[item->mLastMoveXPos]; |
943 | } else { | 961 | } else { |
944 | if (item->cellX() < 0) { | 962 | if (item->cellX() < 0) { |
945 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 963 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
946 | } else { | 964 | } else { |
947 | startDate = mSelectedDates[item->cellX()]; | 965 | startDate = mSelectedDates[item->cellX()]; |
948 | } | 966 | } |
949 | } | 967 | } |
950 | startDt.setDate(startDate); | 968 | startDt.setDate(startDate); |
951 | 969 | ||
952 | if (item->incidence()->doesFloat()) { | 970 | if (item->incidence()->doesFloat()) { |
953 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 971 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
954 | } else { | 972 | } else { |
955 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 973 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
956 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 974 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
957 | if ( item->incidence()->type() == "Event" ) { | 975 | if ( item->incidence()->type() == "Event" ) { |
958 | if ( type == KOAgenda::MOVE ) { | 976 | if ( type == KOAgenda::MOVE ) { |
959 | endDt = startDt.addSecs(lenInSecs); | 977 | endDt = startDt.addSecs(lenInSecs); |
960 | 978 | ||
961 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 979 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
962 | if (item->lastMultiItem()) { | 980 | if (item->lastMultiItem()) { |
963 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 981 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
964 | endDt.setDate(startDate. | 982 | endDt.setDate(startDate. |
965 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 983 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
966 | } else { | 984 | } else { |
967 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 985 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
968 | endDt.setDate(startDate); | 986 | endDt.setDate(startDate); |
969 | } | 987 | } |
970 | } | 988 | } |
971 | } else { | 989 | } else { |
972 | // todo | 990 | // todo |
973 | if (item->lastMultiItem()) { | 991 | if (item->lastMultiItem()) { |
974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 992 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
975 | endDt.setDate(startDate. | 993 | endDt.setDate(startDate. |
976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 994 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
977 | } else { | 995 | } else { |
978 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 996 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
979 | if ( item->cellYBottom() > 0 ) | 997 | if ( item->cellYBottom() > 0 ) |
980 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 998 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
981 | else | 999 | else |
982 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1000 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
983 | endDt.setDate(startDate); | 1001 | endDt.setDate(startDate); |
984 | } | 1002 | } |
985 | } | 1003 | } |
986 | } | 1004 | } |
987 | if ( item->incidence()->type() == "Event" ) { | 1005 | if ( item->incidence()->type() == "Event" ) { |
988 | item->incidence()->setDtStart(startDt); | 1006 | item->incidence()->setDtStart(startDt); |
989 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1007 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
990 | } else if ( item->incidence()->type() == "Todo" ) { | 1008 | } else if ( item->incidence()->type() == "Todo" ) { |
991 | Todo* to = static_cast<Todo*>(item->incidence()); | 1009 | Todo* to = static_cast<Todo*>(item->incidence()); |
992 | 1010 | ||
993 | to->setDtDue(endDt); | 1011 | to->setDtDue(endDt); |
994 | if ( to->hasStartDate() ) { | 1012 | if ( to->hasStartDate() ) { |
995 | if (to->dtStart() >= to->dtDue() ) | 1013 | if (to->dtStart() >= to->dtDue() ) |
996 | to->setDtStart(to->dtDue().addDays( -2 )); | 1014 | to->setDtStart(to->dtDue().addDays( -2 )); |
997 | } | 1015 | } |
998 | 1016 | ||
999 | } | 1017 | } |
1000 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1018 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1001 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1019 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1002 | item->setItemDate(startDt.date()); | 1020 | item->setItemDate(startDt.date()); |
1003 | //item->updateItem(); | 1021 | //item->updateItem(); |
1004 | if ( item->incidence()->type() == "Todo" ) { | 1022 | if ( item->incidence()->type() == "Todo" ) { |
1005 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1023 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1006 | 1024 | ||
1007 | } | 1025 | } |
1008 | else | 1026 | else |
1009 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1027 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1010 | item->updateItem(); | 1028 | item->updateItem(); |
1011 | } | 1029 | } |
1012 | 1030 | ||
1013 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1031 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1014 | { | 1032 | { |
1015 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1033 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1016 | 1034 | ||
1017 | mSelectedDates.clear(); | 1035 | mSelectedDates.clear(); |
1018 | // qDebug("KOAgendaView::showDates "); | 1036 | // qDebug("KOAgendaView::showDates "); |
1019 | QDate d = start; | 1037 | QDate d = start; |