Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (show 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 | |||
@@ -12,48 +12,49 @@ | |||
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 & ) ) ); |
@@ -146,74 +147,101 @@ void DateNavigatorContainer::setBaseDates() | |||
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 | } |