summaryrefslogtreecommitdiffabout
path: root/korganizer/datenavigatorcontainer.cpp
Unidiff
Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index b147427..ab0dd50 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,95 +1,96 @@
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
38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, 38DateNavigatorContainer::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} 49}
49 50
50DateNavigatorContainer::~DateNavigatorContainer() 51DateNavigatorContainer::~DateNavigatorContainer()
51{ 52{
52} 53}
53 54
54void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 55void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
55{ 56{
56 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 57 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
57 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 58 SIGNAL( datesSelected( const KCal::DateList & ) ) );
58#if 0 59#if 0
59 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 60 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
60 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 61 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
61 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 62 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
62 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 63 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
63#endif 64#endif
64 connect( v, SIGNAL( weekClicked( const QDate & ) ), 65 connect( v, SIGNAL( weekClicked( const QDate & ) ),
65 SIGNAL( weekClicked( const QDate & ) ) ); 66 SIGNAL( weekClicked( const QDate & ) ) );
66 67
67 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 68 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
68 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 69 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
69 70
70 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 71 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
71 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 72 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
72 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 73 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 74 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
74 75
75 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 76 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
76} 77}
77 78
78void DateNavigatorContainer::setCalendar( Calendar *cal ) 79void DateNavigatorContainer::setCalendar( Calendar *cal )
79{ 80{
80 mCalendar = cal; 81 mCalendar = cal;
81 mNavigatorView->setCalendar( cal ); 82 mNavigatorView->setCalendar( cal );
82 KDateNavigator *n; 83 KDateNavigator *n;
83 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 84 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
84 n->setCalendar( cal ); 85 n->setCalendar( cal );
85 } 86 }
86} 87}
87 88
88void DateNavigatorContainer::updateDayMatrix() 89void DateNavigatorContainer::updateDayMatrix()
89{ 90{
90 mNavigatorView->updateDayMatrix(); 91 mNavigatorView->updateDayMatrix();
91 KDateNavigator *n; 92 KDateNavigator *n;
92 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 93 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
93 n->updateDayMatrix(); 94 n->updateDayMatrix();
94 } 95 }
95} 96}
@@ -130,138 +131,146 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
130 setBaseDates(); 131 setBaseDates();
131 if ( mExtraViews.count() ) { 132 if ( mExtraViews.count() ) {
132 KDateNavigator *view = mExtraViews.at( 0 ); 133 KDateNavigator *view = mExtraViews.at( 0 );
133 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 134 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
134 view->dayMatrix()->repaint( false ); 135 view->dayMatrix()->repaint( false );
135 if ( mExtraViews.count() > 1 ) { 136 if ( mExtraViews.count() > 1 ) {
136 KDateNavigator *view = mExtraViews.at( 1 ); 137 KDateNavigator *view = mExtraViews.at( 1 );
137 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 138 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
138 view->dayMatrix()->repaint( false ); 139 view->dayMatrix()->repaint( false );
139 } 140 }
140 } 141 }
141} 142}
142 143
143void DateNavigatorContainer::setBaseDates() 144void DateNavigatorContainer::setBaseDates()
144{ 145{
145 KCal::DateList dateList = mNavigatorView->selectedDates(); 146 KCal::DateList dateList = mNavigatorView->selectedDates();
146 if ( dateList.isEmpty() ) { 147 if ( dateList.isEmpty() ) {
147 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; 148 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
148 } 149 }
149 QDate baseDate = dateList.first(); 150 QDate baseDate = dateList.first();
150 KDateNavigator *n; 151 KDateNavigator *n;
151 bool doRepaint = false; // skip first repaint 152 bool doRepaint = false; // skip first repaint
152 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 153 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
153 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 154 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
154 n->setBaseDate( baseDate, doRepaint ); 155 n->setBaseDate( baseDate, doRepaint );
155 doRepaint = true; 156 doRepaint = true;
156 } 157 }
157} 158}
158 159
159void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 160void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
160{ 161{
161#if 0 162#if 0
162 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; 163 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
163 kdDebug(5850) << " CURRENT SIZE: " << size() << endl; 164 kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
164 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; 165 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
165 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; 166 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
166 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; 167 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
167#endif 168#endif
168 //QSize minSize = mNavigatorView->sizeHintTwoButtons(); 169 //QSize minSize = mNavigatorView->sizeHintTwoButtons();
169 QSize minSize = mNavigatorView->yourSizeHint(); 170 QSize minSize = mNavigatorView->yourSizeHint();
170 171
171// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; 172// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
172 173
173 int verticalCount = size().height() / minSize.height(); 174 int verticalCount = size().height() / minSize.height();
174 int horizontalCount = size().width() / minSize.width(); 175 int horizontalCount = size().width() / minSize.width();
175 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 176 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
176 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 177 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
177 bool fontchange = false; 178 bool fontchange = false;
179 if ( horizontalCount == 1)
180 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
178 QFont fo; 181 QFont fo;
179 if ( horizontalCount != mHorizontalCount || 182 if ( horizontalCount != mHorizontalCount ||
180 verticalCount != mVerticalCount ) { 183 verticalCount != mVerticalCount ) {
181 uint count = horizontalCount * verticalCount; 184 uint count = horizontalCount * verticalCount;
182 if ( count == 0 ) { 185 if ( count == 0 ) {
183 bool ok; 186 bool ok;
184 fo = mNavigatorView->yourFontHint( size() , &ok); 187 fo = mNavigatorView->yourFontHint( size() , &ok);
185 //mNavigatorView->resize( size() ); 188 //mNavigatorView->resize( size() );
186 //if ( ! ok ) 189 //if ( ! ok )
187 // return; 190 // return;
191 int butt = 2;
192 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
193 if ( horizontalCount <= 1 )
194 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
195 else
188 minSize = mNavigatorView->sizeHintTwoButtons(); 196 minSize = mNavigatorView->sizeHintTwoButtons();
189 verticalCount = size().height() / minSize.height(); 197 verticalCount = size().height() / minSize.height();
190 horizontalCount = size().width() / minSize.width(); 198 horizontalCount = size().width() / minSize.width();
191 if ( horizontalCount == 0 ) 199 if ( horizontalCount == 0 )
192 horizontalCount = 1; 200 horizontalCount = 1;
193 if ( verticalCount == 0 ) 201 if ( verticalCount == 0 )
194 verticalCount = 1; 202 verticalCount = 1;
195 fontchange = true; 203 fontchange = true;
196 count = horizontalCount * verticalCount; 204 count = horizontalCount * verticalCount;
197 } else { 205 } else {
198 if ( mNavigatorView->fontChanged() ) { 206 if ( mNavigatorView->fontChanged() ) {
199 fontchange = true; 207 fontchange = true;
200 fo = KOPrefs::instance()->mDateNavigatorFont; 208 fo = KOPrefs::instance()->mDateNavigatorFont;
201 mNavigatorView->changeFont( fo ); 209 mNavigatorView->changeFont( fo );
202 mNavigatorView->unsetFontChanged(); 210 mNavigatorView->unsetFontChanged();
203 } 211 }
204 } 212 }
205 213
206 while ( count > ( mExtraViews.count() + 1 ) ) { 214 while ( count > ( mExtraViews.count() + 1 ) ) {
207 KDateNavigator *n = new KDateNavigator( this ); 215 KDateNavigator *n = new KDateNavigator( this );
208 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 216 n->setMonthSignalOffset ( mExtraViews.count()+1 );
209 mExtraViews.append( n ); 217 mExtraViews.append( n );
210 n->setCalendar( mCalendar ); 218 n->setCalendar( mCalendar );
211 setBaseDates(); 219 setBaseDates();
212 connectNavigatorView( n ); 220 connectNavigatorView( n );
213 n->show(); 221 n->show();
214 } 222 }
215 int iii = 0; 223 int iii = 0;
216 while ( iii < ( mExtraViews.count() ) ) { 224 while ( iii < ( mExtraViews.count() ) ) {
217 if ( iii < count-1 ) 225 if ( iii < count-1 )
218 mExtraViews.at( iii )->show(); 226 mExtraViews.at( iii )->show();
219 else 227 else
220 mExtraViews.at( iii )->hide(); 228 mExtraViews.at( iii )->hide();
221 ++iii; 229 ++iii;
222 } 230 }
223 if ( fontchange ) { 231 if ( fontchange ) {
224 //mNavigatorView->changeFont( fo ); 232 //mNavigatorView->changeFont( fo );
225 uint i; 233 uint i;
226 for( i = 0; i < mExtraViews.count(); ++i ) { 234 for( i = 0; i < mExtraViews.count(); ++i ) {
227 KDateNavigator *view = mExtraViews.at( i ); 235 KDateNavigator *view = mExtraViews.at( i );
228 view->changeFont( fo ); 236 view->changeFont( fo );
229 } 237 }
230 } 238 }
231 mHorizontalCount = horizontalCount; 239 mHorizontalCount = horizontalCount;
232 mVerticalCount = verticalCount; 240 mVerticalCount = verticalCount;
233 } 241 }
242 //qDebug("COUNT %d ", mExtraViews.count());
234 int height = size().height() / verticalCount; 243 int height = size().height() / verticalCount;
235 int width = size().width() / horizontalCount; 244 int width = size().width() / horizontalCount;
236 245
237 NavigatorBar *bar = mNavigatorView->navigatorBar(); 246 NavigatorBar *bar = mNavigatorView->navigatorBar();
238 if ( horizontalCount > 1 ) bar->showButtons( true, false ); 247 if ( horizontalCount > 1 ) bar->showButtons( true, false );
239 else bar->showButtons( true, true ); 248 else bar->showButtons( true, true );
240 249
241 mNavigatorView->setGeometry(0, 250 mNavigatorView->setGeometry(0,
242 0, width, height ); 251 0, width, height );
243 for( uint i = 0; i < mExtraViews.count(); ++i ) { 252 for( uint i = 0; i < mExtraViews.count(); ++i ) {
244 int x = ( i + 1 ) % horizontalCount; 253 int x = ( i + 1 ) % horizontalCount;
245 int y = ( i + 1 ) / horizontalCount; 254 int y = ( i + 1 ) / horizontalCount;
246 255
247 KDateNavigator *view = mExtraViews.at( i ); 256 KDateNavigator *view = mExtraViews.at( i );
248 bar = view->navigatorBar(); 257 bar = view->navigatorBar();
249 if ( y > 0 ) bar->showButtons( false, false ); 258 if ( y > 0 ) bar->showButtons( false, false );
250 else { 259 else {
251 if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); 260 if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
252 else bar->showButtons( false, false ); 261 else bar->showButtons( false, false );
253 } 262 }
254 view->setGeometry( x * width, 263 view->setGeometry( x * width,
255 y * height, width, height ); 264 y * height, width, height );
256 } 265 }
257} 266}
258 267
259QSize DateNavigatorContainer::minimumSizeHint() const 268QSize DateNavigatorContainer::minimumSizeHint() const
260{ 269{
261 return mNavigatorView->minimumSizeHint(); 270 return mNavigatorView->minimumSizeHint();
262} 271}
263 272
264QSize DateNavigatorContainer::sizeHint() const 273QSize DateNavigatorContainer::sizeHint() const
265{ 274{
266 return mNavigatorView->sizeHint(); 275 return mNavigatorView->sizeHint();
267} 276}