author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/koagendaitem.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | korganizer/koagendaitem.cpp | 70 |
1 files changed, 40 insertions, 30 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 407424d..0f9a38f 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,873 +1,883 @@ | |||
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 <q3hbox.h> |
23 | #include <qvbox.h> | 23 | #include <q3vbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <q3whatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <q3dragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <QDesktopWidget> | ||
30 | //Added by qt3to4: | ||
31 | #include <Q3PtrList> | ||
32 | #include <QPixmap> | ||
33 | #include <QDragEnterEvent> | ||
34 | #include <QDropEvent> | ||
35 | #include <QResizeEvent> | ||
36 | #include <QMouseEvent> | ||
37 | #include <QEvent> | ||
38 | #include <QPaintEvent> | ||
29 | 39 | ||
30 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 41 | #include <kdebug.h> |
32 | #include <kglobal.h> | 42 | #include <kglobal.h> |
33 | #include <klocale.h> | 43 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 44 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 45 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 46 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 47 | #else |
38 | #include <qapplication.h> | 48 | #include <qapplication.h> |
39 | #define AGENDA_ICON_SIZE 7 | 49 | #define AGENDA_ICON_SIZE 7 |
40 | #endif | 50 | #endif |
41 | #include <libkcal/icaldrag.h> | 51 | #include <libkcal/icaldrag.h> |
42 | #include <libkcal/vcaldrag.h> | 52 | #include <libkcal/vcaldrag.h> |
43 | #include <libkcal/kincidenceformatter.h> | 53 | #include <libkcal/kincidenceformatter.h> |
44 | extern int globalFlagBlockAgenda; | 54 | extern int globalFlagBlockAgenda; |
45 | extern int globalFlagBlockAgendaItemPaint; | 55 | extern int globalFlagBlockAgendaItemPaint; |
46 | extern int globalFlagBlockAgendaItemUpdate; | 56 | extern int globalFlagBlockAgendaItemUpdate; |
47 | 57 | ||
48 | #include "koprefs.h" | 58 | #include "koprefs.h" |
49 | 59 | ||
50 | #include "koagendaitem.h" | 60 | #include "koagendaitem.h" |
51 | //#include "koagendaitem.moc" | 61 | //#include "koagendaitem.moc" |
52 | 62 | ||
53 | 63 | ||
54 | //-------------------------------------------------------------------------- | 64 | //-------------------------------------------------------------------------- |
55 | 65 | ||
56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 66 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
57 | 67 | ||
58 | //-------------------------------------------------------------------------- | 68 | //-------------------------------------------------------------------------- |
59 | 69 | ||
60 | class KOAgendaItemWhatsThis :public QWhatsThis | 70 | class KOAgendaItemWhatsThis :public Q3WhatsThis |
61 | { | 71 | { |
62 | public: | 72 | public: |
63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 73 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : Q3WhatsThis( view ),_view (view) { }; |
64 | 74 | ||
65 | protected: | 75 | protected: |
66 | virtual QString text( const QPoint& ) | 76 | virtual QString text( const QPoint& ) |
67 | { | 77 | { |
68 | return _view->getWhatsThisText() ; | 78 | return _view->getWhatsThisText() ; |
69 | } | 79 | } |
70 | private: | 80 | private: |
71 | KOAgendaItem * _view; | 81 | KOAgendaItem * _view; |
72 | }; | 82 | }; |
73 | 83 | ||
74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 84 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
75 | const char *name,WFlags) : | 85 | const char *name,Qt::WFlags) : |
76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 86 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
77 | { | 87 | { |
78 | #ifndef DESKTOP_VERSION | 88 | #ifndef DESKTOP_VERSION |
79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 89 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
80 | #endif | 90 | #endif |
81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); | 91 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); |
82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 92 | Qt::WindowFlags wflags = windowFlags() |Qt::WRepaintNoErase;// WResizeNoErase |
83 | setWFlags ( wflags); | 93 | setWindowFlags ( wflags); |
84 | mAllDay = allday; | 94 | mAllDay = allday; |
85 | init ( incidence, qd ); | 95 | init ( incidence, qd ); |
86 | //setMouseTracking(true); | 96 | //setMouseTracking(true); |
87 | //setAcceptDrops(true); | 97 | //setAcceptDrops(true); |
88 | xPaintCoord = -1; | 98 | xPaintCoord = -1; |
89 | yPaintCoord = -1; | 99 | yPaintCoord = -1; |
90 | } | 100 | } |
91 | QString KOAgendaItem::getWhatsThisText() | 101 | QString KOAgendaItem::getWhatsThisText() |
92 | { | 102 | { |
93 | if ( mIncidence ) | 103 | if ( mIncidence ) |
94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 104 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
95 | KOPrefs::instance()->mWTshowDetails, | 105 | KOPrefs::instance()->mWTshowDetails, |
96 | KOPrefs::instance()->mWTshowCreated, | 106 | KOPrefs::instance()->mWTshowCreated, |
97 | KOPrefs::instance()->mWTshowChanged); | 107 | KOPrefs::instance()->mWTshowChanged); |
98 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 108 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
99 | } | 109 | } |
100 | 110 | ||
101 | void KOAgendaItem::initColor () | 111 | void KOAgendaItem::initColor () |
102 | { | 112 | { |
103 | if ( (mIncidence->typeID() == todoID ) && | 113 | if ( (mIncidence->typeID() == todoID ) && |
104 | ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && | 114 | ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && |
105 | ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 115 | ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
106 | if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) | 116 | if ( (static_cast<Todo*>(mIncidence))->dtDue() < (QDateTime)QDateTime::currentDateTime().date()) |
107 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 117 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
108 | else | 118 | else |
109 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 119 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
110 | } | 120 | } |
111 | else { | 121 | else { |
112 | QStringList categories = mIncidence->categories(); | 122 | QStringList categories = mIncidence->categories(); |
113 | QString cat = categories.first(); | 123 | QString cat = categories.first(); |
114 | if (cat.isEmpty()) { | 124 | if (cat.isEmpty()) { |
115 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) | 125 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) |
116 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 126 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
117 | else | 127 | else |
118 | mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); | 128 | mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
119 | } else { | 129 | } else { |
120 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 130 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
121 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { | 131 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { |
122 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 132 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
123 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; | 133 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; |
124 | } | 134 | } |
125 | } | 135 | } |
126 | 136 | ||
127 | } | 137 | } |
128 | 138 | ||
129 | QColor BackgroundColor ( mBackgroundColor ); | 139 | QColor BackgroundColor ( mBackgroundColor ); |
130 | if ( mIncidence->calID() > 1 ) { | 140 | if ( mIncidence->calID() > 1 ) { |
131 | //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); | 141 | //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
132 | } | 142 | } |
133 | mColorGroup = QColorGroup( BackgroundColor.light(), | 143 | mColorGroup = QColorGroup( BackgroundColor.light(), |
134 | BackgroundColor.dark(),BackgroundColor.light(), | 144 | BackgroundColor.dark(),BackgroundColor.light(), |
135 | BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; | 145 | BackgroundColor.dark(),BackgroundColor, Qt::black, BackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 146 | setBackgroundColor( mBackgroundColor ); |
137 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); | 147 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); |
138 | } | 148 | } |
139 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 149 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
140 | { | 150 | { |
141 | mIncidence = incidence; | 151 | mIncidence = incidence; |
142 | mDate = qd; | 152 | mDate = qd; |
143 | mFirstMultiItem = 0; | 153 | mFirstMultiItem = 0; |
144 | mNextMultiItem = 0; | 154 | mNextMultiItem = 0; |
145 | mLastMultiItem = 0; | 155 | mLastMultiItem = 0; |
146 | computeText(); | 156 | computeText(); |
147 | initColor(); | 157 | initColor(); |
148 | mConflictItems.clear(); | 158 | mConflictItems.clear(); |
149 | setCellXY(0,0,1); | 159 | setCellXY(0,0,1); |
150 | setCellXWidth(0); | 160 | setCellXWidth(0); |
151 | setSubCell(0); | 161 | setSubCell(0); |
152 | setSubCells(1); | 162 | setSubCells(1); |
153 | setMultiItem(0,0,0); | 163 | setMultiItem(0,0,0); |
154 | startMove(); | 164 | startMove(); |
155 | mSelected = true; | 165 | mSelected = true; |
156 | select(false); | 166 | select(false); |
157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 167 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
158 | mFontPixelSize = fontinf.height();; | 168 | mFontPixelSize = fontinf.height();; |
159 | hide(); | 169 | hide(); |
160 | xPaintCoord = -1; | 170 | xPaintCoord = -1; |
161 | yPaintCoord = -1; | 171 | yPaintCoord = -1; |
162 | } | 172 | } |
163 | 173 | ||
164 | 174 | ||
165 | KOAgendaItem::~KOAgendaItem() | 175 | KOAgendaItem::~KOAgendaItem() |
166 | { | 176 | { |
167 | #if QT_VERSION >= 0x030000 | 177 | #if QT_VERSION >= 0x030000 |
168 | 178 | ||
169 | #else | 179 | #else |
170 | delete mKOAgendaItemWhatsThis; | 180 | delete mKOAgendaItemWhatsThis; |
171 | #endif | 181 | #endif |
172 | 182 | ||
173 | } | 183 | } |
174 | 184 | ||
175 | void KOAgendaItem::recreateIncidence() | 185 | void KOAgendaItem::recreateIncidence() |
176 | { | 186 | { |
177 | #if 0 | 187 | #if 0 |
178 | Incidence* newInc = mIncidence->clone(); | 188 | Incidence* newInc = mIncidence->clone(); |
179 | newInc->recreate(); | 189 | newInc->recreate(); |
180 | if ( mIncidence->doesRecur() ) { | 190 | if ( mIncidence->doesRecur() ) { |
181 | mIncidence->addExDate( mDate ); | 191 | mIncidence->addExDate( mDate ); |
182 | newInc->recurrence()->unsetRecurs(); | 192 | newInc->recurrence()->unsetRecurs(); |
183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 193 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
184 | QTime tim = mIncidence->dtStart().time(); | 194 | QTime tim = mIncidence->dtStart().time(); |
185 | newInc->setDtStart( QDateTime(mDate, tim) ); | 195 | newInc->setDtStart( QDateTime(mDate, tim) ); |
186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 196 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
187 | } | 197 | } |
188 | #endif | 198 | #endif |
189 | mIncidence = mIncidence->recreateCloneException( mDate ); | 199 | mIncidence = mIncidence->recreateCloneException( mDate ); |
190 | } | 200 | } |
191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 201 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
192 | { | 202 | { |
193 | int size = AGENDA_ICON_SIZE; | 203 | int size = AGENDA_ICON_SIZE; |
194 | 204 | ||
195 | int yOff = 0; | 205 | int yOff = 0; |
196 | int xOff = 0; | 206 | int xOff = 0; |
197 | int x = pos().x(); | 207 | int x = pos().x(); |
198 | 208 | ||
199 | if ( x < 0 ) x = 0; | 209 | if ( x < 0 ) x = 0; |
200 | x += 3; | 210 | x += 3; |
201 | int y; | 211 | int y; |
202 | if ( mAllDay ) | 212 | if ( mAllDay ) |
203 | y = pos().y()+3; | 213 | y = pos().y()+3; |
204 | else | 214 | else |
205 | y = mCellYTop * ( height() / cellHeight() ) +3; | 215 | y = mCellYTop * ( height() / cellHeight() ) +3; |
206 | 216 | ||
207 | 217 | ||
208 | if ( mIncidence->calID() > 1 ) { | 218 | if ( mIncidence->calID() > 1 ) { |
209 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 219 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
210 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); | 220 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); |
211 | if ( horLayout ){ | 221 | if ( horLayout ){ |
212 | ++xOff; | 222 | ++xOff; |
213 | ++x; | 223 | ++x; |
214 | } | 224 | } |
215 | else { | 225 | else { |
216 | ++yOff; | 226 | ++yOff; |
217 | ++y; | 227 | ++y; |
218 | } | 228 | } |
219 | } | 229 | } |
220 | if (mIncidence->cancelled() && height() < 20 ) { | 230 | if (mIncidence->cancelled() && height() < 20 ) { |
221 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 231 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
222 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 232 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
223 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 233 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
224 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 234 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
225 | if ( horLayout ) | 235 | if ( horLayout ) |
226 | ++xOff; | 236 | ++xOff; |
227 | else | 237 | else |
228 | ++yOff; | 238 | ++yOff; |
229 | } | 239 | } |
230 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { | 240 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { |
231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 241 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::red ); |
232 | if ( horLayout ) | 242 | if ( horLayout ) |
233 | ++xOff; | 243 | ++xOff; |
234 | else | 244 | else |
235 | ++yOff; | 245 | ++yOff; |
236 | } | 246 | } |
237 | if (mIncidence->doesRecur()) { | 247 | if (mIncidence->doesRecur()) { |
238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 248 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::blue ); |
239 | if ( horLayout ) | 249 | if ( horLayout ) |
240 | ++xOff; | 250 | ++xOff; |
241 | else | 251 | else |
242 | ++yOff; | 252 | ++yOff; |
243 | } | 253 | } |
244 | if (mIncidence->description().length() > 0) { | 254 | if (mIncidence->description().length() > 0) { |
245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 255 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::darkGreen ); |
246 | if ( horLayout ) | 256 | if ( horLayout ) |
247 | ++xOff; | 257 | ++xOff; |
248 | else | 258 | else |
249 | ++yOff; | 259 | ++yOff; |
250 | } | 260 | } |
251 | if (mIncidence->isReadOnly()) { | 261 | if (mIncidence->isReadOnly()) { |
252 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 262 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::white ); |
253 | if ( horLayout ) | 263 | if ( horLayout ) |
254 | ++xOff; | 264 | ++xOff; |
255 | else | 265 | else |
256 | ++yOff; | 266 | ++yOff; |
257 | } | 267 | } |
258 | 268 | ||
259 | if (mIncidence->attendeeCount()>0) { | 269 | if (mIncidence->attendeeCount()>0) { |
260 | 270 | ||
261 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 271 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
262 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 272 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::black ); |
263 | if ( horLayout ) | 273 | if ( horLayout ) |
264 | ++xOff; | 274 | ++xOff; |
265 | else | 275 | else |
266 | ++yOff; | 276 | ++yOff; |
267 | } else { | 277 | } else { |
268 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 278 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
269 | if (me!=0) { | 279 | if (me!=0) { |
270 | 280 | ||
271 | 281 | ||
272 | } else { | 282 | } else { |
273 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 283 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::yellow ); |
274 | if ( horLayout ) | 284 | if ( horLayout ) |
275 | ++xOff; | 285 | ++xOff; |
276 | else | 286 | else |
277 | ++yOff; | 287 | ++yOff; |
278 | 288 | ||
279 | } | 289 | } |
280 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 290 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, Qt::darkYellow ); |
281 | if ( horLayout ) | 291 | if ( horLayout ) |
282 | ++xOff; | 292 | ++xOff; |
283 | else | 293 | else |
284 | ++yOff; | 294 | ++yOff; |
285 | 295 | ||
286 | } | 296 | } |
287 | 297 | ||
288 | } | 298 | } |
289 | return ( yOff || xOff ); | 299 | return ( yOff || xOff ); |
290 | } | 300 | } |
291 | 301 | ||
292 | 302 | ||
293 | void KOAgendaItem::select(bool selected) | 303 | void KOAgendaItem::select(bool selected) |
294 | { | 304 | { |
295 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 305 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
296 | if (mSelected == selected) return; | 306 | if (mSelected == selected) return; |
297 | mSelected = selected; | 307 | mSelected = selected; |
298 | if ( ! isVisible() ) | 308 | if ( ! isVisible() ) |
299 | return; | 309 | return; |
300 | if ( firstMultiItem() ) | 310 | if ( firstMultiItem() ) |
301 | firstMultiItem()->select( selected ); | 311 | firstMultiItem()->select( selected ); |
302 | if ( !firstMultiItem() && nextMultiItem() ) { | 312 | if ( !firstMultiItem() && nextMultiItem() ) { |
303 | KOAgendaItem * placeItem = nextMultiItem(); | 313 | KOAgendaItem * placeItem = nextMultiItem(); |
304 | while ( placeItem ) { | 314 | while ( placeItem ) { |
305 | placeItem->select( selected ); | 315 | placeItem->select( selected ); |
306 | placeItem = placeItem->nextMultiItem(); | 316 | placeItem = placeItem->nextMultiItem(); |
307 | } | 317 | } |
308 | } | 318 | } |
309 | globalFlagBlockAgendaItemUpdate = 0; | 319 | globalFlagBlockAgendaItemUpdate = 0; |
310 | paintMe( selected ); | 320 | paintMe( selected ); |
311 | globalFlagBlockAgendaItemUpdate = 1; | 321 | globalFlagBlockAgendaItemUpdate = 1; |
312 | repaint( false ); | 322 | repaint( false ); |
313 | } | 323 | } |
314 | 324 | ||
315 | 325 | ||
316 | /* | 326 | /* |
317 | The eventFilter has to filter the mouse events of the agenda item childs. The | 327 | The eventFilter has to filter the mouse events of the agenda item childs. The |
318 | events are fed into the event handling method of KOAgendaItem. This allows the | 328 | events are fed into the event handling method of KOAgendaItem. This allows the |
319 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 329 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
320 | */ | 330 | */ |
321 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 331 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
322 | { | 332 | { |
323 | if (e->type() == QEvent::MouseButtonPress || | 333 | if (e->type() == QEvent::MouseButtonPress || |
324 | e->type() == QEvent::MouseButtonDblClick || | 334 | e->type() == QEvent::MouseButtonDblClick || |
325 | e->type() == QEvent::MouseButtonRelease || | 335 | e->type() == QEvent::MouseButtonRelease || |
326 | e->type() == QEvent::MouseMove) { | 336 | e->type() == QEvent::MouseMove) { |
327 | QMouseEvent *me = (QMouseEvent *)e; | 337 | QMouseEvent *me = (QMouseEvent *)e; |
328 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 338 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
329 | mapToGlobal(me->pos())); | 339 | mapToGlobal(me->pos())); |
330 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 340 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
331 | return event(&returnEvent); | 341 | return event(&returnEvent); |
332 | } else { | 342 | } else { |
333 | return false; | 343 | return false; |
334 | } | 344 | } |
335 | } | 345 | } |
336 | void KOAgendaItem::repaintMe( ) | 346 | void KOAgendaItem::repaintMe( ) |
337 | { | 347 | { |
338 | paintMe ( mSelected ); | 348 | paintMe ( mSelected ); |
339 | } | 349 | } |
340 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 350 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
341 | { | 351 | { |
342 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 352 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
343 | return; | 353 | return; |
344 | QPainter pa; | 354 | QPainter pa; |
345 | 355 | ||
346 | if ( mSelected ) { | 356 | if ( mSelected ) { |
347 | pa.begin( this ); | 357 | pa.begin( this ); |
348 | } else { | 358 | } else { |
349 | if ( mAllDay ) | 359 | if ( mAllDay ) |
350 | pa.begin( paintPixAllday() ); | 360 | pa.begin( paintPixAllday() ); |
351 | else | 361 | else |
352 | pa.begin( paintPix() ); | 362 | pa.begin( paintPix() ); |
353 | } | 363 | } |
354 | int x, yy, w, h; | 364 | int x, yy, w, h; |
355 | float nfh = 7.0; | 365 | float nfh = 7.0; |
356 | x = pos().x(); w = width(); h = height (); | 366 | x = pos().x(); w = width(); h = height (); |
357 | if ( mAllDay ) | 367 | if ( mAllDay ) |
358 | yy = y(); | 368 | yy = y(); |
359 | else | 369 | else |
360 | yy = mCellYTop * ( height() / cellHeight() ); | 370 | yy = mCellYTop * ( height() / cellHeight() ); |
361 | if ( mSelected ) { | 371 | if ( mSelected ) { |
362 | pa.translate( -x, -yy ); | 372 | pa.translate( -x, -yy ); |
363 | } | 373 | } |
364 | xPaintCoord= x; | 374 | xPaintCoord= x; |
365 | yPaintCoord = yy; | 375 | yPaintCoord = yy; |
366 | wPaintCoord = width(); | 376 | wPaintCoord = width(); |
367 | hPaintCoord = height(); | 377 | hPaintCoord = height(); |
368 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 378 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
369 | if ( paint == 0 ) | 379 | if ( paint == 0 ) |
370 | paint = &pa; | 380 | paint = &pa; |
371 | bool horLayout = ( w < h ); | 381 | bool horLayout = ( w < h ); |
372 | int maxhei = mFontPixelSize+4; | 382 | int maxhei = mFontPixelSize+4; |
373 | if ( horLayout ) | 383 | if ( horLayout ) |
374 | maxhei += AGENDA_ICON_SIZE -4; | 384 | maxhei += AGENDA_ICON_SIZE -4; |
375 | bool small = ( h < maxhei ); | 385 | bool small = ( h < maxhei ); |
376 | if ( ! small ) | 386 | if ( ! small ) |
377 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 387 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
378 | else { | 388 | else { |
379 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 389 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
380 | f.setBold( false ); | 390 | f.setBold( false ); |
381 | int fh = f.pointSize(); | 391 | int fh = f.pointSize(); |
382 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 392 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
383 | if ( nfh < 6 ) | 393 | if ( nfh < 6 ) |
384 | nfh = 6; | 394 | nfh = 6; |
385 | f.setPointSize( nfh ); | 395 | f.setPointSize( nfh ); |
386 | paint->setFont(f); | 396 | paint->setFont(f); |
387 | } | 397 | } |
388 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 398 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
389 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 399 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
390 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 400 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
391 | if ( mIncidence->typeID() == todoID ) { | 401 | if ( mIncidence->typeID() == todoID ) { |
392 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 402 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
393 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 403 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
394 | int yyy = yy+3; | 404 | int yyy = yy+3; |
395 | if ( tempTodo->isCompleted() ) | 405 | if ( tempTodo->isCompleted() ) |
396 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 406 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
397 | else { | 407 | else { |
398 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 408 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
399 | 409 | ||
400 | } | 410 | } |
401 | } | 411 | } |
402 | bool addIcon = false; | 412 | bool addIcon = false; |
403 | if ( ! small || w > 3 * h || h > 3* w ) | 413 | if ( ! small || w > 3 * h || h > 3* w ) |
404 | addIcon = updateIcons( paint, horLayout ); | 414 | addIcon = updateIcons( paint, horLayout ); |
405 | 415 | ||
406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 416 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); | 417 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); |
408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 418 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
409 | if ( ! small ) { | 419 | if ( ! small ) { |
410 | x += 3; yy += 3;w -= 6; h-= 5; | 420 | x += 3; yy += 3;w -= 6; h-= 5; |
411 | } else { | 421 | } else { |
412 | x += 2; yy += 1;w -= 4; h-= 4; | 422 | x += 2; yy += 1;w -= 4; h-= 4; |
413 | if ( nfh < 6.01 ) { | 423 | if ( nfh < 6.01 ) { |
414 | yy -= 2; | 424 | yy -= 2; |
415 | h += 4; | 425 | h += 4; |
416 | } | 426 | } |
417 | else | 427 | else |
418 | if ( nfh < h -2 ) | 428 | if ( nfh < h -2 ) |
419 | ++yy; | 429 | ++yy; |
420 | } | 430 | } |
421 | int align; | 431 | int align; |
422 | #ifndef DESKTOP_VERSION | 432 | #ifndef DESKTOP_VERSION |
423 | align = ( AlignLeft|WordBreak|AlignTop); | 433 | align = ( Qt::AlignLeft|Qt::TextWordWrap|Qt::AlignTop); |
424 | #else | 434 | #else |
425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 435 | align = ( Qt::AlignLeft|Qt::TextWrapAnywhere|Qt::TextWordWrap|Qt::AlignTop); |
426 | #endif | 436 | #endif |
427 | if ( addIcon ) { | 437 | if ( addIcon ) { |
428 | if ( ! horLayout ) { | 438 | if ( ! horLayout ) { |
429 | x += AGENDA_ICON_SIZE+3; | 439 | x += AGENDA_ICON_SIZE+3; |
430 | w -= (AGENDA_ICON_SIZE+3); | 440 | w -= (AGENDA_ICON_SIZE+3); |
431 | } | 441 | } |
432 | else { | 442 | else { |
433 | yy+= AGENDA_ICON_SIZE+2; | 443 | yy+= AGENDA_ICON_SIZE+2; |
434 | h -=(AGENDA_ICON_SIZE+3); | 444 | h -=(AGENDA_ICON_SIZE+3); |
435 | } | 445 | } |
436 | } | 446 | } |
437 | if ( mWhiteText ) | 447 | if ( mWhiteText ) |
438 | paint->setPen ( white); | 448 | paint->setPen ( Qt::white); |
439 | if ( x < 0 ) { | 449 | if ( x < 0 ) { |
440 | w = w+x-3; | 450 | w = w+x-3; |
441 | x = 3; | 451 | x = 3; |
442 | if ( !horLayout && addIcon ) | 452 | if ( !horLayout && addIcon ) |
443 | x += AGENDA_ICON_SIZE+3; | 453 | x += AGENDA_ICON_SIZE+3; |
444 | if ( w > parentWidget()->width() ){ | 454 | if ( w > parentWidget()->width() ){ |
445 | w = parentWidget()->width() - 6; | 455 | w = parentWidget()->width() - 6; |
446 | #ifndef DESKTOP_VERSION | 456 | #ifndef DESKTOP_VERSION |
447 | align = ( AlignHCenter|WordBreak|AlignTop); | 457 | align = ( Qt::AlignHCenter|Qt::TextWordWrap|Qt::AlignTop); |
448 | #else | 458 | #else |
449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 459 | align = ( Qt::AlignHCenter|Qt::TextWrapAnywhere|Qt::TextWordWrap|Qt::AlignTop); |
450 | #endif | 460 | #endif |
451 | 461 | ||
452 | } | 462 | } |
453 | } | 463 | } |
454 | QRect dr; | 464 | QRect dr; |
455 | if ( w + x > parentWidget()->width() ) | 465 | if ( w + x > parentWidget()->width() ) |
456 | w = parentWidget()->width()-x; | 466 | w = parentWidget()->width()-x; |
457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 467 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
458 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 468 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
459 | if ( mIncidence->cancelled() ){ | 469 | if ( mIncidence->cancelled() ){ |
460 | 470 | ||
461 | 471 | ||
462 | small = ( height() < 20 ); | 472 | small = ( height() < 20 ); |
463 | 473 | ||
464 | if ( ! small ) { | 474 | if ( ! small ) { |
465 | QFontMetrics fm ( paint->font() ); | 475 | QFontMetrics fm ( paint->font() ); |
466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 476 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
467 | } | 477 | } |
468 | 478 | ||
469 | } | 479 | } |
470 | pa.end(); | 480 | pa.end(); |
471 | 481 | ||
472 | } | 482 | } |
473 | 483 | ||
474 | QPixmap * KOAgendaItem::paintPix() | 484 | QPixmap * KOAgendaItem::paintPix() |
475 | { | 485 | { |
476 | static QPixmap* mPaintPix = 0; | 486 | static QPixmap* mPaintPix = 0; |
477 | if ( ! mPaintPix ) { | 487 | if ( ! mPaintPix ) { |
478 | int w = QApplication::desktop()->width(); | 488 | int w = QApplication::desktop()->width(); |
479 | int h = QApplication::desktop()->height(); | 489 | int h = QApplication::desktop()->height(); |
480 | mPaintPix = new QPixmap(w,h); | 490 | mPaintPix = new QPixmap(w,h); |
481 | } | 491 | } |
482 | return mPaintPix ; | 492 | return mPaintPix ; |
483 | } | 493 | } |
484 | QPixmap * KOAgendaItem::paintPixAllday() | 494 | QPixmap * KOAgendaItem::paintPixAllday() |
485 | { | 495 | { |
486 | static QPixmap* mPaintPixA = 0; | 496 | static QPixmap* mPaintPixA = 0; |
487 | if ( ! mPaintPixA ) { | 497 | if ( ! mPaintPixA ) { |
488 | int w = QApplication::desktop()->width(); | 498 | int w = QApplication::desktop()->width(); |
489 | int h = QApplication::desktop()->height()/5; | 499 | int h = QApplication::desktop()->height()/5; |
490 | mPaintPixA = new QPixmap(w,h); | 500 | mPaintPixA = new QPixmap(w,h); |
491 | } | 501 | } |
492 | return mPaintPixA ; | 502 | return mPaintPixA ; |
493 | } | 503 | } |
494 | 504 | ||
495 | void KOAgendaItem::repaintItem() | 505 | void KOAgendaItem::repaintItem() |
496 | { | 506 | { |
497 | globalFlagBlockAgendaItemPaint = 0; | 507 | globalFlagBlockAgendaItemPaint = 0; |
498 | globalFlagBlockAgenda = 0; | 508 | globalFlagBlockAgenda = 0; |
499 | repaint( false ); | 509 | repaint( false ); |
500 | } | 510 | } |
501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 511 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
502 | { | 512 | { |
503 | 513 | ||
504 | if ( globalFlagBlockAgendaItemPaint ) | 514 | if ( globalFlagBlockAgendaItemPaint ) |
505 | return; | 515 | return; |
506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 516 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
507 | return; | 517 | return; |
508 | int yy; | 518 | int yy; |
509 | if ( mAllDay ) | 519 | if ( mAllDay ) |
510 | yy = y(); | 520 | yy = y(); |
511 | else | 521 | else |
512 | yy = mCellYTop * ( height() / cellHeight() ); | 522 | yy = mCellYTop * ( height() / cellHeight() ); |
513 | int xx = x(); | 523 | int xx = x(); |
514 | 524 | ||
515 | if ( xPaintCoord != xx || yPaintCoord != yy || | 525 | if ( xPaintCoord != xx || yPaintCoord != yy || |
516 | wPaintCoord != width() || hPaintCoord != height()) { | 526 | wPaintCoord != width() || hPaintCoord != height()) { |
517 | xPaintCoord= xx; | 527 | xPaintCoord= xx; |
518 | yPaintCoord = yy; | 528 | yPaintCoord = yy; |
519 | wPaintCoord = width(); | 529 | wPaintCoord = width(); |
520 | hPaintCoord = height(); | 530 | hPaintCoord = height(); |
521 | globalFlagBlockAgendaItemUpdate = 0; | 531 | globalFlagBlockAgendaItemUpdate = 0; |
522 | paintMe( mSelected ); | 532 | paintMe( mSelected ); |
523 | //qDebug("calling paintMe "); | 533 | //qDebug("calling paintMe "); |
524 | globalFlagBlockAgendaItemUpdate = 1; | 534 | globalFlagBlockAgendaItemUpdate = 1; |
525 | if ( mSelected ) | 535 | if ( mSelected ) |
526 | return; | 536 | return; |
527 | } | 537 | } |
528 | int rx, ry, rw, rh; | 538 | int rx, ry, rw, rh; |
529 | rx = e->rect().x(); | 539 | rx = e->rect().x(); |
530 | ry = e->rect().y(); | 540 | ry = e->rect().y(); |
531 | rw = e->rect().width(); | 541 | rw = e->rect().width(); |
532 | rh = e->rect().height(); | 542 | rh = e->rect().height(); |
533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 543 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
534 | 544 | ||
535 | QPixmap* paintFrom ; | 545 | QPixmap* paintFrom ; |
536 | if ( mSelected ) { | 546 | if ( mSelected ) { |
537 | paintMe( mSelected ); | 547 | paintMe( mSelected ); |
538 | return; | 548 | return; |
539 | } else { | 549 | } else { |
540 | if ( mAllDay ) | 550 | if ( mAllDay ) |
541 | paintFrom = paintPixAllday(); | 551 | paintFrom = paintPixAllday(); |
542 | else | 552 | else |
543 | paintFrom = paintPix(); | 553 | paintFrom = paintPix(); |
544 | } | 554 | } |
545 | xx += rx; | 555 | xx += rx; |
546 | 556 | ||
547 | if ( xx < 0 ) { | 557 | if ( xx < 0 ) { |
548 | rw = rw + xx; | 558 | rw = rw + xx; |
549 | rx -= xx; | 559 | rx -= xx; |
550 | xx = 0; | 560 | xx = 0; |
551 | if ( rw <= 1 ) { | 561 | if ( rw <= 1 ) { |
552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 562 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
553 | return; | 563 | return; |
554 | } | 564 | } |
555 | } | 565 | } |
556 | if ( paintFrom->width() < xx+rw ) { | 566 | if ( paintFrom->width() < xx+rw ) { |
557 | rw = paintFrom->width() - xx; | 567 | rw = paintFrom->width() - xx; |
558 | if ( rw <= 1 ) { | 568 | if ( rw <= 1 ) { |
559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 569 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
560 | return; | 570 | return; |
561 | } | 571 | } |
562 | } | 572 | } |
563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 573 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 574 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,QPainter::CompositionMode_Source); |
565 | } | 575 | } |
566 | void KOAgendaItem::computeText() | 576 | void KOAgendaItem::computeText() |
567 | { | 577 | { |
568 | mDisplayedText = mIncidence->summary(); | 578 | mDisplayedText = mIncidence->summary(); |
569 | if ( (mIncidence->typeID() == todoID ) ) { | 579 | if ( (mIncidence->typeID() == todoID ) ) { |
570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 580 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 581 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 582 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
573 | else if ( !(mIncidence->doesFloat())) | 583 | else if ( !(mIncidence->doesFloat())) |
574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 584 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
575 | } | 585 | } |
576 | } else { | 586 | } else { |
577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 587 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 588 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
579 | 589 | ||
580 | if ( mAllDay ) { | 590 | if ( mAllDay ) { |
581 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 591 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
582 | int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() ); | 592 | int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() ); |
583 | mDisplayedText += " ("+QString::number( dur )+i18n(" days") +")" ; | 593 | mDisplayedText += " ("+QString::number( dur )+i18n(" days") +")" ; |
584 | 594 | ||
585 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 595 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
586 | if ( mIncidence->doesRecur() ) { | 596 | if ( mIncidence->doesRecur() ) { |
587 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 597 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
588 | } else { | 598 | } else { |
589 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true); | 599 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true); |
590 | } | 600 | } |
591 | } | 601 | } |
592 | } | 602 | } |
593 | } | 603 | } |
594 | } | 604 | } |
595 | if ( !mIncidence->location().isEmpty() ) { | 605 | if ( !mIncidence->location().isEmpty() ) { |
596 | if ( mAllDay ) | 606 | if ( mAllDay ) |
597 | mDisplayedText += " ("; | 607 | mDisplayedText += " ("; |
598 | else | 608 | else |
599 | mDisplayedText += "\n("; | 609 | mDisplayedText += "\n("; |
600 | mDisplayedText += mIncidence->location() +")"; | 610 | mDisplayedText += mIncidence->location() +")"; |
601 | } | 611 | } |
602 | #ifdef DESKTOP_VERSION | 612 | #ifdef DESKTOP_VERSION |
603 | QString tipText = mIncidence->summary(); | 613 | QString tipText = mIncidence->summary(); |
604 | if ( !mIncidence->doesFloat() ) { | 614 | if ( !mIncidence->doesFloat() ) { |
605 | if ( mIncidence->typeID() == eventID ) { | 615 | if ( mIncidence->typeID() == eventID ) { |
606 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 616 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
607 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 617 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
608 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 618 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
609 | } | 619 | } |
610 | else { | 620 | else { |
611 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 621 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
612 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 622 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
613 | } | 623 | } |
614 | } | 624 | } |
615 | else if ( mIncidence->typeID() == todoID ) { | 625 | else if ( mIncidence->typeID() == todoID ) { |
616 | if (mIncidence->hasStartDate()) | 626 | if (mIncidence->hasStartDate()) |
617 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 627 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
618 | if (((Todo*)mIncidence)->hasDueDate()) | 628 | if (((Todo*)mIncidence)->hasDueDate()) |
619 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 629 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
620 | } | 630 | } |
621 | } else if ( mIncidence->typeID() == todoID ) { | 631 | } else if ( mIncidence->typeID() == todoID ) { |
622 | if (mIncidence->hasStartDate()) | 632 | if (mIncidence->hasStartDate()) |
623 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 633 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
624 | if (((Todo*)mIncidence)->hasDueDate()) | 634 | if (((Todo*)mIncidence)->hasDueDate()) |
625 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 635 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
626 | } | 636 | } |
627 | 637 | ||
628 | if (!mIncidence->location().isEmpty()) { | 638 | if (!mIncidence->location().isEmpty()) { |
629 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 639 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
630 | } | 640 | } |
631 | QToolTip::add(this,tipText,toolTipGroup(),""); | 641 | QToolTip::add(this,tipText /*TODO:hacker: ,toolTipGroup(),"" */); |
632 | #endif | 642 | #endif |
633 | } | 643 | } |
634 | void KOAgendaItem::updateItem() | 644 | void KOAgendaItem::updateItem() |
635 | { | 645 | { |
636 | computeText(); | 646 | computeText(); |
637 | 647 | ||
638 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 648 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
639 | paintMe( mSelected ); | 649 | paintMe( mSelected ); |
640 | repaint( false); | 650 | repaint( false); |
641 | } | 651 | } |
642 | 652 | ||
643 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 653 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
644 | { | 654 | { |
645 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 655 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
646 | paintMe( mSelected ); | 656 | paintMe( mSelected ); |
647 | repaint( false ); | 657 | repaint( false ); |
648 | } | 658 | } |
649 | 659 | ||
650 | /* | 660 | /* |
651 | Return height of item in units of agenda cells | 661 | Return height of item in units of agenda cells |
652 | */ | 662 | */ |
653 | int KOAgendaItem::cellHeight() | 663 | int KOAgendaItem::cellHeight() |
654 | { | 664 | { |
655 | int ret = mCellYBottom - mCellYTop + 1; | 665 | int ret = mCellYBottom - mCellYTop + 1; |
656 | if ( ret <= 0 ) { | 666 | if ( ret <= 0 ) { |
657 | ret = 1; | 667 | ret = 1; |
658 | mCellYBottom = 0; | 668 | mCellYBottom = 0; |
659 | mCellYTop = 0; | 669 | mCellYTop = 0; |
660 | } | 670 | } |
661 | return ret; | 671 | return ret; |
662 | } | 672 | } |
663 | // it may be that allday agenda items have a needed width > 32000 | 673 | // it may be that allday agenda items have a needed width > 32000 |
664 | // this code is to fix this problem | 674 | // this code is to fix this problem |
665 | int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) | 675 | int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) |
666 | { | 676 | { |
667 | int diff = 0; | 677 | int diff = 0; |
668 | if ( mCellX < -3 && mAllDay ) { | 678 | if ( mCellX < -3 && mAllDay ) { |
669 | diff = (mCellX + 3) * -grid; | 679 | diff = (mCellX + 3) * -grid; |
670 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); | 680 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); |
671 | if ( diff >= wid ) { | 681 | if ( diff >= wid ) { |
672 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); | 682 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); |
673 | //diff = 0; | 683 | //diff = 0; |
674 | } | 684 | } |
675 | } | 685 | } |
676 | if ( (!invalidWidth && wid == width() ) || diff >= wid ) | 686 | if ( (!invalidWidth && wid == width() ) || diff >= wid ) |
677 | resize( wid, hei ); | 687 | resize( wid, hei ); |
678 | else | 688 | else |
679 | resize( wid - diff, hei ); | 689 | resize( wid - diff, hei ); |
680 | //qDebug("wid %d x %d ", width(), x()); | 690 | //qDebug("wid %d x %d ", width(), x()); |
681 | return diff; | 691 | return diff; |
682 | } | 692 | } |
683 | /* | 693 | /* |
684 | Return height of item in units of agenda cells | 694 | Return height of item in units of agenda cells |
685 | */ | 695 | */ |
686 | int KOAgendaItem::cellWidth() | 696 | int KOAgendaItem::cellWidth() |
687 | { | 697 | { |
688 | return mCellXWidth - mCellX + 1; | 698 | return mCellXWidth - mCellX + 1; |
689 | } | 699 | } |
690 | 700 | ||
691 | void KOAgendaItem::setItemDate(QDate qd) | 701 | void KOAgendaItem::setItemDate(QDate qd) |
692 | { | 702 | { |
693 | mDate = qd; | 703 | mDate = qd; |
694 | } | 704 | } |
695 | 705 | ||
696 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 706 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
697 | { | 707 | { |
698 | mCellX = X; | 708 | mCellX = X; |
699 | mCellYTop = YTop; | 709 | mCellYTop = YTop; |
700 | mCellYBottom = YBottom; | 710 | mCellYBottom = YBottom; |
701 | } | 711 | } |
702 | 712 | ||
703 | void KOAgendaItem::setCellXWidth(int xwidth) | 713 | void KOAgendaItem::setCellXWidth(int xwidth) |
704 | { | 714 | { |
705 | mCellXWidth = xwidth; | 715 | mCellXWidth = xwidth; |
706 | } | 716 | } |
707 | 717 | ||
708 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 718 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
709 | { | 719 | { |
710 | mCellX = XLeft; | 720 | mCellX = XLeft; |
711 | mCellXWidth = XRight; | 721 | mCellXWidth = XRight; |
712 | } | 722 | } |
713 | 723 | ||
714 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 724 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
715 | { | 725 | { |
716 | mCellYTop = YTop; | 726 | mCellYTop = YTop; |
717 | mCellYBottom = YBottom; | 727 | mCellYBottom = YBottom; |
718 | } | 728 | } |
719 | 729 | ||
720 | void KOAgendaItem::setSubCell(int subCell) | 730 | void KOAgendaItem::setSubCell(int subCell) |
721 | { | 731 | { |
722 | mSubCell = subCell; | 732 | mSubCell = subCell; |
723 | } | 733 | } |
724 | 734 | ||
725 | void KOAgendaItem::setSubCells(int subCells) | 735 | void KOAgendaItem::setSubCells(int subCells) |
726 | { | 736 | { |
727 | mSubCells = subCells; | 737 | mSubCells = subCells; |
728 | } | 738 | } |
729 | 739 | ||
730 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 740 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
731 | KOAgendaItem *last) | 741 | KOAgendaItem *last) |
732 | { | 742 | { |
733 | mFirstMultiItem = first; | 743 | mFirstMultiItem = first; |
734 | mNextMultiItem = next; | 744 | mNextMultiItem = next; |
735 | mLastMultiItem = last; | 745 | mLastMultiItem = last; |
736 | } | 746 | } |
737 | 747 | ||
738 | void KOAgendaItem::startMove() | 748 | void KOAgendaItem::startMove() |
739 | { | 749 | { |
740 | mStartCellX = mCellX; | 750 | mStartCellX = mCellX; |
741 | mStartCellXWidth = mCellXWidth; | 751 | mStartCellXWidth = mCellXWidth; |
742 | mStartCellYTop = mCellYTop; | 752 | mStartCellYTop = mCellYTop; |
743 | mStartCellYBottom = mCellYBottom; | 753 | mStartCellYBottom = mCellYBottom; |
744 | } | 754 | } |
745 | 755 | ||
746 | void KOAgendaItem::resetMove() | 756 | void KOAgendaItem::resetMove() |
747 | { | 757 | { |
748 | mCellX = mStartCellX; | 758 | mCellX = mStartCellX; |
749 | mCellXWidth = mStartCellXWidth; | 759 | mCellXWidth = mStartCellXWidth; |
750 | mCellYTop = mStartCellYTop; | 760 | mCellYTop = mStartCellYTop; |
751 | mCellYBottom = mStartCellYBottom; | 761 | mCellYBottom = mStartCellYBottom; |
752 | } | 762 | } |
753 | 763 | ||
754 | void KOAgendaItem::moveRelative(int dx, int dy) | 764 | void KOAgendaItem::moveRelative(int dx, int dy) |
755 | { | 765 | { |
756 | int newX = cellX() + dx; | 766 | int newX = cellX() + dx; |
757 | int newXWidth = cellXWidth() + dx; | 767 | int newXWidth = cellXWidth() + dx; |
758 | int newYTop = cellYTop() + dy; | 768 | int newYTop = cellYTop() + dy; |
759 | int newYBottom = cellYBottom() + dy; | 769 | int newYBottom = cellYBottom() + dy; |
760 | setCellXY(newX,newYTop,newYBottom); | 770 | setCellXY(newX,newYTop,newYBottom); |
761 | setCellXWidth(newXWidth); | 771 | setCellXWidth(newXWidth); |
762 | } | 772 | } |
763 | 773 | ||
764 | void KOAgendaItem::expandTop(int dy) | 774 | void KOAgendaItem::expandTop(int dy) |
765 | { | 775 | { |
766 | int newYTop = cellYTop() + dy; | 776 | int newYTop = cellYTop() + dy; |
767 | int newYBottom = cellYBottom(); | 777 | int newYBottom = cellYBottom(); |
768 | if (newYTop > newYBottom) newYTop = newYBottom; | 778 | if (newYTop > newYBottom) newYTop = newYBottom; |
769 | setCellY(newYTop, newYBottom); | 779 | setCellY(newYTop, newYBottom); |
770 | } | 780 | } |
771 | 781 | ||
772 | void KOAgendaItem::expandBottom(int dy) | 782 | void KOAgendaItem::expandBottom(int dy) |
773 | { | 783 | { |
774 | int newYTop = cellYTop(); | 784 | int newYTop = cellYTop(); |
775 | int newYBottom = cellYBottom() + dy; | 785 | int newYBottom = cellYBottom() + dy; |
776 | if (newYBottom < newYTop) newYBottom = newYTop; | 786 | if (newYBottom < newYTop) newYBottom = newYTop; |
777 | setCellY(newYTop, newYBottom); | 787 | setCellY(newYTop, newYBottom); |
778 | } | 788 | } |
779 | 789 | ||
780 | void KOAgendaItem::expandLeft(int dx) | 790 | void KOAgendaItem::expandLeft(int dx) |
781 | { | 791 | { |
782 | int newX = cellX() + dx; | 792 | int newX = cellX() + dx; |
783 | int newXWidth = cellXWidth(); | 793 | int newXWidth = cellXWidth(); |
784 | if (newX > newXWidth) newX = newXWidth; | 794 | if (newX > newXWidth) newX = newXWidth; |
785 | setCellX(newX,newXWidth); | 795 | setCellX(newX,newXWidth); |
786 | } | 796 | } |
787 | 797 | ||
788 | void KOAgendaItem::expandRight(int dx) | 798 | void KOAgendaItem::expandRight(int dx) |
789 | { | 799 | { |
790 | int newX = cellX(); | 800 | int newX = cellX(); |
791 | int newXWidth = cellXWidth() + dx; | 801 | int newXWidth = cellXWidth() + dx; |
792 | if (newXWidth < newX) newXWidth = newX; | 802 | if (newXWidth < newX) newXWidth = newX; |
793 | setCellX(newX,newXWidth); | 803 | setCellX(newX,newXWidth); |
794 | } | 804 | } |
795 | 805 | ||
796 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 806 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
797 | { | 807 | { |
798 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 808 | /* TODO:hacker: if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); */ |
799 | return mToolTipGroup; | 809 | return mToolTipGroup; |
800 | } | 810 | } |
801 | 811 | ||
802 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 812 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
803 | { | 813 | { |
804 | #ifndef KORG_NODND | 814 | #ifndef KORG_NODND |
805 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 815 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
806 | !QTextDrag::canDecode( e ) ) { | 816 | !Q3TextDrag::canDecode( e ) ) { |
807 | e->ignore(); | 817 | e->ignore(); |
808 | return; | 818 | return; |
809 | } | 819 | } |
810 | e->accept(); | 820 | e->accept(); |
811 | #endif | 821 | #endif |
812 | } | 822 | } |
813 | 823 | ||
814 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 824 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
815 | { | 825 | { |
816 | #ifndef KORG_NODND | 826 | #ifndef KORG_NODND |
817 | QString text; | 827 | QString text; |
818 | if(QTextDrag::decode(e,text)) | 828 | if(Q3TextDrag::decode(e,text)) |
819 | { | 829 | { |
820 | kdDebug() << "Dropped : " << text << endl; | 830 | kdDebug() << "Dropped : " << text << endl; |
821 | QStringList emails = QStringList::split(",",text); | 831 | QStringList emails = QStringList::split(",",text); |
822 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 832 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
823 | kdDebug() << " Email: " << (*it) << endl; | 833 | kdDebug() << " Email: " << (*it) << endl; |
824 | int pos = (*it).find("<"); | 834 | int pos = (*it).find("<"); |
825 | QString name = (*it).left(pos); | 835 | QString name = (*it).left(pos); |
826 | QString email = (*it).mid(pos); | 836 | QString email = (*it).mid(pos); |
827 | if (!email.isEmpty()) { | 837 | if (!email.isEmpty()) { |
828 | mIncidence->addAttendee(new Attendee(name,email)); | 838 | mIncidence->addAttendee(new Attendee(name,email)); |
829 | } | 839 | } |
830 | } | 840 | } |
831 | } | 841 | } |
832 | #endif | 842 | #endif |
833 | } | 843 | } |
834 | 844 | ||
835 | 845 | ||
836 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 846 | Q3PtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
837 | { | 847 | { |
838 | return mConflictItems; | 848 | return mConflictItems; |
839 | } | 849 | } |
840 | 850 | ||
841 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 851 | void KOAgendaItem::setConflictItems(Q3PtrList<KOAgendaItem> ci) |
842 | { | 852 | { |
843 | mConflictItems = ci; | 853 | mConflictItems = ci; |
844 | KOAgendaItem *item; | 854 | KOAgendaItem *item; |
845 | for ( item=mConflictItems.first(); item != 0; | 855 | for ( item=mConflictItems.first(); item != 0; |
846 | item=mConflictItems.next() ) { | 856 | item=mConflictItems.next() ) { |
847 | item->addConflictItem(this); | 857 | item->addConflictItem(this); |
848 | } | 858 | } |
849 | } | 859 | } |
850 | 860 | ||
851 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 861 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
852 | { | 862 | { |
853 | if (mConflictItems.find(ci)<0) | 863 | if (mConflictItems.find(ci)<0) |
854 | mConflictItems.append(ci); | 864 | mConflictItems.append(ci); |
855 | } | 865 | } |
856 | 866 | ||
857 | bool KOAgendaItem::checkLayout() | 867 | bool KOAgendaItem::checkLayout() |
858 | { | 868 | { |
859 | if ( !mConflictItems.count() ) | 869 | if ( !mConflictItems.count() ) |
860 | return true; | 870 | return true; |
861 | int max = 0; | 871 | int max = 0; |
862 | KOAgendaItem *item; | 872 | KOAgendaItem *item; |
863 | for ( item=mConflictItems.first(); item != 0; | 873 | for ( item=mConflictItems.first(); item != 0; |
864 | item=mConflictItems.next() ) { | 874 | item=mConflictItems.next() ) { |
865 | if ( item->subCells() > max ) | 875 | if ( item->subCells() > max ) |
866 | max = item->subCells(); | 876 | max = item->subCells(); |
867 | } | 877 | } |
868 | if ( max > subCells() ) { | 878 | if ( max > subCells() ) { |
869 | setSubCells( max ); | 879 | setSubCells( max ); |
870 | return false; | 880 | return false; |
871 | } | 881 | } |
872 | return true; | 882 | return true; |
873 | } | 883 | } |