author | zautrix <zautrix> | 2005-03-19 22:56:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-19 22:56:08 (UTC) |
commit | 84c18843bbd1203878367572d3a6800a0586c7f1 (patch) (unidiff) | |
tree | 9f58b7356ea700d47e6ec84fb4a462a666a24049 /korganizer/kodaymatrix.cpp | |
parent | 39b719bdc75d95913c3aaf9a03aaa57b1161cc61 (diff) | |
download | kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.zip kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.gz kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.bz2 |
mochn fix
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a886f4a..17a8546 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -12,385 +12,385 @@ | |||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | #include <libkcal/vcaldrag.h> | 34 | #include <libkcal/vcaldrag.h> |
35 | #include <libkcal/icaldrag.h> | 35 | #include <libkcal/icaldrag.h> |
36 | #include <libkcal/dndfactory.h> | 36 | #include <libkcal/dndfactory.h> |
37 | #include <libkcal/calendarresources.h> | 37 | #include <libkcal/calendarresources.h> |
38 | #include <libkcal/resourcecalendar.h> | 38 | #include <libkcal/resourcecalendar.h> |
39 | #include <kresources/resourceselectdialog.h> | 39 | #include <kresources/resourceselectdialog.h> |
40 | 40 | ||
41 | #include <kcalendarsystem.h> | 41 | #include <kcalendarsystem.h> |
42 | 42 | ||
43 | #ifndef KORG_NOPLUGINS | 43 | #ifndef KORG_NOPLUGINS |
44 | #include "kocore.h" | 44 | #include "kocore.h" |
45 | #endif | 45 | #endif |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "koglobals.h" | 47 | #include "koglobals.h" |
48 | 48 | ||
49 | #include "kodaymatrix.h" | 49 | #include "kodaymatrix.h" |
50 | 50 | ||
51 | // ============================================================================ | 51 | // ============================================================================ |
52 | // D Y N A M I C T I P | 52 | // D Y N A M I C T I P |
53 | // ============================================================================ | 53 | // ============================================================================ |
54 | 54 | ||
55 | DynamicTip::DynamicTip( QWidget * parent ) | 55 | DynamicTip::DynamicTip( QWidget * parent ) |
56 | : QToolTip( parent ) | 56 | : QToolTip( parent ) |
57 | { | 57 | { |
58 | matrix = (KODayMatrix*)parent; | 58 | matrix = (KODayMatrix*)parent; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void DynamicTip::maybeTip( const QPoint &pos ) | 62 | void DynamicTip::maybeTip( const QPoint &pos ) |
63 | { | 63 | { |
64 | //calculate which cell of the matrix the mouse is in | 64 | //calculate which cell of the matrix the mouse is in |
65 | QRect sz = matrix->frameRect(); | 65 | QRect sz = matrix->frameRect(); |
66 | int dheight = sz.height()*7 / 42; | 66 | int dheight = sz.height()*7 / 42; |
67 | int dwidth = sz.width() / 7; | 67 | int dwidth = sz.width() / 7; |
68 | int row = pos.y()/dheight; | 68 | int row = pos.y()/dheight; |
69 | int col = pos.x()/dwidth; | 69 | int col = pos.x()/dwidth; |
70 | 70 | ||
71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
72 | 72 | ||
73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
74 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 74 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
75 | 75 | ||
76 | //show holiday names only | 76 | //show holiday names only |
77 | QString str = matrix->getHolidayLabel(col+row*7); | 77 | QString str = matrix->getHolidayLabel(col+row*7); |
78 | if (str.isEmpty()) return; | 78 | if (str.isEmpty()) return; |
79 | tip(rct, str); | 79 | tip(rct, str); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | // ============================================================================ | 83 | // ============================================================================ |
84 | // K O D A Y M A T R I X | 84 | // K O D A Y M A T R I X |
85 | // ============================================================================ | 85 | // ============================================================================ |
86 | 86 | ||
87 | const int KODayMatrix::NOSELECTION = -1000; | 87 | const int KODayMatrix::NOSELECTION = -1000; |
88 | const int KODayMatrix::NUMDAYS = 42; | 88 | const int KODayMatrix::NUMDAYS = 42; |
89 | 89 | ||
90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
91 | : QFrame( parent, name ), mCalendar( 0 ) | 91 | : QFrame( parent, name ), mCalendar( 0 ) |
92 | 92 | ||
93 | #if 0 | 93 | #if 0 |
94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
95 | QFrame(parent, name) | 95 | QFrame(parent, name) |
96 | #endif | 96 | #endif |
97 | { | 97 | { |
98 | 98 | ||
99 | mPendingUpdateBeforeRepaint = false; | 99 | mPendingUpdateBeforeRepaint = false; |
100 | 100 | ||
101 | // initialize dynamic arrays | 101 | // initialize dynamic arrays |
102 | days = new QDate[NUMDAYS]; | 102 | days = new QDate[NUMDAYS]; |
103 | daylbls = new QString[NUMDAYS]; | 103 | daylbls = new QString[NUMDAYS]; |
104 | events = new int[NUMDAYS]; | 104 | events = new int[NUMDAYS]; |
105 | mToolTip = new DynamicTip(this); | 105 | mToolTip = new DynamicTip(this); |
106 | 106 | ||
107 | // set default values used for drawing the matrix | 107 | // set default values used for drawing the matrix |
108 | mDefaultBackColor = palette().active().base(); | 108 | mDefaultBackColor = palette().active().base(); |
109 | mDefaultTextColor = palette().active().foreground(); | 109 | mDefaultTextColor = palette().active().foreground(); |
110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
112 | mSelectedDaysColor = QColor("white"); | 112 | mSelectedDaysColor = QColor("white"); |
113 | mTodayMarginWidth = 2; | 113 | mTodayMarginWidth = 2; |
114 | mSelEnd = mSelStart = NOSELECTION; | 114 | mSelEnd = mSelStart = NOSELECTION; |
115 | 115 | ||
116 | setAcceptDrops(true); | 116 | setAcceptDrops(true); |
117 | //setFont( QFont("Arial", 10) ); | 117 | //setFont( QFont("Arial", 10) ); |
118 | 118 | ||
119 | mUpdateTimer = new QTimer( this ); | 119 | mUpdateTimer = new QTimer( this ); |
120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
121 | mRepaintTimer = new QTimer( this ); | 121 | mRepaintTimer = new QTimer( this ); |
122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
123 | mDayChanged = false; | 123 | mDayChanged = false; |
124 | updateView(); | 124 | updateView(); |
125 | } | 125 | } |
126 | void KODayMatrix::setCalendar( Calendar *cal ) | 126 | void KODayMatrix::setCalendar( Calendar *cal ) |
127 | { | 127 | { |
128 | mCalendar = cal; | 128 | mCalendar = cal; |
129 | 129 | ||
130 | setAcceptDrops( mCalendar ); | 130 | setAcceptDrops( mCalendar ); |
131 | 131 | ||
132 | updateEvents(); | 132 | updateEvents(); |
133 | } | 133 | } |
134 | 134 | ||
135 | QColor KODayMatrix::getShadedColor(QColor color) | 135 | QColor KODayMatrix::getShadedColor(QColor color) |
136 | { | 136 | { |
137 | QColor shaded; | 137 | QColor shaded; |
138 | int h=0; | 138 | int h=0; |
139 | int s=0; | 139 | int s=0; |
140 | int v=0; | 140 | int v=0; |
141 | color.hsv(&h,&s,&v); | 141 | color.hsv(&h,&s,&v); |
142 | s = s/4; | 142 | s = s/4; |
143 | v = 192+v/4; | 143 | v = 192+v/4; |
144 | shaded.setHsv(h,s,v); | 144 | shaded.setHsv(h,s,v); |
145 | 145 | ||
146 | return shaded; | 146 | return shaded; |
147 | } | 147 | } |
148 | 148 | ||
149 | KODayMatrix::~KODayMatrix() | 149 | KODayMatrix::~KODayMatrix() |
150 | { | 150 | { |
151 | delete [] days; | 151 | delete [] days; |
152 | delete [] daylbls; | 152 | delete [] daylbls; |
153 | delete [] events; | 153 | delete [] events; |
154 | delete mToolTip; | 154 | delete mToolTip; |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | void KODayMatrix::setStartDate(QDate start) | 158 | void KODayMatrix::setStartDate(QDate start) |
159 | { | 159 | { |
160 | updateView(start); | 160 | updateView(start); |
161 | } | 161 | } |
162 | */ | 162 | */ |
163 | 163 | ||
164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
165 | { | 165 | { |
166 | 166 | ||
167 | if (mSelStart == NOSELECTION) { | 167 | if (mSelStart == NOSELECTION) { |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | //cope with selection being out of matrix limits at top (< 0) | 171 | //cope with selection being out of matrix limits at top (< 0) |
172 | int i0 = mSelStart; | 172 | int i0 = mSelStart; |
173 | if (i0 < 0) { | 173 | if (i0 < 0) { |
174 | for (int i = i0; i < 0; i++) { | 174 | for (int i = i0; i < 0; i++) { |
175 | selDays.append(days[0].addDays(i)); | 175 | selDays.append(days[0].addDays(i)); |
176 | } | 176 | } |
177 | i0 = 0; | 177 | i0 = 0; |
178 | } | 178 | } |
179 | 179 | ||
180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
181 | if (mSelEnd > NUMDAYS-1) { | 181 | if (mSelEnd > NUMDAYS-1) { |
182 | for (int i = i0; i <= NUMDAYS-1; i++) { | 182 | for (int i = i0; i <= NUMDAYS-1; i++) { |
183 | selDays.append(days[i]); | 183 | selDays.append(days[i]); |
184 | } | 184 | } |
185 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 185 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
186 | selDays.append(days[0].addDays(i)); | 186 | selDays.append(days[0].addDays(i)); |
187 | } | 187 | } |
188 | 188 | ||
189 | // apply normal routine to selection being entirely within matrix limits | 189 | // apply normal routine to selection being entirely within matrix limits |
190 | } else { | 190 | } else { |
191 | for (int i = i0; i <= mSelEnd; i++) { | 191 | for (int i = i0; i <= mSelEnd; i++) { |
192 | selDays.append(days[i]); | 192 | selDays.append(days[i]); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
198 | { | 198 | { |
199 | mSelStart = startdate.daysTo(start); | 199 | mSelStart = startdate.daysTo(start); |
200 | mSelEnd = startdate.daysTo(end); | 200 | mSelEnd = startdate.daysTo(end); |
201 | } | 201 | } |
202 | void KODayMatrix::clearSelection() | 202 | void KODayMatrix::clearSelection() |
203 | { | 203 | { |
204 | mSelEnd = mSelStart = NOSELECTION; | 204 | mSelEnd = mSelStart = NOSELECTION; |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | void KODayMatrix::recalculateToday() | 208 | void KODayMatrix::recalculateToday() |
209 | { | 209 | { |
210 | today = -1; | 210 | today = -1; |
211 | for (int i=0; i<NUMDAYS; i++) { | 211 | for (int i=0; i<NUMDAYS; i++) { |
212 | events[i] = 0; | 212 | events[i] = 0; |
213 | days[i] = startdate.addDays(i); | 213 | days[i] = startdate.addDays(i); |
214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
215 | 215 | ||
216 | // if today is in the currently displayed month, hilight today | 216 | // if today is in the currently displayed month, hilight today |
217 | if (days[i].year() == QDate::currentDate().year() && | 217 | if (days[i].year() == QDate::currentDate().year() && |
218 | days[i].month() == QDate::currentDate().month() && | 218 | days[i].month() == QDate::currentDate().month() && |
219 | days[i].day() == QDate::currentDate().day()) { | 219 | days[i].day() == QDate::currentDate().day()) { |
220 | today = i; | 220 | today = i; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | // qDebug(QString("Today is visible at %1.").arg(today)); | 223 | // qDebug(QString("Today is visible at %1.").arg(today)); |
224 | } | 224 | } |
225 | 225 | ||
226 | void KODayMatrix::updateView() | 226 | void KODayMatrix::updateView() |
227 | { | 227 | { |
228 | updateView(startdate); | 228 | updateView(startdate); |
229 | } | 229 | } |
230 | void KODayMatrix::repaintViewTimed() | 230 | void KODayMatrix::repaintViewTimed() |
231 | { | 231 | { |
232 | mRepaintTimer->stop(); | 232 | mRepaintTimer->stop(); |
233 | repaint(false); | 233 | repaint(false); |
234 | } | 234 | } |
235 | void KODayMatrix::updateViewTimed() | 235 | void KODayMatrix::updateViewTimed() |
236 | { | 236 | { |
237 | mUpdateTimer->stop(); | 237 | mUpdateTimer->stop(); |
238 | if ( !mCalendar ) { | 238 | if ( !mCalendar ) { |
239 | qDebug("NOT CAL "); | 239 | qDebug("NOT CAL "); |
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | //qDebug("KODayMatrix::updateViewTimed "); | 242 | //qDebug("KODayMatrix::updateViewTimed "); |
243 | for(int i = 0; i < NUMDAYS; i++) { | 243 | for(int i = 0; i < NUMDAYS; i++) { |
244 | // if events are set for the day then remember to draw it bold | 244 | // if events are set for the day then remember to draw it bold |
245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
246 | Event *event; | 246 | Event *event; |
247 | int numEvents = eventlist.count(); | 247 | int numEvents = eventlist.count(); |
248 | QString holiStr = ""; | 248 | QString holiStr = ""; |
249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
250 | ushort recurType = event->recurrence()->doesRecur(); | 250 | ushort recurType = event->recurrence()->doesRecur(); |
251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
253 | numEvents--; | 253 | numEvents--; |
254 | } | 254 | } |
255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
256 | if ( !holiStr.isEmpty() ) | 256 | if ( !holiStr.isEmpty() ) |
257 | holiStr += "\n"; | 257 | holiStr += "\n"; |
258 | holiStr += event->summary(); | 258 | holiStr += event->summary(); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | events[i] = numEvents; | 261 | events[i] = numEvents; |
262 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 262 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
264 | !holiStr.isEmpty()) { | 264 | !holiStr.isEmpty()) { |
265 | mHolidays[i] = holiStr; | 265 | mHolidays[i] = holiStr; |
266 | } else { | 266 | } else { |
267 | mHolidays[i] = QString::null; | 267 | mHolidays[i] = QString::null; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | if ( ! mPendingUpdateBeforeRepaint ) | 270 | if ( ! mPendingUpdateBeforeRepaint ) |
271 | repaint(false); | 271 | repaint(false); |
272 | } | 272 | } |
273 | void KODayMatrix::updateView(QDate actdate) | 273 | void KODayMatrix::updateView(QDate actdate) |
274 | { | 274 | { |
275 | 275 | ||
276 | if ( ! actdate.isValid() ) { | 276 | if ( ! actdate.isValid() ) { |
277 | //qDebug("date not valid "); | 277 | //qDebug("date not valid "); |
278 | return; | 278 | return; |
279 | } | 279 | } |
280 | mDayChanged = false; | 280 | mDayChanged = false; |
281 | //flag to indicate if the starting day of the matrix has changed by this call | 281 | //flag to indicate if the starting day of the matrix has changed by this call |
282 | //mDayChanged = false; | 282 | //mDayChanged = false; |
283 | // if a new startdate is to be set then apply Cornelius's calculation | 283 | // if a new startdate is to be set then apply Cornelius's calculation |
284 | // of the first day to be shown | 284 | // of the first day to be shown |
285 | if (actdate != startdate) { | 285 | if (actdate != startdate) { |
286 | // reset index of selection according to shift of starting date from startdate to actdate | 286 | // reset index of selection according to shift of starting date from startdate to actdate |
287 | if (mSelStart != NOSELECTION) { | 287 | if (mSelStart != NOSELECTION) { |
288 | int tmp = actdate.daysTo(startdate); | 288 | int tmp = actdate.daysTo(startdate); |
289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
290 | // shift selection if new one would be visible at least partly ! | 290 | // shift selection if new one would be visible at least partly ! |
291 | 291 | ||
292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
293 | // nested if is required for next X display pushed from a different month - correction required | 293 | // nested if is required for next X display pushed from a different month - correction required |
294 | // otherwise, for month forward and backward, it must be avoided | 294 | // otherwise, for month forward and backward, it must be avoided |
295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
296 | mSelStart = mSelStart + tmp; | 296 | mSelStart = mSelStart + tmp; |
297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
298 | mSelEnd = mSelEnd + tmp; | 298 | mSelEnd = mSelEnd + tmp; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | startdate = actdate; | 301 | startdate = actdate; |
302 | mDayChanged = true; | 302 | mDayChanged = true; |
303 | recalculateToday(); | 303 | recalculateToday(); |
304 | } | 304 | } |
305 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 305 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
306 | if ( !isVisible() ) { | 306 | if ( !isVisible() ) { |
307 | mPendingUpdateBeforeRepaint = true; | 307 | mPendingUpdateBeforeRepaint = true; |
308 | } else { | 308 | } else { |
309 | #ifdef DESKTOP_VERSION | 309 | #ifdef DESKTOP_VERSION |
310 | //mRepaintTimer->start( 250 ); | 310 | //mRepaintTimer->start( 250 ); |
311 | mUpdateTimer->start( 250 ); | 311 | mUpdateTimer->start( 250 ); |
312 | #else | 312 | #else |
313 | mRepaintTimer->start( 350 ); | 313 | mRepaintTimer->start( 350 ); |
314 | mUpdateTimer->start( 2000 ); | 314 | mUpdateTimer->start( 2000 ); |
315 | #endif | 315 | #endif |
316 | } | 316 | } |
317 | } | 317 | } |
318 | void KODayMatrix::updateEvents() | 318 | void KODayMatrix::updateEvents() |
319 | { | 319 | { |
320 | if ( !mCalendar ) return; | 320 | if ( !mCalendar ) return; |
321 | 321 | ||
322 | for( int i = 0; i < NUMDAYS; i++ ) { | 322 | for( int i = 0; i < NUMDAYS; i++ ) { |
323 | // if events are set for the day then remember to draw it bold | 323 | // if events are set for the day then remember to draw it bold |
324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
325 | int numEvents = eventlist.count(); | 325 | int numEvents = eventlist.count(); |
326 | Event *event; | 326 | Event *event; |
327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
328 | ushort recurType = event->doesRecur(); | 328 | ushort recurType = event->doesRecur(); |
329 | 329 | ||
330 | if ( ( recurType == Recurrence::rDaily && | 330 | if ( ( recurType == Recurrence::rDaily && |
331 | !KOPrefs::instance()->mDailyRecur ) || | 331 | !KOPrefs::instance()->mDailyRecur ) || |
332 | ( recurType == Recurrence::rWeekly && | 332 | ( recurType == Recurrence::rWeekly && |
333 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 333 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
334 | numEvents--; | 334 | numEvents--; |
335 | } | 335 | } |
336 | } | 336 | } |
337 | events[ i ] = numEvents; | 337 | events[ i ] = numEvents; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | const QDate& KODayMatrix::getDate(int offset) | 341 | const QDate& KODayMatrix::getDate(int offset) |
342 | { | 342 | { |
343 | if (offset < 0 || offset > NUMDAYS-1) { | 343 | if (offset < 0 || offset > NUMDAYS-1) { |
344 | qDebug("Wrong offset2 "); | 344 | qDebug("Wrong offset2 "); |
345 | return days[0]; | 345 | return days[0]; |
346 | } | 346 | } |
347 | return days[offset]; | 347 | return days[offset]; |
348 | } | 348 | } |
349 | 349 | ||
350 | QString KODayMatrix::getHolidayLabel(int offset) | 350 | QString KODayMatrix::getHolidayLabel(int offset) |
351 | { | 351 | { |
352 | if (offset < 0 || offset > NUMDAYS-1) { | 352 | if (offset < 0 || offset > NUMDAYS-1) { |
353 | qDebug("Wrong offset1 "); | 353 | qDebug("Wrong offset1 "); |
354 | return 0; | 354 | return 0; |
355 | } | 355 | } |
356 | return mHolidays[offset]; | 356 | return mHolidays[offset]; |
357 | } | 357 | } |
358 | 358 | ||
359 | int KODayMatrix::getDayIndexFrom(int x, int y) | 359 | int KODayMatrix::getDayIndexFrom(int x, int y) |
360 | { | 360 | { |
361 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 361 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
362 | 6 - x/daysize.width() : x/daysize.width()); | 362 | 6 - x/daysize.width() : x/daysize.width()); |
363 | } | 363 | } |
364 | 364 | ||
365 | // ---------------------------------------------------------------------------- | 365 | // ---------------------------------------------------------------------------- |
366 | // M O U S E E V E N T H A N D L I N G | 366 | // M O U S E E V E N T H A N D L I N G |
367 | // ---------------------------------------------------------------------------- | 367 | // ---------------------------------------------------------------------------- |
368 | 368 | ||
369 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 369 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
370 | { | 370 | { |
371 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 371 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
372 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 372 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
373 | mSelInit = mSelStart; | 373 | mSelInit = mSelStart; |
374 | } | 374 | } |
375 | 375 | ||
376 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 376 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
377 | { | 377 | { |
378 | 378 | ||
379 | int tmp = getDayIndexFrom(e->x(), e->y()); | 379 | int tmp = getDayIndexFrom(e->x(), e->y()); |
380 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 380 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
381 | 381 | ||
382 | if (mSelInit > tmp) { | 382 | if (mSelInit > tmp) { |
383 | mSelEnd = mSelInit; | 383 | mSelEnd = mSelInit; |
384 | if (tmp != mSelStart) { | 384 | if (tmp != mSelStart) { |
385 | mSelStart = tmp; | 385 | mSelStart = tmp; |
386 | repaint(false); | 386 | repaint(false); |
387 | } | 387 | } |
388 | } else { | 388 | } else { |
389 | mSelStart = mSelInit; | 389 | mSelStart = mSelInit; |
390 | 390 | ||
391 | //repaint only if selection has changed | 391 | //repaint only if selection has changed |
392 | if (tmp != mSelEnd) { | 392 | if (tmp != mSelEnd) { |
393 | mSelEnd = tmp; | 393 | mSelEnd = tmp; |
394 | repaint(false); | 394 | repaint(false); |
395 | } | 395 | } |
396 | } | 396 | } |