summaryrefslogtreecommitdiffabout
path: root/korganizer/datenavigatorcontainer.cpp
Unidiff
Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 548c364..d1caff3 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -5,195 +5,197 @@
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 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
49 mLastDisplayedDN = 0; 49 mLastDisplayedDN = 0;
50 mUpdateTimer; 50 mUpdateTimer;
51 mUpdateTimer = new QTimer( this ); 51 mUpdateTimer = new QTimer( this );
52 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); 52 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
53 mFirstSelectedDate = QDate::currentDate();
54 mSelectedDateCount = 1;
53} 55}
54 56
55DateNavigatorContainer::~DateNavigatorContainer() 57DateNavigatorContainer::~DateNavigatorContainer()
56{ 58{
57} 59}
58 60
59void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 61void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
60{ 62{
61 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 63 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
62 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 64 SIGNAL( datesSelected( const KCal::DateList & ) ) );
63#if 0 65#if 0
64 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 66 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
65 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 67 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
66 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 68 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
67 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 69 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
68#endif 70#endif
69 connect( v, SIGNAL( weekClicked( const QDate & ) ), 71 connect( v, SIGNAL( weekClicked( const QDate & ) ),
70 SIGNAL( weekClicked( const QDate & ) ) ); 72 SIGNAL( weekClicked( const QDate & ) ) );
71 73
72 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 74 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
73 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 75 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
74 76
75 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 77 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
76 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 78 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
77 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 79 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
78 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 80 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
79 81
80 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 82 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
81} 83}
82 84
83void DateNavigatorContainer::slotMonthSelected( int month ) 85void DateNavigatorContainer::slotMonthSelected( int month )
84{ 86{
85 //qDebug("slotMonthSelected %d ", month); 87 //qDebug("slotMonthSelected %d ", month);
86 QDate baseDate = mNavigatorView->baseDate(); 88 QDate baseDate = mNavigatorView->baseDate();
87 if ( baseDate.month() == month ) 89 if ( baseDate.month() == month )
88 return; 90 return;
89 //qDebug("month %d %d ",baseDate.month(),month); 91 //qDebug("month %d %d ",baseDate.month(),month);
90 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); 92 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
91 date = date.addDays( -(baseDate.month()-month ) *30 ); 93 date = date.addDays( -(baseDate.month()-month ) *30 );
92 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); 94 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() );
93 95
94#if 0 96#if 0
95 mFirstSelectedDate = dateList.first() ; 97 mFirstSelectedDate = dateList.first() ;
96 mSelectedDateCount = dateList.count() ; 98 mSelectedDateCount = dateList.count() ;
97 99
98 KDateNavigator *view = mExtraViews.at( 0 ); 100 KDateNavigator *view = mExtraViews.at( 0 );
99 QDate date = view->baseDate(); 101 QDate date = view->baseDate();
100 102
101 QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7); 103 QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7);
102 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 104 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
103 if ( lDate < curEnd && date.addDays( -30 ) < fDate) { 105 if ( lDate < curEnd && date.addDays( -30 ) < fDate) {
104 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 106 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
105 mNavigatorView->dayMatrix()->repaint( false ); 107 mNavigatorView->dayMatrix()->repaint( false );
106 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 108 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
107 KDateNavigator *n = mExtraViews.at( i ); 109 KDateNavigator *n = mExtraViews.at( i );
108 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 110 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
109 n->dayMatrix()->repaint( false ); 111 n->dayMatrix()->repaint( false );
110 } 112 }
111 } 113 }
112 return; 114 return;
113 } 115 }
114#endif 116#endif
115 //qDebug("NEW BASE %s", newBase.toString().latin1()); 117 //qDebug("NEW BASE %s", newBase.toString().latin1());
116 mNavigatorView->setBaseDate( newBase ); 118 mNavigatorView->setBaseDate( newBase );
117 QDate last = lastAvailableDate(); 119 QDate last = lastAvailableDate();
118 QDate first = firstAvailableDate(); 120 QDate first = firstAvailableDate();
119 121
120 QDate selFirst = mFirstSelectedDate; 122 QDate selFirst = mFirstSelectedDate;
121 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 123 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
122 if ( selFirst >= first && selLast <= last ) { 124 if ( selFirst >= first && selLast <= last ) {
123 setBaseDates(); 125 setBaseDates();
124 updateDayMatrixDates(); 126 updateDayMatrixDates();
125 } 127 }
126 else { 128 else {
127 setBaseDates(); 129 setBaseDates();
128 updateDayMatrixDates(); 130 updateDayMatrixDates();
129 emit monthSelected( month ); 131 emit monthSelected( month );
130 } 132 }
131} 133}
132void DateNavigatorContainer::setCalendar( Calendar *cal ) 134void DateNavigatorContainer::setCalendar( Calendar *cal )
133{ 135{
134 mCalendar = cal; 136 mCalendar = cal;
135 mNavigatorView->setCalendar( cal ); 137 mNavigatorView->setCalendar( cal );
136 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 138 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
137 KDateNavigator *n = mExtraViews.at( i ); 139 KDateNavigator *n = mExtraViews.at( i );
138 n->setCalendar( cal ); 140 n->setCalendar( cal );
139 } 141 }
140} 142}
141void DateNavigatorContainer::checkUpdateDayMatrixDates() 143void DateNavigatorContainer::checkUpdateDayMatrixDates()
142{ 144{
143 qDebug("wid %d hei %d ", width(), height()); 145 //qDebug("KODNC: wid %d hei %d ", width(), height());
144 mUpdateTimer->stop(); 146 mUpdateTimer->stop();
145 //return; 147 //return;
146 if ( width() < 3 || height() < 3 ) 148 if ( width() < 3 || height() < 3 )
147 return; 149 return;
148 static int lastWid = 0; 150 static int lastWid = 0;
149 static int lastHei = 0; 151 static int lastHei = 0;
150 if ( lastWid == width() && height() == lastHei ) { 152 if ( lastWid == width() && height() == lastHei ) {
151 qDebug("no layout computing needed. "); 153 qDebug("KODNC: No layout computing needed. ");
152 } else { 154 } else {
153 lastWid = width(); 155 lastWid = width();
154 lastHei = height(); 156 lastHei = height();
155 157
156 QSize minSize = mNavigatorView->yourSizeHint(); 158 QSize minSize = mNavigatorView->yourSizeHint();
157 159
158 int verticalCount = size().height() / minSize.height(); 160 int verticalCount = size().height() / minSize.height();
159 int horizontalCount = size().width() / minSize.width(); 161 int horizontalCount = size().width() / minSize.width();
160 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 162 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
161 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 163 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
162 bool fontchange = false; 164 bool fontchange = false;
163 if ( horizontalCount == 1) 165 if ( horizontalCount == 1)
164 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 166 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
165 QFont fo; 167 QFont fo;
166 if ( horizontalCount != mHorizontalCount || 168 if ( horizontalCount != mHorizontalCount ||
167 verticalCount != mVerticalCount ) { 169 verticalCount != mVerticalCount ) {
168 uint count = horizontalCount * verticalCount; 170 uint count = horizontalCount * verticalCount;
169 if ( count == 0 ) { 171 if ( count == 0 ) {
170 bool ok; 172 bool ok;
171 fo = mNavigatorView->yourFontHint( size() , &ok ); 173 fo = mNavigatorView->yourFontHint( size() , &ok );
172 //mNavigatorView->resize( size() ); 174 //mNavigatorView->resize( size() );
173 //if ( ! ok ) 175 //if ( ! ok )
174 // return; 176 // return;
175 int butt = 2; 177 int butt = 2;
176 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 178 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
177 if ( horizontalCount <= 1 ) 179 if ( horizontalCount <= 1 )
178 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 180 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
179 else 181 else
180 minSize = mNavigatorView->sizeHintTwoButtons(); 182 minSize = mNavigatorView->sizeHintTwoButtons();
181 verticalCount = size().height() / minSize.height(); 183 verticalCount = size().height() / minSize.height();
182 horizontalCount = size().width() / minSize.width(); 184 horizontalCount = size().width() / minSize.width();
183 if ( horizontalCount == 0 ) 185 if ( horizontalCount == 0 )
184 horizontalCount = 1; 186 horizontalCount = 1;
185 if ( verticalCount == 0 ) 187 if ( verticalCount == 0 )
186 verticalCount = 1; 188 verticalCount = 1;
187 fontchange = true; 189 fontchange = true;
188 count = horizontalCount * verticalCount; 190 count = horizontalCount * verticalCount;
189 } else { 191 } else {
190 if ( mNavigatorView->fontChanged() ) { 192 if ( mNavigatorView->fontChanged() ) {
191 fontchange = true; 193 fontchange = true;
192 fo = KOPrefs::instance()->mDateNavigatorFont; 194 fo = KOPrefs::instance()->mDateNavigatorFont;
193 mNavigatorView->changeFont( fo ); 195 mNavigatorView->changeFont( fo );
194 mNavigatorView->unsetFontChanged(); 196 mNavigatorView->unsetFontChanged();
195 } 197 }
196 } 198 }
197 199
198 mLastDisplayedDN = horizontalCount*verticalCount-1; 200 mLastDisplayedDN = horizontalCount*verticalCount-1;
199 while ( count > ( mExtraViews.count() + 1 ) ) { 201 while ( count > ( mExtraViews.count() + 1 ) ) {