-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 83 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.h | 2 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 3 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 16 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 2 |
5 files changed, 82 insertions, 24 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 18756f0..bb27bce 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,276 +1,319 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
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 <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | //#include "koglobals.h" | 29 | //#include "koglobals.h" |
30 | #include "navigatorbar.h" | 30 | #include "navigatorbar.h" |
31 | #include "kdatenavigator.h" | 31 | #include "kdatenavigator.h" |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
39 | const char *name ) | 39 | const char *name ) |
40 | : QWidget( parent, name ), mCalendar( 0 ), | 40 | : QWidget( parent, name ), mCalendar( 0 ), |
41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
42 | { | 42 | { |
43 | mExtraViews.setAutoDelete( true ); | 43 | mExtraViews.setAutoDelete( true ); |
44 | 44 | ||
45 | mNavigatorView = new KDateNavigator( this, name ); | 45 | mNavigatorView = new KDateNavigator( this, name ); |
46 | 46 | ||
47 | connectNavigatorView( mNavigatorView ); | 47 | connectNavigatorView( mNavigatorView ); |
48 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 48 | //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
49 | mDisplayedEndDate = QDate::currentDate(); | ||
50 | mLastDisplayedDN = 0; | ||
49 | } | 51 | } |
50 | 52 | ||
51 | DateNavigatorContainer::~DateNavigatorContainer() | 53 | DateNavigatorContainer::~DateNavigatorContainer() |
52 | { | 54 | { |
53 | } | 55 | } |
54 | 56 | ||
55 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 57 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
56 | { | 58 | { |
57 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 59 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
58 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 60 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
59 | #if 0 | 61 | #if 0 |
60 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 62 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
61 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 63 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
62 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 64 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
63 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 65 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
64 | #endif | 66 | #endif |
65 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 67 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
66 | SIGNAL( weekClicked( const QDate & ) ) ); | 68 | SIGNAL( weekClicked( const QDate & ) ) ); |
67 | 69 | ||
68 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 70 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
69 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 71 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
70 | 72 | ||
71 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 73 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 74 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
73 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 75 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
74 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 76 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
75 | 77 | ||
76 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 78 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
77 | } | 79 | } |
78 | 80 | ||
79 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 81 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
80 | { | 82 | { |
81 | mCalendar = cal; | 83 | mCalendar = cal; |
82 | mNavigatorView->setCalendar( cal ); | 84 | mNavigatorView->setCalendar( cal ); |
83 | KDateNavigator *n; | 85 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
84 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 86 | KDateNavigator *n = mExtraViews.at( i ); |
85 | n->setCalendar( cal ); | 87 | n->setCalendar( cal ); |
86 | } | 88 | } |
87 | } | 89 | } |
88 | 90 | ||
89 | void DateNavigatorContainer::updateDayMatrix() | 91 | void DateNavigatorContainer::updateDayMatrix() |
90 | { | 92 | { |
91 | mNavigatorView->updateDayMatrix(); | 93 | mNavigatorView->updateDayMatrix(); |
92 | KDateNavigator *n; | 94 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
93 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 95 | KDateNavigator *n = mExtraViews.at( i ); |
94 | n->updateDayMatrix(); | 96 | n->updateDayMatrix(); |
95 | } | 97 | } |
96 | } | 98 | } |
97 | 99 | ||
98 | void DateNavigatorContainer::updateToday() | 100 | void DateNavigatorContainer::updateToday() |
99 | { | 101 | { |
100 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 102 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
101 | #if 0 | 103 | #if 0 |
102 | mNavigatorView->updateToday(); | 104 | mNavigatorView->updateToday(); |
103 | KDateNavigator *n; | 105 | KDateNavigator *n; |
104 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 106 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
105 | n->updateToday(); | 107 | n->updateToday(); |
106 | } | 108 | } |
107 | #endif | 109 | #endif |
108 | } | 110 | } |
109 | 111 | ||
110 | void DateNavigatorContainer::updateView() | 112 | void DateNavigatorContainer::updateView() |
111 | { | 113 | { |
112 | mNavigatorView->updateView(); | 114 | mNavigatorView->updateView(); |
113 | KDateNavigator *n; | 115 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
114 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 116 | KDateNavigator *n = mExtraViews.at( i ); |
115 | n->updateView(); | 117 | n->updateView(); |
116 | } | 118 | } |
117 | } | 119 | } |
118 | 120 | ||
119 | void DateNavigatorContainer::updateConfig() | 121 | void DateNavigatorContainer::updateConfig() |
120 | { | 122 | { |
121 | mNavigatorView->updateConfig(); | 123 | mNavigatorView->updateConfig(); |
122 | KDateNavigator *n; | 124 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
123 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 125 | KDateNavigator *n = mExtraViews.at( i ); |
124 | n->updateConfig(); | 126 | n->updateConfig(); |
125 | } | 127 | } |
126 | } | 128 | } |
127 | 129 | ||
128 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 130 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
129 | { | 131 | { |
130 | mNavigatorView->selectDates( dateList ); | 132 | if ( !mLastDisplayedDN ) { |
131 | setBaseDates(); | 133 | mNavigatorView->selectDates( dateList ); |
132 | if ( mExtraViews.count() ) { | 134 | return; |
135 | } | ||
136 | QDate fDate = dateList.first(); | ||
137 | QDate lDate = dateList.last(); | ||
138 | if ( mLastDisplayedDN <= 2 ) { | ||
139 | mNavigatorView->selectDates( dateList ); | ||
140 | KDateNavigator *view = mExtraViews.at( 0 ); | ||
141 | QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 ); | ||
142 | view->setBaseDate( bDate, false ); | ||
143 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); | ||
144 | if ( mLastDisplayedDN == 2 ) { | ||
145 | view = mExtraViews.at( 1 ); | ||
146 | bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 ); | ||
147 | view->setBaseDate( bDate, false ); | ||
148 | view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); | ||
149 | } | ||
150 | return; | ||
151 | } | ||
152 | KDateNavigator *view = mExtraViews.at( 0 ); | ||
153 | QDate date = view->baseDate(); | ||
154 | |||
155 | QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7); | ||
156 | //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); | ||
157 | if ( lDate < curEnd && date.addDays( -30 ) < fDate) { | ||
158 | mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); | ||
159 | mNavigatorView->dayMatrix()->repaint( false ); | ||
160 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | ||
161 | KDateNavigator *n = mExtraViews.at( i ); | ||
162 | if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { | ||
163 | n->dayMatrix()->repaint( false ); | ||
164 | } | ||
165 | } | ||
166 | return; | ||
167 | } | ||
168 | mNavigatorView->selectDates( dateList ); | ||
169 | setBaseDates(); | ||
170 | if ( mLastDisplayedDN ) { | ||
133 | KDateNavigator *view = mExtraViews.at( 0 ); | 171 | KDateNavigator *view = mExtraViews.at( 0 ); |
134 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 172 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
135 | view->dayMatrix()->repaint( false ); | 173 | view->dayMatrix()->repaint( false ); |
136 | if ( mExtraViews.count() > 1 ) { | 174 | if ( mLastDisplayedDN > 1 ) { |
137 | KDateNavigator *view = mExtraViews.at( 1 ); | 175 | KDateNavigator *view = mExtraViews.at( 1 ); |
138 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 176 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
139 | view->dayMatrix()->repaint( false ); | 177 | view->dayMatrix()->repaint( false ); |
140 | } | 178 | } |
141 | } | 179 | } |
142 | } | 180 | } |
143 | 181 | ||
144 | void DateNavigatorContainer::setBaseDates() | 182 | void DateNavigatorContainer::setBaseDates() |
145 | { | 183 | { |
146 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 184 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
147 | if ( dateList.isEmpty() ) { | 185 | if ( dateList.isEmpty() ) { |
148 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 186 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
149 | } | 187 | } |
150 | QDate baseDate = dateList.first(); | 188 | QDate baseDate = dateList.first(); |
151 | KDateNavigator *n; | ||
152 | bool doRepaint = false; // skip first repaint | 189 | bool doRepaint = false; // skip first repaint |
153 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 190 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
191 | KDateNavigator *n = mExtraViews.at( i ); | ||
154 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 192 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
155 | n->setBaseDate( baseDate, doRepaint ); | 193 | n->setBaseDate( baseDate, doRepaint ); |
156 | doRepaint = true; | 194 | doRepaint = true; |
157 | } | 195 | } |
158 | } | 196 | } |
159 | 197 | ||
160 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 198 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
161 | { | 199 | { |
162 | #if 0 | 200 | #if 0 |
163 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 201 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
164 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 202 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
165 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 203 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
166 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 204 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
167 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 205 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
168 | #endif | 206 | #endif |
169 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); | 207 | //QSize minSize = mNavigatorView->sizeHintTwoButtons(); |
170 | QSize minSize = mNavigatorView->yourSizeHint(); | 208 | QSize minSize = mNavigatorView->yourSizeHint(); |
171 | 209 | ||
172 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 210 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
173 | 211 | ||
174 | int verticalCount = size().height() / minSize.height(); | 212 | int verticalCount = size().height() / minSize.height(); |
175 | int horizontalCount = size().width() / minSize.width(); | 213 | int horizontalCount = size().width() / minSize.width(); |
176 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 214 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
177 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 215 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
178 | bool fontchange = false; | 216 | bool fontchange = false; |
179 | if ( horizontalCount == 1) | 217 | if ( horizontalCount == 1) |
180 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); | 218 | horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); |
181 | QFont fo; | 219 | QFont fo; |
182 | if ( horizontalCount != mHorizontalCount || | 220 | if ( horizontalCount != mHorizontalCount || |
183 | verticalCount != mVerticalCount ) { | 221 | verticalCount != mVerticalCount ) { |
184 | uint count = horizontalCount * verticalCount; | 222 | uint count = horizontalCount * verticalCount; |
185 | if ( count == 0 ) { | 223 | if ( count == 0 ) { |
186 | bool ok; | 224 | bool ok; |
187 | fo = mNavigatorView->yourFontHint( size() , &ok ); | 225 | fo = mNavigatorView->yourFontHint( size() , &ok ); |
188 | //mNavigatorView->resize( size() ); | 226 | //mNavigatorView->resize( size() ); |
189 | //if ( ! ok ) | 227 | //if ( ! ok ) |
190 | // return; | 228 | // return; |
191 | int butt = 2; | 229 | int butt = 2; |
192 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); | 230 | horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); |
193 | if ( horizontalCount <= 1 ) | 231 | if ( horizontalCount <= 1 ) |
194 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); | 232 | minSize = mNavigatorView->sizeHintTwoButtons( 4 ); |
195 | else | 233 | else |
196 | minSize = mNavigatorView->sizeHintTwoButtons(); | 234 | minSize = mNavigatorView->sizeHintTwoButtons(); |
197 | verticalCount = size().height() / minSize.height(); | 235 | verticalCount = size().height() / minSize.height(); |
198 | horizontalCount = size().width() / minSize.width(); | 236 | horizontalCount = size().width() / minSize.width(); |
199 | if ( horizontalCount == 0 ) | 237 | if ( horizontalCount == 0 ) |
200 | horizontalCount = 1; | 238 | horizontalCount = 1; |
201 | if ( verticalCount == 0 ) | 239 | if ( verticalCount == 0 ) |
202 | verticalCount = 1; | 240 | verticalCount = 1; |
203 | fontchange = true; | 241 | fontchange = true; |
204 | count = horizontalCount * verticalCount; | 242 | count = horizontalCount * verticalCount; |
205 | } else { | 243 | } else { |
206 | if ( mNavigatorView->fontChanged() ) { | 244 | if ( mNavigatorView->fontChanged() ) { |
207 | fontchange = true; | 245 | fontchange = true; |
208 | fo = KOPrefs::instance()->mDateNavigatorFont; | 246 | fo = KOPrefs::instance()->mDateNavigatorFont; |
209 | mNavigatorView->changeFont( fo ); | 247 | mNavigatorView->changeFont( fo ); |
210 | mNavigatorView->unsetFontChanged(); | 248 | mNavigatorView->unsetFontChanged(); |
211 | } | 249 | } |
212 | } | 250 | } |
213 | 251 | ||
252 | mLastDisplayedDN = horizontalCount*verticalCount-1; | ||
253 | bool setBaseD = false; | ||
214 | while ( count > ( mExtraViews.count() + 1 ) ) { | 254 | while ( count > ( mExtraViews.count() + 1 ) ) { |
215 | KDateNavigator *n = new KDateNavigator( this ); | 255 | KDateNavigator *n = new KDateNavigator( this ); |
216 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 256 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
217 | mExtraViews.append( n ); | 257 | mExtraViews.append( n ); |
218 | n->setCalendar( mCalendar ); | 258 | n->setCalendar( mCalendar ); |
219 | setBaseDates(); | 259 | setBaseD = true; |
220 | connectNavigatorView( n ); | 260 | connectNavigatorView( n ); |
221 | n->show(); | 261 | n->show(); |
222 | } | 262 | } |
223 | int iii = 0; | 263 | int iii = 0; |
224 | while ( iii < ( mExtraViews.count() ) ) { | 264 | while ( iii < ( mExtraViews.count() ) ) { |
225 | if ( iii < count-1 ) | 265 | if ( iii < count-1 ) |
226 | mExtraViews.at( iii )->show(); | 266 | mExtraViews.at( iii )->show(); |
227 | else | 267 | else |
228 | mExtraViews.at( iii )->hide(); | 268 | mExtraViews.at( iii )->hide(); |
229 | ++iii; | 269 | ++iii; |
230 | } | 270 | } |
271 | if ( setBaseD ) | ||
272 | setBaseDates(); | ||
231 | if ( fontchange ) { | 273 | if ( fontchange ) { |
232 | //mNavigatorView->changeFont( fo ); | 274 | //mNavigatorView->changeFont( fo ); |
233 | uint i; | 275 | uint i; |
234 | for( i = 0; i < mExtraViews.count(); ++i ) { | 276 | for( i = 0; i < mExtraViews.count(); ++i ) { |
235 | KDateNavigator *view = mExtraViews.at( i ); | 277 | KDateNavigator *view = mExtraViews.at( i ); |
236 | view->changeFont( fo ); | 278 | view->changeFont( fo ); |
237 | } | 279 | } |
238 | } | 280 | } |
239 | mHorizontalCount = horizontalCount; | 281 | mHorizontalCount = horizontalCount; |
240 | mVerticalCount = verticalCount; | 282 | mVerticalCount = verticalCount; |
283 | |||
241 | } | 284 | } |
242 | //qDebug("COUNT %d ", mExtraViews.count()); | 285 | //qDebug("COUNT %d ", mExtraViews.count()); |
243 | int height = size().height() / verticalCount; | 286 | int height = size().height() / verticalCount; |
244 | int width = size().width() / horizontalCount; | 287 | int width = size().width() / horizontalCount; |
245 | 288 | ||
246 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 289 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
247 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 290 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
248 | else bar->showButtons( true, true ); | 291 | else bar->showButtons( true, true ); |
249 | 292 | ||
250 | mNavigatorView->setGeometry(0, | 293 | mNavigatorView->setGeometry(0, |
251 | 0, width, height ); | 294 | 0, width, height ); |
252 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | 295 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
253 | int x = ( i + 1 ) % horizontalCount; | 296 | int x = ( i + 1 ) % horizontalCount; |
254 | int y = ( i + 1 ) / horizontalCount; | 297 | int y = ( i + 1 ) / horizontalCount; |
255 | 298 | ||
256 | KDateNavigator *view = mExtraViews.at( i ); | 299 | KDateNavigator *view = mExtraViews.at( i ); |
257 | bar = view->navigatorBar(); | 300 | bar = view->navigatorBar(); |
258 | if ( y > 0 ) bar->showButtons( false, false ); | 301 | if ( y > 0 ) bar->showButtons( false, false ); |
259 | else { | 302 | else { |
260 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 303 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
261 | else bar->showButtons( false, false ); | 304 | else bar->showButtons( false, false ); |
262 | } | 305 | } |
263 | view->setGeometry( x * width, | 306 | view->setGeometry( x * width, |
264 | y * height, width, height ); | 307 | y * height, width, height ); |
265 | } | 308 | } |
266 | } | 309 | } |
267 | 310 | ||
268 | QSize DateNavigatorContainer::minimumSizeHint() const | 311 | QSize DateNavigatorContainer::minimumSizeHint() const |
269 | { | 312 | { |
270 | return mNavigatorView->minimumSizeHint(); | 313 | return mNavigatorView->minimumSizeHint(); |
271 | } | 314 | } |
272 | 315 | ||
273 | QSize DateNavigatorContainer::sizeHint() const | 316 | QSize DateNavigatorContainer::sizeHint() const |
274 | { | 317 | { |
275 | return mNavigatorView->yourSizeHint(); | 318 | return mNavigatorView->yourSizeHint(); |
276 | } | 319 | } |
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h index affa8e1..f45af20 100644 --- a/korganizer/datenavigatorcontainer.h +++ b/korganizer/datenavigatorcontainer.h | |||
@@ -1,90 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
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 | #ifndef DATENAVIGATORCONTAINER_H | 25 | #ifndef DATENAVIGATORCONTAINER_H |
26 | #define DATENAVIGATORCONTAINER_H | 26 | #define DATENAVIGATORCONTAINER_H |
27 | 27 | ||
28 | class KDateNavigator; | 28 | class KDateNavigator; |
29 | 29 | ||
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | #include <libkcal/calendar.h> | 31 | #include <libkcal/calendar.h> |
32 | using namespace KCal; | 32 | using namespace KCal; |
33 | 33 | ||
34 | class DateNavigatorContainer: public QWidget | 34 | class DateNavigatorContainer: public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); | 38 | DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); |
39 | ~DateNavigatorContainer(); | 39 | ~DateNavigatorContainer(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | Associate date navigator with a calendar. It is used by KODayMatrix. | 42 | Associate date navigator with a calendar. It is used by KODayMatrix. |
43 | */ | 43 | */ |
44 | void setCalendar( Calendar * ); | 44 | void setCalendar( Calendar * ); |
45 | 45 | ||
46 | QSize minimumSizeHint() const; | 46 | QSize minimumSizeHint() const; |
47 | QSize sizeHint() const; | 47 | QSize sizeHint() const; |
48 | KDateNavigator * navigatorView() { return mNavigatorView;} | 48 | KDateNavigator * navigatorView() { return mNavigatorView;} |
49 | 49 | ||
50 | public slots: | 50 | public slots: |
51 | void selectDates( const KCal::DateList & ); | 51 | void selectDates( const KCal::DateList & ); |
52 | void updateView(); | 52 | void updateView(); |
53 | void updateConfig(); | 53 | void updateConfig(); |
54 | void updateDayMatrix(); | 54 | void updateDayMatrix(); |
55 | void updateToday(); | 55 | void updateToday(); |
56 | 56 | ||
57 | signals: | 57 | signals: |
58 | void datesSelected( const KCal::DateList & ); | 58 | void datesSelected( const KCal::DateList & ); |
59 | void incidenceDropped( Incidence *, const QDate & ); | 59 | void incidenceDropped( Incidence *, const QDate & ); |
60 | void incidenceDroppedMove( Incidence *, const QDate & ); | 60 | void incidenceDroppedMove( Incidence *, const QDate & ); |
61 | void weekClicked( const QDate &); | 61 | void weekClicked( const QDate &); |
62 | 62 | ||
63 | void goPrevious(); | 63 | void goPrevious(); |
64 | void goNext(); | 64 | void goNext(); |
65 | 65 | ||
66 | void goNextMonth(); | 66 | void goNextMonth(); |
67 | void goPrevMonth(); | 67 | void goPrevMonth(); |
68 | void goNextYear(); | 68 | void goNextYear(); |
69 | void goPrevYear(); | 69 | void goPrevYear(); |
70 | 70 | ||
71 | void monthSelected( int month ); | 71 | void monthSelected( int month ); |
72 | 72 | ||
73 | protected: | 73 | protected: |
74 | void resizeEvent( QResizeEvent * ); | 74 | void resizeEvent( QResizeEvent * ); |
75 | 75 | ||
76 | void setBaseDates(); | 76 | void setBaseDates(); |
77 | void connectNavigatorView( KDateNavigator *v ); | 77 | void connectNavigatorView( KDateNavigator *v ); |
78 | 78 | ||
79 | private: | 79 | private: |
80 | int mLastDisplayedDN; | ||
81 | QDate mDisplayedEndDate; | ||
80 | KDateNavigator *mNavigatorView; | 82 | KDateNavigator *mNavigatorView; |
81 | 83 | ||
82 | KCal::Calendar *mCalendar; | 84 | KCal::Calendar *mCalendar; |
83 | 85 | ||
84 | QPtrList<KDateNavigator> mExtraViews; | 86 | QPtrList<KDateNavigator> mExtraViews; |
85 | 87 | ||
86 | int mHorizontalCount; | 88 | int mHorizontalCount; |
87 | int mVerticalCount; | 89 | int mVerticalCount; |
88 | }; | 90 | }; |
89 | 91 | ||
90 | #endif | 92 | #endif |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 10bc1be..93bbceb 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -1,163 +1,166 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KDATENAVIGATOR_H | 23 | #ifndef KDATENAVIGATOR_H |
24 | #define KDATENAVIGATOR_H | 24 | #define KDATENAVIGATOR_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | #include "kodaymatrix.h" | 32 | #include "kodaymatrix.h" |
33 | 33 | ||
34 | class QPushButton; | 34 | class QPushButton; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class KCalendarSystem; | 37 | class KCalendarSystem; |
38 | 38 | ||
39 | class NavigatorBar; | 39 | class NavigatorBar; |
40 | 40 | ||
41 | class KDateNavigator: public QFrame | 41 | class KDateNavigator: public QFrame |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); | 45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); |
46 | ~KDateNavigator(); | 46 | ~KDateNavigator(); |
47 | 47 | ||
48 | /** The DateNavigator automatically checks for | 48 | /** The DateNavigator automatically checks for |
49 | * the passage of midnight. If rollover type is | 49 | * the passage of midnight. If rollover type is |
50 | * set to None, no signals are emitted and no | 50 | * set to None, no signals are emitted and no |
51 | * processing is done. With rollover set to | 51 | * processing is done. With rollover set to |
52 | * FollowDay, the day highlighter changes at | 52 | * FollowDay, the day highlighter changes at |
53 | * midnight and dayPassed() is emitted. | 53 | * midnight and dayPassed() is emitted. |
54 | * With FollowMonth, it has the same effect | 54 | * With FollowMonth, it has the same effect |
55 | * as FollowDay but also adjusts the month that is | 55 | * as FollowDay but also adjusts the month that is |
56 | * visible and emits monthPassed() when the month changes. | 56 | * visible and emits monthPassed() when the month changes. |
57 | */ | 57 | */ |
58 | enum RolloverType { None, FollowDay, FollowMonth } ; | 58 | enum RolloverType { None, FollowDay, FollowMonth } ; |
59 | void enableRollover( RolloverType ); | 59 | void enableRollover( RolloverType ); |
60 | 60 | ||
61 | void setShowWeekNums( bool enabled ); | 61 | void setShowWeekNums( bool enabled ); |
62 | void setCalendar( Calendar * ); | 62 | void setCalendar( Calendar * ); |
63 | void setBaseDate( const QDate & , bool doRepaint = true ); | 63 | void setBaseDate( const QDate & , bool doRepaint = true ); |
64 | |||
65 | QDate baseDate() const { return m_MthYr;} | ||
66 | |||
64 | KCal::DateList selectedDates() const { return mSelectedDates; } | 67 | KCal::DateList selectedDates() const { return mSelectedDates; } |
65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } | 68 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } |
66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;} | 69 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;} |
67 | QSize yourSizeHint()const { return mySizeHint; }; | 70 | QSize yourSizeHint()const { return mySizeHint; }; |
68 | QSize yourFullSizeHint() const { return myFullSizeHint;}; | 71 | QSize yourFullSizeHint() const { return myFullSizeHint;}; |
69 | QFont yourFontHint( QSize , bool * b); | 72 | QFont yourFontHint( QSize , bool * b); |
70 | bool fontChanged() {return mFontChanged; } | 73 | bool fontChanged() {return mFontChanged; } |
71 | void unsetFontChanged() { mFontChanged = false; } | 74 | void unsetFontChanged() { mFontChanged = false; } |
72 | KODayMatrix *dayMatrix() { return daymatrix ;} | 75 | KODayMatrix *dayMatrix() { return daymatrix ;} |
73 | QSize sizeHint() const; | 76 | QSize sizeHint() const; |
74 | QSize sizeHintTwoButtons( int butnum = 2 ) const; | 77 | QSize sizeHintTwoButtons( int butnum = 2 ) const; |
75 | void changeFont ( QFont fo ); | 78 | void changeFont ( QFont fo ); |
76 | public slots: | 79 | public slots: |
77 | void selectDates( const KCal::DateList & ); | 80 | void selectDates( const KCal::DateList & ); |
78 | void updateView(); | 81 | void updateView(); |
79 | void updateConfig(); | 82 | void updateConfig(); |
80 | void updateDayMatrix(); | 83 | void updateDayMatrix(); |
81 | 84 | ||
82 | signals: | 85 | signals: |
83 | void datesSelected( const KCal::DateList & ); | 86 | void datesSelected( const KCal::DateList & ); |
84 | void eventDropped( Event * ); | 87 | void eventDropped( Event * ); |
85 | void weekClicked( const QDate &); | 88 | void weekClicked( const QDate &); |
86 | 89 | ||
87 | void goPrevious(); | 90 | void goPrevious(); |
88 | void goNext(); | 91 | void goNext(); |
89 | 92 | ||
90 | void goNextMonth(); | 93 | void goNextMonth(); |
91 | void goPrevMonth(); | 94 | void goPrevMonth(); |
92 | void goNextYear(); | 95 | void goNextYear(); |
93 | void goPrevYear(); | 96 | void goPrevYear(); |
94 | void monthSelected( int ); | 97 | void monthSelected( int ); |
95 | 98 | ||
96 | // Signals emitted at midnight carrying the new date. | 99 | // Signals emitted at midnight carrying the new date. |
97 | void dayPassed( QDate ); | 100 | void dayPassed( QDate ); |
98 | void monthPassed( QDate ); | 101 | void monthPassed( QDate ); |
99 | 102 | ||
100 | protected slots: | 103 | protected slots: |
101 | 104 | ||
102 | /** | 105 | /** |
103 | * Called regularly to see if we need to update the view | 106 | * Called regularly to see if we need to update the view |
104 | * wrt. the today box and the month box. Only important | 107 | * wrt. the today box and the month box. Only important |
105 | * if you leave KOrganizer idle for long periods of time. | 108 | * if you leave KOrganizer idle for long periods of time. |
106 | * | 109 | * |
107 | * Until we have a reliable way of setting QTimers to go | 110 | * Until we have a reliable way of setting QTimers to go |
108 | * off at a particular wall-clock time, we need this, | 111 | * off at a particular wall-clock time, we need this, |
109 | * which calls passedMidnight() at the right moments. | 112 | * which calls passedMidnight() at the right moments. |
110 | */ | 113 | */ |
111 | void possiblyPastMidnight(); | 114 | void possiblyPastMidnight(); |
112 | 115 | ||
113 | /** handles updating the view when midnight has come by due to idle time. | 116 | /** handles updating the view when midnight has come by due to idle time. |
114 | * | 117 | * |
115 | */ | 118 | */ |
116 | void passedMidnight(); | 119 | void passedMidnight(); |
117 | void slotMonthSelected( int m ); | 120 | void slotMonthSelected( int m ); |
118 | protected: | 121 | protected: |
119 | void updateDates(); | 122 | void updateDates(); |
120 | 123 | ||
121 | void wheelEvent (QWheelEvent *); | 124 | void wheelEvent (QWheelEvent *); |
122 | 125 | ||
123 | bool eventFilter (QObject *,QEvent *); | 126 | bool eventFilter (QObject *,QEvent *); |
124 | 127 | ||
125 | private: | 128 | private: |
126 | QSize mySizeHint; | 129 | QSize mySizeHint; |
127 | QSize myFullSizeHint; | 130 | QSize myFullSizeHint; |
128 | bool mFontChanged; | 131 | bool mFontChanged; |
129 | int mMonthSignalOffset; | 132 | int mMonthSignalOffset; |
130 | NavigatorBar *mNavigatorBar; | 133 | NavigatorBar *mNavigatorBar; |
131 | 134 | ||
132 | QFrame *headingSep; | 135 | QFrame *headingSep; |
133 | QFrame *weeknumSep; | 136 | QFrame *weeknumSep; |
134 | QLabel *headings[7]; | 137 | QLabel *headings[7]; |
135 | QLabel *weeknos[7]; | 138 | QLabel *weeknos[7]; |
136 | KODayMatrix *daymatrix; | 139 | KODayMatrix *daymatrix; |
137 | 140 | ||
138 | KCal::DateList mSelectedDates; | 141 | KCal::DateList mSelectedDates; |
139 | QDate m_MthYr; | 142 | QDate m_MthYr; |
140 | int m_fstDayOfWk; | 143 | int m_fstDayOfWk; |
141 | bool m_bShowWeekNums; | 144 | bool m_bShowWeekNums; |
142 | 145 | ||
143 | int dayNum(int row, int col); | 146 | int dayNum(int row, int col); |
144 | int dayToIndex(int dayNum); | 147 | int dayToIndex(int dayNum); |
145 | 148 | ||
146 | Calendar *mCalendar; | 149 | Calendar *mCalendar; |
147 | KCalendarSystem *mCalendarSystem; | 150 | KCalendarSystem *mCalendarSystem; |
148 | 151 | ||
149 | const QString *curHeaders; | 152 | const QString *curHeaders; |
150 | 153 | ||
151 | /** used to update the day view periodically, in particular every | 154 | /** used to update the day view periodically, in particular every |
152 | * midnight to move the "today" rectangle. | 155 | * midnight to move the "today" rectangle. |
153 | */ | 156 | */ |
154 | QTimer *updateTimer; | 157 | QTimer *updateTimer; |
155 | QDate lastDayChecked; | 158 | QDate lastDayChecked; |
156 | RolloverType updateRollover; | 159 | RolloverType updateRollover; |
157 | 160 | ||
158 | // Disabling copy constructor and assignment operator | 161 | // Disabling copy constructor and assignment operator |
159 | KDateNavigator(const KDateNavigator & ); | 162 | KDateNavigator(const KDateNavigator & ); |
160 | KDateNavigator &operator=(const KDateNavigator &); | 163 | KDateNavigator &operator=(const KDateNavigator &); |
161 | }; | 164 | }; |
162 | 165 | ||
163 | #endif | 166 | #endif |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a2e0ae0..3ee1fa7 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,932 +1,942 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name ), mCalendar( 0 ) | 106 | : QFrame( parent, name ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
114 | mPendingUpdateBeforeRepaint = false; | 114 | mPendingUpdateBeforeRepaint = false; |
115 | mouseDown = false; | 115 | mouseDown = false; |
116 | // initialize dynamic arrays | 116 | // initialize dynamic arrays |
117 | bDays.resize ( NUMDAYS ); | 117 | bDays.resize ( NUMDAYS ); |
118 | days = new QDate[NUMDAYS]; | 118 | days = new QDate[NUMDAYS]; |
119 | daylbls = new QString[NUMDAYS]; | 119 | daylbls = new QString[NUMDAYS]; |
120 | events = new int[NUMDAYS]; | 120 | events = new int[NUMDAYS]; |
121 | mToolTip = new DynamicTip(this); | 121 | mToolTip = new DynamicTip(this); |
122 | 122 | ||
123 | // set default values used for drawing the matrix | 123 | // set default values used for drawing the matrix |
124 | mDefaultBackColor = palette().active().base(); | 124 | mDefaultBackColor = palette().active().base(); |
125 | mDefaultTextColor = palette().active().foreground(); | 125 | mDefaultTextColor = palette().active().foreground(); |
126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
128 | mSelectedDaysColor = QColor("white"); | 128 | mSelectedDaysColor = QColor("white"); |
129 | mTodayMarginWidth = 2; | 129 | mTodayMarginWidth = 2; |
130 | mSelEnd = mSelStart = NOSELECTION; | 130 | mSelEnd = mSelStart = NOSELECTION; |
131 | 131 | ||
132 | setAcceptDrops(true); | 132 | setAcceptDrops(true); |
133 | //setFont( QFont("Arial", 10) ); | 133 | //setFont( QFont("Arial", 10) ); |
134 | 134 | ||
135 | mUpdateTimer = new QTimer( this ); | 135 | mUpdateTimer = new QTimer( this ); |
136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
137 | mRepaintTimer = new QTimer( this ); | 137 | mRepaintTimer = new QTimer( this ); |
138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
139 | mDayChanged = false; | 139 | mDayChanged = false; |
140 | updateView(); | 140 | updateView(); |
141 | } | 141 | } |
142 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 142 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
143 | { | 143 | { |
144 | 144 | ||
145 | int tmp = getDayIndexFrom(p.x(), p.y()); | 145 | int tmp = getDayIndexFrom(p.x(), p.y()); |
146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
147 | return QString(); | 147 | return QString(); |
148 | QDate mDate = days[tmp]; | 148 | QDate mDate = days[tmp]; |
149 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 149 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
150 | Event *event; | 150 | Event *event; |
151 | QStringList mToolTip; | 151 | QStringList mToolTip; |
152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
153 | QString mToolTipText; | 153 | QString mToolTipText; |
154 | QString text; | 154 | QString text; |
155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
156 | if (event->isMultiDay()) { | 156 | if (event->isMultiDay()) { |
157 | QString prefix = "<->";multiday = 2; | 157 | QString prefix = "<->";multiday = 2; |
158 | QString time; | 158 | QString time; |
159 | if ( event->doesRecur() ) { | 159 | if ( event->doesRecur() ) { |
160 | if ( event->recursOn( mDate) ) { | 160 | if ( event->recursOn( mDate) ) { |
161 | prefix ="->" ;multiday = 1; | 161 | prefix ="->" ;multiday = 1; |
162 | } | 162 | } |
163 | else { | 163 | else { |
164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
165 | if ( event->recursOn( mDate.addDays( -days)) ) { | 165 | if ( event->recursOn( mDate.addDays( -days)) ) { |
166 | prefix ="<-" ;multiday = 3; | 166 | prefix ="<-" ;multiday = 3; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } else { | 169 | } else { |
170 | if (mDate == event->dtStart().date()) { | 170 | if (mDate == event->dtStart().date()) { |
171 | prefix ="->" ;multiday = 1; | 171 | prefix ="->" ;multiday = 1; |
172 | } else if (mDate == event->dtEnd().date()) { | 172 | } else if (mDate == event->dtEnd().date()) { |
173 | prefix ="<-" ;multiday = 3; | 173 | prefix ="<-" ;multiday = 3; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | if ( !event->doesFloat() ) { | 176 | if ( !event->doesFloat() ) { |
177 | if ( mDate == event->dtStart().date () ) | 177 | if ( mDate == event->dtStart().date () ) |
178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
179 | else if ( mDate == event->dtEnd().date () ) | 179 | else if ( mDate == event->dtEnd().date () ) |
180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
181 | 181 | ||
182 | } | 182 | } |
183 | text = time + event->summary(); | 183 | text = time + event->summary(); |
184 | mToolTipText += prefix + text; | 184 | mToolTipText += prefix + text; |
185 | } else { | 185 | } else { |
186 | if (event->doesFloat()) { | 186 | if (event->doesFloat()) { |
187 | text = event->summary(); | 187 | text = event->summary(); |
188 | mToolTipText += text; | 188 | mToolTipText += text; |
189 | } | 189 | } |
190 | else { | 190 | else { |
191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
192 | text += " " + event->summary(); | 192 | text += " " + event->summary(); |
193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | if ( !event->location().isEmpty() ) | 196 | if ( !event->location().isEmpty() ) |
197 | mToolTipText += " (" + event->location() + ")"; | 197 | mToolTipText += " (" + event->location() + ")"; |
198 | #if QT_VERSION >= 0x030000 | 198 | #if QT_VERSION >= 0x030000 |
199 | mToolTipText.replace( '<' , "<" ); | 199 | mToolTipText.replace( '<' , "<" ); |
200 | mToolTipText.replace( '>' , ">" ); | 200 | mToolTipText.replace( '>' , ">" ); |
201 | #else | 201 | #else |
202 | if ( mToolTipText.find ('<') >= 0 ) { | 202 | if ( mToolTipText.find ('<') >= 0 ) { |
203 | mToolTipText.replace( QRegExp("<") , "<" ); | 203 | mToolTipText.replace( QRegExp("<") , "<" ); |
204 | } | 204 | } |
205 | if ( mToolTipText.find ('>') >= 0 ) { | 205 | if ( mToolTipText.find ('>') >= 0 ) { |
206 | mToolTipText.replace( QRegExp(">") , ">" ); | 206 | mToolTipText.replace( QRegExp(">") , ">" ); |
207 | } | 207 | } |
208 | #endif | 208 | #endif |
209 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 209 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
210 | mToolTip.append( mToolTipText ); | 210 | mToolTip.append( mToolTipText ); |
211 | } | 211 | } |
212 | mToolTip.sort(); | 212 | mToolTip.sort(); |
213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 213 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
214 | } | 214 | } |
215 | void KODayMatrix::setCalendar( Calendar *cal ) | 215 | void KODayMatrix::setCalendar( Calendar *cal ) |
216 | { | 216 | { |
217 | mCalendar = cal; | 217 | mCalendar = cal; |
218 | 218 | ||
219 | setAcceptDrops( mCalendar ); | 219 | setAcceptDrops( mCalendar ); |
220 | 220 | ||
221 | updateEvents(); | 221 | updateEvents(); |
222 | } | 222 | } |
223 | 223 | ||
224 | QColor KODayMatrix::getShadedColor(QColor color) | 224 | QColor KODayMatrix::getShadedColor(QColor color) |
225 | { | 225 | { |
226 | QColor shaded; | 226 | QColor shaded; |
227 | int h=0; | 227 | int h=0; |
228 | int s=0; | 228 | int s=0; |
229 | int v=0; | 229 | int v=0; |
230 | color.hsv(&h,&s,&v); | 230 | color.hsv(&h,&s,&v); |
231 | s = s/4; | 231 | s = s/4; |
232 | v = 192+v/4; | 232 | v = 192+v/4; |
233 | shaded.setHsv(h,s,v); | 233 | shaded.setHsv(h,s,v); |
234 | 234 | ||
235 | return shaded; | 235 | return shaded; |
236 | } | 236 | } |
237 | 237 | ||
238 | KODayMatrix::~KODayMatrix() | 238 | KODayMatrix::~KODayMatrix() |
239 | { | 239 | { |
240 | // delete mKODaymatrixWhatsThis; | 240 | // delete mKODaymatrixWhatsThis; |
241 | delete [] days; | 241 | delete [] days; |
242 | delete [] daylbls; | 242 | delete [] daylbls; |
243 | delete [] events; | 243 | delete [] events; |
244 | delete mToolTip; | 244 | delete mToolTip; |
245 | } | 245 | } |
246 | 246 | ||
247 | /* | 247 | /* |
248 | void KODayMatrix::setStartDate(QDate start) | 248 | void KODayMatrix::setStartDate(QDate start) |
249 | { | 249 | { |
250 | updateView(start); | 250 | updateView(start); |
251 | } | 251 | } |
252 | */ | 252 | */ |
253 | 253 | ||
254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 254 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
255 | { | 255 | { |
256 | 256 | ||
257 | if (mSelStart == NOSELECTION) { | 257 | if (mSelStart == NOSELECTION) { |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | 260 | ||
261 | //cope with selection being out of matrix limits at top (< 0) | 261 | //cope with selection being out of matrix limits at top (< 0) |
262 | int i0 = mSelStart; | 262 | int i0 = mSelStart; |
263 | if (i0 < 0) { | 263 | if (i0 < 0) { |
264 | for (int i = i0; i < 0; i++) { | 264 | for (int i = i0; i < 0; i++) { |
265 | selDays.append(days[0].addDays(i)); | 265 | selDays.append(days[0].addDays(i)); |
266 | } | 266 | } |
267 | i0 = 0; | 267 | i0 = 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 270 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
271 | if (mSelEnd > NUMDAYS-1) { | 271 | if (mSelEnd > NUMDAYS-1) { |
272 | for (int i = i0; i <= NUMDAYS-1; i++) { | 272 | for (int i = i0; i <= NUMDAYS-1; i++) { |
273 | selDays.append(days[i]); | 273 | selDays.append(days[i]); |
274 | } | 274 | } |
275 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 275 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
276 | selDays.append(days[0].addDays(i)); | 276 | selDays.append(days[0].addDays(i)); |
277 | } | 277 | } |
278 | 278 | ||
279 | // apply normal routine to selection being entirely within matrix limits | 279 | // apply normal routine to selection being entirely within matrix limits |
280 | } else { | 280 | } else { |
281 | for (int i = i0; i <= mSelEnd; i++) { | 281 | for (int i = i0; i <= mSelEnd; i++) { |
282 | selDays.append(days[i]); | 282 | selDays.append(days[i]); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 287 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
288 | { | 288 | { |
289 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | ||
289 | mSelStart = startdate.daysTo(start); | 290 | mSelStart = startdate.daysTo(start); |
290 | if ( mSelStart < 0 ) | 291 | if ( mSelStart < 0 ) |
291 | mSelStart = 0; | 292 | mSelStart = 0; |
292 | mSelEnd = startdate.daysTo(end); | 293 | mSelEnd = startdate.daysTo(end); |
293 | //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd ); | 294 | if ( mSelEnd > NUMDAYS-1 ) |
294 | if ( mSelEnd < 0 ) | 295 | mSelEnd = NUMDAYS-1; |
296 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | ||
295 | clearSelection(); | 297 | clearSelection(); |
298 | if ( noSel ) | ||
299 | return false; | ||
300 | } | ||
301 | |||
302 | return true; | ||
296 | } | 303 | } |
297 | void KODayMatrix::clearSelection() | 304 | void KODayMatrix::clearSelection() |
298 | { | 305 | { |
299 | mSelEnd = mSelStart = NOSELECTION; | 306 | mSelEnd = mSelStart = NOSELECTION; |
300 | } | 307 | } |
301 | 308 | ||
302 | 309 | ||
303 | void KODayMatrix::recalculateToday() | 310 | void KODayMatrix::recalculateToday() |
304 | { | 311 | { |
305 | today = -1; | 312 | today = -1; |
306 | for (int i=0; i<NUMDAYS; i++) { | 313 | for (int i=0; i<NUMDAYS; i++) { |
307 | events[i] = 0; | 314 | events[i] = 0; |
308 | days[i] = startdate.addDays(i); | 315 | days[i] = startdate.addDays(i); |
309 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 316 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
310 | 317 | ||
311 | // if today is in the currently displayed month, hilight today | 318 | // if today is in the currently displayed month, hilight today |
312 | if (days[i].year() == QDate::currentDate().year() && | 319 | if (days[i].year() == QDate::currentDate().year() && |
313 | days[i].month() == QDate::currentDate().month() && | 320 | days[i].month() == QDate::currentDate().month() && |
314 | days[i].day() == QDate::currentDate().day()) { | 321 | days[i].day() == QDate::currentDate().day()) { |
315 | today = i; | 322 | today = i; |
316 | } | 323 | } |
317 | } | 324 | } |
318 | // qDebug(QString("Today is visible at %1.").arg(today)); | 325 | // qDebug(QString("Today is visible at %1.").arg(today)); |
319 | } | 326 | } |
320 | 327 | ||
321 | void KODayMatrix::updateView() | 328 | void KODayMatrix::updateView() |
322 | { | 329 | { |
323 | updateView(startdate); | 330 | updateView(startdate); |
324 | } | 331 | } |
325 | void KODayMatrix::repaintViewTimed() | 332 | void KODayMatrix::repaintViewTimed() |
326 | { | 333 | { |
327 | mRepaintTimer->stop(); | 334 | mRepaintTimer->stop(); |
328 | repaint(false); | 335 | repaint(false); |
329 | } | 336 | } |
330 | void KODayMatrix::updateViewTimed() | 337 | void KODayMatrix::updateViewTimed() |
331 | { | 338 | { |
332 | mUpdateTimer->stop(); | 339 | mUpdateTimer->stop(); |
333 | if ( !mCalendar ) { | 340 | if ( !mCalendar ) { |
334 | qDebug("NOT CAL "); | 341 | qDebug("NOT CAL "); |
335 | return; | 342 | return; |
336 | } | 343 | } |
337 | //qDebug("KODayMatrix::updateViewTimed "); | 344 | //qDebug("KODayMatrix::updateViewTimed "); |
338 | for(int i = 0; i < NUMDAYS; i++) { | 345 | for(int i = 0; i < NUMDAYS; i++) { |
339 | // if events are set for the day then remember to draw it bold | 346 | // if events are set for the day then remember to draw it bold |
340 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 347 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
341 | Event *event; | 348 | Event *event; |
342 | int numEvents = eventlist.count(); | 349 | int numEvents = eventlist.count(); |
343 | QString holiStr = ""; | 350 | QString holiStr = ""; |
344 | bDays.clearBit(i); | 351 | bDays.clearBit(i); |
345 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 352 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
346 | ushort recurType = event->recurrence()->doesRecur(); | 353 | ushort recurType = event->recurrence()->doesRecur(); |
347 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 354 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
348 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 355 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
349 | numEvents--; | 356 | numEvents--; |
350 | } | 357 | } |
351 | if ( event->isHoliday()) { | 358 | if ( event->isHoliday()) { |
352 | if ( !holiStr.isEmpty() ) | 359 | if ( !holiStr.isEmpty() ) |
353 | holiStr += "\n"; | 360 | holiStr += "\n"; |
354 | holiStr += event->summary(); | 361 | holiStr += event->summary(); |
355 | if ( !event->location().isEmpty() ) | 362 | if ( !event->location().isEmpty() ) |
356 | holiStr += " (" + event->location() + ")"; | 363 | holiStr += " (" + event->location() + ")"; |
357 | } | 364 | } |
358 | if ( event->isBirthday()) { | 365 | if ( event->isBirthday()) { |
359 | if ( !holiStr.isEmpty() ) | 366 | if ( !holiStr.isEmpty() ) |
360 | holiStr += "\n"; | 367 | holiStr += "\n"; |
361 | holiStr += i18n("Birthday") + ": "+event->summary(); | 368 | holiStr += i18n("Birthday") + ": "+event->summary(); |
362 | if ( !event->location().isEmpty() ) | 369 | if ( !event->location().isEmpty() ) |
363 | holiStr += " (" + event->location() + ")"; | 370 | holiStr += " (" + event->location() + ")"; |
364 | bDays.setBit(i); | 371 | bDays.setBit(i); |
365 | } | 372 | } |
366 | } | 373 | } |
367 | events[i] = numEvents; | 374 | events[i] = numEvents; |
368 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 375 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
369 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 376 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
370 | !holiStr.isEmpty()) { | 377 | !holiStr.isEmpty()) { |
371 | mHolidays[i] = holiStr; | 378 | mHolidays[i] = holiStr; |
372 | } else { | 379 | } else { |
373 | mHolidays[i] = QString::null; | 380 | mHolidays[i] = QString::null; |
374 | } | 381 | } |
375 | } | 382 | } |
376 | if ( ! mPendingUpdateBeforeRepaint ) | 383 | if ( ! mPendingUpdateBeforeRepaint ) |
377 | repaint(false); | 384 | repaint(false); |
378 | } | 385 | } |
379 | void KODayMatrix::updateView(QDate actdate) | 386 | void KODayMatrix::updateView(QDate actdate) |
380 | { | 387 | { |
381 | 388 | ||
382 | if ( ! actdate.isValid() ) { | 389 | if ( ! actdate.isValid() ) { |
383 | //qDebug("date not valid "); | 390 | //qDebug("date not valid "); |
384 | return; | 391 | return; |
385 | } | 392 | } |
386 | mDayChanged = false; | 393 | mDayChanged = false; |
387 | //flag to indicate if the starting day of the matrix has changed by this call | 394 | //flag to indicate if the starting day of the matrix has changed by this call |
388 | //mDayChanged = false; | 395 | //mDayChanged = false; |
389 | // if a new startdate is to be set then apply Cornelius's calculation | 396 | // if a new startdate is to be set then apply Cornelius's calculation |
390 | // of the first day to be shown | 397 | // of the first day to be shown |
391 | if (actdate != startdate) { | 398 | if (actdate != startdate) { |
392 | // reset index of selection according to shift of starting date from startdate to actdate | 399 | // reset index of selection according to shift of starting date from startdate to actdate |
393 | if (mSelStart != NOSELECTION) { | 400 | if (mSelStart != NOSELECTION) { |
394 | int tmp = actdate.daysTo(startdate); | 401 | int tmp = actdate.daysTo(startdate); |
395 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 402 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
396 | // shift selection if new one would be visible at least partly ! | 403 | // shift selection if new one would be visible at least partly ! |
397 | 404 | ||
398 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 405 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
399 | // nested if is required for next X display pushed from a different month - correction required | 406 | // nested if is required for next X display pushed from a different month - correction required |
400 | // otherwise, for month forward and backward, it must be avoided | 407 | // otherwise, for month forward and backward, it must be avoided |
401 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 408 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
402 | mSelStart = mSelStart + tmp; | 409 | mSelStart = mSelStart + tmp; |
403 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 410 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
404 | mSelEnd = mSelEnd + tmp; | 411 | mSelEnd = mSelEnd + tmp; |
405 | } | 412 | } |
406 | } | 413 | } |
407 | startdate = actdate; | 414 | startdate = actdate; |
408 | mDayChanged = true; | 415 | mDayChanged = true; |
409 | recalculateToday(); | 416 | recalculateToday(); |
410 | } | 417 | } |
411 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 418 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
412 | if ( !isVisible() ) { | 419 | if ( !isVisible() ) { |
413 | mPendingUpdateBeforeRepaint = true; | 420 | mPendingUpdateBeforeRepaint = true; |
414 | } else { | 421 | } else { |
415 | #ifdef DESKTOP_VERSION | 422 | #ifdef DESKTOP_VERSION |
416 | //mRepaintTimer->start( 100 ); | 423 | //mRepaintTimer->start( 100 ); |
417 | //updateViewTimed(); | 424 | //updateViewTimed(); |
418 | mUpdateTimer->start( 20 ); | 425 | mUpdateTimer->start( 20 ); |
419 | #else | 426 | #else |
420 | mRepaintTimer->start( 350 ); | 427 | mRepaintTimer->start( 350 ); |
421 | mUpdateTimer->start( 1200 ); | 428 | mUpdateTimer->start( 1200 ); |
422 | #endif | 429 | #endif |
423 | } | 430 | } |
424 | } | 431 | } |
425 | void KODayMatrix::updateEvents() | 432 | void KODayMatrix::updateEvents() |
426 | { | 433 | { |
427 | if ( !mCalendar ) return; | 434 | if ( !mCalendar ) return; |
428 | 435 | ||
429 | for( int i = 0; i < NUMDAYS; i++ ) { | 436 | for( int i = 0; i < NUMDAYS; i++ ) { |
430 | // if events are set for the day then remember to draw it bold | 437 | // if events are set for the day then remember to draw it bold |
431 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 438 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
432 | int numEvents = eventlist.count(); | 439 | int numEvents = eventlist.count(); |
433 | Event *event; | 440 | Event *event; |
434 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 441 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
435 | ushort recurType = event->doesRecur(); | 442 | ushort recurType = event->doesRecur(); |
436 | 443 | ||
437 | if ( ( recurType == Recurrence::rDaily && | 444 | if ( ( recurType == Recurrence::rDaily && |
438 | !KOPrefs::instance()->mDailyRecur ) || | 445 | !KOPrefs::instance()->mDailyRecur ) || |
439 | ( recurType == Recurrence::rWeekly && | 446 | ( recurType == Recurrence::rWeekly && |
440 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 447 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
441 | numEvents--; | 448 | numEvents--; |
442 | } | 449 | } |
443 | } | 450 | } |
444 | events[ i ] = numEvents; | 451 | events[ i ] = numEvents; |
445 | } | 452 | } |
446 | } | 453 | } |
447 | 454 | ||
448 | const QDate& KODayMatrix::getDate(int offset) | 455 | const QDate& KODayMatrix::getDate(int offset) |
449 | { | 456 | { |
450 | if (offset < 0 || offset > NUMDAYS-1) { | 457 | if (offset < 0 || offset > NUMDAYS-1) { |
451 | qDebug("Wrong offset2 %d", offset); | 458 | qDebug("Wrong offset2 %d", offset); |
452 | return days[0]; | 459 | return days[0]; |
453 | } | 460 | } |
454 | return days[offset]; | 461 | return days[offset]; |
455 | } | 462 | } |
456 | 463 | ||
457 | QString KODayMatrix::getHolidayLabel(int offset) | 464 | QString KODayMatrix::getHolidayLabel(int offset) |
458 | { | 465 | { |
459 | if (offset < 0 || offset > NUMDAYS-1) { | 466 | if (offset < 0 || offset > NUMDAYS-1) { |
460 | qDebug("Wrong offset1 %d", offset); | 467 | qDebug("Wrong offset1 %d", offset); |
461 | return QString(); | 468 | return QString(); |
462 | } | 469 | } |
463 | return mHolidays[offset]; | 470 | return mHolidays[offset]; |
464 | } | 471 | } |
465 | 472 | ||
466 | int KODayMatrix::getDayIndexFrom(int x, int y) | 473 | int KODayMatrix::getDayIndexFrom(int x, int y) |
467 | { | 474 | { |
468 | int colModulo = (width()-2) % 7; | 475 | int colModulo = (width()-2) % 7; |
469 | int rowModulo = (height()-2) % 6; | 476 | int rowModulo = (height()-2) % 6; |
470 | #if 0 | 477 | #if 0 |
471 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 478 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
472 | 6 - x/daysize.width() : x/daysize.width()); | 479 | 6 - x/daysize.width() : x/daysize.width()); |
473 | #endif | 480 | #endif |
474 | int xVal = (x-colModulo/2-2)/daysize.width(); | 481 | int xVal = (x-colModulo/2-2)/daysize.width(); |
475 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 482 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
476 | 483 | ||
477 | 484 | ||
478 | return 7*(yVal) + xVal; | 485 | return 7*(yVal) + xVal; |
479 | 486 | ||
480 | } | 487 | } |
481 | 488 | ||
482 | // ---------------------------------------------------------------------------- | 489 | // ---------------------------------------------------------------------------- |
483 | // M O U S E E V E N T H A N D L I N G | 490 | // M O U S E E V E N T H A N D L I N G |
484 | // ---------------------------------------------------------------------------- | 491 | // ---------------------------------------------------------------------------- |
485 | 492 | ||
486 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 493 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
487 | { | 494 | { |
488 | 495 | ||
489 | if ( e->button() == LeftButton ) | 496 | if ( e->button() == LeftButton ) |
490 | mouseDown = true; | 497 | mouseDown = true; |
491 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 498 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
492 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 499 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
493 | mSelInit = mSelStart; | 500 | mSelInit = mSelStart; |
494 | mSelEnd = mSelStart; | 501 | mSelEnd = mSelStart; |
495 | repaint(false); | 502 | repaint(false); |
496 | } | 503 | } |
497 | 504 | ||
498 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 505 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
499 | { | 506 | { |
500 | if ( e->button() == LeftButton ) | 507 | if ( e->button() == LeftButton ) |
501 | if ( ! mouseDown ) { | 508 | if ( ! mouseDown ) { |
502 | return; | 509 | return; |
503 | } | 510 | } |
504 | else | 511 | else |
505 | mouseDown = false; | 512 | mouseDown = false; |
506 | int tmp = getDayIndexFrom(e->x(), e->y()); | 513 | int tmp = getDayIndexFrom(e->x(), e->y()); |
507 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 514 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
508 | 515 | ||
509 | if (mSelInit > tmp) { | 516 | if (mSelInit > tmp) { |
510 | mSelEnd = mSelInit; | 517 | mSelEnd = mSelInit; |
511 | if (tmp != mSelStart) { | 518 | if (tmp != mSelStart) { |
512 | mSelStart = tmp; | 519 | mSelStart = tmp; |
513 | repaint(false); | 520 | repaint(false); |
514 | } | 521 | } |
515 | } else { | 522 | } else { |
516 | mSelStart = mSelInit; | 523 | mSelStart = mSelInit; |
517 | 524 | ||
518 | //repaint only if selection has changed | 525 | //repaint only if selection has changed |
519 | if (tmp != mSelEnd) { | 526 | if (tmp != mSelEnd) { |
520 | mSelEnd = tmp; | 527 | mSelEnd = tmp; |
521 | repaint(false); | 528 | repaint(false); |
522 | } | 529 | } |
523 | } | 530 | } |
524 | 531 | ||
525 | DateList daylist; | 532 | DateList daylist; |
526 | if ( mSelStart < 0 ) | 533 | if ( mSelStart < 0 ) |
527 | mSelStart = 0; | 534 | mSelStart = 0; |
528 | for (int i = mSelStart; i <= mSelEnd; i++) { | 535 | for (int i = mSelStart; i <= mSelEnd; i++) { |
529 | daylist.append(days[i]); | 536 | daylist.append(days[i]); |
530 | } | 537 | } |
531 | emit selected((const DateList)daylist); | 538 | emit selected((const DateList)daylist); |
532 | 539 | ||
533 | } | 540 | } |
534 | 541 | ||
535 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 542 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
536 | { | 543 | { |
537 | if ( ! mouseDown ) { | 544 | if ( ! mouseDown ) { |
538 | return; | 545 | return; |
539 | } | 546 | } |
540 | int tmp = getDayIndexFrom(e->x(), e->y()); | 547 | int tmp = getDayIndexFrom(e->x(), e->y()); |
541 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 548 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
542 | 549 | ||
543 | if (mSelInit > tmp) { | 550 | if (mSelInit > tmp) { |
544 | mSelEnd = mSelInit; | 551 | mSelEnd = mSelInit; |
545 | if (tmp != mSelStart) { | 552 | if (tmp != mSelStart) { |
546 | mSelStart = tmp; | 553 | mSelStart = tmp; |
547 | repaint(false); | 554 | repaint(false); |
548 | } | 555 | } |
549 | } else { | 556 | } else { |
550 | mSelStart = mSelInit; | 557 | mSelStart = mSelInit; |
551 | 558 | ||
552 | //repaint only if selection has changed | 559 | //repaint only if selection has changed |
553 | if (tmp != mSelEnd) { | 560 | if (tmp != mSelEnd) { |
554 | mSelEnd = tmp; | 561 | mSelEnd = tmp; |
555 | repaint(false); | 562 | repaint(false); |
556 | } | 563 | } |
557 | } | 564 | } |
558 | } | 565 | } |
559 | 566 | ||
560 | // ---------------------------------------------------------------------------- | 567 | // ---------------------------------------------------------------------------- |
561 | // D R A G ' N D R O P H A N D L I N G | 568 | // D R A G ' N D R O P H A N D L I N G |
562 | // ---------------------------------------------------------------------------- | 569 | // ---------------------------------------------------------------------------- |
563 | 570 | ||
564 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 571 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
565 | { | 572 | { |
566 | #ifndef KORG_NODND | 573 | #ifndef KORG_NODND |
567 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 574 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
568 | e->ignore(); | 575 | e->ignore(); |
569 | return; | 576 | return; |
570 | } | 577 | } |
571 | 578 | ||
572 | // some visual feedback | 579 | // some visual feedback |
573 | // oldPalette = palette(); | 580 | // oldPalette = palette(); |
574 | // setPalette(my_HilitePalette); | 581 | // setPalette(my_HilitePalette); |
575 | // update(); | 582 | // update(); |
576 | #endif | 583 | #endif |
577 | } | 584 | } |
578 | 585 | ||
579 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 586 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
580 | { | 587 | { |
581 | #ifndef KORG_NODND | 588 | #ifndef KORG_NODND |
582 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 589 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
583 | e->ignore(); | 590 | e->ignore(); |
584 | return; | 591 | return; |
585 | } | 592 | } |
586 | 593 | ||
587 | e->accept(); | 594 | e->accept(); |
588 | #endif | 595 | #endif |
589 | } | 596 | } |
590 | 597 | ||
591 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 598 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
592 | { | 599 | { |
593 | #ifndef KORG_NODND | 600 | #ifndef KORG_NODND |
594 | // setPalette(oldPalette); | 601 | // setPalette(oldPalette); |
595 | // update(); | 602 | // update(); |
596 | #endif | 603 | #endif |
597 | } | 604 | } |
598 | 605 | ||
599 | void KODayMatrix::dropEvent(QDropEvent *e) | 606 | void KODayMatrix::dropEvent(QDropEvent *e) |
600 | { | 607 | { |
601 | #ifndef KORG_NODND | 608 | #ifndef KORG_NODND |
602 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 609 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
603 | 610 | ||
604 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 611 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
605 | e->ignore(); | 612 | e->ignore(); |
606 | return; | 613 | return; |
607 | } | 614 | } |
608 | 615 | ||
609 | DndFactory factory( mCalendar ); | 616 | DndFactory factory( mCalendar ); |
610 | Event *event = factory.createDrop(e); | 617 | Event *event = factory.createDrop(e); |
611 | 618 | ||
612 | if (event) { | 619 | if (event) { |
613 | e->acceptAction(); | 620 | e->acceptAction(); |
614 | 621 | ||
615 | Event *existingEvent = mCalendar->event(event->uid()); | 622 | Event *existingEvent = mCalendar->event(event->uid()); |
616 | 623 | ||
617 | if(existingEvent) { | 624 | if(existingEvent) { |
618 | // uniquify event | 625 | // uniquify event |
619 | event->recreate(); | 626 | event->recreate(); |
620 | /* | 627 | /* |
621 | KMessageBox::sorry(this, | 628 | KMessageBox::sorry(this, |
622 | i18n("Event already exists in this calendar."), | 629 | i18n("Event already exists in this calendar."), |
623 | i18n("Drop Event")); | 630 | i18n("Drop Event")); |
624 | delete event; | 631 | delete event; |
625 | return; | 632 | return; |
626 | */ | 633 | */ |
627 | } | 634 | } |
628 | // kdDebug() << "Drop new Event" << endl; | 635 | // kdDebug() << "Drop new Event" << endl; |
629 | // Adjust date | 636 | // Adjust date |
630 | QDateTime start = event->dtStart(); | 637 | QDateTime start = event->dtStart(); |
631 | QDateTime end = event->dtEnd(); | 638 | QDateTime end = event->dtEnd(); |
632 | int duration = start.daysTo(end); | 639 | int duration = start.daysTo(end); |
633 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 640 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
634 | 641 | ||
635 | start.setDate(days[idx]); | 642 | start.setDate(days[idx]); |
636 | end.setDate(days[idx].addDays(duration)); | 643 | end.setDate(days[idx].addDays(duration)); |
637 | 644 | ||
638 | event->setDtStart(start); | 645 | event->setDtStart(start); |
639 | event->setDtEnd(end); | 646 | event->setDtEnd(end); |
640 | mCalendar->addEvent(event); | 647 | mCalendar->addEvent(event); |
641 | 648 | ||
642 | emit eventDropped(event); | 649 | emit eventDropped(event); |
643 | } else { | 650 | } else { |
644 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 651 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
645 | e->ignore(); | 652 | e->ignore(); |
646 | } | 653 | } |
647 | #endif | 654 | #endif |
648 | } | 655 | } |
649 | 656 | ||
650 | // ---------------------------------------------------------------------------- | 657 | // ---------------------------------------------------------------------------- |
651 | // P A I N T E V E N T H A N D L I N G | 658 | // P A I N T E V E N T H A N D L I N G |
652 | // ---------------------------------------------------------------------------- | 659 | // ---------------------------------------------------------------------------- |
653 | 660 | ||
654 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 661 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
655 | { | 662 | { |
656 | QRect sz = frameRect(); | 663 | QRect sz = frameRect(); |
657 | if ( sz.width() <= 0 || sz.height() <= 0 ) | 664 | if ( sz.width() <= 0 || sz.height() <= 0 ) |
658 | return; | 665 | return; |
659 | if ( mPendingUpdateBeforeRepaint ) { | 666 | if ( mPendingUpdateBeforeRepaint ) { |
660 | updateViewTimed(); | 667 | updateViewTimed(); |
661 | mPendingUpdateBeforeRepaint = false; | 668 | mPendingUpdateBeforeRepaint = false; |
662 | } | 669 | } |
663 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { | 670 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { |
664 | myPix.resize(sz.size() ); | 671 | myPix.resize(sz.size() ); |
665 | } | 672 | } |
666 | QPainter p(&myPix); | 673 | QPainter p(&myPix); |
667 | p.setFont(font()); | 674 | p.setFont(font()); |
668 | 675 | ||
669 | 676 | ||
670 | int dheight = daysize.height(); | 677 | int dheight = daysize.height(); |
671 | int dwidth = daysize.width(); | 678 | int dwidth = daysize.width(); |
672 | int row,col; | 679 | int row,col; |
673 | int selw, selh; | 680 | int selw, selh; |
674 | int xyOff = frameWidth(); | 681 | int xyOff = frameWidth(); |
675 | int colModulo = sz.width() % 7; | 682 | int colModulo = sz.width() % 7; |
676 | int rowModulo = sz.height() % 6; | 683 | int rowModulo = sz.height() % 6; |
677 | //qDebug("col %d row %d ",colModulo,rowModulo ); | 684 | //qDebug("col %d row %d ",colModulo,rowModulo ); |
678 | 685 | ||
679 | bool isRTL = KOGlobals::self()->reverseLayout(); | 686 | bool isRTL = KOGlobals::self()->reverseLayout(); |
680 | 687 | ||
681 | // draw background and topleft frame | 688 | // draw background and topleft frame |
682 | p.fillRect(pevent->rect(), mDefaultBackColor); | 689 | p.fillRect(pevent->rect(), mDefaultBackColor); |
683 | p.setPen(mDefaultTextColor); | 690 | p.setPen(mDefaultTextColor); |
684 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 691 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
685 | int mSelStartT = mSelStart; | 692 | int mSelStartT = mSelStart; |
686 | int mSelEndT = mSelEnd; | 693 | int mSelEndT = mSelEnd; |
687 | if ( mSelEndT >= NUMDAYS ) | 694 | if ( mSelEndT >= NUMDAYS ) |
688 | mSelEndT = NUMDAYS-1; | 695 | mSelEndT = NUMDAYS-1; |
689 | // draw selected days with highlighted background color | 696 | // draw selected days with highlighted background color |
690 | if (mSelStart != NOSELECTION) { | 697 | if (mSelStart != NOSELECTION) { |
691 | bool skip = false; | 698 | bool skip = false; |
692 | if ( ! mouseDown ) { | 699 | if ( ! mouseDown ) { |
693 | int mo = days[20].month(); | 700 | int mo = days[20].month(); |
694 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 701 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
695 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 702 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
696 | int startMo = days[mSelStartT].month(); | 703 | int startMo = days[mSelStartT].month(); |
697 | int endMo = days[mSelEndT].month(); | 704 | int endMo = days[mSelEndT].month(); |
698 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) | 705 | if ( startMo == 12 && mo == 1 && endMo <= 2 ) |
699 | startMo = 1; | 706 | startMo = 1; |
700 | if ( endMo == 1 && mo == 12 ) | 707 | if ( endMo == 1 && mo == 12 ) |
701 | endMo = 12; | 708 | endMo = 12; |
709 | if ( mo == 12 && startMo == 1 ) | ||
710 | startMo = 13; | ||
702 | if ( (startMo > mo || endMo < mo) ) { | 711 | if ( (startMo > mo || endMo < mo) ) { |
703 | skip = true; | 712 | skip = true; |
704 | } else { | 713 | } else { |
705 | if ( days[mSelStartT].month() != mo ) { | 714 | if ( days[mSelStartT].month() != mo ) { |
706 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 715 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
707 | mSelStartT += add +1; | 716 | mSelStartT += add +1; |
708 | } | 717 | } |
709 | if ( days[mSelEndT].month() != mo ) { | 718 | if ( days[mSelEndT].month() != mo ) { |
710 | int sub = days[mSelEndT].day(); | 719 | int sub = days[mSelEndT].day(); |
711 | mSelEndT -= sub ; | 720 | mSelEndT -= sub ; |
712 | } | 721 | } |
713 | } | 722 | } |
714 | } | 723 | } |
724 | //qDebug("SKIP %d ", skip); | ||
715 | if ( ! skip ) { | 725 | if ( ! skip ) { |
716 | row = mSelStartT/7; | 726 | row = mSelStartT/7; |
717 | col = mSelStartT -row*7; | 727 | col = mSelStartT -row*7; |
718 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 728 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
719 | int addCol = 0; | 729 | int addCol = 0; |
720 | int addRow = 0; | 730 | int addRow = 0; |
721 | int addRow2 = 0; | 731 | int addRow2 = 0; |
722 | int addCol2 = 0; | 732 | int addCol2 = 0; |
723 | if (row == mSelEndT/7) { | 733 | if (row == mSelEndT/7) { |
724 | if ( rowModulo ) { | 734 | if ( rowModulo ) { |
725 | if ( row >= 6 - rowModulo ) | 735 | if ( row >= 6 - rowModulo ) |
726 | addRow = row - 5 + rowModulo; | 736 | addRow = row - 5 + rowModulo; |
727 | } | 737 | } |
728 | if ( colModulo ) { | 738 | if ( colModulo ) { |
729 | int colt1 = mSelEndT%7; | 739 | int colt1 = mSelEndT%7; |
730 | //qDebug("colt1 %d ", colt1 ); | 740 | //qDebug("colt1 %d ", colt1 ); |
731 | if ( colt1 >= 7 - colModulo ) | 741 | if ( colt1 >= 7 - colModulo ) |
732 | addCol = colt1 - 7 + colModulo+1; | 742 | addCol = colt1 - 7 + colModulo+1; |
733 | int colt = mSelStartT%7; | 743 | int colt = mSelStartT%7; |
734 | if ( colt >= 7 - colModulo ) | 744 | if ( colt >= 7 - colModulo ) |
735 | addCol2 = colt - 7 + colModulo; | 745 | addCol2 = colt - 7 + colModulo; |
736 | addCol -= addCol2; | 746 | addCol -= addCol2; |
737 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); | 747 | //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); |
738 | } | 748 | } |
739 | // Single row selection | 749 | // Single row selection |
740 | if ( row == 0) | 750 | if ( row == 0) |
741 | addRow = 1; | 751 | addRow = 1; |
742 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, | 752 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, |
743 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | 753 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); |
744 | } else { | 754 | } else { |
745 | // draw first row to the right | 755 | // draw first row to the right |
746 | if ( colModulo ) { | 756 | if ( colModulo ) { |
747 | if ( col >= 7 - colModulo ) | 757 | if ( col >= 7 - colModulo ) |
748 | addCol2 = col - 7 + colModulo; | 758 | addCol2 = col - 7 + colModulo; |
749 | } | 759 | } |
750 | if ( rowModulo ) { | 760 | if ( rowModulo ) { |
751 | if ( row >= 6 - rowModulo ) | 761 | if ( row >= 6 - rowModulo ) |
752 | addRow = row - 5 + rowModulo; | 762 | addRow = row - 5 + rowModulo; |
753 | } | 763 | } |
754 | if ( row == 0) | 764 | if ( row == 0) |
755 | addRow = 1; | 765 | addRow = 1; |
756 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, | 766 | p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, |
757 | dheight+1, selcol); | 767 | dheight+1, selcol); |
758 | // draw full block till last line | 768 | // draw full block till last line |
759 | selh = mSelEndT/7-row; | 769 | selh = mSelEndT/7-row; |
760 | addRow = 0; | 770 | addRow = 0; |
761 | if ( rowModulo ) { | 771 | if ( rowModulo ) { |
762 | if ( mSelEndT/7 >= 6 - rowModulo ) | 772 | if ( mSelEndT/7 >= 6 - rowModulo ) |
763 | addRow = mSelEndT/7 - 5 + rowModulo; | 773 | addRow = mSelEndT/7 - 5 + rowModulo; |
764 | } | 774 | } |
765 | if (selh > 1) { | 775 | if (selh > 1) { |
766 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); | 776 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); |
767 | } | 777 | } |
768 | // draw last block from left to mSelEndT | 778 | // draw last block from left to mSelEndT |
769 | selw = mSelEndT-7*(mSelEndT/7)+1; | 779 | selw = mSelEndT-7*(mSelEndT/7)+1; |
770 | //qDebug("esl %d ",selw ); | 780 | //qDebug("esl %d ",selw ); |
771 | int add = 0; | 781 | int add = 0; |
772 | if ( colModulo ) { | 782 | if ( colModulo ) { |
773 | add = 7 - colModulo; | 783 | add = 7 - colModulo; |
774 | if ( selw > add ) | 784 | if ( selw > add ) |
775 | add = selw - add; | 785 | add = selw - add; |
776 | else | 786 | else |
777 | add = 0; | 787 | add = 0; |
778 | } | 788 | } |
779 | //qDebug("add %d ", add); | 789 | //qDebug("add %d ", add); |
780 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, | 790 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, |
781 | selw*dwidth+add, dheight+1, selcol); | 791 | selw*dwidth+add, dheight+1, selcol); |
782 | } | 792 | } |
783 | } | 793 | } |
784 | } | 794 | } |
785 | 795 | ||
786 | // iterate over all days in the matrix and draw the day label in appropriate colors | 796 | // iterate over all days in the matrix and draw the day label in appropriate colors |
787 | QColor actcol = mDefaultTextColorShaded; | 797 | QColor actcol = mDefaultTextColorShaded; |
788 | p.setPen(actcol); | 798 | p.setPen(actcol); |
789 | QPen tmppen; | 799 | QPen tmppen; |
790 | for(int i = 0; i < NUMDAYS; i++) { | 800 | for(int i = 0; i < NUMDAYS; i++) { |
791 | row = i/7; | 801 | row = i/7; |
792 | col = isRTL ? 6-(i-row*7) : i-row*7; | 802 | col = isRTL ? 6-(i-row*7) : i-row*7; |
793 | 803 | ||
794 | // if it is the first day of a month switch color from normal to shaded and vice versa | 804 | // if it is the first day of a month switch color from normal to shaded and vice versa |
795 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 805 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
796 | if (actcol == mDefaultTextColorShaded) { | 806 | if (actcol == mDefaultTextColorShaded) { |
797 | actcol = mDefaultTextColor; | 807 | actcol = mDefaultTextColor; |
798 | } else { | 808 | } else { |
799 | actcol = mDefaultTextColorShaded; | 809 | actcol = mDefaultTextColorShaded; |
800 | } | 810 | } |
801 | p.setPen(actcol); | 811 | p.setPen(actcol); |
802 | } | 812 | } |
803 | if (actcol == mDefaultTextColorShaded) { | 813 | if (actcol == mDefaultTextColorShaded) { |
804 | if ( ! mouseDown ) { | 814 | if ( ! mouseDown ) { |
805 | continue; | 815 | continue; |
806 | } | 816 | } |
807 | } | 817 | } |
808 | //Reset pen color after selected days block | 818 | //Reset pen color after selected days block |
809 | if (i == mSelEndT+1) { | 819 | if (i == mSelEndT+1) { |
810 | p.setPen(actcol); | 820 | p.setPen(actcol); |
811 | } | 821 | } |
812 | 822 | ||
813 | // if today then draw rectangle around day | 823 | // if today then draw rectangle around day |
814 | if (today == i) { | 824 | if (today == i) { |
815 | tmppen = p.pen(); | 825 | tmppen = p.pen(); |
816 | QPen mTodayPen(p.pen()); | 826 | QPen mTodayPen(p.pen()); |
817 | if ( daysize.width() < 20 ) | 827 | if ( daysize.width() < 20 ) |
818 | mTodayPen.setWidth(1); | 828 | mTodayPen.setWidth(1); |
819 | else | 829 | else |
820 | mTodayPen.setWidth(mTodayMarginWidth); | 830 | mTodayPen.setWidth(mTodayMarginWidth); |
821 | //draw red rectangle for holidays | 831 | //draw red rectangle for holidays |
822 | if (!mHolidays[i].isNull()) { | 832 | if (!mHolidays[i].isNull()) { |
823 | if (actcol == mDefaultTextColor) { | 833 | if (actcol == mDefaultTextColor) { |
824 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 834 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
825 | } else { | 835 | } else { |
826 | mTodayPen.setColor(mHolidayColorShaded); | 836 | mTodayPen.setColor(mHolidayColorShaded); |
827 | } | 837 | } |
828 | } | 838 | } |
829 | //draw gray rectangle for today if in selection | 839 | //draw gray rectangle for today if in selection |
830 | if (i >= mSelStartT && i <= mSelEndT) { | 840 | if (i >= mSelStartT && i <= mSelEndT) { |
831 | QColor grey("grey"); | 841 | QColor grey("grey"); |
832 | mTodayPen.setColor(grey); | 842 | mTodayPen.setColor(grey); |
833 | } | 843 | } |
834 | p.setPen(mTodayPen); | 844 | p.setPen(mTodayPen); |
835 | 845 | ||
836 | 846 | ||
837 | int addCol = 0; | 847 | int addCol = 0; |
838 | int addRow = 0; | 848 | int addRow = 0; |
839 | if (rowModulo) { | 849 | if (rowModulo) { |
840 | if ( row >= 6 - rowModulo ) | 850 | if ( row >= 6 - rowModulo ) |
841 | addRow = row - 5 + rowModulo; | 851 | addRow = row - 5 + rowModulo; |
842 | } | 852 | } |
843 | if ( colModulo ) { | 853 | if ( colModulo ) { |
844 | if ( col >= 7 - colModulo ) | 854 | if ( col >= 7 - colModulo ) |
845 | addCol = col - 6 + colModulo-1; | 855 | addCol = col - 6 + colModulo-1; |
846 | } | 856 | } |
847 | 857 | ||
848 | addCol += 1; | 858 | addCol += 1; |
849 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); | 859 | p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); |
850 | p.setPen(tmppen); | 860 | p.setPen(tmppen); |
851 | } | 861 | } |
852 | 862 | ||
853 | // if any events are on that day then draw it using a bold font | 863 | // if any events are on that day then draw it using a bold font |
854 | if (events[i] > 0) { | 864 | if (events[i] > 0) { |
855 | QFont myFont = font(); | 865 | QFont myFont = font(); |
856 | myFont.setBold(true); | 866 | myFont.setBold(true); |
857 | p.setFont(myFont); | 867 | p.setFont(myFont); |
858 | } | 868 | } |
859 | 869 | ||
860 | // if it is a holiday then use the default holiday color | 870 | // if it is a holiday then use the default holiday color |
861 | if (!mHolidays[i].isNull()) { | 871 | if (!mHolidays[i].isNull()) { |
862 | if ( bDays.testBit(i) ) { | 872 | if ( bDays.testBit(i) ) { |
863 | p.setPen(Qt::green); | 873 | p.setPen(Qt::green); |
864 | } else { | 874 | } else { |
865 | if (actcol == mDefaultTextColor) { | 875 | if (actcol == mDefaultTextColor) { |
866 | p.setPen(KOPrefs::instance()->mHolidayColor); | 876 | p.setPen(KOPrefs::instance()->mHolidayColor); |
867 | } else { | 877 | } else { |
868 | p.setPen(mHolidayColorShaded); | 878 | p.setPen(mHolidayColorShaded); |
869 | } | 879 | } |
870 | } | 880 | } |
871 | } | 881 | } |
872 | 882 | ||
873 | // draw selected days with special color | 883 | // draw selected days with special color |
874 | // DO NOT specially highlight holidays in selection ! | 884 | // DO NOT specially highlight holidays in selection ! |
875 | if (i >= mSelStartT && i <= mSelEndT) { | 885 | if (i >= mSelStartT && i <= mSelEndT) { |
876 | ;//p.setPen(mSelectedDaysColor); | 886 | ;//p.setPen(mSelectedDaysColor); |
877 | } | 887 | } |
878 | 888 | ||
879 | int addCol = 0; | 889 | int addCol = 0; |
880 | int addRow = 0; | 890 | int addRow = 0; |
881 | if ( colModulo ) { | 891 | if ( colModulo ) { |
882 | if ( col >= 7 - colModulo ) | 892 | if ( col >= 7 - colModulo ) |
883 | addCol = col - 7 + colModulo; | 893 | addCol = col - 7 + colModulo; |
884 | } | 894 | } |
885 | if ( rowModulo ) { | 895 | if ( rowModulo ) { |
886 | if ( row >= 6 - rowModulo ) | 896 | if ( row >= 6 - rowModulo ) |
887 | addRow = row - 5 + rowModulo; | 897 | addRow = row - 5 + rowModulo; |
888 | } | 898 | } |
889 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | 899 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); |
890 | ++addCol;//++addCol; | 900 | ++addCol;//++addCol; |
891 | if ( row == 0) | 901 | if ( row == 0) |
892 | addRow = 1; | 902 | addRow = 1; |
893 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | 903 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, |
894 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 904 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
895 | 905 | ||
896 | // reset color to actual color | 906 | // reset color to actual color |
897 | if (!mHolidays[i].isNull()) { | 907 | if (!mHolidays[i].isNull()) { |
898 | p.setPen(actcol); | 908 | p.setPen(actcol); |
899 | } | 909 | } |
900 | // reset bold font to plain font | 910 | // reset bold font to plain font |
901 | if (events[i] > 0) { | 911 | if (events[i] > 0) { |
902 | QFont myFont = font(); | 912 | QFont myFont = font(); |
903 | myFont.setBold(false); | 913 | myFont.setBold(false); |
904 | p.setFont(myFont); | 914 | p.setFont(myFont); |
905 | } | 915 | } |
906 | } | 916 | } |
907 | int off = xyOff; | 917 | int off = xyOff; |
908 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); | 918 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); |
909 | //qDebug("ffffffffff %d ", off); | 919 | //qDebug("ffffffffff %d ", off); |
910 | } | 920 | } |
911 | 921 | ||
912 | // ---------------------------------------------------------------------------- | 922 | // ---------------------------------------------------------------------------- |
913 | // R E SI Z E E V E N T H A N D L I N G | 923 | // R E SI Z E E V E N T H A N D L I N G |
914 | // ---------------------------------------------------------------------------- | 924 | // ---------------------------------------------------------------------------- |
915 | 925 | ||
916 | void KODayMatrix::resizeEvent(QResizeEvent *) | 926 | void KODayMatrix::resizeEvent(QResizeEvent *) |
917 | { | 927 | { |
918 | QRect sz = frameRect(); | 928 | QRect sz = frameRect(); |
919 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 929 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
920 | daysize.setWidth(sz.width() / 7); | 930 | daysize.setWidth(sz.width() / 7); |
921 | } | 931 | } |
922 | 932 | ||
923 | QSize KODayMatrix::sizeHint() const | 933 | QSize KODayMatrix::sizeHint() const |
924 | { | 934 | { |
925 | 935 | ||
926 | QFontMetrics fm ( font() ); | 936 | QFontMetrics fm ( font() ); |
927 | int wid = fm.width( "30") *7+3; | 937 | int wid = fm.width( "30") *7+3; |
928 | int hei = fm.height() * 6+3; | 938 | int hei = fm.height() * 6+3; |
929 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 939 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
930 | return QSize ( wid, hei ); | 940 | return QSize ( wid, hei ); |
931 | 941 | ||
932 | } | 942 | } |
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index 10f4b05..2a1959c 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -1,324 +1,324 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KODAYMAT_H | 23 | #ifndef _KODAYMAT_H |
24 | #define _KODAYMAT_H | 24 | #define _KODAYMAT_H |
25 | 25 | ||
26 | #include <libkcal/calendar.h> | 26 | #include <libkcal/calendar.h> |
27 | 27 | ||
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qcolor.h> | 30 | #include <qcolor.h> |
31 | #include <qpen.h> | 31 | #include <qpen.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qtooltip.h> | 33 | #include <qtooltip.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qbitarray.h> | 35 | #include <qbitarray.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragMoveEvent; | 39 | class QDragMoveEvent; |
40 | class QDragLeaveEvent; | 40 | class QDragLeaveEvent; |
41 | class QDropEvent; | 41 | class QDropEvent; |
42 | 42 | ||
43 | class KODayMatrix; | 43 | class KODayMatrix; |
44 | class KODaymatrixWhatsThis; | 44 | class KODaymatrixWhatsThis; |
45 | 45 | ||
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * small helper class to dynamically show tooltips inside the day matrix. | 50 | * small helper class to dynamically show tooltips inside the day matrix. |
51 | * This class asks the day matrix object for a appropriate label which | 51 | * This class asks the day matrix object for a appropriate label which |
52 | * is in our special case the name of the holiday or null if this day is no holiday. | 52 | * is in our special case the name of the holiday or null if this day is no holiday. |
53 | */ | 53 | */ |
54 | class DynamicTip : public QToolTip | 54 | class DynamicTip : public QToolTip |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Constructor that expects a KODayMatrix object as parent. | 59 | * Constructor that expects a KODayMatrix object as parent. |
60 | * | 60 | * |
61 | * @param parent the parent KODayMatrix control. | 61 | * @param parent the parent KODayMatrix control. |
62 | */ | 62 | */ |
63 | DynamicTip(QWidget* parent ); | 63 | DynamicTip(QWidget* parent ); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Qt's callback to ask the object to provide an approrpiate text for the | 68 | * Qt's callback to ask the object to provide an approrpiate text for the |
69 | * tooltip to be shown. | 69 | * tooltip to be shown. |
70 | * | 70 | * |
71 | * @param pos coordinates of the mouse. | 71 | * @param pos coordinates of the mouse. |
72 | */ | 72 | */ |
73 | void maybeTip( const QPoint & pos); | 73 | void maybeTip( const QPoint & pos); |
74 | 74 | ||
75 | private: | 75 | private: |
76 | 76 | ||
77 | /** the parent control this tooltip is designed for. */ | 77 | /** the parent control this tooltip is designed for. */ |
78 | KODayMatrix* matrix; | 78 | KODayMatrix* matrix; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. | 82 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. |
83 | * Cornelius thought this was a waste of memory and a lot of overhead. | 83 | * Cornelius thought this was a waste of memory and a lot of overhead. |
84 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame | 84 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame |
85 | * that draws the labels and allows for dragging selection while maintaining nearly full | 85 | * that draws the labels and allows for dragging selection while maintaining nearly full |
86 | * compatibility in behaviour with its predecessor. | 86 | * compatibility in behaviour with its predecessor. |
87 | * | 87 | * |
88 | * The following functionality has been changed: | 88 | * The following functionality has been changed: |
89 | * | 89 | * |
90 | * o when shifting events in the agenda view from one day to another the day matrix is updated now | 90 | * o when shifting events in the agenda view from one day to another the day matrix is updated now |
91 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. | 91 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. |
92 | * o no support for Ctrl+click to create groups of dates | 92 | * o no support for Ctrl+click to create groups of dates |
93 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it | 93 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it |
94 | * user friendly.) | 94 | * user friendly.) |
95 | * This feature has been replaced with dragging a selection on the matrix. The matrix will | 95 | * This feature has been replaced with dragging a selection on the matrix. The matrix will |
96 | * automatically choose the appropriate selection (e.g. you are not any longer able to select | 96 | * automatically choose the appropriate selection (e.g. you are not any longer able to select |
97 | * two distinct groups of date selections as in the old class) | 97 | * two distinct groups of date selections as in the old class) |
98 | * o now that you can select more then a week it can happen that not all selected days are | 98 | * o now that you can select more then a week it can happen that not all selected days are |
99 | * displayed in the matrix. However this is preferred to the alternative which would mean to | 99 | * displayed in the matrix. However this is preferred to the alternative which would mean to |
100 | * adjust the selection and leave some days undisplayed while scrolling through the months | 100 | * adjust the selection and leave some days undisplayed while scrolling through the months |
101 | * | 101 | * |
102 | * @short day matrix widget of the KDateNavigator | 102 | * @short day matrix widget of the KDateNavigator |
103 | * | 103 | * |
104 | * @author Eitzenberger Thomas | 104 | * @author Eitzenberger Thomas |
105 | */ | 105 | */ |
106 | class KODayMatrix: public QFrame { | 106 | class KODayMatrix: public QFrame { |
107 | 107 | ||
108 | Q_OBJECT | 108 | Q_OBJECT |
109 | 109 | ||
110 | public: | 110 | public: |
111 | 111 | ||
112 | /** constructor to create a day matrix widget. | 112 | /** constructor to create a day matrix widget. |
113 | * | 113 | * |
114 | * @param parent widget that is the parent of the day matrix. Normally this should | 114 | * @param parent widget that is the parent of the day matrix. Normally this should |
115 | * be a KDateNavigator | 115 | * be a KDateNavigator |
116 | * @param calendar instance of a calendar on which all calculations are based | 116 | * @param calendar instance of a calendar on which all calculations are based |
117 | * @param date start date of the matrix (is expected to be already fixed). It is | 117 | * @param date start date of the matrix (is expected to be already fixed). It is |
118 | * assumed that this date is the first week day to be shown in the matrix. | 118 | * assumed that this date is the first week day to be shown in the matrix. |
119 | * @param name name of the widget | 119 | * @param name name of the widget |
120 | */ | 120 | */ |
121 | KODayMatrix( QWidget *parent, const char *name ); | 121 | KODayMatrix( QWidget *parent, const char *name ); |
122 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | 122 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); |
123 | 123 | ||
124 | /** destructor that deallocates all dynamically allocated private members. | 124 | /** destructor that deallocates all dynamically allocated private members. |
125 | */ | 125 | */ |
126 | ~KODayMatrix(); | 126 | ~KODayMatrix(); |
127 | 127 | ||
128 | /** updates the day matrix to start with the given date. Does all the necessary | 128 | /** updates the day matrix to start with the given date. Does all the necessary |
129 | * checks for holidays or events on a day and stores them for display later on. | 129 | * checks for holidays or events on a day and stores them for display later on. |
130 | * Does NOT update the view visually. Call repaint() for this. | 130 | * Does NOT update the view visually. Call repaint() for this. |
131 | * | 131 | * |
132 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this | 132 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this |
133 | * date. | 133 | * date. |
134 | */ | 134 | */ |
135 | void updateView(QDate actdate); | 135 | void updateView(QDate actdate); |
136 | void updateEvents(); | 136 | void updateEvents(); |
137 | 137 | ||
138 | /** returns the QDate object associated with day indexed by the | 138 | /** returns the QDate object associated with day indexed by the |
139 | * supplied offset. | 139 | * supplied offset. |
140 | */ | 140 | */ |
141 | const QDate& getDate(int offset); | 141 | const QDate& getDate(int offset); |
142 | void setCalendar( Calendar * ); | 142 | void setCalendar( Calendar * ); |
143 | /** returns the official name of this holy day or 0 if there is no label | 143 | /** returns the official name of this holy day or 0 if there is no label |
144 | * for this day. | 144 | * for this day. |
145 | */ | 145 | */ |
146 | QString getHolidayLabel(int offset); | 146 | QString getHolidayLabel(int offset); |
147 | 147 | ||
148 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied | 148 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied |
149 | * DateList. | 149 | * DateList. |
150 | */ | 150 | */ |
151 | void addSelectedDaysTo(DateList&); | 151 | void addSelectedDaysTo(DateList&); |
152 | 152 | ||
153 | /** sets the actual to be displayed selection in the day matrix starting from | 153 | /** sets the actual to be displayed selection in the day matrix starting from |
154 | * start and ending with end. Theview must be manually updated by calling | 154 | * start and ending with end. Theview must be manually updated by calling |
155 | * repaint. (?) | 155 | * repaint. (?) |
156 | */ | 156 | */ |
157 | void setSelectedDaysFrom(const QDate& start, const QDate& end); | 157 | bool setSelectedDaysFrom(const QDate& start, const QDate& end); |
158 | void clearSelection(); | 158 | void clearSelection(); |
159 | 159 | ||
160 | /** Is today visible in the view? Keep this in sync with | 160 | /** Is today visible in the view? Keep this in sync with |
161 | * the values today (below) can take. | 161 | * the values today (below) can take. |
162 | */ | 162 | */ |
163 | bool isTodayVisible() const { return today>=0; } ; | 163 | bool isTodayVisible() const { return today>=0; } ; |
164 | 164 | ||
165 | /** If today is visible, then we can find out if today is | 165 | /** If today is visible, then we can find out if today is |
166 | * near the beginning or the end of the month. | 166 | * near the beginning or the end of the month. |
167 | * This is dependent on today remaining the index | 167 | * This is dependent on today remaining the index |
168 | * in the array of visible dates and going from | 168 | * in the array of visible dates and going from |
169 | * top left (0) to bottom right (41). | 169 | * top left (0) to bottom right (41). |
170 | */ | 170 | */ |
171 | bool isBeginningOfMonth() const { return today<=8; } ; | 171 | bool isBeginningOfMonth() const { return today<=8; } ; |
172 | bool isEndOfMonth() const { return today>=27; } ; | 172 | bool isEndOfMonth() const { return today>=27; } ; |
173 | QString getWhatsThisText( QPoint ) ; | 173 | QString getWhatsThisText( QPoint ) ; |
174 | QSize sizeHint() const; | 174 | QSize sizeHint() const; |
175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} | 175 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} |
176 | public slots: | 176 | public slots: |
177 | /** Recalculates all the flags of the days in the matrix like holidays or events | 177 | /** Recalculates all the flags of the days in the matrix like holidays or events |
178 | * on a day (Actually calls above method with the actual startdate). | 178 | * on a day (Actually calls above method with the actual startdate). |
179 | */ | 179 | */ |
180 | void updateView(); | 180 | void updateView(); |
181 | void updateViewTimed(); | 181 | void updateViewTimed(); |
182 | void repaintViewTimed(); | 182 | void repaintViewTimed(); |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Calculate which square in the matrix should be | 185 | * Calculate which square in the matrix should be |
186 | * hilighted to indicate it's today. | 186 | * hilighted to indicate it's today. |
187 | */ | 187 | */ |
188 | void recalculateToday(); | 188 | void recalculateToday(); |
189 | 189 | ||
190 | /* | 190 | /* |
191 | void setStartDate(QDate); | 191 | void setStartDate(QDate); |
192 | */ | 192 | */ |
193 | 193 | ||
194 | signals: | 194 | signals: |
195 | 195 | ||
196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 196 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
197 | * inside the matrix | 197 | * inside the matrix |
198 | * | 198 | * |
199 | * @param daylist list of days that have been selected by the user | 199 | * @param daylist list of days that have been selected by the user |
200 | */ | 200 | */ |
201 | void selected( const KCal::DateList &daylist ); | 201 | void selected( const KCal::DateList &daylist ); |
202 | 202 | ||
203 | /** emitted if the user has dropped an event inside the matrix | 203 | /** emitted if the user has dropped an event inside the matrix |
204 | * | 204 | * |
205 | * @param event the dropped calendar event | 205 | * @param event the dropped calendar event |
206 | */ | 206 | */ |
207 | void eventDropped(Event *event); | 207 | void eventDropped(Event *event); |
208 | 208 | ||
209 | protected: | 209 | protected: |
210 | 210 | ||
211 | void paintEvent(QPaintEvent *ev); | 211 | void paintEvent(QPaintEvent *ev); |
212 | 212 | ||
213 | void mousePressEvent (QMouseEvent* e); | 213 | void mousePressEvent (QMouseEvent* e); |
214 | 214 | ||
215 | void mouseReleaseEvent (QMouseEvent* e); | 215 | void mouseReleaseEvent (QMouseEvent* e); |
216 | 216 | ||
217 | void mouseMoveEvent (QMouseEvent* e); | 217 | void mouseMoveEvent (QMouseEvent* e); |
218 | 218 | ||
219 | void dragEnterEvent(QDragEnterEvent *); | 219 | void dragEnterEvent(QDragEnterEvent *); |
220 | 220 | ||
221 | void dragMoveEvent(QDragMoveEvent *); | 221 | void dragMoveEvent(QDragMoveEvent *); |
222 | 222 | ||
223 | void dragLeaveEvent(QDragLeaveEvent *); | 223 | void dragLeaveEvent(QDragLeaveEvent *); |
224 | 224 | ||
225 | void dropEvent(QDropEvent *); | 225 | void dropEvent(QDropEvent *); |
226 | 226 | ||
227 | void resizeEvent(QResizeEvent *); | 227 | void resizeEvent(QResizeEvent *); |
228 | 228 | ||
229 | private: | 229 | private: |
230 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; | 230 | KODaymatrixWhatsThis* mKODaymatrixWhatsThis; |
231 | bool mouseDown; | 231 | bool mouseDown; |
232 | QBitArray bDays; | 232 | QBitArray bDays; |
233 | QPixmap myPix; | 233 | QPixmap myPix; |
234 | QTimer* mUpdateTimer; | 234 | QTimer* mUpdateTimer; |
235 | QTimer* mRepaintTimer; | 235 | QTimer* mRepaintTimer; |
236 | bool mDayChanged; | 236 | bool mDayChanged; |
237 | bool mPendingUpdateBeforeRepaint; | 237 | bool mPendingUpdateBeforeRepaint; |
238 | 238 | ||
239 | /** returns the index of the day located at the matrix's widget (x,y) position. | 239 | /** returns the index of the day located at the matrix's widget (x,y) position. |
240 | * | 240 | * |
241 | * @param x horizontal coordinate | 241 | * @param x horizontal coordinate |
242 | * @param y vertical coordinate | 242 | * @param y vertical coordinate |
243 | */ | 243 | */ |
244 | int getDayIndexFrom(int x, int y); | 244 | int getDayIndexFrom(int x, int y); |
245 | 245 | ||
246 | /** calculates a "shaded" color from the supplied color object. | 246 | /** calculates a "shaded" color from the supplied color object. |
247 | * (Copied from Cornelius's kdpdatebutton.cpp) | 247 | * (Copied from Cornelius's kdpdatebutton.cpp) |
248 | * | 248 | * |
249 | * @param color source based on which a shaded color should be calculated. | 249 | * @param color source based on which a shaded color should be calculated. |
250 | */ | 250 | */ |
251 | QColor getShadedColor(QColor color); | 251 | QColor getShadedColor(QColor color); |
252 | 252 | ||
253 | /** number of days to be displayed. For now there is no support for any other number then 42. | 253 | /** number of days to be displayed. For now there is no support for any other number then 42. |
254 | so change it at your own risk :o) */ | 254 | so change it at your own risk :o) */ |
255 | static const int NUMDAYS; | 255 | static const int NUMDAYS; |
256 | 256 | ||
257 | /** calendar instance to be queried for holidays, events, ... */ | 257 | /** calendar instance to be queried for holidays, events, ... */ |
258 | Calendar *mCalendar; | 258 | Calendar *mCalendar; |
259 | 259 | ||
260 | /** starting date of the matrix */ | 260 | /** starting date of the matrix */ |
261 | QDate startdate; | 261 | QDate startdate; |
262 | 262 | ||
263 | /** array of day labels to optimeize drawing performance. */ | 263 | /** array of day labels to optimeize drawing performance. */ |
264 | QString *daylbls; | 264 | QString *daylbls; |
265 | 265 | ||
266 | /** array of days displayed to reduce memory consumption by | 266 | /** array of days displayed to reduce memory consumption by |
267 | subsequently calling QDate::addDays(). */ | 267 | subsequently calling QDate::addDays(). */ |
268 | QDate *days; | 268 | QDate *days; |
269 | 269 | ||
270 | /** array of storing the number of events on a given day. | 270 | /** array of storing the number of events on a given day. |
271 | * used for drawing a bold font if there is at least one event on that day. | 271 | * used for drawing a bold font if there is at least one event on that day. |
272 | */ | 272 | */ |
273 | int *events; | 273 | int *events; |
274 | 274 | ||
275 | /** stores holiday names of the days shown in the matrix. */ | 275 | /** stores holiday names of the days shown in the matrix. */ |
276 | QMap<int,QString> mHolidays; | 276 | QMap<int,QString> mHolidays; |
277 | 277 | ||
278 | /** indey of today or -1 if today is not visible in the matrix. */ | 278 | /** indey of today or -1 if today is not visible in the matrix. */ |
279 | int today; | 279 | int today; |
280 | 280 | ||
281 | /** index of day where dragged selection was initiated. | 281 | /** index of day where dragged selection was initiated. |
282 | used to detect "negative" timely selections */ | 282 | used to detect "negative" timely selections */ |
283 | int mSelInit; | 283 | int mSelInit; |
284 | 284 | ||
285 | /** if mSelStart has this value it indicates that there is no | 285 | /** if mSelStart has this value it indicates that there is no |
286 | actual selection in the matrix. */ | 286 | actual selection in the matrix. */ |
287 | static const int NOSELECTION; | 287 | static const int NOSELECTION; |
288 | 288 | ||
289 | /** index of first selected day. */ | 289 | /** index of first selected day. */ |
290 | int mSelStart; | 290 | int mSelStart; |
291 | 291 | ||
292 | /** index of last selected day. */ | 292 | /** index of last selected day. */ |
293 | int mSelEnd; | 293 | int mSelEnd; |
294 | 294 | ||
295 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ | 295 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ |
296 | DynamicTip* mToolTip; | 296 | DynamicTip* mToolTip; |
297 | 297 | ||
298 | 298 | ||
299 | /** default background colour of the matrix. */ | 299 | /** default background colour of the matrix. */ |
300 | QColor mDefaultBackColor; | 300 | QColor mDefaultBackColor; |
301 | 301 | ||
302 | /** default text color of the matrix. */ | 302 | /** default text color of the matrix. */ |
303 | QColor mDefaultTextColor; | 303 | QColor mDefaultTextColor; |
304 | 304 | ||
305 | /** default text color for days not in the actual month. */ | 305 | /** default text color for days not in the actual month. */ |
306 | QColor mDefaultTextColorShaded; | 306 | QColor mDefaultTextColorShaded; |
307 | 307 | ||
308 | /** default text color for holidays not in the actual month. */ | 308 | /** default text color for holidays not in the actual month. */ |
309 | QColor mHolidayColorShaded; | 309 | QColor mHolidayColorShaded; |
310 | 310 | ||
311 | /** text color for selected days. */ | 311 | /** text color for selected days. */ |
312 | QColor mSelectedDaysColor; | 312 | QColor mSelectedDaysColor; |
313 | 313 | ||
314 | /** default width of the frame drawn around today if it is visible in the matrix. */ | 314 | /** default width of the frame drawn around today if it is visible in the matrix. */ |
315 | int mTodayMarginWidth; | 315 | int mTodayMarginWidth; |
316 | 316 | ||
317 | /** stores actual size of each day in the widget so that I dont need to ask this data | 317 | /** stores actual size of each day in the widget so that I dont need to ask this data |
318 | * on every repaint. | 318 | * on every repaint. |
319 | */ | 319 | */ |
320 | QRect daysize; | 320 | QRect daysize; |
321 | 321 | ||
322 | }; | 322 | }; |
323 | 323 | ||
324 | #endif | 324 | #endif |