author | zautrix <zautrix> | 2005-03-22 12:05:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-22 12:05:42 (UTC) |
commit | 345c70e057e730850493689185b5c358607566f9 (patch) (unidiff) | |
tree | 5081ceed28a61012c1c4d2c7200205fdbedc6435 | |
parent | dfd7d8d53c7ab916dee820c2371195a5dce134a4 (diff) | |
download | kdepimpi-345c70e057e730850493689185b5c358607566f9.zip kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.gz kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.bz2 |
more layout fixes
-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 | |||
@@ -16,75 +16,77 @@ | |||
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,127 +1,130 @@ | |||
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; |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a2e0ae0..3ee1fa7 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -223,137 +223,144 @@ void KODayMatrix::setCalendar( Calendar *cal ) | |||
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() ) |
@@ -638,141 +645,144 @@ void KODayMatrix::dropEvent(QDropEvent *e) | |||
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 | } |
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index 10f4b05..2a1959c 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -93,129 +93,129 @@ private: | |||
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 *); |