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