author | zautrix <zautrix> | 2005-03-21 09:58:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-21 09:58:16 (UTC) |
commit | 5b9e0451514d65ab576b51e0f9d3515fa6b9e4e6 (patch) (unidiff) | |
tree | c3e1f114768876675b6ab6463083d03dff321b4e | |
parent | fd372d97084c401aacb999e89f8bdd94056a3b59 (diff) | |
download | kdepimpi-5b9e0451514d65ab576b51e0f9d3515fa6b9e4e6.zip kdepimpi-5b9e0451514d65ab576b51e0f9d3515fa6b9e4e6.tar.gz kdepimpi-5b9e0451514d65ab576b51e0f9d3515fa6b9e4e6.tar.bz2 |
nf
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 4 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 14 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 1 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 11 | ||||
-rw-r--r-- | korganizer/navigatorbar.h | 1 |
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 | |||
@@ -115,116 +115,116 @@ void DateNavigatorContainer::updateView() | |||
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | void DateNavigatorContainer::updateConfig() | 118 | void 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 | ||
127 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 127 | void 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 | ||
138 | void DateNavigatorContainer::setBaseDates() | 138 | void 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 | ||
154 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 154 | void 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 | ||
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 92a0ac2..a5dbc5d 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -89,119 +89,131 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | |||
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 | } |
121 | void KDateNavigator::changeFont ( QFont fo ) | 121 | void KDateNavigator::changeFont ( QFont fo ) |
122 | { | 122 | { |
123 | setFont( fo ); | 123 | setFont( fo ); |
124 | mNavigatorBar->resetFont( fo ); | 124 | mNavigatorBar->resetFont( fo ); |
125 | } | 125 | } |
126 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 126 | QFont 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 | } |
148 | QSize KDateNavigator::sizeHint() const | 148 | QSize 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 | } |
160 | QSize 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 | } | ||
160 | void KDateNavigator::slotMonthSelected( int m ) | 172 | void 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 | } |
168 | void KDateNavigator::setCalendar( Calendar *cal ) | 180 | void KDateNavigator::setCalendar( Calendar *cal ) |
169 | { | 181 | { |
170 | daymatrix->setCalendar( cal ); | 182 | daymatrix->setCalendar( cal ); |
171 | } | 183 | } |
172 | 184 | ||
173 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 185 | void 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 | ||
189 | void KDateNavigator::enableRollover(RolloverType r) | 201 | void 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())); |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 3177687..d1f32b6 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -25,96 +25,97 @@ | |||
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 | ||
34 | class QPushButton; | 34 | class QPushButton; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class KCalendarSystem; | 37 | class KCalendarSystem; |
38 | 38 | ||
39 | class NavigatorBar; | 39 | class NavigatorBar; |
40 | 40 | ||
41 | class KDateNavigator: public QFrame | 41 | class 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 | ||
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index e4abbf7..1b4ee52 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -128,129 +128,132 @@ NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *nam | |||
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 | ||
157 | NavigatorBar::~NavigatorBar() | 157 | NavigatorBar::~NavigatorBar() |
158 | { | 158 | { |
159 | } | 159 | } |
160 | QSize NavigatorBar::sizeHint() const | 160 | QSize 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 | } |
178 | QSize NavigatorBar::sizeHintTwoButtons() const | ||
179 | { | ||
180 | return QSize ( mCurrentMinWid + 2 * mCurrentButtonMinWid , mCurrentHei ); | ||
178 | } | 181 | } |
179 | void NavigatorBar::resetFont ( QFont fo ) | 182 | void 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 | ||
212 | void NavigatorBar::showButtons( bool left, bool right ) | 215 | void 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 | ||
235 | void NavigatorBar::selectMonth() | 238 | void 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 | } |
255 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 258 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
256 | { | 259 | { |
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 | ||
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QFrame; | 32 | class QFrame; |
33 | class QLabel; | 33 | class QLabel; |
34 | 34 | ||
35 | class NavigatorBar: public QWidget | 35 | class 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 |