-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 1 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 12 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 5 |
3 files changed, 14 insertions, 4 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index cbfc5b2..3f6e29b 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -122,96 +122,97 @@ void DateNavigatorContainer::updateConfig() | |||
122 | n->updateConfig(); | 122 | n->updateConfig(); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
127 | { | 127 | { |
128 | mNavigatorView->selectDates( dateList ); | 128 | mNavigatorView->selectDates( dateList ); |
129 | setBaseDates(); | 129 | setBaseDates(); |
130 | } | 130 | } |
131 | 131 | ||
132 | void DateNavigatorContainer::setBaseDates() | 132 | void DateNavigatorContainer::setBaseDates() |
133 | { | 133 | { |
134 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 134 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
135 | if ( dateList.isEmpty() ) { | 135 | if ( dateList.isEmpty() ) { |
136 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 136 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
137 | } | 137 | } |
138 | QDate baseDate = dateList.first(); | 138 | QDate baseDate = dateList.first(); |
139 | KDateNavigator *n; | 139 | KDateNavigator *n; |
140 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 140 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
141 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); | 141 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); |
142 | n->setBaseDate( baseDate ); | 142 | n->setBaseDate( baseDate ); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void DateNavigatorContainer::resizeEvent( QResizeEvent * ) | 146 | void DateNavigatorContainer::resizeEvent( QResizeEvent * ) |
147 | { | 147 | { |
148 | #if 0 | 148 | #if 0 |
149 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 149 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
150 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 150 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
151 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 151 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
152 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 152 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
153 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 153 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | QSize minSize = mNavigatorView->minimumSizeHint(); | 156 | QSize minSize = mNavigatorView->minimumSizeHint(); |
157 | 157 | ||
158 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 158 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
159 | 159 | ||
160 | int verticalCount = size().height() / minSize.height(); | 160 | int verticalCount = size().height() / minSize.height(); |
161 | int horizontalCount = size().width() / minSize.width(); | 161 | int horizontalCount = size().width() / minSize.width(); |
162 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 162 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
163 | if ( horizontalCount != mHorizontalCount || | 163 | if ( horizontalCount != mHorizontalCount || |
164 | verticalCount != mVerticalCount ) { | 164 | verticalCount != mVerticalCount ) { |
165 | uint count = horizontalCount * verticalCount; | 165 | uint count = horizontalCount * verticalCount; |
166 | if ( count == 0 ) return; | 166 | if ( count == 0 ) return; |
167 | 167 | ||
168 | while ( count > ( mExtraViews.count() + 1 ) ) { | 168 | while ( count > ( mExtraViews.count() + 1 ) ) { |
169 | KDateNavigator *n = new KDateNavigator( this ); | 169 | KDateNavigator *n = new KDateNavigator( this ); |
170 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | ||
170 | mExtraViews.append( n ); | 171 | mExtraViews.append( n ); |
171 | n->setCalendar( mCalendar ); | 172 | n->setCalendar( mCalendar ); |
172 | setBaseDates(); | 173 | setBaseDates(); |
173 | connectNavigatorView( n ); | 174 | connectNavigatorView( n ); |
174 | n->show(); | 175 | n->show(); |
175 | } | 176 | } |
176 | 177 | ||
177 | while ( count < ( mExtraViews.count() + 1 ) ) { | 178 | while ( count < ( mExtraViews.count() + 1 ) ) { |
178 | mExtraViews.removeLast(); | 179 | mExtraViews.removeLast(); |
179 | } | 180 | } |
180 | 181 | ||
181 | mHorizontalCount = horizontalCount; | 182 | mHorizontalCount = horizontalCount; |
182 | mVerticalCount = verticalCount; | 183 | mVerticalCount = verticalCount; |
183 | } | 184 | } |
184 | 185 | ||
185 | int height = size().height() / verticalCount; | 186 | int height = size().height() / verticalCount; |
186 | int width = size().width() / horizontalCount; | 187 | int width = size().width() / horizontalCount; |
187 | 188 | ||
188 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 189 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
189 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 190 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
190 | else bar->showButtons( true, true ); | 191 | else bar->showButtons( true, true ); |
191 | 192 | ||
192 | mNavigatorView->setGeometry(0, | 193 | mNavigatorView->setGeometry(0, |
193 | 0, width, height ); | 194 | 0, width, height ); |
194 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | 195 | for( uint i = 0; i < mExtraViews.count(); ++i ) { |
195 | int x = ( i + 1 ) % horizontalCount; | 196 | int x = ( i + 1 ) % horizontalCount; |
196 | int y = ( i + 1 ) / horizontalCount; | 197 | int y = ( i + 1 ) / horizontalCount; |
197 | 198 | ||
198 | KDateNavigator *view = mExtraViews.at( i ); | 199 | KDateNavigator *view = mExtraViews.at( i ); |
199 | bar = view->navigatorBar(); | 200 | bar = view->navigatorBar(); |
200 | if ( y > 0 ) bar->showButtons( false, false ); | 201 | if ( y > 0 ) bar->showButtons( false, false ); |
201 | else { | 202 | else { |
202 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 203 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
203 | else bar->showButtons( false, false ); | 204 | else bar->showButtons( false, false ); |
204 | } | 205 | } |
205 | view->setGeometry( x * width, | 206 | view->setGeometry( x * width, |
206 | y * height, width, height ); | 207 | y * height, width, height ); |
207 | } | 208 | } |
208 | } | 209 | } |
209 | 210 | ||
210 | QSize DateNavigatorContainer::minimumSizeHint() const | 211 | QSize DateNavigatorContainer::minimumSizeHint() const |
211 | { | 212 | { |
212 | return mNavigatorView->minimumSizeHint(); | 213 | return mNavigatorView->minimumSizeHint(); |
213 | } | 214 | } |
214 | 215 | ||
215 | QSize DateNavigatorContainer::sizeHint() const | 216 | QSize DateNavigatorContainer::sizeHint() const |
216 | { | 217 | { |
217 | return mNavigatorView->sizeHint(); | 218 | return mNavigatorView->sizeHint(); |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index e76a85a..ab9a40f 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -12,156 +12,164 @@ | |||
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 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
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 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::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 | 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 ) ), SIGNAL( monthSelected( 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 | //setFixedSize ( sizeHint() ); | 118 | //setFixedSize ( sizeHint() ); |
119 | } | 119 | } |
120 | void KDateNavigator::slotMonthSelected( int m ) | ||
121 | { | ||
122 | if ( m_MthYr.month() <= mMonthSignalOffset) | ||
123 | m += 12; | ||
124 | int mo = m - mMonthSignalOffset; | ||
125 | emit monthSelected( m - mMonthSignalOffset ); | ||
126 | |||
127 | } | ||
120 | void KDateNavigator::setCalendar( Calendar *cal ) | 128 | void KDateNavigator::setCalendar( Calendar *cal ) |
121 | { | 129 | { |
122 | daymatrix->setCalendar( cal ); | 130 | daymatrix->setCalendar( cal ); |
123 | } | 131 | } |
124 | 132 | ||
125 | void KDateNavigator::setBaseDate( const QDate &date ) | 133 | void KDateNavigator::setBaseDate( const QDate &date ) |
126 | { | 134 | { |
127 | m_MthYr = date; | 135 | m_MthYr = date; |
128 | 136 | ||
129 | updateDates(); | 137 | updateDates(); |
130 | updateView(); | 138 | updateView(); |
131 | 139 | ||
132 | KCal::DateList dates; | 140 | KCal::DateList dates; |
133 | dates.append( date ); | 141 | dates.append( date ); |
134 | mNavigatorBar->selectDates( dates ); | 142 | mNavigatorBar->selectDates( dates ); |
135 | 143 | ||
136 | daymatrix->clearSelection(); | 144 | daymatrix->clearSelection(); |
137 | daymatrix->repaint(); | 145 | daymatrix->repaint(); |
138 | } | 146 | } |
139 | 147 | ||
140 | void KDateNavigator::enableRollover(RolloverType r) | 148 | void KDateNavigator::enableRollover(RolloverType r) |
141 | { | 149 | { |
142 | switch(r) | 150 | switch(r) |
143 | { | 151 | { |
144 | case None : | 152 | case None : |
145 | if (updateTimer) | 153 | if (updateTimer) |
146 | { | 154 | { |
147 | updateTimer->stop(); | 155 | updateTimer->stop(); |
148 | delete updateTimer; | 156 | delete updateTimer; |
149 | updateTimer=0L; | 157 | updateTimer=0L; |
150 | } | 158 | } |
151 | break; | 159 | break; |
152 | case FollowDay : | 160 | case FollowDay : |
153 | case FollowMonth : | 161 | case FollowMonth : |
154 | if (!updateTimer) | 162 | if (!updateTimer) |
155 | { | 163 | { |
156 | updateTimer = new QTimer(this); | 164 | updateTimer = new QTimer(this); |
157 | QObject::connect(updateTimer,SIGNAL(timeout()), | 165 | QObject::connect(updateTimer,SIGNAL(timeout()), |
158 | this,SLOT(possiblyPastMidnight())); | 166 | this,SLOT(possiblyPastMidnight())); |
159 | } | 167 | } |
160 | updateTimer->start(0,true); | 168 | updateTimer->start(0,true); |
161 | lastDayChecked = QDate::currentDate(); | 169 | lastDayChecked = QDate::currentDate(); |
162 | } | 170 | } |
163 | updateRollover=r; | 171 | updateRollover=r; |
164 | } | 172 | } |
165 | 173 | ||
166 | 174 | ||
167 | KDateNavigator::~KDateNavigator() | 175 | KDateNavigator::~KDateNavigator() |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 0aeb77a..56822fa 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -18,133 +18,134 @@ | |||
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 | ||
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 & ); | 63 | void setBaseDate( const QDate & ); |
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 | 66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} | |
67 | public slots: | 67 | public slots: |
68 | void selectDates( const KCal::DateList & ); | 68 | void selectDates( const KCal::DateList & ); |
69 | void updateView(); | 69 | void updateView(); |
70 | void updateConfig(); | 70 | void updateConfig(); |
71 | void updateDayMatrix(); | 71 | void updateDayMatrix(); |
72 | 72 | ||
73 | signals: | 73 | signals: |
74 | void datesSelected( const KCal::DateList & ); | 74 | void datesSelected( const KCal::DateList & ); |
75 | void eventDropped( Event * ); | 75 | void eventDropped( Event * ); |
76 | void weekClicked( const QDate &); | 76 | void weekClicked( const QDate &); |
77 | 77 | ||
78 | void goPrevious(); | 78 | void goPrevious(); |
79 | void goNext(); | 79 | void goNext(); |
80 | 80 | ||
81 | void goNextMonth(); | 81 | void goNextMonth(); |
82 | void goPrevMonth(); | 82 | void goPrevMonth(); |
83 | void goNextYear(); | 83 | void goNextYear(); |
84 | void goPrevYear(); | 84 | void goPrevYear(); |
85 | void monthSelected( int ); | 85 | void monthSelected( int ); |
86 | 86 | ||
87 | // Signals emitted at midnight carrying the new date. | 87 | // Signals emitted at midnight carrying the new date. |
88 | void dayPassed( QDate ); | 88 | void dayPassed( QDate ); |
89 | void monthPassed( QDate ); | 89 | void monthPassed( QDate ); |
90 | 90 | ||
91 | protected slots: | 91 | protected slots: |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Called regularly to see if we need to update the view | 94 | * Called regularly to see if we need to update the view |
95 | * wrt. the today box and the month box. Only important | 95 | * wrt. the today box and the month box. Only important |
96 | * if you leave KOrganizer idle for long periods of time. | 96 | * if you leave KOrganizer idle for long periods of time. |
97 | * | 97 | * |
98 | * Until we have a reliable way of setting QTimers to go | 98 | * Until we have a reliable way of setting QTimers to go |
99 | * off at a particular wall-clock time, we need this, | 99 | * off at a particular wall-clock time, we need this, |
100 | * which calls passedMidnight() at the right moments. | 100 | * which calls passedMidnight() at the right moments. |
101 | */ | 101 | */ |
102 | void possiblyPastMidnight(); | 102 | void possiblyPastMidnight(); |
103 | 103 | ||
104 | /** handles updating the view when midnight has come by due to idle time. | 104 | /** handles updating the view when midnight has come by due to idle time. |
105 | * | 105 | * |
106 | */ | 106 | */ |
107 | void passedMidnight(); | 107 | void passedMidnight(); |
108 | 108 | void slotMonthSelected( int m ); | |
109 | protected: | 109 | protected: |
110 | void updateDates(); | 110 | void updateDates(); |
111 | 111 | ||
112 | void wheelEvent (QWheelEvent *); | 112 | void wheelEvent (QWheelEvent *); |
113 | 113 | ||
114 | bool eventFilter (QObject *,QEvent *); | 114 | bool eventFilter (QObject *,QEvent *); |
115 | 115 | ||
116 | private: | 116 | private: |
117 | int mMonthSignalOffset; | ||
117 | NavigatorBar *mNavigatorBar; | 118 | NavigatorBar *mNavigatorBar; |
118 | 119 | ||
119 | QFrame *headingSep; | 120 | QFrame *headingSep; |
120 | QFrame *weeknumSep; | 121 | QFrame *weeknumSep; |
121 | QLabel *headings[7]; | 122 | QLabel *headings[7]; |
122 | QLabel *weeknos[7]; | 123 | QLabel *weeknos[7]; |
123 | KODayMatrix *daymatrix; | 124 | KODayMatrix *daymatrix; |
124 | 125 | ||
125 | KCal::DateList mSelectedDates; | 126 | KCal::DateList mSelectedDates; |
126 | QDate m_MthYr; | 127 | QDate m_MthYr; |
127 | int m_fstDayOfWk; | 128 | int m_fstDayOfWk; |
128 | bool m_bShowWeekNums; | 129 | bool m_bShowWeekNums; |
129 | 130 | ||
130 | int dayNum(int row, int col); | 131 | int dayNum(int row, int col); |
131 | int dayToIndex(int dayNum); | 132 | int dayToIndex(int dayNum); |
132 | 133 | ||
133 | Calendar *mCalendar; | 134 | Calendar *mCalendar; |
134 | KCalendarSystem *mCalendarSystem; | 135 | KCalendarSystem *mCalendarSystem; |
135 | 136 | ||
136 | const QString *curHeaders; | 137 | const QString *curHeaders; |
137 | 138 | ||
138 | /** used to update the day view periodically, in particular every | 139 | /** used to update the day view periodically, in particular every |
139 | * midnight to move the "today" rectangle. | 140 | * midnight to move the "today" rectangle. |
140 | */ | 141 | */ |
141 | QTimer *updateTimer; | 142 | QTimer *updateTimer; |
142 | QDate lastDayChecked; | 143 | QDate lastDayChecked; |
143 | RolloverType updateRollover; | 144 | RolloverType updateRollover; |
144 | 145 | ||
145 | // Disabling copy constructor and assignment operator | 146 | // Disabling copy constructor and assignment operator |
146 | KDateNavigator(const KDateNavigator & ); | 147 | KDateNavigator(const KDateNavigator & ); |
147 | KDateNavigator &operator=(const KDateNavigator &); | 148 | KDateNavigator &operator=(const KDateNavigator &); |
148 | }; | 149 | }; |
149 | 150 | ||
150 | #endif | 151 | #endif |