summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp4
-rw-r--r--korganizer/kdatenavigator.cpp14
-rw-r--r--korganizer/kdatenavigator.h1
-rw-r--r--korganizer/navigatorbar.cpp11
-rw-r--r--korganizer/navigatorbar.h1
5 files changed, 24 insertions, 7 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 3358ecf..5cdaa83 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -67,191 +67,191 @@ void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
67 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 67 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
68 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 68 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
69 69
70 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 70 connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
71 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 71 connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
72 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 72 connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 73 connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
74 74
75 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 75 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
76} 76}
77 77
78void DateNavigatorContainer::setCalendar( Calendar *cal ) 78void DateNavigatorContainer::setCalendar( Calendar *cal )
79{ 79{
80 mCalendar = cal; 80 mCalendar = cal;
81 mNavigatorView->setCalendar( cal ); 81 mNavigatorView->setCalendar( cal );
82 KDateNavigator *n; 82 KDateNavigator *n;
83 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 83 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
84 n->setCalendar( cal ); 84 n->setCalendar( cal );
85 } 85 }
86} 86}
87 87
88void DateNavigatorContainer::updateDayMatrix() 88void DateNavigatorContainer::updateDayMatrix()
89{ 89{
90 mNavigatorView->updateDayMatrix(); 90 mNavigatorView->updateDayMatrix();
91 KDateNavigator *n; 91 KDateNavigator *n;
92 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 92 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
93 n->updateDayMatrix(); 93 n->updateDayMatrix();
94 } 94 }
95} 95}
96 96
97void DateNavigatorContainer::updateToday() 97void DateNavigatorContainer::updateToday()
98{ 98{
99 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 99 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
100#if 0 100#if 0
101 mNavigatorView->updateToday(); 101 mNavigatorView->updateToday();
102 KDateNavigator *n; 102 KDateNavigator *n;
103 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 103 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
104 n->updateToday(); 104 n->updateToday();
105 } 105 }
106#endif 106#endif
107} 107}
108 108
109void DateNavigatorContainer::updateView() 109void DateNavigatorContainer::updateView()
110{ 110{
111 mNavigatorView->updateView(); 111 mNavigatorView->updateView();
112 KDateNavigator *n; 112 KDateNavigator *n;
113 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 113 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
114 n->updateView(); 114 n->updateView();
115 } 115 }
116} 116}
117 117
118void DateNavigatorContainer::updateConfig() 118void DateNavigatorContainer::updateConfig()
119{ 119{
120 mNavigatorView->updateConfig(); 120 mNavigatorView->updateConfig();
121 KDateNavigator *n; 121 KDateNavigator *n;
122 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 122 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
123 n->updateConfig(); 123 n->updateConfig();
124 } 124 }
125} 125}
126 126
127void DateNavigatorContainer::selectDates( const DateList &dateList ) 127void DateNavigatorContainer::selectDates( const DateList &dateList )
128{ 128{
129 mNavigatorView->selectDates( dateList ); 129 mNavigatorView->selectDates( dateList );
130 setBaseDates(); 130 setBaseDates();
131 if ( mExtraViews.count() ) { 131 if ( mExtraViews.count() ) {
132 KDateNavigator *view = mExtraViews.at( 0 ); 132 KDateNavigator *view = mExtraViews.at( 0 );
133 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 133 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
134 view->dayMatrix()->repaint(); 134 view->dayMatrix()->repaint();
135 } 135 }
136} 136}
137 137
138void DateNavigatorContainer::setBaseDates() 138void DateNavigatorContainer::setBaseDates()
139{ 139{
140 KCal::DateList dateList = mNavigatorView->selectedDates(); 140 KCal::DateList dateList = mNavigatorView->selectedDates();
141 if ( dateList.isEmpty() ) { 141 if ( dateList.isEmpty() ) {
142 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; 142 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
143 } 143 }
144 QDate baseDate = dateList.first(); 144 QDate baseDate = dateList.first();
145 KDateNavigator *n; 145 KDateNavigator *n;
146 bool doRepaint = false; // skip first repaint 146 bool doRepaint = false; // skip first repaint
147 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 147 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
148 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 148 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
149 n->setBaseDate( baseDate, doRepaint ); 149 n->setBaseDate( baseDate, doRepaint );
150 doRepaint = true; 150 doRepaint = true;
151 } 151 }
152} 152}
153 153
154void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 154void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
155{ 155{
156#if 0 156#if 0
157 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; 157 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
158 kdDebug(5850) << " CURRENT SIZE: " << size() << endl; 158 kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
159 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; 159 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
160 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; 160 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
161 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; 161 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
162#endif 162#endif
163 QSize minSize = mNavigatorView->yourSizeHint(); 163 QSize minSize = mNavigatorView->sizeHintTwoButtons();
164 164
165// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; 165// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
166 166
167 int verticalCount = size().height() / minSize.height(); 167 int verticalCount = size().height() / minSize.height();
168 int horizontalCount = size().width() / minSize.width(); 168 int horizontalCount = size().width() / minSize.width();
169 //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() );
170 //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; 171 bool fontchange = false;
172 QFont fo; 172 QFont fo;
173 if ( horizontalCount != mHorizontalCount || 173 if ( horizontalCount != mHorizontalCount ||
174 verticalCount != mVerticalCount ) { 174 verticalCount != mVerticalCount ) {
175 uint count = horizontalCount * verticalCount; 175 uint count = horizontalCount * verticalCount;
176 if ( count == 0 ) { 176 if ( count == 0 ) {
177 bool ok; 177 bool ok;
178 fo = mNavigatorView->yourFontHint( size() , &ok); 178 fo = mNavigatorView->yourFontHint( size() , &ok);
179 //mNavigatorView->resize( size() ); 179 //mNavigatorView->resize( size() );
180 //if ( ! ok ) 180 //if ( ! ok )
181 // return; 181 // return;
182 minSize = mNavigatorView->sizeHint(); 182 minSize = mNavigatorView->sizeHintTwoButtons();
183 verticalCount = size().height() / minSize.height(); 183 verticalCount = size().height() / minSize.height();
184 horizontalCount = size().width() / minSize.width(); 184 horizontalCount = size().width() / minSize.width();
185 if ( horizontalCount == 0 ) 185 if ( horizontalCount == 0 )
186 horizontalCount = 1; 186 horizontalCount = 1;
187 if ( verticalCount == 0 ) 187 if ( verticalCount == 0 )
188 verticalCount = 1; 188 verticalCount = 1;
189 fontchange = true; 189 fontchange = true;
190 count = horizontalCount * verticalCount; 190 count = horizontalCount * verticalCount;
191 } else { 191 } else {
192 if ( mNavigatorView->fontChanged() ) { 192 if ( mNavigatorView->fontChanged() ) {
193 fontchange = true; 193 fontchange = true;
194 fo = KOPrefs::instance()->mDateNavigatorFont; 194 fo = KOPrefs::instance()->mDateNavigatorFont;
195 mNavigatorView->changeFont( fo ); 195 mNavigatorView->changeFont( fo );
196 mNavigatorView->unsetFontChanged(); 196 mNavigatorView->unsetFontChanged();
197 } 197 }
198 } 198 }
199 199
200 while ( count > ( mExtraViews.count() + 1 ) ) { 200 while ( count > ( mExtraViews.count() + 1 ) ) {
201 KDateNavigator *n = new KDateNavigator( this ); 201 KDateNavigator *n = new KDateNavigator( this );
202 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 202 n->setMonthSignalOffset ( mExtraViews.count()+1 );
203 mExtraViews.append( n ); 203 mExtraViews.append( n );
204 n->setCalendar( mCalendar ); 204 n->setCalendar( mCalendar );
205 setBaseDates(); 205 setBaseDates();
206 connectNavigatorView( n ); 206 connectNavigatorView( n );
207 n->show(); 207 n->show();
208 } 208 }
209 209
210 while ( count < ( mExtraViews.count() + 1 ) ) { 210 while ( count < ( mExtraViews.count() + 1 ) ) {
211 mExtraViews.removeLast(); 211 mExtraViews.removeLast();
212 } 212 }
213 if ( fontchange ) { 213 if ( fontchange ) {
214 //mNavigatorView->changeFont( fo ); 214 //mNavigatorView->changeFont( fo );
215 uint i; 215 uint i;
216 for( i = 0; i < mExtraViews.count(); ++i ) { 216 for( i = 0; i < mExtraViews.count(); ++i ) {
217 KDateNavigator *view = mExtraViews.at( i ); 217 KDateNavigator *view = mExtraViews.at( i );
218 view->changeFont( fo ); 218 view->changeFont( fo );
219 } 219 }
220 } 220 }
221 mHorizontalCount = horizontalCount; 221 mHorizontalCount = horizontalCount;
222 mVerticalCount = verticalCount; 222 mVerticalCount = verticalCount;
223 } 223 }
224 int height = size().height() / verticalCount; 224 int height = size().height() / verticalCount;
225 int width = size().width() / horizontalCount; 225 int width = size().width() / horizontalCount;
226 226
227 NavigatorBar *bar = mNavigatorView->navigatorBar(); 227 NavigatorBar *bar = mNavigatorView->navigatorBar();
228 if ( horizontalCount > 1 ) bar->showButtons( true, false ); 228 if ( horizontalCount > 1 ) bar->showButtons( true, false );
229 else bar->showButtons( true, true ); 229 else bar->showButtons( true, true );
230 230
231 mNavigatorView->setGeometry(0, 231 mNavigatorView->setGeometry(0,
232 0, width, height ); 232 0, width, height );
233 for( uint i = 0; i < mExtraViews.count(); ++i ) { 233 for( uint i = 0; i < mExtraViews.count(); ++i ) {
234 int x = ( i + 1 ) % horizontalCount; 234 int x = ( i + 1 ) % horizontalCount;
235 int y = ( i + 1 ) / horizontalCount; 235 int y = ( i + 1 ) / horizontalCount;
236 236
237 KDateNavigator *view = mExtraViews.at( i ); 237 KDateNavigator *view = mExtraViews.at( i );
238 bar = view->navigatorBar(); 238 bar = view->navigatorBar();
239 if ( y > 0 ) bar->showButtons( false, false ); 239 if ( y > 0 ) bar->showButtons( false, false );
240 else { 240 else {
241 if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); 241 if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
242 else bar->showButtons( false, false ); 242 else bar->showButtons( false, false );
243 } 243 }
244 view->setGeometry( x * width, 244 view->setGeometry( x * width,
245 y * height, width, height ); 245 y * height, width, height );
246 } 246 }
247} 247}
248 248
249QSize DateNavigatorContainer::minimumSizeHint() const 249QSize DateNavigatorContainer::minimumSizeHint() const
250{ 250{
251 return mNavigatorView->minimumSizeHint(); 251 return mNavigatorView->minimumSizeHint();
252} 252}
253 253
254QSize DateNavigatorContainer::sizeHint() const 254QSize DateNavigatorContainer::sizeHint() const
255{ 255{
256 return mNavigatorView->sizeHint(); 256 return mNavigatorView->sizeHint();
257} 257}
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 92a0ac2..a5dbc5d 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -41,215 +41,227 @@
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) 48KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
49 : QFrame(parent, name), 49 : QFrame(parent, name),
50 updateTimer(0L) 50 updateTimer(0L)
51{ 51{
52 setFrameStyle(QFrame::NoFrame); 52 setFrameStyle(QFrame::NoFrame);
53 QDate startDate = QDate::currentDate(); 53 QDate startDate = QDate::currentDate();
54 QGridLayout *topLayout = new QGridLayout(this,8,8); 54 QGridLayout *topLayout = new QGridLayout(this,8,8);
55 55
56 if (! startDate.isValid()) { 56 if (! startDate.isValid()) {
57 qDebug("KDateNavigator::invalid startdate "); 57 qDebug("KDateNavigator::invalid startdate ");
58 startDate = QDate::currentDate(); 58 startDate = QDate::currentDate();
59 } 59 }
60 mMonthSignalOffset = 0; 60 mMonthSignalOffset = 0;
61 mSelectedDates.append(startDate); 61 mSelectedDates.append(startDate);
62 m_MthYr = startDate; 62 m_MthYr = startDate;
63 m_bShowWeekNums = true; 63 m_bShowWeekNums = true;
64 64
65 setFont( KOPrefs::instance()->mDateNavigatorFont ); 65 setFont( KOPrefs::instance()->mDateNavigatorFont );
66 mNavigatorBar = new NavigatorBar( startDate, this ); 66 mNavigatorBar = new NavigatorBar( startDate, this );
67 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 67 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
68 //mNavigatorBar->resize( 1,1); 68 //mNavigatorBar->resize( 1,1);
69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
74 74
75 // get the day of the week on the first day 75 // get the day of the week on the first day
76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
77 m_fstDayOfWk = dayone.dayOfWeek(); 77 m_fstDayOfWk = dayone.dayOfWeek();
78 78
79 int i; 79 int i;
80 80
81 // Set up the heading fields. 81 // Set up the heading fields.
82 for( i = 0; i < 7; i++ ) { 82 for( i = 0; i < 7; i++ ) {
83 headings[i] = new QLabel("",this); 83 headings[i] = new QLabel("",this);
84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
85 headings[i]->setAlignment(AlignCenter); 85 headings[i]->setAlignment(AlignCenter);
86 86
87 topLayout->addWidget(headings[i],1,i+1); 87 topLayout->addWidget(headings[i],1,i+1);
88 } 88 }
89 89
90 // Create the weeknumber labels 90 // Create the weeknumber labels
91 for( i = 0; i < 6; i++ ) { 91 for( i = 0; i < 6; i++ ) {
92 weeknos[i] = new QLabel(this); 92 weeknos[i] = new QLabel(this);
93 weeknos[i]->setAlignment(AlignCenter); 93 weeknos[i]->setAlignment(AlignCenter);
94 //weeknos[i]->setFont(QFont("Arial", 10)); 94 //weeknos[i]->setFont(QFont("Arial", 10));
95 if(!m_bShowWeekNums) { 95 if(!m_bShowWeekNums) {
96 weeknos[i]->hide(); 96 weeknos[i]->hide();
97 } 97 }
98 weeknos[i]->installEventFilter(this); 98 weeknos[i]->installEventFilter(this);
99 99
100 topLayout->addWidget(weeknos[i],i+2,0); 100 topLayout->addWidget(weeknos[i],i+2,0);
101 } 101 }
102 102
103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 103 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 104 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
105 daymatrix->setLineWidth(1); 105 daymatrix->setLineWidth(1);
106 106
107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 107 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
108 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 108 SIGNAL( datesSelected( const KCal::DateList & ) ) );
109 109
110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 110 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
111 SIGNAL( eventDropped( Event * ) ) ); 111 SIGNAL( eventDropped( Event * ) ) );
112 112
113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 113 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
114 114
115 // read settings from configuration file. 115 // read settings from configuration file.
116 updateConfig(); 116 updateConfig();
117 enableRollover(FollowMonth); 117 enableRollover(FollowMonth);
118 mySizeHint = sizeHint(); 118 mySizeHint = sizeHint();
119 mFontChanged = false; 119 mFontChanged = false;
120} 120}
121void KDateNavigator::changeFont ( QFont fo ) 121void KDateNavigator::changeFont ( QFont fo )
122{ 122{
123 setFont( fo ); 123 setFont( fo );
124 mNavigatorBar->resetFont( fo ); 124 mNavigatorBar->resetFont( fo );
125} 125}
126QFont KDateNavigator::yourFontHint( QSize si , bool *b) 126QFont KDateNavigator::yourFontHint( QSize si , bool *b)
127{ 127{
128 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 128 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
129 *b = false; 129 *b = false;
130 int fontPoint = fo.pointSize(); 130 int fontPoint = fo.pointSize();
131 while ( fontPoint > 5 ) { 131 while ( fontPoint > 5 ) {
132 --fontPoint; 132 --fontPoint;
133 fo.setPointSize( fontPoint ); 133 fo.setPointSize( fontPoint );
134 setFont( fo ); 134 setFont( fo );
135 mFontChanged = true; 135 mFontChanged = true;
136 mNavigatorBar->resetFont( fo ); 136 mNavigatorBar->resetFont( fo );
137 QSize sh = sizeHint(); 137 QSize sh = sizeHintTwoButtons();
138 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 138 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
139 if ( si.width() > sh.width() && si.height() > sh.height()) { 139 if ( si.width() > sh.width() && si.height() > sh.height()) {
140 *b = true; 140 *b = true;
141 //qDebug("fooooooooooooooooooooooouuuuund "); 141 //qDebug("fooooooooooooooooooooooouuuuund ");
142 break; 142 break;
143 } 143 }
144 } 144 }
145 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); 145 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
146 return fo; 146 return fo;
147} 147}
148QSize KDateNavigator::sizeHint() const 148QSize KDateNavigator::sizeHint() const
149{ 149{
150 QFontMetrics fm ( font() ); 150 QFontMetrics fm ( font() );
151 QSize day = daymatrix->sizeHint(); 151 QSize day = daymatrix->sizeHint();
152 QSize nav = mNavigatorBar->sizeHint(); 152 QSize nav = mNavigatorBar->sizeHint();
153 int wid = fm.width( "30") + day.width()+3; 153 int wid = fm.width( "30") + day.width()+3;
154 int hei = fm.height() +day.height()+nav.height()+2; 154 int hei = fm.height() +day.height()+nav.height()+2;
155 if ( wid < nav.width() ) 155 if ( wid < nav.width() )
156 wid = nav.width() ; 156 wid = nav.width() ;
157 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 157 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
158 return QSize ( wid, hei ); 158 return QSize ( wid, hei );
159} 159}
160QSize KDateNavigator::sizeHintTwoButtons() const
161{
162 QFontMetrics fm ( font() );
163 QSize day = daymatrix->sizeHint();
164 QSize nav = mNavigatorBar->sizeHintTwoButtons();
165 int wid = fm.width( "30") + day.width()+3;
166 int hei = fm.height() +day.height()+nav.height()+2;
167 if ( wid < nav.width() )
168 wid = nav.width() ;
169 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
170 return QSize ( wid, hei );
171}
160void KDateNavigator::slotMonthSelected( int m ) 172void KDateNavigator::slotMonthSelected( int m )
161{ 173{
162 if ( m_MthYr.month() <= mMonthSignalOffset) 174 if ( m_MthYr.month() <= mMonthSignalOffset)
163 m += 12; 175 m += 12;
164 int mo = m - mMonthSignalOffset; 176 int mo = m - mMonthSignalOffset;
165 emit monthSelected( m - mMonthSignalOffset ); 177 emit monthSelected( m - mMonthSignalOffset );
166 178
167} 179}
168void KDateNavigator::setCalendar( Calendar *cal ) 180void KDateNavigator::setCalendar( Calendar *cal )
169{ 181{
170 daymatrix->setCalendar( cal ); 182 daymatrix->setCalendar( cal );
171} 183}
172 184
173void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true 185void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
174{ 186{
175 m_MthYr = date; 187 m_MthYr = date;
176 188
177 updateDates(); 189 updateDates();
178 updateView(); 190 updateView();
179 191
180 KCal::DateList dates; 192 KCal::DateList dates;
181 dates.append( date ); 193 dates.append( date );
182 mNavigatorBar->selectDates( dates ); 194 mNavigatorBar->selectDates( dates );
183 195
184 daymatrix->clearSelection(); 196 daymatrix->clearSelection();
185 if ( doRepaint ) 197 if ( doRepaint )
186 daymatrix->repaint(); 198 daymatrix->repaint();
187} 199}
188 200
189void KDateNavigator::enableRollover(RolloverType r) 201void KDateNavigator::enableRollover(RolloverType r)
190{ 202{
191 switch(r) 203 switch(r)
192 { 204 {
193 case None : 205 case None :
194 if (updateTimer) 206 if (updateTimer)
195 { 207 {
196 updateTimer->stop(); 208 updateTimer->stop();
197 delete updateTimer; 209 delete updateTimer;
198 updateTimer=0L; 210 updateTimer=0L;
199 } 211 }
200 break; 212 break;
201 case FollowDay : 213 case FollowDay :
202 case FollowMonth : 214 case FollowMonth :
203 if (!updateTimer) 215 if (!updateTimer)
204 { 216 {
205 updateTimer = new QTimer(this); 217 updateTimer = new QTimer(this);
206 QObject::connect(updateTimer,SIGNAL(timeout()), 218 QObject::connect(updateTimer,SIGNAL(timeout()),
207 this,SLOT(possiblyPastMidnight())); 219 this,SLOT(possiblyPastMidnight()));
208 } 220 }
209 updateTimer->start(0,true); 221 updateTimer->start(0,true);
210 lastDayChecked = QDate::currentDate(); 222 lastDayChecked = QDate::currentDate();
211 } 223 }
212 updateRollover=r; 224 updateRollover=r;
213} 225}
214 226
215 227
216KDateNavigator::~KDateNavigator() 228KDateNavigator::~KDateNavigator()
217{ 229{
218} 230}
219 231
220 232
221void KDateNavigator::passedMidnight() 233void KDateNavigator::passedMidnight()
222{ 234{
223 QDate today = QDate::currentDate(); 235 QDate today = QDate::currentDate();
224 bool emitMonth = false; 236 bool emitMonth = false;
225 237
226 if (today.month() != lastDayChecked.month()) 238 if (today.month() != lastDayChecked.month())
227 { 239 {
228 if (updateRollover==FollowMonth && 240 if (updateRollover==FollowMonth &&
229 daymatrix->isEndOfMonth()) { 241 daymatrix->isEndOfMonth()) {
230 goNextMonth(); 242 goNextMonth();
231 emitMonth=true; 243 emitMonth=true;
232 } 244 }
233 } 245 }
234 daymatrix->recalculateToday(); 246 daymatrix->recalculateToday();
235 daymatrix->repaint(); 247 daymatrix->repaint();
236 emit dayPassed(today); 248 emit dayPassed(today);
237 if (emitMonth) { emit monthPassed(today); } 249 if (emitMonth) { emit monthPassed(today); }
238} 250}
239 251
240/* slot */ void KDateNavigator::possiblyPastMidnight() 252/* slot */ void KDateNavigator::possiblyPastMidnight()
241{ 253{
242 if (lastDayChecked!=QDate::currentDate()) 254 if (lastDayChecked!=QDate::currentDate())
243 { 255 {
244 passedMidnight(); 256 passedMidnight();
245 lastDayChecked=QDate::currentDate(); 257 lastDayChecked=QDate::currentDate();
246 } 258 }
247 // Set the timer to go off 1 second after midnight 259 // Set the timer to go off 1 second after midnight
248 // or after 8 minutes, whichever comes first. 260 // or after 8 minutes, whichever comes first.
249 if (updateTimer) 261 if (updateTimer)
250 { 262 {
251 QTime now = QTime::currentTime(); 263 QTime now = QTime::currentTime();
252 QTime midnight = QTime(23,59,59); 264 QTime midnight = QTime(23,59,59);
253 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 265 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
254 266
255 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 267 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h
index 3177687..d1f32b6 100644
--- a/korganizer/kdatenavigator.h
+++ b/korganizer/kdatenavigator.h
@@ -1,160 +1,161 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KDATENAVIGATOR_H 23#ifndef KDATENAVIGATOR_H
24#define KDATENAVIGATOR_H 24#define KDATENAVIGATOR_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlabel.h> 28#include <qlabel.h>
29 29
30#include <libkcal/calendar.h> 30#include <libkcal/calendar.h>
31 31
32#include "kodaymatrix.h" 32#include "kodaymatrix.h"
33 33
34class QPushButton; 34class QPushButton;
35class QTimer; 35class QTimer;
36 36
37class KCalendarSystem; 37class KCalendarSystem;
38 38
39class NavigatorBar; 39class NavigatorBar;
40 40
41class KDateNavigator: public QFrame 41class KDateNavigator: public QFrame
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44 public: 44 public:
45 KDateNavigator( QWidget *parent = 0,const char *name = 0 ); 45 KDateNavigator( QWidget *parent = 0,const char *name = 0 );
46 ~KDateNavigator(); 46 ~KDateNavigator();
47 47
48 /** The DateNavigator automatically checks for 48 /** The DateNavigator automatically checks for
49 * the passage of midnight. If rollover type is 49 * the passage of midnight. If rollover type is
50 * set to None, no signals are emitted and no 50 * set to None, no signals are emitted and no
51 * processing is done. With rollover set to 51 * processing is done. With rollover set to
52 * FollowDay, the day highlighter changes at 52 * FollowDay, the day highlighter changes at
53 * midnight and dayPassed() is emitted. 53 * midnight and dayPassed() is emitted.
54 * With FollowMonth, it has the same effect 54 * With FollowMonth, it has the same effect
55 * as FollowDay but also adjusts the month that is 55 * as FollowDay but also adjusts the month that is
56 * visible and emits monthPassed() when the month changes. 56 * visible and emits monthPassed() when the month changes.
57 */ 57 */
58 enum RolloverType { None, FollowDay, FollowMonth } ; 58 enum RolloverType { None, FollowDay, FollowMonth } ;
59 void enableRollover( RolloverType ); 59 void enableRollover( RolloverType );
60 60
61 void setShowWeekNums( bool enabled ); 61 void setShowWeekNums( bool enabled );
62 void setCalendar( Calendar * ); 62 void setCalendar( Calendar * );
63 void setBaseDate( const QDate & , bool doRepaint = true ); 63 void setBaseDate( const QDate & , bool doRepaint = true );
64 KCal::DateList selectedDates() const { return mSelectedDates; } 64 KCal::DateList selectedDates() const { return mSelectedDates; }
65 NavigatorBar *navigatorBar() const { return mNavigatorBar; } 65 NavigatorBar *navigatorBar() const { return mNavigatorBar; }
66 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} 66 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;}
67 QSize yourSizeHint() { return mySizeHint; } 67 QSize yourSizeHint() { return mySizeHint; }
68 QFont yourFontHint( QSize , bool * b); 68 QFont yourFontHint( QSize , bool * b);
69 bool fontChanged() {return mFontChanged; } 69 bool fontChanged() {return mFontChanged; }
70 void unsetFontChanged() { mFontChanged = false; } 70 void unsetFontChanged() { mFontChanged = false; }
71 KODayMatrix *dayMatrix() { return daymatrix ;} 71 KODayMatrix *dayMatrix() { return daymatrix ;}
72 QSize sizeHint() const; 72 QSize sizeHint() const;
73 QSize sizeHintTwoButtons() const;
73 void changeFont ( QFont fo ); 74 void changeFont ( QFont fo );
74 public slots: 75 public slots:
75 void selectDates( const KCal::DateList & ); 76 void selectDates( const KCal::DateList & );
76 void updateView(); 77 void updateView();
77 void updateConfig(); 78 void updateConfig();
78 void updateDayMatrix(); 79 void updateDayMatrix();
79 80
80 signals: 81 signals:
81 void datesSelected( const KCal::DateList & ); 82 void datesSelected( const KCal::DateList & );
82 void eventDropped( Event * ); 83 void eventDropped( Event * );
83 void weekClicked( const QDate &); 84 void weekClicked( const QDate &);
84 85
85 void goPrevious(); 86 void goPrevious();
86 void goNext(); 87 void goNext();
87 88
88 void goNextMonth(); 89 void goNextMonth();
89 void goPrevMonth(); 90 void goPrevMonth();
90 void goNextYear(); 91 void goNextYear();
91 void goPrevYear(); 92 void goPrevYear();
92 void monthSelected( int ); 93 void monthSelected( int );
93 94
94 // Signals emitted at midnight carrying the new date. 95 // Signals emitted at midnight carrying the new date.
95 void dayPassed( QDate ); 96 void dayPassed( QDate );
96 void monthPassed( QDate ); 97 void monthPassed( QDate );
97 98
98 protected slots: 99 protected slots:
99 100
100 /** 101 /**
101 * Called regularly to see if we need to update the view 102 * Called regularly to see if we need to update the view
102 * wrt. the today box and the month box. Only important 103 * wrt. the today box and the month box. Only important
103 * if you leave KOrganizer idle for long periods of time. 104 * if you leave KOrganizer idle for long periods of time.
104 * 105 *
105 * Until we have a reliable way of setting QTimers to go 106 * Until we have a reliable way of setting QTimers to go
106 * off at a particular wall-clock time, we need this, 107 * off at a particular wall-clock time, we need this,
107 * which calls passedMidnight() at the right moments. 108 * which calls passedMidnight() at the right moments.
108 */ 109 */
109 void possiblyPastMidnight(); 110 void possiblyPastMidnight();
110 111
111 /** handles updating the view when midnight has come by due to idle time. 112 /** handles updating the view when midnight has come by due to idle time.
112 * 113 *
113 */ 114 */
114 void passedMidnight(); 115 void passedMidnight();
115 void slotMonthSelected( int m ); 116 void slotMonthSelected( int m );
116 protected: 117 protected:
117 void updateDates(); 118 void updateDates();
118 119
119 void wheelEvent (QWheelEvent *); 120 void wheelEvent (QWheelEvent *);
120 121
121 bool eventFilter (QObject *,QEvent *); 122 bool eventFilter (QObject *,QEvent *);
122 123
123 private: 124 private:
124 QSize mySizeHint; 125 QSize mySizeHint;
125 bool mFontChanged; 126 bool mFontChanged;
126 int mMonthSignalOffset; 127 int mMonthSignalOffset;
127 NavigatorBar *mNavigatorBar; 128 NavigatorBar *mNavigatorBar;
128 129
129 QFrame *headingSep; 130 QFrame *headingSep;
130 QFrame *weeknumSep; 131 QFrame *weeknumSep;
131 QLabel *headings[7]; 132 QLabel *headings[7];
132 QLabel *weeknos[7]; 133 QLabel *weeknos[7];
133 KODayMatrix *daymatrix; 134 KODayMatrix *daymatrix;
134 135
135 KCal::DateList mSelectedDates; 136 KCal::DateList mSelectedDates;
136 QDate m_MthYr; 137 QDate m_MthYr;
137 int m_fstDayOfWk; 138 int m_fstDayOfWk;
138 bool m_bShowWeekNums; 139 bool m_bShowWeekNums;
139 140
140 int dayNum(int row, int col); 141 int dayNum(int row, int col);
141 int dayToIndex(int dayNum); 142 int dayToIndex(int dayNum);
142 143
143 Calendar *mCalendar; 144 Calendar *mCalendar;
144 KCalendarSystem *mCalendarSystem; 145 KCalendarSystem *mCalendarSystem;
145 146
146 const QString *curHeaders; 147 const QString *curHeaders;
147 148
148 /** used to update the day view periodically, in particular every 149 /** used to update the day view periodically, in particular every
149 * midnight to move the "today" rectangle. 150 * midnight to move the "today" rectangle.
150 */ 151 */
151 QTimer *updateTimer; 152 QTimer *updateTimer;
152 QDate lastDayChecked; 153 QDate lastDayChecked;
153 RolloverType updateRollover; 154 RolloverType updateRollover;
154 155
155 // Disabling copy constructor and assignment operator 156 // Disabling copy constructor and assignment operator
156 KDateNavigator(const KDateNavigator & ); 157 KDateNavigator(const KDateNavigator & );
157 KDateNavigator &operator=(const KDateNavigator &); 158 KDateNavigator &operator=(const KDateNavigator &);
158}; 159};
159 160
160#endif 161#endif
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index e4abbf7..1b4ee52 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -80,190 +80,193 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam
80 mPrevMonth = new QPushButton( mCtrlFrame ); 80 mPrevMonth = new QPushButton( mCtrlFrame );
81 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 81 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
82 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 82 QToolTip::add( mPrevMonth, i18n("Previous Month") );
83 83
84 // Create forward navigation buttons 84 // Create forward navigation buttons
85 mNextMonth = new QPushButton( mCtrlFrame ); 85 mNextMonth = new QPushButton( mCtrlFrame );
86 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 86 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
87 QToolTip::add( mNextMonth, i18n("Next Month") ); 87 QToolTip::add( mNextMonth, i18n("Next Month") );
88 88
89 mPrevWeek = new QPushButton( mCtrlFrame ); 89 mPrevWeek = new QPushButton( mCtrlFrame );
90 mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 90 mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
91 QToolTip::add( mPrevWeek, i18n("Previous Week") ); 91 QToolTip::add( mPrevWeek, i18n("Previous Week") );
92 92
93 // Create forward navigation buttons 93 // Create forward navigation buttons
94 mNextWeek = new QPushButton( mCtrlFrame ); 94 mNextWeek = new QPushButton( mCtrlFrame );
95 mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 95 mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
96 QToolTip::add( mNextWeek, i18n("Next Week") ); 96 QToolTip::add( mNextWeek, i18n("Next Week") );
97 97
98 mNextYear = new QPushButton( mCtrlFrame ); 98 mNextYear = new QPushButton( mCtrlFrame );
99 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 99 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
100 QToolTip::add( mNextYear, i18n("Next Year") ); 100 QToolTip::add( mNextYear, i18n("Next Year") );
101 mSelectMonth = new QPushButton( mCtrlFrame ); 101 mSelectMonth = new QPushButton( mCtrlFrame );
102 // Create month name label 102 // Create month name label
103 //selectMonth->setFont( tfont ); 103 //selectMonth->setFont( tfont );
104 // selectMonth->setAlignment( AlignCenter ); 104 // selectMonth->setAlignment( AlignCenter );
105 //mDateLabel = new QLabel( selectMonth ); 105 //mDateLabel = new QLabel( selectMonth );
106 //mDateLabel->setFont( tfont ); 106 //mDateLabel->setFont( tfont );
107 //mDateLabel->setAlignment( AlignCenter ); 107 //mDateLabel->setAlignment( AlignCenter );
108 if ( QString ( name ) == QString("useBigPixmaps") ) { 108 if ( QString ( name ) == QString("useBigPixmaps") ) {
109 mNextMonth->setFlat( true); 109 mNextMonth->setFlat( true);
110 mNextWeek->setFlat( true); 110 mNextWeek->setFlat( true);
111 mNextYear->setFlat( true); 111 mNextYear->setFlat( true);
112 mSelectMonth->setFlat( true); 112 mSelectMonth->setFlat( true);
113 mPrevYear->setFlat( true); 113 mPrevYear->setFlat( true);
114 mPrevMonth->setFlat( true); 114 mPrevMonth->setFlat( true);
115 mPrevWeek->setFlat( true); 115 mPrevWeek->setFlat( true);
116 } else { 116 } else {
117 mPrevWeek->hide(); 117 mPrevWeek->hide();
118 mNextWeek->hide(); 118 mNextWeek->hide();
119 } 119 }
120 120
121 resetFont( font() ); 121 resetFont( font() );
122 122
123 123
124 // set up control frame layout 124 // set up control frame layout
125 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 125 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
126 ctrlLayout->addWidget( mPrevYear, 3 ); 126 ctrlLayout->addWidget( mPrevYear, 3 );
127 ctrlLayout->addWidget( mPrevMonth, 3 ); 127 ctrlLayout->addWidget( mPrevMonth, 3 );
128 ctrlLayout->addWidget( mPrevWeek, 3 ); 128 ctrlLayout->addWidget( mPrevWeek, 3 );
129 //ctrlLayout->addStretch( 1 ); 129 //ctrlLayout->addStretch( 1 );
130 // ctrlLayout->addSpacing( 1 ); 130 // ctrlLayout->addSpacing( 1 );
131 // ctrlLayout->addWidget( mDateLabel ); 131 // ctrlLayout->addWidget( mDateLabel );
132 ctrlLayout->addWidget( mSelectMonth ); 132 ctrlLayout->addWidget( mSelectMonth );
133 // ctrlLayout->addSpacing( 1 ); 133 // ctrlLayout->addSpacing( 1 );
134 // ctrlLayout->addStretch( 1 ); 134 // ctrlLayout->addStretch( 1 );
135 ctrlLayout->addWidget( mNextWeek, 3 ); 135 ctrlLayout->addWidget( mNextWeek, 3 );
136 ctrlLayout->addWidget( mNextMonth, 3 ); 136 ctrlLayout->addWidget( mNextMonth, 3 );
137 ctrlLayout->addWidget( mNextYear, 3 ); 137 ctrlLayout->addWidget( mNextYear, 3 );
138 138
139 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 139 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
140 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 140 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
141 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 141 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
142 connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); 142 connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) );
143 connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); 143 connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) );
144 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 144 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
145 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 145 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
146 mPrevYear->setFocusPolicy(NoFocus); 146 mPrevYear->setFocusPolicy(NoFocus);
147 mPrevMonth->setFocusPolicy(NoFocus); 147 mPrevMonth->setFocusPolicy(NoFocus);
148 mNextMonth->setFocusPolicy(NoFocus); 148 mNextMonth->setFocusPolicy(NoFocus);
149 mPrevWeek->setFocusPolicy(NoFocus); 149 mPrevWeek->setFocusPolicy(NoFocus);
150 mNextWeek->setFocusPolicy(NoFocus); 150 mNextWeek->setFocusPolicy(NoFocus);
151 mNextYear->setFocusPolicy(NoFocus); 151 mNextYear->setFocusPolicy(NoFocus);
152 mSelectMonth->setFocusPolicy(NoFocus); 152 mSelectMonth->setFocusPolicy(NoFocus);
153 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 153 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
154 154
155} 155}
156 156
157NavigatorBar::~NavigatorBar() 157NavigatorBar::~NavigatorBar()
158{ 158{
159} 159}
160QSize NavigatorBar::sizeHint() const 160QSize NavigatorBar::sizeHint() const
161{ 161{
162 int wid = mCurrentMinWid ; 162 int wid = mCurrentMinWid ;
163 if ( mPrevYear->isVisible() ) 163 if ( mPrevYear->isVisible() )
164 wid += mCurrentButtonMinWid; 164 wid += mCurrentButtonMinWid;
165 if ( mPrevMonth->isVisible() ) 165 if ( mPrevMonth->isVisible() )
166 wid += mCurrentButtonMinWid; 166 wid += mCurrentButtonMinWid;
167 if ( mPrevWeek->isVisible() ) 167 if ( mPrevWeek->isVisible() )
168 wid += mCurrentButtonMinWid; 168 wid += mCurrentButtonMinWid;
169 if ( mNextMonth->isVisible() ) 169 if ( mNextMonth->isVisible() )
170 wid += mCurrentButtonMinWid; 170 wid += mCurrentButtonMinWid;
171 if ( mNextWeek->isVisible() ) 171 if ( mNextWeek->isVisible() )
172 wid += mCurrentButtonMinWid; 172 wid += mCurrentButtonMinWid;
173 if ( mNextYear->isVisible() ) 173 if ( mNextYear->isVisible() )
174 wid += mCurrentButtonMinWid; 174 wid += mCurrentButtonMinWid;
175 //qDebug("ret %d %d ", wid, mCurrentHei); 175 //qDebug("ret %d %d ", wid, mCurrentHei);
176 int add = 2; 176 return QSize ( wid, mCurrentHei );
177 return QSize ( wid+add, mCurrentHei+add ); 177}
178QSize NavigatorBar::sizeHintTwoButtons() const
179{
180 return QSize ( mCurrentMinWid + 2 * mCurrentButtonMinWid , mCurrentHei );
178} 181}
179void NavigatorBar::resetFont ( QFont fo ) 182void NavigatorBar::resetFont ( QFont fo )
180{ 183{
181 184
182 QFont tfont = fo; 185 QFont tfont = fo;
183 if ( QApplication::desktop()->width() >= 480 ) 186 if ( QApplication::desktop()->width() >= 480 )
184 tfont.setPointSize(tfont.pointSize()+2); 187 tfont.setPointSize(tfont.pointSize()+2);
185 tfont.setBold(true); 188 tfont.setBold(true);
186 189
187 mSelectMonth->setFont( tfont ); 190 mSelectMonth->setFont( tfont );
188 // Set minimum width to width of widest month name label 191 // Set minimum width to width of widest month name label
189 int i; 192 int i;
190 int maxwidth = 0; 193 int maxwidth = 0;
191 QFontMetrics fm ( mSelectMonth->font() ); 194 QFontMetrics fm ( mSelectMonth->font() );
192 int width = fm.width("September '00" ); 195 int width = fm.width("September '00" );
193 maxwidth = width+2; 196 maxwidth = width+2;
194 int size = fm.height()+2; 197 int size = fm.height()+2;
195 if ( QApplication::desktop()->width() >= 480 ) { 198 if ( QApplication::desktop()->width() >= 480 ) {
196 size += 6; 199 size += 6;
197 maxwidth+= 6; 200 maxwidth+= 6;
198 } 201 }
199 mSelectMonth->setMinimumWidth( maxwidth ); 202 mSelectMonth->setMinimumWidth( maxwidth );
200 mSelectMonth->setFixedHeight( size ); 203 mSelectMonth->setFixedHeight( size );
201 mPrevYear->setFixedHeight( size ); 204 mPrevYear->setFixedHeight( size );
202 mPrevMonth->setFixedHeight( size ); 205 mPrevMonth->setFixedHeight( size );
203 mPrevWeek->setFixedHeight( size ); 206 mPrevWeek->setFixedHeight( size );
204 mNextMonth->setFixedHeight( size ); 207 mNextMonth->setFixedHeight( size );
205 mNextWeek->setFixedHeight( size ); 208 mNextWeek->setFixedHeight( size );
206 mNextYear->setFixedHeight ( size ); 209 mNextYear->setFixedHeight ( size );
207 mCurrentHei = size; 210 mCurrentHei = size +2;
208 mCurrentMinWid = maxwidth; 211 mCurrentMinWid = maxwidth+2;
209 mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; 212 mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2;
210} 213}
211 214
212void NavigatorBar::showButtons( bool left, bool right ) 215void NavigatorBar::showButtons( bool left, bool right )
213{ 216{
214 if ( left ) { 217 if ( left ) {
215 mPrevYear->show(); 218 mPrevYear->show();
216 mPrevMonth->show(); 219 mPrevMonth->show();
217 } else { 220 } else {
218 mPrevYear->hide(); 221 mPrevYear->hide();
219 mPrevMonth->hide(); 222 mPrevMonth->hide();
220 } 223 }
221 224
222 if ( right ) { 225 if ( right ) {
223 mNextYear->show(); 226 mNextYear->show();
224 mNextMonth->show(); 227 mNextMonth->show();
225 } else { 228 } else {
226 mNextYear->hide(); 229 mNextYear->hide();
227 mNextMonth->hide(); 230 mNextMonth->hide();
228 } 231 }
229 if ( !left && !right ) { 232 if ( !left && !right ) {
230 //mSelectMonth->setMaximumWidth( 1024 ); 233 //mSelectMonth->setMaximumWidth( 1024 );
231 mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 234 mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
232 } 235 }
233} 236}
234 237
235void NavigatorBar::selectMonth() 238void NavigatorBar::selectMonth()
236{ 239{
237 240
238 int month; 241 int month;
239 KPopupFrame* popup = new KPopupFrame(this); 242 KPopupFrame* popup = new KPopupFrame(this);
240 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); 243 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup);
241 // ----- 244 // -----
242 picker->resize(picker->sizeHint()); 245 picker->resize(picker->sizeHint());
243 popup->setMainWidget(picker); 246 popup->setMainWidget(picker);
244 picker->setFocus(); 247 picker->setFocus();
245 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 248 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
246 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) 249 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
247 { 250 {
248 month = picker->getResult(); 251 month = picker->getResult();
249 emit monthSelected ( month ); 252 emit monthSelected ( month );
250 } else { 253 } else {
251 KNotifyClient::beep(); 254 KNotifyClient::beep();
252 } 255 }
253 delete popup; 256 delete popup;
254} 257}
255void NavigatorBar::selectDates( const KCal::DateList &dateList ) 258void NavigatorBar::selectDates( const KCal::DateList &dateList )
256{ 259{
257 if (dateList.count() > 0) { 260 if (dateList.count() > 0) {
258 QDate date = dateList.first(); 261 QDate date = dateList.first();
259 262
260 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 263 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
261 264
262 // compute the label at the top of the navigator 265 // compute the label at the top of the navigator
263 QString dtstr = i18n(calSys->monthName( date )) + " '" + 266 QString dtstr = i18n(calSys->monthName( date )) + " '" +
264 QString::number( calSys->year( date ) ).right(2); 267 QString::number( calSys->year( date ) ).right(2);
265 268
266 mSelectMonth->setText( dtstr ); 269 mSelectMonth->setText( dtstr );
267 } 270 }
268} 271}
269 272
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h
index 5d5aff4..bf6d173 100644
--- a/korganizer/navigatorbar.h
+++ b/korganizer/navigatorbar.h
@@ -1,75 +1,76 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef NAVIGATORBAR_H 24#ifndef NAVIGATORBAR_H
25#define NAVIGATORBAR_H 25#define NAVIGATORBAR_H
26 26
27#include <libkcal/incidencebase.h> 27#include <libkcal/incidencebase.h>
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30 30
31class QPushButton; 31class QPushButton;
32class QFrame; 32class QFrame;
33class QLabel; 33class QLabel;
34 34
35class NavigatorBar: public QWidget 35class NavigatorBar: public QWidget
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); 39 NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 );
40 ~NavigatorBar(); 40 ~NavigatorBar();
41 void showButtons( bool left, bool right ); 41 void showButtons( bool left, bool right );
42 void resetFont ( QFont fo ); 42 void resetFont ( QFont fo );
43 QSize sizeHint() const; 43 QSize sizeHint() const;
44 QSize sizeHintTwoButtons() const;
44 45
45 public slots: 46 public slots:
46 void selectDates( const KCal::DateList & ); 47 void selectDates( const KCal::DateList & );
47 void selectMonth(); 48 void selectMonth();
48 49
49 signals: 50 signals:
50 void goNextMonth(); 51 void goNextMonth();
51 void goPrevMonth(); 52 void goPrevMonth();
52 void goNextWeek(); 53 void goNextWeek();
53 void goPrevWeek(); 54 void goPrevWeek();
54 void goNextYear(); 55 void goNextYear();
55 void goPrevYear(); 56 void goPrevYear();
56 void monthSelected( int ); 57 void monthSelected( int );
57 58
58 private: 59 private:
59 int mCurrentHei; 60 int mCurrentHei;
60 int mCurrentMinWid; 61 int mCurrentMinWid;
61 int mCurrentButtonMinWid; 62 int mCurrentButtonMinWid;
62 QFrame *mCtrlFrame; 63 QFrame *mCtrlFrame;
63 64
64 QPushButton *mPrevYear; 65 QPushButton *mPrevYear;
65 QPushButton *mPrevMonth; 66 QPushButton *mPrevMonth;
66 QPushButton *mNextMonth; 67 QPushButton *mNextMonth;
67 QPushButton *mPrevWeek; 68 QPushButton *mPrevWeek;
68 QPushButton *mNextWeek; 69 QPushButton *mNextWeek;
69 QPushButton *mNextYear; 70 QPushButton *mNextYear;
70 QPushButton *mSelectMonth; 71 QPushButton *mSelectMonth;
71 72
72 //QLabel *mDateLabel; 73 //QLabel *mDateLabel;
73}; 74};
74 75
75#endif 76#endif