-rw-r--r-- | korganizer/komonthview.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index f9bc1ca..2fe80af 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,294 +1,296 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.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 <qwhatsthis.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 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | } | 86 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 88 | { |
89 | 89 | ||
90 | } | 90 | } |
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
92 | { | 92 | { |
93 | QListBoxItem* item = itemAt ( p ); | 93 | QListBoxItem* item = itemAt ( p ); |
94 | if ( ! item ) { | 94 | if ( ! item ) { |
95 | return i18n("Click in the cell\nto add an event!"); | 95 | return i18n("Click in the cell\nto add an event!"); |
96 | } | 96 | } |
97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
98 | KOPrefs::instance()->mWTshowDetails, | ||
99 | KOPrefs::instance()->mWTshowCreated, | ||
100 | KOPrefs::instance()->mWTshowChanged); | ||
98 | } | 101 | } |
99 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
100 | { | 103 | { |
101 | 104 | ||
102 | switch(e->key()) { | 105 | switch(e->key()) { |
103 | case Key_Right: | 106 | case Key_Right: |
104 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
105 | { | 108 | { |
106 | e->ignore(); | 109 | e->ignore(); |
107 | return; | 110 | return; |
108 | } | 111 | } |
109 | scrollBy(10,0); | 112 | scrollBy(10,0); |
110 | break; | 113 | break; |
111 | case Key_Left: | 114 | case Key_Left: |
112 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
113 | { | 116 | { |
114 | e->ignore(); | 117 | e->ignore(); |
115 | return; | 118 | return; |
116 | } | 119 | } |
117 | scrollBy(-10,0); | 120 | scrollBy(-10,0); |
118 | break; | 121 | break; |
119 | case Key_Up: | 122 | case Key_Up: |
120 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
121 | e->ignore(); | 124 | e->ignore(); |
122 | break; | 125 | break; |
123 | } | 126 | } |
124 | setCurrentItem((currentItem()+count()-1)%count()); | 127 | setCurrentItem((currentItem()+count()-1)%count()); |
125 | if(!itemVisible(currentItem())) { | 128 | if(!itemVisible(currentItem())) { |
126 | if((unsigned int) currentItem() == (count()-1)) { | 129 | if((unsigned int) currentItem() == (count()-1)) { |
127 | setTopItem(currentItem()-numItemsVisible()+1); | 130 | setTopItem(currentItem()-numItemsVisible()+1); |
128 | } else { | 131 | } else { |
129 | setTopItem(topItem()-1); | 132 | setTopItem(topItem()-1); |
130 | } | 133 | } |
131 | } | 134 | } |
132 | break; | 135 | break; |
133 | case Key_Down: | 136 | case Key_Down: |
134 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
135 | e->ignore(); | 138 | e->ignore(); |
136 | break; | 139 | break; |
137 | } | 140 | } |
138 | setCurrentItem((currentItem()+1)%count()); | 141 | setCurrentItem((currentItem()+1)%count()); |
139 | if(!itemVisible(currentItem())) { | 142 | if(!itemVisible(currentItem())) { |
140 | if(currentItem() == 0) { | 143 | if(currentItem() == 0) { |
141 | setTopItem(0); | 144 | setTopItem(0); |
142 | } else { | 145 | } else { |
143 | setTopItem(topItem()+1); | 146 | setTopItem(topItem()+1); |
144 | } | 147 | } |
145 | } | 148 | } |
146 | break; | 149 | break; |
147 | case Key_I: | 150 | case Key_I: |
148 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
149 | e->ignore(); | 152 | e->ignore(); |
150 | break; | 153 | break; |
151 | case Key_Shift: | 154 | case Key_Shift: |
152 | emit shiftDown(); | 155 | emit shiftDown(); |
153 | break; | 156 | break; |
154 | default: | 157 | default: |
155 | e->ignore(); | 158 | e->ignore(); |
156 | break; | 159 | break; |
157 | } | 160 | } |
158 | } | 161 | } |
159 | 162 | ||
160 | void KNoScrollListBox::oneDown() | 163 | void KNoScrollListBox::oneDown() |
161 | { | 164 | { |
162 | setCurrentItem((currentItem()+1)%count()); | 165 | setCurrentItem((currentItem()+1)%count()); |
163 | if(!itemVisible(currentItem())) { | 166 | if(!itemVisible(currentItem())) { |
164 | if(currentItem() == 0) { | 167 | if(currentItem() == 0) { |
165 | setTopItem(0); | 168 | setTopItem(0); |
166 | } else { | 169 | } else { |
167 | setTopItem(topItem()+1); | 170 | setTopItem(topItem()+1); |
168 | } | 171 | } |
169 | } | 172 | } |
170 | } | 173 | } |
171 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
172 | { | 175 | { |
173 | switch(e->key()) { | 176 | switch(e->key()) { |
174 | case Key_Shift: | 177 | case Key_Shift: |
175 | emit shiftUp(); | 178 | emit shiftUp(); |
176 | break; | 179 | break; |
177 | default: | 180 | default: |
178 | break; | 181 | break; |
179 | } | 182 | } |
180 | } | 183 | } |
181 | 184 | ||
182 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
183 | { | 186 | { |
184 | QListBox::mousePressEvent(e); | 187 | QListBox::mousePressEvent(e); |
185 | 188 | ||
186 | if(e->button() == RightButton) { | 189 | if(e->button() == RightButton) { |
187 | emit rightClick(); | 190 | emit rightClick(); |
188 | } | 191 | } |
189 | } | 192 | } |
190 | 193 | ||
191 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
192 | : QListBoxItem() | 195 | : QListBoxItem() |
193 | { | 196 | { |
194 | setText( s ); | 197 | setText( s ); |
195 | 198 | ||
196 | mIncidence = incidence; | 199 | mIncidence = incidence; |
197 | mDate = qd; | 200 | mDate = qd; |
198 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | ||
199 | mRecur = false; | 201 | mRecur = false; |
200 | mAlarm = false; | 202 | mAlarm = false; |
201 | mReply = false; | 203 | mReply = false; |
202 | mInfo = false; | 204 | mInfo = false; |
203 | } | 205 | } |
204 | 206 | ||
205 | void MonthViewItem::paint(QPainter *p) | 207 | void MonthViewItem::paint(QPainter *p) |
206 | { | 208 | { |
207 | #if QT_VERSION >= 0x030000 | 209 | #if QT_VERSION >= 0x030000 |
208 | bool sel = isSelected(); | 210 | bool sel = isSelected(); |
209 | #else | 211 | #else |
210 | bool sel = selected(); | 212 | bool sel = selected(); |
211 | #endif | 213 | #endif |
212 | 214 | ||
213 | 215 | ||
214 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 216 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
215 | { | 217 | { |
216 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 218 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
217 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 219 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
218 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 220 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
219 | } | 221 | } |
220 | int x = 1; | 222 | int x = 1; |
221 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 223 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
222 | int size = PIXMAP_SIZE; | 224 | int size = PIXMAP_SIZE; |
223 | if ( QApplication::desktop()->width() < 300 ) | 225 | if ( QApplication::desktop()->width() < 300 ) |
224 | size = 3; | 226 | size = 3; |
225 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 227 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
226 | if ( mInfo ) { | 228 | if ( mInfo ) { |
227 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 229 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
228 | x += size + 1; | 230 | x += size + 1; |
229 | } | 231 | } |
230 | if ( mRecur ) { | 232 | if ( mRecur ) { |
231 | p->fillRect ( x, y,size,size, Qt::blue ); | 233 | p->fillRect ( x, y,size,size, Qt::blue ); |
232 | x += size + 1; | 234 | x += size + 1; |
233 | } | 235 | } |
234 | if ( mAlarm ) { | 236 | if ( mAlarm ) { |
235 | p->fillRect ( x, y,size,size, Qt::red ); | 237 | p->fillRect ( x, y,size,size, Qt::red ); |
236 | x += size + 1; | 238 | x += size + 1; |
237 | } | 239 | } |
238 | if ( mReply ) { | 240 | if ( mReply ) { |
239 | p->fillRect ( x, y,size,size, Qt::yellow ); | 241 | p->fillRect ( x, y,size,size, Qt::yellow ); |
240 | x += size + 1; | 242 | x += size + 1; |
241 | } | 243 | } |
242 | } | 244 | } |
243 | QFontMetrics fm = p->fontMetrics(); | 245 | QFontMetrics fm = p->fontMetrics(); |
244 | int yPos; | 246 | int yPos; |
245 | int pmheight = size; | 247 | int pmheight = size; |
246 | if( pmheight < fm.height() ) | 248 | if( pmheight < fm.height() ) |
247 | yPos = fm.ascent() + fm.leading()/2; | 249 | yPos = fm.ascent() + fm.leading()/2; |
248 | else | 250 | else |
249 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 251 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
250 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 252 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
251 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 253 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
252 | p->drawText( x, yPos, text() ); | 254 | p->drawText( x, yPos, text() ); |
253 | if ( mIncidence->cancelled() ) { | 255 | if ( mIncidence->cancelled() ) { |
254 | int wid = fm.width( text() ); | 256 | int wid = fm.width( text() ); |
255 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); | 257 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); |
256 | } | 258 | } |
257 | 259 | ||
258 | } | 260 | } |
259 | 261 | ||
260 | int MonthViewItem::height(const QListBox *lb) const | 262 | int MonthViewItem::height(const QListBox *lb) const |
261 | { | 263 | { |
262 | return lb->fontMetrics().lineSpacing()+1; | 264 | return lb->fontMetrics().lineSpacing()+1; |
263 | } | 265 | } |
264 | 266 | ||
265 | int MonthViewItem::width(const QListBox *lb) const | 267 | int MonthViewItem::width(const QListBox *lb) const |
266 | { | 268 | { |
267 | int size = PIXMAP_SIZE; | 269 | int size = PIXMAP_SIZE; |
268 | if ( QApplication::desktop()->width() < 300 ) | 270 | if ( QApplication::desktop()->width() < 300 ) |
269 | size = 3; | 271 | size = 3; |
270 | int x = 1; | 272 | int x = 1; |
271 | if ( mInfo ) { | 273 | if ( mInfo ) { |
272 | x += size + 1; | 274 | x += size + 1; |
273 | } | 275 | } |
274 | if( mRecur ) { | 276 | if( mRecur ) { |
275 | x += size+1; | 277 | x += size+1; |
276 | } | 278 | } |
277 | if( mAlarm ) { | 279 | if( mAlarm ) { |
278 | x += size+1; | 280 | x += size+1; |
279 | } | 281 | } |
280 | if( mReply ) { | 282 | if( mReply ) { |
281 | x += size+1; | 283 | x += size+1; |
282 | } | 284 | } |
283 | 285 | ||
284 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 286 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
285 | } | 287 | } |
286 | 288 | ||
287 | 289 | ||
288 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 290 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
289 | : QWidget( par ), | 291 | : QWidget( par ), |
290 | mMonthView( parent ) | 292 | mMonthView( parent ) |
291 | { | 293 | { |
292 | 294 | ||
293 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 295 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
294 | 296 | ||