-rw-r--r-- | korganizer/kdatenavigator.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index d62402f..6438c9a 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -26,193 +26,193 @@ | |||
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 | 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 | headings[i]->installEventFilter(this); | 86 | headings[i]->installEventFilter(this); |
87 | 87 | ||
88 | topLayout->addWidget(headings[i],1,i+1); | 88 | topLayout->addWidget(headings[i],1,i+1); |
89 | } | 89 | } |
90 | 90 | ||
91 | // Create the weeknumber labels | 91 | // Create the weeknumber labels |
92 | for( i = 0; i < 6; i++ ) { | 92 | for( i = 0; i < 6; i++ ) { |
93 | weeknos[i] = new QLabel(this); | 93 | weeknos[i] = new QLabel(this); |
94 | weeknos[i]->setAlignment(AlignCenter); | 94 | weeknos[i]->setAlignment(AlignCenter); |
95 | //weeknos[i]->setFont(QFont("Arial", 10)); | 95 | //weeknos[i]->setFont(QFont("Arial", 10)); |
96 | if(!m_bShowWeekNums) { | 96 | if(!m_bShowWeekNums) { |
97 | weeknos[i]->hide(); | 97 | weeknos[i]->hide(); |
98 | } | 98 | } |
99 | weeknos[i]->installEventFilter(this); | 99 | weeknos[i]->installEventFilter(this); |
100 | 100 | ||
101 | topLayout->addWidget(weeknos[i],i+2,0); | 101 | topLayout->addWidget(weeknos[i],i+2,0); |
102 | } | 102 | } |
103 | 103 | ||
104 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 104 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
105 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 105 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
106 | daymatrix->setLineWidth(1); | 106 | daymatrix->setLineWidth(1); |
107 | 107 | ||
108 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 108 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
109 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 109 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
110 | 110 | ||
111 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 111 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
112 | SIGNAL( eventDropped( Event * ) ) ); | 112 | SIGNAL( eventDropped( Event * ) ) ); |
113 | 113 | ||
114 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 114 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
115 | 115 | ||
116 | // read settings from configuration file. | 116 | // read settings from configuration file. |
117 | updateConfig(); | 117 | updateConfig(); |
118 | enableRollover(FollowMonth); | 118 | enableRollover(FollowMonth); |
119 | mySizeHint = sizeHintTwoButtons(); | 119 | mySizeHint = sizeHintTwoButtons(); |
120 | myFullSizeHint = sizeHintTwoButtons( 4 ); | 120 | myFullSizeHint = sizeHintTwoButtons( 4 ); |
121 | mFontChanged = false; | 121 | mFontChanged = false; |
122 | resize ( mySizeHint ); | 122 | resize ( 0,0 ); |
123 | } | 123 | } |
124 | void KDateNavigator::changeFont ( QFont fo ) | 124 | void KDateNavigator::changeFont ( QFont fo ) |
125 | { | 125 | { |
126 | setFont( fo ); | 126 | setFont( fo ); |
127 | mNavigatorBar->resetFont( fo ); | 127 | mNavigatorBar->resetFont( fo ); |
128 | } | 128 | } |
129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) |
130 | { | 130 | { |
131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
132 | *b = false; | 132 | *b = false; |
133 | int fontPoint = fo.pointSize(); | 133 | int fontPoint = fo.pointSize(); |
134 | while ( fontPoint > 5 ) { | 134 | while ( fontPoint > 5 ) { |
135 | --fontPoint; | 135 | --fontPoint; |
136 | fo.setPointSize( fontPoint ); | 136 | fo.setPointSize( fontPoint ); |
137 | setFont( fo ); | 137 | setFont( fo ); |
138 | mFontChanged = true; | 138 | mFontChanged = true; |
139 | mNavigatorBar->resetFont( fo ); | 139 | mNavigatorBar->resetFont( fo ); |
140 | QSize sh = sizeHintTwoButtons( 2 ); | 140 | QSize sh = sizeHintTwoButtons( 2 ); |
141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); |
142 | if ( si.width() > sh.width() && si.height() > sh.height()) { | 142 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
143 | if ( si.width() / sh.width() == 1 ) { | 143 | if ( si.width() / sh.width() == 1 ) { |
144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) | 144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) |
145 | continue; | 145 | continue; |
146 | } | 146 | } |
147 | *b = true; | 147 | *b = true; |
148 | //qDebug("fooooooooooooooooooooooouuuuund "); | 148 | //qDebug("fooooooooooooooooooooooouuuuund "); |
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | } | 151 | } |
152 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | 152 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); |
153 | return fo; | 153 | return fo; |
154 | } | 154 | } |
155 | QSize KDateNavigator::sizeHint() const | 155 | QSize KDateNavigator::sizeHint() const |
156 | { | 156 | { |
157 | QFontMetrics fm ( font() ); | 157 | QFontMetrics fm ( font() ); |
158 | QSize day = daymatrix->sizeHint(); | 158 | QSize day = daymatrix->sizeHint(); |
159 | QSize nav = mNavigatorBar->sizeHint(); | 159 | QSize nav = mNavigatorBar->sizeHint(); |
160 | int wid = fm.width( "30") + day.width()+3; | 160 | int wid = fm.width( "30") + day.width()+3; |
161 | int hei = fm.height() +day.height()+nav.height()+2; | 161 | int hei = fm.height() +day.height()+nav.height()+2; |
162 | if ( wid < nav.width() ) | 162 | if ( wid < nav.width() ) |
163 | wid = nav.width() ; | 163 | wid = nav.width() ; |
164 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 164 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
165 | return QSize ( wid, hei ); | 165 | return QSize ( wid, hei ); |
166 | } | 166 | } |
167 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const | 167 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const |
168 | { | 168 | { |
169 | QFontMetrics fm ( font() ); | 169 | QFontMetrics fm ( font() ); |
170 | QSize day = daymatrix->sizeHint(); | 170 | QSize day = daymatrix->sizeHint(); |
171 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); | 171 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); |
172 | int wid = fm.width( "30") + day.width()+3; | 172 | int wid = fm.width( "30") + day.width()+3; |
173 | int hei = fm.height() +day.height()+nav.height()+2; | 173 | int hei = fm.height() +day.height()+nav.height()+2; |
174 | if ( wid < nav.width() ) | 174 | if ( wid < nav.width() ) |
175 | wid = nav.width() ; | 175 | wid = nav.width() ; |
176 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 176 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
177 | return QSize ( wid, hei ); | 177 | return QSize ( wid, hei ); |
178 | } | 178 | } |
179 | void KDateNavigator::slotMonthSelected( int m ) | 179 | void KDateNavigator::slotMonthSelected( int m ) |
180 | { | 180 | { |
181 | if ( m_MthYr.month() <= mMonthSignalOffset) | 181 | if ( m_MthYr.month() <= mMonthSignalOffset) |
182 | m += 12; | 182 | m += 12; |
183 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); | 183 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
184 | emit monthSelected( m - mMonthSignalOffset ); | 184 | emit monthSelected( m - mMonthSignalOffset ); |
185 | 185 | ||
186 | } | 186 | } |
187 | void KDateNavigator::setCalendar( Calendar *cal ) | 187 | void KDateNavigator::setCalendar( Calendar *cal ) |
188 | { | 188 | { |
189 | daymatrix->setCalendar( cal ); | 189 | daymatrix->setCalendar( cal ); |
190 | } | 190 | } |
191 | 191 | ||
192 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 192 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
193 | { | 193 | { |
194 | m_MthYr = date; | 194 | m_MthYr = date; |
195 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); | 195 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); |
196 | 196 | ||
197 | updateDates(); | 197 | updateDates(); |
198 | updateView(); | 198 | updateView(); |
199 | 199 | ||
200 | KCal::DateList dates; | 200 | KCal::DateList dates; |
201 | dates.append( date ); | 201 | dates.append( date ); |
202 | mNavigatorBar->selectDates( dates ); | 202 | mNavigatorBar->selectDates( dates ); |
203 | 203 | ||
204 | daymatrix->clearSelection(); | 204 | daymatrix->clearSelection(); |
205 | if ( doRepaint ) | 205 | if ( doRepaint ) |
206 | daymatrix->repaint( false ); | 206 | daymatrix->repaint( false ); |
207 | } | 207 | } |
208 | 208 | ||
209 | void KDateNavigator::enableRollover(RolloverType r) | 209 | void KDateNavigator::enableRollover(RolloverType r) |
210 | { | 210 | { |
211 | switch(r) | 211 | switch(r) |
212 | { | 212 | { |
213 | case None : | 213 | case None : |
214 | if (updateTimer) | 214 | if (updateTimer) |
215 | { | 215 | { |
216 | updateTimer->stop(); | 216 | updateTimer->stop(); |
217 | delete updateTimer; | 217 | delete updateTimer; |
218 | updateTimer=0L; | 218 | updateTimer=0L; |