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