-rw-r--r-- | korganizer/komonthview.cpp | 218 |
1 files changed, 115 insertions, 103 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 85e9166..ca55c43 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -8,40 +8,52 @@ | |||
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 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <q3popupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qnamespace.h> |
24 | #include <qhbox.h> | 24 | #include <q3hbox.h> |
25 | #include <qvbox.h> | 25 | #include <q3vbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <q3widgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <q3whatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <QDesktopWidget> | ||
37 | //Added by qt3to4: | ||
38 | #include <QResizeEvent> | ||
39 | #include <QLabel> | ||
40 | #include <QPixmap> | ||
41 | #include <QFocusEvent> | ||
42 | #include <QMouseEvent> | ||
43 | #include <QKeyEvent> | ||
44 | #include <Q3VBoxLayout> | ||
45 | #include <Q3Frame> | ||
46 | #include <Q3PointArray> | ||
47 | #include <Q3PtrList> | ||
36 | #endif | 48 | #endif |
37 | 49 | ||
38 | #include <kdebug.h> | 50 | #include <kdebug.h> |
39 | #include <klocale.h> | 51 | #include <klocale.h> |
40 | #include <kglobal.h> | 52 | #include <kglobal.h> |
41 | #include <kconfig.h> | 53 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 54 | #include <kiconloader.h> |
43 | 55 | ||
44 | #include <kcalendarsystem.h> | 56 | #include <kcalendarsystem.h> |
45 | 57 | ||
46 | #ifndef KORG_NOPRINTER | 58 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 59 | #include "calprinter.h" |
@@ -50,202 +62,202 @@ | |||
50 | #ifndef KORG_NOPLUGINS | 62 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 63 | #include "kocore.h" |
52 | #endif | 64 | #endif |
53 | #include "koglobals.h" | 65 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 66 | #include <libkcal/kincidenceformatter.h> |
55 | 67 | ||
56 | #include "komonthview.h" | 68 | #include "komonthview.h" |
57 | 69 | ||
58 | #define PIXMAP_SIZE 5 | 70 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 71 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 72 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 73 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 74 | class KNOWhatsThis :public Q3WhatsThis |
63 | { | 75 | { |
64 | public: | 76 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 77 | KNOWhatsThis( KNoScrollListBox* sbox ) : Q3WhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 78 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 79 | ||
68 | protected: | 80 | protected: |
69 | virtual QString text( const QPoint& p) | 81 | virtual QString text( const QPoint& p) |
70 | { | 82 | { |
71 | return _wid->getWhatsThisText(p) ; | 83 | return _wid->getWhatsThisText(p) ; |
72 | }; | 84 | }; |
73 | private: | 85 | private: |
74 | KNoScrollListBox* _wid; | 86 | KNoScrollListBox* _wid; |
75 | 87 | ||
76 | }; | 88 | }; |
77 | 89 | ||
78 | 90 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 91 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 92 | : Q3ListBox(parent, name, Qt::WNoAutoErase) |
81 | { | 93 | { |
82 | #ifndef DESKTOP_VERSION | 94 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 95 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 96 | #endif |
85 | mBlockDeselect = false; | 97 | mBlockDeselect = false; |
86 | mWT = new KNOWhatsThis(this); | 98 | mWT = new KNOWhatsThis(this); |
87 | resetOnFocusIn = true; | 99 | resetOnFocusIn = true; |
88 | setVScrollBarMode(QScrollView::AlwaysOff); | 100 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
89 | setHScrollBarMode(QScrollView::AlwaysOff); | 101 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
90 | } | 102 | } |
91 | KNoScrollListBox::~KNoScrollListBox() | 103 | KNoScrollListBox::~KNoScrollListBox() |
92 | { | 104 | { |
93 | #if QT_VERSION >= 0x030000 | 105 | #if QT_VERSION >= 0x030000 |
94 | 106 | ||
95 | #else | 107 | #else |
96 | delete mWT; | 108 | delete mWT; |
97 | #endif | 109 | #endif |
98 | } | 110 | } |
99 | 111 | ||
100 | 112 | ||
101 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 113 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
102 | { | 114 | { |
103 | QListBox::focusInEvent ( e ); | 115 | Q3ListBox::focusInEvent ( e ); |
104 | if ( count() ){ | 116 | if ( count() ){ |
105 | int ci = currentItem(); | 117 | int ci = currentItem(); |
106 | if ( ci < 0 ) ci = 0; | 118 | if ( ci < 0 ) ci = 0; |
107 | 119 | ||
108 | setCurrentItem( ci ); | 120 | setCurrentItem( ci ); |
109 | setSelected ( ci, true ); | 121 | setSelected ( ci, true ); |
110 | emit highlighted( item ( ci ) ); | 122 | emit highlighted( item ( ci ) ); |
111 | 123 | ||
112 | resetOnFocusIn = true; | 124 | resetOnFocusIn = true; |
113 | 125 | ||
114 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 126 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
115 | QListBoxItem *fi = firstItem (); | 127 | Q3ListBoxItem *fi = firstItem (); |
116 | if (fi ) { | 128 | if (fi ) { |
117 | int ihei = fi->height( this ); | 129 | int ihei = fi->height( this ); |
118 | int hei = numRows () * ihei; | 130 | int hei = numRows () * ihei; |
119 | if ( hei < height() - horizontalScrollBar()->height () ) { | 131 | if ( hei < height() - horizontalScrollBar()->height () ) { |
120 | setVScrollBarMode(QScrollView::AlwaysOff); | 132 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
121 | } | 133 | } |
122 | else | 134 | else |
123 | setVScrollBarMode(QScrollView::Auto); | 135 | setVScrollBarMode(Q3ScrollView::Auto); |
124 | if ( ihei *3 > height() ) { | 136 | if ( ihei *3 > height() ) { |
125 | setHScrollBarMode(QScrollView::AlwaysOff); | 137 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
126 | } | 138 | } |
127 | else { | 139 | else { |
128 | setHScrollBarMode(QScrollView::Auto); | 140 | setHScrollBarMode(Q3ScrollView::Auto); |
129 | } | 141 | } |
130 | } else { | 142 | } else { |
131 | setVScrollBarMode(QScrollView::Auto); | 143 | setVScrollBarMode(Q3ScrollView::Auto); |
132 | setHScrollBarMode(QScrollView::Auto); | 144 | setHScrollBarMode(Q3ScrollView::Auto); |
133 | } | 145 | } |
134 | } | 146 | } |
135 | } | 147 | } |
136 | } | 148 | } |
137 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 149 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
138 | { | 150 | { |
139 | if ( ! mBlockDeselect ) { | 151 | if ( ! mBlockDeselect ) { |
140 | int i = currentItem (); | 152 | int i = currentItem (); |
141 | if ( i >= 0 ) { | 153 | if ( i >= 0 ) { |
142 | setSelected ( i, false ); | 154 | setSelected ( i, false ); |
143 | } | 155 | } |
144 | QListBox::focusOutEvent ( e ); | 156 | Q3ListBox::focusOutEvent ( e ); |
145 | } | 157 | } |
146 | setVScrollBarMode(QScrollView::AlwaysOff); | 158 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
147 | setHScrollBarMode(QScrollView::AlwaysOff); | 159 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
148 | if ( ! mBlockDeselect ) | 160 | if ( ! mBlockDeselect ) |
149 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); | 161 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); |
150 | mBlockDeselect = false; | 162 | mBlockDeselect = false; |
151 | } | 163 | } |
152 | 164 | ||
153 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 165 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
154 | { | 166 | { |
155 | QListBoxItem* item = itemAt ( p ); | 167 | Q3ListBoxItem* item = itemAt ( p ); |
156 | if ( ! item ) { | 168 | if ( ! item ) { |
157 | return i18n("Click in the cell\nto add an event!"); | 169 | return i18n("Click in the cell\nto add an event!"); |
158 | } | 170 | } |
159 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 171 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
160 | KOPrefs::instance()->mWTshowDetails, | 172 | KOPrefs::instance()->mWTshowDetails, |
161 | KOPrefs::instance()->mWTshowCreated, | 173 | KOPrefs::instance()->mWTshowCreated, |
162 | KOPrefs::instance()->mWTshowChanged); | 174 | KOPrefs::instance()->mWTshowChanged); |
163 | } | 175 | } |
164 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 176 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
165 | { | 177 | { |
166 | //qDebug("KNoScrollListBox::keyPressEvent "); | 178 | //qDebug("KNoScrollListBox::keyPressEvent "); |
167 | switch(e->key()) { | 179 | switch(e->key()) { |
168 | case Key_Right: | 180 | case Qt::Key_Right: |
169 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 181 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
170 | { | 182 | { |
171 | e->ignore(); | 183 | e->ignore(); |
172 | return; | 184 | return; |
173 | } | 185 | } |
174 | scrollBy(10,0); | 186 | scrollBy(10,0); |
175 | break; | 187 | break; |
176 | case Key_Left: | 188 | case Qt::Key_Left: |
177 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 189 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
178 | { | 190 | { |
179 | e->ignore(); | 191 | e->ignore(); |
180 | return; | 192 | return; |
181 | } | 193 | } |
182 | scrollBy(-10,0); | 194 | scrollBy(-10,0); |
183 | break; | 195 | break; |
184 | case Key_Up: | 196 | case Qt::Key_Up: |
185 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 197 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
186 | e->ignore(); | 198 | e->ignore(); |
187 | break; | 199 | break; |
188 | } | 200 | } |
189 | if ( count() ) { | 201 | if ( count() ) { |
190 | if ( currentItem() == 0 ) { | 202 | if ( currentItem() == 0 ) { |
191 | emit prevCell(); | 203 | emit prevCell(); |
192 | } else { | 204 | } else { |
193 | setCurrentItem((currentItem()+count()-1)%count()); | 205 | setCurrentItem((currentItem()+count()-1)%count()); |
194 | if(!itemVisible(currentItem())) { | 206 | if(!itemVisible(currentItem())) { |
195 | if((unsigned int) currentItem() == (count()-1)) { | 207 | if((unsigned int) currentItem() == (count()-1)) { |
196 | setTopItem(currentItem()-numItemsVisible()+1); | 208 | setTopItem(currentItem()-numItemsVisible()+1); |
197 | } else { | 209 | } else { |
198 | setTopItem(topItem()-1); | 210 | setTopItem(topItem()-1); |
199 | } | 211 | } |
200 | } | 212 | } |
201 | } | 213 | } |
202 | } | 214 | } |
203 | break; | 215 | break; |
204 | case Key_Down: | 216 | case Qt::Key_Down: |
205 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 217 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
206 | e->ignore(); | 218 | e->ignore(); |
207 | break; | 219 | break; |
208 | } | 220 | } |
209 | if ( count () ) { | 221 | if ( count () ) { |
210 | if ( ((uint)currentItem()+1) == count () ) { | 222 | if ( ((uint)currentItem()+1) == count () ) { |
211 | emit nextCell(); | 223 | emit nextCell(); |
212 | } else { | 224 | } else { |
213 | setCurrentItem((currentItem()+1)%count()); | 225 | setCurrentItem((currentItem()+1)%count()); |
214 | if(!itemVisible(currentItem())) { | 226 | if(!itemVisible(currentItem())) { |
215 | if(currentItem() == 0) { | 227 | if(currentItem() == 0) { |
216 | setTopItem(0); | 228 | setTopItem(0); |
217 | } else { | 229 | } else { |
218 | setTopItem(topItem()+1); | 230 | setTopItem(topItem()+1); |
219 | } | 231 | } |
220 | } | 232 | } |
221 | } | 233 | } |
222 | } | 234 | } |
223 | break; | 235 | break; |
224 | case Key_I: | 236 | case Qt::Key_I: |
225 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 237 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
226 | e->ignore(); | 238 | e->ignore(); |
227 | break; | 239 | break; |
228 | case Key_Return: | 240 | case Qt::Key_Return: |
229 | case Key_Enter: | 241 | case Qt::Key_Enter: |
230 | { | 242 | { |
231 | if ( currentItem() >= 0 ) { | 243 | if ( currentItem() >= 0 ) { |
232 | emit doubleClicked( item( currentItem() ) ); | 244 | emit doubleClicked( item( currentItem() ) ); |
233 | e->accept(); | 245 | e->accept(); |
234 | } else { | 246 | } else { |
235 | e->ignore(); | 247 | e->ignore(); |
236 | } | 248 | } |
237 | } | 249 | } |
238 | break; | 250 | break; |
239 | case Key_Shift: | 251 | case Qt::Key_Shift: |
240 | emit shiftDown(); | 252 | emit shiftDown(); |
241 | break; | 253 | break; |
242 | default: | 254 | default: |
243 | e->ignore(); | 255 | e->ignore(); |
244 | break; | 256 | break; |
245 | } | 257 | } |
246 | } | 258 | } |
247 | 259 | ||
248 | void KNoScrollListBox::oneDown() | 260 | void KNoScrollListBox::oneDown() |
249 | { | 261 | { |
250 | if ( count () ) { | 262 | if ( count () ) { |
251 | if ( ((uint)currentItem()+1) == count () ) { | 263 | if ( ((uint)currentItem()+1) == count () ) { |
@@ -257,43 +269,43 @@ void KNoScrollListBox::oneDown() | |||
257 | if(currentItem() == 0) { | 269 | if(currentItem() == 0) { |
258 | setTopItem(0); | 270 | setTopItem(0); |
259 | } else { | 271 | } else { |
260 | setTopItem(topItem()+1); | 272 | setTopItem(topItem()+1); |
261 | } | 273 | } |
262 | } | 274 | } |
263 | } | 275 | } |
264 | } | 276 | } |
265 | } | 277 | } |
266 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 278 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
267 | { | 279 | { |
268 | switch(e->key()) { | 280 | switch(e->key()) { |
269 | case Key_Shift: | 281 | case Qt::Key_Shift: |
270 | emit shiftUp(); | 282 | emit shiftUp(); |
271 | break; | 283 | break; |
272 | default: | 284 | default: |
273 | break; | 285 | break; |
274 | } | 286 | } |
275 | } | 287 | } |
276 | 288 | ||
277 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 289 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
278 | { | 290 | { |
279 | QListBox::mousePressEvent(e); | 291 | Q3ListBox::mousePressEvent(e); |
280 | 292 | ||
281 | if(e->button() == RightButton) { | 293 | if(e->button() == Qt::RightButton) { |
282 | emit rightClick(); | 294 | emit rightClick(); |
283 | } | 295 | } |
284 | } | 296 | } |
285 | 297 | ||
286 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) | 298 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
287 | : QListBoxItem() | 299 | : Q3ListBoxItem() |
288 | { | 300 | { |
289 | mblockRepaint = true; | 301 | mblockRepaint = true; |
290 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 302 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
291 | recycle( incidence, s ); | 303 | recycle( incidence, s ); |
292 | } | 304 | } |
293 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) | 305 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
294 | { | 306 | { |
295 | mDisplayHighlighted = false; | 307 | mDisplayHighlighted = false; |
296 | setText( s ); | 308 | setText( s ); |
297 | mMultiday = 0; | 309 | mMultiday = 0; |
298 | mIncidence = incidence; | 310 | mIncidence = incidence; |
299 | mRecur = false; | 311 | mRecur = false; |
@@ -386,32 +398,32 @@ void MonthViewItem::paint(QPainter *p) | |||
386 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 398 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
387 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 399 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
388 | #endif | 400 | #endif |
389 | QColor textColor = p->pen().color(); | 401 | QColor textColor = p->pen().color(); |
390 | 402 | ||
391 | 403 | ||
392 | if ( mMultiday ) { | 404 | if ( mMultiday ) { |
393 | int yyy = y+(size/2); | 405 | int yyy = y+(size/2); |
394 | int sizeM = size+2; | 406 | int sizeM = size+2; |
395 | p->setBrush( QBrush( textColor ) ); | 407 | p->setBrush( QBrush( textColor ) ); |
396 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 408 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
397 | if ( mMultiday == 2 || mMultiday == 3 ) { | 409 | if ( mMultiday == 2 || mMultiday == 3 ) { |
398 | QPointArray pa ( 3 ); | 410 | Q3PointArray pa ( 3 ); |
399 | pa.setPoint (0, x, yyy ); | 411 | pa.setPoint (0, x, yyy ); |
400 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 412 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
401 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 413 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
402 | p->drawPolygon( pa ); | 414 | p->drawPolygon( pa ); |
403 | } | 415 | } |
404 | if ( mMultiday == 2 || mMultiday == 1 ) { | 416 | if ( mMultiday == 2 || mMultiday == 1 ) { |
405 | QPointArray pa ( 3 ); | 417 | Q3PointArray pa ( 3 ); |
406 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 418 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
407 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 419 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
408 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 420 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
409 | p->drawPolygon( pa ); | 421 | p->drawPolygon( pa ); |
410 | } | 422 | } |
411 | if ( mMultiday == 1 ) { | 423 | if ( mMultiday == 1 ) { |
412 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 424 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
413 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 425 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
414 | } | 426 | } |
415 | if ( mMultiday == 3 ) { | 427 | if ( mMultiday == 3 ) { |
416 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 428 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
417 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 429 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
@@ -453,33 +465,33 @@ void MonthViewItem::paint(QPainter *p) | |||
453 | } else { | 465 | } else { |
454 | QString pText = text(); | 466 | QString pText = text(); |
455 | if( pText.mid(2,1) == ":" ) | 467 | if( pText.mid(2,1) == ":" ) |
456 | pText = pText.mid( 6 ); | 468 | pText = pText.mid( 6 ); |
457 | p->drawText( x, yPos, pText ); | 469 | p->drawText( x, yPos, pText ); |
458 | if ( mIncidence->cancelled() ) { | 470 | if ( mIncidence->cancelled() ) { |
459 | int wid = fm.width( pText ); | 471 | int wid = fm.width( pText ); |
460 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 472 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
461 | } | 473 | } |
462 | } | 474 | } |
463 | } | 475 | } |
464 | 476 | ||
465 | int MonthViewItem::height(const QListBox *lb) const | 477 | int MonthViewItem::height(const Q3ListBox *lb) const |
466 | { | 478 | { |
467 | int ret = 10; | 479 | int ret = 10; |
468 | if ( lb ) | 480 | if ( lb ) |
469 | ret = lb->fontMetrics().lineSpacing()+1; | 481 | ret = lb->fontMetrics().lineSpacing()+1; |
470 | return ret; | 482 | return ret; |
471 | } | 483 | } |
472 | 484 | ||
473 | int MonthViewItem::width(const QListBox *lb) const | 485 | int MonthViewItem::width(const Q3ListBox *lb) const |
474 | { | 486 | { |
475 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 487 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
476 | int size = PIXMAP_SIZE; | 488 | int size = PIXMAP_SIZE; |
477 | if ( QApplication::desktop()->width() < 300 ) | 489 | if ( QApplication::desktop()->width() < 300 ) |
478 | size = 3; | 490 | size = 3; |
479 | int x = 1; | 491 | int x = 1; |
480 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 492 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
481 | if ( mInfo ) { | 493 | if ( mInfo ) { |
482 | x += size + 1; | 494 | x += size + 1; |
483 | } | 495 | } |
484 | if( mRecur ) { | 496 | if( mRecur ) { |
485 | x += size+1; | 497 | x += size+1; |
@@ -505,56 +517,56 @@ int MonthViewItem::width(const QListBox *lb) const | |||
505 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 517 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
506 | : KNoScrollListBox( par ), | 518 | : KNoScrollListBox( par ), |
507 | mMonthView( parent ) | 519 | mMonthView( parent ) |
508 | { | 520 | { |
509 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 521 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
510 | currentPalette = 0; | 522 | currentPalette = 0; |
511 | // mLabel = new QLabel( this );QPushButton | 523 | // mLabel = new QLabel( this );QPushButton |
512 | mLabel = new QPushButton( this ); | 524 | mLabel = new QPushButton( this ); |
513 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 525 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
514 | //mLabel->setLineWidth( 1 ); | 526 | //mLabel->setLineWidth( 1 ); |
515 | //mLabel->setAlignment( AlignCenter ); | 527 | //mLabel->setAlignment( AlignCenter ); |
516 | mLabel->setFlat( true ); | 528 | mLabel->setFlat( true ); |
517 | mLabel->setFocusPolicy(NoFocus); | 529 | mLabel->setFocusPolicy(Qt::NoFocus); |
518 | //mItemList = new KNoScrollListBox( this ); | 530 | //mItemList = new KNoScrollListBox( this ); |
519 | setMinimumSize( 10, 10 ); | 531 | setMinimumSize( 10, 10 ); |
520 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 532 | setFrameStyle( Q3Frame::Panel | Q3Frame::Plain ); |
521 | setLineWidth( 1 ); | 533 | setLineWidth( 1 ); |
522 | //topLayout->addWidget( mItemList ); | 534 | //topLayout->addWidget( mItemList ); |
523 | mLabel->raise(); | 535 | mLabel->raise(); |
524 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 536 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
525 | mStandardPalette = palette(); | 537 | mStandardPalette = palette(); |
526 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 538 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
527 | 539 | ||
528 | enableScrollBars( false ); | 540 | enableScrollBars( false ); |
529 | updateConfig(); | 541 | updateConfig(); |
530 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 542 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
531 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 543 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
532 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 544 | connect( this , SIGNAL( doubleClicked( Q3ListBoxItem *) ), |
533 | SLOT( defaultAction( QListBoxItem * ) ) ); | 545 | SLOT( defaultAction( Q3ListBoxItem * ) ) ); |
534 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 546 | connect( this, SIGNAL( rightButtonPressed( Q3ListBoxItem *, |
535 | const QPoint &) ), | 547 | const QPoint &) ), |
536 | SLOT( contextMenu( QListBoxItem * ) ) ); | 548 | SLOT( contextMenu( Q3ListBoxItem * ) ) ); |
537 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 549 | connect( this, SIGNAL( highlighted( Q3ListBoxItem *) ), |
538 | SLOT( selection( QListBoxItem * ) ) ); | 550 | SLOT( selection( Q3ListBoxItem * ) ) ); |
539 | 551 | ||
540 | /* | 552 | /* |
541 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 553 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
542 | SLOT( selection( QListBoxItem * ) ) ); | 554 | SLOT( selection( QListBoxItem * ) ) ); |
543 | */ | 555 | */ |
544 | } | 556 | } |
545 | #ifdef DESKTOP_VERSION | 557 | #ifdef DESKTOP_VERSION |
546 | QToolTipGroup *MonthViewCell::toolTipGroup() | 558 | QToolTipGroup *MonthViewCell::toolTipGroup() |
547 | { | 559 | { |
548 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 560 | /* TODO:hacker: if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); */ |
549 | return mToolTipGroup; | 561 | return mToolTipGroup; |
550 | } | 562 | } |
551 | #endif | 563 | #endif |
552 | 564 | ||
553 | void MonthViewCell::setDate( const QDate &date ) | 565 | void MonthViewCell::setDate( const QDate &date ) |
554 | { | 566 | { |
555 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 567 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
556 | mDate = date; | 568 | mDate = date; |
557 | 569 | ||
558 | 570 | ||
559 | 571 | ||
560 | //resizeEvent( 0 ); | 572 | //resizeEvent( 0 ); |
@@ -628,25 +640,25 @@ void MonthViewCell::setHoliday( const QString &holiday ) | |||
628 | { | 640 | { |
629 | mHolidayString = holiday; | 641 | mHolidayString = holiday; |
630 | 642 | ||
631 | if ( !holiday.isEmpty() ) { | 643 | if ( !holiday.isEmpty() ) { |
632 | setHoliday( true ); | 644 | setHoliday( true ); |
633 | } | 645 | } |
634 | } | 646 | } |
635 | 647 | ||
636 | void MonthViewCell::startUpdateCell() | 648 | void MonthViewCell::startUpdateCell() |
637 | { | 649 | { |
638 | blockSignals( true ); | 650 | blockSignals( true ); |
639 | mdayCount = 0; | 651 | mdayCount = 0; |
640 | setFocusPolicy(NoFocus); | 652 | setFocusPolicy(Qt::NoFocus); |
641 | if ( !mMonthView->isUpdatePossible() ) | 653 | if ( !mMonthView->isUpdatePossible() ) |
642 | return; | 654 | return; |
643 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 655 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
644 | while ( mitem ) { | 656 | while ( mitem ) { |
645 | mitem->setBlockRepaint( true ); | 657 | mitem->setBlockRepaint( true ); |
646 | mitem = (MonthViewItem *)mitem->next(); | 658 | mitem = (MonthViewItem *)mitem->next(); |
647 | } | 659 | } |
648 | if ( mAvailItemList.count() > 20 ) { | 660 | if ( mAvailItemList.count() > 20 ) { |
649 | mAvailItemList.setAutoDelete( true ); | 661 | mAvailItemList.setAutoDelete( true ); |
650 | mAvailItemList.clear(); | 662 | mAvailItemList.clear(); |
651 | mAvailItemList.setAutoDelete( false ); | 663 | mAvailItemList.setAutoDelete( false ); |
652 | clear(); | 664 | clear(); |
@@ -683,25 +695,25 @@ void MonthViewCell::startUpdateCell() | |||
683 | mToolTip.append ( mHolidayString ); | 695 | mToolTip.append ( mHolidayString ); |
684 | } | 696 | } |
685 | #endif | 697 | #endif |
686 | } | 698 | } |
687 | 699 | ||
688 | int MonthViewCell::insertEvent(Event *event) | 700 | int MonthViewCell::insertEvent(Event *event) |
689 | { | 701 | { |
690 | bool useToolTips = true; | 702 | bool useToolTips = true; |
691 | #ifndef DESKTOP_VERSION | 703 | #ifndef DESKTOP_VERSION |
692 | useToolTips = false; | 704 | useToolTips = false; |
693 | #endif | 705 | #endif |
694 | QString mToolTipText; | 706 | QString mToolTipText; |
695 | setFocusPolicy(WheelFocus); | 707 | setFocusPolicy(Qt::WheelFocus); |
696 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 708 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
697 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 709 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
698 | return mdayCount; | 710 | return mdayCount; |
699 | else | 711 | else |
700 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 712 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
701 | return mdayCount; | 713 | return mdayCount; |
702 | } | 714 | } |
703 | 715 | ||
704 | if ( event->isHoliday()) { | 716 | if ( event->isHoliday()) { |
705 | setHoliday( true ); | 717 | setHoliday( true ); |
706 | if ( mDate.dayOfWeek() == 7 ) | 718 | if ( mDate.dayOfWeek() == 7 ) |
707 | setLineWidth( 3 ); | 719 | setLineWidth( 3 ); |
@@ -825,41 +837,41 @@ int MonthViewCell::insertEvent(Event *event) | |||
825 | insertItem( item ,mdayCount); | 837 | insertItem( item ,mdayCount); |
826 | ++mdayCount; | 838 | ++mdayCount; |
827 | } else { | 839 | } else { |
828 | uint i = mdayCount; | 840 | uint i = mdayCount; |
829 | uint pos = mdayCount; | 841 | uint pos = mdayCount; |
830 | uint itcount = count(); | 842 | uint itcount = count(); |
831 | if ( itcount > 1000 ) { | 843 | if ( itcount > 1000 ) { |
832 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 844 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
833 | itcount = 0; | 845 | itcount = 0; |
834 | } | 846 | } |
835 | for ( i = pos; i < itcount;++i ) { | 847 | for ( i = pos; i < itcount;++i ) { |
836 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 848 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
837 | QListBoxItem* it = this->item ( i ); | 849 | Q3ListBoxItem* it = this->item ( i ); |
838 | if ( it && text < it->text() ) { | 850 | if ( it && text < it->text() ) { |
839 | pos = i; | 851 | pos = i; |
840 | break; | 852 | break; |
841 | } | 853 | } |
842 | ++pos; | 854 | ++pos; |
843 | } | 855 | } |
844 | insertItem( item ,pos); | 856 | insertItem( item ,pos); |
845 | } | 857 | } |
846 | if ( useToolTips ) { | 858 | if ( useToolTips ) { |
847 | mToolTip.append( mToolTipText ); | 859 | mToolTip.append( mToolTipText ); |
848 | } | 860 | } |
849 | return mdayCount; | 861 | return mdayCount; |
850 | } | 862 | } |
851 | void MonthViewCell::insertTodo(Todo *todo) | 863 | void MonthViewCell::insertTodo(Todo *todo) |
852 | { | 864 | { |
853 | setFocusPolicy(WheelFocus); | 865 | setFocusPolicy(Qt::WheelFocus); |
854 | QString text; | 866 | QString text; |
855 | if (todo->hasDueDate()) { | 867 | if (todo->hasDueDate()) { |
856 | if (!todo->doesFloat()) { | 868 | if (!todo->doesFloat()) { |
857 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 869 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
858 | text += " "; | 870 | text += " "; |
859 | } | 871 | } |
860 | } | 872 | } |
861 | text += todo->summary(); | 873 | text += todo->summary(); |
862 | MonthViewItem *item ; | 874 | MonthViewItem *item ; |
863 | if ( mAvailItemList.count() ) { | 875 | if ( mAvailItemList.count() ) { |
864 | item = mAvailItemList.first(); | 876 | item = mAvailItemList.first(); |
865 | mAvailItemList.remove( item ); | 877 | mAvailItemList.remove( item ); |
@@ -913,47 +925,47 @@ void MonthViewCell::repaintfinishUpdateCell() | |||
913 | mitem = (MonthViewItem *)mitem->next(); | 925 | mitem = (MonthViewItem *)mitem->next(); |
914 | } | 926 | } |
915 | blockSignals( false ); | 927 | blockSignals( false ); |
916 | } | 928 | } |
917 | void MonthViewCell::finishUpdateCell() | 929 | void MonthViewCell::finishUpdateCell() |
918 | { | 930 | { |
919 | 931 | ||
920 | 932 | ||
921 | 933 | ||
922 | #ifdef DESKTOP_VERSION | 934 | #ifdef DESKTOP_VERSION |
923 | if (mToolTip.count() > 0 ) { | 935 | if (mToolTip.count() > 0 ) { |
924 | mToolTip.sort(); | 936 | mToolTip.sort(); |
925 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 937 | /* TODO: hacker: QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); */ |
926 | } | 938 | } |
927 | #endif | 939 | #endif |
928 | //sort(); | 940 | //sort(); |
929 | //setMyPalette(); | 941 | //setMyPalette(); |
930 | setMyPalette(); | 942 | setMyPalette(); |
931 | 943 | ||
932 | resizeEvent( 0 ); | 944 | resizeEvent( 0 ); |
933 | 945 | ||
934 | } | 946 | } |
935 | void MonthViewCell::updateCell() | 947 | void MonthViewCell::updateCell() |
936 | { | 948 | { |
937 | if ( !mMonthView->isUpdatePossible() ) | 949 | if ( !mMonthView->isUpdatePossible() ) |
938 | return; | 950 | return; |
939 | startUpdateCell(); | 951 | startUpdateCell(); |
940 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 952 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
941 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 953 | Q3PtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
942 | Event *event; | 954 | Event *event; |
943 | for( event = events.first(); event; event = events.next() ) { // for event | 955 | for( event = events.first(); event; event = events.next() ) { // for event |
944 | insertEvent(event); | 956 | insertEvent(event); |
945 | } | 957 | } |
946 | // insert due todos | 958 | // insert due todos |
947 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 959 | Q3PtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
948 | Todo *todo; | 960 | Todo *todo; |
949 | for(todo = todos.first(); todo; todo = todos.next()) { | 961 | for(todo = todos.first(); todo; todo = todos.next()) { |
950 | insertTodo( todo ); | 962 | insertTodo( todo ); |
951 | } | 963 | } |
952 | finishUpdateCell(); | 964 | finishUpdateCell(); |
953 | // if ( isVisible()) | 965 | // if ( isVisible()) |
954 | //qApp->processEvents(); | 966 | //qApp->processEvents(); |
955 | } | 967 | } |
956 | 968 | ||
957 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 969 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
958 | { | 970 | { |
959 | 971 | ||
@@ -983,46 +995,46 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false | |||
983 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 995 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
984 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 996 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
985 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 997 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
986 | } | 998 | } |
987 | //updateCell(); | 999 | //updateCell(); |
988 | } | 1000 | } |
989 | 1001 | ||
990 | void MonthViewCell::enableScrollBars( bool enabled ) | 1002 | void MonthViewCell::enableScrollBars( bool enabled ) |
991 | { | 1003 | { |
992 | 1004 | ||
993 | return; | 1005 | return; |
994 | if ( enabled ) { | 1006 | if ( enabled ) { |
995 | QListBoxItem *fi = firstItem (); | 1007 | Q3ListBoxItem *fi = firstItem (); |
996 | if (fi ) { | 1008 | if (fi ) { |
997 | int ihei = fi->height( this ); | 1009 | int ihei = fi->height( this ); |
998 | int hei = numRows () * ihei; | 1010 | int hei = numRows () * ihei; |
999 | if ( hei < height() - horizontalScrollBar()->height () ) { | 1011 | if ( hei < height() - horizontalScrollBar()->height () ) { |
1000 | setVScrollBarMode(QScrollView::AlwaysOff); | 1012 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
1001 | } | 1013 | } |
1002 | else | 1014 | else |
1003 | setVScrollBarMode(QScrollView::Auto); | 1015 | setVScrollBarMode(Q3ScrollView::Auto); |
1004 | if ( ihei *3 > height() ) { | 1016 | if ( ihei *3 > height() ) { |
1005 | setHScrollBarMode(QScrollView::AlwaysOff); | 1017 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
1006 | } | 1018 | } |
1007 | else { | 1019 | else { |
1008 | setHScrollBarMode(QScrollView::Auto); | 1020 | setHScrollBarMode(Q3ScrollView::Auto); |
1009 | } | 1021 | } |
1010 | } else { | 1022 | } else { |
1011 | setVScrollBarMode(QScrollView::Auto); | 1023 | setVScrollBarMode(Q3ScrollView::Auto); |
1012 | setHScrollBarMode(QScrollView::Auto); | 1024 | setHScrollBarMode(Q3ScrollView::Auto); |
1013 | } | 1025 | } |
1014 | } else { | 1026 | } else { |
1015 | setVScrollBarMode(QScrollView::AlwaysOff); | 1027 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
1016 | setHScrollBarMode(QScrollView::AlwaysOff); | 1028 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
1017 | } | 1029 | } |
1018 | } | 1030 | } |
1019 | 1031 | ||
1020 | Incidence *MonthViewCell::selectedIncidence() | 1032 | Incidence *MonthViewCell::selectedIncidence() |
1021 | { | 1033 | { |
1022 | int index = currentItem(); | 1034 | int index = currentItem(); |
1023 | if ( index < 0 ) return 0; | 1035 | if ( index < 0 ) return 0; |
1024 | 1036 | ||
1025 | MonthViewItem *mitem = | 1037 | MonthViewItem *mitem = |
1026 | static_cast<MonthViewItem *>( item( index ) ); | 1038 | static_cast<MonthViewItem *>( item( index ) ); |
1027 | 1039 | ||
1028 | if ( !mitem ) return 0; | 1040 | if ( !mitem ) return 0; |
@@ -1074,75 +1086,75 @@ void MonthViewCell::resizeEvent ( QResizeEvent * e ) | |||
1074 | if ( size > 0 ) | 1086 | if ( size > 0 ) |
1075 | verticalScrollBar()->setMaximumHeight( size ); | 1087 | verticalScrollBar()->setMaximumHeight( size ); |
1076 | size = width() - mLabel->width() -lineWidth()-1; | 1088 | size = width() - mLabel->width() -lineWidth()-1; |
1077 | if ( size > 0 ) | 1089 | if ( size > 0 ) |
1078 | horizontalScrollBar()->setMaximumWidth( size ); | 1090 | horizontalScrollBar()->setMaximumWidth( size ); |
1079 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1091 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1080 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1092 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1081 | // mItemList->resize ( width(), height () ); | 1093 | // mItemList->resize ( width(), height () ); |
1082 | if ( e ) | 1094 | if ( e ) |
1083 | KNoScrollListBox::resizeEvent ( e ); | 1095 | KNoScrollListBox::resizeEvent ( e ); |
1084 | } | 1096 | } |
1085 | 1097 | ||
1086 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1098 | void MonthViewCell::defaultAction( Q3ListBoxItem *item ) |
1087 | { | 1099 | { |
1088 | 1100 | ||
1089 | if ( !item ) { | 1101 | if ( !item ) { |
1090 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1102 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1091 | emit newEventSignal( dt ); | 1103 | emit newEventSignal( dt ); |
1092 | return; | 1104 | return; |
1093 | } | 1105 | } |
1094 | 1106 | ||
1095 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1107 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1096 | Incidence *incidence = eventItem->incidence(); | 1108 | Incidence *incidence = eventItem->incidence(); |
1097 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1109 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1098 | } | 1110 | } |
1099 | void MonthViewCell::showDay() | 1111 | void MonthViewCell::showDay() |
1100 | { | 1112 | { |
1101 | emit showDaySignal( date() ); | 1113 | emit showDaySignal( date() ); |
1102 | } | 1114 | } |
1103 | void MonthViewCell::newEvent() | 1115 | void MonthViewCell::newEvent() |
1104 | { | 1116 | { |
1105 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1117 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1106 | emit newEventSignal( dt ); | 1118 | emit newEventSignal( dt ); |
1107 | } | 1119 | } |
1108 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1120 | void MonthViewCell::cellClicked( Q3ListBoxItem *item ) |
1109 | { | 1121 | { |
1110 | mMonthView->setSelectedCell( this ); | 1122 | mMonthView->setSelectedCell( this ); |
1111 | if ( item == 0 ) { | 1123 | if ( item == 0 ) { |
1112 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1124 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1113 | emit newEventSignal( dt ); | 1125 | emit newEventSignal( dt ); |
1114 | return; | 1126 | return; |
1115 | } | 1127 | } |
1116 | 1128 | ||
1117 | } | 1129 | } |
1118 | 1130 | ||
1119 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1131 | void MonthViewCell::contextMenu( Q3ListBoxItem *item ) |
1120 | { | 1132 | { |
1121 | mMonthView->setPopupCell( this ); | 1133 | mMonthView->setPopupCell( this ); |
1122 | if ( !item ) { | 1134 | if ( !item ) { |
1123 | mMonthView->showContextMenu( 0 ); | 1135 | mMonthView->showContextMenu( 0 ); |
1124 | return; | 1136 | return; |
1125 | } | 1137 | } |
1126 | //selection( item ); | 1138 | //selection( item ); |
1127 | //qApp->processEvents(); | 1139 | //qApp->processEvents(); |
1128 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1140 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1129 | Incidence *incidence = eventItem->incidence(); | 1141 | Incidence *incidence = eventItem->incidence(); |
1130 | if ( incidence ) { | 1142 | if ( incidence ) { |
1131 | mBlockDeselect = true; | 1143 | mBlockDeselect = true; |
1132 | mMonthView->showContextMenu( incidence ); | 1144 | mMonthView->showContextMenu( incidence ); |
1133 | } | 1145 | } |
1134 | } | 1146 | } |
1135 | 1147 | ||
1136 | void MonthViewCell::selection( QListBoxItem *item ) | 1148 | void MonthViewCell::selection( Q3ListBoxItem *item ) |
1137 | { | 1149 | { |
1138 | if ( !item ) { | 1150 | if ( !item ) { |
1139 | emit highlightIncidence( 0 , this, 0 ); | 1151 | emit highlightIncidence( 0 , this, 0 ); |
1140 | return; | 1152 | return; |
1141 | } | 1153 | } |
1142 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1154 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1143 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1155 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1144 | mMonthView->setSelectedCell( this ); | 1156 | mMonthView->setSelectedCell( this ); |
1145 | } | 1157 | } |
1146 | 1158 | ||
1147 | void MonthViewCell::deHighLight() | 1159 | void MonthViewCell::deHighLight() |
1148 | { | 1160 | { |
@@ -1176,26 +1188,26 @@ bool MonthViewCell::doHighLight( Incidence * inc ) | |||
1176 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1188 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1177 | : KOEventView( calendar, parent, name ), | 1189 | : KOEventView( calendar, parent, name ), |
1178 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1190 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1179 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1191 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1180 | { | 1192 | { |
1181 | mFlagKeyPressed = false; | 1193 | mFlagKeyPressed = false; |
1182 | mShortDayLabelsM = false; | 1194 | mShortDayLabelsM = false; |
1183 | mShortDayLabelsW = false; | 1195 | mShortDayLabelsW = false; |
1184 | skipResize = false; | 1196 | skipResize = false; |
1185 | clPending = true; | 1197 | clPending = true; |
1186 | mPopupCell = 0; | 1198 | mPopupCell = 0; |
1187 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1199 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1188 | mWidStack = new QWidgetStack( this ); | 1200 | mWidStack = new Q3WidgetStack( this ); |
1189 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1201 | Q3VBoxLayout* hb = new Q3VBoxLayout( this ); |
1190 | mMonthView = new QWidget( mWidStack ); | 1202 | mMonthView = new QWidget( mWidStack ); |
1191 | mWeekView = new QWidget( mWidStack ); | 1203 | mWeekView = new QWidget( mWidStack ); |
1192 | #if QT_VERSION >= 0x030000 | 1204 | #if QT_VERSION >= 0x030000 |
1193 | mWidStack->addWidget(mMonthView ); | 1205 | mWidStack->addWidget(mMonthView ); |
1194 | mWidStack->addWidget(mWeekView ); | 1206 | mWidStack->addWidget(mWeekView ); |
1195 | #else | 1207 | #else |
1196 | mWidStack->addWidget( mMonthView, 1 ); | 1208 | mWidStack->addWidget( mMonthView, 1 ); |
1197 | mWidStack->addWidget( mWeekView , 1 ); | 1209 | mWidStack->addWidget( mWeekView , 1 ); |
1198 | #endif | 1210 | #endif |
1199 | hb->addWidget( mNavigatorBar ); | 1211 | hb->addWidget( mNavigatorBar ); |
1200 | hb->addWidget( mWidStack ); | 1212 | hb->addWidget( mWidStack ); |
1201 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1213 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
@@ -1206,69 +1218,69 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
1206 | mDayLabels.resize( mDaysPerWeek ); | 1218 | mDayLabels.resize( mDaysPerWeek ); |
1207 | mDayLabelsW.resize( mDaysPerWeek ); | 1219 | mDayLabelsW.resize( mDaysPerWeek ); |
1208 | QFont bfont = font(); | 1220 | QFont bfont = font(); |
1209 | if ( QApplication::desktop()->width() < 650 ) { | 1221 | if ( QApplication::desktop()->width() < 650 ) { |
1210 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1222 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1211 | } | 1223 | } |
1212 | bfont.setBold( true ); | 1224 | bfont.setBold( true ); |
1213 | int i; | 1225 | int i; |
1214 | 1226 | ||
1215 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1227 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1216 | QLabel *label = new QLabel( mMonthView ); | 1228 | QLabel *label = new QLabel( mMonthView ); |
1217 | label->setFont(bfont); | 1229 | label->setFont(bfont); |
1218 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1230 | label->setFrameStyle(Q3Frame::Panel|Q3Frame::Raised); |
1219 | label->setLineWidth(1); | 1231 | label->setLineWidth(1); |
1220 | label->setAlignment(AlignCenter); | 1232 | label->setAlignment(Qt::AlignCenter); |
1221 | mDayLabels.insert( i, label ); | 1233 | mDayLabels.insert( i, label ); |
1222 | label = new QLabel( mWeekView ); | 1234 | label = new QLabel( mWeekView ); |
1223 | label->setFont(bfont); | 1235 | label->setFont(bfont); |
1224 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1236 | label->setFrameStyle(Q3Frame::Panel|Q3Frame::Raised); |
1225 | label->setLineWidth(1); | 1237 | label->setLineWidth(1); |
1226 | label->setAlignment(AlignCenter); | 1238 | label->setAlignment(Qt::AlignCenter); |
1227 | mDayLabelsW.insert( i, label ); | 1239 | mDayLabelsW.insert( i, label ); |
1228 | } | 1240 | } |
1229 | 1241 | ||
1230 | bfont.setBold( false ); | 1242 | bfont.setBold( false ); |
1231 | mWeekLabels.resize( mNumWeeks+1 ); | 1243 | mWeekLabels.resize( mNumWeeks+1 ); |
1232 | mWeekLabelsW.resize( 2 ); | 1244 | mWeekLabelsW.resize( 2 ); |
1233 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1245 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1234 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1246 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1235 | label->setFocusPolicy(NoFocus); | 1247 | label->setFocusPolicy(Qt::NoFocus); |
1236 | label->setFont(bfont); | 1248 | label->setFont(bfont); |
1237 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1249 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1238 | label->setFlat(true); | 1250 | label->setFlat(true); |
1239 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1251 | Q3WhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1240 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1252 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1241 | //label->setLineWidth(1); | 1253 | //label->setLineWidth(1); |
1242 | //label->setAlignment(AlignCenter); | 1254 | //label->setAlignment(AlignCenter); |
1243 | mWeekLabels.insert( i, label ); | 1255 | mWeekLabels.insert( i, label ); |
1244 | } | 1256 | } |
1245 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1257 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1246 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1258 | mWeekLabels[mNumWeeks]->setFocusPolicy(Qt::WheelFocus); |
1247 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1259 | Q3WhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1248 | 1260 | ||
1249 | for( i = 0; i < 1+1; i++ ) { | 1261 | for( i = 0; i < 1+1; i++ ) { |
1250 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1262 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1251 | label->setFocusPolicy(NoFocus); | 1263 | label->setFocusPolicy(Qt::NoFocus); |
1252 | label->setFont(bfont); | 1264 | label->setFont(bfont); |
1253 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1265 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1254 | label->setFlat(true); | 1266 | label->setFlat(true); |
1255 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1267 | Q3WhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1256 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1268 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1257 | //label->setLineWidth(1); | 1269 | //label->setLineWidth(1); |
1258 | //label->setAlignment(AlignCenter); | 1270 | //label->setAlignment(AlignCenter); |
1259 | mWeekLabelsW.insert( i, label ); | 1271 | mWeekLabelsW.insert( i, label ); |
1260 | } | 1272 | } |
1261 | mWeekLabelsW[1]->setText( i18n("W")); | 1273 | mWeekLabelsW[1]->setText( i18n("W")); |
1262 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1274 | mWeekLabelsW[1]->setFocusPolicy(Qt::WheelFocus); |
1263 | 1275 | ||
1264 | 1276 | ||
1265 | int row, col; | 1277 | int row, col; |
1266 | mCells.resize( mNumCells ); | 1278 | mCells.resize( mNumCells ); |
1267 | for( row = 0; row < mNumWeeks; ++row ) { | 1279 | for( row = 0; row < mNumWeeks; ++row ) { |
1268 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1280 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1269 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1281 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1270 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1282 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1271 | 1283 | ||
1272 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1284 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1273 | SLOT( defaultAction( Incidence * ) ) ); | 1285 | SLOT( defaultAction( Incidence * ) ) ); |
1274 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1286 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
@@ -1296,45 +1308,45 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
1296 | SIGNAL( showDaySignal( QDate ) ) ); | 1308 | SIGNAL( showDaySignal( QDate ) ) ); |
1297 | connect( cell, SIGNAL( nextCell() ), | 1309 | connect( cell, SIGNAL( nextCell() ), |
1298 | SLOT( nextCell() ) ); | 1310 | SLOT( nextCell() ) ); |
1299 | connect( cell, SIGNAL( prevCell() ), | 1311 | connect( cell, SIGNAL( prevCell() ), |
1300 | SLOT( prevCell() ) ); | 1312 | SLOT( prevCell() ) ); |
1301 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1313 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1302 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1314 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1303 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1315 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1304 | } | 1316 | } |
1305 | 1317 | ||
1306 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1318 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1307 | mContextMenu = eventPopup(); | 1319 | mContextMenu = eventPopup(); |
1308 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1320 | mContextMenu->addAdditionalItem(QIcon(QPixmap()), |
1309 | i18n("New Event..."),this, | 1321 | i18n("New Event..."),this, |
1310 | SLOT(slotNewEvent()),false); | 1322 | SLOT(slotNewEvent()),false); |
1311 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1323 | mContextMenu->addAdditionalItem(QIcon(QPixmap()), |
1312 | i18n("New Todo..."),this, | 1324 | i18n("New Todo..."),this, |
1313 | SLOT(slotNewTodo()),false); | 1325 | SLOT(slotNewTodo()),false); |
1314 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1326 | mContextMenu->addAdditionalItem(QIcon(QPixmap()), |
1315 | i18n("Journal"),this, | 1327 | i18n("Journal"),this, |
1316 | SLOT(slotEditJournal()),false); | 1328 | SLOT(slotEditJournal()),false); |
1317 | 1329 | ||
1318 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1330 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1319 | SLOT( catChanged( Incidence * ) )); | 1331 | SLOT( catChanged( Incidence * ) )); |
1320 | 1332 | ||
1321 | 1333 | ||
1322 | QString pathString = ""; | 1334 | QString pathString = ""; |
1323 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1335 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1324 | if ( QApplication::desktop()->width() < 480 ) | 1336 | if ( QApplication::desktop()->width() < 480 ) |
1325 | pathString += "icons16/"; | 1337 | pathString += "icons16/"; |
1326 | } else | 1338 | } else |
1327 | pathString += "iconsmini/"; | 1339 | pathString += "iconsmini/"; |
1328 | mNewItemMenu = new QPopupMenu( this ); | 1340 | mNewItemMenu = new Q3PopupMenu( this ); |
1329 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1341 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1330 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1342 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1331 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1343 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1332 | 1344 | ||
1333 | // updateConfig(); //useless here... | 1345 | // updateConfig(); //useless here... |
1334 | // ... but we need mWidthLongDayLabel computed | 1346 | // ... but we need mWidthLongDayLabel computed |
1335 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1347 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1336 | mWidthLongDayLabel = 0; | 1348 | mWidthLongDayLabel = 0; |
1337 | for (int i = 0; i < 7; i++) { | 1349 | for (int i = 0; i < 7; i++) { |
1338 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1350 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1339 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1351 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1340 | } | 1352 | } |
@@ -1388,25 +1400,25 @@ void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int | |||
1388 | lastCell = mc; | 1400 | lastCell = mc; |
1389 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1401 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1390 | 1402 | ||
1391 | bool weekview = false; | 1403 | bool weekview = false; |
1392 | uint index = 0; | 1404 | uint index = 0; |
1393 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1405 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1394 | if ( mCellsW[i] == mc ) { | 1406 | if ( mCellsW[i] == mc ) { |
1395 | weekview = true; | 1407 | weekview = true; |
1396 | index = i; | 1408 | index = i; |
1397 | break; | 1409 | break; |
1398 | } | 1410 | } |
1399 | } | 1411 | } |
1400 | QPtrVector<MonthViewCell> *cells; | 1412 | Q3PtrVector<MonthViewCell> *cells; |
1401 | if ( weekview ) | 1413 | if ( weekview ) |
1402 | cells = &mCellsW; | 1414 | cells = &mCellsW; |
1403 | else { | 1415 | else { |
1404 | for (uint i = 0; i < mCells.count(); ++i) { | 1416 | for (uint i = 0; i < mCells.count(); ++i) { |
1405 | if ( mCells[i] == mc ) { | 1417 | if ( mCells[i] == mc ) { |
1406 | index = i; | 1418 | index = i; |
1407 | break; | 1419 | break; |
1408 | } | 1420 | } |
1409 | } | 1421 | } |
1410 | cells = &mCells; | 1422 | cells = &mCells; |
1411 | } | 1423 | } |
1412 | for (uint i = 0; i < (*cells).count(); ++i) { | 1424 | for (uint i = 0; i < (*cells).count(); ++i) { |
@@ -1486,27 +1498,27 @@ void KOMonthView::switchView() | |||
1486 | } | 1498 | } |
1487 | 1499 | ||
1488 | int KOMonthView::maxDatesHint() | 1500 | int KOMonthView::maxDatesHint() |
1489 | { | 1501 | { |
1490 | return mNumCells; | 1502 | return mNumCells; |
1491 | } | 1503 | } |
1492 | 1504 | ||
1493 | int KOMonthView::currentDateCount() | 1505 | int KOMonthView::currentDateCount() |
1494 | { | 1506 | { |
1495 | return mNumCells; | 1507 | return mNumCells; |
1496 | } | 1508 | } |
1497 | 1509 | ||
1498 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1510 | Q3PtrList<Incidence> KOMonthView::selectedIncidences() |
1499 | { | 1511 | { |
1500 | QPtrList<Incidence> selected; | 1512 | Q3PtrList<Incidence> selected; |
1501 | 1513 | ||
1502 | if ( mSelectedCell ) { | 1514 | if ( mSelectedCell ) { |
1503 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1515 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1504 | if ( incidence ) selected.append( incidence ); | 1516 | if ( incidence ) selected.append( incidence ); |
1505 | } | 1517 | } |
1506 | 1518 | ||
1507 | return selected; | 1519 | return selected; |
1508 | } | 1520 | } |
1509 | 1521 | ||
1510 | DateList KOMonthView::selectedDates() | 1522 | DateList KOMonthView::selectedDates() |
1511 | { | 1523 | { |
1512 | DateList selected; | 1524 | DateList selected; |
@@ -1552,33 +1564,33 @@ void KOMonthView::updateConfig() | |||
1552 | updateDayLabels(); | 1564 | updateDayLabels(); |
1553 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1565 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1554 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1566 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1555 | //resizeEvent( 0 ); | 1567 | //resizeEvent( 0 ); |
1556 | for (uint i = 0; i < mCells.count(); ++i) { | 1568 | for (uint i = 0; i < mCells.count(); ++i) { |
1557 | mCells[i]->updateConfig(); | 1569 | mCells[i]->updateConfig(); |
1558 | } | 1570 | } |
1559 | 1571 | ||
1560 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1572 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1561 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1573 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1562 | } | 1574 | } |
1563 | #ifdef DESKTOP_VERSION | 1575 | #ifdef DESKTOP_VERSION |
1564 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1576 | /* TODO:hacker: MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); */ |
1565 | #endif | 1577 | #endif |
1566 | updateView(); | 1578 | updateView(); |
1567 | } | 1579 | } |
1568 | 1580 | ||
1569 | void KOMonthView::updateDayLabels() | 1581 | void KOMonthView::updateDayLabels() |
1570 | { | 1582 | { |
1571 | 1583 | ||
1572 | QPtrVector<QLabel> *mDayLabelsT; | 1584 | Q3PtrVector<QLabel> *mDayLabelsT; |
1573 | 1585 | ||
1574 | mDayLabelsT = &mDayLabelsW; | 1586 | mDayLabelsT = &mDayLabelsW; |
1575 | for (int i = 0; i < 7; i++) { | 1587 | for (int i = 0; i < 7; i++) { |
1576 | { | 1588 | { |
1577 | bool show = mShortDayLabelsW; | 1589 | bool show = mShortDayLabelsW; |
1578 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1590 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1579 | show = true; | 1591 | show = true; |
1580 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1592 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1581 | } | 1593 | } |
1582 | } | 1594 | } |
1583 | mDayLabelsT = &mDayLabels; | 1595 | mDayLabelsT = &mDayLabels; |
1584 | for (int i = 0; i < 7; i++) { | 1596 | for (int i = 0; i < 7; i++) { |
@@ -1601,27 +1613,27 @@ void KOMonthView::clearList() | |||
1601 | unsigned int i; | 1613 | unsigned int i; |
1602 | for( i = 0; i < mCells.size(); ++i ) { | 1614 | for( i = 0; i < mCells.size(); ++i ) { |
1603 | mCells[i]->clear(); | 1615 | mCells[i]->clear(); |
1604 | } | 1616 | } |
1605 | for( i = 0; i < mCellsW.size(); ++i ) { | 1617 | for( i = 0; i < mCellsW.size(); ++i ) { |
1606 | mCellsW[i]->clear(); | 1618 | mCellsW[i]->clear(); |
1607 | } | 1619 | } |
1608 | } | 1620 | } |
1609 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1621 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1610 | { | 1622 | { |
1611 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1623 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1612 | 1624 | ||
1613 | QPtrVector<MonthViewCell> *cells; | 1625 | Q3PtrVector<MonthViewCell> *cells; |
1614 | QPtrVector<QLabel> *dayLabels; | 1626 | Q3PtrVector<QLabel> *dayLabels; |
1615 | QPtrVector<KOWeekButton> *weekLabels; | 1627 | Q3PtrVector<KOWeekButton> *weekLabels; |
1616 | uint weekNum = 6; | 1628 | uint weekNum = 6; |
1617 | mStartDate = start; | 1629 | mStartDate = start; |
1618 | if ( mShowWeekView ) { | 1630 | if ( mShowWeekView ) { |
1619 | weekNum = 1; | 1631 | weekNum = 1; |
1620 | cells = &mCellsW; | 1632 | cells = &mCellsW; |
1621 | dayLabels = &mDayLabelsW; | 1633 | dayLabels = &mDayLabelsW; |
1622 | weekLabels = &mWeekLabelsW; | 1634 | weekLabels = &mWeekLabelsW; |
1623 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1635 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1624 | mStartDate = mStartDate.addDays( 1 ); | 1636 | mStartDate = mStartDate.addDays( 1 ); |
1625 | } | 1637 | } |
1626 | } else { | 1638 | } else { |
1627 | cells = &mCells; | 1639 | cells = &mCells; |
@@ -1659,62 +1671,62 @@ void KOMonthView::showDates(const QDate &start, const QDate &) | |||
1659 | // not just 1. | 1671 | // not just 1. |
1660 | int dayOfYear = date.dayOfYear(); | 1672 | int dayOfYear = date.dayOfYear(); |
1661 | if (dayOfYear % 7 != 0) | 1673 | if (dayOfYear % 7 != 0) |
1662 | wno = dayOfYear / 7 + 1; | 1674 | wno = dayOfYear / 7 + 1; |
1663 | else | 1675 | else |
1664 | wno =dayOfYear / 7; | 1676 | wno =dayOfYear / 7; |
1665 | (*weekLabels)[i]->setWeekNum( wno ); | 1677 | (*weekLabels)[i]->setWeekNum( wno ); |
1666 | date = date.addDays( 7 ); | 1678 | date = date.addDays( 7 ); |
1667 | } | 1679 | } |
1668 | updateView(); | 1680 | updateView(); |
1669 | } | 1681 | } |
1670 | 1682 | ||
1671 | void KOMonthView::showEvents(QPtrList<Event>) | 1683 | void KOMonthView::showEvents(Q3PtrList<Event>) |
1672 | { | 1684 | { |
1673 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1685 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1674 | } | 1686 | } |
1675 | 1687 | ||
1676 | void KOMonthView::changeEventDisplay(Event *, int) | 1688 | void KOMonthView::changeEventDisplay(Event *, int) |
1677 | { | 1689 | { |
1678 | // this should be re-written to be much more efficient, but this | 1690 | // this should be re-written to be much more efficient, but this |
1679 | // quick-and-dirty-hack gets the job done for right now. | 1691 | // quick-and-dirty-hack gets the job done for right now. |
1680 | //qDebug("KOMonthView::changeEventDisplay "); | 1692 | //qDebug("KOMonthView::changeEventDisplay "); |
1681 | updateView(); | 1693 | updateView(); |
1682 | } | 1694 | } |
1683 | 1695 | ||
1684 | void KOMonthView::updateView() | 1696 | void KOMonthView::updateView() |
1685 | { | 1697 | { |
1686 | 1698 | ||
1687 | if ( !updatePossible ) | 1699 | if ( !updatePossible ) |
1688 | return; | 1700 | return; |
1689 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1701 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1690 | //QTime ti; | 1702 | //QTime ti; |
1691 | //ti.start(); | 1703 | //ti.start(); |
1692 | clearSelection(); | 1704 | clearSelection(); |
1693 | QPtrVector<MonthViewCell> *cells; | 1705 | Q3PtrVector<MonthViewCell> *cells; |
1694 | if ( mShowWeekView ) { | 1706 | if ( mShowWeekView ) { |
1695 | cells = &mCellsW; | 1707 | cells = &mCellsW; |
1696 | } else { | 1708 | } else { |
1697 | cells = &mCells; | 1709 | cells = &mCells; |
1698 | } | 1710 | } |
1699 | #if 1 | 1711 | #if 1 |
1700 | int i; | 1712 | int i; |
1701 | int timeSpan = (*cells).size()-1; | 1713 | int timeSpan = (*cells).size()-1; |
1702 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1714 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1703 | timeSpan = 6; | 1715 | timeSpan = 6; |
1704 | for( i = 0; i < timeSpan + 1; ++i ) { | 1716 | for( i = 0; i < timeSpan + 1; ++i ) { |
1705 | (*cells)[i]->startUpdateCell(); | 1717 | (*cells)[i]->startUpdateCell(); |
1706 | } | 1718 | } |
1707 | 1719 | ||
1708 | QPtrList<Event> events = calendar()->events(); | 1720 | Q3PtrList<Event> events = calendar()->events(); |
1709 | Event *event; | 1721 | Event *event; |
1710 | QDateTime dt; | 1722 | QDateTime dt; |
1711 | QDate endDate = mStartDate.addDays( timeSpan ); | 1723 | QDate endDate = mStartDate.addDays( timeSpan ); |
1712 | for( event = events.first(); event; event = events.next() ) { // for event | 1724 | for( event = events.first(); event; event = events.next() ) { // for event |
1713 | if ( event->doesRecur() ) { | 1725 | if ( event->doesRecur() ) { |
1714 | bool last; | 1726 | bool last; |
1715 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1727 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1716 | QDateTime incidenceEnd; | 1728 | QDateTime incidenceEnd; |
1717 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1729 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1718 | bool invalid = false; | 1730 | bool invalid = false; |
1719 | while( true ) { | 1731 | while( true ) { |
1720 | if ( incidenceStart.isValid() ) { | 1732 | if ( incidenceStart.isValid() ) { |
@@ -1760,25 +1772,25 @@ void KOMonthView::updateView() | |||
1760 | //normalize | 1772 | //normalize |
1761 | st = timeSpan - st; | 1773 | st = timeSpan - st; |
1762 | if ( st < 0 ) st = 0; | 1774 | if ( st < 0 ) st = 0; |
1763 | if ( end > timeSpan ) end = timeSpan; | 1775 | if ( end > timeSpan ) end = timeSpan; |
1764 | int iii; | 1776 | int iii; |
1765 | for ( iii = st;iii<= end;++iii) | 1777 | for ( iii = st;iii<= end;++iii) |
1766 | (*cells)[iii]->insertEvent( event ); | 1778 | (*cells)[iii]->insertEvent( event ); |
1767 | } | 1779 | } |
1768 | } | 1780 | } |
1769 | } | 1781 | } |
1770 | } | 1782 | } |
1771 | // insert due todos | 1783 | // insert due todos |
1772 | QPtrList<Todo> todos = calendar()->todos( ); | 1784 | Q3PtrList<Todo> todos = calendar()->todos( ); |
1773 | Todo *todo; | 1785 | Todo *todo; |
1774 | for(todo = todos.first(); todo; todo = todos.next()) { | 1786 | for(todo = todos.first(); todo; todo = todos.next()) { |
1775 | //insertTodo( todo ); | 1787 | //insertTodo( todo ); |
1776 | if ( todo->hasDueDate() ) { | 1788 | if ( todo->hasDueDate() ) { |
1777 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1789 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1778 | if ( day >= 0 && day < timeSpan + 1) { | 1790 | if ( day >= 0 && day < timeSpan + 1) { |
1779 | (*cells)[day]->insertTodo( todo ); | 1791 | (*cells)[day]->insertTodo( todo ); |
1780 | } | 1792 | } |
1781 | } | 1793 | } |
1782 | } | 1794 | } |
1783 | 1795 | ||
1784 | for( i = 0; i < timeSpan+1; ++i ) { | 1796 | for( i = 0; i < timeSpan+1; ++i ) { |
@@ -2216,25 +2228,25 @@ void KOMonthView::setSelectedCell( MonthViewCell *cell ) | |||
2216 | } else | 2228 | } else |
2217 | mSelectedCell = cell; | 2229 | mSelectedCell = cell; |
2218 | // if ( mSelectedCell ) | 2230 | // if ( mSelectedCell ) |
2219 | // mSelectedCell->select(); | 2231 | // mSelectedCell->select(); |
2220 | if ( !mSelectedCell ) | 2232 | if ( !mSelectedCell ) |
2221 | emit incidenceSelected( 0 ); | 2233 | emit incidenceSelected( 0 ); |
2222 | else | 2234 | else |
2223 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 2235 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
2224 | } | 2236 | } |
2225 | 2237 | ||
2226 | void KOMonthView::processSelectionChange() | 2238 | void KOMonthView::processSelectionChange() |
2227 | { | 2239 | { |
2228 | QPtrList<Incidence> incidences = selectedIncidences(); | 2240 | Q3PtrList<Incidence> incidences = selectedIncidences(); |
2229 | if (incidences.count() > 0) { | 2241 | if (incidences.count() > 0) { |
2230 | emit incidenceSelected( incidences.first() ); | 2242 | emit incidenceSelected( incidences.first() ); |
2231 | } else { | 2243 | } else { |
2232 | emit incidenceSelected( 0 ); | 2244 | emit incidenceSelected( 0 ); |
2233 | clearSelection(); | 2245 | clearSelection(); |
2234 | } | 2246 | } |
2235 | } | 2247 | } |
2236 | 2248 | ||
2237 | void KOMonthView::clearSelection() | 2249 | void KOMonthView::clearSelection() |
2238 | { | 2250 | { |
2239 | if ( mSelectedCell ) { | 2251 | if ( mSelectedCell ) { |
2240 | mSelectedCell->deselect(); | 2252 | mSelectedCell->deselect(); |
@@ -2252,55 +2264,55 @@ void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | |||
2252 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2264 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2253 | { | 2265 | { |
2254 | 2266 | ||
2255 | qApp->processEvents(); | 2267 | qApp->processEvents(); |
2256 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2268 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2257 | //e->ignore(); | 2269 | //e->ignore(); |
2258 | e->accept(); | 2270 | e->accept(); |
2259 | return; | 2271 | return; |
2260 | } | 2272 | } |
2261 | if (! e->isAutoRepeat() ) | 2273 | if (! e->isAutoRepeat() ) |
2262 | mFlagKeyPressed = true; | 2274 | mFlagKeyPressed = true; |
2263 | switch(e->key()) { | 2275 | switch(e->key()) { |
2264 | case Key_Up: | 2276 | case Qt::Key_Up: |
2265 | { | 2277 | { |
2266 | if ( mShowWeekView ) { | 2278 | if ( mShowWeekView ) { |
2267 | emit selectWeekNum ( currentWeek() - 1 ); | 2279 | emit selectWeekNum ( currentWeek() - 1 ); |
2268 | } | 2280 | } |
2269 | else { | 2281 | else { |
2270 | emit prevMonth(); | 2282 | emit prevMonth(); |
2271 | } | 2283 | } |
2272 | } | 2284 | } |
2273 | e->accept(); | 2285 | e->accept(); |
2274 | break; | 2286 | break; |
2275 | case Key_Down: | 2287 | case Qt::Key_Down: |
2276 | { | 2288 | { |
2277 | if ( mShowWeekView ) { | 2289 | if ( mShowWeekView ) { |
2278 | emit selectWeekNum ( currentWeek() +1); | 2290 | emit selectWeekNum ( currentWeek() +1); |
2279 | } | 2291 | } |
2280 | else { | 2292 | else { |
2281 | emit nextMonth(); | 2293 | emit nextMonth(); |
2282 | } | 2294 | } |
2283 | 2295 | ||
2284 | } | 2296 | } |
2285 | e->accept(); | 2297 | e->accept(); |
2286 | break; | 2298 | break; |
2287 | case Key_Return: | 2299 | case Qt::Key_Return: |
2288 | case Key_Enter: | 2300 | case Qt::Key_Enter: |
2289 | { | 2301 | { |
2290 | selectInternalWeekNum ( currentWeek() ); | 2302 | selectInternalWeekNum ( currentWeek() ); |
2291 | } | 2303 | } |
2292 | e->accept(); | 2304 | e->accept(); |
2293 | break; | 2305 | break; |
2294 | case Key_D: | 2306 | case Qt::Key_D: |
2295 | if ( mSelectedCell ) { | 2307 | if ( mSelectedCell ) { |
2296 | mSelectedCell->showDay(); | 2308 | mSelectedCell->showDay(); |
2297 | e->accept(); | 2309 | e->accept(); |
2298 | } else { | 2310 | } else { |
2299 | e->ignore(); | 2311 | e->ignore(); |
2300 | } | 2312 | } |
2301 | break; | 2313 | break; |
2302 | default: | 2314 | default: |
2303 | e->ignore(); | 2315 | e->ignore(); |
2304 | break; | 2316 | break; |
2305 | } | 2317 | } |
2306 | } | 2318 | } |