-rw-r--r-- | korganizer/komonthview.cpp | 33 | ||||
-rw-r--r-- | korganizer/komonthview.h | 6 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 4 |
3 files changed, 30 insertions, 13 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 00b1e92..f2cfb75 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1412 +1,1427 @@ | |||
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 <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 27 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPRINTER | 44 | #ifndef KORG_NOPRINTER |
45 | #include "calprinter.h" | 45 | #include "calprinter.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #ifndef KORG_NOPLUGINS | 48 | #ifndef KORG_NOPLUGINS |
49 | #include "kocore.h" | 49 | #include "kocore.h" |
50 | #endif | 50 | #endif |
51 | #include "koglobals.h" | 51 | #include "koglobals.h" |
52 | #include <libkcal/kincidenceformatter.h> | 52 | #include <libkcal/kincidenceformatter.h> |
53 | 53 | ||
54 | #include "komonthview.h" | 54 | #include "komonthview.h" |
55 | 55 | ||
56 | #define PIXMAP_SIZE 5 | 56 | #define PIXMAP_SIZE 5 |
57 | #ifdef DESKTOP_VERSION | 57 | #ifdef DESKTOP_VERSION |
58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 58 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
59 | #endif | 59 | #endif |
60 | class KNOWhatsThis :public QWhatsThis | 60 | class KNOWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 63 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 64 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
65 | 65 | ||
66 | protected: | 66 | protected: |
67 | virtual QString text( const QPoint& p) | 67 | virtual QString text( const QPoint& p) |
68 | { | 68 | { |
69 | return _wid->getWhatsThisText(p) ; | 69 | return _wid->getWhatsThisText(p) ; |
70 | }; | 70 | }; |
71 | private: | 71 | private: |
72 | KNoScrollListBox* _wid; | 72 | KNoScrollListBox* _wid; |
73 | 73 | ||
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 77 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
78 | : QListBox(parent, name, WRepaintNoErase) | 78 | : QListBox(parent, name, WRepaintNoErase) |
79 | { | 79 | { |
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 81 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
82 | #endif | 82 | #endif |
83 | mWT = new KNOWhatsThis(this); | 83 | mWT = new KNOWhatsThis(this); |
84 | } | 84 | } |
85 | KNoScrollListBox::~KNoScrollListBox() | 85 | KNoScrollListBox::~KNoScrollListBox() |
86 | { | 86 | { |
87 | 87 | ||
88 | } | 88 | } |
89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 89 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
90 | { | 90 | { |
91 | QListBoxItem* item = itemAt ( p ); | 91 | QListBoxItem* item = itemAt ( p ); |
92 | if ( ! item ) { | 92 | if ( ! item ) { |
93 | return i18n("Click in the cell\nto add an event!"); | 93 | return i18n("Click in the cell\nto add an event!"); |
94 | } | 94 | } |
95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 95 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
96 | } | 96 | } |
97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 97 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
98 | { | 98 | { |
99 | 99 | ||
100 | switch(e->key()) { | 100 | switch(e->key()) { |
101 | case Key_Right: | 101 | case Key_Right: |
102 | // if ( e->state() == Qt::ControlButton ) | 102 | // if ( e->state() == Qt::ControlButton ) |
103 | { | 103 | { |
104 | e->ignore(); | 104 | e->ignore(); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | scrollBy(4,0); | 107 | scrollBy(4,0); |
108 | break; | 108 | break; |
109 | case Key_Left: | 109 | case Key_Left: |
110 | // if ( e->state() == Qt::ControlButton ) | 110 | // if ( e->state() == Qt::ControlButton ) |
111 | { | 111 | { |
112 | e->ignore(); | 112 | e->ignore(); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | scrollBy(-4,0); | 115 | scrollBy(-4,0); |
116 | break; | 116 | break; |
117 | case Key_Up: | 117 | case Key_Up: |
118 | if(count() < 2) { | 118 | if(count() < 2) { |
119 | e->ignore(); | 119 | e->ignore(); |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | setCurrentItem((currentItem()+count()-1)%count()); | 122 | setCurrentItem((currentItem()+count()-1)%count()); |
123 | if(!itemVisible(currentItem())) { | 123 | if(!itemVisible(currentItem())) { |
124 | if((unsigned int) currentItem() == (count()-1)) { | 124 | if((unsigned int) currentItem() == (count()-1)) { |
125 | setTopItem(currentItem()-numItemsVisible()+1); | 125 | setTopItem(currentItem()-numItemsVisible()+1); |
126 | } else { | 126 | } else { |
127 | setTopItem(topItem()-1); | 127 | setTopItem(topItem()-1); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | break; | 130 | break; |
131 | case Key_Down: | 131 | case Key_Down: |
132 | if(count() < 2) { | 132 | if(count() < 2) { |
133 | e->ignore(); | 133 | e->ignore(); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | setCurrentItem((currentItem()+1)%count()); | 136 | setCurrentItem((currentItem()+1)%count()); |
137 | if(!itemVisible(currentItem())) { | 137 | if(!itemVisible(currentItem())) { |
138 | if(currentItem() == 0) { | 138 | if(currentItem() == 0) { |
139 | setTopItem(0); | 139 | setTopItem(0); |
140 | } else { | 140 | } else { |
141 | setTopItem(topItem()+1); | 141 | setTopItem(topItem()+1); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | break; | 144 | break; |
145 | case Key_Shift: | 145 | case Key_Shift: |
146 | emit shiftDown(); | 146 | emit shiftDown(); |
147 | break; | 147 | break; |
148 | default: | 148 | default: |
149 | e->ignore(); | 149 | e->ignore(); |
150 | break; | 150 | break; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 154 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
155 | { | 155 | { |
156 | switch(e->key()) { | 156 | switch(e->key()) { |
157 | case Key_Shift: | 157 | case Key_Shift: |
158 | emit shiftUp(); | 158 | emit shiftUp(); |
159 | break; | 159 | break; |
160 | default: | 160 | default: |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 165 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
166 | { | 166 | { |
167 | QListBox::mousePressEvent(e); | 167 | QListBox::mousePressEvent(e); |
168 | 168 | ||
169 | if(e->button() == RightButton) { | 169 | if(e->button() == RightButton) { |
170 | emit rightClick(); | 170 | emit rightClick(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 174 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
175 | : QListBoxItem() | 175 | : QListBoxItem() |
176 | { | 176 | { |
177 | setText( s ); | 177 | setText( s ); |
178 | 178 | ||
179 | mIncidence = incidence; | 179 | mIncidence = incidence; |
180 | mDate = qd; | 180 | mDate = qd; |
181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 181 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
182 | mRecur = false; | 182 | mRecur = false; |
183 | mAlarm = false; | 183 | mAlarm = false; |
184 | mReply = false; | 184 | mReply = false; |
185 | mInfo = false; | 185 | mInfo = false; |
186 | } | 186 | } |
187 | 187 | ||
188 | void MonthViewItem::paint(QPainter *p) | 188 | void MonthViewItem::paint(QPainter *p) |
189 | { | 189 | { |
190 | #if QT_VERSION >= 0x030000 | 190 | #if QT_VERSION >= 0x030000 |
191 | bool sel = isSelected(); | 191 | bool sel = isSelected(); |
192 | #else | 192 | #else |
193 | bool sel = selected(); | 193 | bool sel = selected(); |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | 196 | ||
197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 197 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
198 | { | 198 | { |
199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 199 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 200 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 201 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
202 | } | 202 | } |
203 | int x = 1; | 203 | int x = 1; |
204 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 204 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
205 | int size = PIXMAP_SIZE; | 205 | int size = PIXMAP_SIZE; |
206 | if ( QApplication::desktop()->width() < 300 ) | 206 | if ( QApplication::desktop()->width() < 300 ) |
207 | size = 3; | 207 | size = 3; |
208 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 208 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
209 | if ( mInfo ) { | 209 | if ( mInfo ) { |
210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 210 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
211 | x += size + 1; | 211 | x += size + 1; |
212 | } | 212 | } |
213 | if ( mRecur ) { | 213 | if ( mRecur ) { |
214 | p->fillRect ( x, y,size,size, Qt::blue ); | 214 | p->fillRect ( x, y,size,size, Qt::blue ); |
215 | x += size + 1; | 215 | x += size + 1; |
216 | } | 216 | } |
217 | if ( mAlarm ) { | 217 | if ( mAlarm ) { |
218 | p->fillRect ( x, y,size,size, Qt::red ); | 218 | p->fillRect ( x, y,size,size, Qt::red ); |
219 | x += size + 1; | 219 | x += size + 1; |
220 | } | 220 | } |
221 | if ( mReply ) { | 221 | if ( mReply ) { |
222 | p->fillRect ( x, y,size,size, Qt::yellow ); | 222 | p->fillRect ( x, y,size,size, Qt::yellow ); |
223 | x += size + 1; | 223 | x += size + 1; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | QFontMetrics fm = p->fontMetrics(); | 226 | QFontMetrics fm = p->fontMetrics(); |
227 | int yPos; | 227 | int yPos; |
228 | int pmheight = size; | 228 | int pmheight = size; |
229 | if( pmheight < fm.height() ) | 229 | if( pmheight < fm.height() ) |
230 | yPos = fm.ascent() + fm.leading()/2; | 230 | yPos = fm.ascent() + fm.leading()/2; |
231 | else | 231 | else |
232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 232 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
233 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 233 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 234 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
235 | p->drawText( x, yPos, text() ); | 235 | p->drawText( x, yPos, text() ); |
236 | if ( mIncidence->cancelled() ) { | 236 | if ( mIncidence->cancelled() ) { |
237 | int wid = fm.width( text() ); | 237 | int wid = fm.width( text() ); |
238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); | 238 | p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); |
239 | } | 239 | } |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | int MonthViewItem::height(const QListBox *lb) const | 243 | int MonthViewItem::height(const QListBox *lb) const |
244 | { | 244 | { |
245 | return lb->fontMetrics().lineSpacing()+1; | 245 | return lb->fontMetrics().lineSpacing()+1; |
246 | } | 246 | } |
247 | 247 | ||
248 | int MonthViewItem::width(const QListBox *lb) const | 248 | int MonthViewItem::width(const QListBox *lb) const |
249 | { | 249 | { |
250 | int size = PIXMAP_SIZE; | 250 | int size = PIXMAP_SIZE; |
251 | if ( QApplication::desktop()->width() < 300 ) | 251 | if ( QApplication::desktop()->width() < 300 ) |
252 | size = 3; | 252 | size = 3; |
253 | int x = 1; | 253 | int x = 1; |
254 | if ( mInfo ) { | 254 | if ( mInfo ) { |
255 | x += size + 1; | 255 | x += size + 1; |
256 | } | 256 | } |
257 | if( mRecur ) { | 257 | if( mRecur ) { |
258 | x += size+1; | 258 | x += size+1; |
259 | } | 259 | } |
260 | if( mAlarm ) { | 260 | if( mAlarm ) { |
261 | x += size+1; | 261 | x += size+1; |
262 | } | 262 | } |
263 | if( mReply ) { | 263 | if( mReply ) { |
264 | x += size+1; | 264 | x += size+1; |
265 | } | 265 | } |
266 | 266 | ||
267 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 267 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 271 | MonthViewCell::MonthViewCell( KOMonthView *parent) |
272 | : QWidget( parent ), | 272 | : QWidget( parent ), |
273 | mMonthView( parent ) | 273 | mMonthView( parent ) |
274 | { | 274 | { |
275 | 275 | ||
276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 276 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
277 | 277 | ||
278 | // mLabel = new QLabel( this );QPushButton | 278 | // mLabel = new QLabel( this );QPushButton |
279 | mLabel = new QPushButton( this ); | 279 | mLabel = new QPushButton( this ); |
280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 280 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
281 | //mLabel->setLineWidth( 1 ); | 281 | //mLabel->setLineWidth( 1 ); |
282 | //mLabel->setAlignment( AlignCenter ); | 282 | //mLabel->setAlignment( AlignCenter ); |
283 | mLabel->setFlat( true ); | 283 | mLabel->setFlat( true ); |
284 | mItemList = new KNoScrollListBox( this ); | 284 | mItemList = new KNoScrollListBox( this ); |
285 | mItemList->setMinimumSize( 10, 10 ); | 285 | mItemList->setMinimumSize( 10, 10 ); |
286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 286 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
287 | mItemList->setLineWidth( 1 ); | 287 | mItemList->setLineWidth( 1 ); |
288 | topLayout->addWidget( mItemList ); | 288 | topLayout->addWidget( mItemList ); |
289 | mLabel->raise(); | 289 | mLabel->raise(); |
290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 290 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
291 | mStandardPalette = palette(); | 291 | mStandardPalette = palette(); |
292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 292 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
293 | 293 | ||
294 | enableScrollBars( false ); | 294 | enableScrollBars( false ); |
295 | updateConfig(); | 295 | updateConfig(); |
296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 296 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 297 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 298 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
299 | SLOT( defaultAction( QListBoxItem * ) ) ); | 299 | SLOT( defaultAction( QListBoxItem * ) ) ); |
300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 300 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
301 | const QPoint &) ), | 301 | const QPoint &) ), |
302 | SLOT( contextMenu( QListBoxItem * ) ) ); | 302 | SLOT( contextMenu( QListBoxItem * ) ) ); |
303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 303 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
304 | SLOT( selection( QListBoxItem * ) ) ); | 304 | SLOT( selection( QListBoxItem * ) ) ); |
305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 305 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
306 | SLOT( cellClicked( QListBoxItem * ) ) ); | 306 | SLOT( cellClicked( QListBoxItem * ) ) ); |
307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 307 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
308 | SLOT( selection( QListBoxItem * ) ) ); | 308 | SLOT( selection( QListBoxItem * ) ) ); |
309 | } | 309 | } |
310 | #ifdef DESKTOP_VERSION | 310 | #ifdef DESKTOP_VERSION |
311 | QToolTipGroup *MonthViewCell::toolTipGroup() | 311 | QToolTipGroup *MonthViewCell::toolTipGroup() |
312 | { | 312 | { |
313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 313 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
314 | return mToolTipGroup; | 314 | return mToolTipGroup; |
315 | } | 315 | } |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | void MonthViewCell::setDate( const QDate &date ) | 318 | void MonthViewCell::setDate( const QDate &date ) |
319 | { | 319 | { |
320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 320 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
321 | mDate = date; | 321 | mDate = date; |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | //resizeEvent( 0 ); | 325 | //resizeEvent( 0 ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QDate MonthViewCell::date() const | 328 | QDate MonthViewCell::date() const |
329 | { | 329 | { |
330 | return mDate; | 330 | return mDate; |
331 | } | 331 | } |
332 | 332 | ||
333 | void MonthViewCell::setPrimary( bool primary ) | 333 | void MonthViewCell::setPrimary( bool primary ) |
334 | { | 334 | { |
335 | mPrimary = primary; | 335 | mPrimary = primary; |
336 | //setMyPalette(); | 336 | //setMyPalette(); |
337 | } | 337 | } |
338 | void MonthViewCell::setMyPalette() | 338 | void MonthViewCell::setMyPalette() |
339 | { | 339 | { |
340 | 340 | ||
341 | if ( mHoliday) { | 341 | if ( mHoliday) { |
342 | setPalette( mHolidayPalette ); | 342 | setPalette( mHolidayPalette ); |
343 | } else { | 343 | } else { |
344 | if ( mPrimary ) { | 344 | if ( mPrimary ) { |
345 | setPalette( mPrimaryPalette ); | 345 | setPalette( mPrimaryPalette ); |
346 | } else { | 346 | } else { |
347 | setPalette( mNonPrimaryPalette ); | 347 | setPalette( mNonPrimaryPalette ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | QPalette pal = palette(); | 350 | QPalette pal = palette(); |
351 | 351 | ||
352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 352 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
353 | } | 353 | } |
354 | QPalette MonthViewCell::getPalette () | 354 | QPalette MonthViewCell::getPalette () |
355 | { | 355 | { |
356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 356 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
357 | return mStandardPalette; | 357 | return mStandardPalette; |
358 | if ( mHoliday) { | 358 | if ( mHoliday) { |
359 | return mHolidayPalette ; | 359 | return mHolidayPalette ; |
360 | } else { | 360 | } else { |
361 | if ( mPrimary ) { | 361 | if ( mPrimary ) { |
362 | return mPrimaryPalette ; | 362 | return mPrimaryPalette ; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | return mNonPrimaryPalette; | 365 | return mNonPrimaryPalette; |
366 | } | 366 | } |
367 | bool MonthViewCell::isPrimary() const | 367 | bool MonthViewCell::isPrimary() const |
368 | { | 368 | { |
369 | return mPrimary; | 369 | return mPrimary; |
370 | } | 370 | } |
371 | 371 | ||
372 | void MonthViewCell::setHoliday( bool holiday ) | 372 | void MonthViewCell::setHoliday( bool holiday ) |
373 | { | 373 | { |
374 | mHoliday = holiday; | 374 | mHoliday = holiday; |
375 | //setMyPalette(); | 375 | //setMyPalette(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void MonthViewCell::setHoliday( const QString &holiday ) | 378 | void MonthViewCell::setHoliday( const QString &holiday ) |
379 | { | 379 | { |
380 | mHolidayString = holiday; | 380 | mHolidayString = holiday; |
381 | 381 | ||
382 | if ( !holiday.isEmpty() ) { | 382 | if ( !holiday.isEmpty() ) { |
383 | setHoliday( true ); | 383 | setHoliday( true ); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 386 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
387 | { | 387 | { |
388 | 388 | ||
389 | e->ignore(); | 389 | e->ignore(); |
390 | 390 | ||
391 | } | 391 | } |
392 | void MonthViewCell::clear() | 392 | void MonthViewCell::clear() |
393 | { | 393 | { |
394 | mItemList->clear(); | 394 | mItemList->clear(); |
395 | QApplication::removePostedEvents ( mItemList ); | 395 | QApplication::removePostedEvents ( mItemList ); |
396 | QApplication::removePostedEvents ( mLabel ); | 396 | QApplication::removePostedEvents ( mLabel ); |
397 | QApplication::removePostedEvents ( this ); | 397 | QApplication::removePostedEvents ( this ); |
398 | } | 398 | } |
399 | 399 | ||
400 | void MonthViewCell::startUpdateCell() | 400 | void MonthViewCell::startUpdateCell() |
401 | { | 401 | { |
402 | 402 | ||
403 | if ( !mMonthView->isUpdatePossible() ) | 403 | if ( !mMonthView->isUpdatePossible() ) |
404 | return; | 404 | return; |
405 | /* | 405 | /* |
406 | if ( !isVisible() ){ | 406 | if ( !isVisible() ){ |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | */ | 409 | */ |
410 | // qDebug("MonthViewCell::updateCell() "); | 410 | // qDebug("MonthViewCell::updateCell() "); |
411 | setPrimary( mDate.month()%2 ); | 411 | setPrimary( mDate.month()%2 ); |
412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 412 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
413 | if ( mDate == QDate::currentDate() ) { | 413 | if ( mDate == QDate::currentDate() ) { |
414 | mItemList->setLineWidth( 3 ); | 414 | mItemList->setLineWidth( 3 ); |
415 | } else { | 415 | } else { |
416 | mItemList->setLineWidth( 1 ); | 416 | mItemList->setLineWidth( 1 ); |
417 | } | 417 | } |
418 | mItemList->clear(); | 418 | mItemList->clear(); |
419 | 419 | ||
420 | #ifdef DESKTOP_VERSION | 420 | #ifdef DESKTOP_VERSION |
421 | QToolTip::remove(this); | 421 | QToolTip::remove(this); |
422 | #endif | 422 | #endif |
423 | mToolTip = ""; | 423 | mToolTip = ""; |
424 | //qApp->processEvents(); | 424 | //qApp->processEvents(); |
425 | if ( !mHolidayString.isEmpty() ) { | 425 | if ( !mHolidayString.isEmpty() ) { |
426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 426 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
427 | item->setPalette( mHolidayPalette ); | 427 | item->setPalette( mHolidayPalette ); |
428 | mItemList->insertItem( item ); | 428 | mItemList->insertItem( item ); |
429 | mToolTip += mHolidayString+"\n"; | 429 | mToolTip += mHolidayString+"\n"; |
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | void MonthViewCell::insertEvent(Event *event) | 433 | void MonthViewCell::insertEvent(Event *event) |
434 | { | 434 | { |
435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
437 | return; | 437 | return; |
438 | else | 438 | else |
439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | if ( event->categories().contains("Holiday") || | 443 | if ( event->categories().contains("Holiday") || |
444 | event->categories().contains(i18n("Holiday"))) { | 444 | event->categories().contains(i18n("Holiday"))) { |
445 | setHoliday( true ); | 445 | setHoliday( true ); |
446 | if ( mDate.dayOfWeek() == 7 ) | 446 | if ( mDate.dayOfWeek() == 7 ) |
447 | mItemList->setLineWidth( 3 ); | 447 | mItemList->setLineWidth( 3 ); |
448 | } | 448 | } |
449 | QString text; | 449 | QString text; |
450 | if (event->isMultiDay()) { | 450 | if (event->isMultiDay()) { |
451 | QString prefix = "<->"; | 451 | QString prefix = "<->"; |
452 | if ( event->doesRecur() ) { | 452 | if ( event->doesRecur() ) { |
453 | if ( event->recursOn( mDate) ) | 453 | if ( event->recursOn( mDate) ) |
454 | prefix ="->" ; | 454 | prefix ="->" ; |
455 | else { | 455 | else { |
456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 456 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
457 | if ( event->recursOn( mDate.addDays( -days)) ) | 457 | if ( event->recursOn( mDate.addDays( -days)) ) |
458 | prefix ="<-" ; | 458 | prefix ="<-" ; |
459 | } | 459 | } |
460 | 460 | ||
461 | } else { | 461 | } else { |
462 | if (mDate == event->dtStart().date()) { | 462 | if (mDate == event->dtStart().date()) { |
463 | prefix ="->" ; | 463 | prefix ="->" ; |
464 | } else if (mDate == event->dtEnd().date()) { | 464 | } else if (mDate == event->dtEnd().date()) { |
465 | prefix ="<-" ; | 465 | prefix ="<-" ; |
466 | } | 466 | } |
467 | } | 467 | } |
468 | if ( !event->doesFloat() ) { | 468 | if ( !event->doesFloat() ) { |
469 | if ( mDate == event->dtStart().date () ) | 469 | if ( mDate == event->dtStart().date () ) |
470 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 470 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
471 | else if ( mDate == event->dtEnd().date () ) | 471 | else if ( mDate == event->dtEnd().date () ) |
472 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 472 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
473 | 473 | ||
474 | } | 474 | } |
475 | text = prefix + event->summary(); | 475 | text = prefix + event->summary(); |
476 | mToolTip += text; | 476 | mToolTip += text; |
477 | } else { | 477 | } else { |
478 | if (event->doesFloat()) { | 478 | if (event->doesFloat()) { |
479 | text = event->summary(); | 479 | text = event->summary(); |
480 | mToolTip += text; | 480 | mToolTip += text; |
481 | } | 481 | } |
482 | else { | 482 | else { |
483 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 483 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
484 | text += " " + event->summary(); | 484 | text += " " + event->summary(); |
485 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 485 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 489 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
490 | QPalette pal; | 490 | QPalette pal; |
491 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 491 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
492 | QStringList categories = event->categories(); | 492 | QStringList categories = event->categories(); |
493 | QString cat = categories.first(); | 493 | QString cat = categories.first(); |
494 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 494 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
495 | pal = getPalette(); | 495 | pal = getPalette(); |
496 | if (cat.isEmpty()) { | 496 | if (cat.isEmpty()) { |
497 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 497 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
498 | } else { | 498 | } else { |
499 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 499 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
500 | } | 500 | } |
501 | 501 | ||
502 | } else { | 502 | } else { |
503 | if (cat.isEmpty()) { | 503 | if (cat.isEmpty()) { |
504 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 504 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
505 | } else { | 505 | } else { |
506 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 506 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | } else { | 510 | } else { |
511 | pal = mStandardPalette ; | 511 | pal = mStandardPalette ; |
512 | } | 512 | } |
513 | item->setPalette( pal ); | 513 | item->setPalette( pal ); |
514 | item->setRecur( event->recurrence()->doesRecur() ); | 514 | item->setRecur( event->recurrence()->doesRecur() ); |
515 | item->setAlarm( event->isAlarmEnabled() ); | 515 | item->setAlarm( event->isAlarmEnabled() ); |
516 | item->setMoreInfo( event->description().length() > 0 ); | 516 | item->setMoreInfo( event->description().length() > 0 ); |
517 | #ifdef DESKTOP_VERSION | 517 | #ifdef DESKTOP_VERSION |
518 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 518 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
519 | KOPrefs::instance()->email()); | 519 | KOPrefs::instance()->email()); |
520 | if ( me != 0 ) { | 520 | if ( me != 0 ) { |
521 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 521 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
522 | item->setReply(true); | 522 | item->setReply(true); |
523 | else | 523 | else |
524 | item->setReply(false); | 524 | item->setReply(false); |
525 | } else | 525 | } else |
526 | item->setReply(false); | 526 | item->setReply(false); |
527 | #endif | 527 | #endif |
528 | mItemList->insertItem( item ); | 528 | mItemList->insertItem( item ); |
529 | mToolTip += "\n"; | 529 | mToolTip += "\n"; |
530 | } | 530 | } |
531 | void MonthViewCell::insertTodo(Todo *todo) | 531 | void MonthViewCell::insertTodo(Todo *todo) |
532 | { | 532 | { |
533 | QString text; | 533 | QString text; |
534 | if (todo->hasDueDate()) { | 534 | if (todo->hasDueDate()) { |
535 | if (!todo->doesFloat()) { | 535 | if (!todo->doesFloat()) { |
536 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 536 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
537 | text += " "; | 537 | text += " "; |
538 | } | 538 | } |
539 | } | 539 | } |
540 | text += i18n("To-Do: %1").arg(todo->summary()); | 540 | text += i18n("To-Do: %1").arg(todo->summary()); |
541 | 541 | ||
542 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 542 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
543 | //item->setPalette( mStandardPalette ); | 543 | //item->setPalette( mStandardPalette ); |
544 | QPalette pal; | 544 | QPalette pal; |
545 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 545 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
546 | QStringList categories = todo->categories(); | 546 | QStringList categories = todo->categories(); |
547 | QString cat = categories.first(); | 547 | QString cat = categories.first(); |
548 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 548 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
549 | pal = getPalette(); | 549 | pal = getPalette(); |
550 | if (cat.isEmpty()) { | 550 | if (cat.isEmpty()) { |
551 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 551 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
552 | } else { | 552 | } else { |
553 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 553 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
554 | } | 554 | } |
555 | 555 | ||
556 | } else { | 556 | } else { |
557 | if (cat.isEmpty()) { | 557 | if (cat.isEmpty()) { |
558 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 558 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
559 | } else { | 559 | } else { |
560 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 560 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | } else { | 564 | } else { |
565 | pal = mStandardPalette ; | 565 | pal = mStandardPalette ; |
566 | } | 566 | } |
567 | item->setPalette( pal ); | 567 | item->setPalette( pal ); |
568 | mItemList->insertItem( item ); | 568 | mItemList->insertItem( item ); |
569 | mToolTip += text+"\n"; | 569 | mToolTip += text+"\n"; |
570 | } | 570 | } |
571 | void MonthViewCell::finishUpdateCell() | 571 | void MonthViewCell::finishUpdateCell() |
572 | { | 572 | { |
573 | #ifdef DESKTOP_VERSION | 573 | #ifdef DESKTOP_VERSION |
574 | if (mToolTip != "") | 574 | if (mToolTip != "") |
575 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 575 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
576 | #endif | 576 | #endif |
577 | mItemList->sort(); | 577 | mItemList->sort(); |
578 | //setMyPalette(); | 578 | //setMyPalette(); |
579 | setMyPalette(); | 579 | setMyPalette(); |
580 | QString text; | 580 | QString text; |
581 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 581 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
582 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 582 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
583 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 583 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
584 | mLabel->resize( mLabelBigSize ); | 584 | mLabel->resize( mLabelBigSize ); |
585 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 585 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
586 | } else { | 586 | } else { |
587 | mLabel->resize( mLabelSize ); | 587 | mLabel->resize( mLabelSize ); |
588 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 588 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
589 | } | 589 | } |
590 | 590 | ||
591 | mLabel->setText( text ); | 591 | mLabel->setText( text ); |
592 | resizeEvent( 0 ); | 592 | resizeEvent( 0 ); |
593 | } | 593 | } |
594 | void MonthViewCell::updateCell() | 594 | void MonthViewCell::updateCell() |
595 | { | 595 | { |
596 | if ( !mMonthView->isUpdatePossible() ) | 596 | if ( !mMonthView->isUpdatePossible() ) |
597 | return; | 597 | return; |
598 | startUpdateCell(); | 598 | startUpdateCell(); |
599 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 599 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
600 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 600 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
601 | Event *event; | 601 | Event *event; |
602 | for( event = events.first(); event; event = events.next() ) { // for event | 602 | for( event = events.first(); event; event = events.next() ) { // for event |
603 | insertEvent(event); | 603 | insertEvent(event); |
604 | } | 604 | } |
605 | // insert due todos | 605 | // insert due todos |
606 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 606 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
607 | Todo *todo; | 607 | Todo *todo; |
608 | for(todo = todos.first(); todo; todo = todos.next()) { | 608 | for(todo = todos.first(); todo; todo = todos.next()) { |
609 | insertTodo( todo ); | 609 | insertTodo( todo ); |
610 | } | 610 | } |
611 | finishUpdateCell(); | 611 | finishUpdateCell(); |
612 | // if ( isVisible()) | 612 | // if ( isVisible()) |
613 | //qApp->processEvents(); | 613 | //qApp->processEvents(); |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::updateConfig() | 616 | void MonthViewCell::updateConfig() |
617 | { | 617 | { |
618 | setFont( KOPrefs::instance()->mMonthViewFont ); | 618 | setFont( KOPrefs::instance()->mMonthViewFont ); |
619 | 619 | ||
620 | QFontMetrics fm( font() ); | 620 | QFontMetrics fm( font() ); |
621 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 621 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
622 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 622 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
623 | mHolidayPalette = mStandardPalette; | 623 | mHolidayPalette = mStandardPalette; |
624 | mPrimaryPalette = mStandardPalette; | 624 | mPrimaryPalette = mStandardPalette; |
625 | mNonPrimaryPalette = mStandardPalette; | 625 | mNonPrimaryPalette = mStandardPalette; |
626 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 626 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
627 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 627 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
628 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 628 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
629 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 629 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
630 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 630 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
631 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 631 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
632 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 632 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
633 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 633 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
634 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 634 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
635 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 635 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
636 | } | 636 | } |
637 | //updateCell(); | 637 | //updateCell(); |
638 | } | 638 | } |
639 | 639 | ||
640 | void MonthViewCell::enableScrollBars( bool enabled ) | 640 | void MonthViewCell::enableScrollBars( bool enabled ) |
641 | { | 641 | { |
642 | if ( enabled ) { | 642 | if ( enabled ) { |
643 | mItemList->setVScrollBarMode(QScrollView::Auto); | 643 | mItemList->setVScrollBarMode(QScrollView::Auto); |
644 | mItemList->setHScrollBarMode(QScrollView::Auto); | 644 | mItemList->setHScrollBarMode(QScrollView::Auto); |
645 | } else { | 645 | } else { |
646 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 646 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
647 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 647 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
648 | } | 648 | } |
649 | } | 649 | } |
650 | 650 | ||
651 | Incidence *MonthViewCell::selectedIncidence() | 651 | Incidence *MonthViewCell::selectedIncidence() |
652 | { | 652 | { |
653 | int index = mItemList->currentItem(); | 653 | int index = mItemList->currentItem(); |
654 | if ( index < 0 ) return 0; | 654 | if ( index < 0 ) return 0; |
655 | 655 | ||
656 | MonthViewItem *item = | 656 | MonthViewItem *item = |
657 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 657 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
658 | 658 | ||
659 | if ( !item ) return 0; | 659 | if ( !item ) return 0; |
660 | 660 | ||
661 | return item->incidence(); | 661 | return item->incidence(); |
662 | } | 662 | } |
663 | 663 | ||
664 | QDate MonthViewCell::selectedIncidenceDate() | 664 | QDate MonthViewCell::selectedIncidenceDate() |
665 | { | 665 | { |
666 | QDate qd; | 666 | QDate qd; |
667 | int index = mItemList->currentItem(); | 667 | int index = mItemList->currentItem(); |
668 | if ( index < 0 ) return qd; | 668 | if ( index < 0 ) return qd; |
669 | 669 | ||
670 | MonthViewItem *item = | 670 | MonthViewItem *item = |
671 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 671 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
672 | 672 | ||
673 | if ( !item ) return qd; | 673 | if ( !item ) return qd; |
674 | 674 | ||
675 | return item->incidenceDate(); | 675 | return item->incidenceDate(); |
676 | } | 676 | } |
677 | 677 | ||
678 | void MonthViewCell::deselect() | 678 | void MonthViewCell::deselect() |
679 | { | 679 | { |
680 | mItemList->clearSelection(); | 680 | mItemList->clearSelection(); |
681 | enableScrollBars( false ); | 681 | enableScrollBars( false ); |
682 | // updateCell(); | 682 | // updateCell(); |
683 | } | 683 | } |
684 | void MonthViewCell::select() | 684 | void MonthViewCell::select() |
685 | { | 685 | { |
686 | ;// updateCell(); | 686 | ;// updateCell(); |
687 | } | 687 | } |
688 | 688 | ||
689 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 689 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
690 | { | 690 | { |
691 | if ( !mMonthView->isUpdatePossible() ) | 691 | if ( !mMonthView->isUpdatePossible() ) |
692 | return; | 692 | return; |
693 | 693 | ||
694 | int size = height() - mLabel->height() - 2; | 694 | int size = height() - mLabel->height() - 2; |
695 | if ( size > 0 ) | 695 | if ( size > 0 ) |
696 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 696 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
697 | size = width() - mLabel->width() -2; | 697 | size = width() - mLabel->width() -2; |
698 | if ( size > 0 ) | 698 | if ( size > 0 ) |
699 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 699 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
700 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 700 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
701 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 701 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
702 | } | 702 | } |
703 | 703 | ||
704 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 704 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
705 | { | 705 | { |
706 | if ( !item ) return; | 706 | if ( !item ) return; |
707 | 707 | ||
708 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 708 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
709 | Incidence *incidence = eventItem->incidence(); | 709 | Incidence *incidence = eventItem->incidence(); |
710 | if ( incidence ) mMonthView->defaultAction( incidence ); | 710 | if ( incidence ) mMonthView->defaultAction( incidence ); |
711 | } | 711 | } |
712 | void MonthViewCell::showDay() | 712 | void MonthViewCell::showDay() |
713 | { | 713 | { |
714 | emit showDaySignal( date() ); | 714 | emit showDaySignal( date() ); |
715 | } | 715 | } |
716 | void MonthViewCell::newEvent() | 716 | void MonthViewCell::newEvent() |
717 | { | 717 | { |
718 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 718 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
719 | emit newEventSignal( dt ); | 719 | emit newEventSignal( dt ); |
720 | } | 720 | } |
721 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 721 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
722 | { | 722 | { |
723 | static QListBoxItem * lastClicked = 0; | 723 | static QListBoxItem * lastClicked = 0; |
724 | if ( item == 0 ) { | 724 | if ( item == 0 ) { |
725 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 725 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
726 | emit newEventSignal( dt ); | 726 | emit newEventSignal( dt ); |
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | /* | 729 | /* |
730 | if ( lastClicked ) | 730 | if ( lastClicked ) |
731 | if ( ! item ) { | 731 | if ( ! item ) { |
732 | if ( lastClicked->listBox() != item->listBox() ) | 732 | if ( lastClicked->listBox() != item->listBox() ) |
733 | lastClicked->listBox()->clearSelection(); | 733 | lastClicked->listBox()->clearSelection(); |
734 | } | 734 | } |
735 | */ | 735 | */ |
736 | 736 | ||
737 | mMonthView->setSelectedCell( this ); | 737 | mMonthView->setSelectedCell( this ); |
738 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 738 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
739 | select(); | 739 | select(); |
740 | } | 740 | } |
741 | 741 | ||
742 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 742 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
743 | { | 743 | { |
744 | if ( !item ) return; | 744 | if ( !item ) return; |
745 | 745 | ||
746 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 746 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
747 | Incidence *incidence = eventItem->incidence(); | 747 | Incidence *incidence = eventItem->incidence(); |
748 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 748 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
749 | } | 749 | } |
750 | 750 | ||
751 | void MonthViewCell::selection( QListBoxItem *item ) | 751 | void MonthViewCell::selection( QListBoxItem *item ) |
752 | { | 752 | { |
753 | if ( !item ) return; | 753 | if ( !item ) return; |
754 | 754 | ||
755 | mMonthView->setSelectedCell( this ); | 755 | mMonthView->setSelectedCell( this ); |
756 | } | 756 | } |
757 | 757 | ||
758 | 758 | ||
759 | // ******************************************************************************* | 759 | // ******************************************************************************* |
760 | // ******************************************************************************* | 760 | // ******************************************************************************* |
761 | // ******************************************************************************* | 761 | // ******************************************************************************* |
762 | 762 | ||
763 | 763 | ||
764 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 764 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
765 | : KOEventView( calendar, parent, name ), | 765 | : KOEventView( calendar, parent, name ), |
766 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 766 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
767 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 767 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
768 | { | 768 | { |
769 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 769 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
770 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 770 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
771 | if ( mShowWeekView ) | 771 | if ( mShowWeekView ) |
772 | mWeekStartsMonday = true; | 772 | mWeekStartsMonday = true; |
773 | updatePossible = false; | 773 | updatePossible = false; |
774 | mCells.setAutoDelete( true ); | 774 | mCells.setAutoDelete( true ); |
775 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 775 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
776 | // mDayLayout = new QGridLayout( this ); | 776 | // mDayLayout = new QGridLayout( this ); |
777 | // create the day of the week labels (Sun, Mon, etc) and add them to | 777 | // create the day of the week labels (Sun, Mon, etc) and add them to |
778 | // the layout. | 778 | // the layout. |
779 | mDayLabels.resize( mDaysPerWeek ); | 779 | mDayLabels.resize( mDaysPerWeek ); |
780 | QFont bfont = font(); | 780 | QFont bfont = font(); |
781 | if ( QApplication::desktop()->width() < 650 ) { | 781 | if ( QApplication::desktop()->width() < 650 ) { |
782 | bfont.setPointSize( bfont.pointSize() - 2 ); | 782 | bfont.setPointSize( bfont.pointSize() - 2 ); |
783 | } | 783 | } |
784 | bfont.setBold( true ); | 784 | bfont.setBold( true ); |
785 | int i; | 785 | int i; |
786 | 786 | ||
787 | for( i = 0; i < mDaysPerWeek; i++ ) { | 787 | for( i = 0; i < mDaysPerWeek; i++ ) { |
788 | QLabel *label = new QLabel( this ); | 788 | QLabel *label = new QLabel( this ); |
789 | label->setFont(bfont); | 789 | label->setFont(bfont); |
790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
791 | label->setLineWidth(1); | 791 | label->setLineWidth(1); |
792 | label->setAlignment(AlignCenter); | 792 | label->setAlignment(AlignCenter); |
793 | mDayLabels.insert( i, label ); | 793 | mDayLabels.insert( i, label ); |
794 | } | 794 | } |
795 | 795 | ||
796 | bfont.setBold( false ); | 796 | bfont.setBold( false ); |
797 | mWeekLabels.resize( mNumWeeks+1 ); | 797 | mWeekLabels.resize( mNumWeeks+1 ); |
798 | for( i = 0; i < mNumWeeks+1; i++ ) { | 798 | for( i = 0; i < mNumWeeks+1; i++ ) { |
799 | KOWeekButton *label = new KOWeekButton( this ); | 799 | KOWeekButton *label = new KOWeekButton( this ); |
800 | label->setFont(bfont); | 800 | label->setFont(bfont); |
801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
802 | label->setFlat(true); | 802 | label->setFlat(true); |
803 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 803 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
804 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 804 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
805 | //label->setLineWidth(1); | 805 | //label->setLineWidth(1); |
806 | //label->setAlignment(AlignCenter); | 806 | //label->setAlignment(AlignCenter); |
807 | mWeekLabels.insert( i, label ); | 807 | mWeekLabels.insert( i, label ); |
808 | } | 808 | } |
809 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 809 | mWeekLabels[mNumWeeks]->setText( i18n("")); |
810 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nswitch to week mode view")); | 810 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
811 | int row, col; | 811 | int row, col; |
812 | QPopupMenu * wpo = new QPopupMenu (this); | ||
813 | wpo->insertItem( i18n("W#"), 0 ); | ||
814 | for ( i = 1; i < 54; i++ ) | ||
815 | wpo->insertItem( i18n("%1").arg(i), i ); | ||
816 | mWeekLabels[mNumWeeks]->setPopup( wpo ); | ||
812 | mCells.resize( mNumCells ); | 817 | mCells.resize( mNumCells ); |
813 | for( row = 0; row < mNumWeeks; ++row ) { | 818 | for( row = 0; row < mNumWeeks; ++row ) { |
814 | for( col = 0; col < mDaysPerWeek; ++col ) { | 819 | for( col = 0; col < mDaysPerWeek; ++col ) { |
815 | MonthViewCell *cell = new MonthViewCell( this ); | 820 | MonthViewCell *cell = new MonthViewCell( this ); |
816 | mCells.insert( row * mDaysPerWeek + col, cell ); | 821 | mCells.insert( row * mDaysPerWeek + col, cell ); |
817 | 822 | ||
818 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 823 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
819 | SLOT( defaultAction( Incidence * ) ) ); | 824 | SLOT( defaultAction( Incidence * ) ) ); |
820 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 825 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
821 | SIGNAL( newEventSignal( QDateTime ) ) ); | 826 | SIGNAL( newEventSignal( QDateTime ) ) ); |
822 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 827 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
823 | SIGNAL( showDaySignal( QDate ) ) ); | 828 | SIGNAL( showDaySignal( QDate ) ) ); |
824 | } | 829 | } |
825 | } | 830 | } |
826 | 831 | ||
827 | connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), | 832 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
828 | SLOT( switchView() ) ); | 833 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); |
829 | mContextMenu = eventPopup(); | 834 | mContextMenu = eventPopup(); |
830 | // updateConfig(); //useless here | 835 | // updateConfig(); //useless here |
831 | 836 | ||
832 | emit incidenceSelected( 0 ); | 837 | emit incidenceSelected( 0 ); |
833 | } | 838 | } |
834 | 839 | ||
835 | KOMonthView::~KOMonthView() | 840 | KOMonthView::~KOMonthView() |
836 | { | 841 | { |
837 | delete mContextMenu; | 842 | delete mContextMenu; |
838 | } | 843 | } |
844 | void KOMonthView::selectDateWeekNum ( int ) | ||
845 | { | ||
846 | |||
847 | } | ||
848 | void KOMonthView::selectInternalWeekNum ( int n ) | ||
849 | { | ||
850 | emit selectWeekNum ( n ); | ||
851 | switchView(); | ||
852 | } | ||
853 | |||
839 | void KOMonthView::switchView() | 854 | void KOMonthView::switchView() |
840 | { | 855 | { |
841 | if ( selectedCell( ) ) | 856 | if ( selectedCell( ) ) |
842 | selectedCell()->deselect(); | 857 | selectedCell()->deselect(); |
843 | mShowWeekView = !mShowWeekView; | 858 | mShowWeekView = !mShowWeekView; |
844 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 859 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
845 | emit showNavigator( !mShowWeekView ); | 860 | //emit showNavigator( !mShowWeekView ); |
846 | computeLayout(); | 861 | computeLayout(); |
847 | updateConfig(); | 862 | updateConfig(); |
848 | } | 863 | } |
849 | 864 | ||
850 | int KOMonthView::maxDatesHint() | 865 | int KOMonthView::maxDatesHint() |
851 | { | 866 | { |
852 | return mNumCells; | 867 | return mNumCells; |
853 | } | 868 | } |
854 | 869 | ||
855 | int KOMonthView::currentDateCount() | 870 | int KOMonthView::currentDateCount() |
856 | { | 871 | { |
857 | return mNumCells; | 872 | return mNumCells; |
858 | } | 873 | } |
859 | 874 | ||
860 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 875 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
861 | { | 876 | { |
862 | QPtrList<Incidence> selected; | 877 | QPtrList<Incidence> selected; |
863 | 878 | ||
864 | if ( mSelectedCell ) { | 879 | if ( mSelectedCell ) { |
865 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 880 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
866 | if ( incidence ) selected.append( incidence ); | 881 | if ( incidence ) selected.append( incidence ); |
867 | } | 882 | } |
868 | 883 | ||
869 | return selected; | 884 | return selected; |
870 | } | 885 | } |
871 | 886 | ||
872 | DateList KOMonthView::selectedDates() | 887 | DateList KOMonthView::selectedDates() |
873 | { | 888 | { |
874 | DateList selected; | 889 | DateList selected; |
875 | 890 | ||
876 | if ( mSelectedCell ) { | 891 | if ( mSelectedCell ) { |
877 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 892 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
878 | if ( qd.isValid() ) selected.append( qd ); | 893 | if ( qd.isValid() ) selected.append( qd ); |
879 | } | 894 | } |
880 | 895 | ||
881 | return selected; | 896 | return selected; |
882 | } | 897 | } |
883 | 898 | ||
884 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 899 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
885 | const QDate &td) | 900 | const QDate &td) |
886 | { | 901 | { |
887 | #ifndef KORG_NOPRINTER | 902 | #ifndef KORG_NOPRINTER |
888 | calPrinter->preview(CalPrinter::Month, fd, td); | 903 | calPrinter->preview(CalPrinter::Month, fd, td); |
889 | #endif | 904 | #endif |
890 | } | 905 | } |
891 | 906 | ||
892 | void KOMonthView::updateConfig() | 907 | void KOMonthView::updateConfig() |
893 | { | 908 | { |
894 | 909 | ||
895 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 910 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
896 | 911 | ||
897 | if ( mShowWeekView ) | 912 | if ( mShowWeekView ) |
898 | mWeekStartsMonday = true; | 913 | mWeekStartsMonday = true; |
899 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 914 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
900 | mWidthLongDayLabel = 0; | 915 | mWidthLongDayLabel = 0; |
901 | 916 | ||
902 | for (int i = 0; i < 7; i++) { | 917 | for (int i = 0; i < 7; i++) { |
903 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 918 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
904 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 919 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
905 | } | 920 | } |
906 | bool temp = mShowSatSunComp ; | 921 | bool temp = mShowSatSunComp ; |
907 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 922 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
908 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 923 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
909 | computeLayout(); | 924 | computeLayout(); |
910 | updateDayLabels(); | 925 | updateDayLabels(); |
911 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 926 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
912 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 927 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
913 | //resizeEvent( 0 ); | 928 | //resizeEvent( 0 ); |
914 | for (uint i = 0; i < mCells.count(); ++i) { | 929 | for (uint i = 0; i < mCells.count(); ++i) { |
915 | mCells[i]->updateConfig(); | 930 | mCells[i]->updateConfig(); |
916 | } | 931 | } |
917 | #ifdef DESKTOP_VERSION | 932 | #ifdef DESKTOP_VERSION |
918 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 933 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
919 | #endif | 934 | #endif |
920 | updateView(); | 935 | updateView(); |
921 | } | 936 | } |
922 | 937 | ||
923 | void KOMonthView::updateDayLabels() | 938 | void KOMonthView::updateDayLabels() |
924 | { | 939 | { |
925 | 940 | ||
926 | for (int i = 0; i < 7; i++) { | 941 | for (int i = 0; i < 7; i++) { |
927 | if (mWeekStartsMonday) { | 942 | if (mWeekStartsMonday) { |
928 | bool show = mShortDayLabels; | 943 | bool show = mShortDayLabels; |
929 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 944 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
930 | show = true; | 945 | show = true; |
931 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 946 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
932 | } else { | 947 | } else { |
933 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 948 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
934 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 949 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
935 | 950 | ||
936 | } | 951 | } |
937 | } | 952 | } |
938 | } | 953 | } |
939 | 954 | ||
940 | void KOMonthView::showDates(const QDate &start, const QDate &) | 955 | void KOMonthView::showDates(const QDate &start, const QDate &) |
941 | { | 956 | { |
942 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 957 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
943 | 958 | ||
944 | 959 | ||
945 | mStartDate = start; | 960 | mStartDate = start; |
946 | 961 | ||
947 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 962 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
948 | 963 | ||
949 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 964 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
950 | mStartDate = mStartDate.addDays( -1 ); | 965 | mStartDate = mStartDate.addDays( -1 ); |
951 | } | 966 | } |
952 | 967 | ||
953 | bool primary = false; | 968 | bool primary = false; |
954 | uint i; | 969 | uint i; |
955 | for( i = 0; i < mCells.size(); ++i ) { | 970 | for( i = 0; i < mCells.size(); ++i ) { |
956 | QDate date = mStartDate.addDays( i ); | 971 | QDate date = mStartDate.addDays( i ); |
957 | mCells[i]->setDate( date ); | 972 | mCells[i]->setDate( date ); |
958 | 973 | ||
959 | #ifndef KORG_NOPLUGINS | 974 | #ifndef KORG_NOPLUGINS |
960 | // add holiday, if present | 975 | // add holiday, if present |
961 | QString hstring(KOCore::self()->holiday(date)); | 976 | QString hstring(KOCore::self()->holiday(date)); |
962 | mCells[i]->setHoliday( hstring ); | 977 | mCells[i]->setHoliday( hstring ); |
963 | #endif | 978 | #endif |
964 | 979 | ||
965 | } | 980 | } |
966 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 981 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
967 | for( i = 0; i < 6; ++i ) { | 982 | for( i = 0; i < 6; ++i ) { |
968 | int wno; | 983 | int wno; |
969 | // remember, according to ISO 8601, the first week of the year is the | 984 | // remember, according to ISO 8601, the first week of the year is the |
970 | // first week that contains a thursday. Thus we must subtract off 4, | 985 | // first week that contains a thursday. Thus we must subtract off 4, |
971 | // not just 1. | 986 | // not just 1. |
972 | int dayOfYear = date.dayOfYear(); | 987 | int dayOfYear = date.dayOfYear(); |
973 | if (dayOfYear % 7 != 0) | 988 | if (dayOfYear % 7 != 0) |
974 | wno = dayOfYear / 7 + 1; | 989 | wno = dayOfYear / 7 + 1; |
975 | else | 990 | else |
976 | wno =dayOfYear / 7; | 991 | wno =dayOfYear / 7; |
977 | mWeekLabels[i]->setWeekNum( wno ); | 992 | mWeekLabels[i]->setWeekNum( wno ); |
978 | date = date.addDays( 7 ); | 993 | date = date.addDays( 7 ); |
979 | } | 994 | } |
980 | updateView(); | 995 | updateView(); |
981 | } | 996 | } |
982 | 997 | ||
983 | void KOMonthView::showEvents(QPtrList<Event>) | 998 | void KOMonthView::showEvents(QPtrList<Event>) |
984 | { | 999 | { |
985 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1000 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
986 | } | 1001 | } |
987 | 1002 | ||
988 | void KOMonthView::changeEventDisplay(Event *, int) | 1003 | void KOMonthView::changeEventDisplay(Event *, int) |
989 | { | 1004 | { |
990 | // this should be re-written to be much more efficient, but this | 1005 | // this should be re-written to be much more efficient, but this |
991 | // quick-and-dirty-hack gets the job done for right now. | 1006 | // quick-and-dirty-hack gets the job done for right now. |
992 | updateView(); | 1007 | updateView(); |
993 | } | 1008 | } |
994 | 1009 | ||
995 | void KOMonthView::updateView() | 1010 | void KOMonthView::updateView() |
996 | { | 1011 | { |
997 | 1012 | ||
998 | if ( !updatePossible ) | 1013 | if ( !updatePossible ) |
999 | return; | 1014 | return; |
1000 | //QTime ti; | 1015 | //QTime ti; |
1001 | //ti.start(); | 1016 | //ti.start(); |
1002 | #if 1 | 1017 | #if 1 |
1003 | int i; | 1018 | int i; |
1004 | int timeSpan = mCells.size()-1; | 1019 | int timeSpan = mCells.size()-1; |
1005 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1020 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1006 | timeSpan = 6; | 1021 | timeSpan = 6; |
1007 | for( i = 0; i < timeSpan + 1; ++i ) { | 1022 | for( i = 0; i < timeSpan + 1; ++i ) { |
1008 | mCells[i]->startUpdateCell(); | 1023 | mCells[i]->startUpdateCell(); |
1009 | } | 1024 | } |
1010 | 1025 | ||
1011 | QPtrList<Event> events = calendar()->events(); | 1026 | QPtrList<Event> events = calendar()->events(); |
1012 | Event *event; | 1027 | Event *event; |
1013 | QDateTime dt; | 1028 | QDateTime dt; |
1014 | bool ok; | 1029 | bool ok; |
1015 | QDate endDate = mStartDate.addDays( timeSpan ); | 1030 | QDate endDate = mStartDate.addDays( timeSpan ); |
1016 | for( event = events.first(); event; event = events.next() ) { // for event | 1031 | for( event = events.first(); event; event = events.next() ) { // for event |
1017 | if ( event->doesRecur() ) { | 1032 | if ( event->doesRecur() ) { |
1018 | bool last; | 1033 | bool last; |
1019 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1034 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1020 | QDateTime incidenceEnd; | 1035 | QDateTime incidenceEnd; |
1021 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1036 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1022 | bool invalid = false; | 1037 | bool invalid = false; |
1023 | while( true ) { | 1038 | while( true ) { |
1024 | if ( incidenceStart.isValid() ) { | 1039 | if ( incidenceStart.isValid() ) { |
1025 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1040 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1026 | int st = incidenceStart.date().daysTo( endDate ); | 1041 | int st = incidenceStart.date().daysTo( endDate ); |
1027 | if ( st >= 0 ) { // start before timeend | 1042 | if ( st >= 0 ) { // start before timeend |
1028 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1043 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1029 | if ( end >= 0 ) { // end after timestart --- got one! | 1044 | if ( end >= 0 ) { // end after timestart --- got one! |
1030 | //normalize | 1045 | //normalize |
1031 | st = timeSpan - st; | 1046 | st = timeSpan - st; |
1032 | if ( st < 0 ) st = 0; | 1047 | if ( st < 0 ) st = 0; |
1033 | if ( end > timeSpan ) end = timeSpan; | 1048 | if ( end > timeSpan ) end = timeSpan; |
1034 | int iii; | 1049 | int iii; |
1035 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1050 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1036 | for ( iii = st;iii<= end;++iii) | 1051 | for ( iii = st;iii<= end;++iii) |
1037 | mCells[iii]->insertEvent( event ); | 1052 | mCells[iii]->insertEvent( event ); |
1038 | } | 1053 | } |
1039 | } | 1054 | } |
1040 | } else { | 1055 | } else { |
1041 | if ( invalid ) | 1056 | if ( invalid ) |
1042 | break; | 1057 | break; |
1043 | invalid = true; | 1058 | invalid = true; |
1044 | //qDebug("invalid %s", event->summary().latin1()); | 1059 | //qDebug("invalid %s", event->summary().latin1()); |
1045 | incidenceStart = QDateTime( mStartDate ); | 1060 | incidenceStart = QDateTime( mStartDate ); |
1046 | } | 1061 | } |
1047 | if ( last ) | 1062 | if ( last ) |
1048 | break; | 1063 | break; |
1049 | bool ok; | 1064 | bool ok; |
1050 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1065 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1051 | if ( ! ok ) | 1066 | if ( ! ok ) |
1052 | break; | 1067 | break; |
1053 | if ( incidenceStart.date() > endDate ) | 1068 | if ( incidenceStart.date() > endDate ) |
1054 | break; | 1069 | break; |
1055 | } | 1070 | } |
1056 | } else { // no recur | 1071 | } else { // no recur |
1057 | int st = event->dtStart().date().daysTo( endDate ); | 1072 | int st = event->dtStart().date().daysTo( endDate ); |
1058 | if ( st >= 0 ) { // start before timeend | 1073 | if ( st >= 0 ) { // start before timeend |
1059 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1074 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1060 | if ( end >= 0 ) { // end after timestart --- got one! | 1075 | if ( end >= 0 ) { // end after timestart --- got one! |
1061 | //normalize | 1076 | //normalize |
1062 | st = timeSpan - st; | 1077 | st = timeSpan - st; |
1063 | if ( st < 0 ) st = 0; | 1078 | if ( st < 0 ) st = 0; |
1064 | if ( end > timeSpan ) end = timeSpan; | 1079 | if ( end > timeSpan ) end = timeSpan; |
1065 | int iii; | 1080 | int iii; |
1066 | for ( iii = st;iii<= end;++iii) | 1081 | for ( iii = st;iii<= end;++iii) |
1067 | mCells[iii]->insertEvent( event ); | 1082 | mCells[iii]->insertEvent( event ); |
1068 | } | 1083 | } |
1069 | } | 1084 | } |
1070 | } | 1085 | } |
1071 | } | 1086 | } |
1072 | // insert due todos | 1087 | // insert due todos |
1073 | QPtrList<Todo> todos = calendar()->todos( ); | 1088 | QPtrList<Todo> todos = calendar()->todos( ); |
1074 | Todo *todo; | 1089 | Todo *todo; |
1075 | for(todo = todos.first(); todo; todo = todos.next()) { | 1090 | for(todo = todos.first(); todo; todo = todos.next()) { |
1076 | //insertTodo( todo ); | 1091 | //insertTodo( todo ); |
1077 | if ( todo->hasDueDate() ) { | 1092 | if ( todo->hasDueDate() ) { |
1078 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1093 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1079 | if ( day >= 0 && day < timeSpan + 1) { | 1094 | if ( day >= 0 && day < timeSpan + 1) { |
1080 | mCells[day]->insertTodo( todo ); | 1095 | mCells[day]->insertTodo( todo ); |
1081 | } | 1096 | } |
1082 | } | 1097 | } |
1083 | } | 1098 | } |
1084 | 1099 | ||
1085 | for( i = 0; i < timeSpan+1; ++i ) { | 1100 | for( i = 0; i < timeSpan+1; ++i ) { |
1086 | mCells[i]->finishUpdateCell(); | 1101 | mCells[i]->finishUpdateCell(); |
1087 | } | 1102 | } |
1088 | processSelectionChange(); | 1103 | processSelectionChange(); |
1089 | mCells[0]->setFocus(); | 1104 | mCells[0]->setFocus(); |
1090 | 1105 | ||
1091 | 1106 | ||
1092 | #else | 1107 | #else |
1093 | // old code | 1108 | // old code |
1094 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1109 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1095 | int i; | 1110 | int i; |
1096 | for( i = 0; i < mCells.count(); ++i ) { | 1111 | for( i = 0; i < mCells.count(); ++i ) { |
1097 | mCells[i]->updateCell(); | 1112 | mCells[i]->updateCell(); |
1098 | } | 1113 | } |
1099 | 1114 | ||
1100 | //qDebug("KOMonthView::updateView() "); | 1115 | //qDebug("KOMonthView::updateView() "); |
1101 | processSelectionChange(); | 1116 | processSelectionChange(); |
1102 | // qDebug("---------------------------------------------------------------------+ "); | 1117 | // qDebug("---------------------------------------------------------------------+ "); |
1103 | mCells[0]->setFocus(); | 1118 | mCells[0]->setFocus(); |
1104 | #endif | 1119 | #endif |
1105 | 1120 | ||
1106 | //qDebug("update time %d ", ti.elapsed()); | 1121 | //qDebug("update time %d ", ti.elapsed()); |
1107 | } | 1122 | } |
1108 | 1123 | ||
1109 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1124 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1110 | { | 1125 | { |
1111 | computeLayout(); | 1126 | computeLayout(); |
1112 | mCells[0]->setFocus(); | 1127 | mCells[0]->setFocus(); |
1113 | } | 1128 | } |
1114 | void KOMonthView::computeLayoutWeek() | 1129 | void KOMonthView::computeLayoutWeek() |
1115 | { | 1130 | { |
1116 | 1131 | ||
1117 | int daysToShow; | 1132 | int daysToShow; |
1118 | bool combinedSatSun = false; | 1133 | bool combinedSatSun = false; |
1119 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1134 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1120 | daysToShow = 6; | 1135 | daysToShow = 6; |
1121 | combinedSatSun = true; | 1136 | combinedSatSun = true; |
1122 | } | 1137 | } |
1123 | int tWid = topLevelWidget()->size().width(); | 1138 | int tWid = topLevelWidget()->size().width(); |
1124 | int tHei = topLevelWidget()->size().height(); | 1139 | int tHei = topLevelWidget()->size().height(); |
1125 | 1140 | ||
1126 | int wid = size().width();//e | 1141 | int wid = size().width();//e |
1127 | int hei = size().height()-1; | 1142 | int hei = size().height()-1; |
1128 | 1143 | ||
1129 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1144 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1130 | return; | 1145 | return; |
1131 | 1146 | ||
1132 | if ( wid < hei ) | 1147 | if ( wid < hei ) |
1133 | daysToShow = 2; | 1148 | daysToShow = 2; |
1134 | else | 1149 | else |
1135 | daysToShow = 3; | 1150 | daysToShow = 3; |
1136 | mShowSatSunComp = true; | 1151 | mShowSatSunComp = true; |
1137 | combinedSatSun = true; | 1152 | combinedSatSun = true; |
1138 | 1153 | ||
1139 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1154 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1140 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1155 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1141 | int weeklabelwid = fm.width( "888" ); | 1156 | int weeklabelwid = fm.width( "888" ); |
1142 | wid -= weeklabelwid; | 1157 | wid -= weeklabelwid; |
1143 | 1158 | ||
1144 | int colWid = wid / daysToShow; | 1159 | int colWid = wid / daysToShow; |
1145 | int lastCol = wid - ( colWid*6 ); | 1160 | int lastCol = wid - ( colWid*6 ); |
1146 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1161 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1147 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1162 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1148 | int colModulo = wid % daysToShow; | 1163 | int colModulo = wid % daysToShow; |
1149 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1164 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1150 | //qDebug("rowmod %d ", rowModulo); | 1165 | //qDebug("rowmod %d ", rowModulo); |
1151 | int i; | 1166 | int i; |
1152 | int x,y,w,h; | 1167 | int x,y,w,h; |
1153 | x= 0; | 1168 | x= 0; |
1154 | y= 0; | 1169 | y= 0; |
1155 | w = colWid; | 1170 | w = colWid; |
1156 | h = dayLabelHei ; | 1171 | h = dayLabelHei ; |
1157 | for ( i = 0; i < 7; i++) { | 1172 | for ( i = 0; i < 7; i++) { |
1158 | if ( i && !( i % daysToShow) && i < 6) { | 1173 | if ( i && !( i % daysToShow) && i < 6) { |
1159 | y += hei/(5-daysToShow); | 1174 | y += hei/(5-daysToShow); |
1160 | x = 0; | 1175 | x = 0; |
1161 | w = colWid; | 1176 | w = colWid; |
1162 | } | 1177 | } |
1163 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1178 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1164 | ++w; | 1179 | ++w; |
1165 | } | 1180 | } |
1166 | if ( i >= 5 ) { | 1181 | if ( i >= 5 ) { |
1167 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1182 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1168 | x -= (w/2 ); | 1183 | x -= (w/2 ); |
1169 | } | 1184 | } |
1170 | else | 1185 | else |
1171 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1186 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1172 | x += w; | 1187 | x += w; |
1173 | } | 1188 | } |
1174 | x= 0; | 1189 | x= 0; |
1175 | y= dayLabelHei; | 1190 | y= dayLabelHei; |
1176 | w = colWid; | 1191 | w = colWid; |
1177 | h = cellHei; | 1192 | h = cellHei; |
1178 | for ( i = 0; i < mCells.count(); ++i) { | 1193 | for ( i = 0; i < mCells.count(); ++i) { |
1179 | if ( i > 6 ) { | 1194 | if ( i > 6 ) { |
1180 | mCells[i]->hide(); | 1195 | mCells[i]->hide(); |
1181 | continue; | 1196 | continue; |
1182 | } | 1197 | } |
1183 | 1198 | ||
1184 | w = colWid; | 1199 | w = colWid; |
1185 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1200 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1186 | ++w; | 1201 | ++w; |
1187 | } | 1202 | } |
1188 | if ( i == (daysToShow-1-rowModulo)*7) | 1203 | if ( i == (daysToShow-1-rowModulo)*7) |
1189 | ++h; | 1204 | ++h; |
1190 | 1205 | ||
1191 | if ( i >= 5 ) { | 1206 | if ( i >= 5 ) { |
1192 | if ( i ==5 ) { | 1207 | if ( i ==5 ) { |
1193 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1208 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1194 | x -= w ;y += h/2; | 1209 | x -= w ;y += h/2; |
1195 | } else { | 1210 | } else { |
1196 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1211 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1197 | ++w; | 1212 | ++w; |
1198 | } | 1213 | } |
1199 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1214 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1200 | y -= h/2; | 1215 | y -= h/2; |
1201 | } | 1216 | } |
1202 | } else | 1217 | } else |
1203 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1218 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1204 | 1219 | ||
1205 | 1220 | ||
1206 | x += w; | 1221 | x += w; |
1207 | if ( x + w/2 > wid ) { | 1222 | if ( x + w/2 > wid ) { |
1208 | x = 0; | 1223 | x = 0; |
1209 | y += h+dayLabelHei ; | 1224 | y += h+dayLabelHei ; |
1210 | } | 1225 | } |
1211 | } | 1226 | } |
1212 | y= dayLabelHei; | 1227 | y= dayLabelHei; |
1213 | h = cellHei ; | 1228 | h = cellHei ; |
1214 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1229 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1215 | for ( i = 1; i < 6; i++) { | 1230 | for ( i = 1; i < 6; i++) { |
1216 | mWeekLabels[i]->hide(); | 1231 | mWeekLabels[i]->hide(); |
1217 | } | 1232 | } |
1218 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1233 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1219 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1234 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1220 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1235 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1221 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1236 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1222 | updateDayLabels(); | 1237 | updateDayLabels(); |
1223 | bool forceUpdate = !updatePossible; | 1238 | bool forceUpdate = !updatePossible; |
1224 | updatePossible = true; | 1239 | updatePossible = true; |
1225 | mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1240 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1226 | if ( forceUpdate ) | 1241 | if ( forceUpdate ) |
1227 | updateView(); | 1242 | updateView(); |
1228 | } | 1243 | } |
1229 | void KOMonthView::computeLayout() | 1244 | void KOMonthView::computeLayout() |
1230 | { | 1245 | { |
1231 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1246 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1232 | // note this only changes the text if the requested size crosses the | 1247 | // note this only changes the text if the requested size crosses the |
1233 | // threshold between big enough to support the full name and not big | 1248 | // threshold between big enough to support the full name and not big |
1234 | // enough. | 1249 | // enough. |
1235 | if ( mShowWeekView ){ | 1250 | if ( mShowWeekView ){ |
1236 | computeLayoutWeek(); | 1251 | computeLayoutWeek(); |
1237 | return; | 1252 | return; |
1238 | } | 1253 | } |
1239 | int daysToShow = 7; | 1254 | int daysToShow = 7; |
1240 | bool combinedSatSun = false; | 1255 | bool combinedSatSun = false; |
1241 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1256 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1242 | daysToShow = 6; | 1257 | daysToShow = 6; |
1243 | combinedSatSun = true; | 1258 | combinedSatSun = true; |
1244 | } | 1259 | } |
1245 | int tWid = topLevelWidget()->size().width(); | 1260 | int tWid = topLevelWidget()->size().width(); |
1246 | int tHei = topLevelWidget()->size().height(); | 1261 | int tHei = topLevelWidget()->size().height(); |
1247 | 1262 | ||
1248 | int wid = size().width();//e | 1263 | int wid = size().width();//e |
1249 | int hei = size().height()-1; | 1264 | int hei = size().height()-1; |
1250 | 1265 | ||
1251 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1266 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1252 | return; | 1267 | return; |
1253 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1268 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1254 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1269 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1255 | int weeklabelwid = fm.width( "888" ); | 1270 | int weeklabelwid = fm.width( "888" ); |
1256 | wid -= weeklabelwid; | 1271 | wid -= weeklabelwid; |
1257 | 1272 | ||
1258 | int colWid = wid / daysToShow; | 1273 | int colWid = wid / daysToShow; |
1259 | int lastCol = wid - ( colWid*6 ); | 1274 | int lastCol = wid - ( colWid*6 ); |
1260 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1275 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1261 | int cellHei = (hei - dayLabelHei) /6; | 1276 | int cellHei = (hei - dayLabelHei) /6; |
1262 | int colModulo = wid % daysToShow; | 1277 | int colModulo = wid % daysToShow; |
1263 | int rowModulo = (hei- dayLabelHei) % 6; | 1278 | int rowModulo = (hei- dayLabelHei) % 6; |
1264 | //qDebug("rowmod %d ", rowModulo); | 1279 | //qDebug("rowmod %d ", rowModulo); |
1265 | int i; | 1280 | int i; |
1266 | int x,y,w,h; | 1281 | int x,y,w,h; |
1267 | x= 0; | 1282 | x= 0; |
1268 | y= 0; | 1283 | y= 0; |
1269 | w = colWid; | 1284 | w = colWid; |
1270 | h = dayLabelHei ; | 1285 | h = dayLabelHei ; |
1271 | for ( i = 0; i < 7; i++) { | 1286 | for ( i = 0; i < 7; i++) { |
1272 | if ( i == daysToShow-colModulo ) | 1287 | if ( i == daysToShow-colModulo ) |
1273 | ++w; | 1288 | ++w; |
1274 | if ( combinedSatSun ) { | 1289 | if ( combinedSatSun ) { |
1275 | if ( i >= daysToShow-1 ) { | 1290 | if ( i >= daysToShow-1 ) { |
1276 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1291 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1277 | x -= w/2 ; | 1292 | x -= w/2 ; |
1278 | } | 1293 | } |
1279 | else | 1294 | else |
1280 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1295 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1281 | } else | 1296 | } else |
1282 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1297 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1283 | x += w; | 1298 | x += w; |
1284 | } | 1299 | } |
1285 | x= 0; | 1300 | x= 0; |
1286 | y= dayLabelHei; | 1301 | y= dayLabelHei; |
1287 | w = colWid; | 1302 | w = colWid; |
1288 | h = cellHei ; | 1303 | h = cellHei ; |
1289 | for ( i = 0; i < mCells.count(); ++i) { | 1304 | for ( i = 0; i < mCells.count(); ++i) { |
1290 | mCells[i]->show(); | 1305 | mCells[i]->show(); |
1291 | w = colWid; | 1306 | w = colWid; |
1292 | if ( ((i) % 7) >= 7-colModulo ) { | 1307 | if ( ((i) % 7) >= 7-colModulo ) { |
1293 | ++w; | 1308 | ++w; |
1294 | } | 1309 | } |
1295 | if ( i == (6-rowModulo)*7) | 1310 | if ( i == (6-rowModulo)*7) |
1296 | ++h; | 1311 | ++h; |
1297 | if ( combinedSatSun ) { | 1312 | if ( combinedSatSun ) { |
1298 | if ( (i)%7 >= daysToShow-1 ) { | 1313 | if ( (i)%7 >= daysToShow-1 ) { |
1299 | if ( (i)%7 == daysToShow-1 ) { | 1314 | if ( (i)%7 == daysToShow-1 ) { |
1300 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1315 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1301 | x -= w ;y += h/2; | 1316 | x -= w ;y += h/2; |
1302 | } else { | 1317 | } else { |
1303 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1318 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1304 | y -= h/2; | 1319 | y -= h/2; |
1305 | } | 1320 | } |
1306 | } else | 1321 | } else |
1307 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1322 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1308 | 1323 | ||
1309 | } | 1324 | } |
1310 | else | 1325 | else |
1311 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1326 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1312 | x += w; | 1327 | x += w; |
1313 | if ( x + w/2 > wid ) { | 1328 | if ( x + w/2 > wid ) { |
1314 | x = 0; | 1329 | x = 0; |
1315 | y += h; | 1330 | y += h; |
1316 | } | 1331 | } |
1317 | } | 1332 | } |
1318 | y= dayLabelHei; | 1333 | y= dayLabelHei; |
1319 | h = cellHei ; | 1334 | h = cellHei ; |
1320 | for ( i = 0; i < 6; i++) { | 1335 | for ( i = 0; i < 6; i++) { |
1321 | mWeekLabels[i]->show(); | 1336 | mWeekLabels[i]->show(); |
1322 | if ( i == (6-rowModulo)) | 1337 | if ( i == (6-rowModulo)) |
1323 | ++h; | 1338 | ++h; |
1324 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1339 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1325 | y += h; | 1340 | y += h; |
1326 | } | 1341 | } |
1327 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1342 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1328 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1343 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1329 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1344 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1330 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1345 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1331 | updateDayLabels(); | 1346 | updateDayLabels(); |
1332 | bool forceUpdate = !updatePossible; | 1347 | bool forceUpdate = !updatePossible; |
1333 | updatePossible = true; | 1348 | updatePossible = true; |
1334 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1349 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1335 | if ( forceUpdate ) | 1350 | if ( forceUpdate ) |
1336 | updateView(); | 1351 | updateView(); |
1337 | } | 1352 | } |
1338 | 1353 | ||
1339 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1354 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1340 | { | 1355 | { |
1341 | mContextMenu->showIncidencePopup(incidence); | 1356 | mContextMenu->showIncidencePopup(incidence); |
1342 | /* | 1357 | /* |
1343 | if( incidence && incidence->type() == "Event" ) { | 1358 | if( incidence && incidence->type() == "Event" ) { |
1344 | Event *event = static_cast<Event *>(incidence); | 1359 | Event *event = static_cast<Event *>(incidence); |
1345 | mContextMenu->showEventPopup(event); | 1360 | mContextMenu->showEventPopup(event); |
1346 | } else { | 1361 | } else { |
1347 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1362 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1348 | } | 1363 | } |
1349 | */ | 1364 | */ |
1350 | } | 1365 | } |
1351 | MonthViewCell * KOMonthView::selectedCell( ) | 1366 | MonthViewCell * KOMonthView::selectedCell( ) |
1352 | { | 1367 | { |
1353 | return mSelectedCell; | 1368 | return mSelectedCell; |
1354 | } | 1369 | } |
1355 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1370 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1356 | { | 1371 | { |
1357 | // qDebug("KOMonthView::setSelectedCell "); | 1372 | // qDebug("KOMonthView::setSelectedCell "); |
1358 | if ( mSelectedCell && mSelectedCell != cell ) { | 1373 | if ( mSelectedCell && mSelectedCell != cell ) { |
1359 | MonthViewCell * mvc = mSelectedCell; | 1374 | MonthViewCell * mvc = mSelectedCell; |
1360 | mSelectedCell = cell; | 1375 | mSelectedCell = cell; |
1361 | mvc->deselect(); | 1376 | mvc->deselect(); |
1362 | } else | 1377 | } else |
1363 | mSelectedCell = cell; | 1378 | mSelectedCell = cell; |
1364 | // if ( mSelectedCell ) | 1379 | // if ( mSelectedCell ) |
1365 | // mSelectedCell->select(); | 1380 | // mSelectedCell->select(); |
1366 | if ( !mSelectedCell ) | 1381 | if ( !mSelectedCell ) |
1367 | emit incidenceSelected( 0 ); | 1382 | emit incidenceSelected( 0 ); |
1368 | else | 1383 | else |
1369 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1384 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1370 | } | 1385 | } |
1371 | 1386 | ||
1372 | void KOMonthView::processSelectionChange() | 1387 | void KOMonthView::processSelectionChange() |
1373 | { | 1388 | { |
1374 | QPtrList<Incidence> incidences = selectedIncidences(); | 1389 | QPtrList<Incidence> incidences = selectedIncidences(); |
1375 | if (incidences.count() > 0) { | 1390 | if (incidences.count() > 0) { |
1376 | emit incidenceSelected( incidences.first() ); | 1391 | emit incidenceSelected( incidences.first() ); |
1377 | } else { | 1392 | } else { |
1378 | emit incidenceSelected( 0 ); | 1393 | emit incidenceSelected( 0 ); |
1379 | } | 1394 | } |
1380 | } | 1395 | } |
1381 | 1396 | ||
1382 | void KOMonthView::clearSelection() | 1397 | void KOMonthView::clearSelection() |
1383 | { | 1398 | { |
1384 | if ( mSelectedCell ) { | 1399 | if ( mSelectedCell ) { |
1385 | mSelectedCell->deselect(); | 1400 | mSelectedCell->deselect(); |
1386 | mSelectedCell = 0; | 1401 | mSelectedCell = 0; |
1387 | } | 1402 | } |
1388 | } | 1403 | } |
1389 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1404 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1390 | { | 1405 | { |
1391 | //qDebug("KOMonthView::keyPressEvent "); | 1406 | //qDebug("KOMonthView::keyPressEvent "); |
1392 | switch(e->key()) { | 1407 | switch(e->key()) { |
1393 | case Key_Up: | 1408 | case Key_Up: |
1394 | { | 1409 | { |
1395 | emit prevMonth(); | 1410 | emit prevMonth(); |
1396 | mCells[0]->setFocus(); | 1411 | mCells[0]->setFocus(); |
1397 | } | 1412 | } |
1398 | e->accept(); | 1413 | e->accept(); |
1399 | break; | 1414 | break; |
1400 | case Key_Down: | 1415 | case Key_Down: |
1401 | { | 1416 | { |
1402 | emit nextMonth(); | 1417 | emit nextMonth(); |
1403 | mCells[0]->setFocus(); | 1418 | mCells[0]->setFocus(); |
1404 | 1419 | ||
1405 | } | 1420 | } |
1406 | e->accept(); | 1421 | e->accept(); |
1407 | break; | 1422 | break; |
1408 | default: | 1423 | default: |
1409 | e->ignore(); | 1424 | e->ignore(); |
1410 | break; | 1425 | break; |
1411 | } | 1426 | } |
1412 | } | 1427 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 0bc3743..1ed200b 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,283 +1,285 @@ | |||
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 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qintdict.h> | 29 | #include <qintdict.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qvaluelist.h> | 31 | #include <qvaluelist.h> |
32 | #include <qptrvector.h> | 32 | #include <qptrvector.h> |
33 | 33 | ||
34 | #include <libkcal/calendar.h> | 34 | #include <libkcal/calendar.h> |
35 | #include <libkcal/event.h> | 35 | #include <libkcal/event.h> |
36 | 36 | ||
37 | #include "koeventview.h" | 37 | #include "koeventview.h" |
38 | 38 | ||
39 | #ifdef DESKTOP_VERSION | 39 | #ifdef DESKTOP_VERSION |
40 | class QToolTipGroup; | 40 | class QToolTipGroup; |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | class KNOWhatsThis; | 43 | class KNOWhatsThis; |
44 | class KOWeekButton : public QPushButton | 44 | class KOWeekButton : public QPushButton |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | public: | 47 | public: |
48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 48 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
49 | QPushButton( parent, name) | 49 | QPushButton( parent, name) |
50 | { | 50 | { |
51 | connect( this, SIGNAL( clicked() ), | 51 | connect( this, SIGNAL( clicked() ), |
52 | SLOT( bottonClicked() )); | 52 | SLOT( bottonClicked() )); |
53 | mNumber = -1; | 53 | mNumber = -1; |
54 | } | 54 | } |
55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 55 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
56 | signals: | 56 | signals: |
57 | void selectWeekNum ( int ); | 57 | void selectWeekNum ( int ); |
58 | private: | 58 | private: |
59 | int mNumber; | 59 | int mNumber; |
60 | private slots : | 60 | private slots : |
61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 61 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
62 | }; | 62 | }; |
63 | 63 | ||
64 | class KNoScrollListBox: public QListBox | 64 | class KNoScrollListBox: public QListBox |
65 | { | 65 | { |
66 | Q_OBJECT | 66 | Q_OBJECT |
67 | public: | 67 | public: |
68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 68 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
69 | ~KNoScrollListBox(); | 69 | ~KNoScrollListBox(); |
70 | QString getWhatsThisText(QPoint p) ; | 70 | QString getWhatsThisText(QPoint p) ; |
71 | 71 | ||
72 | signals: | 72 | signals: |
73 | void shiftDown(); | 73 | void shiftDown(); |
74 | void shiftUp(); | 74 | void shiftUp(); |
75 | void rightClick(); | 75 | void rightClick(); |
76 | 76 | ||
77 | protected slots: | 77 | protected slots: |
78 | void keyPressEvent(QKeyEvent *); | 78 | void keyPressEvent(QKeyEvent *); |
79 | void keyReleaseEvent(QKeyEvent *); | 79 | void keyReleaseEvent(QKeyEvent *); |
80 | void mousePressEvent(QMouseEvent *); | 80 | void mousePressEvent(QMouseEvent *); |
81 | 81 | ||
82 | private: | 82 | private: |
83 | KNOWhatsThis * mWT; | 83 | KNOWhatsThis * mWT; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | 86 | ||
87 | class MonthViewItem: public QListBoxItem | 87 | class MonthViewItem: public QListBoxItem |
88 | { | 88 | { |
89 | public: | 89 | public: |
90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 90 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
91 | 91 | ||
92 | void setRecur(bool on) { mRecur = on; } | 92 | void setRecur(bool on) { mRecur = on; } |
93 | void setAlarm(bool on) { mAlarm = on; } | 93 | void setAlarm(bool on) { mAlarm = on; } |
94 | void setReply(bool on) { mReply = on; } | 94 | void setReply(bool on) { mReply = on; } |
95 | void setMoreInfo(bool on) { mInfo = on; } | 95 | void setMoreInfo(bool on) { mInfo = on; } |
96 | 96 | ||
97 | 97 | ||
98 | void setPalette(const QPalette &p) { mPalette = p; } | 98 | void setPalette(const QPalette &p) { mPalette = p; } |
99 | QPalette palette() const { return mPalette; } | 99 | QPalette palette() const { return mPalette; } |
100 | 100 | ||
101 | Incidence *incidence() const { return mIncidence; } | 101 | Incidence *incidence() const { return mIncidence; } |
102 | QDate incidenceDate() { return mDate; } | 102 | QDate incidenceDate() { return mDate; } |
103 | 103 | ||
104 | protected: | 104 | protected: |
105 | virtual void paint(QPainter *); | 105 | virtual void paint(QPainter *); |
106 | virtual int height(const QListBox *) const; | 106 | virtual int height(const QListBox *) const; |
107 | virtual int width(const QListBox *) const; | 107 | virtual int width(const QListBox *) const; |
108 | 108 | ||
109 | private: | 109 | private: |
110 | bool mRecur; | 110 | bool mRecur; |
111 | bool mAlarm; | 111 | bool mAlarm; |
112 | bool mReply; | 112 | bool mReply; |
113 | bool mInfo; | 113 | bool mInfo; |
114 | 114 | ||
115 | QPalette mPalette; | 115 | QPalette mPalette; |
116 | QDate mDate; | 116 | QDate mDate; |
117 | 117 | ||
118 | Incidence *mIncidence; | 118 | Incidence *mIncidence; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | class KOMonthView; | 122 | class KOMonthView; |
123 | 123 | ||
124 | class MonthViewCell : public QWidget | 124 | class MonthViewCell : public QWidget |
125 | { | 125 | { |
126 | Q_OBJECT | 126 | Q_OBJECT |
127 | public: | 127 | public: |
128 | MonthViewCell( KOMonthView * ); | 128 | MonthViewCell( KOMonthView * ); |
129 | 129 | ||
130 | void setDate( const QDate & ); | 130 | void setDate( const QDate & ); |
131 | QDate date() const; | 131 | QDate date() const; |
132 | 132 | ||
133 | void setPrimary( bool ); | 133 | void setPrimary( bool ); |
134 | bool isPrimary() const; | 134 | bool isPrimary() const; |
135 | 135 | ||
136 | void setHoliday( bool ); | 136 | void setHoliday( bool ); |
137 | void setHoliday( const QString & ); | 137 | void setHoliday( const QString & ); |
138 | 138 | ||
139 | void updateCell(); | 139 | void updateCell(); |
140 | void startUpdateCell(); | 140 | void startUpdateCell(); |
141 | void finishUpdateCell(); | 141 | void finishUpdateCell(); |
142 | void insertEvent(Event *); | 142 | void insertEvent(Event *); |
143 | void insertTodo(Todo *); | 143 | void insertTodo(Todo *); |
144 | 144 | ||
145 | void updateConfig(); | 145 | void updateConfig(); |
146 | 146 | ||
147 | void enableScrollBars( bool ); | 147 | void enableScrollBars( bool ); |
148 | 148 | ||
149 | Incidence *selectedIncidence(); | 149 | Incidence *selectedIncidence(); |
150 | QDate selectedIncidenceDate(); | 150 | QDate selectedIncidenceDate(); |
151 | 151 | ||
152 | void deselect(); | 152 | void deselect(); |
153 | void select(); | 153 | void select(); |
154 | void clear(); | 154 | void clear(); |
155 | 155 | ||
156 | #ifdef DESKTOP_VERSION | 156 | #ifdef DESKTOP_VERSION |
157 | static QToolTipGroup *toolTipGroup(); | 157 | static QToolTipGroup *toolTipGroup(); |
158 | #endif | 158 | #endif |
159 | signals: | 159 | signals: |
160 | void defaultAction( Incidence * ); | 160 | void defaultAction( Incidence * ); |
161 | void newEventSignal( QDateTime ); | 161 | void newEventSignal( QDateTime ); |
162 | void showDaySignal( QDate ); | 162 | void showDaySignal( QDate ); |
163 | 163 | ||
164 | protected: | 164 | protected: |
165 | QString mToolTip; | 165 | QString mToolTip; |
166 | void resizeEvent( QResizeEvent * ); | 166 | void resizeEvent( QResizeEvent * ); |
167 | 167 | ||
168 | protected slots: | 168 | protected slots: |
169 | void defaultAction( QListBoxItem * ); | 169 | void defaultAction( QListBoxItem * ); |
170 | void contextMenu( QListBoxItem * ); | 170 | void contextMenu( QListBoxItem * ); |
171 | void selection( QListBoxItem * ); | 171 | void selection( QListBoxItem * ); |
172 | void cellClicked( QListBoxItem * ); | 172 | void cellClicked( QListBoxItem * ); |
173 | void newEvent(); | 173 | void newEvent(); |
174 | void showDay(); | 174 | void showDay(); |
175 | 175 | ||
176 | private: | 176 | private: |
177 | KOMonthView *mMonthView; | 177 | KOMonthView *mMonthView; |
178 | 178 | ||
179 | QDate mDate; | 179 | QDate mDate; |
180 | bool mPrimary; | 180 | bool mPrimary; |
181 | bool mHoliday; | 181 | bool mHoliday; |
182 | QString mHolidayString; | 182 | QString mHolidayString; |
183 | 183 | ||
184 | //QLabel *mLabel; | 184 | //QLabel *mLabel; |
185 | QPushButton *mLabel; | 185 | QPushButton *mLabel; |
186 | QListBox *mItemList; | 186 | QListBox *mItemList; |
187 | #ifdef DESKTOP_VERSION | 187 | #ifdef DESKTOP_VERSION |
188 | static QToolTipGroup *mToolTipGroup; | 188 | static QToolTipGroup *mToolTipGroup; |
189 | #endif | 189 | #endif |
190 | QSize mLabelSize; | 190 | QSize mLabelSize; |
191 | QSize mLabelBigSize; | 191 | QSize mLabelBigSize; |
192 | QPalette mHolidayPalette; | 192 | QPalette mHolidayPalette; |
193 | QPalette mStandardPalette; | 193 | QPalette mStandardPalette; |
194 | QPalette mPrimaryPalette; | 194 | QPalette mPrimaryPalette; |
195 | QPalette mNonPrimaryPalette; | 195 | QPalette mNonPrimaryPalette; |
196 | void setMyPalette(); | 196 | void setMyPalette(); |
197 | QPalette getPalette (); | 197 | QPalette getPalette (); |
198 | void keyPressEvent ( QKeyEvent * ) ; | 198 | void keyPressEvent ( QKeyEvent * ) ; |
199 | 199 | ||
200 | }; | 200 | }; |
201 | 201 | ||
202 | 202 | ||
203 | class KOMonthView: public KOEventView | 203 | class KOMonthView: public KOEventView |
204 | { | 204 | { |
205 | Q_OBJECT | 205 | Q_OBJECT |
206 | public: | 206 | public: |
207 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 207 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
208 | ~KOMonthView(); | 208 | ~KOMonthView(); |
209 | 209 | ||
210 | /** Returns maximum number of days supported by the komonthview */ | 210 | /** Returns maximum number of days supported by the komonthview */ |
211 | virtual int maxDatesHint(); | 211 | virtual int maxDatesHint(); |
212 | 212 | ||
213 | /** Returns number of currently shown dates. */ | 213 | /** Returns number of currently shown dates. */ |
214 | virtual int currentDateCount(); | 214 | virtual int currentDateCount(); |
215 | 215 | ||
216 | /** returns the currently selected events */ | 216 | /** returns the currently selected events */ |
217 | virtual QPtrList<Incidence> selectedIncidences(); | 217 | virtual QPtrList<Incidence> selectedIncidences(); |
218 | 218 | ||
219 | /** returns dates of the currently selected events */ | 219 | /** returns dates of the currently selected events */ |
220 | virtual DateList selectedDates(); | 220 | virtual DateList selectedDates(); |
221 | 221 | ||
222 | virtual void printPreview(CalPrinter *calPrinter, | 222 | virtual void printPreview(CalPrinter *calPrinter, |
223 | const QDate &, const QDate &); | 223 | const QDate &, const QDate &); |
224 | bool isMonthView() { return true; } | 224 | bool isMonthView() { return true; } |
225 | bool isUpdatePossible() { return updatePossible; } | 225 | bool isUpdatePossible() { return updatePossible; } |
226 | 226 | ||
227 | MonthViewCell * selectedCell(); | 227 | MonthViewCell * selectedCell(); |
228 | public slots: | 228 | public slots: |
229 | virtual void updateView(); | 229 | virtual void updateView(); |
230 | virtual void updateConfig(); | 230 | virtual void updateConfig(); |
231 | virtual void showDates(const QDate &start, const QDate &end); | 231 | virtual void showDates(const QDate &start, const QDate &end); |
232 | virtual void showEvents(QPtrList<Event> eventList); | 232 | virtual void showEvents(QPtrList<Event> eventList); |
233 | 233 | ||
234 | void changeEventDisplay(Event *, int); | 234 | void changeEventDisplay(Event *, int); |
235 | 235 | ||
236 | void clearSelection(); | 236 | void clearSelection(); |
237 | 237 | ||
238 | void showContextMenu( Incidence * ); | 238 | void showContextMenu( Incidence * ); |
239 | 239 | ||
240 | void setSelectedCell( MonthViewCell * ); | 240 | void setSelectedCell( MonthViewCell * ); |
241 | 241 | ||
242 | protected slots: | 242 | protected slots: |
243 | void selectDateWeekNum ( int ); | ||
244 | void selectInternalWeekNum ( int ); | ||
243 | void switchView(); | 245 | void switchView(); |
244 | void processSelectionChange(); | 246 | void processSelectionChange(); |
245 | signals: | 247 | signals: |
246 | void nextMonth(); | 248 | void nextMonth(); |
247 | void prevMonth(); | 249 | void prevMonth(); |
248 | void showNavigator( bool ); | 250 | void showNavigator( bool ); |
249 | void selectWeekNum ( int ); | 251 | void selectWeekNum ( int ); |
250 | void showDaySignal( QDate ); | 252 | void showDaySignal( QDate ); |
251 | protected: | 253 | protected: |
252 | void resizeEvent(QResizeEvent *); | 254 | void resizeEvent(QResizeEvent *); |
253 | void viewChanged(); | 255 | void viewChanged(); |
254 | void updateDayLabels(); | 256 | void updateDayLabels(); |
255 | 257 | ||
256 | private: | 258 | private: |
257 | bool mShowWeekView; | 259 | bool mShowWeekView; |
258 | bool updatePossible; | 260 | bool updatePossible; |
259 | int mDaysPerWeek; | 261 | int mDaysPerWeek; |
260 | int mNumWeeks; | 262 | int mNumWeeks; |
261 | int mNumCells; | 263 | int mNumCells; |
262 | bool mWeekStartsMonday; | 264 | bool mWeekStartsMonday; |
263 | bool mShowSatSunComp; | 265 | bool mShowSatSunComp; |
264 | void computeLayout(); | 266 | void computeLayout(); |
265 | void computeLayoutWeek(); | 267 | void computeLayoutWeek(); |
266 | 268 | ||
267 | QPtrVector<MonthViewCell> mCells; | 269 | QPtrVector<MonthViewCell> mCells; |
268 | QPtrVector<QLabel> mDayLabels; | 270 | QPtrVector<QLabel> mDayLabels; |
269 | QPtrVector<KOWeekButton> mWeekLabels; | 271 | QPtrVector<KOWeekButton> mWeekLabels; |
270 | 272 | ||
271 | bool mShortDayLabels; | 273 | bool mShortDayLabels; |
272 | int mWidthLongDayLabel; | 274 | int mWidthLongDayLabel; |
273 | 275 | ||
274 | QDate mStartDate; | 276 | QDate mStartDate; |
275 | 277 | ||
276 | MonthViewCell *mSelectedCell; | 278 | MonthViewCell *mSelectedCell; |
277 | 279 | ||
278 | KOEventPopupMenu *mContextMenu; | 280 | KOEventPopupMenu *mContextMenu; |
279 | void keyPressEvent ( QKeyEvent * ) ; | 281 | void keyPressEvent ( QKeyEvent * ) ; |
280 | 282 | ||
281 | }; | 283 | }; |
282 | 284 | ||
283 | #endif | 285 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 8aa0697..ca3de59 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,662 +1,662 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | void KOViewManager::showDateView( int view, QDate date) | 101 | void KOViewManager::showDateView( int view, QDate date) |
102 | { | 102 | { |
103 | static int lastMode = 0; | 103 | static int lastMode = 0; |
104 | static int lastCount = 0; | 104 | static int lastCount = 0; |
105 | static bool lastNDMode = false; | 105 | static bool lastNDMode = false; |
106 | static QDate lastDate; | 106 | static QDate lastDate; |
107 | //qDebug("date %d %s", view, date.toString().latin1()); | 107 | //qDebug("date %d %s", view, date.toString().latin1()); |
108 | 108 | ||
109 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); | 109 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); |
110 | bool savemFlagShowNextxDays = mFlagShowNextxDays; | 110 | bool savemFlagShowNextxDays = mFlagShowNextxDays; |
111 | mFlagShowNextxDays = false; | 111 | mFlagShowNextxDays = false; |
112 | if ( view == 3 ) { | 112 | if ( view == 3 ) { |
113 | //mCurrentAgendaView = 1 ; | 113 | //mCurrentAgendaView = 1 ; |
114 | lastDate = mMainView->dateNavigator()->selectedDates().first(); | 114 | lastDate = mMainView->dateNavigator()->selectedDates().first(); |
115 | lastCount = mMainView->dateNavigator()->selectedDates().count(); | 115 | lastCount = mMainView->dateNavigator()->selectedDates().count(); |
116 | lastNDMode = savemFlagShowNextxDays; | 116 | lastNDMode = savemFlagShowNextxDays; |
117 | mMainView->showDay( date ); | 117 | mMainView->showDay( date ); |
118 | } else if (view == 4 ) { | 118 | } else if (view == 4 ) { |
119 | mCurrentAgendaView = 7 ; | 119 | mCurrentAgendaView = 7 ; |
120 | mMainView->dateNavigator()->selectDates( date, 7 ); | 120 | mMainView->dateNavigator()->selectDates( date, 7 ); |
121 | } else if (view == 5 ) { | 121 | } else if (view == 5 ) { |
122 | mCurrentAgendaView = 14 ; | 122 | mCurrentAgendaView = 14 ; |
123 | mMainView->dateNavigator()->selectDates( date, 14); | 123 | mMainView->dateNavigator()->selectDates( date, 14); |
124 | } else if (view == 6 ) { | 124 | } else if (view == 6 ) { |
125 | mMainView->dateNavigator()->selectDates( date, 7 ); | 125 | mMainView->dateNavigator()->selectDates( date, 7 ); |
126 | showMonthView(); | 126 | showMonthView(); |
127 | } else if (view == 7 ) { | 127 | } else if (view == 7 ) { |
128 | mMainView->dateNavigator()->selectDate( date ); | 128 | mMainView->dateNavigator()->selectDate( date ); |
129 | showJournalView(); | 129 | showJournalView(); |
130 | } else if (view == 8 ) { | 130 | } else if (view == 8 ) { |
131 | globalFlagBlockAgenda = 1; | 131 | globalFlagBlockAgenda = 1; |
132 | if ( mCurrentAgendaView != 3 ) | 132 | if ( mCurrentAgendaView != 3 ) |
133 | mCurrentAgendaView = -1; | 133 | mCurrentAgendaView = -1; |
134 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 134 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
135 | globalFlagBlockAgenda = 2; | 135 | globalFlagBlockAgenda = 2; |
136 | mMainView->dateNavigator()->selectDates( date , | 136 | mMainView->dateNavigator()->selectDates( date , |
137 | KOPrefs::instance()->mNextXDays ); | 137 | KOPrefs::instance()->mNextXDays ); |
138 | mFlagShowNextxDays = true; | 138 | mFlagShowNextxDays = true; |
139 | mCurrentAgendaView = 3 ; | 139 | mCurrentAgendaView = 3 ; |
140 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) | 140 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) |
141 | if ( lastMode ) { | 141 | if ( lastMode ) { |
142 | mCurrentAgendaView = lastCount ; | 142 | mCurrentAgendaView = lastCount ; |
143 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); | 143 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); |
144 | mFlagShowNextxDays = lastNDMode; | 144 | mFlagShowNextxDays = lastNDMode; |
145 | if ( mFlagShowNextxDays ) { | 145 | if ( mFlagShowNextxDays ) { |
146 | mCurrentAgendaView = 3 ; | 146 | mCurrentAgendaView = 3 ; |
147 | } | 147 | } |
148 | } else | 148 | } else |
149 | showWeekView(); | 149 | showWeekView(); |
150 | } else if (view == 10) { | 150 | } else if (view == 10) { |
151 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); | 151 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); |
152 | } | 152 | } |
153 | lastMode = view; | 153 | lastMode = view; |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | 157 | ||
158 | void KOViewManager::writeSettings(KConfig *config) | 158 | void KOViewManager::writeSettings(KConfig *config) |
159 | { | 159 | { |
160 | config->setGroup("General"); | 160 | config->setGroup("General"); |
161 | 161 | ||
162 | QString view; | 162 | QString view; |
163 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 163 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
164 | else if (mCurrentView == mMonthView) view = "Month"; | 164 | else if (mCurrentView == mMonthView) view = "Month"; |
165 | else if (mCurrentView == mListView) view = "List"; | 165 | else if (mCurrentView == mListView) view = "List"; |
166 | else if (mCurrentView == mJournalView) view = "Journal"; | 166 | else if (mCurrentView == mJournalView) view = "Journal"; |
167 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 167 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
168 | else if (mCurrentView == mTodoView) view = "Todo"; | 168 | else if (mCurrentView == mTodoView) view = "Todo"; |
169 | else view = "Agenda"; | 169 | else view = "Agenda"; |
170 | 170 | ||
171 | config->writeEntry("Current View",view); | 171 | config->writeEntry("Current View",view); |
172 | 172 | ||
173 | if (mAgendaView) { | 173 | if (mAgendaView) { |
174 | mAgendaView->writeSettings(config); | 174 | mAgendaView->writeSettings(config); |
175 | } | 175 | } |
176 | if (mTimeSpanView) { | 176 | if (mTimeSpanView) { |
177 | mTimeSpanView->writeSettings(config); | 177 | mTimeSpanView->writeSettings(config); |
178 | } | 178 | } |
179 | if (mListView) { | 179 | if (mListView) { |
180 | mListView->writeSettings(config); | 180 | mListView->writeSettings(config); |
181 | } | 181 | } |
182 | if (mTodoView) { | 182 | if (mTodoView) { |
183 | mTodoView->saveLayout(config,"Todo View"); | 183 | mTodoView->saveLayout(config,"Todo View"); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 187 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
188 | { | 188 | { |
189 | 189 | ||
190 | //mFlagShowNextxDays = false; | 190 | //mFlagShowNextxDays = false; |
191 | //if(view == mCurrentView) return; | 191 | //if(view == mCurrentView) return; |
192 | if ( view == 0 ) { | 192 | if ( view == 0 ) { |
193 | view = mCurrentView; | 193 | view = mCurrentView; |
194 | if ( view == 0 ) | 194 | if ( view == 0 ) |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | bool full = fullScreen; | 197 | bool full = fullScreen; |
198 | if(view == mCurrentView && view != mWhatsNextView ) { | 198 | if(view == mCurrentView && view != mWhatsNextView ) { |
199 | if ( mCurrentAgendaView < 0 ) | 199 | if ( mCurrentAgendaView < 0 ) |
200 | return; | 200 | return; |
201 | full = mMainView->leftFrame()->isVisible(); | 201 | full = mMainView->leftFrame()->isVisible(); |
202 | } else { | 202 | } else { |
203 | mCurrentView = view; | 203 | mCurrentView = view; |
204 | // bool full = fullScreen; | 204 | // bool full = fullScreen; |
205 | bool isFull = !mMainView->leftFrame()->isVisible(); | 205 | bool isFull = !mMainView->leftFrame()->isVisible(); |
206 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 206 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
207 | full = true; | 207 | full = true; |
208 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 208 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
209 | full = false; | 209 | full = false; |
210 | } | 210 | } |
211 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 211 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
212 | //raiseCurrentView( full ); | 212 | //raiseCurrentView( full ); |
213 | mMainView->processIncidenceSelection( 0 ); | 213 | mMainView->processIncidenceSelection( 0 ); |
214 | //mMainView->updateView(); | 214 | //mMainView->updateView(); |
215 | raiseCurrentView( full, true ); | 215 | raiseCurrentView( full, true ); |
216 | mMainView->adaptNavigationUnits(); | 216 | mMainView->adaptNavigationUnits(); |
217 | } | 217 | } |
218 | 218 | ||
219 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | 219 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
220 | { | 220 | { |
221 | mCurrentAgendaView = 0; | 221 | mCurrentAgendaView = 0; |
222 | int wid = mMainView->width() ; | 222 | int wid = mMainView->width() ; |
223 | int hei = mMainView->height(); | 223 | int hei = mMainView->height(); |
224 | if ( mCurrentView == mMonthView ) { | 224 | if ( mCurrentView == mMonthView ) { |
225 | if ( !KOPrefs::instance()->mMonthViewWeek ) { | 225 | if ( true /* !KOPrefs::instance()->mMonthViewWeek*/ ) { |
226 | mMainView->navigatorBar()->show(); | 226 | mMainView->navigatorBar()->show(); |
227 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 227 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
228 | } | 228 | } |
229 | //mMainView->navigatorBar()->hide(); | 229 | //mMainView->navigatorBar()->hide(); |
230 | } else { | 230 | } else { |
231 | mMainView->navigatorBar()->hide(); | 231 | mMainView->navigatorBar()->hide(); |
232 | } | 232 | } |
233 | if ( fullScreen ) { | 233 | if ( fullScreen ) { |
234 | mMainView->leftFrame()->hide(); | 234 | mMainView->leftFrame()->hide(); |
235 | } else { | 235 | } else { |
236 | mMainView->leftFrame()->show(); | 236 | mMainView->leftFrame()->show(); |
237 | if ( KOPrefs::instance()->mVerticalScreen ) | 237 | if ( KOPrefs::instance()->mVerticalScreen ) |
238 | hei -= mMainView->leftFrame()->height(); | 238 | hei -= mMainView->leftFrame()->height(); |
239 | else | 239 | else |
240 | wid -= mMainView->leftFrame()->width(); | 240 | wid -= mMainView->leftFrame()->width(); |
241 | } | 241 | } |
242 | emit signalFullScreen( !fullScreen ); | 242 | emit signalFullScreen( !fullScreen ); |
243 | if ( callUpdateView ) | 243 | if ( callUpdateView ) |
244 | mMainView->updateView(); | 244 | mMainView->updateView(); |
245 | 245 | ||
246 | if ( globalFlagBlockAgenda == 5 ) { | 246 | if ( globalFlagBlockAgenda == 5 ) { |
247 | globalFlagBlockAgenda = 4; | 247 | globalFlagBlockAgenda = 4; |
248 | globalFlagBlockAgendaItemPaint = 1; | 248 | globalFlagBlockAgendaItemPaint = 1; |
249 | } | 249 | } |
250 | mMainView->viewStack()->raiseWidget(mCurrentView); | 250 | mMainView->viewStack()->raiseWidget(mCurrentView); |
251 | if ( globalFlagBlockAgenda == 4 ) { | 251 | if ( globalFlagBlockAgenda == 4 ) { |
252 | if ( mCurrentView == mAgendaView ) { | 252 | if ( mCurrentView == mAgendaView ) { |
253 | //globalFlagBlockAgenda =1 ; | 253 | //globalFlagBlockAgenda =1 ; |
254 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 254 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
255 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 255 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
256 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 256 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
257 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 257 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
258 | qApp->processEvents(); | 258 | qApp->processEvents(); |
259 | //qDebug("qApp->processEvents() "); | 259 | //qDebug("qApp->processEvents() "); |
260 | globalFlagBlockAgenda = 0; | 260 | globalFlagBlockAgenda = 0; |
261 | mAgendaView->repaintAgenda(); | 261 | mAgendaView->repaintAgenda(); |
262 | 262 | ||
263 | } | 263 | } |
264 | globalFlagBlockAgenda = 0; | 264 | globalFlagBlockAgenda = 0; |
265 | } | 265 | } |
266 | emit signalAgendaView( mCurrentView == mAgendaView ); | 266 | emit signalAgendaView( mCurrentView == mAgendaView ); |
267 | //qDebug("raiseCurrentView ende "); | 267 | //qDebug("raiseCurrentView ende "); |
268 | 268 | ||
269 | } | 269 | } |
270 | 270 | ||
271 | void KOViewManager::updateView() | 271 | void KOViewManager::updateView() |
272 | { | 272 | { |
273 | // qDebug("KOViewManager::updateView() "); | 273 | // qDebug("KOViewManager::updateView() "); |
274 | // if we are updating mTodoView, we get endless recursion | 274 | // if we are updating mTodoView, we get endless recursion |
275 | if ( mTodoView == mCurrentView ) | 275 | if ( mTodoView == mCurrentView ) |
276 | return; | 276 | return; |
277 | if ( mCurrentView ) mCurrentView->updateView(); | 277 | if ( mCurrentView ) mCurrentView->updateView(); |
278 | 278 | ||
279 | } | 279 | } |
280 | 280 | ||
281 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 281 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
282 | { | 282 | { |
283 | // kdDebug() << "KOViewManager::updateView()" << endl; | 283 | // kdDebug() << "KOViewManager::updateView()" << endl; |
284 | 284 | ||
285 | if (mCurrentView) mCurrentView->showDates(start, end); | 285 | if (mCurrentView) mCurrentView->showDates(start, end); |
286 | 286 | ||
287 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); | 287 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | void KOViewManager::updateWNview() | 291 | void KOViewManager::updateWNview() |
292 | { | 292 | { |
293 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 293 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
294 | mWhatsNextView->updateView(); | 294 | mWhatsNextView->updateView(); |
295 | 295 | ||
296 | } | 296 | } |
297 | void KOViewManager::showWhatsNextView() | 297 | void KOViewManager::showWhatsNextView() |
298 | { | 298 | { |
299 | if (!mWhatsNextView) { | 299 | if (!mWhatsNextView) { |
300 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 300 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
301 | "KOViewManager::WhatsNextView"); | 301 | "KOViewManager::WhatsNextView"); |
302 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 302 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
303 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 303 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
304 | addView(mWhatsNextView); | 304 | addView(mWhatsNextView); |
305 | connect(this, SIGNAL( printWNV() ), | 305 | connect(this, SIGNAL( printWNV() ), |
306 | mWhatsNextView, SLOT( printMe() ) ); | 306 | mWhatsNextView, SLOT( printMe() ) ); |
307 | } | 307 | } |
308 | globalFlagBlockAgenda = 1; | 308 | globalFlagBlockAgenda = 1; |
309 | showView(mWhatsNextView, true ); | 309 | showView(mWhatsNextView, true ); |
310 | //mWhatsNextView->updateView(); | 310 | //mWhatsNextView->updateView(); |
311 | 311 | ||
312 | } | 312 | } |
313 | 313 | ||
314 | void KOViewManager::showListView() | 314 | void KOViewManager::showListView() |
315 | { | 315 | { |
316 | if (!mListView) { | 316 | if (!mListView) { |
317 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 317 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
318 | addView(mListView); | 318 | addView(mListView); |
319 | 319 | ||
320 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 320 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
321 | mMainView, SLOT(showIncidence(Incidence *))); | 321 | mMainView, SLOT(showIncidence(Incidence *))); |
322 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 322 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
323 | mMainView, SLOT(editIncidence(Incidence *))); | 323 | mMainView, SLOT(editIncidence(Incidence *))); |
324 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 324 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
325 | mMainView, SLOT(deleteIncidence(Incidence *))); | 325 | mMainView, SLOT(deleteIncidence(Incidence *))); |
326 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 326 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
327 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 327 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
328 | connect( mListView, SIGNAL( signalNewEvent() ), | 328 | connect( mListView, SIGNAL( signalNewEvent() ), |
329 | mMainView, SLOT( newEvent() ) ); | 329 | mMainView, SLOT( newEvent() ) ); |
330 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 330 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
331 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 331 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
332 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 332 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
333 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 333 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
334 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 334 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
335 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 335 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
336 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 336 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
337 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 337 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
338 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 338 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
339 | } | 339 | } |
340 | // bool temp = mFlagShowNextxDays; | 340 | // bool temp = mFlagShowNextxDays; |
341 | //globalFlagBlockPainting = true; | 341 | //globalFlagBlockPainting = true; |
342 | globalFlagBlockAgenda = 1; | 342 | globalFlagBlockAgenda = 1; |
343 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 343 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
344 | mMainView->setBlockShowDates( true ); | 344 | mMainView->setBlockShowDates( true ); |
345 | mMainView->dateNavigator()->selectMonth(); | 345 | mMainView->dateNavigator()->selectMonth(); |
346 | mMainView->setBlockShowDates( false ); | 346 | mMainView->setBlockShowDates( false ); |
347 | } | 347 | } |
348 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 348 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
349 | //mFlagShowNextxDays = temp; | 349 | //mFlagShowNextxDays = temp; |
350 | } | 350 | } |
351 | 351 | ||
352 | void KOViewManager::showAgendaView( bool fullScreen ) | 352 | void KOViewManager::showAgendaView( bool fullScreen ) |
353 | { | 353 | { |
354 | 354 | ||
355 | mMainView->dialogManager()->hideSearchDialog(); | 355 | mMainView->dialogManager()->hideSearchDialog(); |
356 | // qDebug("KOViewManager::showAgendaView "); | 356 | // qDebug("KOViewManager::showAgendaView "); |
357 | bool full; | 357 | bool full; |
358 | full = fullScreen; | 358 | full = fullScreen; |
359 | if (!mAgendaView) { | 359 | if (!mAgendaView) { |
360 | full = false; | 360 | full = false; |
361 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 361 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
362 | addView(mAgendaView); | 362 | addView(mAgendaView); |
363 | #ifndef DESKTOP_VERSION | 363 | #ifndef DESKTOP_VERSION |
364 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 364 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
365 | #endif | 365 | #endif |
366 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 366 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
367 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 367 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
368 | 368 | ||
369 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 369 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
370 | 370 | ||
371 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 371 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
372 | 372 | ||
373 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 373 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
374 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 374 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
375 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 375 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
376 | mMainView, SLOT(newEvent(QDateTime))); | 376 | mMainView, SLOT(newEvent(QDateTime))); |
377 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 377 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
378 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 378 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
379 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 379 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
380 | mMainView, SLOT(newEvent(QDate))); | 380 | mMainView, SLOT(newEvent(QDate))); |
381 | 381 | ||
382 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 382 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
383 | mMainView, SLOT(editIncidence(Incidence *))); | 383 | mMainView, SLOT(editIncidence(Incidence *))); |
384 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 384 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
385 | mMainView, SLOT(showIncidence(Incidence *))); | 385 | mMainView, SLOT(showIncidence(Incidence *))); |
386 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 386 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
387 | mMainView, SLOT(deleteIncidence(Incidence *))); | 387 | mMainView, SLOT(deleteIncidence(Incidence *))); |
388 | 388 | ||
389 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 389 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
390 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 390 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
391 | 391 | ||
392 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 392 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
393 | mMainView, SLOT( toggleExpand() ) ); | 393 | mMainView, SLOT( toggleExpand() ) ); |
394 | 394 | ||
395 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 395 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
396 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 396 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
397 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 397 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
398 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 398 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
399 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 399 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
400 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 400 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
401 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 401 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
402 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 402 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
403 | SLOT( updateTodo( Todo *, int ) ) ); | 403 | SLOT( updateTodo( Todo *, int ) ) ); |
404 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 404 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
405 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 405 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
406 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 406 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
407 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 407 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
408 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 408 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
409 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 409 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
410 | mAgendaView->readSettings(); | 410 | mAgendaView->readSettings(); |
411 | mAgendaView->updateConfig(); | 411 | mAgendaView->updateConfig(); |
412 | } | 412 | } |
413 | 413 | ||
414 | showView( mAgendaView, full); | 414 | showView( mAgendaView, full); |
415 | 415 | ||
416 | } | 416 | } |
417 | 417 | ||
418 | void KOViewManager::showDayView() | 418 | void KOViewManager::showDayView() |
419 | { | 419 | { |
420 | mFlagShowNextxDays = false; | 420 | mFlagShowNextxDays = false; |
421 | globalFlagBlockLabel = 1; | 421 | globalFlagBlockLabel = 1; |
422 | globalFlagBlockAgenda = 1; | 422 | globalFlagBlockAgenda = 1; |
423 | if ( mCurrentAgendaView != 1 ) | 423 | if ( mCurrentAgendaView != 1 ) |
424 | mCurrentAgendaView = -1; | 424 | mCurrentAgendaView = -1; |
425 | showAgendaView(); | 425 | showAgendaView(); |
426 | qApp->processEvents(); | 426 | qApp->processEvents(); |
427 | globalFlagBlockAgenda = 2; | 427 | globalFlagBlockAgenda = 2; |
428 | globalFlagBlockLabel = 0; | 428 | globalFlagBlockLabel = 0; |
429 | mMainView->dateNavigator()->selectDates( 1 ); | 429 | mMainView->dateNavigator()->selectDates( 1 ); |
430 | mCurrentAgendaView = 1 ; | 430 | mCurrentAgendaView = 1 ; |
431 | 431 | ||
432 | } | 432 | } |
433 | 433 | ||
434 | void KOViewManager::showWorkWeekView() | 434 | void KOViewManager::showWorkWeekView() |
435 | { | 435 | { |
436 | mFlagShowNextxDays = false; | 436 | mFlagShowNextxDays = false; |
437 | globalFlagBlockAgenda = 1; | 437 | globalFlagBlockAgenda = 1; |
438 | globalFlagBlockLabel = 1; | 438 | globalFlagBlockLabel = 1; |
439 | if ( mCurrentAgendaView != 5 ) | 439 | if ( mCurrentAgendaView != 5 ) |
440 | mCurrentAgendaView = -1; | 440 | mCurrentAgendaView = -1; |
441 | showAgendaView(); | 441 | showAgendaView(); |
442 | qApp->processEvents(); | 442 | qApp->processEvents(); |
443 | globalFlagBlockAgenda = 2; | 443 | globalFlagBlockAgenda = 2; |
444 | globalFlagBlockLabel = 0; | 444 | globalFlagBlockLabel = 0; |
445 | mMainView->dateNavigator()->selectWorkWeek(); | 445 | mMainView->dateNavigator()->selectWorkWeek(); |
446 | mCurrentAgendaView = 5 ; | 446 | mCurrentAgendaView = 5 ; |
447 | 447 | ||
448 | } | 448 | } |
449 | 449 | ||
450 | void KOViewManager::showWeekView() | 450 | void KOViewManager::showWeekView() |
451 | { | 451 | { |
452 | /* | 452 | /* |
453 | globalFlagBlockAgenda = 2; | 453 | globalFlagBlockAgenda = 2; |
454 | qDebug("4globalFlagBlockAgenda = 2; "); | 454 | qDebug("4globalFlagBlockAgenda = 2; "); |
455 | //globalFlagBlockPainting = true; | 455 | //globalFlagBlockPainting = true; |
456 | mMainView->dateNavigator()->selectWeek(); | 456 | mMainView->dateNavigator()->selectWeek(); |
457 | showAgendaView(); | 457 | showAgendaView(); |
458 | */ | 458 | */ |
459 | 459 | ||
460 | 460 | ||
461 | mFlagShowNextxDays = false; | 461 | mFlagShowNextxDays = false; |
462 | globalFlagBlockAgenda = 1; | 462 | globalFlagBlockAgenda = 1; |
463 | globalFlagBlockLabel = 1; | 463 | globalFlagBlockLabel = 1; |
464 | if ( mCurrentAgendaView != 7 ) | 464 | if ( mCurrentAgendaView != 7 ) |
465 | mCurrentAgendaView = -1; | 465 | mCurrentAgendaView = -1; |
466 | showAgendaView(); | 466 | showAgendaView(); |
467 | qApp->processEvents(); | 467 | qApp->processEvents(); |
468 | globalFlagBlockAgenda = 2; | 468 | globalFlagBlockAgenda = 2; |
469 | globalFlagBlockLabel = 0; | 469 | globalFlagBlockLabel = 0; |
470 | mMainView->dateNavigator()->selectWeek(); | 470 | mMainView->dateNavigator()->selectWeek(); |
471 | mCurrentAgendaView = 7 ; | 471 | mCurrentAgendaView = 7 ; |
472 | } | 472 | } |
473 | 473 | ||
474 | void KOViewManager::showNextXView() | 474 | void KOViewManager::showNextXView() |
475 | { | 475 | { |
476 | 476 | ||
477 | globalFlagBlockAgenda = 1; | 477 | globalFlagBlockAgenda = 1; |
478 | if ( mCurrentAgendaView != 3 ) | 478 | if ( mCurrentAgendaView != 3 ) |
479 | mCurrentAgendaView = -1; | 479 | mCurrentAgendaView = -1; |
480 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 480 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
481 | globalFlagBlockAgenda = 2; | 481 | globalFlagBlockAgenda = 2; |
482 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 482 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
483 | KOPrefs::instance()->mNextXDays ); | 483 | KOPrefs::instance()->mNextXDays ); |
484 | mFlagShowNextxDays = true; | 484 | mFlagShowNextxDays = true; |
485 | mCurrentAgendaView = 3 ; | 485 | mCurrentAgendaView = 3 ; |
486 | } | 486 | } |
487 | bool KOViewManager::showsNextDays() | 487 | bool KOViewManager::showsNextDays() |
488 | { | 488 | { |
489 | return mFlagShowNextxDays; | 489 | return mFlagShowNextxDays; |
490 | } | 490 | } |
491 | void KOViewManager::showMonthView() | 491 | void KOViewManager::showMonthView() |
492 | { | 492 | { |
493 | if (!mMonthView) { | 493 | if (!mMonthView) { |
494 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 494 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
495 | 495 | ||
496 | addView(mMonthView); | 496 | addView(mMonthView); |
497 | // mMonthView->show(); | 497 | // mMonthView->show(); |
498 | // SIGNALS/SLOTS FOR MONTH VIEW | 498 | // SIGNALS/SLOTS FOR MONTH VIEW |
499 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 499 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
500 | mMainView, SLOT(newEvent(QDateTime))); | 500 | mMainView, SLOT(newEvent(QDateTime))); |
501 | 501 | ||
502 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 502 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
503 | mMainView, SLOT(showIncidence(Incidence *))); | 503 | mMainView, SLOT(showIncidence(Incidence *))); |
504 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 504 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
505 | mMainView, SLOT(editIncidence(Incidence *))); | 505 | mMainView, SLOT(editIncidence(Incidence *))); |
506 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 506 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
507 | mMainView, SLOT(deleteIncidence(Incidence *))); | 507 | mMainView, SLOT(deleteIncidence(Incidence *))); |
508 | 508 | ||
509 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 509 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
510 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 510 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
511 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 511 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
512 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 512 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
513 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 513 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
514 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 514 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
515 | 515 | ||
516 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 516 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
517 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 517 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
518 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 518 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
519 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 519 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
520 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 520 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
521 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 521 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); |
522 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 522 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
523 | mMainView, SLOT ( showDay( QDate ) ) ); | 523 | mMainView, SLOT ( showDay( QDate ) ) ); |
524 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 524 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
525 | connect( mMonthView, SIGNAL(nextMonth() ), | 525 | connect( mMonthView, SIGNAL(nextMonth() ), |
526 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 526 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
527 | connect( mMonthView, SIGNAL(prevMonth() ), | 527 | connect( mMonthView, SIGNAL(prevMonth() ), |
528 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 528 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
529 | connect( mMonthView, SIGNAL( showNavigator(bool) ), | 529 | connect( mMonthView, SIGNAL( showNavigator(bool) ), |
530 | mMainView, SLOT ( showNavigatorBar(bool) ) ); | 530 | mMainView, SLOT ( showNavigatorBar(bool) ) ); |
531 | } | 531 | } |
532 | 532 | ||
533 | globalFlagBlockAgenda = 1; | 533 | globalFlagBlockAgenda = 1; |
534 | //mFlagShowNextxDays = false; | 534 | //mFlagShowNextxDays = false; |
535 | // if(mMonthView == mCurrentView) return; | 535 | // if(mMonthView == mCurrentView) return; |
536 | if ( KOPrefs::instance()->mMonthViewWeek ) | 536 | if ( KOPrefs::instance()->mMonthViewWeek ) |
537 | mMainView->dateNavigator()->selectWeek(); | 537 | mMainView->dateNavigator()->selectWeek(); |
538 | else | 538 | else |
539 | mMainView->dateNavigator()->selectMonth(); | 539 | mMainView->dateNavigator()->selectMonth(); |
540 | 540 | ||
541 | showView(mMonthView, true ); | 541 | showView(mMonthView, true ); |
542 | 542 | ||
543 | } | 543 | } |
544 | 544 | ||
545 | void KOViewManager::showTodoView() | 545 | void KOViewManager::showTodoView() |
546 | { | 546 | { |
547 | //mFlagShowNextxDays = false; | 547 | //mFlagShowNextxDays = false; |
548 | if ( !mTodoView ) { | 548 | if ( !mTodoView ) { |
549 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 549 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
550 | "KOViewManager::TodoView" ); | 550 | "KOViewManager::TodoView" ); |
551 | 551 | ||
552 | addView( mTodoView ); | 552 | addView( mTodoView ); |
553 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 553 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
554 | 554 | ||
555 | // SIGNALS/SLOTS FOR TODO VIEW | 555 | // SIGNALS/SLOTS FOR TODO VIEW |
556 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 556 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
557 | mMainView, SLOT( newTodo() ) ); | 557 | mMainView, SLOT( newTodo() ) ); |
558 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 558 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
559 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 559 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
560 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 560 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
561 | mMainView, SLOT( showTodo( Todo * ) ) ); | 561 | mMainView, SLOT( showTodo( Todo * ) ) ); |
562 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 562 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
563 | mMainView, SLOT( editTodo( Todo * ) ) ); | 563 | mMainView, SLOT( editTodo( Todo * ) ) ); |
564 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 564 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
565 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 565 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
566 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 566 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
567 | mMainView, SLOT( purgeCompleted() ) ); | 567 | mMainView, SLOT( purgeCompleted() ) ); |
568 | 568 | ||
569 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 569 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
570 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 570 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
571 | 571 | ||
572 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 572 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
573 | SLOT( updateConfig() ) ); | 573 | SLOT( updateConfig() ) ); |
574 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 574 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
575 | SLOT( updateTodo( Todo *, int ) ) ); | 575 | SLOT( updateTodo( Todo *, int ) ) ); |
576 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 576 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
577 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 577 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
578 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 578 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
579 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 579 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
580 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 580 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
581 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 581 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
582 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 582 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
583 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 583 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
584 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 584 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
585 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 585 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
586 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 586 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
587 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 587 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
588 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 588 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
589 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 589 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
590 | KConfig *config = KOGlobals::config(); | 590 | KConfig *config = KOGlobals::config(); |
591 | mTodoView->restoreLayout(config,"Todo View"); | 591 | mTodoView->restoreLayout(config,"Todo View"); |
592 | mTodoView->setNavigator( mMainView->dateNavigator() ); | 592 | mTodoView->setNavigator( mMainView->dateNavigator() ); |
593 | } | 593 | } |
594 | 594 | ||
595 | globalFlagBlockAgenda = 1; | 595 | globalFlagBlockAgenda = 1; |
596 | showView( mTodoView, true ); | 596 | showView( mTodoView, true ); |
597 | 597 | ||
598 | } | 598 | } |
599 | 599 | ||
600 | void KOViewManager::showJournalView() | 600 | void KOViewManager::showJournalView() |
601 | { | 601 | { |
602 | //mFlagShowNextxDays = false; | 602 | //mFlagShowNextxDays = false; |
603 | if (!mJournalView) { | 603 | if (!mJournalView) { |
604 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 604 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
605 | "KOViewManager::JournalView"); | 605 | "KOViewManager::JournalView"); |
606 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 606 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
607 | SLOT( updateConfig() ) ); | 607 | SLOT( updateConfig() ) ); |
608 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 608 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
609 | addView(mJournalView); | 609 | addView(mJournalView); |
610 | } | 610 | } |
611 | 611 | ||
612 | showView(mJournalView); | 612 | showView(mJournalView); |
613 | mMainView->dateNavigator()->selectDates( 1 ); | 613 | mMainView->dateNavigator()->selectDates( 1 ); |
614 | } | 614 | } |
615 | 615 | ||
616 | void KOViewManager::showTimeSpanView() | 616 | void KOViewManager::showTimeSpanView() |
617 | { | 617 | { |
618 | //mFlagShowNextxDays = false; | 618 | //mFlagShowNextxDays = false; |
619 | if (!mTimeSpanView) { | 619 | if (!mTimeSpanView) { |
620 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 620 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
621 | "KOViewManager::TimeSpanView"); | 621 | "KOViewManager::TimeSpanView"); |
622 | addView(mTimeSpanView); | 622 | addView(mTimeSpanView); |
623 | 623 | ||
624 | mTimeSpanView->readSettings(); | 624 | mTimeSpanView->readSettings(); |
625 | } | 625 | } |
626 | 626 | ||
627 | showView(mTimeSpanView); | 627 | showView(mTimeSpanView); |
628 | } | 628 | } |
629 | 629 | ||
630 | Incidence *KOViewManager::currentSelection() | 630 | Incidence *KOViewManager::currentSelection() |
631 | { | 631 | { |
632 | if (!mCurrentView) return 0; | 632 | if (!mCurrentView) return 0; |
633 | if ( mCurrentView == mListView ) { | 633 | if ( mCurrentView == mListView ) { |
634 | if ( mListView->currentItem() ) | 634 | if ( mListView->currentItem() ) |
635 | return mListView->currentItem(); | 635 | return mListView->currentItem(); |
636 | } | 636 | } |
637 | return mCurrentView->selectedIncidences().first(); | 637 | return mCurrentView->selectedIncidences().first(); |
638 | } | 638 | } |
639 | 639 | ||
640 | QDate KOViewManager::currentSelectionDate() | 640 | QDate KOViewManager::currentSelectionDate() |
641 | { | 641 | { |
642 | QDate qd; | 642 | QDate qd; |
643 | if (mCurrentView) { | 643 | if (mCurrentView) { |
644 | DateList qvl = mCurrentView->selectedDates(); | 644 | DateList qvl = mCurrentView->selectedDates(); |
645 | if (!qvl.isEmpty()) qd = qvl.first(); | 645 | if (!qvl.isEmpty()) qd = qvl.first(); |
646 | } | 646 | } |
647 | return qd; | 647 | return qd; |
648 | } | 648 | } |
649 | 649 | ||
650 | void KOViewManager::addView(KOrg::BaseView *view) | 650 | void KOViewManager::addView(KOrg::BaseView *view) |
651 | { | 651 | { |
652 | #if QT_VERSION >= 0x030000 | 652 | #if QT_VERSION >= 0x030000 |
653 | mMainView->viewStack()->addWidget( view ); | 653 | mMainView->viewStack()->addWidget( view ); |
654 | #else | 654 | #else |
655 | mMainView->viewStack()->addWidget( view, 1 ); | 655 | mMainView->viewStack()->addWidget( view, 1 ); |
656 | #endif | 656 | #endif |
657 | } | 657 | } |
658 | 658 | ||
659 | void KOViewManager::setDocumentId( const QString &id ) | 659 | void KOViewManager::setDocumentId( const QString &id ) |
660 | { | 660 | { |
661 | if (mTodoView) mTodoView->setDocumentId( id ); | 661 | if (mTodoView) mTodoView->setDocumentId( id ); |
662 | } | 662 | } |