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