-rw-r--r-- | korganizer/kdatenavigator.cpp | 3 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 226 | ||||
-rw-r--r-- | korganizer/komonthview.h | 14 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 3 |
4 files changed, 175 insertions, 71 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 6438c9a..0cb767f 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,314 +1,315 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 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 | 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 ( 0,0 ); | 122 | resize ( 3,3 ); |
123 | |||
123 | } | 124 | } |
124 | void KDateNavigator::changeFont ( QFont fo ) | 125 | void KDateNavigator::changeFont ( QFont fo ) |
125 | { | 126 | { |
126 | setFont( fo ); | 127 | setFont( fo ); |
127 | mNavigatorBar->resetFont( fo ); | 128 | mNavigatorBar->resetFont( fo ); |
128 | } | 129 | } |
129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 130 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) |
130 | { | 131 | { |
131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 132 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
132 | *b = false; | 133 | *b = false; |
133 | int fontPoint = fo.pointSize(); | 134 | int fontPoint = fo.pointSize(); |
134 | while ( fontPoint > 5 ) { | 135 | while ( fontPoint > 5 ) { |
135 | --fontPoint; | 136 | --fontPoint; |
136 | fo.setPointSize( fontPoint ); | 137 | fo.setPointSize( fontPoint ); |
137 | setFont( fo ); | 138 | setFont( fo ); |
138 | mFontChanged = true; | 139 | mFontChanged = true; |
139 | mNavigatorBar->resetFont( fo ); | 140 | mNavigatorBar->resetFont( fo ); |
140 | QSize sh = sizeHintTwoButtons( 2 ); | 141 | QSize sh = sizeHintTwoButtons( 2 ); |
141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 142 | //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()) { | 143 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
143 | if ( si.width() / sh.width() == 1 ) { | 144 | if ( si.width() / sh.width() == 1 ) { |
144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) | 145 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) |
145 | continue; | 146 | continue; |
146 | } | 147 | } |
147 | *b = true; | 148 | *b = true; |
148 | //qDebug("fooooooooooooooooooooooouuuuund "); | 149 | //qDebug("fooooooooooooooooooooooouuuuund "); |
149 | break; | 150 | break; |
150 | } | 151 | } |
151 | } | 152 | } |
152 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | 153 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); |
153 | return fo; | 154 | return fo; |
154 | } | 155 | } |
155 | QSize KDateNavigator::sizeHint() const | 156 | QSize KDateNavigator::sizeHint() const |
156 | { | 157 | { |
157 | QFontMetrics fm ( font() ); | 158 | QFontMetrics fm ( font() ); |
158 | QSize day = daymatrix->sizeHint(); | 159 | QSize day = daymatrix->sizeHint(); |
159 | QSize nav = mNavigatorBar->sizeHint(); | 160 | QSize nav = mNavigatorBar->sizeHint(); |
160 | int wid = fm.width( "30") + day.width()+3; | 161 | int wid = fm.width( "30") + day.width()+3; |
161 | int hei = fm.height() +day.height()+nav.height()+2; | 162 | int hei = fm.height() +day.height()+nav.height()+2; |
162 | if ( wid < nav.width() ) | 163 | if ( wid < nav.width() ) |
163 | wid = nav.width() ; | 164 | wid = nav.width() ; |
164 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 165 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
165 | return QSize ( wid, hei ); | 166 | return QSize ( wid, hei ); |
166 | } | 167 | } |
167 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const | 168 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const |
168 | { | 169 | { |
169 | QFontMetrics fm ( font() ); | 170 | QFontMetrics fm ( font() ); |
170 | QSize day = daymatrix->sizeHint(); | 171 | QSize day = daymatrix->sizeHint(); |
171 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); | 172 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); |
172 | int wid = fm.width( "30") + day.width()+3; | 173 | int wid = fm.width( "30") + day.width()+3; |
173 | int hei = fm.height() +day.height()+nav.height()+2; | 174 | int hei = fm.height() +day.height()+nav.height()+2; |
174 | if ( wid < nav.width() ) | 175 | if ( wid < nav.width() ) |
175 | wid = nav.width() ; | 176 | wid = nav.width() ; |
176 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 177 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
177 | return QSize ( wid, hei ); | 178 | return QSize ( wid, hei ); |
178 | } | 179 | } |
179 | void KDateNavigator::slotMonthSelected( int m ) | 180 | void KDateNavigator::slotMonthSelected( int m ) |
180 | { | 181 | { |
181 | if ( m_MthYr.month() <= mMonthSignalOffset) | 182 | if ( m_MthYr.month() <= mMonthSignalOffset) |
182 | m += 12; | 183 | m += 12; |
183 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); | 184 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
184 | emit monthSelected( m - mMonthSignalOffset ); | 185 | emit monthSelected( m - mMonthSignalOffset ); |
185 | 186 | ||
186 | } | 187 | } |
187 | void KDateNavigator::setCalendar( Calendar *cal ) | 188 | void KDateNavigator::setCalendar( Calendar *cal ) |
188 | { | 189 | { |
189 | daymatrix->setCalendar( cal ); | 190 | daymatrix->setCalendar( cal ); |
190 | } | 191 | } |
191 | 192 | ||
192 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 193 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
193 | { | 194 | { |
194 | m_MthYr = date; | 195 | m_MthYr = date; |
195 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); | 196 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); |
196 | 197 | ||
197 | updateDates(); | 198 | updateDates(); |
198 | updateView(); | 199 | updateView(); |
199 | 200 | ||
200 | KCal::DateList dates; | 201 | KCal::DateList dates; |
201 | dates.append( date ); | 202 | dates.append( date ); |
202 | mNavigatorBar->selectDates( dates ); | 203 | mNavigatorBar->selectDates( dates ); |
203 | 204 | ||
204 | daymatrix->clearSelection(); | 205 | daymatrix->clearSelection(); |
205 | if ( doRepaint ) | 206 | if ( doRepaint ) |
206 | daymatrix->repaint( false ); | 207 | daymatrix->repaint( false ); |
207 | } | 208 | } |
208 | 209 | ||
209 | void KDateNavigator::enableRollover(RolloverType r) | 210 | void KDateNavigator::enableRollover(RolloverType r) |
210 | { | 211 | { |
211 | switch(r) | 212 | switch(r) |
212 | { | 213 | { |
213 | case None : | 214 | case None : |
214 | if (updateTimer) | 215 | if (updateTimer) |
215 | { | 216 | { |
216 | updateTimer->stop(); | 217 | updateTimer->stop(); |
217 | delete updateTimer; | 218 | delete updateTimer; |
218 | updateTimer=0L; | 219 | updateTimer=0L; |
219 | } | 220 | } |
220 | break; | 221 | break; |
221 | case FollowDay : | 222 | case FollowDay : |
222 | case FollowMonth : | 223 | case FollowMonth : |
223 | if (!updateTimer) | 224 | if (!updateTimer) |
224 | { | 225 | { |
225 | updateTimer = new QTimer(this); | 226 | updateTimer = new QTimer(this); |
226 | QObject::connect(updateTimer,SIGNAL(timeout()), | 227 | QObject::connect(updateTimer,SIGNAL(timeout()), |
227 | this,SLOT(possiblyPastMidnight())); | 228 | this,SLOT(possiblyPastMidnight())); |
228 | } | 229 | } |
229 | updateTimer->start(0,true); | 230 | updateTimer->start(0,true); |
230 | lastDayChecked = QDate::currentDate(); | 231 | lastDayChecked = QDate::currentDate(); |
231 | } | 232 | } |
232 | updateRollover=r; | 233 | updateRollover=r; |
233 | } | 234 | } |
234 | 235 | ||
235 | 236 | ||
236 | KDateNavigator::~KDateNavigator() | 237 | KDateNavigator::~KDateNavigator() |
237 | { | 238 | { |
238 | } | 239 | } |
239 | 240 | ||
240 | 241 | ||
241 | void KDateNavigator::passedMidnight() | 242 | void KDateNavigator::passedMidnight() |
242 | { | 243 | { |
243 | QDate today = QDate::currentDate(); | 244 | QDate today = QDate::currentDate(); |
244 | bool emitMonth = false; | 245 | bool emitMonth = false; |
245 | 246 | ||
246 | if (today.month() != lastDayChecked.month()) | 247 | if (today.month() != lastDayChecked.month()) |
247 | { | 248 | { |
248 | if (updateRollover==FollowMonth && | 249 | if (updateRollover==FollowMonth && |
249 | daymatrix->isEndOfMonth()) { | 250 | daymatrix->isEndOfMonth()) { |
250 | goNextMonth(); | 251 | goNextMonth(); |
251 | emitMonth=true; | 252 | emitMonth=true; |
252 | } | 253 | } |
253 | } | 254 | } |
254 | daymatrix->recalculateToday(); | 255 | daymatrix->recalculateToday(); |
255 | daymatrix->repaint( false ); | 256 | daymatrix->repaint( false ); |
256 | emit dayPassed(today); | 257 | emit dayPassed(today); |
257 | if (emitMonth) { emit monthPassed(today); } | 258 | if (emitMonth) { emit monthPassed(today); } |
258 | } | 259 | } |
259 | 260 | ||
260 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 261 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
261 | { | 262 | { |
262 | if (lastDayChecked!=QDate::currentDate()) | 263 | if (lastDayChecked!=QDate::currentDate()) |
263 | { | 264 | { |
264 | passedMidnight(); | 265 | passedMidnight(); |
265 | lastDayChecked=QDate::currentDate(); | 266 | lastDayChecked=QDate::currentDate(); |
266 | } | 267 | } |
267 | // Set the timer to go off 1 second after midnight | 268 | // Set the timer to go off 1 second after midnight |
268 | // or after 8 minutes, whichever comes first. | 269 | // or after 8 minutes, whichever comes first. |
269 | if (updateTimer) | 270 | if (updateTimer) |
270 | { | 271 | { |
271 | QTime now = QTime::currentTime(); | 272 | QTime now = QTime::currentTime(); |
272 | QTime midnight = QTime(23,59,59); | 273 | QTime midnight = QTime(23,59,59); |
273 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 274 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
274 | 275 | ||
275 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 276 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
276 | //.arg(now.toString()).arg(midnight.toString())); | 277 | //.arg(now.toString()).arg(midnight.toString())); |
277 | 278 | ||
278 | updateTimer->stop(); | 279 | updateTimer->stop(); |
279 | updateTimer->start(msecsWait,true); | 280 | updateTimer->start(msecsWait,true); |
280 | } | 281 | } |
281 | } | 282 | } |
282 | 283 | ||
283 | void KDateNavigator::updateDates() | 284 | void KDateNavigator::updateDates() |
284 | { | 285 | { |
285 | // Find the first day of the week of the current month. | 286 | // Find the first day of the week of the current month. |
286 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 287 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
287 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 288 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
288 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 289 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
289 | //int di = d1 - d2 + 1; | 290 | //int di = d1 - d2 + 1; |
290 | dayone = dayone.addDays( -d2 + 1 ); | 291 | dayone = dayone.addDays( -d2 + 1 ); |
291 | 292 | ||
292 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 293 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
293 | 294 | ||
294 | // If month begins on Monday and Monday is first day of week, | 295 | // If month begins on Monday and Monday is first day of week, |
295 | // month should begin on second line. Sunday doesn't have this problem. | 296 | // month should begin on second line. Sunday doesn't have this problem. |
296 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 297 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
297 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 298 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
298 | 299 | ||
299 | // update the matrix dates | 300 | // update the matrix dates |
300 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 301 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
301 | 302 | ||
302 | 303 | ||
303 | daymatrix->updateView(dayone.addDays(index)); | 304 | daymatrix->updateView(dayone.addDays(index)); |
304 | //each updateDates is followed by an updateView -> repaint is issued there ! | 305 | //each updateDates is followed by an updateView -> repaint is issued there ! |
305 | // daymatrix->repaint(); | 306 | // daymatrix->repaint(); |
306 | } | 307 | } |
307 | 308 | ||
308 | void KDateNavigator::updateDayMatrix() | 309 | void KDateNavigator::updateDayMatrix() |
309 | { | 310 | { |
310 | daymatrix->updateView(); | 311 | daymatrix->updateView(); |
311 | //daymatrix->repaint(); | 312 | //daymatrix->repaint(); |
312 | } | 313 | } |
313 | 314 | ||
314 | 315 | ||
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 050bfb9..38cfda7 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -5,1006 +5,1097 @@ | |||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | } | 86 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 88 | { |
89 | 89 | ||
90 | } | 90 | } |
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
92 | { | 92 | { |
93 | QListBoxItem* item = itemAt ( p ); | 93 | QListBoxItem* item = itemAt ( p ); |
94 | if ( ! item ) { | 94 | if ( ! item ) { |
95 | return i18n("Click in the cell\nto add an event!"); | 95 | return i18n("Click in the cell\nto add an event!"); |
96 | } | 96 | } |
97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
98 | KOPrefs::instance()->mWTshowDetails, | 98 | KOPrefs::instance()->mWTshowDetails, |
99 | KOPrefs::instance()->mWTshowCreated, | 99 | KOPrefs::instance()->mWTshowCreated, |
100 | KOPrefs::instance()->mWTshowChanged); | 100 | KOPrefs::instance()->mWTshowChanged); |
101 | } | 101 | } |
102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
103 | { | 103 | { |
104 | 104 | ||
105 | switch(e->key()) { | 105 | switch(e->key()) { |
106 | case Key_Right: | 106 | case Key_Right: |
107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
108 | { | 108 | { |
109 | e->ignore(); | 109 | e->ignore(); |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | scrollBy(10,0); | 112 | scrollBy(10,0); |
113 | break; | 113 | break; |
114 | case Key_Left: | 114 | case Key_Left: |
115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
116 | { | 116 | { |
117 | e->ignore(); | 117 | e->ignore(); |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | scrollBy(-10,0); | 120 | scrollBy(-10,0); |
121 | break; | 121 | break; |
122 | case Key_Up: | 122 | case Key_Up: |
123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | setCurrentItem((currentItem()+count()-1)%count()); | 127 | setCurrentItem((currentItem()+count()-1)%count()); |
128 | if(!itemVisible(currentItem())) { | 128 | if(!itemVisible(currentItem())) { |
129 | if((unsigned int) currentItem() == (count()-1)) { | 129 | if((unsigned int) currentItem() == (count()-1)) { |
130 | setTopItem(currentItem()-numItemsVisible()+1); | 130 | setTopItem(currentItem()-numItemsVisible()+1); |
131 | } else { | 131 | } else { |
132 | setTopItem(topItem()-1); | 132 | setTopItem(topItem()-1); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | break; | 135 | break; |
136 | case Key_Down: | 136 | case Key_Down: |
137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
138 | e->ignore(); | 138 | e->ignore(); |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | setCurrentItem((currentItem()+1)%count()); | 141 | setCurrentItem((currentItem()+1)%count()); |
142 | if(!itemVisible(currentItem())) { | 142 | if(!itemVisible(currentItem())) { |
143 | if(currentItem() == 0) { | 143 | if(currentItem() == 0) { |
144 | setTopItem(0); | 144 | setTopItem(0); |
145 | } else { | 145 | } else { |
146 | setTopItem(topItem()+1); | 146 | setTopItem(topItem()+1); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | break; | 149 | break; |
150 | case Key_I: | 150 | case Key_I: |
151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
152 | e->ignore(); | 152 | e->ignore(); |
153 | break; | 153 | break; |
154 | case Key_Shift: | 154 | case Key_Shift: |
155 | emit shiftDown(); | 155 | emit shiftDown(); |
156 | break; | 156 | break; |
157 | default: | 157 | default: |
158 | e->ignore(); | 158 | e->ignore(); |
159 | break; | 159 | break; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | void KNoScrollListBox::oneDown() | 163 | void KNoScrollListBox::oneDown() |
164 | { | 164 | { |
165 | setCurrentItem((currentItem()+1)%count()); | 165 | setCurrentItem((currentItem()+1)%count()); |
166 | if(!itemVisible(currentItem())) { | 166 | if(!itemVisible(currentItem())) { |
167 | if(currentItem() == 0) { | 167 | if(currentItem() == 0) { |
168 | setTopItem(0); | 168 | setTopItem(0); |
169 | } else { | 169 | } else { |
170 | setTopItem(topItem()+1); | 170 | setTopItem(topItem()+1); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | } | 173 | } |
174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
175 | { | 175 | { |
176 | switch(e->key()) { | 176 | switch(e->key()) { |
177 | case Key_Shift: | 177 | case Key_Shift: |
178 | emit shiftUp(); | 178 | emit shiftUp(); |
179 | break; | 179 | break; |
180 | default: | 180 | default: |
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
186 | { | 186 | { |
187 | QListBox::mousePressEvent(e); | 187 | QListBox::mousePressEvent(e); |
188 | 188 | ||
189 | if(e->button() == RightButton) { | 189 | if(e->button() == RightButton) { |
190 | emit rightClick(); | 190 | emit rightClick(); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
195 | : QListBoxItem() | 195 | : QListBoxItem() |
196 | { | 196 | { |
197 | mblockRepaint = true; | ||
197 | setText( s ); | 198 | setText( s ); |
198 | mMultiday = 0; | 199 | mMultiday = 0; |
199 | mIncidence = incidence; | 200 | mIncidence = incidence; |
200 | mDate = qd; | 201 | mDate = qd; |
201 | mRecur = false; | 202 | mRecur = false; |
202 | mAlarm = false; | 203 | mAlarm = false; |
203 | mReply = false; | 204 | mReply = false; |
204 | mInfo = false; | 205 | mInfo = false; |
206 | //qDebug("NEWWWWWWWWWWWWW "); | ||
207 | } | ||
208 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | ||
209 | { | ||
210 | setText( s ); | ||
211 | mMultiday = 0; | ||
212 | mIncidence = incidence; | ||
213 | mDate = qd; | ||
214 | mRecur = false; | ||
215 | mAlarm = false; | ||
216 | mReply = false; | ||
217 | mInfo = false; | ||
218 | //qDebug("recucleeeeeeeeeeeeeeeee "); | ||
205 | } | 219 | } |
206 | 220 | ||
207 | void MonthViewItem::paint(QPainter *p) | 221 | void MonthViewItem::paint(QPainter *p) |
208 | { | 222 | { |
223 | if ( mblockRepaint ) { | ||
224 | //qDebug("block "); | ||
225 | return; | ||
226 | } | ||
227 | //qDebug("NON block "); | ||
209 | #if QT_VERSION >= 0x030000 | 228 | #if QT_VERSION >= 0x030000 |
210 | bool sel = isSelected(); | 229 | bool sel = isSelected(); |
211 | #else | 230 | #else |
212 | bool sel = selected(); | 231 | bool sel = selected(); |
213 | #endif | 232 | #endif |
214 | 233 | ||
215 | 234 | ||
216 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 235 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
217 | { | 236 | { |
218 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 237 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
219 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 238 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
220 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 239 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
221 | } | 240 | } |
222 | int x = 1; | 241 | int x = 1; |
223 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 242 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
224 | int size = PIXMAP_SIZE; | 243 | int size = PIXMAP_SIZE; |
225 | if ( QApplication::desktop()->width() < 300 ) | 244 | if ( QApplication::desktop()->width() < 300 ) |
226 | size = 3; | 245 | size = 3; |
227 | int heihei = height( listBox () ); | 246 | int heihei = height( listBox () ); |
228 | int y = (heihei - size -1 ) /2; | 247 | int y = (heihei - size -1 ) /2; |
229 | 248 | ||
230 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 249 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
231 | if ( mInfo ) { | 250 | if ( mInfo ) { |
232 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 251 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
233 | x += size + 1; | 252 | x += size + 1; |
234 | } | 253 | } |
235 | if ( mRecur ) { | 254 | if ( mRecur ) { |
236 | p->fillRect ( x, y,size,size, Qt::blue ); | 255 | p->fillRect ( x, y,size,size, Qt::blue ); |
237 | x += size + 1; | 256 | x += size + 1; |
238 | } | 257 | } |
239 | if ( mAlarm ) { | 258 | if ( mAlarm ) { |
240 | p->fillRect ( x, y,size,size, Qt::red ); | 259 | p->fillRect ( x, y,size,size, Qt::red ); |
241 | x += size + 1; | 260 | x += size + 1; |
242 | } | 261 | } |
243 | if ( mReply ) { | 262 | if ( mReply ) { |
244 | p->fillRect ( x, y,size,size, Qt::yellow ); | 263 | p->fillRect ( x, y,size,size, Qt::yellow ); |
245 | x += size + 1; | 264 | x += size + 1; |
246 | } | 265 | } |
247 | } | 266 | } |
248 | if ( mMultiday ) { | 267 | if ( mMultiday ) { |
249 | int yyy = y+(size/2); | 268 | int yyy = y+(size/2); |
250 | int sizeM = size+2; | 269 | int sizeM = size+2; |
251 | p->setBrush( QBrush::SolidPattern ); | 270 | p->setBrush( QBrush::SolidPattern ); |
252 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 271 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
253 | if ( mMultiday == 2 || mMultiday == 3 ) { | 272 | if ( mMultiday == 2 || mMultiday == 3 ) { |
254 | QPointArray pa ( 3 ); | 273 | QPointArray pa ( 3 ); |
255 | pa.setPoint (0, x, yyy ); | 274 | pa.setPoint (0, x, yyy ); |
256 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 275 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
257 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 276 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
258 | p->drawPolygon( pa ); | 277 | p->drawPolygon( pa ); |
259 | } | 278 | } |
260 | if ( mMultiday == 2 || mMultiday == 1 ) { | 279 | if ( mMultiday == 2 || mMultiday == 1 ) { |
261 | QPointArray pa ( 3 ); | 280 | QPointArray pa ( 3 ); |
262 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 281 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
263 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 282 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
264 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 283 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
265 | p->drawPolygon( pa ); | 284 | p->drawPolygon( pa ); |
266 | } | 285 | } |
267 | if ( mMultiday == 1 ) { | 286 | if ( mMultiday == 1 ) { |
268 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 287 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
269 | 288 | ||
270 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 289 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
271 | } | 290 | } |
272 | if ( mMultiday == 3 ) { | 291 | if ( mMultiday == 3 ) { |
273 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 292 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
274 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 293 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
275 | 294 | ||
276 | } | 295 | } |
277 | x += sizeM/2 + 1; | 296 | x += sizeM/2 + 1; |
278 | x += sizeM + 1; | 297 | x += sizeM + 1; |
279 | } | 298 | } |
280 | 299 | ||
281 | if ( mIncidence->type() == "Todo" ){ | 300 | if ( mIncidence->type() == "Todo" ){ |
282 | Todo* td = ( Todo* ) mIncidence; | 301 | Todo* td = ( Todo* ) mIncidence; |
283 | if ( td->isCompleted() ) { | 302 | if ( td->isCompleted() ) { |
284 | int half = size/2; | 303 | int half = size/2; |
285 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 304 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
286 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 305 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
287 | x += half+half + 4; | 306 | x += half+half + 4; |
288 | 307 | ||
289 | } else { | 308 | } else { |
290 | int val = td->percentComplete()/20; | 309 | int val = td->percentComplete()/20; |
291 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); | 310 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); |
292 | p->drawRect ( x, y-1,7,size+2); | 311 | p->drawRect ( x, y-1,7,size+2); |
293 | x += size + 3; | 312 | x += size + 3; |
294 | } | 313 | } |
295 | } | 314 | } |
296 | QFontMetrics fm = p->fontMetrics(); | 315 | QFontMetrics fm = p->fontMetrics(); |
297 | int yPos; | 316 | int yPos; |
298 | int pmheight = size; | 317 | int pmheight = size; |
299 | if( pmheight < fm.height() ) | 318 | if( pmheight < fm.height() ) |
300 | yPos = fm.ascent() + fm.leading()/2; | 319 | yPos = fm.ascent() + fm.leading()/2; |
301 | else | 320 | else |
302 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 321 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
303 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 322 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
304 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 323 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
305 | p->drawText( x, yPos, text() ); | 324 | p->drawText( x, yPos, text() ); |
306 | if ( mIncidence->cancelled() ) { | 325 | if ( mIncidence->cancelled() ) { |
307 | int wid = fm.width( text() ); | 326 | int wid = fm.width( text() ); |
308 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); | 327 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); |
309 | } | 328 | } |
310 | 329 | ||
311 | } | 330 | } |
312 | 331 | ||
313 | int MonthViewItem::height(const QListBox *lb) const | 332 | int MonthViewItem::height(const QListBox *lb) const |
314 | { | 333 | { |
315 | int ret = 10; | 334 | int ret = 10; |
316 | if ( lb ) | 335 | if ( lb ) |
317 | ret = lb->fontMetrics().lineSpacing()+1; | 336 | ret = lb->fontMetrics().lineSpacing()+1; |
318 | return ret; | 337 | return ret; |
319 | } | 338 | } |
320 | 339 | ||
321 | int MonthViewItem::width(const QListBox *lb) const | 340 | int MonthViewItem::width(const QListBox *lb) const |
322 | { | 341 | { |
323 | 342 | ||
324 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 343 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
325 | int size = PIXMAP_SIZE; | 344 | int size = PIXMAP_SIZE; |
326 | if ( QApplication::desktop()->width() < 300 ) | 345 | if ( QApplication::desktop()->width() < 300 ) |
327 | size = 3; | 346 | size = 3; |
328 | int x = 1; | 347 | int x = 1; |
329 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 348 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
330 | if ( mInfo ) { | 349 | if ( mInfo ) { |
331 | x += size + 1; | 350 | x += size + 1; |
332 | } | 351 | } |
333 | if( mRecur ) { | 352 | if( mRecur ) { |
334 | x += size+1; | 353 | x += size+1; |
335 | } | 354 | } |
336 | if( mAlarm ) { | 355 | if( mAlarm ) { |
337 | x += size+1; | 356 | x += size+1; |
338 | } | 357 | } |
339 | if( mReply ) { | 358 | if( mReply ) { |
340 | x += size+1; | 359 | x += size+1; |
341 | } | 360 | } |
342 | } | 361 | } |
343 | if( mMultiday ) { | 362 | if( mMultiday ) { |
344 | x += size+1+2+size/2; | 363 | x += size+1+2+size/2; |
345 | } | 364 | } |
346 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 365 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
347 | } | 366 | } |
348 | if ( ! lb ) | 367 | if ( ! lb ) |
349 | return 10; | 368 | return 10; |
350 | //qDebug("ret wid %d ", lb->width()); | 369 | //qDebug("ret wid %d ", lb->width()); |
351 | return lb->width(); | 370 | return lb->width(); |
352 | } | 371 | } |
353 | 372 | ||
354 | 373 | ||
355 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 374 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
356 | : QWidget( par ), | 375 | : KNoScrollListBox( par ), |
357 | mMonthView( parent ) | 376 | mMonthView( parent ) |
358 | { | 377 | { |
359 | 378 | ||
379 | mCurrentAvailItem = 0; | ||
360 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 380 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
361 | 381 | currentPalette = 0; | |
362 | // mLabel = new QLabel( this );QPushButton | 382 | // mLabel = new QLabel( this );QPushButton |
363 | mLabel = new QPushButton( this ); | 383 | mLabel = new QPushButton( this ); |
364 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 384 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
365 | //mLabel->setLineWidth( 1 ); | 385 | //mLabel->setLineWidth( 1 ); |
366 | //mLabel->setAlignment( AlignCenter ); | 386 | //mLabel->setAlignment( AlignCenter ); |
367 | mLabel->setFlat( true ); | 387 | mLabel->setFlat( true ); |
368 | mLabel->setFocusPolicy(NoFocus); | 388 | mLabel->setFocusPolicy(NoFocus); |
369 | mItemList = new KNoScrollListBox( this ); | 389 | //mItemList = new KNoScrollListBox( this ); |
370 | mItemList->setMinimumSize( 10, 10 ); | 390 | setMinimumSize( 10, 10 ); |
371 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 391 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
372 | mItemList->setLineWidth( 1 ); | 392 | setLineWidth( 1 ); |
373 | //topLayout->addWidget( mItemList ); | 393 | //topLayout->addWidget( mItemList ); |
374 | mLabel->raise(); | 394 | mLabel->raise(); |
375 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 395 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
376 | mStandardPalette = palette(); | 396 | mStandardPalette = palette(); |
377 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 397 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
378 | 398 | ||
379 | enableScrollBars( false ); | 399 | enableScrollBars( false ); |
380 | updateConfig(); | 400 | updateConfig(); |
381 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 401 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
382 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 402 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
383 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 403 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
384 | SLOT( defaultAction( QListBoxItem * ) ) ); | 404 | SLOT( defaultAction( QListBoxItem * ) ) ); |
385 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 405 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
386 | const QPoint &) ), | 406 | const QPoint &) ), |
387 | SLOT( contextMenu( QListBoxItem * ) ) ); | 407 | SLOT( contextMenu( QListBoxItem * ) ) ); |
388 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 408 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
389 | SLOT( selection( QListBoxItem * ) ) ); | 409 | SLOT( selection( QListBoxItem * ) ) ); |
390 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 410 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
391 | SLOT( cellClicked( QListBoxItem * ) ) ); | 411 | SLOT( cellClicked( QListBoxItem * ) ) ); |
392 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 412 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
393 | SLOT( selection( QListBoxItem * ) ) ); | 413 | SLOT( selection( QListBoxItem * ) ) ); |
394 | } | 414 | } |
395 | #ifdef DESKTOP_VERSION | 415 | #ifdef DESKTOP_VERSION |
396 | QToolTipGroup *MonthViewCell::toolTipGroup() | 416 | QToolTipGroup *MonthViewCell::toolTipGroup() |
397 | { | 417 | { |
398 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 418 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
399 | return mToolTipGroup; | 419 | return mToolTipGroup; |
400 | } | 420 | } |
401 | #endif | 421 | #endif |
402 | 422 | ||
403 | void MonthViewCell::setDate( const QDate &date ) | 423 | void MonthViewCell::setDate( const QDate &date ) |
404 | { | 424 | { |
405 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 425 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
406 | mDate = date; | 426 | mDate = date; |
407 | 427 | ||
408 | 428 | ||
409 | 429 | ||
410 | //resizeEvent( 0 ); | 430 | //resizeEvent( 0 ); |
411 | } | 431 | } |
412 | 432 | ||
413 | QDate MonthViewCell::date() const | 433 | QDate MonthViewCell::date() const |
414 | { | 434 | { |
415 | return mDate; | 435 | return mDate; |
416 | } | 436 | } |
417 | 437 | ||
418 | void MonthViewCell::setPrimary( bool primary ) | 438 | void MonthViewCell::setPrimary( bool primary ) |
419 | { | 439 | { |
420 | mPrimary = primary; | 440 | mPrimary = primary; |
421 | //setMyPalette(); | 441 | //setMyPalette(); |
422 | } | 442 | } |
423 | void MonthViewCell::setMyPalette() | 443 | void MonthViewCell::setMyPalette() |
424 | { | 444 | { |
425 | 445 | ||
426 | if ( mHoliday) { | 446 | if ( mHoliday) { |
447 | if ( currentPalette == 1 ) return; | ||
427 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 448 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
428 | mItemList->setPalette( mHolidayPalette ); | 449 | setPalette( mHolidayPalette ); |
450 | //mLabel->setPalette( mHolidayPalette ); | ||
451 | currentPalette = 1; | ||
452 | |||
429 | } else { | 453 | } else { |
430 | if ( mPrimary ) { | 454 | if ( mPrimary ) { |
455 | if ( currentPalette == 2 ) return; | ||
431 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 456 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
432 | mItemList->setPalette( mPrimaryPalette ); | 457 | //mLabel->setPalette( mPrimaryPalette ); |
458 | setPalette( mPrimaryPalette ); | ||
459 | currentPalette = 2; | ||
460 | |||
433 | } else { | 461 | } else { |
434 | mItemList->setPalette( mNonPrimaryPalette ); | 462 | if ( currentPalette == 3 ) return; |
435 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 463 | setPalette( mNonPrimaryPalette ); |
464 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | ||
465 | //mLabel->setPalette( mNonPrimaryPalette );; | ||
466 | currentPalette = 3; | ||
436 | } | 467 | } |
437 | } | 468 | } |
438 | //QPalette pal = palette(); | 469 | //QPalette pal = palette(); |
439 | 470 | ||
440 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 471 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
441 | } | 472 | } |
442 | QPalette MonthViewCell::getPalette () | 473 | QPalette MonthViewCell::getPalette () |
443 | { | 474 | { |
444 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 475 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
445 | return mStandardPalette; | 476 | return mStandardPalette; |
446 | if ( mHoliday) { | 477 | if ( mHoliday) { |
447 | return mHolidayPalette ; | 478 | return mHolidayPalette ; |
448 | } else { | 479 | } else { |
449 | if ( mPrimary ) { | 480 | if ( mPrimary ) { |
450 | return mPrimaryPalette ; | 481 | return mPrimaryPalette ; |
451 | } | 482 | } |
452 | } | 483 | } |
453 | return mNonPrimaryPalette; | 484 | return mNonPrimaryPalette; |
454 | } | 485 | } |
455 | bool MonthViewCell::isPrimary() const | 486 | bool MonthViewCell::isPrimary() const |
456 | { | 487 | { |
457 | return mPrimary; | 488 | return mPrimary; |
458 | } | 489 | } |
459 | 490 | ||
460 | void MonthViewCell::setHoliday( bool holiday ) | 491 | void MonthViewCell::setHoliday( bool holiday ) |
461 | { | 492 | { |
462 | mHoliday = holiday; | 493 | mHoliday = holiday; |
463 | //setMyPalette(); | 494 | //setMyPalette(); |
464 | } | 495 | } |
465 | 496 | ||
466 | void MonthViewCell::setHoliday( const QString &holiday ) | 497 | void MonthViewCell::setHoliday( const QString &holiday ) |
467 | { | 498 | { |
468 | mHolidayString = holiday; | 499 | mHolidayString = holiday; |
469 | 500 | ||
470 | if ( !holiday.isEmpty() ) { | 501 | if ( !holiday.isEmpty() ) { |
471 | setHoliday( true ); | 502 | setHoliday( true ); |
472 | } | 503 | } |
473 | } | 504 | } |
474 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | ||
475 | { | ||
476 | |||
477 | e->ignore(); | ||
478 | |||
479 | } | ||
480 | 505 | ||
481 | void MonthViewCell::startUpdateCell() | 506 | void MonthViewCell::startUpdateCell() |
482 | { | 507 | { |
483 | 508 | ||
484 | mItemList->setFocusPolicy(NoFocus); | 509 | setFocusPolicy(NoFocus); |
485 | if ( !mMonthView->isUpdatePossible() ) | 510 | if ( !mMonthView->isUpdatePossible() ) |
486 | return; | 511 | return; |
487 | 512 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | |
513 | while ( mitem ) { | ||
514 | mitem->setBlockRepaint( true ); | ||
515 | mitem = (MonthViewItem *)mitem->next(); | ||
516 | } | ||
488 | /* | 517 | /* |
489 | if ( !isVisible() ){ | 518 | if ( !isVisible() ){ |
490 | return; | 519 | return; |
491 | } | 520 | } |
492 | */ | 521 | */ |
493 | // qDebug("MonthViewCell::updateCell() "); | 522 | // qDebug("MonthViewCell::updateCell() "); |
494 | setPrimary( mDate.month()%2 ); | 523 | setPrimary( mDate.month()%2 ); |
495 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 524 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
496 | if ( mDate == QDate::currentDate() ) { | 525 | if ( mDate == QDate::currentDate() ) { |
497 | mItemList->setLineWidth( 3 ); | 526 | setLineWidth( 3 ); |
498 | } else { | 527 | } else { |
499 | mItemList->setLineWidth( 1 ); | 528 | setLineWidth( 1 ); |
500 | } | 529 | } |
501 | mItemList->clear(); | 530 | mCurrentAvailItem = (MonthViewItem*) firstItem (); |
531 | //clear(); | ||
502 | 532 | ||
503 | #ifdef DESKTOP_VERSION | 533 | #ifdef DESKTOP_VERSION |
504 | QToolTip::remove(this); | 534 | QToolTip::remove(this); |
505 | #endif | 535 | #endif |
506 | mToolTip.clear(); | 536 | mToolTip.clear(); |
507 | //qApp->processEvents(); | 537 | //qApp->processEvents(); |
538 | #if 0 | ||
508 | if ( !mHolidayString.isEmpty() ) { | 539 | if ( !mHolidayString.isEmpty() ) { |
509 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 540 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
510 | item->setPalette( mHolidayPalette ); | 541 | item->setPalette( mHolidayPalette ); |
511 | mItemList->insertItem( item ); | 542 | insertItem( item ); |
512 | mToolTip.append ( mHolidayString ); | 543 | mToolTip.append ( mHolidayString ); |
513 | } | 544 | } |
545 | #endif | ||
514 | } | 546 | } |
515 | 547 | ||
516 | void MonthViewCell::insertEvent(Event *event) | 548 | void MonthViewCell::insertEvent(Event *event) |
517 | { | 549 | { |
518 | QString mToolTipText; | 550 | QString mToolTipText; |
519 | mItemList->setFocusPolicy(WheelFocus); | 551 | bool insertNewItem = false; |
552 | setFocusPolicy(WheelFocus); | ||
520 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 553 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
521 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 554 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
522 | return; | 555 | return; |
523 | else | 556 | else |
524 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 557 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
525 | return; | 558 | return; |
526 | } | 559 | } |
527 | 560 | ||
528 | if ( event->isHoliday()) { | 561 | if ( event->isHoliday()) { |
529 | setHoliday( true ); | 562 | setHoliday( true ); |
530 | if ( mDate.dayOfWeek() == 7 ) | 563 | if ( mDate.dayOfWeek() == 7 ) |
531 | mItemList->setLineWidth( 3 ); | 564 | setLineWidth( 3 ); |
532 | } | 565 | } |
533 | QString text; | 566 | QString text; |
534 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 567 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
535 | if (event->isMultiDay()) { | 568 | if (event->isMultiDay()) { |
536 | QString prefix = "<->";multiday = 2; | 569 | QString prefix = "<->";multiday = 2; |
537 | QString time; | 570 | QString time; |
538 | if ( event->doesRecur() ) { | 571 | if ( event->doesRecur() ) { |
539 | if ( event->recursOn( mDate) ) { | 572 | if ( event->recursOn( mDate) ) { |
540 | prefix ="->" ;multiday = 1; | 573 | prefix ="->" ;multiday = 1; |
541 | } | 574 | } |
542 | else { | 575 | else { |
543 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 576 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
544 | if ( event->recursOn( mDate.addDays( -days)) ) { | 577 | if ( event->recursOn( mDate.addDays( -days)) ) { |
545 | prefix ="<-" ;multiday = 3; | 578 | prefix ="<-" ;multiday = 3; |
546 | } | 579 | } |
547 | } | 580 | } |
548 | 581 | ||
549 | } else { | 582 | } else { |
550 | if (mDate == event->dtStart().date()) { | 583 | if (mDate == event->dtStart().date()) { |
551 | prefix ="->" ;multiday = 1; | 584 | prefix ="->" ;multiday = 1; |
552 | } else if (mDate == event->dtEnd().date()) { | 585 | } else if (mDate == event->dtEnd().date()) { |
553 | prefix ="<-" ;multiday = 3; | 586 | prefix ="<-" ;multiday = 3; |
554 | } | 587 | } |
555 | } | 588 | } |
556 | if ( !event->doesFloat() ) { | 589 | if ( !event->doesFloat() ) { |
557 | if ( mDate == event->dtStart().date () ) | 590 | if ( mDate == event->dtStart().date () ) |
558 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 591 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
559 | else if ( mDate == event->dtEnd().date () ) | 592 | else if ( mDate == event->dtEnd().date () ) |
560 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 593 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
561 | 594 | ||
562 | } | 595 | } |
563 | text = time + event->summary(); | 596 | text = time + event->summary(); |
564 | mToolTipText += prefix + text; | 597 | mToolTipText += prefix + text; |
565 | } else { | 598 | } else { |
566 | if (event->doesFloat()) { | 599 | if (event->doesFloat()) { |
567 | text = event->summary(); | 600 | text = event->summary(); |
568 | mToolTipText += text; | 601 | mToolTipText += text; |
569 | } | 602 | } |
570 | else { | 603 | else { |
571 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 604 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
572 | text += " " + event->summary(); | 605 | text += " " + event->summary(); |
573 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 606 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
574 | } | 607 | } |
575 | } | 608 | } |
576 | 609 | MonthViewItem *item ; | |
577 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 610 | if ( mCurrentAvailItem ) { |
611 | item = mCurrentAvailItem; | ||
612 | mCurrentAvailItem = (MonthViewItem*) item->next(); | ||
613 | item->recycle( event, mDate, text ); | ||
614 | } else { | ||
615 | if ( mAvailItemList.count() ) { | ||
616 | item = mAvailItemList.first(); | ||
617 | mAvailItemList.remove( item ); | ||
618 | item->recycle( event, mDate, text ); | ||
619 | insertNewItem = true; | ||
620 | } else { | ||
621 | insertNewItem = true; | ||
622 | item = new MonthViewItem( event, mDate, text ); | ||
623 | } | ||
624 | } | ||
578 | QPalette pal; | 625 | QPalette pal; |
579 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 626 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
580 | QStringList categories = event->categories(); | 627 | QStringList categories = event->categories(); |
581 | QString cat = categories.first(); | 628 | QString cat = categories.first(); |
582 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 629 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
583 | pal = getPalette(); | 630 | pal = getPalette(); |
584 | if (cat.isEmpty()) { | 631 | if (cat.isEmpty()) { |
585 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 632 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
586 | } else { | 633 | } else { |
587 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 634 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
588 | } | 635 | } |
589 | 636 | ||
590 | } else { | 637 | } else { |
591 | if (cat.isEmpty()) { | 638 | if (cat.isEmpty()) { |
592 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 639 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
593 | } else { | 640 | } else { |
594 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 641 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
595 | } | 642 | } |
596 | } | 643 | } |
597 | 644 | ||
598 | } else { | 645 | } else { |
599 | pal = mStandardPalette ; | 646 | pal = mStandardPalette ; |
600 | } | 647 | } |
601 | item->setPalette( pal ); | 648 | item->setPalette( pal ); |
602 | item->setRecur( event->recurrence()->doesRecur() ); | 649 | item->setRecur( event->recurrence()->doesRecur() ); |
603 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 650 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
604 | item->setMoreInfo( event->description().length() > 0 ); | 651 | item->setMoreInfo( event->description().length() > 0 ); |
605 | #ifdef DESKTOP_VERSION | 652 | #ifdef DESKTOP_VERSION |
606 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 653 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
607 | KOPrefs::instance()->email()); | 654 | KOPrefs::instance()->email()); |
608 | if ( me != 0 ) { | 655 | if ( me != 0 ) { |
609 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 656 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
610 | item->setReply(true && multiday < 2); | 657 | item->setReply(true && multiday < 2); |
611 | else | 658 | else |
612 | item->setReply(false); | 659 | item->setReply(false); |
613 | } else | 660 | } else |
614 | item->setReply(false); | 661 | item->setReply(false); |
615 | #endif | 662 | #endif |
616 | item->setMultiDay( multiday ); | 663 | item->setMultiDay( multiday ); |
617 | mItemList->insertItem( item ); | 664 | if ( insertNewItem) |
665 | insertItem( item ); | ||
618 | mToolTip.append( mToolTipText ); | 666 | mToolTip.append( mToolTipText ); |
619 | } | 667 | } |
620 | void MonthViewCell::insertTodo(Todo *todo) | 668 | void MonthViewCell::insertTodo(Todo *todo) |
621 | { | 669 | { |
622 | mItemList->setFocusPolicy(WheelFocus); | 670 | bool insertNewItem = false; |
671 | setFocusPolicy(WheelFocus); | ||
623 | QString text; | 672 | QString text; |
624 | if (todo->hasDueDate()) { | 673 | if (todo->hasDueDate()) { |
625 | if (!todo->doesFloat()) { | 674 | if (!todo->doesFloat()) { |
626 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 675 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
627 | text += " "; | 676 | text += " "; |
628 | } | 677 | } |
629 | } | 678 | } |
630 | text += todo->summary(); | 679 | text += todo->summary(); |
631 | 680 | MonthViewItem *item ; | |
632 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 681 | if ( mCurrentAvailItem ) { |
682 | item = mCurrentAvailItem; | ||
683 | mCurrentAvailItem = (MonthViewItem*) item->next(); | ||
684 | item->recycle( todo, mDate, text ); | ||
685 | } else { | ||
686 | if ( mAvailItemList.count() ) { | ||
687 | item = mAvailItemList.first(); | ||
688 | mAvailItemList.remove( item ); | ||
689 | item->recycle( todo, mDate, text ); | ||
690 | insertNewItem = true; | ||
691 | } else { | ||
692 | insertNewItem = true; | ||
693 | item = new MonthViewItem( todo, mDate, text ); | ||
694 | } | ||
695 | } | ||
696 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | ||
633 | //item->setPalette( mStandardPalette ); | 697 | //item->setPalette( mStandardPalette ); |
634 | QPalette pal; | 698 | QPalette pal; |
635 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 699 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
636 | QStringList categories = todo->categories(); | 700 | QStringList categories = todo->categories(); |
637 | QString cat = categories.first(); | 701 | QString cat = categories.first(); |
638 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 702 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
639 | pal = getPalette(); | 703 | pal = getPalette(); |
640 | if (cat.isEmpty()) { | 704 | if (cat.isEmpty()) { |
641 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 705 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
642 | } else { | 706 | } else { |
643 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 707 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
644 | } | 708 | } |
645 | 709 | ||
646 | } else { | 710 | } else { |
647 | if (cat.isEmpty()) { | 711 | if (cat.isEmpty()) { |
648 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 712 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
649 | } else { | 713 | } else { |
650 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 714 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
651 | } | 715 | } |
652 | } | 716 | } |
653 | 717 | ||
654 | } else { | 718 | } else { |
655 | pal = mStandardPalette ; | 719 | pal = mStandardPalette ; |
656 | } | 720 | } |
657 | item->setPalette( pal ); | 721 | item->setPalette( pal ); |
658 | item->setRecur( todo->recurrence()->doesRecur() ); | 722 | item->setRecur( todo->recurrence()->doesRecur() ); |
659 | item->setAlarm( todo->isAlarmEnabled() ); | 723 | item->setAlarm( todo->isAlarmEnabled() ); |
660 | item->setMoreInfo( todo->description().length() > 0 ); | 724 | item->setMoreInfo( todo->description().length() > 0 ); |
661 | mItemList->insertItem( item ); | 725 | if ( insertNewItem) |
726 | insertItem( item ); | ||
662 | mToolTip.append( text ); | 727 | mToolTip.append( text ); |
663 | } | 728 | } |
729 | void MonthViewCell::repaintfinishUpdateCell() | ||
730 | { | ||
731 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | ||
732 | while ( mitem ) { | ||
733 | mitem->setBlockRepaint( false ); | ||
734 | updateItem ( mitem ); | ||
735 | mitem = (MonthViewItem *)mitem->next(); | ||
736 | } | ||
737 | } | ||
664 | void MonthViewCell::finishUpdateCell() | 738 | void MonthViewCell::finishUpdateCell() |
665 | { | 739 | { |
740 | while ( mCurrentAvailItem ) { | ||
741 | MonthViewItem *item = mCurrentAvailItem; | ||
742 | mCurrentAvailItem = (MonthViewItem *)item->next(); | ||
743 | mAvailItemList.append( item ); | ||
744 | takeItem ( item ); | ||
745 | } | ||
746 | |||
747 | |||
666 | #ifdef DESKTOP_VERSION | 748 | #ifdef DESKTOP_VERSION |
667 | if (mToolTip.count() > 0 ) { | 749 | if (mToolTip.count() > 0 ) { |
668 | mToolTip.sort(); | 750 | mToolTip.sort(); |
669 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 751 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
670 | } | 752 | } |
671 | #endif | 753 | #endif |
672 | mItemList->sort(); | 754 | sort(); |
673 | //setMyPalette(); | 755 | //setMyPalette(); |
674 | setMyPalette(); | 756 | setMyPalette(); |
675 | QString text; | 757 | QString text; |
676 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 758 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
677 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 759 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
678 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 760 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
679 | mLabel->resize( mLabelBigSize ); | 761 | mLabel->resize( mLabelBigSize ); |
680 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 762 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
681 | } else { | 763 | } else { |
682 | mLabel->resize( mLabelSize ); | 764 | mLabel->resize( mLabelSize ); |
683 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 765 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
684 | } | 766 | } |
685 | 767 | ||
686 | mLabel->setText( text ); | 768 | mLabel->setText( text ); |
687 | resizeEvent( 0 ); | 769 | resizeEvent( 0 ); |
688 | 770 | ||
689 | } | 771 | } |
690 | void MonthViewCell::updateCell() | 772 | void MonthViewCell::updateCell() |
691 | { | 773 | { |
692 | //qDebug("MonthViewCell::updateCell() "); | 774 | //qDebug("MonthViewCell::updateCell() "); |
693 | if ( !mMonthView->isUpdatePossible() ) | 775 | if ( !mMonthView->isUpdatePossible() ) |
694 | return; | 776 | return; |
695 | startUpdateCell(); | 777 | startUpdateCell(); |
696 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 778 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
697 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 779 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
698 | Event *event; | 780 | Event *event; |
699 | for( event = events.first(); event; event = events.next() ) { // for event | 781 | for( event = events.first(); event; event = events.next() ) { // for event |
700 | insertEvent(event); | 782 | insertEvent(event); |
701 | } | 783 | } |
702 | // insert due todos | 784 | // insert due todos |
703 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 785 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
704 | Todo *todo; | 786 | Todo *todo; |
705 | for(todo = todos.first(); todo; todo = todos.next()) { | 787 | for(todo = todos.first(); todo; todo = todos.next()) { |
706 | insertTodo( todo ); | 788 | insertTodo( todo ); |
707 | } | 789 | } |
708 | finishUpdateCell(); | 790 | finishUpdateCell(); |
709 | // if ( isVisible()) | 791 | // if ( isVisible()) |
710 | //qApp->processEvents(); | 792 | //qApp->processEvents(); |
711 | } | 793 | } |
712 | 794 | ||
713 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 795 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
714 | { | 796 | { |
715 | 797 | ||
716 | if ( bigFont ) { | 798 | if ( bigFont ) { |
717 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 799 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
718 | int ps = fo.pointSize() + 2; | 800 | int ps = fo.pointSize() + 2; |
719 | if ( ps < 18 ) | 801 | if ( ps < 18 ) |
720 | ps += 2; | 802 | ps += 2; |
721 | fo.setPointSize( ps ); | 803 | fo.setPointSize( ps ); |
722 | setFont( fo ); | 804 | setFont( fo ); |
723 | } else | 805 | } else |
724 | setFont( KOPrefs::instance()->mMonthViewFont ); | 806 | setFont( KOPrefs::instance()->mMonthViewFont ); |
725 | 807 | ||
726 | QFontMetrics fm( font() ); | 808 | QFontMetrics fm( font() ); |
727 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 809 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
728 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 810 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
729 | mHolidayPalette = mStandardPalette; | 811 | mHolidayPalette = mStandardPalette; |
730 | mPrimaryPalette = mStandardPalette; | 812 | mPrimaryPalette = mStandardPalette; |
731 | mNonPrimaryPalette = mStandardPalette; | 813 | mNonPrimaryPalette = mStandardPalette; |
732 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 814 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
733 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 815 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
734 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 816 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
735 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 817 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
736 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 818 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
737 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 819 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
738 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 820 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
739 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 821 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
740 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 822 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
741 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 823 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
742 | } | 824 | } |
743 | //updateCell(); | 825 | //updateCell(); |
744 | } | 826 | } |
745 | 827 | ||
746 | void MonthViewCell::enableScrollBars( bool enabled ) | 828 | void MonthViewCell::enableScrollBars( bool enabled ) |
747 | { | 829 | { |
748 | if ( enabled ) { | 830 | if ( enabled ) { |
749 | //mItemList->setVScrollBarMode(QScrollView::Auto); | 831 | |
750 | mItemList->setHScrollBarMode(QScrollView::Auto); | 832 | QListBoxItem *fi = firstItem (); |
751 | QListBoxItem *fi = mItemList->firstItem (); | ||
752 | if (fi ) { | 833 | if (fi ) { |
753 | int hei = mItemList->numRows () * fi->height(mItemList); | 834 | int ihei = fi->height( this ); |
754 | if ( hei < height() - mItemList->horizontalScrollBar()->height () ) | 835 | int hei = numRows () * ihei; |
755 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 836 | if ( hei < height() - horizontalScrollBar()->height () ) |
837 | setVScrollBarMode(QScrollView::AlwaysOff); | ||
756 | else | 838 | else |
757 | mItemList->setVScrollBarMode(QScrollView::Auto); | 839 | setVScrollBarMode(QScrollView::Auto); |
840 | if ( ihei *3 > height() ) | ||
841 | setHScrollBarMode(QScrollView::AlwaysOff); | ||
842 | else | ||
843 | setHScrollBarMode(QScrollView::Auto); | ||
844 | } else { | ||
845 | setVScrollBarMode(QScrollView::Auto); | ||
846 | setHScrollBarMode(QScrollView::Auto); | ||
758 | } | 847 | } |
759 | } else { | 848 | } else { |
760 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 849 | setVScrollBarMode(QScrollView::AlwaysOff); |
761 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 850 | setHScrollBarMode(QScrollView::AlwaysOff); |
762 | } | 851 | } |
763 | } | 852 | } |
764 | 853 | ||
765 | Incidence *MonthViewCell::selectedIncidence() | 854 | Incidence *MonthViewCell::selectedIncidence() |
766 | { | 855 | { |
767 | int index = mItemList->currentItem(); | 856 | int index = currentItem(); |
768 | if ( index < 0 ) return 0; | 857 | if ( index < 0 ) return 0; |
769 | 858 | ||
770 | MonthViewItem *item = | 859 | MonthViewItem *mitem = |
771 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 860 | static_cast<MonthViewItem *>( item( index ) ); |
772 | 861 | ||
773 | if ( !item ) return 0; | 862 | if ( !mitem ) return 0; |
774 | 863 | ||
775 | return item->incidence(); | 864 | return mitem->incidence(); |
776 | } | 865 | } |
777 | 866 | ||
778 | QDate MonthViewCell::selectedIncidenceDate() | 867 | QDate MonthViewCell::selectedIncidenceDate() |
779 | { | 868 | { |
780 | QDate qd; | 869 | QDate qd; |
781 | int index = mItemList->currentItem(); | 870 | int index = currentItem(); |
782 | if ( index < 0 ) return qd; | 871 | if ( index < 0 ) return qd; |
783 | 872 | ||
784 | MonthViewItem *item = | 873 | MonthViewItem *mitem = |
785 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 874 | static_cast<MonthViewItem *>( item( index ) ); |
786 | 875 | ||
787 | if ( !item ) return qd; | 876 | if ( !mitem ) return qd; |
788 | 877 | ||
789 | return item->incidenceDate(); | 878 | return mitem->incidenceDate(); |
790 | } | 879 | } |
791 | 880 | ||
792 | void MonthViewCell::deselect() | 881 | void MonthViewCell::deselect() |
793 | { | 882 | { |
794 | mItemList->clearSelection(); | 883 | clearSelection(); |
795 | enableScrollBars( false ); | 884 | enableScrollBars( false ); |
796 | // updateCell(); | 885 | // updateCell(); |
797 | } | 886 | } |
798 | void MonthViewCell::select() | 887 | void MonthViewCell::select() |
799 | { | 888 | { |
800 | ;// updateCell(); | 889 | ;// updateCell(); |
801 | } | 890 | } |
802 | 891 | ||
803 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 892 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
804 | { | 893 | { |
805 | if ( !mMonthView->isUpdatePossible() ) | 894 | if ( !mMonthView->isUpdatePossible() ) |
806 | return; | 895 | return; |
807 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 896 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
808 | deselect(); | 897 | deselect(); |
809 | int size = height() - mLabel->height() - 2; | 898 | int size = height() - mLabel->height() - lineWidth()-1; |
899 | //qDebug("LW %d ", lineWidth()); | ||
810 | if ( size > 0 ) | 900 | if ( size > 0 ) |
811 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 901 | verticalScrollBar()->setMaximumHeight( size ); |
812 | size = width() - mLabel->width() -2; | 902 | size = width() - mLabel->width() -lineWidth()-1; |
813 | if ( size > 0 ) | 903 | if ( size > 0 ) |
814 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 904 | horizontalScrollBar()->setMaximumWidth( size ); |
815 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 905 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
816 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 906 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
817 | mItemList->resize ( width(), height () ); | 907 | // mItemList->resize ( width(), height () ); |
818 | 908 | if ( e ) | |
909 | KNoScrollListBox::resizeEvent ( e ); | ||
819 | } | 910 | } |
820 | 911 | ||
821 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 912 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
822 | { | 913 | { |
823 | if ( !item ) return; | 914 | if ( !item ) return; |
824 | 915 | ||
825 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 916 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
826 | Incidence *incidence = eventItem->incidence(); | 917 | Incidence *incidence = eventItem->incidence(); |
827 | if ( incidence ) mMonthView->defaultAction( incidence ); | 918 | if ( incidence ) mMonthView->defaultAction( incidence ); |
828 | } | 919 | } |
829 | void MonthViewCell::showDay() | 920 | void MonthViewCell::showDay() |
830 | { | 921 | { |
831 | emit showDaySignal( date() ); | 922 | emit showDaySignal( date() ); |
832 | } | 923 | } |
833 | void MonthViewCell::newEvent() | 924 | void MonthViewCell::newEvent() |
834 | { | 925 | { |
835 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 926 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
836 | emit newEventSignal( dt ); | 927 | emit newEventSignal( dt ); |
837 | } | 928 | } |
838 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 929 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
839 | { | 930 | { |
840 | static QListBoxItem * lastClicked = 0; | 931 | static QListBoxItem * lastClicked = 0; |
841 | if ( item == 0 ) { | 932 | if ( item == 0 ) { |
842 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 933 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
843 | emit newEventSignal( dt ); | 934 | emit newEventSignal( dt ); |
844 | return; | 935 | return; |
845 | } | 936 | } |
846 | /* | 937 | /* |
847 | if ( lastClicked ) | 938 | if ( lastClicked ) |
848 | if ( ! item ) { | 939 | if ( ! item ) { |
849 | if ( lastClicked->listBox() != item->listBox() ) | 940 | if ( lastClicked->listBox() != item->listBox() ) |
850 | lastClicked->listBox()->clearSelection(); | 941 | lastClicked->listBox()->clearSelection(); |
851 | } | 942 | } |
852 | */ | 943 | */ |
853 | 944 | ||
854 | mMonthView->setSelectedCell( this ); | 945 | mMonthView->setSelectedCell( this ); |
855 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 946 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
856 | select(); | 947 | select(); |
857 | } | 948 | } |
858 | 949 | ||
859 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 950 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
860 | { | 951 | { |
861 | if ( !item ) return; | 952 | if ( !item ) return; |
862 | 953 | ||
863 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 954 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
864 | Incidence *incidence = eventItem->incidence(); | 955 | Incidence *incidence = eventItem->incidence(); |
865 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 956 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
866 | } | 957 | } |
867 | 958 | ||
868 | void MonthViewCell::selection( QListBoxItem *item ) | 959 | void MonthViewCell::selection( QListBoxItem *item ) |
869 | { | 960 | { |
870 | if ( !item ) return; | 961 | if ( !item ) return; |
871 | 962 | ||
872 | mMonthView->setSelectedCell( this ); | 963 | mMonthView->setSelectedCell( this ); |
873 | } | 964 | } |
874 | 965 | ||
875 | 966 | ||
876 | // ******************************************************************************* | 967 | // ******************************************************************************* |
877 | // ******************************************************************************* | 968 | // ******************************************************************************* |
878 | // ******************************************************************************* | 969 | // ******************************************************************************* |
879 | 970 | ||
880 | 971 | ||
881 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 972 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
882 | : KOEventView( calendar, parent, name ), | 973 | : KOEventView( calendar, parent, name ), |
883 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 974 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
884 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 975 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
885 | { | 976 | { |
886 | mShortDayLabelsM = false; | 977 | mShortDayLabelsM = false; |
887 | mShortDayLabelsW = false; | 978 | mShortDayLabelsW = false; |
888 | skipResize = false; | 979 | skipResize = false; |
889 | clPending = true; | 980 | clPending = true; |
890 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 981 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
891 | mWidStack = new QWidgetStack( this ); | 982 | mWidStack = new QWidgetStack( this ); |
892 | QVBoxLayout* hb = new QVBoxLayout( this ); | 983 | QVBoxLayout* hb = new QVBoxLayout( this ); |
893 | mMonthView = new QWidget( mWidStack ); | 984 | mMonthView = new QWidget( mWidStack ); |
894 | mWeekView = new QWidget( mWidStack ); | 985 | mWeekView = new QWidget( mWidStack ); |
895 | #if QT_VERSION >= 0x030000 | 986 | #if QT_VERSION >= 0x030000 |
896 | mWidStack->addWidget(mMonthView ); | 987 | mWidStack->addWidget(mMonthView ); |
897 | mWidStack->addWidget(mWeekView ); | 988 | mWidStack->addWidget(mWeekView ); |
898 | #else | 989 | #else |
899 | mWidStack->addWidget( mMonthView, 1 ); | 990 | mWidStack->addWidget( mMonthView, 1 ); |
900 | mWidStack->addWidget( mWeekView , 1 ); | 991 | mWidStack->addWidget( mWeekView , 1 ); |
901 | #endif | 992 | #endif |
902 | hb->addWidget( mNavigatorBar ); | 993 | hb->addWidget( mNavigatorBar ); |
903 | hb->addWidget( mWidStack ); | 994 | hb->addWidget( mWidStack ); |
904 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 995 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
905 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 996 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
906 | if ( mShowWeekView ) | 997 | if ( mShowWeekView ) |
907 | mWeekStartsMonday = true; | 998 | mWeekStartsMonday = true; |
908 | updatePossible = false; | 999 | updatePossible = false; |
909 | //updatePossible = true; | 1000 | //updatePossible = true; |
910 | mCells.setAutoDelete( true ); | 1001 | mCells.setAutoDelete( true ); |
911 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1002 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
912 | mDayLabels.resize( mDaysPerWeek ); | 1003 | mDayLabels.resize( mDaysPerWeek ); |
913 | mDayLabelsW.resize( mDaysPerWeek ); | 1004 | mDayLabelsW.resize( mDaysPerWeek ); |
914 | QFont bfont = font(); | 1005 | QFont bfont = font(); |
915 | if ( QApplication::desktop()->width() < 650 ) { | 1006 | if ( QApplication::desktop()->width() < 650 ) { |
916 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1007 | bfont.setPointSize( bfont.pointSize() - 2 ); |
917 | } | 1008 | } |
918 | bfont.setBold( true ); | 1009 | bfont.setBold( true ); |
919 | int i; | 1010 | int i; |
920 | 1011 | ||
921 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1012 | for( i = 0; i < mDaysPerWeek; i++ ) { |
922 | QLabel *label = new QLabel( mMonthView ); | 1013 | QLabel *label = new QLabel( mMonthView ); |
923 | label->setFont(bfont); | 1014 | label->setFont(bfont); |
924 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1015 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
925 | label->setLineWidth(1); | 1016 | label->setLineWidth(1); |
926 | label->setAlignment(AlignCenter); | 1017 | label->setAlignment(AlignCenter); |
927 | mDayLabels.insert( i, label ); | 1018 | mDayLabels.insert( i, label ); |
928 | label = new QLabel( mWeekView ); | 1019 | label = new QLabel( mWeekView ); |
929 | label->setFont(bfont); | 1020 | label->setFont(bfont); |
930 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1021 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
931 | label->setLineWidth(1); | 1022 | label->setLineWidth(1); |
932 | label->setAlignment(AlignCenter); | 1023 | label->setAlignment(AlignCenter); |
933 | mDayLabelsW.insert( i, label ); | 1024 | mDayLabelsW.insert( i, label ); |
934 | } | 1025 | } |
935 | 1026 | ||
936 | bfont.setBold( false ); | 1027 | bfont.setBold( false ); |
937 | mWeekLabels.resize( mNumWeeks+1 ); | 1028 | mWeekLabels.resize( mNumWeeks+1 ); |
938 | mWeekLabelsW.resize( 2 ); | 1029 | mWeekLabelsW.resize( 2 ); |
939 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1030 | for( i = 0; i < mNumWeeks+1; i++ ) { |
940 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1031 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
941 | label->setFocusPolicy(NoFocus); | 1032 | label->setFocusPolicy(NoFocus); |
942 | label->setFont(bfont); | 1033 | label->setFont(bfont); |
943 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1034 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
944 | label->setFlat(true); | 1035 | label->setFlat(true); |
945 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1036 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
946 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1037 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
947 | //label->setLineWidth(1); | 1038 | //label->setLineWidth(1); |
948 | //label->setAlignment(AlignCenter); | 1039 | //label->setAlignment(AlignCenter); |
949 | mWeekLabels.insert( i, label ); | 1040 | mWeekLabels.insert( i, label ); |
950 | } | 1041 | } |
951 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1042 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
952 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1043 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
953 | 1044 | ||
954 | for( i = 0; i < 1+1; i++ ) { | 1045 | for( i = 0; i < 1+1; i++ ) { |
955 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1046 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
956 | label->setFocusPolicy(NoFocus); | 1047 | label->setFocusPolicy(NoFocus); |
957 | label->setFont(bfont); | 1048 | label->setFont(bfont); |
958 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1049 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
959 | label->setFlat(true); | 1050 | label->setFlat(true); |
960 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1051 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
961 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1052 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
962 | //label->setLineWidth(1); | 1053 | //label->setLineWidth(1); |
963 | //label->setAlignment(AlignCenter); | 1054 | //label->setAlignment(AlignCenter); |
964 | mWeekLabelsW.insert( i, label ); | 1055 | mWeekLabelsW.insert( i, label ); |
965 | } | 1056 | } |
966 | mWeekLabelsW[1]->setText( i18n("W")); | 1057 | mWeekLabelsW[1]->setText( i18n("W")); |
967 | 1058 | ||
968 | 1059 | ||
969 | int row, col; | 1060 | int row, col; |
970 | mCells.resize( mNumCells ); | 1061 | mCells.resize( mNumCells ); |
971 | for( row = 0; row < mNumWeeks; ++row ) { | 1062 | for( row = 0; row < mNumWeeks; ++row ) { |
972 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1063 | for( col = 0; col < mDaysPerWeek; ++col ) { |
973 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1064 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
974 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1065 | mCells.insert( row * mDaysPerWeek + col, cell ); |
975 | 1066 | ||
976 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1067 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
977 | SLOT( defaultAction( Incidence * ) ) ); | 1068 | SLOT( defaultAction( Incidence * ) ) ); |
978 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1069 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
979 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1070 | SIGNAL( newEventSignal( QDateTime ) ) ); |
980 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1071 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
981 | SIGNAL( showDaySignal( QDate ) ) ); | 1072 | SIGNAL( showDaySignal( QDate ) ) ); |
982 | } | 1073 | } |
983 | } | 1074 | } |
984 | mCellsW.resize( mDaysPerWeek ); | 1075 | mCellsW.resize( mDaysPerWeek ); |
985 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1076 | for( col = 0; col < mDaysPerWeek; ++col ) { |
986 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1077 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
987 | mCellsW.insert( col, cell ); | 1078 | mCellsW.insert( col, cell ); |
988 | 1079 | ||
989 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1080 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
990 | SLOT( defaultAction( Incidence * ) ) ); | 1081 | SLOT( defaultAction( Incidence * ) ) ); |
991 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1082 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
992 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1083 | SIGNAL( newEventSignal( QDateTime ) ) ); |
993 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1084 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
994 | SIGNAL( showDaySignal( QDate ) ) ); | 1085 | SIGNAL( showDaySignal( QDate ) ) ); |
995 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1086 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
996 | } | 1087 | } |
997 | 1088 | ||
998 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1089 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
999 | mContextMenu = eventPopup(); | 1090 | mContextMenu = eventPopup(); |
1000 | // updateConfig(); //useless here... | 1091 | // updateConfig(); //useless here... |
1001 | // ... but we need mWidthLongDayLabel computed | 1092 | // ... but we need mWidthLongDayLabel computed |
1002 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1093 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1003 | mWidthLongDayLabel = 0; | 1094 | mWidthLongDayLabel = 0; |
1004 | for (int i = 0; i < 7; i++) { | 1095 | for (int i = 0; i < 7; i++) { |
1005 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1096 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1006 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1097 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1007 | } | 1098 | } |
1008 | 1099 | ||
1009 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1100 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1010 | 1101 | ||
@@ -1071,480 +1162,485 @@ void KOMonthView::switchView() | |||
1071 | mWidStack->raiseWidget( mMonthView ); | 1162 | mWidStack->raiseWidget( mMonthView ); |
1072 | clPending = false; | 1163 | clPending = false; |
1073 | } | 1164 | } |
1074 | 1165 | ||
1075 | int KOMonthView::maxDatesHint() | 1166 | int KOMonthView::maxDatesHint() |
1076 | { | 1167 | { |
1077 | return mNumCells; | 1168 | return mNumCells; |
1078 | } | 1169 | } |
1079 | 1170 | ||
1080 | int KOMonthView::currentDateCount() | 1171 | int KOMonthView::currentDateCount() |
1081 | { | 1172 | { |
1082 | return mNumCells; | 1173 | return mNumCells; |
1083 | } | 1174 | } |
1084 | 1175 | ||
1085 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1176 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1086 | { | 1177 | { |
1087 | QPtrList<Incidence> selected; | 1178 | QPtrList<Incidence> selected; |
1088 | 1179 | ||
1089 | if ( mSelectedCell ) { | 1180 | if ( mSelectedCell ) { |
1090 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1181 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1091 | if ( incidence ) selected.append( incidence ); | 1182 | if ( incidence ) selected.append( incidence ); |
1092 | } | 1183 | } |
1093 | 1184 | ||
1094 | return selected; | 1185 | return selected; |
1095 | } | 1186 | } |
1096 | 1187 | ||
1097 | DateList KOMonthView::selectedDates() | 1188 | DateList KOMonthView::selectedDates() |
1098 | { | 1189 | { |
1099 | DateList selected; | 1190 | DateList selected; |
1100 | 1191 | ||
1101 | if ( mSelectedCell ) { | 1192 | if ( mSelectedCell ) { |
1102 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1193 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1103 | if ( qd.isValid() ) selected.append( qd ); | 1194 | if ( qd.isValid() ) selected.append( qd ); |
1104 | } | 1195 | } |
1105 | 1196 | ||
1106 | return selected; | 1197 | return selected; |
1107 | } | 1198 | } |
1108 | 1199 | ||
1109 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1200 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1110 | const QDate &td) | 1201 | const QDate &td) |
1111 | { | 1202 | { |
1112 | #ifndef KORG_NOPRINTER | 1203 | #ifndef KORG_NOPRINTER |
1113 | calPrinter->preview(CalPrinter::Month, fd, td); | 1204 | calPrinter->preview(CalPrinter::Month, fd, td); |
1114 | #endif | 1205 | #endif |
1115 | } | 1206 | } |
1116 | 1207 | ||
1117 | void KOMonthView::updateConfig() | 1208 | void KOMonthView::updateConfig() |
1118 | { | 1209 | { |
1119 | 1210 | ||
1120 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1211 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1121 | 1212 | ||
1122 | if ( mShowWeekView ) { | 1213 | if ( mShowWeekView ) { |
1123 | mWeekStartsMonday = true; | 1214 | mWeekStartsMonday = true; |
1124 | } | 1215 | } |
1125 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1216 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1126 | mWidthLongDayLabel = 0; | 1217 | mWidthLongDayLabel = 0; |
1127 | 1218 | ||
1128 | for (int i = 0; i < 7; i++) { | 1219 | for (int i = 0; i < 7; i++) { |
1129 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1220 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1130 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1221 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1131 | } | 1222 | } |
1132 | bool temp = mShowSatSunComp ; | 1223 | bool temp = mShowSatSunComp ; |
1133 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1224 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1134 | if ( ! mShowWeekView ) { | 1225 | if ( ! mShowWeekView ) { |
1135 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1226 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1136 | computeLayout(); | 1227 | computeLayout(); |
1137 | } | 1228 | } |
1138 | updateDayLabels(); | 1229 | updateDayLabels(); |
1139 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1230 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1140 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1231 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1141 | //resizeEvent( 0 ); | 1232 | //resizeEvent( 0 ); |
1142 | for (uint i = 0; i < mCells.count(); ++i) { | 1233 | for (uint i = 0; i < mCells.count(); ++i) { |
1143 | mCells[i]->updateConfig(); | 1234 | mCells[i]->updateConfig(); |
1144 | } | 1235 | } |
1145 | 1236 | ||
1146 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1237 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1147 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1238 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1148 | } | 1239 | } |
1149 | #ifdef DESKTOP_VERSION | 1240 | #ifdef DESKTOP_VERSION |
1150 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1241 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1151 | #endif | 1242 | #endif |
1152 | updateView(); | 1243 | updateView(); |
1153 | } | 1244 | } |
1154 | 1245 | ||
1155 | void KOMonthView::updateDayLabels() | 1246 | void KOMonthView::updateDayLabels() |
1156 | { | 1247 | { |
1157 | 1248 | ||
1158 | QPtrVector<QLabel> *mDayLabelsT; | 1249 | QPtrVector<QLabel> *mDayLabelsT; |
1159 | 1250 | ||
1160 | mDayLabelsT = &mDayLabelsW; | 1251 | mDayLabelsT = &mDayLabelsW; |
1161 | for (int i = 0; i < 7; i++) { | 1252 | for (int i = 0; i < 7; i++) { |
1162 | if (mWeekStartsMonday) { | 1253 | if (mWeekStartsMonday) { |
1163 | bool show = mShortDayLabelsW; | 1254 | bool show = mShortDayLabelsW; |
1164 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1255 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1165 | show = true; | 1256 | show = true; |
1166 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1257 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1167 | } else { | 1258 | } else { |
1168 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | 1259 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1169 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | 1260 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1170 | 1261 | ||
1171 | } | 1262 | } |
1172 | } | 1263 | } |
1173 | mDayLabelsT = &mDayLabels; | 1264 | mDayLabelsT = &mDayLabels; |
1174 | for (int i = 0; i < 7; i++) { | 1265 | for (int i = 0; i < 7; i++) { |
1175 | if (mWeekStartsMonday) { | 1266 | if (mWeekStartsMonday) { |
1176 | bool show = mShortDayLabelsM; | 1267 | bool show = mShortDayLabelsM; |
1177 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1268 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1178 | show = true; | 1269 | show = true; |
1179 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1270 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1180 | } else { | 1271 | } else { |
1181 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1272 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1182 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1273 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1183 | 1274 | ||
1184 | } | 1275 | } |
1185 | } | 1276 | } |
1186 | 1277 | ||
1187 | } | 1278 | } |
1188 | 1279 | ||
1189 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1280 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1190 | { | 1281 | { |
1191 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1282 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1192 | 1283 | ||
1193 | QPtrVector<MonthViewCell> *cells; | 1284 | QPtrVector<MonthViewCell> *cells; |
1194 | QPtrVector<QLabel> *dayLabels; | 1285 | QPtrVector<QLabel> *dayLabels; |
1195 | QPtrVector<KOWeekButton> *weekLabels; | 1286 | QPtrVector<KOWeekButton> *weekLabels; |
1196 | int weekNum = 6; | 1287 | int weekNum = 6; |
1197 | if ( mShowWeekView ) { | 1288 | if ( mShowWeekView ) { |
1198 | weekNum = 1; | 1289 | weekNum = 1; |
1199 | cells = &mCellsW; | 1290 | cells = &mCellsW; |
1200 | dayLabels = &mDayLabelsW; | 1291 | dayLabels = &mDayLabelsW; |
1201 | weekLabels = &mWeekLabelsW; | 1292 | weekLabels = &mWeekLabelsW; |
1202 | } else { | 1293 | } else { |
1203 | cells = &mCells; | 1294 | cells = &mCells; |
1204 | dayLabels = &mDayLabels; | 1295 | dayLabels = &mDayLabels; |
1205 | weekLabels = &mWeekLabels; | 1296 | weekLabels = &mWeekLabels; |
1206 | } | 1297 | } |
1207 | 1298 | ||
1208 | mStartDate = start; | 1299 | mStartDate = start; |
1209 | 1300 | ||
1210 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1301 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1211 | 1302 | ||
1212 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1303 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1213 | mStartDate = mStartDate.addDays( -1 ); | 1304 | mStartDate = mStartDate.addDays( -1 ); |
1214 | } | 1305 | } |
1215 | 1306 | ||
1216 | bool primary = false; | 1307 | bool primary = false; |
1217 | uint i; | 1308 | uint i; |
1218 | for( i = 0; i < (*cells).size(); ++i ) { | 1309 | for( i = 0; i < (*cells).size(); ++i ) { |
1219 | QDate date = mStartDate.addDays( i ); | 1310 | QDate date = mStartDate.addDays( i ); |
1220 | (*cells)[i]->setDate( date ); | 1311 | (*cells)[i]->setDate( date ); |
1221 | 1312 | ||
1222 | #ifndef KORG_NOPLUGINS | 1313 | #ifndef KORG_NOPLUGINS |
1223 | // add holiday, if present | 1314 | // add holiday, if present |
1224 | QString hstring(KOCore::self()->holiday(date)); | 1315 | QString hstring(KOCore::self()->holiday(date)); |
1225 | (*cells)[i]->setHoliday( hstring ); | 1316 | (*cells)[i]->setHoliday( hstring ); |
1226 | #endif | 1317 | #endif |
1227 | 1318 | ||
1228 | } | 1319 | } |
1229 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1320 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1230 | for( i = 0; i < weekNum; ++i ) { | 1321 | for( i = 0; i < weekNum; ++i ) { |
1231 | int wno; | 1322 | int wno; |
1232 | // remember, according to ISO 8601, the first week of the year is the | 1323 | // remember, according to ISO 8601, the first week of the year is the |
1233 | // first week that contains a thursday. Thus we must subtract off 4, | 1324 | // first week that contains a thursday. Thus we must subtract off 4, |
1234 | // not just 1. | 1325 | // not just 1. |
1235 | int dayOfYear = date.dayOfYear(); | 1326 | int dayOfYear = date.dayOfYear(); |
1236 | if (dayOfYear % 7 != 0) | 1327 | if (dayOfYear % 7 != 0) |
1237 | wno = dayOfYear / 7 + 1; | 1328 | wno = dayOfYear / 7 + 1; |
1238 | else | 1329 | else |
1239 | wno =dayOfYear / 7; | 1330 | wno =dayOfYear / 7; |
1240 | (*weekLabels)[i]->setWeekNum( wno ); | 1331 | (*weekLabels)[i]->setWeekNum( wno ); |
1241 | date = date.addDays( 7 ); | 1332 | date = date.addDays( 7 ); |
1242 | } | 1333 | } |
1243 | updateView(); | 1334 | updateView(); |
1244 | } | 1335 | } |
1245 | 1336 | ||
1246 | void KOMonthView::showEvents(QPtrList<Event>) | 1337 | void KOMonthView::showEvents(QPtrList<Event>) |
1247 | { | 1338 | { |
1248 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1339 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1249 | } | 1340 | } |
1250 | 1341 | ||
1251 | void KOMonthView::changeEventDisplay(Event *, int) | 1342 | void KOMonthView::changeEventDisplay(Event *, int) |
1252 | { | 1343 | { |
1253 | // this should be re-written to be much more efficient, but this | 1344 | // this should be re-written to be much more efficient, but this |
1254 | // quick-and-dirty-hack gets the job done for right now. | 1345 | // quick-and-dirty-hack gets the job done for right now. |
1255 | updateView(); | 1346 | updateView(); |
1256 | } | 1347 | } |
1257 | 1348 | ||
1258 | void KOMonthView::updateView() | 1349 | void KOMonthView::updateView() |
1259 | { | 1350 | { |
1260 | 1351 | ||
1261 | if ( !updatePossible ) | 1352 | if ( !updatePossible ) |
1262 | return; | 1353 | return; |
1354 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | ||
1263 | //QTime ti; | 1355 | //QTime ti; |
1264 | //ti.start(); | 1356 | //ti.start(); |
1265 | clearSelection(); | 1357 | clearSelection(); |
1266 | QPtrVector<MonthViewCell> *cells; | 1358 | QPtrVector<MonthViewCell> *cells; |
1267 | if ( mShowWeekView ) { | 1359 | if ( mShowWeekView ) { |
1268 | cells = &mCellsW; | 1360 | cells = &mCellsW; |
1269 | } else { | 1361 | } else { |
1270 | cells = &mCells; | 1362 | cells = &mCells; |
1271 | } | 1363 | } |
1272 | #if 1 | 1364 | #if 1 |
1273 | int i; | 1365 | int i; |
1274 | int timeSpan = (*cells).size()-1; | 1366 | int timeSpan = (*cells).size()-1; |
1275 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1367 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1276 | timeSpan = 6; | 1368 | timeSpan = 6; |
1277 | for( i = 0; i < timeSpan + 1; ++i ) { | 1369 | for( i = 0; i < timeSpan + 1; ++i ) { |
1278 | (*cells)[i]->startUpdateCell(); | 1370 | (*cells)[i]->startUpdateCell(); |
1279 | } | 1371 | } |
1280 | 1372 | ||
1281 | QPtrList<Event> events = calendar()->events(); | 1373 | QPtrList<Event> events = calendar()->events(); |
1282 | Event *event; | 1374 | Event *event; |
1283 | QDateTime dt; | 1375 | QDateTime dt; |
1284 | bool ok; | 1376 | bool ok; |
1285 | QDate endDate = mStartDate.addDays( timeSpan ); | 1377 | QDate endDate = mStartDate.addDays( timeSpan ); |
1286 | for( event = events.first(); event; event = events.next() ) { // for event | 1378 | for( event = events.first(); event; event = events.next() ) { // for event |
1287 | if ( event->doesRecur() ) { | 1379 | if ( event->doesRecur() ) { |
1288 | bool last; | 1380 | bool last; |
1289 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1381 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1290 | QDateTime incidenceEnd; | 1382 | QDateTime incidenceEnd; |
1291 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1383 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1292 | bool invalid = false; | 1384 | bool invalid = false; |
1293 | while( true ) { | 1385 | while( true ) { |
1294 | if ( incidenceStart.isValid() ) { | 1386 | if ( incidenceStart.isValid() ) { |
1295 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1387 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1296 | int st = incidenceStart.date().daysTo( endDate ); | 1388 | int st = incidenceStart.date().daysTo( endDate ); |
1297 | if ( st >= 0 ) { // start before timeend | 1389 | if ( st >= 0 ) { // start before timeend |
1298 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1390 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1299 | if ( end >= 0 ) { // end after timestart --- got one! | 1391 | if ( end >= 0 ) { // end after timestart --- got one! |
1300 | //normalize | 1392 | //normalize |
1301 | st = timeSpan - st; | 1393 | st = timeSpan - st; |
1302 | if ( st < 0 ) st = 0; | 1394 | if ( st < 0 ) st = 0; |
1303 | if ( end > timeSpan ) end = timeSpan; | 1395 | if ( end > timeSpan ) end = timeSpan; |
1304 | int iii; | 1396 | int iii; |
1305 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1397 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1306 | for ( iii = st;iii<= end;++iii) | 1398 | for ( iii = st;iii<= end;++iii) |
1307 | (*cells)[iii]->insertEvent( event ); | 1399 | (*cells)[iii]->insertEvent( event ); |
1308 | } | 1400 | } |
1309 | } | 1401 | } |
1310 | } else { | 1402 | } else { |
1311 | if ( invalid ) | 1403 | if ( invalid ) |
1312 | break; | 1404 | break; |
1313 | invalid = true; | 1405 | invalid = true; |
1314 | //qDebug("invalid %s", event->summary().latin1()); | 1406 | //qDebug("invalid %s", event->summary().latin1()); |
1315 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1407 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1316 | } | 1408 | } |
1317 | if ( last ) | 1409 | if ( last ) |
1318 | break; | 1410 | break; |
1319 | bool ok; | 1411 | bool ok; |
1320 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1412 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1321 | if ( ! ok ) | 1413 | if ( ! ok ) |
1322 | break; | 1414 | break; |
1323 | if ( incidenceStart.date() > endDate ) | 1415 | if ( incidenceStart.date() > endDate ) |
1324 | break; | 1416 | break; |
1325 | } | 1417 | } |
1326 | } else { // no recur | 1418 | } else { // no recur |
1327 | int st = event->dtStart().date().daysTo( endDate ); | 1419 | int st = event->dtStart().date().daysTo( endDate ); |
1328 | if ( st >= 0 ) { // start before timeend | 1420 | if ( st >= 0 ) { // start before timeend |
1329 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1421 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1330 | if ( end >= 0 ) { // end after timestart --- got one! | 1422 | if ( end >= 0 ) { // end after timestart --- got one! |
1331 | //normalize | 1423 | //normalize |
1332 | st = timeSpan - st; | 1424 | st = timeSpan - st; |
1333 | if ( st < 0 ) st = 0; | 1425 | if ( st < 0 ) st = 0; |
1334 | if ( end > timeSpan ) end = timeSpan; | 1426 | if ( end > timeSpan ) end = timeSpan; |
1335 | int iii; | 1427 | int iii; |
1336 | for ( iii = st;iii<= end;++iii) | 1428 | for ( iii = st;iii<= end;++iii) |
1337 | (*cells)[iii]->insertEvent( event ); | 1429 | (*cells)[iii]->insertEvent( event ); |
1338 | } | 1430 | } |
1339 | } | 1431 | } |
1340 | } | 1432 | } |
1341 | } | 1433 | } |
1342 | // insert due todos | 1434 | // insert due todos |
1343 | QPtrList<Todo> todos = calendar()->todos( ); | 1435 | QPtrList<Todo> todos = calendar()->todos( ); |
1344 | Todo *todo; | 1436 | Todo *todo; |
1345 | for(todo = todos.first(); todo; todo = todos.next()) { | 1437 | for(todo = todos.first(); todo; todo = todos.next()) { |
1346 | //insertTodo( todo ); | 1438 | //insertTodo( todo ); |
1347 | if ( todo->hasDueDate() ) { | 1439 | if ( todo->hasDueDate() ) { |
1348 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1440 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1349 | if ( day >= 0 && day < timeSpan + 1) { | 1441 | if ( day >= 0 && day < timeSpan + 1) { |
1350 | (*cells)[day]->insertTodo( todo ); | 1442 | (*cells)[day]->insertTodo( todo ); |
1351 | } | 1443 | } |
1352 | } | 1444 | } |
1353 | } | 1445 | } |
1354 | 1446 | ||
1355 | for( i = 0; i < timeSpan+1; ++i ) { | 1447 | for( i = 0; i < timeSpan+1; ++i ) { |
1356 | (*cells)[i]->finishUpdateCell(); | 1448 | (*cells)[i]->finishUpdateCell(); |
1357 | } | 1449 | } |
1358 | processSelectionChange(); | 1450 | processSelectionChange(); |
1451 | qApp->processEvents(); | ||
1452 | for( i = 0; i < timeSpan+1; ++i ) { | ||
1453 | (*cells)[i]->repaintfinishUpdateCell(); | ||
1454 | } | ||
1359 | (*cells)[0]->setFocus(); | 1455 | (*cells)[0]->setFocus(); |
1360 | 1456 | ||
1361 | 1457 | ||
1362 | #else | 1458 | #else |
1363 | // old code | 1459 | // old code |
1364 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1460 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1365 | int i; | 1461 | int i; |
1366 | for( i = 0; i < (*cells).count(); ++i ) { | 1462 | for( i = 0; i < (*cells).count(); ++i ) { |
1367 | (*cells)[i]->updateCell(); | 1463 | (*cells)[i]->updateCell(); |
1368 | } | 1464 | } |
1369 | 1465 | ||
1370 | //qDebug("KOMonthView::updateView() "); | 1466 | //qDebug("KOMonthView::updateView() "); |
1371 | processSelectionChange(); | 1467 | processSelectionChange(); |
1372 | // qDebug("---------------------------------------------------------------------+ "); | 1468 | // qDebug("---------------------------------------------------------------------+ "); |
1373 | (*cells)[0]->setFocus(); | 1469 | (*cells)[0]->setFocus(); |
1374 | #endif | 1470 | #endif |
1375 | 1471 | ||
1376 | //qDebug("update time %d ", ti.elapsed()); | 1472 | //qDebug("update time %d ", ti.elapsed()); |
1377 | } | 1473 | } |
1378 | 1474 | ||
1379 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1475 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1380 | { | 1476 | { |
1381 | qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1477 | qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1382 | if ( isVisible() ) { | 1478 | if ( isVisible() ) { |
1383 | qDebug("KOMonthView::isVisible "); | 1479 | qDebug("KOMonthView::isVisible "); |
1384 | slotComputeLayout(); | 1480 | slotComputeLayout(); |
1385 | } else | 1481 | } else |
1386 | mComputeLayoutTimer->start( 100 ); | 1482 | mComputeLayoutTimer->start( 100 ); |
1387 | } | 1483 | } |
1388 | 1484 | ||
1389 | void KOMonthView::slotComputeLayout() | 1485 | void KOMonthView::slotComputeLayout() |
1390 | { | 1486 | { |
1391 | mComputeLayoutTimer->stop(); | 1487 | mComputeLayoutTimer->stop(); |
1392 | qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1488 | qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1393 | computeLayout(); | 1489 | computeLayout(); |
1394 | clPending = true; | 1490 | clPending = true; |
1395 | if ( mShowWeekView ) | 1491 | if ( mShowWeekView ) |
1396 | mCellsW[0]->setFocus(); | 1492 | mCellsW[0]->setFocus(); |
1397 | else | 1493 | else |
1398 | mCells[0]->setFocus(); | 1494 | mCells[0]->setFocus(); |
1399 | 1495 | ||
1400 | } | 1496 | } |
1401 | void KOMonthView::computeLayoutWeek() | 1497 | void KOMonthView::computeLayoutWeek() |
1402 | { | 1498 | { |
1403 | static int lastWid = 0; | 1499 | static int lastWid = 0; |
1404 | static int lastHei = 0; | 1500 | static int lastHei = 0; |
1405 | int daysToShow; | 1501 | int daysToShow; |
1406 | bool combinedSatSun = false; | 1502 | bool combinedSatSun = false; |
1407 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1503 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1408 | daysToShow = 6; | 1504 | daysToShow = 6; |
1409 | combinedSatSun = true; | 1505 | combinedSatSun = true; |
1410 | } | 1506 | } |
1411 | int tWid = topLevelWidget()->size().width(); | 1507 | int tWid = topLevelWidget()->size().width(); |
1412 | int tHei = topLevelWidget()->size().height(); | 1508 | int tHei = topLevelWidget()->size().height(); |
1413 | 1509 | ||
1414 | int wid = width();//e | 1510 | int wid = width();//e |
1415 | int hei = height()-1-mNavigatorBar->height(); | 1511 | int hei = height()-1-mNavigatorBar->height(); |
1416 | 1512 | ||
1417 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1513 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1418 | return; | 1514 | return; |
1419 | 1515 | ||
1420 | if ( lastWid == width() && lastHei == height() ) { | 1516 | if ( lastWid == width() && lastHei == height() ) { |
1421 | qDebug("KOListWeekView::No compute layout needed "); | 1517 | qDebug("KOListWeekView::No compute layout needed "); |
1422 | return; | 1518 | return; |
1423 | } | 1519 | } |
1424 | lastWid = width(); | 1520 | lastWid = width(); |
1425 | lastHei = height(); | 1521 | lastHei = height(); |
1426 | 1522 | ||
1427 | 1523 | ||
1428 | if ( wid < hei ) | 1524 | if ( wid < hei ) |
1429 | daysToShow = 2; | 1525 | daysToShow = 2; |
1430 | else | 1526 | else |
1431 | daysToShow = 3; | 1527 | daysToShow = 3; |
1432 | mShowSatSunComp = true; | 1528 | mShowSatSunComp = true; |
1433 | combinedSatSun = true; | 1529 | combinedSatSun = true; |
1434 | 1530 | ||
1435 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1531 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1436 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1532 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1437 | int weeklabelwid = fm.width( "888" ); | 1533 | int weeklabelwid = fm.width( "888" ); |
1438 | wid -= weeklabelwid; | 1534 | wid -= weeklabelwid; |
1439 | 1535 | ||
1440 | int colWid = wid / daysToShow; | 1536 | int colWid = wid / daysToShow; |
1441 | int lastCol = wid - ( colWid*6 ); | 1537 | int lastCol = wid - ( colWid*6 ); |
1442 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1538 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1443 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1539 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1444 | int colModulo = wid % daysToShow; | 1540 | int colModulo = wid % daysToShow; |
1445 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1541 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1446 | //qDebug("rowmod %d ", rowModulo); | 1542 | //qDebug("rowmod %d ", rowModulo); |
1447 | int i; | 1543 | int i; |
1448 | int x,y,w,h; | 1544 | int x,y,w,h; |
1449 | x= 0; | 1545 | x= 0; |
1450 | y= 0; | 1546 | y= 0; |
1451 | w = colWid; | 1547 | w = colWid; |
1452 | h = dayLabelHei ; | 1548 | h = dayLabelHei ; |
1453 | for ( i = 0; i < 7; i++) { | 1549 | for ( i = 0; i < 7; i++) { |
1454 | if ( i && !( i % daysToShow) && i < 6) { | 1550 | if ( i && !( i % daysToShow) && i < 6) { |
1455 | y += hei/(5-daysToShow); | 1551 | y += hei/(5-daysToShow); |
1456 | x = 0; | 1552 | x = 0; |
1457 | w = colWid; | 1553 | w = colWid; |
1458 | } | 1554 | } |
1459 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1555 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1460 | ++w; | 1556 | ++w; |
1461 | } | 1557 | } |
1462 | if ( i >= 5 ) { | 1558 | if ( i >= 5 ) { |
1463 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1559 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1464 | x -= (w/2 ); | 1560 | x -= (w/2 ); |
1465 | } | 1561 | } |
1466 | else | 1562 | else |
1467 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1563 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1468 | x += w; | 1564 | x += w; |
1469 | } | 1565 | } |
1470 | x= 0; | 1566 | x= 0; |
1471 | y= dayLabelHei; | 1567 | y= dayLabelHei; |
1472 | w = colWid; | 1568 | w = colWid; |
1473 | h = cellHei; | 1569 | h = cellHei; |
1474 | for ( i = 0; i < mCellsW.count(); ++i) { | 1570 | for ( i = 0; i < mCellsW.count(); ++i) { |
1475 | if ( i > 6 ) { | 1571 | if ( i > 6 ) { |
1476 | mCellsW[i]->hide(); | 1572 | mCellsW[i]->hide(); |
1477 | continue; | 1573 | continue; |
1478 | } | 1574 | } |
1479 | 1575 | ||
1480 | w = colWid; | 1576 | w = colWid; |
1481 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1577 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1482 | ++w; | 1578 | ++w; |
1483 | } | 1579 | } |
1484 | if ( i == (daysToShow-1-rowModulo)*7) | 1580 | if ( i == (daysToShow-1-rowModulo)*7) |
1485 | ++h; | 1581 | ++h; |
1486 | 1582 | ||
1487 | if ( i >= 5 ) { | 1583 | if ( i >= 5 ) { |
1488 | if ( i ==5 ) { | 1584 | if ( i ==5 ) { |
1489 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1585 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1490 | x -= w ;y += h/2; | 1586 | x -= w ;y += h/2; |
1491 | } else { | 1587 | } else { |
1492 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1588 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1493 | ++w; | 1589 | ++w; |
1494 | } | 1590 | } |
1495 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1591 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1496 | y -= h/2; | 1592 | y -= h/2; |
1497 | } | 1593 | } |
1498 | } else | 1594 | } else |
1499 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1595 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1500 | 1596 | ||
1501 | 1597 | ||
1502 | x += w; | 1598 | x += w; |
1503 | if ( x + w/2 > wid ) { | 1599 | if ( x + w/2 > wid ) { |
1504 | x = 0; | 1600 | x = 0; |
1505 | y += h+dayLabelHei ; | 1601 | y += h+dayLabelHei ; |
1506 | } | 1602 | } |
1507 | } | 1603 | } |
1508 | y= dayLabelHei; | 1604 | y= dayLabelHei; |
1509 | h = cellHei ; | 1605 | h = cellHei ; |
1510 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1606 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1511 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1607 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1512 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1608 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1513 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1609 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1514 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1610 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1515 | updateDayLabels(); | 1611 | updateDayLabels(); |
1516 | //bool forceUpdate = !updatePossible; | 1612 | //bool forceUpdate = !updatePossible; |
1517 | updatePossible = true; | 1613 | updatePossible = true; |
1518 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1614 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1519 | //if ( forceUpdate ) | 1615 | //if ( forceUpdate ) |
1520 | // updateView(); | 1616 | // updateView(); |
1521 | } | 1617 | } |
1522 | void KOMonthView::computeLayout() | 1618 | void KOMonthView::computeLayout() |
1523 | { | 1619 | { |
1524 | 1620 | ||
1525 | 1621 | ||
1526 | static int lastWid = 0; | 1622 | static int lastWid = 0; |
1527 | static int lastHei = 0; | 1623 | static int lastHei = 0; |
1528 | 1624 | ||
1529 | if ( mShowWeekView ){ | 1625 | if ( mShowWeekView ){ |
1530 | computeLayoutWeek(); | 1626 | computeLayoutWeek(); |
1531 | return; | 1627 | return; |
1532 | } | 1628 | } |
1533 | int daysToShow = 7; | 1629 | int daysToShow = 7; |
1534 | bool combinedSatSun = false; | 1630 | bool combinedSatSun = false; |
1535 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1631 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1536 | daysToShow = 6; | 1632 | daysToShow = 6; |
1537 | combinedSatSun = true; | 1633 | combinedSatSun = true; |
1538 | } | 1634 | } |
1539 | int tWid = topLevelWidget()->size().width(); | 1635 | int tWid = topLevelWidget()->size().width(); |
1540 | int tHei = topLevelWidget()->size().height(); | 1636 | int tHei = topLevelWidget()->size().height(); |
1541 | 1637 | ||
1542 | int wid = width();//e | 1638 | int wid = width();//e |
1543 | int hei = height()-1-mNavigatorBar->height(); | 1639 | int hei = height()-1-mNavigatorBar->height(); |
1544 | 1640 | ||
1545 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1641 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1546 | return; | 1642 | return; |
1547 | } | 1643 | } |
1548 | if ( lastWid == width() && lastHei == height() ){ | 1644 | if ( lastWid == width() && lastHei == height() ){ |
1549 | qDebug("KOMonthview::No compute layout needed "); | 1645 | qDebug("KOMonthview::No compute layout needed "); |
1550 | return; | 1646 | return; |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 89912e0..b997c1a 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,307 +1,313 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qintdict.h> | 31 | #include <qintdict.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
34 | #include <qptrvector.h> | 34 | #include <qptrvector.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | #include <libkcal/event.h> | 37 | #include <libkcal/event.h> |
38 | 38 | ||
39 | #include "koeventview.h" | 39 | #include "koeventview.h" |
40 | #include "navigatorbar.h" | 40 | #include "navigatorbar.h" |
41 | 41 | ||
42 | #ifdef DESKTOP_VERSION | 42 | #ifdef DESKTOP_VERSION |
43 | class QToolTipGroup; | 43 | class QToolTipGroup; |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | class KNOWhatsThis; | 46 | class KNOWhatsThis; |
47 | class KOWeekButton : public QPushButton | 47 | class KOWeekButton : public QPushButton |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 51 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
52 | QPushButton( parent, name) | 52 | QPushButton( parent, name) |
53 | { | 53 | { |
54 | connect( this, SIGNAL( clicked() ), | 54 | connect( this, SIGNAL( clicked() ), |
55 | SLOT( bottonClicked() )); | 55 | SLOT( bottonClicked() )); |
56 | mNumber = -1; | 56 | mNumber = -1; |
57 | } | 57 | } |
58 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 58 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
59 | int getWeekNum() { return mNumber;} | 59 | int getWeekNum() { return mNumber;} |
60 | signals: | 60 | signals: |
61 | void selectWeekNum ( int ); | 61 | void selectWeekNum ( int ); |
62 | private: | 62 | private: |
63 | int mNumber; | 63 | int mNumber; |
64 | private slots : | 64 | private slots : |
65 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 65 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
66 | }; | 66 | }; |
67 | 67 | ||
68 | class KNoScrollListBox: public QListBox | 68 | class KNoScrollListBox: public QListBox |
69 | { | 69 | { |
70 | Q_OBJECT | 70 | Q_OBJECT |
71 | public: | 71 | public: |
72 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 72 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
73 | ~KNoScrollListBox(); | 73 | ~KNoScrollListBox(); |
74 | QString getWhatsThisText(QPoint p) ; | 74 | QString getWhatsThisText(QPoint p) ; |
75 | 75 | ||
76 | signals: | 76 | signals: |
77 | void shiftDown(); | 77 | void shiftDown(); |
78 | void shiftUp(); | 78 | void shiftUp(); |
79 | void rightClick(); | 79 | void rightClick(); |
80 | 80 | ||
81 | protected slots: | 81 | protected slots: |
82 | void oneDown(); | 82 | void oneDown(); |
83 | void keyPressEvent(QKeyEvent *); | 83 | void keyPressEvent(QKeyEvent *); |
84 | void keyReleaseEvent(QKeyEvent *); | 84 | void keyReleaseEvent(QKeyEvent *); |
85 | void mousePressEvent(QMouseEvent *); | 85 | void mousePressEvent(QMouseEvent *); |
86 | 86 | ||
87 | private: | 87 | private: |
88 | KNOWhatsThis * mWT; | 88 | KNOWhatsThis * mWT; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | 91 | ||
92 | class MonthViewItem: public QListBoxItem | 92 | class MonthViewItem: public QListBoxItem |
93 | { | 93 | { |
94 | public: | 94 | public: |
95 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 95 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
96 | 96 | void recycle( Incidence *incidence, QDate qd, const QString & s); | |
97 | void setRecur(bool on) { mRecur = on; } | 97 | void setRecur(bool on) { mRecur = on; } |
98 | void setAlarm(bool on) { mAlarm = on; } | 98 | void setAlarm(bool on) { mAlarm = on; } |
99 | void setReply(bool on) { mReply = on; } | 99 | void setReply(bool on) { mReply = on; } |
100 | void setMoreInfo(bool on) { mInfo = on; } | 100 | void setMoreInfo(bool on) { mInfo = on; } |
101 | void setMultiDay(int type) { mMultiday = type; } | 101 | void setMultiDay(int type) { mMultiday = type; } |
102 | void setBlockRepaint(bool on) { mblockRepaint = on; } | ||
102 | 103 | ||
103 | 104 | ||
104 | void setPalette(const QPalette &p) { mPalette = p; } | 105 | void setPalette(const QPalette &p) { mPalette = p; } |
105 | QPalette palette() const { return mPalette; } | 106 | QPalette palette() const { return mPalette; } |
106 | 107 | ||
107 | Incidence *incidence() const { return mIncidence; } | 108 | Incidence *incidence() const { return mIncidence; } |
108 | QDate incidenceDate() { return mDate; } | 109 | QDate incidenceDate() { return mDate; } |
109 | 110 | ||
110 | protected: | 111 | protected: |
111 | virtual void paint(QPainter *); | 112 | virtual void paint(QPainter *); |
112 | virtual int height(const QListBox *) const; | 113 | virtual int height(const QListBox *) const; |
113 | virtual int width(const QListBox *) const; | 114 | virtual int width(const QListBox *) const; |
114 | 115 | ||
115 | private: | 116 | private: |
117 | bool mblockRepaint; | ||
116 | int mMultiday; | 118 | int mMultiday; |
117 | bool mRecur; | 119 | bool mRecur; |
118 | bool mAlarm; | 120 | bool mAlarm; |
119 | bool mReply; | 121 | bool mReply; |
120 | bool mInfo; | 122 | bool mInfo; |
121 | 123 | ||
122 | QPalette mPalette; | 124 | QPalette mPalette; |
123 | QDate mDate; | 125 | QDate mDate; |
124 | 126 | ||
125 | Incidence *mIncidence; | 127 | Incidence *mIncidence; |
126 | }; | 128 | }; |
127 | 129 | ||
128 | 130 | ||
129 | class KOMonthView; | 131 | class KOMonthView; |
130 | 132 | ||
131 | class MonthViewCell : public QWidget | 133 | class MonthViewCell : public KNoScrollListBox |
132 | { | 134 | { |
133 | Q_OBJECT | 135 | Q_OBJECT |
134 | public: | 136 | public: |
135 | MonthViewCell(KOMonthView *,QWidget* ); | 137 | MonthViewCell(KOMonthView *,QWidget* ); |
138 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} | ||
136 | 139 | ||
137 | void setDate( const QDate & ); | 140 | void setDate( const QDate & ); |
138 | QDate date() const; | 141 | QDate date() const; |
139 | 142 | ||
140 | void setPrimary( bool ); | 143 | void setPrimary( bool ); |
141 | bool isPrimary() const; | 144 | bool isPrimary() const; |
142 | 145 | ||
143 | void setHoliday( bool ); | 146 | void setHoliday( bool ); |
144 | void setHoliday( const QString & ); | 147 | void setHoliday( const QString & ); |
145 | 148 | ||
146 | void updateCell(); | 149 | void updateCell(); |
147 | void startUpdateCell(); | 150 | void startUpdateCell(); |
148 | void finishUpdateCell(); | 151 | void finishUpdateCell(); |
152 | void repaintfinishUpdateCell(); | ||
149 | void insertEvent(Event *); | 153 | void insertEvent(Event *); |
150 | void insertTodo(Todo *); | 154 | void insertTodo(Todo *); |
151 | 155 | ||
152 | void updateConfig( bool bigFont = false ); | 156 | void updateConfig( bool bigFont = false ); |
153 | 157 | ||
154 | void enableScrollBars( bool ); | 158 | void enableScrollBars( bool ); |
155 | 159 | ||
156 | Incidence *selectedIncidence(); | 160 | Incidence *selectedIncidence(); |
157 | QDate selectedIncidenceDate(); | 161 | QDate selectedIncidenceDate(); |
158 | 162 | ||
159 | void deselect(); | 163 | void deselect(); |
160 | void select(); | 164 | void select(); |
161 | 165 | ||
162 | #ifdef DESKTOP_VERSION | 166 | #ifdef DESKTOP_VERSION |
163 | static QToolTipGroup *toolTipGroup(); | 167 | static QToolTipGroup *toolTipGroup(); |
164 | #endif | 168 | #endif |
165 | signals: | 169 | signals: |
166 | void defaultAction( Incidence * ); | 170 | void defaultAction( Incidence * ); |
167 | void newEventSignal( QDateTime ); | 171 | void newEventSignal( QDateTime ); |
168 | void showDaySignal( QDate ); | 172 | void showDaySignal( QDate ); |
169 | 173 | ||
170 | protected: | 174 | protected: |
171 | QStringList mToolTip; | 175 | QStringList mToolTip; |
172 | void resizeEvent( QResizeEvent * ); | 176 | void resizeEvent( QResizeEvent * ); |
173 | 177 | ||
174 | 178 | ||
175 | public slots: | 179 | public slots: |
176 | void showDay(); | 180 | void showDay(); |
177 | 181 | ||
178 | protected slots: | 182 | protected slots: |
179 | void defaultAction( QListBoxItem * ); | 183 | void defaultAction( QListBoxItem * ); |
180 | void contextMenu( QListBoxItem * ); | 184 | void contextMenu( QListBoxItem * ); |
181 | void selection( QListBoxItem * ); | 185 | void selection( QListBoxItem * ); |
182 | void cellClicked( QListBoxItem * ); | 186 | void cellClicked( QListBoxItem * ); |
183 | void newEvent(); | 187 | void newEvent(); |
184 | 188 | ||
185 | private: | 189 | private: |
190 | MonthViewItem* mCurrentAvailItem; | ||
191 | QPtrList <MonthViewItem> mAvailItemList; | ||
186 | KOMonthView *mMonthView; | 192 | KOMonthView *mMonthView; |
193 | int currentPalette; | ||
187 | 194 | ||
188 | QDate mDate; | 195 | QDate mDate; |
189 | bool mPrimary; | 196 | bool mPrimary; |
190 | bool mHoliday; | 197 | bool mHoliday; |
191 | QString mHolidayString; | 198 | QString mHolidayString; |
192 | 199 | ||
193 | //QLabel *mLabel; | 200 | //QLabel *mLabel; |
194 | QPushButton *mLabel; | 201 | QPushButton *mLabel; |
195 | QListBox *mItemList; | 202 | //QListBox *mItemList; |
196 | #ifdef DESKTOP_VERSION | 203 | #ifdef DESKTOP_VERSION |
197 | static QToolTipGroup *mToolTipGroup; | 204 | static QToolTipGroup *mToolTipGroup; |
198 | #endif | 205 | #endif |
199 | QSize mLabelSize; | 206 | QSize mLabelSize; |
200 | QSize mLabelBigSize; | 207 | QSize mLabelBigSize; |
201 | QPalette mHolidayPalette; | 208 | QPalette mHolidayPalette; |
202 | QPalette mStandardPalette; | 209 | QPalette mStandardPalette; |
203 | QPalette mPrimaryPalette; | 210 | QPalette mPrimaryPalette; |
204 | QPalette mNonPrimaryPalette; | 211 | QPalette mNonPrimaryPalette; |
205 | void setMyPalette(); | 212 | void setMyPalette(); |
206 | QPalette getPalette (); | 213 | QPalette getPalette (); |
207 | void keyPressEvent ( QKeyEvent * ) ; | ||
208 | 214 | ||
209 | }; | 215 | }; |
210 | 216 | ||
211 | 217 | ||
212 | class KOMonthView: public KOEventView | 218 | class KOMonthView: public KOEventView |
213 | { | 219 | { |
214 | Q_OBJECT | 220 | Q_OBJECT |
215 | public: | 221 | public: |
216 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 222 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
217 | ~KOMonthView(); | 223 | ~KOMonthView(); |
218 | 224 | ||
219 | /** Returns maximum number of days supported by the komonthview */ | 225 | /** Returns maximum number of days supported by the komonthview */ |
220 | virtual int maxDatesHint(); | 226 | virtual int maxDatesHint(); |
221 | 227 | ||
222 | /** Returns number of currently shown dates. */ | 228 | /** Returns number of currently shown dates. */ |
223 | virtual int currentDateCount(); | 229 | virtual int currentDateCount(); |
224 | 230 | ||
225 | /** returns the currently selected events */ | 231 | /** returns the currently selected events */ |
226 | virtual QPtrList<Incidence> selectedIncidences(); | 232 | virtual QPtrList<Incidence> selectedIncidences(); |
227 | 233 | ||
228 | /** returns dates of the currently selected events */ | 234 | /** returns dates of the currently selected events */ |
229 | virtual DateList selectedDates(); | 235 | virtual DateList selectedDates(); |
230 | 236 | ||
231 | virtual void printPreview(CalPrinter *calPrinter, | 237 | virtual void printPreview(CalPrinter *calPrinter, |
232 | const QDate &, const QDate &); | 238 | const QDate &, const QDate &); |
233 | bool isMonthView() { return !mShowWeekView; } | 239 | bool isMonthView() { return !mShowWeekView; } |
234 | bool isUpdatePossible() { return updatePossible; } | 240 | bool isUpdatePossible() { return updatePossible; } |
235 | 241 | ||
236 | MonthViewCell * selectedCell(); | 242 | MonthViewCell * selectedCell(); |
237 | bool skipResize; | 243 | bool skipResize; |
238 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 244 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
239 | public slots: | 245 | public slots: |
240 | virtual void updateView(); | 246 | virtual void updateView(); |
241 | virtual void updateConfig(); | 247 | virtual void updateConfig(); |
242 | virtual void showDates(const QDate &start, const QDate &end); | 248 | virtual void showDates(const QDate &start, const QDate &end); |
243 | virtual void showEvents(QPtrList<Event> eventList); | 249 | virtual void showEvents(QPtrList<Event> eventList); |
244 | 250 | ||
245 | void changeEventDisplay(Event *, int); | 251 | void changeEventDisplay(Event *, int); |
246 | 252 | ||
247 | void clearSelection(); | 253 | void clearSelection(); |
248 | 254 | ||
249 | void showContextMenu( Incidence * ); | 255 | void showContextMenu( Incidence * ); |
250 | 256 | ||
251 | void setSelectedCell( MonthViewCell * ); | 257 | void setSelectedCell( MonthViewCell * ); |
252 | void switchView(); | 258 | void switchView(); |
253 | 259 | ||
254 | protected slots: | 260 | protected slots: |
255 | void slotComputeLayout(); | 261 | void slotComputeLayout(); |
256 | void selectInternalWeekNum ( int ); | 262 | void selectInternalWeekNum ( int ); |
257 | void processSelectionChange(); | 263 | void processSelectionChange(); |
258 | signals: | 264 | signals: |
259 | void nextMonth(); | 265 | void nextMonth(); |
260 | void prevMonth(); | 266 | void prevMonth(); |
261 | void selectWeekNum ( int ); | 267 | void selectWeekNum ( int ); |
262 | void selectMonth (); | 268 | void selectMonth (); |
263 | void showDaySignal( QDate ); | 269 | void showDaySignal( QDate ); |
264 | protected: | 270 | protected: |
265 | void resizeEvent(QResizeEvent *); | 271 | void resizeEvent(QResizeEvent *); |
266 | void viewChanged(); | 272 | void viewChanged(); |
267 | void updateDayLabels(); | 273 | void updateDayLabels(); |
268 | 274 | ||
269 | private: | 275 | private: |
270 | QTimer* mComputeLayoutTimer; | 276 | QTimer* mComputeLayoutTimer; |
271 | NavigatorBar* mNavigatorBar; | 277 | NavigatorBar* mNavigatorBar; |
272 | int currentWeek(); | 278 | int currentWeek(); |
273 | bool clPending; | 279 | bool clPending; |
274 | QWidgetStack * mWidStack; | 280 | QWidgetStack * mWidStack; |
275 | QWidget* mMonthView; | 281 | QWidget* mMonthView; |
276 | QWidget* mWeekView; | 282 | QWidget* mWeekView; |
277 | bool mShowWeekView; | 283 | bool mShowWeekView; |
278 | bool updatePossible; | 284 | bool updatePossible; |
279 | int mDaysPerWeek; | 285 | int mDaysPerWeek; |
280 | int mNumWeeks; | 286 | int mNumWeeks; |
281 | int mNumCells; | 287 | int mNumCells; |
282 | bool mWeekStartsMonday; | 288 | bool mWeekStartsMonday; |
283 | bool mShowSatSunComp; | 289 | bool mShowSatSunComp; |
284 | void computeLayout(); | 290 | void computeLayout(); |
285 | void computeLayoutWeek(); | 291 | void computeLayoutWeek(); |
286 | 292 | ||
287 | QPtrVector<MonthViewCell> mCells; | 293 | QPtrVector<MonthViewCell> mCells; |
288 | QPtrVector<QLabel> mDayLabels; | 294 | QPtrVector<QLabel> mDayLabels; |
289 | QPtrVector<KOWeekButton> mWeekLabels; | 295 | QPtrVector<KOWeekButton> mWeekLabels; |
290 | QPtrVector<MonthViewCell> mCellsW; | 296 | QPtrVector<MonthViewCell> mCellsW; |
291 | QPtrVector<QLabel> mDayLabelsW; | 297 | QPtrVector<QLabel> mDayLabelsW; |
292 | QPtrVector<KOWeekButton> mWeekLabelsW; | 298 | QPtrVector<KOWeekButton> mWeekLabelsW; |
293 | 299 | ||
294 | bool mShortDayLabelsM; | 300 | bool mShortDayLabelsM; |
295 | bool mShortDayLabelsW; | 301 | bool mShortDayLabelsW; |
296 | int mWidthLongDayLabel; | 302 | int mWidthLongDayLabel; |
297 | 303 | ||
298 | QDate mStartDate; | 304 | QDate mStartDate; |
299 | 305 | ||
300 | MonthViewCell *mSelectedCell; | 306 | MonthViewCell *mSelectedCell; |
301 | 307 | ||
302 | KOEventPopupMenu *mContextMenu; | 308 | KOEventPopupMenu *mContextMenu; |
303 | void keyPressEvent ( QKeyEvent * ) ; | 309 | void keyPressEvent ( QKeyEvent * ) ; |
304 | 310 | ||
305 | }; | 311 | }; |
306 | 312 | ||
307 | #endif | 313 | #endif |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 94d74f1..c6e76c4 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -19,406 +19,407 @@ | |||
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") { | 91 | else if (view == "Month") { |
92 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 92 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
93 | showMonthView(); | 93 | showMonthView(); |
94 | else | 94 | else |
95 | showMonthViewWeek(); | 95 | showMonthViewWeek(); |
96 | } | 96 | } |
97 | else if (view == "List") showListView(); | 97 | else if (view == "List") showListView(); |
98 | else if (view == "Journal") showJournalView(); | 98 | else if (view == "Journal") showJournalView(); |
99 | else if (view == "TimeSpan") showTimeSpanView(); | 99 | else if (view == "TimeSpan") showTimeSpanView(); |
100 | else if (view == "Todo") showTodoView(); | 100 | else if (view == "Todo") showTodoView(); |
101 | else { | 101 | else { |
102 | config->setGroup( "Views" ); | 102 | config->setGroup( "Views" ); |
103 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 103 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
104 | mCurrentAgendaView = dateCount; | 104 | mCurrentAgendaView = dateCount; |
105 | showAgendaView(); | 105 | showAgendaView(); |
106 | mCurrentAgendaView = dateCount; | 106 | mCurrentAgendaView = dateCount; |
107 | #ifdef DESKTOP_VERSION | 107 | #ifdef DESKTOP_VERSION |
108 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); | 108 | QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); |
109 | #endif | 109 | #endif |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | void KOViewManager::showDateView( int view, QDate date) | 113 | void KOViewManager::showDateView( int view, QDate date) |
114 | { | 114 | { |
115 | static int lastMode = 0; | 115 | static int lastMode = 0; |
116 | static int lastCount = 0; | 116 | static int lastCount = 0; |
117 | static bool lastNDMode = false; | 117 | static bool lastNDMode = false; |
118 | static QDate lastDate; | 118 | static QDate lastDate; |
119 | //qDebug("date %d %s", view, date.toString().latin1()); | 119 | //qDebug("date %d %s", view, date.toString().latin1()); |
120 | 120 | ||
121 | if (view != 9) | 121 | if (view != 9) |
122 | lastMode = 0; | 122 | lastMode = 0; |
123 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); | 123 | //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); |
124 | bool savemFlagShowNextxDays = mFlagShowNextxDays; | 124 | bool savemFlagShowNextxDays = mFlagShowNextxDays; |
125 | mFlagShowNextxDays = false; | 125 | mFlagShowNextxDays = false; |
126 | if ( view == 3 ) { | 126 | if ( view == 3 ) { |
127 | //mCurrentAgendaView = 1 ; | 127 | //mCurrentAgendaView = 1 ; |
128 | lastDate = mMainView->dateNavigator()->selectedDates().first(); | 128 | lastDate = mMainView->dateNavigator()->selectedDates().first(); |
129 | lastCount = mMainView->dateNavigator()->selectedDates().count(); | 129 | lastCount = mMainView->dateNavigator()->selectedDates().count(); |
130 | lastNDMode = savemFlagShowNextxDays; | 130 | lastNDMode = savemFlagShowNextxDays; |
131 | mMainView->showDay( date ); | 131 | mMainView->showDay( date ); |
132 | lastMode = 1; | 132 | lastMode = 1; |
133 | } else if (view == 4 ) { | 133 | } else if (view == 4 ) { |
134 | mCurrentAgendaView = 7 ; | 134 | mCurrentAgendaView = 7 ; |
135 | mMainView->dateNavigator()->selectDates( date, 7 ); | 135 | mMainView->dateNavigator()->selectDates( date, 7 ); |
136 | } else if (view == 5 ) { | 136 | } else if (view == 5 ) { |
137 | mCurrentAgendaView = 14 ; | 137 | mCurrentAgendaView = 14 ; |
138 | mMainView->dateNavigator()->selectDates( date, 14); | 138 | mMainView->dateNavigator()->selectDates( date, 14); |
139 | } else if (view == 6 ) { | 139 | } else if (view == 6 ) { |
140 | //mMainView->dateNavigator()->selectDates( date, 7 ); | 140 | //mMainView->dateNavigator()->selectDates( date, 7 ); |
141 | showMonthView(); | 141 | showMonthView(); |
142 | } else if (view == 7 ) { | 142 | } else if (view == 7 ) { |
143 | mMainView->dateNavigator()->selectDate( date ); | 143 | mMainView->dateNavigator()->selectDate( date ); |
144 | showJournalView(); | 144 | showJournalView(); |
145 | } else if (view == 8 ) { | 145 | } else if (view == 8 ) { |
146 | globalFlagBlockAgenda = 1; | 146 | globalFlagBlockAgenda = 1; |
147 | if ( mCurrentAgendaView != 3 ) | 147 | if ( mCurrentAgendaView != 3 ) |
148 | mCurrentAgendaView = -1; | 148 | mCurrentAgendaView = -1; |
149 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 149 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
150 | globalFlagBlockAgenda = 2; | 150 | globalFlagBlockAgenda = 2; |
151 | mMainView->dateNavigator()->selectDates( date , | 151 | mMainView->dateNavigator()->selectDates( date , |
152 | KOPrefs::instance()->mNextXDays ); | 152 | KOPrefs::instance()->mNextXDays ); |
153 | mFlagShowNextxDays = true; | 153 | mFlagShowNextxDays = true; |
154 | mCurrentAgendaView = 3 ; | 154 | mCurrentAgendaView = 3 ; |
155 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) | 155 | } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) |
156 | if ( lastMode ) { | 156 | if ( lastMode ) { |
157 | mCurrentAgendaView = lastCount ; | 157 | mCurrentAgendaView = lastCount ; |
158 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); | 158 | mMainView->dateNavigator()->selectDates( lastDate, lastCount); |
159 | mFlagShowNextxDays = lastNDMode; | 159 | mFlagShowNextxDays = lastNDMode; |
160 | if ( mFlagShowNextxDays ) { | 160 | if ( mFlagShowNextxDays ) { |
161 | mCurrentAgendaView = 3 ; | 161 | mCurrentAgendaView = 3 ; |
162 | } | 162 | } |
163 | } else | 163 | } else |
164 | showWeekView(); | 164 | showWeekView(); |
165 | } else if (view == 10) { | 165 | } else if (view == 10) { |
166 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); | 166 | mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | void KOViewManager::writeSettings(KConfig *config) | 172 | void KOViewManager::writeSettings(KConfig *config) |
173 | { | 173 | { |
174 | config->setGroup("General"); | 174 | config->setGroup("General"); |
175 | 175 | ||
176 | QString view; | 176 | QString view; |
177 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 177 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
178 | else if (mCurrentView == mMonthView) view = "Month"; | 178 | else if (mCurrentView == mMonthView) view = "Month"; |
179 | else if (mCurrentView == mListView) view = "List"; | 179 | else if (mCurrentView == mListView) view = "List"; |
180 | else if (mCurrentView == mJournalView) view = "Journal"; | 180 | else if (mCurrentView == mJournalView) view = "Journal"; |
181 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 181 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
182 | else if (mCurrentView == mTodoView) view = "Todo"; | 182 | else if (mCurrentView == mTodoView) view = "Todo"; |
183 | else view = "Agenda"; | 183 | else view = "Agenda"; |
184 | 184 | ||
185 | config->writeEntry("Current View",view); | 185 | config->writeEntry("Current View",view); |
186 | 186 | ||
187 | if (mAgendaView) { | 187 | if (mAgendaView) { |
188 | mAgendaView->writeSettings(config); | 188 | mAgendaView->writeSettings(config); |
189 | } | 189 | } |
190 | if (mTimeSpanView) { | 190 | if (mTimeSpanView) { |
191 | mTimeSpanView->writeSettings(config); | 191 | mTimeSpanView->writeSettings(config); |
192 | } | 192 | } |
193 | if (mListView) { | 193 | if (mListView) { |
194 | mListView->writeSettings(config); | 194 | mListView->writeSettings(config); |
195 | } | 195 | } |
196 | if (mTodoView) { | 196 | if (mTodoView) { |
197 | mTodoView->saveLayout(config,"Todo View"); | 197 | mTodoView->saveLayout(config,"Todo View"); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 201 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
202 | { | 202 | { |
203 | 203 | ||
204 | //mFlagShowNextxDays = false; | 204 | //mFlagShowNextxDays = false; |
205 | //if(view == mCurrentView) return; | 205 | //if(view == mCurrentView) return; |
206 | if ( view == 0 ) { | 206 | if ( view == 0 ) { |
207 | view = mCurrentView; | 207 | view = mCurrentView; |
208 | if ( view == 0 ) | 208 | if ( view == 0 ) |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | bool callupdate = !(view == mCurrentView); | ||
211 | bool full = fullScreen; | 212 | bool full = fullScreen; |
212 | if(view == mCurrentView && view != mWhatsNextView ) { | 213 | if(view == mCurrentView && view != mWhatsNextView ) { |
213 | if ( mCurrentAgendaView < 0 ) | 214 | if ( mCurrentAgendaView < 0 ) |
214 | return; | 215 | return; |
215 | if ( view != mMonthView ) | 216 | if ( view != mMonthView ) |
216 | full = mMainView->leftFrame()->isVisible(); | 217 | full = mMainView->leftFrame()->isVisible(); |
217 | } else { | 218 | } else { |
218 | if ( view == mMonthView && mMonthView) | 219 | if ( view == mMonthView && mMonthView) |
219 | ;//mMonthView->skipResize = true ; | 220 | ;//mMonthView->skipResize = true ; |
220 | mCurrentView = view; | 221 | mCurrentView = view; |
221 | // bool full = fullScreen; | 222 | // bool full = fullScreen; |
222 | bool isFull = !mMainView->leftFrame()->isVisible(); | 223 | bool isFull = !mMainView->leftFrame()->isVisible(); |
223 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 224 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
224 | full = true; | 225 | full = true; |
225 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 226 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
226 | full = false; | 227 | full = false; |
227 | } | 228 | } |
228 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 229 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
229 | //raiseCurrentView( full ); | 230 | //raiseCurrentView( full ); |
230 | mMainView->processIncidenceSelection( 0 ); | 231 | mMainView->processIncidenceSelection( 0 ); |
231 | //mMainView->updateView(); | 232 | //mMainView->updateView(); |
232 | raiseCurrentView( full, true ); | 233 | raiseCurrentView( full, callupdate ); |
233 | mMainView->adaptNavigationUnits(); | 234 | mMainView->adaptNavigationUnits(); |
234 | } | 235 | } |
235 | 236 | ||
236 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | 237 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
237 | { | 238 | { |
238 | mCurrentAgendaView = 0; | 239 | mCurrentAgendaView = 0; |
239 | if ( fullScreen ) { | 240 | if ( fullScreen ) { |
240 | mMainView->leftFrame()->hide(); | 241 | mMainView->leftFrame()->hide(); |
241 | } else { | 242 | } else { |
242 | mMainView->leftFrame()->show(); | 243 | mMainView->leftFrame()->show(); |
243 | } | 244 | } |
244 | //if ( mCurrentView == mMonthView ) qApp->processEvents(); | 245 | //if ( mCurrentView == mMonthView ) qApp->processEvents(); |
245 | emit signalFullScreen( !fullScreen ); | 246 | emit signalFullScreen( !fullScreen ); |
246 | if ( callUpdateView ) | 247 | if ( callUpdateView ) |
247 | mMainView->updateView(); | 248 | mMainView->updateView(); |
248 | 249 | ||
249 | if ( globalFlagBlockAgenda == 5 ) { | 250 | if ( globalFlagBlockAgenda == 5 ) { |
250 | globalFlagBlockAgenda = 4; | 251 | globalFlagBlockAgenda = 4; |
251 | globalFlagBlockAgendaItemPaint = 1; | 252 | globalFlagBlockAgendaItemPaint = 1; |
252 | } | 253 | } |
253 | mMainView->viewStack()->raiseWidget(mCurrentView); | 254 | mMainView->viewStack()->raiseWidget(mCurrentView); |
254 | if ( globalFlagBlockAgenda == 4 ) { | 255 | if ( globalFlagBlockAgenda == 4 ) { |
255 | if ( mCurrentView == mAgendaView ) { | 256 | if ( mCurrentView == mAgendaView ) { |
256 | //globalFlagBlockAgenda =1 ; | 257 | //globalFlagBlockAgenda =1 ; |
257 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 258 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
258 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 259 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
259 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 260 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
260 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 261 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
261 | qApp->processEvents(); | 262 | qApp->processEvents(); |
262 | //qDebug("qApp->processEvents() "); | 263 | //qDebug("qApp->processEvents() "); |
263 | globalFlagBlockAgenda = 0; | 264 | globalFlagBlockAgenda = 0; |
264 | mAgendaView->repaintAgenda(); | 265 | mAgendaView->repaintAgenda(); |
265 | 266 | ||
266 | } | 267 | } |
267 | globalFlagBlockAgenda = 0; | 268 | globalFlagBlockAgenda = 0; |
268 | } | 269 | } |
269 | emit signalAgendaView( mCurrentView == mAgendaView ); | 270 | emit signalAgendaView( mCurrentView == mAgendaView ); |
270 | //qDebug("raiseCurrentView ende "); | 271 | //qDebug("raiseCurrentView ende "); |
271 | 272 | ||
272 | } | 273 | } |
273 | 274 | ||
274 | void KOViewManager::updateView() | 275 | void KOViewManager::updateView() |
275 | { | 276 | { |
276 | // qDebug("KOViewManager::updateView() "); | 277 | // qDebug("KOViewManager::updateView() "); |
277 | // if we are updating mTodoView, we get endless recursion | 278 | // if we are updating mTodoView, we get endless recursion |
278 | if ( mTodoView == mCurrentView ) | 279 | if ( mTodoView == mCurrentView ) |
279 | return; | 280 | return; |
280 | if ( mCurrentView ) mCurrentView->updateView(); | 281 | if ( mCurrentView ) mCurrentView->updateView(); |
281 | 282 | ||
282 | } | 283 | } |
283 | 284 | ||
284 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 285 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
285 | { | 286 | { |
286 | // kdDebug() << "KOViewManager::updateView()" << endl; | 287 | // kdDebug() << "KOViewManager::updateView()" << endl; |
287 | 288 | ||
288 | if (mCurrentView) mCurrentView->showDates(start, end); | 289 | if (mCurrentView) mCurrentView->showDates(start, end); |
289 | 290 | ||
290 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); | 291 | if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); |
291 | } | 292 | } |
292 | 293 | ||
293 | 294 | ||
294 | void KOViewManager::updateWNview() | 295 | void KOViewManager::updateWNview() |
295 | { | 296 | { |
296 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 297 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
297 | mWhatsNextView->updateView(); | 298 | mWhatsNextView->updateView(); |
298 | 299 | ||
299 | } | 300 | } |
300 | void KOViewManager::showWhatsNextView() | 301 | void KOViewManager::showWhatsNextView() |
301 | { | 302 | { |
302 | if (!mWhatsNextView) { | 303 | if (!mWhatsNextView) { |
303 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 304 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
304 | "KOViewManager::WhatsNextView"); | 305 | "KOViewManager::WhatsNextView"); |
305 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 306 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
306 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 307 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
307 | addView(mWhatsNextView); | 308 | addView(mWhatsNextView); |
308 | connect(this, SIGNAL( printWNV() ), | 309 | connect(this, SIGNAL( printWNV() ), |
309 | mWhatsNextView, SLOT( printMe() ) ); | 310 | mWhatsNextView, SLOT( printMe() ) ); |
310 | } | 311 | } |
311 | globalFlagBlockAgenda = 1; | 312 | globalFlagBlockAgenda = 1; |
312 | showView(mWhatsNextView, true ); | 313 | showView(mWhatsNextView, true ); |
313 | //mWhatsNextView->updateView(); | 314 | //mWhatsNextView->updateView(); |
314 | 315 | ||
315 | } | 316 | } |
316 | 317 | ||
317 | void KOViewManager::showListView() | 318 | void KOViewManager::showListView() |
318 | { | 319 | { |
319 | if (!mListView) { | 320 | if (!mListView) { |
320 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 321 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
321 | addView(mListView); | 322 | addView(mListView); |
322 | 323 | ||
323 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 324 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
324 | mMainView, SLOT(showIncidence(Incidence *))); | 325 | mMainView, SLOT(showIncidence(Incidence *))); |
325 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 326 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
326 | mMainView, SLOT(editIncidence(Incidence *))); | 327 | mMainView, SLOT(editIncidence(Incidence *))); |
327 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 328 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
328 | mMainView, SLOT(deleteIncidence(Incidence *))); | 329 | mMainView, SLOT(deleteIncidence(Incidence *))); |
329 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 330 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
330 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 331 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
331 | connect( mListView, SIGNAL( signalNewEvent() ), | 332 | connect( mListView, SIGNAL( signalNewEvent() ), |
332 | mMainView, SLOT( newEvent() ) ); | 333 | mMainView, SLOT( newEvent() ) ); |
333 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 334 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
334 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 335 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
335 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 336 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
336 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 337 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
337 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 338 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
338 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 339 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
339 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 340 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
340 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 341 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
341 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 342 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
342 | } | 343 | } |
343 | // bool temp = mFlagShowNextxDays; | 344 | // bool temp = mFlagShowNextxDays; |
344 | //globalFlagBlockPainting = true; | 345 | //globalFlagBlockPainting = true; |
345 | globalFlagBlockAgenda = 1; | 346 | globalFlagBlockAgenda = 1; |
346 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 347 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
347 | mMainView->setBlockShowDates( true ); | 348 | mMainView->setBlockShowDates( true ); |
348 | mMainView->dateNavigator()->selectMonth(); | 349 | mMainView->dateNavigator()->selectMonth(); |
349 | mMainView->setBlockShowDates( false ); | 350 | mMainView->setBlockShowDates( false ); |
350 | } | 351 | } |
351 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 352 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
352 | //mFlagShowNextxDays = temp; | 353 | //mFlagShowNextxDays = temp; |
353 | } | 354 | } |
354 | 355 | ||
355 | void KOViewManager::showAgendaView( bool fullScreen ) | 356 | void KOViewManager::showAgendaView( bool fullScreen ) |
356 | { | 357 | { |
357 | 358 | ||
358 | mMainView->dialogManager()->hideSearchDialog(); | 359 | mMainView->dialogManager()->hideSearchDialog(); |
359 | // qDebug("KOViewManager::showAgendaView "); | 360 | // qDebug("KOViewManager::showAgendaView "); |
360 | bool full; | 361 | bool full; |
361 | full = fullScreen; | 362 | full = fullScreen; |
362 | if (!mAgendaView) { | 363 | if (!mAgendaView) { |
363 | full = false; | 364 | full = false; |
364 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 365 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
365 | addView(mAgendaView); | 366 | addView(mAgendaView); |
366 | #ifndef DESKTOP_VERSION | 367 | #ifndef DESKTOP_VERSION |
367 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 368 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
368 | #endif | 369 | #endif |
369 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 370 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
370 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 371 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
371 | 372 | ||
372 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 373 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
373 | 374 | ||
374 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 375 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
375 | 376 | ||
376 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 377 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
377 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 378 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
378 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 379 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
379 | mMainView, SLOT(newEvent(QDateTime))); | 380 | mMainView, SLOT(newEvent(QDateTime))); |
380 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 381 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
381 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 382 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
382 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 383 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
383 | mMainView, SLOT(newEvent(QDate))); | 384 | mMainView, SLOT(newEvent(QDate))); |
384 | 385 | ||
385 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 386 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
386 | mMainView, SLOT(editIncidence(Incidence *))); | 387 | mMainView, SLOT(editIncidence(Incidence *))); |
387 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 388 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
388 | mMainView, SLOT(showIncidence(Incidence *))); | 389 | mMainView, SLOT(showIncidence(Incidence *))); |
389 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 390 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
390 | mMainView, SLOT(deleteIncidence(Incidence *))); | 391 | mMainView, SLOT(deleteIncidence(Incidence *))); |
391 | 392 | ||
392 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 393 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
393 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 394 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
394 | 395 | ||
395 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 396 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
396 | mMainView, SLOT( toggleExpand() ) ); | 397 | mMainView, SLOT( toggleExpand() ) ); |
397 | 398 | ||
398 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 399 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
399 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 400 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
400 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 401 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
401 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 402 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
402 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 403 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
403 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 404 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
404 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 405 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
405 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 406 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
406 | SLOT( updateTodo( Todo *, int ) ) ); | 407 | SLOT( updateTodo( Todo *, int ) ) ); |
407 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 408 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
408 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 409 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
409 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 410 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
410 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 411 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
411 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 412 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
412 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 413 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
413 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), | 414 | connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), |
414 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); | 415 | mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); |
415 | mAgendaView->readSettings(); | 416 | mAgendaView->readSettings(); |
416 | mAgendaView->updateConfig(); | 417 | mAgendaView->updateConfig(); |
417 | } | 418 | } |
418 | 419 | ||
419 | showView( mAgendaView, full); | 420 | showView( mAgendaView, full); |
420 | 421 | ||
421 | } | 422 | } |
422 | 423 | ||
423 | void KOViewManager::showDayView() | 424 | void KOViewManager::showDayView() |
424 | { | 425 | { |