Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 3f6e29b..d09f484 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -34,186 +34,196 @@ | |||
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | 36 | ||
37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
38 | const char *name ) | 38 | const char *name ) |
39 | : QWidget( parent, name ), mCalendar( 0 ), | 39 | : QWidget( parent, name ), mCalendar( 0 ), |
40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
41 | { | 41 | { |
42 | mExtraViews.setAutoDelete( true ); | 42 | mExtraViews.setAutoDelete( true ); |
43 | 43 | ||
44 | mNavigatorView = new KDateNavigator( this, name ); | 44 | mNavigatorView = new KDateNavigator( this, name ); |
45 | 45 | ||
46 | connectNavigatorView( mNavigatorView ); | 46 | connectNavigatorView( mNavigatorView ); |
47 | } | 47 | } |
48 | 48 | ||
49 | DateNavigatorContainer::~DateNavigatorContainer() | 49 | DateNavigatorContainer::~DateNavigatorContainer() |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
54 | { | 54 | { |
55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
57 | #if 0 | 57 | #if 0 |
58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
62 | #endif | 62 | #endif |
63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
64 | SIGNAL( weekClicked( const QDate & ) ) ); | 64 | SIGNAL( weekClicked( const QDate & ) ) ); |
65 | 65 | ||
66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
68 | 68 | ||
69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
73 | 73 | ||
74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
78 | { | 78 | { |
79 | mCalendar = cal; | 79 | mCalendar = cal; |
80 | mNavigatorView->setCalendar( cal ); | 80 | mNavigatorView->setCalendar( cal ); |
81 | KDateNavigator *n; | 81 | KDateNavigator *n; |
82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
83 | n->setCalendar( cal ); | 83 | n->setCalendar( cal ); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | void DateNavigatorContainer::updateDayMatrix() | 87 | void DateNavigatorContainer::updateDayMatrix() |
88 | { | 88 | { |
89 | mNavigatorView->updateDayMatrix(); | 89 | mNavigatorView->updateDayMatrix(); |
90 | KDateNavigator *n; | 90 | KDateNavigator *n; |
91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
92 | n->updateDayMatrix(); | 92 | n->updateDayMatrix(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void DateNavigatorContainer::updateToday() | 96 | void DateNavigatorContainer::updateToday() |
97 | { | 97 | { |
98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
99 | #if 0 | 99 | #if 0 |
100 | mNavigatorView->updateToday(); | 100 | mNavigatorView->updateToday(); |
101 | KDateNavigator *n; | 101 | KDateNavigator *n; |
102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
103 | n->updateToday(); | 103 | n->updateToday(); |
104 | } | 104 | } |
105 | #endif | 105 | #endif |
106 | } | 106 | } |
107 | 107 | ||
108 | void DateNavigatorContainer::updateView() | 108 | void DateNavigatorContainer::updateView() |
109 | { | 109 | { |
110 | mNavigatorView->updateView(); | 110 | mNavigatorView->updateView(); |
111 | KDateNavigator *n; | 111 | KDateNavigator *n; |
112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
113 | n->updateView(); | 113 | n->updateView(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | void DateNavigatorContainer::updateConfig() | 117 | void DateNavigatorContainer::updateConfig() |
118 | { | 118 | { |
119 | mNavigatorView->updateConfig(); | 119 | mNavigatorView->updateConfig(); |
120 | KDateNavigator *n; | 120 | KDateNavigator *n; |
121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
122 | n->updateConfig(); | 122 | n->updateConfig(); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
127 | { | 127 | { |
128 | mNavigatorView->selectDates( dateList ); | 128 | mNavigatorView->selectDates( dateList ); |
129 | setBaseDates(); | 129 | setBaseDates(); |
130 | if ( mExtraViews.count() ) { | ||
131 | KDateNavigator *view = mExtraViews.at( 0 ); | ||
132 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | ||
133 | view->dayMatrix()->repaint(); | ||
134 | } | ||
130 | } | 135 | } |
131 | 136 | ||
132 | void DateNavigatorContainer::setBaseDates() | 137 | void DateNavigatorContainer::setBaseDates() |
133 | { | 138 | { |
134 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 139 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
135 | if ( dateList.isEmpty() ) { | 140 | if ( dateList.isEmpty() ) { |
136 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 141 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
137 | } | 142 | } |
138 | QDate baseDate = dateList.first(); | 143 | QDate baseDate = dateList.first(); |
139 | KDateNavigator *n; | 144 | KDateNavigator *n; |
145 | bool doRepaint = false; // skip first repaint | ||
140 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 146 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
141 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); | 147 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); |
142 | n->setBaseDate( baseDate ); | 148 | n->setBaseDate( baseDate, doRepaint ); |
149 | doRepaint = true; | ||
143 | } | 150 | } |
144 | } | 151 | } |
145 | 152 | ||
146 | void DateNavigatorContainer::resizeEvent( QResizeEvent * ) | 153 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
147 | { | 154 | { |
148 | #if 0 | 155 | #if 0 |
149 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 156 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
150 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 157 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
151 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 158 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
152 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 159 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
153 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 160 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
154 | #endif | 161 | #endif |
155 | 162 | QSize minSize = mNavigatorView->yourSizeHint(); | |
156 | QSize minSize = mNavigatorView->minimumSizeHint(); | ||
157 | 163 | ||
158 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 164 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
159 | 165 | ||
160 | int verticalCount = size().height() / minSize.height(); | 166 | int verticalCount = size().height() / minSize.height(); |
161 | int horizontalCount = size().width() / minSize.width(); | 167 | int horizontalCount = size().width() / minSize.width(); |
168 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | ||
162 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 169 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
163 | if ( horizontalCount != mHorizontalCount || | 170 | if ( horizontalCount != mHorizontalCount || |
164 | verticalCount != mVerticalCount ) { | 171 | verticalCount != mVerticalCount ) { |
165 | uint count = horizontalCount * verticalCount; | 172 | uint count = horizontalCount * verticalCount; |
166 | if ( count == 0 ) return; | 173 | if ( count == 0 ) { |
174 | mNavigatorView->resize( minSize ); | ||
175 | return; | ||
176 | } | ||
167 | 177 | ||
168 | while ( count > ( mExtraViews.count() + 1 ) ) { | 178 | while ( count > ( mExtraViews.count() + 1 ) ) { |
169 | KDateNavigator *n = new KDateNavigator( this ); | 179 | KDateNavigator *n = new KDateNavigator( this ); |
170 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 180 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
171 | mExtraViews.append( n ); | 181 | mExtraViews.append( n ); |
172 | n->setCalendar( mCalendar ); | 182 | n->setCalendar( mCalendar ); |
173 | setBaseDates(); | 183 | setBaseDates(); |
174 | connectNavigatorView( n ); | 184 | connectNavigatorView( n ); |
175 | n->show(); | 185 | n->show(); |
176 | } | 186 | } |
177 | 187 | ||
178 | while ( count < ( mExtraViews.count() + 1 ) ) { | 188 | while ( count < ( mExtraViews.count() + 1 ) ) { |
179 | mExtraViews.removeLast(); | 189 | mExtraViews.removeLast(); |
180 | } | 190 | } |
181 | 191 | ||
182 | mHorizontalCount = horizontalCount; | 192 | mHorizontalCount = horizontalCount; |
183 | mVerticalCount = verticalCount; | 193 | mVerticalCount = verticalCount; |
184 | } | 194 | } |
185 | 195 | ||
186 | int height = size().height() / verticalCount; | 196 | int height = size().height() / verticalCount; |
187 | int width = size().width() / horizontalCount; | 197 | int width = size().width() / horizontalCount; |
188 | 198 | ||
189 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 199 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
190 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 200 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
191 | else bar->showButtons( true, true ); | 201 | else bar->showButtons( true, true ); |
192 | 202 | ||
193 | mNavigatorView->setGeometry(0, | 203 | mNavigatorView->setGeometry(0, |
194 | 0, width, height ); | 204 | 0, width, height ); |
195 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | 205 | for( uint i = 0; i < mExtraViews.count(); ++i ) { |
196 | int x = ( i + 1 ) % horizontalCount; | 206 | int x = ( i + 1 ) % horizontalCount; |
197 | int y = ( i + 1 ) / horizontalCount; | 207 | int y = ( i + 1 ) / horizontalCount; |
198 | 208 | ||
199 | KDateNavigator *view = mExtraViews.at( i ); | 209 | KDateNavigator *view = mExtraViews.at( i ); |
200 | bar = view->navigatorBar(); | 210 | bar = view->navigatorBar(); |
201 | if ( y > 0 ) bar->showButtons( false, false ); | 211 | if ( y > 0 ) bar->showButtons( false, false ); |
202 | else { | 212 | else { |
203 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 213 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
204 | else bar->showButtons( false, false ); | 214 | else bar->showButtons( false, false ); |
205 | } | 215 | } |
206 | view->setGeometry( x * width, | 216 | view->setGeometry( x * width, |
207 | y * height, width, height ); | 217 | y * height, width, height ); |
208 | } | 218 | } |
209 | } | 219 | } |
210 | 220 | ||
211 | QSize DateNavigatorContainer::minimumSizeHint() const | 221 | QSize DateNavigatorContainer::minimumSizeHint() const |
212 | { | 222 | { |
213 | return mNavigatorView->minimumSizeHint(); | 223 | return mNavigatorView->minimumSizeHint(); |
214 | } | 224 | } |
215 | 225 | ||
216 | QSize DateNavigatorContainer::sizeHint() const | 226 | QSize DateNavigatorContainer::sizeHint() const |
217 | { | 227 | { |
218 | return mNavigatorView->sizeHint(); | 228 | return mNavigatorView->sizeHint(); |
219 | } | 229 | } |