author | zautrix <zautrix> | 2005-03-19 21:14:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-19 21:14:06 (UTC) |
commit | 6c913e8e5fb19ef3c5a74b94757aeabb9b808cc4 (patch) (unidiff) | |
tree | 0facf1e6f5040d1345f1e067efe44d2382a3981a /korganizer | |
parent | 88e1a262374ba8cb018469f7873df45b12050c67 (diff) | |
download | kdepimpi-6c913e8e5fb19ef3c5a74b94757aeabb9b808cc4.zip kdepimpi-6c913e8e5fb19ef3c5a74b94757aeabb9b808cc4.tar.gz kdepimpi-6c913e8e5fb19ef3c5a74b94757aeabb9b808cc4.tar.bz2 |
month select fix
-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 | |||
@@ -154,32 +154,33 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * ) | |||
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; |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index e76a85a..ab9a40f 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -44,46 +44,46 @@ | |||
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 | ||
@@ -104,32 +104,40 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | |||
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 | ||
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 0aeb77a..56822fa 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -50,33 +50,33 @@ class KDateNavigator: public QFrame | |||
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(); |
@@ -92,41 +92,42 @@ class KDateNavigator: public QFrame | |||
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 | ||