author | zautrix <zautrix> | 2005-03-21 12:34:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-21 12:34:49 (UTC) |
commit | ad4ecbb0cbf79f37140041eb9a14e71e6fd393f1 (patch) (unidiff) | |
tree | b92ef416aa5542e06f1fc472d19619804ff897c8 | |
parent | 3b7ba9f46c78816bae8c4b30a455e261d7da9f4a (diff) | |
download | kdepimpi-ad4ecbb0cbf79f37140041eb9a14e71e6fd393f1.zip kdepimpi-ad4ecbb0cbf79f37140041eb9a14e71e6fd393f1.tar.gz kdepimpi-ad4ecbb0cbf79f37140041eb9a14e71e6fd393f1.tar.bz2 |
fixes
-rw-r--r-- | korganizer/koagendaitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 2 |
3 files changed, 2 insertions, 4 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 19cc0e3..5ee433a 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,350 +1,350 @@ | |||
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 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
74 | const char *name,WFlags) : | 74 | const char *name,WFlags) : |
75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 78 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); | 80 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); |
81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
82 | setWFlags ( wflags); | 82 | setWFlags ( wflags); |
83 | mAllDay = allday; | 83 | mAllDay = allday; |
84 | init ( incidence, qd ); | 84 | init ( incidence, qd ); |
85 | //setMouseTracking(true); | 85 | //setMouseTracking(true); |
86 | //setAcceptDrops(true); | 86 | //setAcceptDrops(true); |
87 | xPaintCoord = -1; | 87 | xPaintCoord = -1; |
88 | yPaintCoord = -1; | 88 | yPaintCoord = -1; |
89 | } | 89 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString KOAgendaItem::getWhatsThisText() |
91 | { | 91 | { |
92 | if ( mIncidence ) | 92 | if ( mIncidence ) |
93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
94 | KOPrefs::instance()->mWTshowDetails, | 94 | KOPrefs::instance()->mWTshowDetails, |
95 | KOPrefs::instance()->mWTshowCreated, | 95 | KOPrefs::instance()->mWTshowCreated, |
96 | KOPrefs::instance()->mWTshowChanged); | 96 | KOPrefs::instance()->mWTshowChanged); |
97 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 97 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
98 | } | 98 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
100 | { | 100 | { |
101 | mIncidence = incidence; | 101 | mIncidence = incidence; |
102 | mDate = qd; | 102 | mDate = qd; |
103 | mFirstMultiItem = 0; | 103 | mFirstMultiItem = 0; |
104 | mNextMultiItem = 0; | 104 | mNextMultiItem = 0; |
105 | mLastMultiItem = 0; | 105 | mLastMultiItem = 0; |
106 | computeText(); | 106 | computeText(); |
107 | 107 | ||
108 | if ( (incidence->type() == "Todo") && | 108 | if ( (incidence->type() == "Todo") && |
109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
113 | else | 113 | else |
114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
115 | } | 115 | } |
116 | else { | 116 | else { |
117 | QStringList categories = mIncidence->categories(); | 117 | QStringList categories = mIncidence->categories(); |
118 | QString cat = categories.first(); | 118 | QString cat = categories.first(); |
119 | if (cat.isEmpty()) { | 119 | if (cat.isEmpty()) { |
120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
122 | else | 122 | else |
123 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 123 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
124 | } else { | 124 | } else { |
125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 133 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
134 | mBackgroundColor.dark(),mBackgroundColor.light(), | 134 | mBackgroundColor.dark(),mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | 137 | ||
138 | mConflictItems.clear(); | 138 | mConflictItems.clear(); |
139 | setCellXY(0,0,1); | 139 | setCellXY(0,0,1); |
140 | setCellXWidth(0); | 140 | setCellXWidth(0); |
141 | setSubCell(0); | 141 | setSubCell(0); |
142 | setSubCells(1); | 142 | setSubCells(1); |
143 | setMultiItem(0,0,0); | 143 | setMultiItem(0,0,0); |
144 | startMove(); | 144 | startMove(); |
145 | mSelected = true; | 145 | mSelected = true; |
146 | select(false); | 146 | select(false); |
147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
148 | mFontPixelSize = fontinf.height();; | 148 | mFontPixelSize = fontinf.height();; |
149 | hide(); | 149 | hide(); |
150 | xPaintCoord = -1; | 150 | xPaintCoord = -1; |
151 | yPaintCoord = -1; | 151 | yPaintCoord = -1; |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
156 | { | 156 | { |
157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
158 | delete mKOAgendaItemWhatsThis; | 158 | // delete mKOAgendaItemWhatsThis; |
159 | } | 159 | } |
160 | 160 | ||
161 | void KOAgendaItem::recreateIncidence() | 161 | void KOAgendaItem::recreateIncidence() |
162 | { | 162 | { |
163 | #if 0 | 163 | #if 0 |
164 | Incidence* newInc = mIncidence->clone(); | 164 | Incidence* newInc = mIncidence->clone(); |
165 | newInc->recreate(); | 165 | newInc->recreate(); |
166 | if ( mIncidence->doesRecur() ) { | 166 | if ( mIncidence->doesRecur() ) { |
167 | mIncidence->addExDate( mDate ); | 167 | mIncidence->addExDate( mDate ); |
168 | newInc->recurrence()->unsetRecurs(); | 168 | newInc->recurrence()->unsetRecurs(); |
169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
170 | QTime tim = mIncidence->dtStart().time(); | 170 | QTime tim = mIncidence->dtStart().time(); |
171 | newInc->setDtStart( QDateTime(mDate, tim) ); | 171 | newInc->setDtStart( QDateTime(mDate, tim) ); |
172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
173 | } | 173 | } |
174 | #endif | 174 | #endif |
175 | mIncidence = mIncidence->recreateCloneException( mDate ); | 175 | mIncidence = mIncidence->recreateCloneException( mDate ); |
176 | } | 176 | } |
177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
178 | { | 178 | { |
179 | int size = AGENDA_ICON_SIZE; | 179 | int size = AGENDA_ICON_SIZE; |
180 | 180 | ||
181 | int yOff = 0; | 181 | int yOff = 0; |
182 | int xOff = 0; | 182 | int xOff = 0; |
183 | int x = pos().x() +3; | 183 | int x = pos().x() +3; |
184 | int y; | 184 | int y; |
185 | if ( mAllDay ) | 185 | if ( mAllDay ) |
186 | y = pos().y()+3; | 186 | y = pos().y()+3; |
187 | else | 187 | else |
188 | y = mCellYTop * ( height() / cellHeight() ) +3; | 188 | y = mCellYTop * ( height() / cellHeight() ) +3; |
189 | if (mIncidence->cancelled()) { | 189 | if (mIncidence->cancelled()) { |
190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
194 | if ( horLayout ) | 194 | if ( horLayout ) |
195 | ++xOff; | 195 | ++xOff; |
196 | else | 196 | else |
197 | ++yOff; | 197 | ++yOff; |
198 | } | 198 | } |
199 | if (mIncidence->isAlarmEnabled()) { | 199 | if (mIncidence->isAlarmEnabled()) { |
200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
201 | if ( horLayout ) | 201 | if ( horLayout ) |
202 | ++xOff; | 202 | ++xOff; |
203 | else | 203 | else |
204 | ++yOff; | 204 | ++yOff; |
205 | } | 205 | } |
206 | if (mIncidence->recurrence()->doesRecur()) { | 206 | if (mIncidence->recurrence()->doesRecur()) { |
207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
208 | if ( horLayout ) | 208 | if ( horLayout ) |
209 | ++xOff; | 209 | ++xOff; |
210 | else | 210 | else |
211 | ++yOff; | 211 | ++yOff; |
212 | } | 212 | } |
213 | if (mIncidence->description().length() > 0) { | 213 | if (mIncidence->description().length() > 0) { |
214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
215 | if ( horLayout ) | 215 | if ( horLayout ) |
216 | ++xOff; | 216 | ++xOff; |
217 | else | 217 | else |
218 | ++yOff; | 218 | ++yOff; |
219 | } | 219 | } |
220 | if (mIncidence->isReadOnly()) { | 220 | if (mIncidence->isReadOnly()) { |
221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
222 | if ( horLayout ) | 222 | if ( horLayout ) |
223 | ++xOff; | 223 | ++xOff; |
224 | else | 224 | else |
225 | ++yOff; | 225 | ++yOff; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (mIncidence->attendeeCount()>0) { | 228 | if (mIncidence->attendeeCount()>0) { |
229 | 229 | ||
230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
232 | if ( horLayout ) | 232 | if ( horLayout ) |
233 | ++xOff; | 233 | ++xOff; |
234 | else | 234 | else |
235 | ++yOff; | 235 | ++yOff; |
236 | } else { | 236 | } else { |
237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
238 | if (me!=0) { | 238 | if (me!=0) { |
239 | 239 | ||
240 | 240 | ||
241 | } else { | 241 | } else { |
242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
243 | if ( horLayout ) | 243 | if ( horLayout ) |
244 | ++xOff; | 244 | ++xOff; |
245 | else | 245 | else |
246 | ++yOff; | 246 | ++yOff; |
247 | 247 | ||
248 | } | 248 | } |
249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
250 | if ( horLayout ) | 250 | if ( horLayout ) |
251 | ++xOff; | 251 | ++xOff; |
252 | else | 252 | else |
253 | ++yOff; | 253 | ++yOff; |
254 | 254 | ||
255 | } | 255 | } |
256 | 256 | ||
257 | } | 257 | } |
258 | return ( yOff || xOff ); | 258 | return ( yOff || xOff ); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
262 | void KOAgendaItem::select(bool selected) | 262 | void KOAgendaItem::select(bool selected) |
263 | { | 263 | { |
264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
265 | if (mSelected == selected) return; | 265 | if (mSelected == selected) return; |
266 | mSelected = selected; | 266 | mSelected = selected; |
267 | if ( ! isVisible() ) | 267 | if ( ! isVisible() ) |
268 | return; | 268 | return; |
269 | if ( firstMultiItem() ) | 269 | if ( firstMultiItem() ) |
270 | firstMultiItem()->select( selected ); | 270 | firstMultiItem()->select( selected ); |
271 | if ( !firstMultiItem() && nextMultiItem() ) { | 271 | if ( !firstMultiItem() && nextMultiItem() ) { |
272 | KOAgendaItem * placeItem = nextMultiItem(); | 272 | KOAgendaItem * placeItem = nextMultiItem(); |
273 | while ( placeItem ) { | 273 | while ( placeItem ) { |
274 | placeItem->select( selected ); | 274 | placeItem->select( selected ); |
275 | placeItem = placeItem->nextMultiItem(); | 275 | placeItem = placeItem->nextMultiItem(); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | globalFlagBlockAgendaItemUpdate = 0; | 278 | globalFlagBlockAgendaItemUpdate = 0; |
279 | paintMe( selected ); | 279 | paintMe( selected ); |
280 | globalFlagBlockAgendaItemUpdate = 1; | 280 | globalFlagBlockAgendaItemUpdate = 1; |
281 | repaint( false ); | 281 | repaint( false ); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | /* | 285 | /* |
286 | The eventFilter has to filter the mouse events of the agenda item childs. The | 286 | The eventFilter has to filter the mouse events of the agenda item childs. The |
287 | events are fed into the event handling method of KOAgendaItem. This allows the | 287 | events are fed into the event handling method of KOAgendaItem. This allows the |
288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
289 | */ | 289 | */ |
290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
291 | { | 291 | { |
292 | if (e->type() == QEvent::MouseButtonPress || | 292 | if (e->type() == QEvent::MouseButtonPress || |
293 | e->type() == QEvent::MouseButtonDblClick || | 293 | e->type() == QEvent::MouseButtonDblClick || |
294 | e->type() == QEvent::MouseButtonRelease || | 294 | e->type() == QEvent::MouseButtonRelease || |
295 | e->type() == QEvent::MouseMove) { | 295 | e->type() == QEvent::MouseMove) { |
296 | QMouseEvent *me = (QMouseEvent *)e; | 296 | QMouseEvent *me = (QMouseEvent *)e; |
297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
298 | mapToGlobal(me->pos())); | 298 | mapToGlobal(me->pos())); |
299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
300 | return event(&returnEvent); | 300 | return event(&returnEvent); |
301 | } else { | 301 | } else { |
302 | return false; | 302 | return false; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | void KOAgendaItem::repaintMe( ) | 305 | void KOAgendaItem::repaintMe( ) |
306 | { | 306 | { |
307 | paintMe ( mSelected ); | 307 | paintMe ( mSelected ); |
308 | } | 308 | } |
309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
310 | { | 310 | { |
311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
312 | return; | 312 | return; |
313 | QPainter pa; | 313 | QPainter pa; |
314 | 314 | ||
315 | if ( mSelected ) { | 315 | if ( mSelected ) { |
316 | pa.begin( paintPixSel() ); | 316 | pa.begin( paintPixSel() ); |
317 | } else { | 317 | } else { |
318 | if ( mAllDay ) | 318 | if ( mAllDay ) |
319 | pa.begin( paintPixAllday() ); | 319 | pa.begin( paintPixAllday() ); |
320 | else | 320 | else |
321 | pa.begin( paintPix() ); | 321 | pa.begin( paintPix() ); |
322 | } | 322 | } |
323 | int x, yy, w, h; | 323 | int x, yy, w, h; |
324 | float nfh = 7.0; | 324 | float nfh = 7.0; |
325 | x = pos().x(); w = width(); h = height (); | 325 | x = pos().x(); w = width(); h = height (); |
326 | if ( mAllDay ) | 326 | if ( mAllDay ) |
327 | yy = y(); | 327 | yy = y(); |
328 | else | 328 | else |
329 | yy = mCellYTop * ( height() / cellHeight() ); | 329 | yy = mCellYTop * ( height() / cellHeight() ); |
330 | xPaintCoord= x; | 330 | xPaintCoord= x; |
331 | yPaintCoord = yy; | 331 | yPaintCoord = yy; |
332 | wPaintCoord = width(); | 332 | wPaintCoord = width(); |
333 | hPaintCoord = height(); | 333 | hPaintCoord = height(); |
334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
335 | if ( paint == 0 ) | 335 | if ( paint == 0 ) |
336 | paint = &pa; | 336 | paint = &pa; |
337 | bool horLayout = ( w < h ); | 337 | bool horLayout = ( w < h ); |
338 | int maxhei = mFontPixelSize+4; | 338 | int maxhei = mFontPixelSize+4; |
339 | if ( horLayout ) | 339 | if ( horLayout ) |
340 | maxhei += AGENDA_ICON_SIZE -4; | 340 | maxhei += AGENDA_ICON_SIZE -4; |
341 | bool small = ( h < maxhei ); | 341 | bool small = ( h < maxhei ); |
342 | if ( ! small ) | 342 | if ( ! small ) |
343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
344 | else { | 344 | else { |
345 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 345 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
346 | f.setBold( false ); | 346 | f.setBold( false ); |
347 | int fh = f.pointSize(); | 347 | int fh = f.pointSize(); |
348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
349 | if ( nfh < 6 ) | 349 | if ( nfh < 6 ) |
350 | nfh = 6; | 350 | nfh = 6; |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 9c1f5f3..582b2ef 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,405 +1,403 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
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 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; |
66 | ~KODaymatrixWhatsThis() { ; }; | 66 | ~KODaymatrixWhatsThis() { ; }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p ) | 69 | virtual QString text( const QPoint& p ) |
70 | { | 70 | { |
71 | return _view->getWhatsThisText( p ) ; | 71 | return _view->getWhatsThisText( p ) ; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name ), mCalendar( 0 ) | 106 | : QFrame( parent, name ), mCalendar( 0 ) |
107 | 107 | ||
108 | #if 0 | 108 | #if 0 |
109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 109 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
110 | QFrame(parent, name) | 110 | QFrame(parent, name) |
111 | #endif | 111 | #endif |
112 | { | 112 | { |
113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 113 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
114 | mPendingUpdateBeforeRepaint = false; | 114 | mPendingUpdateBeforeRepaint = false; |
115 | mouseDown = false; | 115 | mouseDown = false; |
116 | // initialize dynamic arrays | 116 | // initialize dynamic arrays |
117 | bDays.resize ( NUMDAYS ); | 117 | bDays.resize ( NUMDAYS ); |
118 | days = new QDate[NUMDAYS]; | 118 | days = new QDate[NUMDAYS]; |
119 | daylbls = new QString[NUMDAYS]; | 119 | daylbls = new QString[NUMDAYS]; |
120 | events = new int[NUMDAYS]; | 120 | events = new int[NUMDAYS]; |
121 | mToolTip = new DynamicTip(this); | 121 | mToolTip = new DynamicTip(this); |
122 | 122 | ||
123 | // set default values used for drawing the matrix | 123 | // set default values used for drawing the matrix |
124 | mDefaultBackColor = palette().active().base(); | 124 | mDefaultBackColor = palette().active().base(); |
125 | mDefaultTextColor = palette().active().foreground(); | 125 | mDefaultTextColor = palette().active().foreground(); |
126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 126 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 127 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
128 | mSelectedDaysColor = QColor("white"); | 128 | mSelectedDaysColor = QColor("white"); |
129 | mTodayMarginWidth = 2; | 129 | mTodayMarginWidth = 2; |
130 | mSelEnd = mSelStart = NOSELECTION; | 130 | mSelEnd = mSelStart = NOSELECTION; |
131 | 131 | ||
132 | setAcceptDrops(true); | 132 | setAcceptDrops(true); |
133 | //setFont( QFont("Arial", 10) ); | 133 | //setFont( QFont("Arial", 10) ); |
134 | 134 | ||
135 | mUpdateTimer = new QTimer( this ); | 135 | mUpdateTimer = new QTimer( this ); |
136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 136 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
137 | mRepaintTimer = new QTimer( this ); | 137 | mRepaintTimer = new QTimer( this ); |
138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 138 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
139 | mDayChanged = false; | 139 | mDayChanged = false; |
140 | updateView(); | 140 | updateView(); |
141 | } | 141 | } |
142 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 142 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
143 | { | 143 | { |
144 | 144 | ||
145 | int tmp = getDayIndexFrom(p.x(), p.y()); | 145 | int tmp = getDayIndexFrom(p.x(), p.y()); |
146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 146 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
147 | return QString(); | 147 | return QString(); |
148 | QDate mDate = days[tmp]; | 148 | QDate mDate = days[tmp]; |
149 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 149 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
150 | Event *event; | 150 | Event *event; |
151 | QStringList mToolTip; | 151 | QStringList mToolTip; |
152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 152 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
153 | QString mToolTipText; | 153 | QString mToolTipText; |
154 | QString text; | 154 | QString text; |
155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 155 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
156 | if (event->isMultiDay()) { | 156 | if (event->isMultiDay()) { |
157 | QString prefix = "<->";multiday = 2; | 157 | QString prefix = "<->";multiday = 2; |
158 | QString time; | 158 | QString time; |
159 | if ( event->doesRecur() ) { | 159 | if ( event->doesRecur() ) { |
160 | if ( event->recursOn( mDate) ) { | 160 | if ( event->recursOn( mDate) ) { |
161 | prefix ="->" ;multiday = 1; | 161 | prefix ="->" ;multiday = 1; |
162 | } | 162 | } |
163 | else { | 163 | else { |
164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 164 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
165 | if ( event->recursOn( mDate.addDays( -days)) ) { | 165 | if ( event->recursOn( mDate.addDays( -days)) ) { |
166 | prefix ="<-" ;multiday = 3; | 166 | prefix ="<-" ;multiday = 3; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } else { | 169 | } else { |
170 | if (mDate == event->dtStart().date()) { | 170 | if (mDate == event->dtStart().date()) { |
171 | prefix ="->" ;multiday = 1; | 171 | prefix ="->" ;multiday = 1; |
172 | } else if (mDate == event->dtEnd().date()) { | 172 | } else if (mDate == event->dtEnd().date()) { |
173 | prefix ="<-" ;multiday = 3; | 173 | prefix ="<-" ;multiday = 3; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | if ( !event->doesFloat() ) { | 176 | if ( !event->doesFloat() ) { |
177 | if ( mDate == event->dtStart().date () ) | 177 | if ( mDate == event->dtStart().date () ) |
178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 178 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
179 | else if ( mDate == event->dtEnd().date () ) | 179 | else if ( mDate == event->dtEnd().date () ) |
180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 180 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
181 | 181 | ||
182 | } | 182 | } |
183 | qDebug("event->isMultiDay() %s", event->summary().latin1() ); | ||
184 | text = time + event->summary(); | 183 | text = time + event->summary(); |
185 | mToolTipText += prefix + text; | 184 | mToolTipText += prefix + text; |
186 | } else { | 185 | } else { |
187 | if (event->doesFloat()) { | 186 | if (event->doesFloat()) { |
188 | text = event->summary(); | 187 | text = event->summary(); |
189 | mToolTipText += text; | 188 | mToolTipText += text; |
190 | } | 189 | } |
191 | else { | 190 | else { |
192 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 191 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
193 | text += " " + event->summary(); | 192 | text += " " + event->summary(); |
194 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 193 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
195 | } | 194 | } |
196 | } | 195 | } |
197 | if ( !event->location().isEmpty() ) | 196 | if ( !event->location().isEmpty() ) |
198 | mToolTipText += " (" + event->location() + ")"; | 197 | mToolTipText += " (" + event->location() + ")"; |
199 | #if QT_VERSION >= 0x030000 | 198 | #if QT_VERSION >= 0x030000 |
200 | mToolTipText.replace( '<' , "<" ); | 199 | mToolTipText.replace( '<' , "<" ); |
201 | mToolTipText.replace( '>' , ">" ); | 200 | mToolTipText.replace( '>' , ">" ); |
202 | #else | 201 | #else |
203 | if ( mToolTipText.find ('<') > 0 ) { | 202 | if ( mToolTipText.find ('<') > 0 ) { |
204 | mToolTipText.replace( QRegExp("<") , "<" ); | 203 | mToolTipText.replace( QRegExp("<") , "<" ); |
205 | } | 204 | } |
206 | if ( mToolTipText.find ('>') > 0 ) { | 205 | if ( mToolTipText.find ('>') > 0 ) { |
207 | mToolTipText.replace( QRegExp(">") , ">" ); | 206 | mToolTipText.replace( QRegExp(">") , ">" ); |
208 | } | 207 | } |
209 | #endif | 208 | #endif |
210 | mToolTip.append( mToolTipText ); | 209 | mToolTip.append( mToolTipText ); |
211 | } | 210 | } |
212 | mToolTip.sort(); | 211 | mToolTip.sort(); |
213 | qDebug("%s ", mToolTip.join("<br>").latin1()); | ||
214 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 212 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
215 | } | 213 | } |
216 | void KODayMatrix::setCalendar( Calendar *cal ) | 214 | void KODayMatrix::setCalendar( Calendar *cal ) |
217 | { | 215 | { |
218 | mCalendar = cal; | 216 | mCalendar = cal; |
219 | 217 | ||
220 | setAcceptDrops( mCalendar ); | 218 | setAcceptDrops( mCalendar ); |
221 | 219 | ||
222 | updateEvents(); | 220 | updateEvents(); |
223 | } | 221 | } |
224 | 222 | ||
225 | QColor KODayMatrix::getShadedColor(QColor color) | 223 | QColor KODayMatrix::getShadedColor(QColor color) |
226 | { | 224 | { |
227 | QColor shaded; | 225 | QColor shaded; |
228 | int h=0; | 226 | int h=0; |
229 | int s=0; | 227 | int s=0; |
230 | int v=0; | 228 | int v=0; |
231 | color.hsv(&h,&s,&v); | 229 | color.hsv(&h,&s,&v); |
232 | s = s/4; | 230 | s = s/4; |
233 | v = 192+v/4; | 231 | v = 192+v/4; |
234 | shaded.setHsv(h,s,v); | 232 | shaded.setHsv(h,s,v); |
235 | 233 | ||
236 | return shaded; | 234 | return shaded; |
237 | } | 235 | } |
238 | 236 | ||
239 | KODayMatrix::~KODayMatrix() | 237 | KODayMatrix::~KODayMatrix() |
240 | { | 238 | { |
241 | // delete mKODaymatrixWhatsThis; | 239 | // delete mKODaymatrixWhatsThis; |
242 | delete [] days; | 240 | delete [] days; |
243 | delete [] daylbls; | 241 | delete [] daylbls; |
244 | delete [] events; | 242 | delete [] events; |
245 | delete mToolTip; | 243 | delete mToolTip; |
246 | } | 244 | } |
247 | 245 | ||
248 | /* | 246 | /* |
249 | void KODayMatrix::setStartDate(QDate start) | 247 | void KODayMatrix::setStartDate(QDate start) |
250 | { | 248 | { |
251 | updateView(start); | 249 | updateView(start); |
252 | } | 250 | } |
253 | */ | 251 | */ |
254 | 252 | ||
255 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 253 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
256 | { | 254 | { |
257 | 255 | ||
258 | if (mSelStart == NOSELECTION) { | 256 | if (mSelStart == NOSELECTION) { |
259 | return; | 257 | return; |
260 | } | 258 | } |
261 | 259 | ||
262 | //cope with selection being out of matrix limits at top (< 0) | 260 | //cope with selection being out of matrix limits at top (< 0) |
263 | int i0 = mSelStart; | 261 | int i0 = mSelStart; |
264 | if (i0 < 0) { | 262 | if (i0 < 0) { |
265 | for (int i = i0; i < 0; i++) { | 263 | for (int i = i0; i < 0; i++) { |
266 | selDays.append(days[0].addDays(i)); | 264 | selDays.append(days[0].addDays(i)); |
267 | } | 265 | } |
268 | i0 = 0; | 266 | i0 = 0; |
269 | } | 267 | } |
270 | 268 | ||
271 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 269 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
272 | if (mSelEnd > NUMDAYS-1) { | 270 | if (mSelEnd > NUMDAYS-1) { |
273 | for (int i = i0; i <= NUMDAYS-1; i++) { | 271 | for (int i = i0; i <= NUMDAYS-1; i++) { |
274 | selDays.append(days[i]); | 272 | selDays.append(days[i]); |
275 | } | 273 | } |
276 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 274 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
277 | selDays.append(days[0].addDays(i)); | 275 | selDays.append(days[0].addDays(i)); |
278 | } | 276 | } |
279 | 277 | ||
280 | // apply normal routine to selection being entirely within matrix limits | 278 | // apply normal routine to selection being entirely within matrix limits |
281 | } else { | 279 | } else { |
282 | for (int i = i0; i <= mSelEnd; i++) { | 280 | for (int i = i0; i <= mSelEnd; i++) { |
283 | selDays.append(days[i]); | 281 | selDays.append(days[i]); |
284 | } | 282 | } |
285 | } | 283 | } |
286 | } | 284 | } |
287 | 285 | ||
288 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 286 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
289 | { | 287 | { |
290 | mSelStart = startdate.daysTo(start); | 288 | mSelStart = startdate.daysTo(start); |
291 | if ( mSelStart < 0 ) | 289 | if ( mSelStart < 0 ) |
292 | mSelStart = 0; | 290 | mSelStart = 0; |
293 | mSelEnd = startdate.daysTo(end); | 291 | mSelEnd = startdate.daysTo(end); |
294 | if ( mSelEnd < 0 ) | 292 | if ( mSelEnd < 0 ) |
295 | clearSelection(); | 293 | clearSelection(); |
296 | } | 294 | } |
297 | void KODayMatrix::clearSelection() | 295 | void KODayMatrix::clearSelection() |
298 | { | 296 | { |
299 | mSelEnd = mSelStart = NOSELECTION; | 297 | mSelEnd = mSelStart = NOSELECTION; |
300 | } | 298 | } |
301 | 299 | ||
302 | 300 | ||
303 | void KODayMatrix::recalculateToday() | 301 | void KODayMatrix::recalculateToday() |
304 | { | 302 | { |
305 | today = -1; | 303 | today = -1; |
306 | for (int i=0; i<NUMDAYS; i++) { | 304 | for (int i=0; i<NUMDAYS; i++) { |
307 | events[i] = 0; | 305 | events[i] = 0; |
308 | days[i] = startdate.addDays(i); | 306 | days[i] = startdate.addDays(i); |
309 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 307 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
310 | 308 | ||
311 | // if today is in the currently displayed month, hilight today | 309 | // if today is in the currently displayed month, hilight today |
312 | if (days[i].year() == QDate::currentDate().year() && | 310 | if (days[i].year() == QDate::currentDate().year() && |
313 | days[i].month() == QDate::currentDate().month() && | 311 | days[i].month() == QDate::currentDate().month() && |
314 | days[i].day() == QDate::currentDate().day()) { | 312 | days[i].day() == QDate::currentDate().day()) { |
315 | today = i; | 313 | today = i; |
316 | } | 314 | } |
317 | } | 315 | } |
318 | // qDebug(QString("Today is visible at %1.").arg(today)); | 316 | // qDebug(QString("Today is visible at %1.").arg(today)); |
319 | } | 317 | } |
320 | 318 | ||
321 | void KODayMatrix::updateView() | 319 | void KODayMatrix::updateView() |
322 | { | 320 | { |
323 | updateView(startdate); | 321 | updateView(startdate); |
324 | } | 322 | } |
325 | void KODayMatrix::repaintViewTimed() | 323 | void KODayMatrix::repaintViewTimed() |
326 | { | 324 | { |
327 | mRepaintTimer->stop(); | 325 | mRepaintTimer->stop(); |
328 | repaint(false); | 326 | repaint(false); |
329 | } | 327 | } |
330 | void KODayMatrix::updateViewTimed() | 328 | void KODayMatrix::updateViewTimed() |
331 | { | 329 | { |
332 | mUpdateTimer->stop(); | 330 | mUpdateTimer->stop(); |
333 | if ( !mCalendar ) { | 331 | if ( !mCalendar ) { |
334 | qDebug("NOT CAL "); | 332 | qDebug("NOT CAL "); |
335 | return; | 333 | return; |
336 | } | 334 | } |
337 | //qDebug("KODayMatrix::updateViewTimed "); | 335 | //qDebug("KODayMatrix::updateViewTimed "); |
338 | for(int i = 0; i < NUMDAYS; i++) { | 336 | for(int i = 0; i < NUMDAYS; i++) { |
339 | // if events are set for the day then remember to draw it bold | 337 | // if events are set for the day then remember to draw it bold |
340 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 338 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
341 | Event *event; | 339 | Event *event; |
342 | int numEvents = eventlist.count(); | 340 | int numEvents = eventlist.count(); |
343 | QString holiStr = ""; | 341 | QString holiStr = ""; |
344 | bDays.clearBit(i); | 342 | bDays.clearBit(i); |
345 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 343 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
346 | ushort recurType = event->recurrence()->doesRecur(); | 344 | ushort recurType = event->recurrence()->doesRecur(); |
347 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 345 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
348 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 346 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
349 | numEvents--; | 347 | numEvents--; |
350 | } | 348 | } |
351 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 349 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
352 | if ( !holiStr.isEmpty() ) | 350 | if ( !holiStr.isEmpty() ) |
353 | holiStr += "\n"; | 351 | holiStr += "\n"; |
354 | holiStr += event->summary(); | 352 | holiStr += event->summary(); |
355 | if ( !event->location().isEmpty() ) | 353 | if ( !event->location().isEmpty() ) |
356 | holiStr += " (" + event->location() + ")"; | 354 | holiStr += " (" + event->location() + ")"; |
357 | } | 355 | } |
358 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { | 356 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { |
359 | if ( !holiStr.isEmpty() ) | 357 | if ( !holiStr.isEmpty() ) |
360 | holiStr += "\n"; | 358 | holiStr += "\n"; |
361 | holiStr += i18n("Birthday") + ": "+event->summary(); | 359 | holiStr += i18n("Birthday") + ": "+event->summary(); |
362 | if ( !event->location().isEmpty() ) | 360 | if ( !event->location().isEmpty() ) |
363 | holiStr += " (" + event->location() + ")"; | 361 | holiStr += " (" + event->location() + ")"; |
364 | bDays.setBit(i); | 362 | bDays.setBit(i); |
365 | } | 363 | } |
366 | } | 364 | } |
367 | events[i] = numEvents; | 365 | events[i] = numEvents; |
368 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 366 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
369 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 367 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
370 | !holiStr.isEmpty()) { | 368 | !holiStr.isEmpty()) { |
371 | mHolidays[i] = holiStr; | 369 | mHolidays[i] = holiStr; |
372 | } else { | 370 | } else { |
373 | mHolidays[i] = QString::null; | 371 | mHolidays[i] = QString::null; |
374 | } | 372 | } |
375 | } | 373 | } |
376 | if ( ! mPendingUpdateBeforeRepaint ) | 374 | if ( ! mPendingUpdateBeforeRepaint ) |
377 | repaint(false); | 375 | repaint(false); |
378 | } | 376 | } |
379 | void KODayMatrix::updateView(QDate actdate) | 377 | void KODayMatrix::updateView(QDate actdate) |
380 | { | 378 | { |
381 | 379 | ||
382 | if ( ! actdate.isValid() ) { | 380 | if ( ! actdate.isValid() ) { |
383 | //qDebug("date not valid "); | 381 | //qDebug("date not valid "); |
384 | return; | 382 | return; |
385 | } | 383 | } |
386 | mDayChanged = false; | 384 | mDayChanged = false; |
387 | //flag to indicate if the starting day of the matrix has changed by this call | 385 | //flag to indicate if the starting day of the matrix has changed by this call |
388 | //mDayChanged = false; | 386 | //mDayChanged = false; |
389 | // if a new startdate is to be set then apply Cornelius's calculation | 387 | // if a new startdate is to be set then apply Cornelius's calculation |
390 | // of the first day to be shown | 388 | // of the first day to be shown |
391 | if (actdate != startdate) { | 389 | if (actdate != startdate) { |
392 | // reset index of selection according to shift of starting date from startdate to actdate | 390 | // reset index of selection according to shift of starting date from startdate to actdate |
393 | if (mSelStart != NOSELECTION) { | 391 | if (mSelStart != NOSELECTION) { |
394 | int tmp = actdate.daysTo(startdate); | 392 | int tmp = actdate.daysTo(startdate); |
395 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 393 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
396 | // shift selection if new one would be visible at least partly ! | 394 | // shift selection if new one would be visible at least partly ! |
397 | 395 | ||
398 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 396 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
399 | // nested if is required for next X display pushed from a different month - correction required | 397 | // nested if is required for next X display pushed from a different month - correction required |
400 | // otherwise, for month forward and backward, it must be avoided | 398 | // otherwise, for month forward and backward, it must be avoided |
401 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 399 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
402 | mSelStart = mSelStart + tmp; | 400 | mSelStart = mSelStart + tmp; |
403 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 401 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
404 | mSelEnd = mSelEnd + tmp; | 402 | mSelEnd = mSelEnd + tmp; |
405 | } | 403 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 2b01c23..e008625 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -361,385 +361,385 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
361 | mNavigator = 0; | 361 | mNavigator = 0; |
362 | QBoxLayout *topLayout = new QVBoxLayout(this); | 362 | QBoxLayout *topLayout = new QVBoxLayout(this); |
363 | mName = QString ( name ); | 363 | mName = QString ( name ); |
364 | mBlockUpdate = false; | 364 | mBlockUpdate = false; |
365 | mQuickAdd = new KOQuickTodo(this); | 365 | mQuickAdd = new KOQuickTodo(this); |
366 | topLayout->addWidget(mQuickAdd); | 366 | topLayout->addWidget(mQuickAdd); |
367 | 367 | ||
368 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 368 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
369 | 369 | ||
370 | mTodoListView = new KOTodoListView(calendar,this, name ); | 370 | mTodoListView = new KOTodoListView(calendar,this, name ); |
371 | topLayout->addWidget(mTodoListView); | 371 | topLayout->addWidget(mTodoListView); |
372 | //mTodoListView->header()->setMaximumHeight(30); | 372 | //mTodoListView->header()->setMaximumHeight(30); |
373 | mTodoListView->setRootIsDecorated(true); | 373 | mTodoListView->setRootIsDecorated(true); |
374 | mTodoListView->setAllColumnsShowFocus(true); | 374 | mTodoListView->setAllColumnsShowFocus(true); |
375 | 375 | ||
376 | mTodoListView->setShowSortIndicator(true); | 376 | mTodoListView->setShowSortIndicator(true); |
377 | 377 | ||
378 | mTodoListView->addColumn(i18n("Todo")); | 378 | mTodoListView->addColumn(i18n("Todo")); |
379 | mTodoListView->addColumn(i18n("Prio")); | 379 | mTodoListView->addColumn(i18n("Prio")); |
380 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 380 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
381 | mTodoListView->addColumn(i18n("Complete")); | 381 | mTodoListView->addColumn(i18n("Complete")); |
382 | mTodoListView->setColumnAlignment(2,AlignCenter); | 382 | mTodoListView->setColumnAlignment(2,AlignCenter); |
383 | 383 | ||
384 | mTodoListView->addColumn(i18n("Due Date")); | 384 | mTodoListView->addColumn(i18n("Due Date")); |
385 | mTodoListView->setColumnAlignment(3,AlignLeft); | 385 | mTodoListView->setColumnAlignment(3,AlignLeft); |
386 | mTodoListView->addColumn(i18n("Due Time")); | 386 | mTodoListView->addColumn(i18n("Due Time")); |
387 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 387 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
388 | 388 | ||
389 | mTodoListView->addColumn(i18n("Start Date")); | 389 | mTodoListView->addColumn(i18n("Start Date")); |
390 | mTodoListView->setColumnAlignment(5,AlignLeft); | 390 | mTodoListView->setColumnAlignment(5,AlignLeft); |
391 | mTodoListView->addColumn(i18n("Start Time")); | 391 | mTodoListView->addColumn(i18n("Start Time")); |
392 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 392 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
393 | 393 | ||
394 | mTodoListView->addColumn(i18n("Cancelled")); | 394 | mTodoListView->addColumn(i18n("Cancelled")); |
395 | mTodoListView->addColumn(i18n("Categories")); | 395 | mTodoListView->addColumn(i18n("Categories")); |
396 | #if 0 | 396 | #if 0 |
397 | mTodoListView->addColumn(i18n("Sort Id")); | 397 | mTodoListView->addColumn(i18n("Sort Id")); |
398 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 398 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
399 | #endif | 399 | #endif |
400 | 400 | ||
401 | mTodoListView->setMinimumHeight( 60 ); | 401 | mTodoListView->setMinimumHeight( 60 ); |
402 | mTodoListView->setItemsRenameable( true ); | 402 | mTodoListView->setItemsRenameable( true ); |
403 | mTodoListView->setRenameable( 0 ); | 403 | mTodoListView->setRenameable( 0 ); |
404 | mTodoListView->setColumnWidth( 0, 120 ); | 404 | mTodoListView->setColumnWidth( 0, 120 ); |
405 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 405 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
406 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 406 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
407 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 407 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
408 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 408 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
409 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 409 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
410 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 410 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
411 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 411 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
412 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 412 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
413 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 413 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
414 | 414 | ||
415 | 415 | ||
416 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 416 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
417 | 417 | ||
418 | mPriorityPopupMenu = new QPopupMenu(this); | 418 | mPriorityPopupMenu = new QPopupMenu(this); |
419 | for (int i = 1; i <= 5; i++) { | 419 | for (int i = 1; i <= 5; i++) { |
420 | QString label = QString ("%1").arg (i); | 420 | QString label = QString ("%1").arg (i); |
421 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 421 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
422 | } | 422 | } |
423 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 423 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
424 | 424 | ||
425 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 425 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
426 | for (int i = 0; i <= 100; i+=20) { | 426 | for (int i = 0; i <= 100; i+=20) { |
427 | QString label = QString ("%1 %").arg (i); | 427 | QString label = QString ("%1 %").arg (i); |
428 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 428 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
429 | } | 429 | } |
430 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 430 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
431 | 431 | ||
432 | 432 | ||
433 | 433 | ||
434 | mItemPopupMenu = new QPopupMenu(this); | 434 | mItemPopupMenu = new QPopupMenu(this); |
435 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 435 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
436 | SLOT (showTodo())); | 436 | SLOT (showTodo())); |
437 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 437 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
438 | SLOT (editTodo())); | 438 | SLOT (editTodo())); |
439 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 439 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
440 | SLOT (deleteTodo())); | 440 | SLOT (deleteTodo())); |
441 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 441 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
442 | SLOT (cloneTodo())); | 442 | SLOT (cloneTodo())); |
443 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 443 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
444 | SLOT (moveTodo())); | 444 | SLOT (moveTodo())); |
445 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 445 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
446 | SLOT (beamTodo())); | 446 | SLOT (beamTodo())); |
447 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 447 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
448 | SLOT (cancelTodo())); | 448 | SLOT (cancelTodo())); |
449 | mItemPopupMenu->insertSeparator(); | 449 | mItemPopupMenu->insertSeparator(); |
450 | 450 | ||
451 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 451 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
452 | SLOT (newTodo())); | 452 | SLOT (newTodo())); |
453 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 453 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
454 | SLOT (newSubTodo())); | 454 | SLOT (newSubTodo())); |
455 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 455 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
456 | SLOT (unparentTodo()),0,21); | 456 | SLOT (unparentTodo()),0,21); |
457 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 457 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
458 | SLOT (reparentTodo()),0,22); | 458 | SLOT (reparentTodo()),0,22); |
459 | mItemPopupMenu->insertSeparator(); | 459 | mItemPopupMenu->insertSeparator(); |
460 | #if 0 | 460 | #if 0 |
461 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 461 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
462 | this, SLOT( purgeCompleted() ) ); | 462 | this, SLOT( purgeCompleted() ) ); |
463 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 463 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
464 | this, SLOT( toggleCompleted() ),0, 33 ); | 464 | this, SLOT( toggleCompleted() ),0, 33 ); |
465 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 465 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
466 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 466 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
467 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 467 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
468 | this, SLOT( toggleRunning() ),0, 35 ); | 468 | this, SLOT( toggleRunning() ),0, 35 ); |
469 | 469 | ||
470 | #endif | 470 | #endif |
471 | mPopupMenu = new QPopupMenu(this); | 471 | mPopupMenu = new QPopupMenu(this); |
472 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 472 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
473 | SLOT (newTodo()),0,1); | 473 | SLOT (newTodo()),0,1); |
474 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 474 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
475 | this, SLOT(purgeCompleted()),0,2); | 475 | this, SLOT(purgeCompleted()),0,2); |
476 | mPopupMenu->insertItem(i18n("Show Completed"), | 476 | mPopupMenu->insertItem(i18n("Show Completed"), |
477 | this, SLOT( toggleCompleted() ),0,3 ); | 477 | this, SLOT( toggleCompleted() ),0,3 ); |
478 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 478 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
479 | this, SLOT( toggleQuickTodo() ),0,4 ); | 479 | this, SLOT( toggleQuickTodo() ),0,4 ); |
480 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 480 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
481 | this, SLOT( toggleRunning() ),0,5 ); | 481 | this, SLOT( toggleRunning() ),0,5 ); |
482 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 482 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
483 | this, SLOT( setAllOpen() ),0,6 ); | 483 | this, SLOT( setAllOpen() ),0,6 ); |
484 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 484 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
485 | this, SLOT( setAllClose() ),0,7 ); | 485 | this, SLOT( setAllClose() ),0,7 ); |
486 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 486 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
487 | this, SLOT( setAllFlat() ),0,8 ); | 487 | this, SLOT( setAllFlat() ),0,8 ); |
488 | mDocPrefs = new DocPrefs( name ); | 488 | mDocPrefs = new DocPrefs( name ); |
489 | 489 | ||
490 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 490 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
491 | mPopupMenu->setCheckable( true ); | 491 | mPopupMenu->setCheckable( true ); |
492 | mItemPopupMenu->setCheckable( true ); | 492 | mItemPopupMenu->setCheckable( true ); |
493 | 493 | ||
494 | 494 | ||
495 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 495 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
496 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 496 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
497 | 497 | ||
498 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 498 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
499 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 499 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
500 | 500 | ||
501 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 501 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
502 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 502 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
503 | 503 | ||
504 | 504 | ||
505 | // Double clicking conflicts with opening/closing the subtree | 505 | // Double clicking conflicts with opening/closing the subtree |
506 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 506 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
507 | SLOT( editItem( QListViewItem *) ) ); | 507 | SLOT( editItem( QListViewItem *) ) ); |
508 | /* | 508 | /* |
509 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 509 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
510 | const QPoint &,int ) ), | 510 | const QPoint &,int ) ), |
511 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 511 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
512 | */ | 512 | */ |
513 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 513 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
514 | const QPoint &,int ) ), | 514 | const QPoint &,int ) ), |
515 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 515 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
516 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 516 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
517 | SLOT( itemClicked( QListViewItem * ) ) ); | 517 | SLOT( itemClicked( QListViewItem * ) ) ); |
518 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 518 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
519 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 519 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
520 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 520 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
521 | SLOT( updateView() ) ); | 521 | SLOT( updateView() ) ); |
522 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 522 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
523 | SLOT( todoModified(Todo *, int) ) ); | 523 | SLOT( todoModified(Todo *, int) ) ); |
524 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 524 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
525 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 525 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
526 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 526 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
527 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 527 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
528 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 528 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
529 | SLOT( paintNeeded()) ); | 529 | SLOT( paintNeeded()) ); |
530 | 530 | ||
531 | #if 0 | 531 | #if 0 |
532 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 532 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
533 | SLOT(selectionChanged(QListViewItem *))); | 533 | SLOT(selectionChanged(QListViewItem *))); |
534 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 534 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
535 | SLOT(selectionChanged(QListViewItem *))); | 535 | SLOT(selectionChanged(QListViewItem *))); |
536 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 536 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
537 | SLOT(selectionChanged(QListViewItem *))); | 537 | SLOT(selectionChanged(QListViewItem *))); |
538 | #endif | 538 | #endif |
539 | 539 | ||
540 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 540 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
541 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 541 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
542 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 542 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
543 | 543 | ||
544 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 544 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
545 | SLOT( processSelectionChange() ) ); | 545 | SLOT( processSelectionChange() ) ); |
546 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 546 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
547 | SLOT( addQuickTodo() ) ); | 547 | SLOT( addQuickTodo() ) ); |
548 | 548 | ||
549 | } | 549 | } |
550 | 550 | ||
551 | KOTodoView::~KOTodoView() | 551 | KOTodoView::~KOTodoView() |
552 | { | 552 | { |
553 | delete mKOTodoViewWhatsThis; | 553 | // delete mKOTodoViewWhatsThis; |
554 | delete mDocPrefs; | 554 | delete mDocPrefs; |
555 | } | 555 | } |
556 | QString KOTodoView::getWhatsThisText(QPoint p) | 556 | QString KOTodoView::getWhatsThisText(QPoint p) |
557 | { | 557 | { |
558 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 558 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
559 | if ( item ) | 559 | if ( item ) |
560 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 560 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
561 | KOPrefs::instance()->mWTshowDetails, | 561 | KOPrefs::instance()->mWTshowDetails, |
562 | KOPrefs::instance()->mWTshowCreated, | 562 | KOPrefs::instance()->mWTshowCreated, |
563 | KOPrefs::instance()->mWTshowChanged); | 563 | KOPrefs::instance()->mWTshowChanged); |
564 | return i18n("That is the todo view" ); | 564 | return i18n("That is the todo view" ); |
565 | 565 | ||
566 | } | 566 | } |
567 | 567 | ||
568 | void KOTodoView::jumpToDate () | 568 | void KOTodoView::jumpToDate () |
569 | { | 569 | { |
570 | // if (mActiveItem) { | 570 | // if (mActiveItem) { |
571 | // mActiveItem->todo()); | 571 | // mActiveItem->todo()); |
572 | // if ( mActiveItem->todo()->hasDueDate() ) | 572 | // if ( mActiveItem->todo()->hasDueDate() ) |
573 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 573 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
574 | } | 574 | } |
575 | void KOTodoView::paintNeeded() | 575 | void KOTodoView::paintNeeded() |
576 | { | 576 | { |
577 | if ( mPendingUpdateBeforeRepaint ) { | 577 | if ( mPendingUpdateBeforeRepaint ) { |
578 | updateView(); | 578 | updateView(); |
579 | mPendingUpdateBeforeRepaint = false; | 579 | mPendingUpdateBeforeRepaint = false; |
580 | } | 580 | } |
581 | } | 581 | } |
582 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 582 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
583 | { | 583 | { |
584 | if ( mPendingUpdateBeforeRepaint ) { | 584 | if ( mPendingUpdateBeforeRepaint ) { |
585 | updateView(); | 585 | updateView(); |
586 | mPendingUpdateBeforeRepaint = false; | 586 | mPendingUpdateBeforeRepaint = false; |
587 | } | 587 | } |
588 | KOrg::BaseView::paintEvent( pevent); | 588 | KOrg::BaseView::paintEvent( pevent); |
589 | } | 589 | } |
590 | 590 | ||
591 | void KOTodoView::updateView() | 591 | void KOTodoView::updateView() |
592 | { | 592 | { |
593 | pendingSubtodo = 0; | 593 | pendingSubtodo = 0; |
594 | if ( mBlockUpdate ) { | 594 | if ( mBlockUpdate ) { |
595 | return; | 595 | return; |
596 | } | 596 | } |
597 | if ( !isVisible() ) { | 597 | if ( !isVisible() ) { |
598 | mPendingUpdateBeforeRepaint = true; | 598 | mPendingUpdateBeforeRepaint = true; |
599 | return; | 599 | return; |
600 | } | 600 | } |
601 | //qDebug("KOTodoView::updateView() %x", this); | 601 | //qDebug("KOTodoView::updateView() %x", this); |
602 | if ( isFlatDisplay ) { | 602 | if ( isFlatDisplay ) { |
603 | displayAllFlat(); | 603 | displayAllFlat(); |
604 | return; | 604 | return; |
605 | } | 605 | } |
606 | //qDebug("update "); | 606 | //qDebug("update "); |
607 | // kdDebug() << "KOTodoView::updateView()" << endl; | 607 | // kdDebug() << "KOTodoView::updateView()" << endl; |
608 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 608 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
609 | Incidence* oldInc = 0; | 609 | Incidence* oldInc = 0; |
610 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 610 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
611 | if (mActiveItem) | 611 | if (mActiveItem) |
612 | oldInc = mActiveItem->todo(); | 612 | oldInc = mActiveItem->todo(); |
613 | 613 | ||
614 | mTodoListView->clear(); | 614 | mTodoListView->clear(); |
615 | if ( mName == "todolistsmall" ) { | 615 | if ( mName == "todolistsmall" ) { |
616 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 616 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
617 | int ps = fo.pointSize() -2; | 617 | int ps = fo.pointSize() -2; |
618 | if ( ps > 12 ) | 618 | if ( ps > 12 ) |
619 | ps -= 2; | 619 | ps -= 2; |
620 | fo.setPointSize( ps ); | 620 | fo.setPointSize( ps ); |
621 | } | 621 | } |
622 | } | 622 | } |
623 | 623 | ||
624 | mTodoListView->setFont( fo ); | 624 | mTodoListView->setFont( fo ); |
625 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 625 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
626 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 626 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
627 | QPtrList<Todo> todoList = calendar()->todos(); | 627 | QPtrList<Todo> todoList = calendar()->todos(); |
628 | 628 | ||
629 | /* | 629 | /* |
630 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 630 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
631 | Event *t; | 631 | Event *t; |
632 | for(t = todoList.first(); t; t = todoList.next()) { | 632 | for(t = todoList.first(); t; t = todoList.next()) { |
633 | kdDebug() << " " << t->getSummary() << endl; | 633 | kdDebug() << " " << t->getSummary() << endl; |
634 | 634 | ||
635 | if (t->getRelatedTo()) { | 635 | if (t->getRelatedTo()) { |
636 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 636 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
637 | } | 637 | } |
638 | 638 | ||
639 | QPtrList<Event> l = t->getRelations(); | 639 | QPtrList<Event> l = t->getRelations(); |
640 | Event *c; | 640 | Event *c; |
641 | for(c=l.first();c;c=l.next()) { | 641 | for(c=l.first();c;c=l.next()) { |
642 | kdDebug() << " - relation: " << c->getSummary() << endl; | 642 | kdDebug() << " - relation: " << c->getSummary() << endl; |
643 | } | 643 | } |
644 | } | 644 | } |
645 | */ | 645 | */ |
646 | 646 | ||
647 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 647 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
648 | // specific order of events. That means that we have to generate parent items | 648 | // specific order of events. That means that we have to generate parent items |
649 | // recursively for proper hierarchical display of Todos. | 649 | // recursively for proper hierarchical display of Todos. |
650 | mTodoMap.clear(); | 650 | mTodoMap.clear(); |
651 | Todo *todo; | 651 | Todo *todo; |
652 | todo = todoList.first();// todo; todo = todoList.next()) { | 652 | todo = todoList.first();// todo; todo = todoList.next()) { |
653 | while ( todo ) { | 653 | while ( todo ) { |
654 | bool next = true; | 654 | bool next = true; |
655 | // qDebug("todo %s ", todo->summary().latin1()); | 655 | // qDebug("todo %s ", todo->summary().latin1()); |
656 | Incidence *incidence = todo->relatedTo(); | 656 | Incidence *incidence = todo->relatedTo(); |
657 | while ( incidence ) { | 657 | while ( incidence ) { |
658 | if ( incidence->type() == "Todo") { | 658 | if ( incidence->type() == "Todo") { |
659 | //qDebug("related %s ",incidence->summary().latin1() ); | 659 | //qDebug("related %s ",incidence->summary().latin1() ); |
660 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 660 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
661 | //qDebug("related not found "); | 661 | //qDebug("related not found "); |
662 | todoList.remove( ); | 662 | todoList.remove( ); |
663 | todo = todoList.current(); | 663 | todo = todoList.current(); |
664 | next = false; | 664 | next = false; |
665 | incidence = 0; | 665 | incidence = 0; |
666 | 666 | ||
667 | } else { | 667 | } else { |
668 | //qDebug("related found "); | 668 | //qDebug("related found "); |
669 | incidence = incidence->relatedTo(); | 669 | incidence = incidence->relatedTo(); |
670 | } | 670 | } |
671 | } else | 671 | } else |
672 | incidence = 0; | 672 | incidence = 0; |
673 | } | 673 | } |
674 | if ( next ) | 674 | if ( next ) |
675 | todo = todoList.next(); | 675 | todo = todoList.next(); |
676 | } | 676 | } |
677 | // qDebug("again .... "); | 677 | // qDebug("again .... "); |
678 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 678 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
679 | 679 | ||
680 | // qDebug("yytodo %s ", todo->summary().latin1()); | 680 | // qDebug("yytodo %s ", todo->summary().latin1()); |
681 | // } | 681 | // } |
682 | //qDebug("for "); | 682 | //qDebug("for "); |
683 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 683 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
684 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 684 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
685 | { | 685 | { |
686 | insertTodoItem(todo); | 686 | insertTodoItem(todo); |
687 | } | 687 | } |
688 | } | 688 | } |
689 | //qDebug("for end "); | 689 | //qDebug("for end "); |
690 | // Restore opened/closed state | 690 | // Restore opened/closed state |
691 | mTodoListView->blockSignals( true ); | 691 | mTodoListView->blockSignals( true ); |
692 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 692 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
693 | mTodoListView->blockSignals( false ); | 693 | mTodoListView->blockSignals( false ); |
694 | mTodoListView->setFocus(); | 694 | mTodoListView->setFocus(); |
695 | if ( mTodoListView->firstChild () ) { | 695 | if ( mTodoListView->firstChild () ) { |
696 | if ( oldInc ) { | 696 | if ( oldInc ) { |
697 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 697 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
698 | while ( item ) { | 698 | while ( item ) { |
699 | if ( item->todo() == oldInc ) { | 699 | if ( item->todo() == oldInc ) { |
700 | mTodoListView->setCurrentItem( item ); | 700 | mTodoListView->setCurrentItem( item ); |
701 | mTodoListView->ensureItemVisible( item ); | 701 | mTodoListView->ensureItemVisible( item ); |
702 | break; | 702 | break; |
703 | } | 703 | } |
704 | item = (KOTodoViewItem*)item->itemBelow(); | 704 | item = (KOTodoViewItem*)item->itemBelow(); |
705 | } | 705 | } |
706 | if ( ! item ) | 706 | if ( ! item ) |
707 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 707 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
708 | } else { | 708 | } else { |
709 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 709 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
710 | } | 710 | } |
711 | } | 711 | } |
712 | processSelectionChange(); | 712 | processSelectionChange(); |
713 | } | 713 | } |
714 | 714 | ||
715 | bool KOTodoView::checkTodo( Todo * todo ) | 715 | bool KOTodoView::checkTodo( Todo * todo ) |
716 | { | 716 | { |
717 | 717 | ||
718 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 718 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
719 | return false; | 719 | return false; |
720 | if ( !todo->isCompleted() ) { | 720 | if ( !todo->isCompleted() ) { |
721 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 721 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
722 | return true; | 722 | return true; |
723 | } | 723 | } |
724 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 724 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
725 | if ( todo->hasStartDate() ) | 725 | if ( todo->hasStartDate() ) |
726 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 726 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
727 | return false; | 727 | return false; |
728 | if ( todo->hasDueDate() ) | 728 | if ( todo->hasDueDate() ) |
729 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 729 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
730 | return false; | 730 | return false; |
731 | } | 731 | } |
732 | return true; | 732 | return true; |
733 | } | 733 | } |
734 | 734 | ||
735 | void KOTodoView::restoreItemState( QListViewItem *item ) | 735 | void KOTodoView::restoreItemState( QListViewItem *item ) |
736 | { | 736 | { |
737 | pendingSubtodo = 0; | 737 | pendingSubtodo = 0; |
738 | while( item ) { | 738 | while( item ) { |
739 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 739 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
740 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 740 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
741 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 741 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
742 | item = item->nextSibling(); | 742 | item = item->nextSibling(); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||