author | zautrix <zautrix> | 2005-01-30 20:31:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-30 20:31:35 (UTC) |
commit | 15c5772f8a54750115f82aea34fea47e5842ff4f (patch) (unidiff) | |
tree | 13c31b5fd3d41058b65a392acf17ee3efd230f33 | |
parent | 23d345c877ae9de6a077af3705026d15bb04d1e3 (diff) | |
download | kdepimpi-15c5772f8a54750115f82aea34fea47e5842ff4f.zip kdepimpi-15c5772f8a54750115f82aea34fea47e5842ff4f.tar.gz kdepimpi-15c5772f8a54750115f82aea34fea47e5842ff4f.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagenda.cpp | 35 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 7 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 4 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 1 |
5 files changed, 29 insertions, 22 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0aef929..ffa2678 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,1998 +1,2003 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 66 | { |
67 | setLineWidth(0); | 67 | setLineWidth(0); |
68 | setMargin(0); | 68 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 72 | minutes->start(0, true); |
73 | 73 | ||
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | delete minutes; | 88 | delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | 154 | ||
155 | mTimeBox->raise(); | 155 | mTimeBox->raise(); |
156 | //mTimeBox->setAutoMask(true); | 156 | //mTimeBox->setAutoMask(true); |
157 | minutes->start(5000,true); | 157 | minutes->start(5000,true); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | 172 | ||
173 | mColumns = columns; | 173 | mColumns = columns; |
174 | mRows = rows; | 174 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 176 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 179 | #endif |
180 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
181 | init(); | 181 | init(); |
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
185 | Create an agenda widget with columns columns and one row. This is used for | 185 | Create an agenda widget with columns columns and one row. This is used for |
186 | all-day events. | 186 | all-day events. |
187 | */ | 187 | */ |
188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
189 | QScrollView(parent,name,f) | 189 | QScrollView(parent,name,f) |
190 | { | 190 | { |
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | mNewItemPopup = new QPopupMenu( this ); | 225 | mNewItemPopup = new QPopupMenu( this ); |
226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
227 | QString pathString = ""; | 227 | QString pathString = ""; |
228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
229 | if ( QApplication::desktop()->width() < 480 ) | 229 | if ( QApplication::desktop()->width() < 480 ) |
230 | pathString += "icons16/"; | 230 | pathString += "icons16/"; |
231 | } else | 231 | } else |
232 | pathString += "iconsmini/"; | 232 | pathString += "iconsmini/"; |
233 | 233 | ||
234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
236 | mNewItemPopup->insertSeparator ( ); | 236 | mNewItemPopup->insertSeparator ( ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
243 | #ifndef _WIN32_ | 243 | #ifndef _WIN32_ |
244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
245 | viewport()->setWFlags ( wflags); | 245 | viewport()->setWFlags ( wflags); |
246 | #endif | 246 | #endif |
247 | mGridSpacingX = 80; | 247 | mGridSpacingX = 80; |
248 | mResizeBorderWidth = 8; | 248 | mResizeBorderWidth = 8; |
249 | mScrollBorderWidth = 8; | 249 | mScrollBorderWidth = 8; |
250 | mScrollDelay = 30; | 250 | mScrollDelay = 30; |
251 | mScrollOffset = 10; | 251 | mScrollOffset = 10; |
252 | mPaintPixmap.resize( 20,20); | 252 | mPaintPixmap.resize( 20,20); |
253 | //enableClipper(true); | 253 | //enableClipper(true); |
254 | 254 | ||
255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
256 | // effect. Has to be fixed. | 256 | // effect. Has to be fixed. |
257 | setFocusPolicy(WheelFocus); | 257 | setFocusPolicy(WheelFocus); |
258 | 258 | ||
259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
262 | 262 | ||
263 | mStartCellX = 0; | 263 | mStartCellX = 0; |
264 | mStartCellY = 0; | 264 | mStartCellY = 0; |
265 | mCurrentCellX = 0; | 265 | mCurrentCellX = 0; |
266 | mCurrentCellY = 0; | 266 | mCurrentCellY = 0; |
267 | 267 | ||
268 | mSelectionCellX = 0; | 268 | mSelectionCellX = 0; |
269 | mSelectionYTop = 0; | 269 | mSelectionYTop = 0; |
270 | mSelectionHeight = 0; | 270 | mSelectionHeight = 0; |
271 | 271 | ||
272 | mOldLowerScrollValue = -1; | 272 | mOldLowerScrollValue = -1; |
273 | mOldUpperScrollValue = -1; | 273 | mOldUpperScrollValue = -1; |
274 | 274 | ||
275 | mClickedItem = 0; | 275 | mClickedItem = 0; |
276 | 276 | ||
277 | mActionItem = 0; | 277 | mActionItem = 0; |
278 | mActionType = NOP; | 278 | mActionType = NOP; |
279 | mItemMoved = false; | 279 | mItemMoved = false; |
280 | 280 | ||
281 | mSelectedItem = 0; | 281 | mSelectedItem = 0; |
282 | 282 | ||
283 | // mItems.setAutoDelete(true); | 283 | // mItems.setAutoDelete(true); |
284 | 284 | ||
285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
286 | 286 | ||
287 | viewport()->update(); | 287 | viewport()->update(); |
288 | 288 | ||
289 | setMinimumSize(30, 1); | 289 | setMinimumSize(30, 1); |
290 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 290 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
291 | 291 | ||
292 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 292 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
293 | // controlled in a way that the contents horizontally always fits. Then it is | 293 | // controlled in a way that the contents horizontally always fits. Then it is |
294 | // not necessary to turn off the scrollbar. | 294 | // not necessary to turn off the scrollbar. |
295 | setHScrollBarMode(AlwaysOff); | 295 | setHScrollBarMode(AlwaysOff); |
296 | if ( ! mAllDayMode ) | 296 | if ( ! mAllDayMode ) |
297 | setVScrollBarMode(AlwaysOn); | 297 | setVScrollBarMode(AlwaysOn); |
298 | else | 298 | else |
299 | setVScrollBarMode(AlwaysOff); | 299 | setVScrollBarMode(AlwaysOff); |
300 | 300 | ||
301 | setStartHour(KOPrefs::instance()->mDayBegins); | 301 | setStartHour(KOPrefs::instance()->mDayBegins); |
302 | 302 | ||
303 | calculateWorkingHours(); | 303 | calculateWorkingHours(); |
304 | 304 | ||
305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
306 | SLOT(checkScrollBoundaries(int))); | 306 | SLOT(checkScrollBoundaries(int))); |
307 | 307 | ||
308 | // Create the Marcus Bains line. | 308 | // Create the Marcus Bains line. |
309 | if(mAllDayMode) | 309 | if(mAllDayMode) |
310 | mMarcusBains = 0; | 310 | mMarcusBains = 0; |
311 | else { | 311 | else { |
312 | mMarcusBains = new MarcusBains(this); | 312 | mMarcusBains = new MarcusBains(this); |
313 | addChild(mMarcusBains); | 313 | addChild(mMarcusBains); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOAgenda::clear() | 317 | void KOAgenda::clear() |
318 | { | 318 | { |
319 | KOAgendaItem *item; | 319 | KOAgendaItem *item; |
320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
321 | mUnusedItems.append( item ); | 321 | mUnusedItems.append( item ); |
322 | //item->hide(); | 322 | //item->hide(); |
323 | } | 323 | } |
324 | mItems.clear(); | 324 | mItems.clear(); |
325 | mSelectedItem = 0; | 325 | mSelectedItem = 0; |
326 | clearSelection(); | 326 | clearSelection(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KOAgenda::clearSelection() | 329 | void KOAgenda::clearSelection() |
330 | { | 330 | { |
331 | mSelectionCellX = 0; | 331 | mSelectionCellX = 0; |
332 | mSelectionYTop = 0; | 332 | mSelectionYTop = 0; |
333 | mSelectionHeight = 0; | 333 | mSelectionHeight = 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | void KOAgenda::marcus_bains() | 336 | void KOAgenda::marcus_bains() |
337 | { | 337 | { |
338 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 338 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void KOAgenda::changeColumns(int columns) | 342 | void KOAgenda::changeColumns(int columns) |
343 | { | 343 | { |
344 | if (columns == 0) { | 344 | if (columns == 0) { |
345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | 348 | ||
349 | clear(); | 349 | clear(); |
350 | 350 | ||
351 | mColumns = columns; | 351 | mColumns = columns; |
352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | 352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); |
353 | // init(); | 353 | // init(); |
354 | // update(); | 354 | // update(); |
355 | //qDebug("KOAgenda::changeColumns "); | 355 | //qDebug("KOAgenda::changeColumns "); |
356 | computeSizes(); | 356 | computeSizes(); |
357 | // QResizeEvent event( size(), size() ); | 357 | // QResizeEvent event( size(), size() ); |
358 | 358 | ||
359 | //QApplication::sendEvent( this, &event ); | 359 | //QApplication::sendEvent( this, &event ); |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | This is the eventFilter function, which gets all events from the KOAgendaItems | 363 | This is the eventFilter function, which gets all events from the KOAgendaItems |
364 | contained in the agenda. It has to handle moving and resizing for all items. | 364 | contained in the agenda. It has to handle moving and resizing for all items. |
365 | */ | 365 | */ |
366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
367 | { | 367 | { |
368 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 368 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
369 | switch(event->type()) { | 369 | switch(event->type()) { |
370 | case QEvent::MouseButtonPress: | 370 | case QEvent::MouseButtonPress: |
371 | case QEvent::MouseButtonDblClick: | 371 | case QEvent::MouseButtonDblClick: |
372 | case QEvent::MouseButtonRelease: | 372 | case QEvent::MouseButtonRelease: |
373 | case QEvent::MouseMove: | 373 | case QEvent::MouseMove: |
374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
375 | 375 | ||
376 | case (QEvent::Leave): | 376 | case (QEvent::Leave): |
377 | if (!mActionItem) | 377 | if (!mActionItem) |
378 | setCursor(arrowCursor); | 378 | setCursor(arrowCursor); |
379 | return true; | 379 | return true; |
380 | 380 | ||
381 | default: | 381 | default: |
382 | return QScrollView::eventFilter(object,event); | 382 | return QScrollView::eventFilter(object,event); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
388 | { | 388 | { |
389 | //qDebug("KOAgenda::eventFilter_mous "); | 389 | //qDebug("KOAgenda::eventFilter_mous "); |
390 | QPoint viewportPos; | 390 | QPoint viewportPos; |
391 | if (object != viewport()) { | 391 | if (object != viewport()) { |
392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
393 | } else { | 393 | } else { |
394 | viewportPos = me->pos(); | 394 | viewportPos = me->pos(); |
395 | } | 395 | } |
396 | static int startX = 0; | 396 | static int startX = 0; |
397 | static int startY = 0; | 397 | static int startY = 0; |
398 | static bool block = true; | 398 | static bool block = true; |
399 | switch (me->type()) { | 399 | switch (me->type()) { |
400 | case QEvent::MouseButtonPress: | 400 | case QEvent::MouseButtonPress: |
401 | //qDebug("QEvent::MouseButtonPress: "); | 401 | //qDebug("QEvent::MouseButtonPress: "); |
402 | // kdDebug() << "koagenda: filtered button press" << endl; | 402 | // kdDebug() << "koagenda: filtered button press" << endl; |
403 | if (object != viewport()) { | 403 | if (object != viewport()) { |
404 | if (me->button() == RightButton) { | 404 | if (me->button() == RightButton) { |
405 | 405 | ||
406 | mClickedItem = (KOAgendaItem *)object; | 406 | mClickedItem = (KOAgendaItem *)object; |
407 | if (mClickedItem) { | 407 | if (mClickedItem) { |
408 | selectItem(mClickedItem); | 408 | selectItem(mClickedItem); |
409 | // emit showIncidencePopupSignal(mClickedItem->incidence()); | 409 | // emit showIncidencePopupSignal(mClickedItem->incidence()); |
410 | } | 410 | } |
411 | //mItemPopup->popup(QCursor::pos()); | 411 | //mItemPopup->popup(QCursor::pos()); |
412 | } else { | 412 | } else { |
413 | mActionItem = (KOAgendaItem *)object; | 413 | mActionItem = (KOAgendaItem *)object; |
414 | if (mActionItem) { | 414 | if (mActionItem) { |
415 | if ( mSelectionHeight > 0 ) { | 415 | if ( mSelectionHeight > 0 ) { |
416 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 416 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
417 | int selectionYTop = mSelectionYTop; | 417 | int selectionYTop = mSelectionYTop; |
418 | int gridSpacingX = mGridSpacingX; | 418 | int gridSpacingX = mGridSpacingX; |
419 | int selectionHeight = mSelectionHeight; | 419 | int selectionHeight = mSelectionHeight; |
420 | clearSelection(); | 420 | clearSelection(); |
421 | repaintContents( selectionCellX, selectionYTop, | 421 | repaintContents( selectionCellX, selectionYTop, |
422 | gridSpacingX, selectionHeight,false ); | 422 | gridSpacingX, selectionHeight,false ); |
423 | } | 423 | } |
424 | selectItem(mActionItem); | 424 | selectItem(mActionItem); |
425 | Incidence *incidence = mActionItem->incidence(); | 425 | Incidence *incidence = mActionItem->incidence(); |
426 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 426 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
427 | mActionItem = 0; | 427 | mActionItem = 0; |
428 | } else { | 428 | } else { |
429 | startItemAction(viewportPos); | 429 | startItemAction(viewportPos); |
430 | startX = viewportPos.x(); | 430 | startX = viewportPos.x(); |
431 | startY = viewportPos.y(); | 431 | startY = viewportPos.y(); |
432 | block = true; | 432 | block = true; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } | 435 | } |
436 | } else { | 436 | } else { |
437 | selectItem(0); | 437 | selectItem(0); |
438 | mActionItem = 0; | 438 | mActionItem = 0; |
439 | if (me->button() == RightButton ) { | 439 | if (me->button() == RightButton ) { |
440 | blockNewEvent = true; | 440 | blockNewEvent = true; |
441 | //qDebug("right "); | 441 | block = false; |
442 | int x,y; | ||
443 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
444 | int gx,gy; | ||
445 | contentsToGrid(x,y,gx,gy); | ||
446 | mStartCellX = gx; | ||
447 | mStartCellY = gy; | ||
448 | mCurrentCellX = gx; | ||
449 | mCurrentCellY = gy; | ||
450 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | ||
451 | |||
452 | } else { | 442 | } else { |
453 | blockNewEvent = false; | 443 | blockNewEvent = false; |
454 | setCursor(arrowCursor); | 444 | setCursor(arrowCursor); |
455 | startSelectAction(viewportPos); | 445 | startSelectAction(viewportPos); |
456 | } | 446 | } |
457 | } | 447 | } |
458 | break; | 448 | break; |
459 | 449 | ||
460 | case QEvent::MouseButtonRelease: | 450 | case QEvent::MouseButtonRelease: |
461 | //qDebug("QEvent::MouseButtonRelease: "); | 451 | //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); |
462 | if (me->button() == RightButton && block ) { | 452 | if (me->button() == RightButton && blockNewEvent && !block) { |
453 | int x,y; | ||
454 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
455 | int gx,gy; | ||
456 | contentsToGrid(x,y,gx,gy); | ||
457 | if ( mCurrentCellY < mStartCellY +1 ) { | ||
458 | //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); | ||
459 | mCurrentCellX = gx; | ||
460 | mCurrentCellY = gy; | ||
461 | mStartCellX = gx; | ||
462 | mStartCellY = gy; | ||
463 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | ||
464 | break; | ||
465 | } else { | ||
466 | blockNewEvent = false; | ||
467 | } | ||
468 | } else if (me->button() == RightButton && block ) { | ||
463 | if (object != viewport()) { | 469 | if (object != viewport()) { |
464 | mClickedItem = (KOAgendaItem *)object; | 470 | mClickedItem = (KOAgendaItem *)object; |
465 | if (mActionItem ) { | 471 | if (mActionItem ) { |
466 | endItemAction(); | 472 | endItemAction(); |
467 | } | 473 | } |
468 | if (mClickedItem) { | 474 | if (mClickedItem) { |
469 | selectItem(mClickedItem); | 475 | selectItem(mClickedItem); |
470 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 476 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
471 | } | 477 | } |
472 | } | 478 | } |
473 | break; | 479 | break; |
474 | } | 480 | } |
475 | block = true; | 481 | block = true; |
476 | if (mActionItem) { | 482 | if (mActionItem) { |
477 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 483 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
478 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 484 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
479 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 485 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
480 | mScrollUpTimer.stop(); | 486 | mScrollUpTimer.stop(); |
481 | mScrollDownTimer.stop(); | 487 | mScrollDownTimer.stop(); |
482 | mActionItem->resetMove(); | 488 | mActionItem->resetMove(); |
483 | placeSubCells( mActionItem ); | 489 | placeSubCells( mActionItem ); |
484 | // emit startDragSignal( mActionItem->incidence() ); | 490 | // emit startDragSignal( mActionItem->incidence() ); |
485 | setCursor( arrowCursor ); | 491 | setCursor( arrowCursor ); |
486 | mActionItem = 0; | 492 | mActionItem = 0; |
487 | mActionType = NOP; | 493 | mActionType = NOP; |
488 | mItemMoved = 0; | 494 | mItemMoved = 0; |
489 | return true; | 495 | return true; |
490 | } | 496 | } |
491 | endItemAction(); | 497 | endItemAction(); |
492 | } else if ( mActionType == SELECT ) { | 498 | } else if ( mActionType == SELECT ) { |
493 | if (me->button() == RightButton ) { | 499 | if (me->button() == RightButton ) { |
494 | |||
495 | } else { | 500 | } else { |
496 | endSelectAction( !blockNewEvent ); | 501 | endSelectAction( !blockNewEvent ); |
497 | } | 502 | } |
498 | } | 503 | } |
499 | break; | 504 | break; |
500 | 505 | ||
501 | case QEvent::MouseMove: | 506 | case QEvent::MouseMove: |
502 | if (object != viewport()) { | 507 | if (object != viewport()) { |
503 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 508 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
504 | //qDebug("moveItem %d ",moveItem ); | 509 | //qDebug("moveItem %d ",moveItem ); |
505 | if (!moveItem->incidence()->isReadOnly() /*&& | 510 | if (!moveItem->incidence()->isReadOnly() /*&& |
506 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) | 511 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) |
507 | if (!mActionItem) | 512 | if (!mActionItem) |
508 | setNoActionCursor(moveItem,viewportPos); | 513 | setNoActionCursor(moveItem,viewportPos); |
509 | else { | 514 | else { |
510 | if ( block ) { | 515 | if ( block ) { |
511 | int dX, dY; | 516 | int dX, dY; |
512 | dX = startX - viewportPos.x(); | 517 | dX = startX - viewportPos.x(); |
513 | if ( dX < 0 ) | 518 | if ( dX < 0 ) |
514 | dX = -dX; | 519 | dX = -dX; |
515 | dY = viewportPos.y() - startY; | 520 | dY = viewportPos.y() - startY; |
516 | if ( dY < 0 ) | 521 | if ( dY < 0 ) |
517 | dY = -dY; | 522 | dY = -dY; |
518 | int diff = 30; | 523 | int diff = 30; |
519 | if ( QApplication::desktop()->width() < 480 ) | 524 | if ( QApplication::desktop()->width() < 480 ) |
520 | diff = 15; | 525 | diff = 15; |
521 | // qDebug(" %d %d ",dX, dY ); | 526 | // qDebug(" %d %d ",dX, dY ); |
522 | if ( dX > diff || dY > diff ) { | 527 | if ( dX > diff || dY > diff ) { |
523 | block = false; | 528 | block = false; |
524 | } | 529 | } |
525 | } | 530 | } |
526 | if ( !block ) | 531 | if ( !block ) |
527 | performItemAction(viewportPos); | 532 | performItemAction(viewportPos); |
528 | } | 533 | } |
529 | } else { | 534 | } else { |
530 | if ( mActionType == SELECT ) { | 535 | if ( mActionType == SELECT ) { |
531 | performSelectAction( viewportPos ); | 536 | performSelectAction( viewportPos ); |
532 | } | 537 | } |
533 | } | 538 | } |
534 | break; | 539 | break; |
535 | 540 | ||
536 | case QEvent::MouseButtonDblClick: | 541 | case QEvent::MouseButtonDblClick: |
537 | if (object == viewport()) { | 542 | if (object == viewport()) { |
538 | selectItem(0); | 543 | selectItem(0); |
539 | int x,y; | 544 | int x,y; |
540 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 545 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
541 | int gx,gy; | 546 | int gx,gy; |
542 | contentsToGrid(x,y,gx,gy); | 547 | contentsToGrid(x,y,gx,gy); |
543 | emit newEventSignal(gx,gy); | 548 | emit newEventSignal(gx,gy); |
544 | } else { | 549 | } else { |
545 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 550 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
546 | selectItem(doubleClickedItem); | 551 | selectItem(doubleClickedItem); |
547 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 552 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
548 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 553 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
549 | else | 554 | else |
550 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 555 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
551 | } | 556 | } |
552 | break; | 557 | break; |
553 | 558 | ||
554 | default: | 559 | default: |
555 | break; | 560 | break; |
556 | } | 561 | } |
557 | 562 | ||
558 | return true; | 563 | return true; |
559 | } | 564 | } |
560 | 565 | ||
561 | void KOAgenda::newItem( int item ) | 566 | void KOAgenda::newItem( int item ) |
562 | { | 567 | { |
563 | if ( item == 1 ) { //new event | 568 | if ( item == 1 ) { //new event |
564 | newEventSignal(mStartCellX ,mStartCellY ); | 569 | newEventSignal(mStartCellX ,mStartCellY ); |
565 | } else | 570 | } else |
566 | if ( item == 2 ) { //new event | 571 | if ( item == 2 ) { //new event |
567 | newTodoSignal(mStartCellX ,mStartCellY ); | 572 | newTodoSignal(mStartCellX ,mStartCellY ); |
568 | } else | 573 | } else |
569 | { | 574 | { |
570 | QDate day = mSelectedDates[mStartCellX]; | 575 | QDate day = mSelectedDates[mStartCellX]; |
571 | emit showDateView( item, day ); | 576 | emit showDateView( item, day ); |
572 | // 3Day view | 577 | // 3Day view |
573 | // 4Week view | 578 | // 4Week view |
574 | // 5Month view | 579 | // 5Month view |
575 | // 6Journal view | 580 | // 6Journal view |
576 | } | 581 | } |
577 | } | 582 | } |
578 | void KOAgenda::startSelectAction(QPoint viewportPos) | 583 | void KOAgenda::startSelectAction(QPoint viewportPos) |
579 | { | 584 | { |
580 | //emit newStartSelectSignal(); | 585 | //emit newStartSelectSignal(); |
581 | 586 | ||
582 | mActionType = SELECT; | 587 | mActionType = SELECT; |
583 | 588 | ||
584 | int x,y; | 589 | int x,y; |
585 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 590 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
586 | int gx,gy; | 591 | int gx,gy; |
587 | contentsToGrid(x,y,gx,gy); | 592 | contentsToGrid(x,y,gx,gy); |
588 | 593 | ||
589 | mStartCellX = gx; | 594 | mStartCellX = gx; |
590 | mStartCellY = gy; | 595 | mStartCellY = gy; |
591 | mCurrentCellX = gx; | 596 | mCurrentCellX = gx; |
592 | mCurrentCellY = gy; | 597 | mCurrentCellY = gy; |
593 | 598 | ||
594 | // Store coordinates of old selection | 599 | // Store coordinates of old selection |
595 | int selectionX = mSelectionCellX * mGridSpacingX; | 600 | int selectionX = mSelectionCellX * mGridSpacingX; |
596 | int selectionYTop = mSelectionYTop; | 601 | int selectionYTop = mSelectionYTop; |
597 | int selectionHeight = mSelectionHeight; | 602 | int selectionHeight = mSelectionHeight; |
598 | 603 | ||
599 | // Store new selection | 604 | // Store new selection |
600 | mSelectionCellX = gx; | 605 | mSelectionCellX = gx; |
601 | mSelectionYTop = gy * mGridSpacingY; | 606 | mSelectionYTop = gy * mGridSpacingY; |
602 | mSelectionHeight = mGridSpacingY; | 607 | mSelectionHeight = mGridSpacingY; |
603 | 608 | ||
604 | // Clear old selection | 609 | // Clear old selection |
605 | repaintContents( selectionX, selectionYTop, | 610 | repaintContents( selectionX, selectionYTop, |
606 | mGridSpacingX, selectionHeight,false ); | 611 | mGridSpacingX, selectionHeight,false ); |
607 | 612 | ||
608 | // Paint new selection | 613 | // Paint new selection |
609 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 614 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
610 | // mGridSpacingX, mSelectionHeight ); | 615 | // mGridSpacingX, mSelectionHeight ); |
611 | } | 616 | } |
612 | 617 | ||
613 | void KOAgenda::performSelectAction(QPoint viewportPos) | 618 | void KOAgenda::performSelectAction(QPoint viewportPos) |
614 | { | 619 | { |
615 | int x,y; | 620 | int x,y; |
616 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 621 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
617 | int gx,gy; | 622 | int gx,gy; |
618 | contentsToGrid(x,y,gx,gy); | 623 | contentsToGrid(x,y,gx,gy); |
619 | 624 | ||
620 | QPoint clipperPos = clipper()-> | 625 | QPoint clipperPos = clipper()-> |
621 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 626 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
622 | 627 | ||
623 | // Scroll if cursor was moved to upper or lower end of agenda. | 628 | // Scroll if cursor was moved to upper or lower end of agenda. |
624 | if (clipperPos.y() < mScrollBorderWidth) { | 629 | if (clipperPos.y() < mScrollBorderWidth) { |
625 | mScrollUpTimer.start(mScrollDelay); | 630 | mScrollUpTimer.start(mScrollDelay); |
626 | } else if (visibleHeight() - clipperPos.y() < | 631 | } else if (visibleHeight() - clipperPos.y() < |
627 | mScrollBorderWidth) { | 632 | mScrollBorderWidth) { |
628 | mScrollDownTimer.start(mScrollDelay); | 633 | mScrollDownTimer.start(mScrollDelay); |
629 | } else { | 634 | } else { |
630 | mScrollUpTimer.stop(); | 635 | mScrollUpTimer.stop(); |
631 | mScrollDownTimer.stop(); | 636 | mScrollDownTimer.stop(); |
632 | } | 637 | } |
633 | 638 | ||
634 | if ( gy > mCurrentCellY ) { | 639 | if ( gy > mCurrentCellY ) { |
635 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 640 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
636 | 641 | ||
637 | #if 0 | 642 | #if 0 |
638 | // FIXME: Repaint only the newly selected region | 643 | // FIXME: Repaint only the newly selected region |
639 | repaintContents( mSelectionCellX * mGridSpacingX, | 644 | repaintContents( mSelectionCellX * mGridSpacingX, |
640 | mCurrentCellY + mGridSpacingY, | 645 | mCurrentCellY + mGridSpacingY, |
641 | mGridSpacingX, | 646 | mGridSpacingX, |
642 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 647 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
643 | #else | 648 | #else |
644 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 649 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
645 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 650 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
646 | mGridSpacingX, mSelectionYTop, | 651 | mGridSpacingX, mSelectionYTop, |
647 | mGridSpacingX, mSelectionHeight , false); | 652 | mGridSpacingX, mSelectionHeight , false); |
648 | #endif | 653 | #endif |
649 | 654 | ||
650 | mCurrentCellY = gy; | 655 | mCurrentCellY = gy; |
651 | } else if ( gy < mCurrentCellY ) { | 656 | } else if ( gy < mCurrentCellY ) { |
652 | if ( gy >= mStartCellY ) { | 657 | if ( gy >= mStartCellY ) { |
653 | int selectionHeight = mSelectionHeight; | 658 | int selectionHeight = mSelectionHeight; |
654 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 659 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
655 | 660 | ||
656 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 661 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
657 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 662 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
658 | mGridSpacingX, mSelectionYTop, | 663 | mGridSpacingX, mSelectionYTop, |
659 | mGridSpacingX, selectionHeight,false ); | 664 | mGridSpacingX, selectionHeight,false ); |
660 | 665 | ||
661 | mCurrentCellY = gy; | 666 | mCurrentCellY = gy; |
662 | } else { | 667 | } else { |
663 | } | 668 | } |
664 | } | 669 | } |
665 | } | 670 | } |
666 | 671 | ||
667 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 672 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
668 | { | 673 | { |
669 | mActionType = NOP; | 674 | mActionType = NOP; |
670 | mScrollUpTimer.stop(); | 675 | mScrollUpTimer.stop(); |
671 | mScrollDownTimer.stop(); | 676 | mScrollDownTimer.stop(); |
672 | 677 | ||
673 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 678 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
674 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) | 679 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) |
675 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 680 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
676 | } | 681 | } |
677 | 682 | ||
678 | void KOAgenda::startItemAction(QPoint viewportPos) | 683 | void KOAgenda::startItemAction(QPoint viewportPos) |
679 | { | 684 | { |
680 | int x,y; | 685 | int x,y; |
681 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 686 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
682 | int gx,gy; | 687 | int gx,gy; |
683 | contentsToGrid(x,y,gx,gy); | 688 | contentsToGrid(x,y,gx,gy); |
684 | 689 | ||
685 | mStartCellX = gx; | 690 | mStartCellX = gx; |
686 | mStartCellY = gy; | 691 | mStartCellY = gy; |
687 | mCurrentCellX = gx; | 692 | mCurrentCellX = gx; |
688 | mCurrentCellY = gy; | 693 | mCurrentCellY = gy; |
689 | 694 | ||
690 | if (mAllDayMode) { | 695 | if (mAllDayMode) { |
691 | int gridDistanceX = (x - gx * mGridSpacingX); | 696 | int gridDistanceX = (x - gx * mGridSpacingX); |
692 | if (gridDistanceX < mResizeBorderWidth && | 697 | if (gridDistanceX < mResizeBorderWidth && |
693 | mActionItem->cellX() == mCurrentCellX) { | 698 | mActionItem->cellX() == mCurrentCellX) { |
694 | mActionType = RESIZELEFT; | 699 | mActionType = RESIZELEFT; |
695 | setCursor(sizeHorCursor); | 700 | setCursor(sizeHorCursor); |
696 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 701 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
697 | mActionItem->cellXWidth() == mCurrentCellX) { | 702 | mActionItem->cellXWidth() == mCurrentCellX) { |
698 | mActionType = RESIZERIGHT; | 703 | mActionType = RESIZERIGHT; |
699 | setCursor(sizeHorCursor); | 704 | setCursor(sizeHorCursor); |
700 | } else { | 705 | } else { |
701 | mActionType = MOVE; | 706 | mActionType = MOVE; |
702 | mActionItem->startMove(); | 707 | mActionItem->startMove(); |
703 | setCursor(sizeAllCursor); | 708 | setCursor(sizeAllCursor); |
704 | } | 709 | } |
705 | } else { | 710 | } else { |
706 | int gridDistanceY = (y - gy * mGridSpacingY); | 711 | int gridDistanceY = (y - gy * mGridSpacingY); |
707 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 712 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
708 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 713 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
709 | mActionItem->cellYTop() == mCurrentCellY && | 714 | mActionItem->cellYTop() == mCurrentCellY && |
710 | !mActionItem->firstMultiItem()) { | 715 | !mActionItem->firstMultiItem()) { |
711 | mActionType = RESIZETOP; | 716 | mActionType = RESIZETOP; |
712 | setCursor(sizeVerCursor); | 717 | setCursor(sizeVerCursor); |
713 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 718 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
714 | mActionItem->cellYBottom() == mCurrentCellY && | 719 | mActionItem->cellYBottom() == mCurrentCellY && |
715 | !mActionItem->lastMultiItem()) { | 720 | !mActionItem->lastMultiItem()) { |
716 | mActionType = RESIZEBOTTOM; | 721 | mActionType = RESIZEBOTTOM; |
717 | setCursor(sizeVerCursor); | 722 | setCursor(sizeVerCursor); |
718 | } else { | 723 | } else { |
719 | mActionType = MOVE; | 724 | mActionType = MOVE; |
720 | mActionItem->startMove(); | 725 | mActionItem->startMove(); |
721 | setCursor(sizeAllCursor); | 726 | setCursor(sizeAllCursor); |
722 | } | 727 | } |
723 | } | 728 | } |
724 | } | 729 | } |
725 | 730 | ||
726 | void KOAgenda::performItemAction(QPoint viewportPos) | 731 | void KOAgenda::performItemAction(QPoint viewportPos) |
727 | { | 732 | { |
728 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 733 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
729 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 734 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
730 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 735 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
731 | // point = clipper()->mapFromGlobal(point); | 736 | // point = clipper()->mapFromGlobal(point); |
732 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 737 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
733 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 738 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
734 | int x,y; | 739 | int x,y; |
735 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 740 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
736 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 741 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
737 | int gx,gy; | 742 | int gx,gy; |
738 | contentsToGrid(x,y,gx,gy); | 743 | contentsToGrid(x,y,gx,gy); |
739 | QPoint clipperPos = clipper()-> | 744 | QPoint clipperPos = clipper()-> |
740 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 745 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
741 | 746 | ||
742 | // Cursor left active agenda area. | 747 | // Cursor left active agenda area. |
743 | // This starts a drag. | 748 | // This starts a drag. |
744 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 749 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
745 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 750 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
746 | if ( mActionType == MOVE ) { | 751 | if ( mActionType == MOVE ) { |
747 | mScrollUpTimer.stop(); | 752 | mScrollUpTimer.stop(); |
748 | mScrollDownTimer.stop(); | 753 | mScrollDownTimer.stop(); |
749 | mActionItem->resetMove(); | 754 | mActionItem->resetMove(); |
750 | placeSubCells( mActionItem ); | 755 | placeSubCells( mActionItem ); |
751 | // emit startDragSignal( mActionItem->incidence() ); | 756 | // emit startDragSignal( mActionItem->incidence() ); |
752 | setCursor( arrowCursor ); | 757 | setCursor( arrowCursor ); |
753 | mActionItem = 0; | 758 | mActionItem = 0; |
754 | mActionType = NOP; | 759 | mActionType = NOP; |
755 | mItemMoved = 0; | 760 | mItemMoved = 0; |
756 | return; | 761 | return; |
757 | } | 762 | } |
758 | } else { | 763 | } else { |
759 | switch ( mActionType ) { | 764 | switch ( mActionType ) { |
760 | case MOVE: | 765 | case MOVE: |
761 | setCursor( sizeAllCursor ); | 766 | setCursor( sizeAllCursor ); |
762 | break; | 767 | break; |
763 | case RESIZETOP: | 768 | case RESIZETOP: |
764 | case RESIZEBOTTOM: | 769 | case RESIZEBOTTOM: |
765 | setCursor( sizeVerCursor ); | 770 | setCursor( sizeVerCursor ); |
766 | break; | 771 | break; |
767 | case RESIZELEFT: | 772 | case RESIZELEFT: |
768 | case RESIZERIGHT: | 773 | case RESIZERIGHT: |
769 | setCursor( sizeHorCursor ); | 774 | setCursor( sizeHorCursor ); |
770 | break; | 775 | break; |
771 | default: | 776 | default: |
772 | setCursor( arrowCursor ); | 777 | setCursor( arrowCursor ); |
773 | } | 778 | } |
774 | } | 779 | } |
775 | 780 | ||
776 | // Scroll if item was moved to upper or lower end of agenda. | 781 | // Scroll if item was moved to upper or lower end of agenda. |
777 | if (clipperPos.y() < mScrollBorderWidth) { | 782 | if (clipperPos.y() < mScrollBorderWidth) { |
778 | mScrollUpTimer.start(mScrollDelay); | 783 | mScrollUpTimer.start(mScrollDelay); |
779 | } else if (visibleHeight() - clipperPos.y() < | 784 | } else if (visibleHeight() - clipperPos.y() < |
780 | mScrollBorderWidth) { | 785 | mScrollBorderWidth) { |
781 | mScrollDownTimer.start(mScrollDelay); | 786 | mScrollDownTimer.start(mScrollDelay); |
782 | } else { | 787 | } else { |
783 | mScrollUpTimer.stop(); | 788 | mScrollUpTimer.stop(); |
784 | mScrollDownTimer.stop(); | 789 | mScrollDownTimer.stop(); |
785 | } | 790 | } |
786 | 791 | ||
787 | // Move or resize item if necessary | 792 | // Move or resize item if necessary |
788 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 793 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
789 | mItemMoved = true; | 794 | mItemMoved = true; |
790 | mActionItem->raise(); | 795 | mActionItem->raise(); |
791 | if (mActionType == MOVE) { | 796 | if (mActionType == MOVE) { |
792 | // Move all items belonging to a multi item | 797 | // Move all items belonging to a multi item |
793 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 798 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
794 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 799 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
795 | if (!moveItem) moveItem = mActionItem; | 800 | if (!moveItem) moveItem = mActionItem; |
796 | while (moveItem) { | 801 | while (moveItem) { |
797 | int dy; | 802 | int dy; |
798 | if (isMultiItem) dy = 0; | 803 | if (isMultiItem) dy = 0; |
799 | else dy = gy - mCurrentCellY; | 804 | else dy = gy - mCurrentCellY; |
800 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 805 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
801 | int x,y; | 806 | int x,y; |
802 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 807 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
803 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 808 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
804 | mGridSpacingY * moveItem->cellHeight()); | 809 | mGridSpacingY * moveItem->cellHeight()); |
805 | moveChild(moveItem,x,y); | 810 | moveChild(moveItem,x,y); |
806 | moveItem = moveItem->nextMultiItem(); | 811 | moveItem = moveItem->nextMultiItem(); |
807 | } | 812 | } |
808 | } else if (mActionType == RESIZETOP) { | 813 | } else if (mActionType == RESIZETOP) { |
809 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 814 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
810 | mActionItem->expandTop(gy - mCurrentCellY); | 815 | mActionItem->expandTop(gy - mCurrentCellY); |
811 | mActionItem->resize(mActionItem->width(), | 816 | mActionItem->resize(mActionItem->width(), |
812 | mGridSpacingY * mActionItem->cellHeight()); | 817 | mGridSpacingY * mActionItem->cellHeight()); |
813 | int x,y; | 818 | int x,y; |
814 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 819 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
815 | //moveChild(mActionItem,childX(mActionItem),y); | 820 | //moveChild(mActionItem,childX(mActionItem),y); |
816 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 821 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
817 | } | 822 | } |
818 | } else if (mActionType == RESIZEBOTTOM) { | 823 | } else if (mActionType == RESIZEBOTTOM) { |
819 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 824 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
820 | mActionItem->expandBottom(gy - mCurrentCellY); | 825 | mActionItem->expandBottom(gy - mCurrentCellY); |
821 | mActionItem->resize(mActionItem->width(), | 826 | mActionItem->resize(mActionItem->width(), |
822 | mGridSpacingY * mActionItem->cellHeight()); | 827 | mGridSpacingY * mActionItem->cellHeight()); |
823 | } | 828 | } |
824 | } else if (mActionType == RESIZELEFT) { | 829 | } else if (mActionType == RESIZELEFT) { |
825 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 830 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
826 | mActionItem->expandLeft(gx - mCurrentCellX); | 831 | mActionItem->expandLeft(gx - mCurrentCellX); |
827 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 832 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
828 | mActionItem->height()); | 833 | mActionItem->height()); |
829 | int x,y; | 834 | int x,y; |
830 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 835 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
831 | moveChild(mActionItem,x,childY(mActionItem)); | 836 | moveChild(mActionItem,x,childY(mActionItem)); |
832 | } | 837 | } |
833 | } else if (mActionType == RESIZERIGHT) { | 838 | } else if (mActionType == RESIZERIGHT) { |
834 | if (mCurrentCellX >= mActionItem->cellX()) { | 839 | if (mCurrentCellX >= mActionItem->cellX()) { |
835 | mActionItem->expandRight(gx - mCurrentCellX); | 840 | mActionItem->expandRight(gx - mCurrentCellX); |
836 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 841 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
837 | mActionItem->height()); | 842 | mActionItem->height()); |
838 | } | 843 | } |
839 | } | 844 | } |
840 | mCurrentCellX = gx; | 845 | mCurrentCellX = gx; |
841 | mCurrentCellY = gy; | 846 | mCurrentCellY = gy; |
842 | } | 847 | } |
843 | } | 848 | } |
844 | 849 | ||
845 | void KOAgenda::endItemAction() | 850 | void KOAgenda::endItemAction() |
846 | { | 851 | { |
847 | 852 | ||
848 | if ( mItemMoved ) { | 853 | if ( mItemMoved ) { |
849 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 854 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
850 | if ( !placeItem ) { | 855 | if ( !placeItem ) { |
851 | placeItem = mActionItem; | 856 | placeItem = mActionItem; |
852 | } | 857 | } |
853 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 858 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
854 | Incidence* oldInc = placeItem->incidence(); | 859 | Incidence* oldInc = placeItem->incidence(); |
855 | placeItem->recreateIncidence(); | 860 | placeItem->recreateIncidence(); |
856 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 861 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
857 | } | 862 | } |
858 | int type = mActionType; | 863 | int type = mActionType; |
859 | if ( mAllDayMode ) | 864 | if ( mAllDayMode ) |
860 | type = -1; | 865 | type = -1; |
861 | KOAgendaItem *modifiedItem = placeItem; | 866 | KOAgendaItem *modifiedItem = placeItem; |
862 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 867 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
863 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 868 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
864 | KOAgendaItem *item; | 869 | KOAgendaItem *item; |
865 | 870 | ||
866 | if ( placeItem->incidence()->type() == "Todo" ) { | 871 | if ( placeItem->incidence()->type() == "Todo" ) { |
867 | mSelectedItem = 0; | 872 | mSelectedItem = 0; |
868 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 873 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
869 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 874 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
870 | emit itemModified( modifiedItem, mActionType ); | 875 | emit itemModified( modifiedItem, mActionType ); |
871 | } | 876 | } |
872 | else { | 877 | else { |
873 | #if 0 | 878 | #if 0 |
874 | for ( item=oldconflictItems.first(); item != 0; | 879 | for ( item=oldconflictItems.first(); item != 0; |
875 | item=oldconflictItems.next() ) { | 880 | item=oldconflictItems.next() ) { |
876 | placeSubCells(item); | 881 | placeSubCells(item); |
877 | } | 882 | } |
878 | while ( placeItem ) { | 883 | while ( placeItem ) { |
879 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 884 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
880 | placeSubCells( placeItem ); | 885 | placeSubCells( placeItem ); |
881 | placeItem = placeItem->nextMultiItem(); | 886 | placeItem = placeItem->nextMultiItem(); |
882 | } | 887 | } |
883 | #endif | 888 | #endif |
884 | 889 | ||
885 | globalFlagBlockAgendaItemPaint = 1; | 890 | globalFlagBlockAgendaItemPaint = 1; |
886 | for ( item=oldconflictItems.first(); item != 0; | 891 | for ( item=oldconflictItems.first(); item != 0; |
887 | item=oldconflictItems.next() ) { | 892 | item=oldconflictItems.next() ) { |
888 | placeSubCells(item); | 893 | placeSubCells(item); |
889 | } | 894 | } |
890 | while ( placeItem ) { | 895 | while ( placeItem ) { |
891 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 896 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
892 | oldconflictItems = placeItem->conflictItems(); | 897 | oldconflictItems = placeItem->conflictItems(); |
893 | for ( item=oldconflictItems.first(); item != 0; | 898 | for ( item=oldconflictItems.first(); item != 0; |
894 | item=oldconflictItems.next() ) { | 899 | item=oldconflictItems.next() ) { |
895 | placeSubCells(item); | 900 | placeSubCells(item); |
896 | } | 901 | } |
897 | placeSubCells( placeItem ); | 902 | placeSubCells( placeItem ); |
898 | placeItem = placeItem->nextMultiItem(); | 903 | placeItem = placeItem->nextMultiItem(); |
899 | } | 904 | } |
900 | globalFlagBlockAgendaItemPaint = 0; | 905 | globalFlagBlockAgendaItemPaint = 0; |
901 | for ( item=oldconflictItems.first(); item != 0; | 906 | for ( item=oldconflictItems.first(); item != 0; |
902 | item=oldconflictItems.next() ) { | 907 | item=oldconflictItems.next() ) { |
903 | globalFlagBlockAgendaItemUpdate = 0; | 908 | globalFlagBlockAgendaItemUpdate = 0; |
904 | item->repaintMe(); | 909 | item->repaintMe(); |
905 | globalFlagBlockAgendaItemUpdate = 1; | 910 | globalFlagBlockAgendaItemUpdate = 1; |
906 | item->repaint( false ); | 911 | item->repaint( false ); |
907 | } | 912 | } |
908 | placeItem = modifiedItem; | 913 | placeItem = modifiedItem; |
909 | 914 | ||
910 | while ( placeItem ) { | 915 | while ( placeItem ) { |
911 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 916 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
912 | globalFlagBlockAgendaItemUpdate = 0; | 917 | globalFlagBlockAgendaItemUpdate = 0; |
913 | placeItem->repaintMe(); | 918 | placeItem->repaintMe(); |
914 | globalFlagBlockAgendaItemUpdate = 1; | 919 | globalFlagBlockAgendaItemUpdate = 1; |
915 | placeItem->repaint(false); | 920 | placeItem->repaint(false); |
916 | placeItem = placeItem->nextMultiItem(); | 921 | placeItem = placeItem->nextMultiItem(); |
917 | } | 922 | } |
918 | emit itemModified( modifiedItem, mActionType ); | 923 | emit itemModified( modifiedItem, mActionType ); |
919 | 924 | ||
920 | 925 | ||
921 | placeItem = modifiedItem; | 926 | placeItem = modifiedItem; |
922 | while ( placeItem ) { | 927 | while ( placeItem ) { |
923 | oldconflictItems = placeItem->conflictItems(); | 928 | oldconflictItems = placeItem->conflictItems(); |
924 | for ( item=oldconflictItems.first(); item != 0; | 929 | for ( item=oldconflictItems.first(); item != 0; |
925 | item=oldconflictItems.next() ) { | 930 | item=oldconflictItems.next() ) { |
926 | placeSubCells(item); | 931 | placeSubCells(item); |
927 | } | 932 | } |
928 | placeSubCells( placeItem ); | 933 | placeSubCells( placeItem ); |
929 | placeItem = placeItem->nextMultiItem(); | 934 | placeItem = placeItem->nextMultiItem(); |
930 | 935 | ||
931 | } | 936 | } |
932 | placeItem = modifiedItem; | 937 | placeItem = modifiedItem; |
933 | while ( placeItem ) { | 938 | while ( placeItem ) { |
934 | oldconflictItems = placeItem->conflictItems(); | 939 | oldconflictItems = placeItem->conflictItems(); |
935 | for ( item=oldconflictItems.first(); item != 0; | 940 | for ( item=oldconflictItems.first(); item != 0; |
936 | item=oldconflictItems.next() ) { | 941 | item=oldconflictItems.next() ) { |
937 | globalFlagBlockAgendaItemUpdate = 0; | 942 | globalFlagBlockAgendaItemUpdate = 0; |
938 | item->repaintMe(); | 943 | item->repaintMe(); |
939 | globalFlagBlockAgendaItemUpdate = 1; | 944 | globalFlagBlockAgendaItemUpdate = 1; |
940 | item->repaint(false); | 945 | item->repaint(false); |
941 | } | 946 | } |
942 | placeItem = placeItem->nextMultiItem(); | 947 | placeItem = placeItem->nextMultiItem(); |
943 | } | 948 | } |
944 | /* | 949 | /* |
945 | 950 | ||
946 | oldconflictItems = modifiedItem->conflictItems(); | 951 | oldconflictItems = modifiedItem->conflictItems(); |
947 | for ( item=oldconflictItems.first(); item != 0; | 952 | for ( item=oldconflictItems.first(); item != 0; |
948 | item=oldconflictItems.next() ) { | 953 | item=oldconflictItems.next() ) { |
949 | globalFlagBlockAgendaItemUpdate = 0; | 954 | globalFlagBlockAgendaItemUpdate = 0; |
950 | item->paintMe(false); | 955 | item->paintMe(false); |
951 | globalFlagBlockAgendaItemUpdate = 1; | 956 | globalFlagBlockAgendaItemUpdate = 1; |
952 | item->repaint(false); | 957 | item->repaint(false); |
953 | } | 958 | } |
954 | */ | 959 | */ |
955 | 960 | ||
956 | 961 | ||
957 | } | 962 | } |
958 | 963 | ||
959 | } | 964 | } |
960 | 965 | ||
961 | mScrollUpTimer.stop(); | 966 | mScrollUpTimer.stop(); |
962 | mScrollDownTimer.stop(); | 967 | mScrollDownTimer.stop(); |
963 | setCursor( arrowCursor ); | 968 | setCursor( arrowCursor ); |
964 | mActionItem = 0; | 969 | mActionItem = 0; |
965 | mActionType = NOP; | 970 | mActionType = NOP; |
966 | mItemMoved = 0; | 971 | mItemMoved = 0; |
967 | 972 | ||
968 | } | 973 | } |
969 | 974 | ||
970 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 975 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
971 | { | 976 | { |
972 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 977 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
973 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 978 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
974 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 979 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
975 | // point = clipper()->mapFromGlobal(point); | 980 | // point = clipper()->mapFromGlobal(point); |
976 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 981 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
977 | 982 | ||
978 | int x,y; | 983 | int x,y; |
979 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 984 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
980 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 985 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
981 | int gx,gy; | 986 | int gx,gy; |
982 | contentsToGrid(x,y,gx,gy); | 987 | contentsToGrid(x,y,gx,gy); |
983 | 988 | ||
984 | // Change cursor to resize cursor if appropriate | 989 | // Change cursor to resize cursor if appropriate |
985 | if (mAllDayMode) { | 990 | if (mAllDayMode) { |
986 | int gridDistanceX = (x - gx * mGridSpacingX); | 991 | int gridDistanceX = (x - gx * mGridSpacingX); |
987 | if (gridDistanceX < mResizeBorderWidth && | 992 | if (gridDistanceX < mResizeBorderWidth && |
988 | moveItem->cellX() == gx) { | 993 | moveItem->cellX() == gx) { |
989 | setCursor(sizeHorCursor); | 994 | setCursor(sizeHorCursor); |
990 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 995 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
991 | moveItem->cellXWidth() == gx) { | 996 | moveItem->cellXWidth() == gx) { |
992 | setCursor(sizeHorCursor); | 997 | setCursor(sizeHorCursor); |
993 | } else { | 998 | } else { |
994 | setCursor(arrowCursor); | 999 | setCursor(arrowCursor); |
995 | } | 1000 | } |
996 | } else { | 1001 | } else { |
997 | int gridDistanceY = (y - gy * mGridSpacingY); | 1002 | int gridDistanceY = (y - gy * mGridSpacingY); |
998 | if (gridDistanceY < mResizeBorderWidth && | 1003 | if (gridDistanceY < mResizeBorderWidth && |
999 | moveItem->cellYTop() == gy && | 1004 | moveItem->cellYTop() == gy && |
1000 | !moveItem->firstMultiItem()) { | 1005 | !moveItem->firstMultiItem()) { |
1001 | setCursor(sizeVerCursor); | 1006 | setCursor(sizeVerCursor); |
1002 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1007 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1003 | moveItem->cellYBottom() == gy && | 1008 | moveItem->cellYBottom() == gy && |
1004 | !moveItem->lastMultiItem()) { | 1009 | !moveItem->lastMultiItem()) { |
1005 | setCursor(sizeVerCursor); | 1010 | setCursor(sizeVerCursor); |
1006 | } else { | 1011 | } else { |
1007 | setCursor(arrowCursor); | 1012 | setCursor(arrowCursor); |
1008 | } | 1013 | } |
1009 | } | 1014 | } |
1010 | } | 1015 | } |
1011 | 1016 | ||
1012 | 1017 | ||
1013 | /* | 1018 | /* |
1014 | Place item in cell and take care that multiple items using the same cell do | 1019 | Place item in cell and take care that multiple items using the same cell do |
1015 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1020 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1016 | it can get in all cases. | 1021 | it can get in all cases. |
1017 | At the moment the method has a bug: When an item is placed only the sub cell | 1022 | At the moment the method has a bug: When an item is placed only the sub cell |
1018 | widths of the items are changed, which are within the Y region the item to | 1023 | widths of the items are changed, which are within the Y region the item to |
1019 | place spans. When the sub cell width change of one of this items affects a | 1024 | place spans. When the sub cell width change of one of this items affects a |
1020 | cell, where other items are, which do not overlap in Y with the item to place, | 1025 | cell, where other items are, which do not overlap in Y with the item to place, |
1021 | the display gets corrupted, although the corruption looks quite nice. | 1026 | the display gets corrupted, although the corruption looks quite nice. |
1022 | */ | 1027 | */ |
1023 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1028 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1024 | { | 1029 | { |
1025 | 1030 | ||
1026 | QPtrList<KOAgendaItem> conflictItems; | 1031 | QPtrList<KOAgendaItem> conflictItems; |
1027 | int maxSubCells = 0; | 1032 | int maxSubCells = 0; |
1028 | QIntDict<KOAgendaItem> subCellDict(5); | 1033 | QIntDict<KOAgendaItem> subCellDict(5); |
1029 | 1034 | ||
1030 | KOAgendaItem *item; | 1035 | KOAgendaItem *item; |
1031 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1036 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1032 | if (item != placeItem) { | 1037 | if (item != placeItem) { |
1033 | if (placeItem->cellX() <= item->cellXWidth() && | 1038 | if (placeItem->cellX() <= item->cellXWidth() && |
1034 | placeItem->cellXWidth() >= item->cellX()) { | 1039 | placeItem->cellXWidth() >= item->cellX()) { |
1035 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1040 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1036 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1041 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1037 | conflictItems.append(item); | 1042 | conflictItems.append(item); |
1038 | if (item->subCells() > maxSubCells) | 1043 | if (item->subCells() > maxSubCells) |
1039 | maxSubCells = item->subCells(); | 1044 | maxSubCells = item->subCells(); |
1040 | subCellDict.insert(item->subCell(),item); | 1045 | subCellDict.insert(item->subCell(),item); |
1041 | } | 1046 | } |
1042 | } | 1047 | } |
1043 | } | 1048 | } |
1044 | } | 1049 | } |
1045 | 1050 | ||
1046 | if (conflictItems.count() > 0) { | 1051 | if (conflictItems.count() > 0) { |
1047 | // Look for unused sub cell and insert item | 1052 | // Look for unused sub cell and insert item |
1048 | int i; | 1053 | int i; |
1049 | for(i=0;i<maxSubCells;++i) { | 1054 | for(i=0;i<maxSubCells;++i) { |
1050 | if (!subCellDict.find(i)) { | 1055 | if (!subCellDict.find(i)) { |
1051 | placeItem->setSubCell(i); | 1056 | placeItem->setSubCell(i); |
1052 | break; | 1057 | break; |
1053 | } | 1058 | } |
1054 | } | 1059 | } |
1055 | if (i == maxSubCells) { | 1060 | if (i == maxSubCells) { |
1056 | placeItem->setSubCell(maxSubCells); | 1061 | placeItem->setSubCell(maxSubCells); |
1057 | maxSubCells++; // add new item to number of sub cells | 1062 | maxSubCells++; // add new item to number of sub cells |
1058 | } | 1063 | } |
1059 | 1064 | ||
1060 | // Prepare for sub cell geometry adjustment | 1065 | // Prepare for sub cell geometry adjustment |
1061 | int newSubCellWidth; | 1066 | int newSubCellWidth; |
1062 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1067 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1063 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1068 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1064 | conflictItems.append(placeItem); | 1069 | conflictItems.append(placeItem); |
1065 | 1070 | ||
1066 | 1071 | ||
1067 | // Adjust sub cell geometry of all items | 1072 | // Adjust sub cell geometry of all items |
1068 | for ( item=conflictItems.first(); item != 0; | 1073 | for ( item=conflictItems.first(); item != 0; |
1069 | item=conflictItems.next() ) { | 1074 | item=conflictItems.next() ) { |
1070 | item->setSubCells(maxSubCells); | 1075 | item->setSubCells(maxSubCells); |
1071 | if (mAllDayMode) { | 1076 | if (mAllDayMode) { |
1072 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1077 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1073 | } else { | 1078 | } else { |
1074 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1079 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1075 | } | 1080 | } |
1076 | int x,y; | 1081 | int x,y; |
1077 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1082 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1078 | if (mAllDayMode) { | 1083 | if (mAllDayMode) { |
1079 | y += item->subCell() * newSubCellWidth; | 1084 | y += item->subCell() * newSubCellWidth; |
1080 | } else { | 1085 | } else { |
1081 | x += item->subCell() * newSubCellWidth; | 1086 | x += item->subCell() * newSubCellWidth; |
1082 | } | 1087 | } |
1083 | moveChild(item,x,y); | 1088 | moveChild(item,x,y); |
1084 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1089 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1085 | //item->updateItem(); | 1090 | //item->updateItem(); |
1086 | } | 1091 | } |
1087 | 1092 | ||
1088 | } else { | 1093 | } else { |
1089 | placeItem->setSubCell(0); | 1094 | placeItem->setSubCell(0); |
1090 | placeItem->setSubCells(1); | 1095 | placeItem->setSubCells(1); |
1091 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1096 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1092 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1097 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1093 | int x,y; | 1098 | int x,y; |
1094 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1099 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1095 | moveChild(placeItem,x,y); | 1100 | moveChild(placeItem,x,y); |
1096 | } | 1101 | } |
1097 | placeItem->setConflictItems(conflictItems); | 1102 | placeItem->setConflictItems(conflictItems); |
1098 | // for ( item=conflictItems.first(); item != 0; | 1103 | // for ( item=conflictItems.first(); item != 0; |
1099 | // item=conflictItems.next() ) { | 1104 | // item=conflictItems.next() ) { |
1100 | // //item->updateItem(); | 1105 | // //item->updateItem(); |
1101 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1106 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1102 | // } | 1107 | // } |
1103 | // placeItem->updateItem(); | 1108 | // placeItem->updateItem(); |
1104 | } | 1109 | } |
1105 | 1110 | ||
1106 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1111 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1107 | { | 1112 | { |
1108 | if ( globalFlagBlockAgenda ) | 1113 | if ( globalFlagBlockAgenda ) |
1109 | return; | 1114 | return; |
1110 | //qDebug("KOAgenda::drawContents "); | 1115 | //qDebug("KOAgenda::drawContents "); |
1111 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1116 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1112 | ;//drawContentsToPainter(); | 1117 | ;//drawContentsToPainter(); |
1113 | 1118 | ||
1114 | QPaintDevice* pd = p->device(); | 1119 | QPaintDevice* pd = p->device(); |
1115 | p->end(); | 1120 | p->end(); |
1116 | int vx, vy; | 1121 | int vx, vy; |
1117 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1122 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1118 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1123 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1119 | mSelectionCellX * mGridSpacingX; | 1124 | mSelectionCellX * mGridSpacingX; |
1120 | contentsToViewport ( cx, cy, vx,vy); | 1125 | contentsToViewport ( cx, cy, vx,vy); |
1121 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1126 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1122 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1127 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1123 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1128 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1124 | 1129 | ||
1125 | if ( mSelectionHeight > 0 ) { | 1130 | if ( mSelectionHeight > 0 ) { |
1126 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1131 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1127 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1132 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1128 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1133 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1129 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1134 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1130 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1135 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1131 | } | 1136 | } |
1132 | } | 1137 | } |
1133 | //qDebug("btbl "); | 1138 | //qDebug("btbl "); |
1134 | p->begin( pd ); | 1139 | p->begin( pd ); |
1135 | //qDebug("end "); | 1140 | //qDebug("end "); |
1136 | } | 1141 | } |
1137 | 1142 | ||
1138 | void KOAgenda::finishUpdate() | 1143 | void KOAgenda::finishUpdate() |
1139 | { | 1144 | { |
1140 | 1145 | ||
1141 | KOAgendaItem *item; | 1146 | KOAgendaItem *item; |
1142 | globalFlagBlockAgendaItemPaint = 1; | 1147 | globalFlagBlockAgendaItemPaint = 1; |
1143 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1148 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1144 | if ( !item->isVisible() ) | 1149 | if ( !item->isVisible() ) |
1145 | item->show(); | 1150 | item->show(); |
1146 | 1151 | ||
1147 | } | 1152 | } |
1148 | globalFlagBlockAgendaItemUpdate = 0; | 1153 | globalFlagBlockAgendaItemUpdate = 0; |
1149 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1154 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1150 | item->repaintMe( ); | 1155 | item->repaintMe( ); |
1151 | } | 1156 | } |
1152 | globalFlagBlockAgendaItemUpdate = 1; | 1157 | globalFlagBlockAgendaItemUpdate = 1; |
1153 | qApp->processEvents(); | 1158 | qApp->processEvents(); |
1154 | globalFlagBlockAgendaItemPaint = 0; | 1159 | globalFlagBlockAgendaItemPaint = 0; |
1155 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1160 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1156 | item->repaint( false ); | 1161 | item->repaint( false ); |
1157 | } | 1162 | } |
1158 | 1163 | ||
1159 | } | 1164 | } |
1160 | 1165 | ||
1161 | /* | 1166 | /* |
1162 | Draw grid in the background of the agenda. | 1167 | Draw grid in the background of the agenda. |
1163 | */ | 1168 | */ |
1164 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1169 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1165 | { | 1170 | { |
1166 | 1171 | ||
1167 | 1172 | ||
1168 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1173 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1169 | return; | 1174 | return; |
1170 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1175 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1171 | return; | 1176 | return; |
1172 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1177 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1173 | if ( ch < 1 ) | 1178 | if ( ch < 1 ) |
1174 | ch = 1; | 1179 | ch = 1; |
1175 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1180 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1176 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1181 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1177 | } | 1182 | } |
1178 | mCurPixWid = contentsWidth(); | 1183 | mCurPixWid = contentsWidth(); |
1179 | mCurPixHei = ch; | 1184 | mCurPixHei = ch; |
1180 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1185 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1181 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1186 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1182 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1187 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1183 | } | 1188 | } |
1184 | mPixPainter.begin( &mPaintPixmap) ; | 1189 | mPixPainter.begin( &mPaintPixmap) ; |
1185 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1190 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1186 | QPainter * p ; | 1191 | QPainter * p ; |
1187 | if (paint == 0) { | 1192 | if (paint == 0) { |
1188 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1193 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1189 | p = &mPixPainter; | 1194 | p = &mPixPainter; |
1190 | } | 1195 | } |
1191 | else | 1196 | else |
1192 | p = paint ; | 1197 | p = paint ; |
1193 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1198 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1194 | 1199 | ||
1195 | //--cx;++cw; | 1200 | //--cx;++cw; |
1196 | int lGridSpacingY = mGridSpacingY*2; | 1201 | int lGridSpacingY = mGridSpacingY*2; |
1197 | int selDay; | 1202 | int selDay; |
1198 | if ( !backgroundOnly ) | 1203 | if ( !backgroundOnly ) |
1199 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1204 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1200 | { | 1205 | { |
1201 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1206 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1202 | int x1 = cx; | 1207 | int x1 = cx; |
1203 | int y1 = 0; | 1208 | int y1 = 0; |
1204 | if (y1 < cy) y1 = cy; | 1209 | if (y1 < cy) y1 = cy; |
1205 | int x2 = cx+cw-1; | 1210 | int x2 = cx+cw-1; |
1206 | int y2 = contentsHeight(); | 1211 | int y2 = contentsHeight(); |
1207 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1212 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1208 | if (x2 >= x1 && y2 >= y1) { | 1213 | if (x2 >= x1 && y2 >= y1) { |
1209 | int gxStart = selDay; | 1214 | int gxStart = selDay; |
1210 | int gxEnd = gxStart ; | 1215 | int gxEnd = gxStart ; |
1211 | int xStart = KOGlobals::self()->reverseLayout() ? | 1216 | int xStart = KOGlobals::self()->reverseLayout() ? |
1212 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1217 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1213 | gxStart*mGridSpacingX; | 1218 | gxStart*mGridSpacingX; |
1214 | if (xStart < x1) xStart = x1; | 1219 | if (xStart < x1) xStart = x1; |
1215 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1220 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1216 | (mColumns - gxStart)*mGridSpacingX-1 : | 1221 | (mColumns - gxStart)*mGridSpacingX-1 : |
1217 | (gxStart+1)*mGridSpacingX-1; | 1222 | (gxStart+1)*mGridSpacingX-1; |
1218 | if (xEnd > x2) xEnd = x2; | 1223 | if (xEnd > x2) xEnd = x2; |
1219 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1224 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1220 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1225 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1221 | KOPrefs::instance()->mAgendaBgColor.light()); | 1226 | KOPrefs::instance()->mAgendaBgColor.light()); |
1222 | else | 1227 | else |
1223 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1228 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1224 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1229 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1225 | 1230 | ||
1226 | } | 1231 | } |
1227 | } | 1232 | } |
1228 | } | 1233 | } |
1229 | // Highlight working hours | 1234 | // Highlight working hours |
1230 | 1235 | ||
1231 | if ( !backgroundOnly ) | 1236 | if ( !backgroundOnly ) |
1232 | if (mWorkingHoursEnable) { | 1237 | if (mWorkingHoursEnable) { |
1233 | int x1 = cx; | 1238 | int x1 = cx; |
1234 | int y1 = mWorkingHoursYTop; | 1239 | int y1 = mWorkingHoursYTop; |
1235 | if (y1 < cy) y1 = cy; | 1240 | if (y1 < cy) y1 = cy; |
1236 | int x2 = cx+cw-1; | 1241 | int x2 = cx+cw-1; |
1237 | // int x2 = mGridSpacingX * 5 - 1; | 1242 | // int x2 = mGridSpacingX * 5 - 1; |
1238 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1243 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1239 | int y2 = mWorkingHoursYBottom; | 1244 | int y2 = mWorkingHoursYBottom; |
1240 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1245 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1241 | 1246 | ||
1242 | if (x2 >= x1 && y2 >= y1) { | 1247 | if (x2 >= x1 && y2 >= y1) { |
1243 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1248 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1244 | int gxStart = x1/mGridSpacingX; | 1249 | int gxStart = x1/mGridSpacingX; |
1245 | int gxEnd = x2/mGridSpacingX; | 1250 | int gxEnd = x2/mGridSpacingX; |
1246 | while(gxStart <= gxEnd) { | 1251 | while(gxStart <= gxEnd) { |
1247 | if (gxStart < int(mHolidayMask->count()) && | 1252 | if (gxStart < int(mHolidayMask->count()) && |
1248 | !mHolidayMask->at(gxStart)) { | 1253 | !mHolidayMask->at(gxStart)) { |
1249 | int xStart = KOGlobals::self()->reverseLayout() ? | 1254 | int xStart = KOGlobals::self()->reverseLayout() ? |
1250 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1255 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1251 | gxStart*mGridSpacingX; | 1256 | gxStart*mGridSpacingX; |
1252 | if (xStart < x1) xStart = x1; | 1257 | if (xStart < x1) xStart = x1; |
1253 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1258 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1254 | (mColumns - gxStart)*mGridSpacingX-1 : | 1259 | (mColumns - gxStart)*mGridSpacingX-1 : |
1255 | (gxStart+1)*mGridSpacingX-1; | 1260 | (gxStart+1)*mGridSpacingX-1; |
1256 | if (xEnd > x2) xEnd = x2; | 1261 | if (xEnd > x2) xEnd = x2; |
1257 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1262 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1258 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1263 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1259 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1264 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1260 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1265 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1261 | else | 1266 | else |
1262 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1267 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1263 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1268 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1264 | } else { | 1269 | } else { |
1265 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1270 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1266 | KOPrefs::instance()->mWorkingHoursColor); | 1271 | KOPrefs::instance()->mWorkingHoursColor); |
1267 | } | 1272 | } |
1268 | } | 1273 | } |
1269 | ++gxStart; | 1274 | ++gxStart; |
1270 | } | 1275 | } |
1271 | } | 1276 | } |
1272 | } | 1277 | } |
1273 | /* | 1278 | /* |
1274 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1279 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1275 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1280 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1276 | mSelectionCellX * mGridSpacingX; | 1281 | mSelectionCellX * mGridSpacingX; |
1277 | 1282 | ||
1278 | // Draw selection | 1283 | // Draw selection |
1279 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1284 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1280 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1285 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1281 | // TODO: paint only part within cx,cy,cw,ch | 1286 | // TODO: paint only part within cx,cy,cw,ch |
1282 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1287 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1283 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1288 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1284 | } | 1289 | } |
1285 | */ | 1290 | */ |
1286 | // Draw vertical lines of grid | 1291 | // Draw vertical lines of grid |
1287 | 1292 | ||
1288 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1293 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1289 | if ( mGridSpacingX > 0 ) { | 1294 | if ( mGridSpacingX > 0 ) { |
1290 | while (x < cx + cw) { | 1295 | while (x < cx + cw) { |
1291 | p->drawLine(x,cy,x,cy+ch); | 1296 | p->drawLine(x,cy,x,cy+ch); |
1292 | x+=mGridSpacingX; | 1297 | x+=mGridSpacingX; |
1293 | } | 1298 | } |
1294 | } | 1299 | } |
1295 | // Draw horizontal lines of grid | 1300 | // Draw horizontal lines of grid |
1296 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1301 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1297 | if ( lGridSpacingY > 0 ) { | 1302 | if ( lGridSpacingY > 0 ) { |
1298 | while (y < cy + ch) { | 1303 | while (y < cy + ch) { |
1299 | p->setPen( SolidLine ); | 1304 | p->setPen( SolidLine ); |
1300 | p->drawLine(cx,y,cx+cw,y); | 1305 | p->drawLine(cx,y,cx+cw,y); |
1301 | y+=lGridSpacingY; | 1306 | y+=lGridSpacingY; |
1302 | p->setPen( DotLine ); | 1307 | p->setPen( DotLine ); |
1303 | p->drawLine(cx,y,cx+cw,y); | 1308 | p->drawLine(cx,y,cx+cw,y); |
1304 | y+=lGridSpacingY; | 1309 | y+=lGridSpacingY; |
1305 | } | 1310 | } |
1306 | p->setPen( SolidLine ); | 1311 | p->setPen( SolidLine ); |
1307 | } | 1312 | } |
1308 | mPixPainter.end() ; | 1313 | mPixPainter.end() ; |
1309 | } | 1314 | } |
1310 | 1315 | ||
1311 | /* | 1316 | /* |
1312 | Convert srcollview contents coordinates to agenda grid coordinates. | 1317 | Convert srcollview contents coordinates to agenda grid coordinates. |
1313 | */ | 1318 | */ |
1314 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1319 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1315 | { | 1320 | { |
1316 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1321 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1317 | x/mGridSpacingX; | 1322 | x/mGridSpacingX; |
1318 | gy = y/mGridSpacingY; | 1323 | gy = y/mGridSpacingY; |
1319 | } | 1324 | } |
1320 | 1325 | ||
1321 | /* | 1326 | /* |
1322 | Convert agenda grid coordinates to scrollview contents coordinates. | 1327 | Convert agenda grid coordinates to scrollview contents coordinates. |
1323 | */ | 1328 | */ |
1324 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1329 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1325 | { | 1330 | { |
1326 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1331 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1327 | gx*mGridSpacingX; | 1332 | gx*mGridSpacingX; |
1328 | y = gy*mGridSpacingY; | 1333 | y = gy*mGridSpacingY; |
1329 | } | 1334 | } |
1330 | 1335 | ||
1331 | 1336 | ||
1332 | /* | 1337 | /* |
1333 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1338 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1334 | the grid. | 1339 | the grid. |
1335 | */ | 1340 | */ |
1336 | int KOAgenda::timeToY(const QTime &time) | 1341 | int KOAgenda::timeToY(const QTime &time) |
1337 | { | 1342 | { |
1338 | int minutesPerCell = 24 * 60 / mRows; | 1343 | int minutesPerCell = 24 * 60 / mRows; |
1339 | int timeMinutes = time.hour() * 60 + time.minute(); | 1344 | int timeMinutes = time.hour() * 60 + time.minute(); |
1340 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1345 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1341 | return Y; | 1346 | return Y; |
1342 | } | 1347 | } |
1343 | 1348 | ||
1344 | 1349 | ||
1345 | /* | 1350 | /* |
1346 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1351 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1347 | fit into the grid. | 1352 | fit into the grid. |
1348 | */ | 1353 | */ |
1349 | QTime KOAgenda::gyToTime(int gy) | 1354 | QTime KOAgenda::gyToTime(int gy) |
1350 | { | 1355 | { |
1351 | 1356 | ||
1352 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1357 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1353 | 1358 | ||
1354 | int timeSeconds = secondsPerCell * gy; | 1359 | int timeSeconds = secondsPerCell * gy; |
1355 | 1360 | ||
1356 | QTime time( 0, 0, 0 ); | 1361 | QTime time( 0, 0, 0 ); |
1357 | if ( timeSeconds < 24 * 60 * 60 ) { | 1362 | if ( timeSeconds < 24 * 60 * 60 ) { |
1358 | time = time.addSecs(timeSeconds); | 1363 | time = time.addSecs(timeSeconds); |
1359 | } else { | 1364 | } else { |
1360 | time.setHMS( 23, 59, 59 ); | 1365 | time.setHMS( 23, 59, 59 ); |
1361 | } | 1366 | } |
1362 | 1367 | ||
1363 | return time; | 1368 | return time; |
1364 | } | 1369 | } |
1365 | 1370 | ||
1366 | void KOAgenda::setStartHour(int startHour) | 1371 | void KOAgenda::setStartHour(int startHour) |
1367 | { | 1372 | { |
1368 | int startCell = startHour * mRows / 24; | 1373 | int startCell = startHour * mRows / 24; |
1369 | setContentsPos(0,startCell * gridSpacingY()); | 1374 | setContentsPos(0,startCell * gridSpacingY()); |
1370 | } | 1375 | } |
1371 | void KOAgenda::hideUnused() | 1376 | void KOAgenda::hideUnused() |
1372 | { | 1377 | { |
1373 | // experimental only | 1378 | // experimental only |
1374 | // return; | 1379 | // return; |
1375 | KOAgendaItem *item; | 1380 | KOAgendaItem *item; |
1376 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1381 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1377 | item->hide(); | 1382 | item->hide(); |
1378 | } | 1383 | } |
1379 | } | 1384 | } |
1380 | 1385 | ||
1381 | 1386 | ||
1382 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1387 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1383 | { | 1388 | { |
1384 | 1389 | ||
1385 | KOAgendaItem *fi; | 1390 | KOAgendaItem *fi; |
1386 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1391 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1387 | if ( fi->incidence() == event ) { | 1392 | if ( fi->incidence() == event ) { |
1388 | mUnusedItems.remove(); | 1393 | mUnusedItems.remove(); |
1389 | fi->init( event, qd ); | 1394 | fi->init( event, qd ); |
1390 | return fi; | 1395 | return fi; |
1391 | } | 1396 | } |
1392 | } | 1397 | } |
1393 | fi=mUnusedItems.first(); | 1398 | fi=mUnusedItems.first(); |
1394 | if ( fi ) { | 1399 | if ( fi ) { |
1395 | mUnusedItems.remove(); | 1400 | mUnusedItems.remove(); |
1396 | fi->init( event, qd ); | 1401 | fi->init( event, qd ); |
1397 | return fi; | 1402 | return fi; |
1398 | } | 1403 | } |
1399 | // qDebug("new KOAgendaItem "); | 1404 | // qDebug("new KOAgendaItem "); |
1400 | 1405 | ||
1401 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1406 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1402 | agendaItem->installEventFilter(this); | 1407 | agendaItem->installEventFilter(this); |
1403 | addChild(agendaItem,0,0); | 1408 | addChild(agendaItem,0,0); |
1404 | return agendaItem; | 1409 | return agendaItem; |
1405 | } | 1410 | } |
1406 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1411 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1407 | { | 1412 | { |
1408 | KOAgendaItem *item; | 1413 | KOAgendaItem *item; |
1409 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1414 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1410 | if ( item->incidence() == todo ) { | 1415 | if ( item->incidence() == todo ) { |
1411 | mItems.remove(); | 1416 | mItems.remove(); |
1412 | return item; | 1417 | return item; |
1413 | } | 1418 | } |
1414 | } | 1419 | } |
1415 | return 0; | 1420 | return 0; |
1416 | } | 1421 | } |
1417 | 1422 | ||
1418 | 1423 | ||
1419 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1424 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1420 | { | 1425 | { |
1421 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1426 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1422 | KOAgendaItem *item; | 1427 | KOAgendaItem *item; |
1423 | item = getItemForTodo ( todo ); | 1428 | item = getItemForTodo ( todo ); |
1424 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1429 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1425 | if ( item ) { | 1430 | if ( item ) { |
1426 | blockSignals( true ); | 1431 | blockSignals( true ); |
1427 | //qDebug("item found "); | 1432 | //qDebug("item found "); |
1428 | item->hide(); | 1433 | item->hide(); |
1429 | item->setCellX(-2, -1 ); | 1434 | item->setCellX(-2, -1 ); |
1430 | item->select(false); | 1435 | item->select(false); |
1431 | mUnusedItems.append( item ); | 1436 | mUnusedItems.append( item ); |
1432 | mItems.remove( item ); | 1437 | mItems.remove( item ); |
1433 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1438 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1434 | KOAgendaItem *itemit; | 1439 | KOAgendaItem *itemit; |
1435 | //globalFlagBlockAgendaItemPaint = 1; | 1440 | //globalFlagBlockAgendaItemPaint = 1; |
1436 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1441 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1437 | itemit=oldconflictItems.next() ) { | 1442 | itemit=oldconflictItems.next() ) { |
1438 | if ( itemit != item ) | 1443 | if ( itemit != item ) |
1439 | placeSubCells(itemit); | 1444 | placeSubCells(itemit); |
1440 | } | 1445 | } |
1441 | qApp->processEvents(); | 1446 | qApp->processEvents(); |
1442 | //globalFlagBlockAgendaItemPaint = 0; | 1447 | //globalFlagBlockAgendaItemPaint = 0; |
1443 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1448 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1444 | itemit=oldconflictItems.next() ) { | 1449 | itemit=oldconflictItems.next() ) { |
1445 | globalFlagBlockAgendaItemUpdate = 0; | 1450 | globalFlagBlockAgendaItemUpdate = 0; |
1446 | if ( itemit != item ) | 1451 | if ( itemit != item ) |
1447 | itemit->repaintMe(); | 1452 | itemit->repaintMe(); |
1448 | globalFlagBlockAgendaItemUpdate = 1; | 1453 | globalFlagBlockAgendaItemUpdate = 1; |
1449 | itemit->repaint(); | 1454 | itemit->repaint(); |
1450 | } | 1455 | } |
1451 | blockSignals( false ); | 1456 | blockSignals( false ); |
1452 | } | 1457 | } |
1453 | if ( remove ) { | 1458 | if ( remove ) { |
1454 | //qDebug("remove****************************************** "); | 1459 | //qDebug("remove****************************************** "); |
1455 | return; | 1460 | return; |
1456 | } | 1461 | } |
1457 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1462 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1458 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1463 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1459 | QDate currentDate; | 1464 | QDate currentDate; |
1460 | QDateTime dt; | 1465 | QDateTime dt; |
1461 | if ( todo->hasCompletedDate() ) | 1466 | if ( todo->hasCompletedDate() ) |
1462 | dt = todo->completed(); | 1467 | dt = todo->completed(); |
1463 | else | 1468 | else |
1464 | dt = todo->dtDue(); | 1469 | dt = todo->dtDue(); |
1465 | if ( overdue ) { | 1470 | if ( overdue ) { |
1466 | currentDate = QDate::currentDate(); | 1471 | currentDate = QDate::currentDate(); |
1467 | days += todo->dtDue().date().daysTo( currentDate ); | 1472 | days += todo->dtDue().date().daysTo( currentDate ); |
1468 | } | 1473 | } |
1469 | else | 1474 | else |
1470 | currentDate = dt.date(); | 1475 | currentDate = dt.date(); |
1471 | 1476 | ||
1472 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1477 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1473 | if ( ! mAllDayMode ) return; | 1478 | if ( ! mAllDayMode ) return; |
1474 | // aldayagenda | 1479 | // aldayagenda |
1475 | globalFlagBlockAgendaItemPaint = 1; | 1480 | globalFlagBlockAgendaItemPaint = 1; |
1476 | item = insertAllDayItem(todo, currentDate,days, days); | 1481 | item = insertAllDayItem(todo, currentDate,days, days); |
1477 | item->show(); | 1482 | item->show(); |
1478 | 1483 | ||
1479 | } | 1484 | } |
1480 | else { | 1485 | else { |
1481 | if ( mAllDayMode ) return; | 1486 | if ( mAllDayMode ) return; |
1482 | // mAgenda | 1487 | // mAgenda |
1483 | globalFlagBlockAgendaItemPaint = 1; | 1488 | globalFlagBlockAgendaItemPaint = 1; |
1484 | int endY = timeToY(dt.time()) - 1; | 1489 | int endY = timeToY(dt.time()) - 1; |
1485 | int hi = 12/KOPrefs::instance()->mHourSize; | 1490 | int hi = 12/KOPrefs::instance()->mHourSize; |
1486 | int startY = endY - 1-hi; | 1491 | int startY = endY - 1-hi; |
1487 | item = insertItem(todo,currentDate,days,startY,endY); | 1492 | item = insertItem(todo,currentDate,days,startY,endY); |
1488 | item->show(); | 1493 | item->show(); |
1489 | } | 1494 | } |
1490 | qApp->processEvents(); | 1495 | qApp->processEvents(); |
1491 | globalFlagBlockAgendaItemPaint = 0; | 1496 | globalFlagBlockAgendaItemPaint = 0; |
1492 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1497 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1493 | KOAgendaItem *itemit; | 1498 | KOAgendaItem *itemit; |
1494 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1499 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1495 | itemit=oldconflictItems.next() ) { | 1500 | itemit=oldconflictItems.next() ) { |
1496 | globalFlagBlockAgendaItemUpdate = 0; | 1501 | globalFlagBlockAgendaItemUpdate = 0; |
1497 | itemit->repaintMe(); | 1502 | itemit->repaintMe(); |
1498 | globalFlagBlockAgendaItemUpdate = 1; | 1503 | globalFlagBlockAgendaItemUpdate = 1; |
1499 | itemit->repaint(); | 1504 | itemit->repaint(); |
1500 | } | 1505 | } |
1501 | globalFlagBlockAgendaItemUpdate = 0; | 1506 | globalFlagBlockAgendaItemUpdate = 0; |
1502 | item->repaintMe(); | 1507 | item->repaintMe(); |
1503 | globalFlagBlockAgendaItemUpdate = 1; | 1508 | globalFlagBlockAgendaItemUpdate = 1; |
1504 | item->repaint(); | 1509 | item->repaint(); |
1505 | } | 1510 | } |
1506 | /* | 1511 | /* |
1507 | Insert KOAgendaItem into agenda. | 1512 | Insert KOAgendaItem into agenda. |
1508 | */ | 1513 | */ |
1509 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1514 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1510 | { | 1515 | { |
1511 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1516 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1512 | 1517 | ||
1513 | if (mAllDayMode) { | 1518 | if (mAllDayMode) { |
1514 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1519 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1515 | return 0; | 1520 | return 0; |
1516 | } | 1521 | } |
1517 | 1522 | ||
1518 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1523 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1519 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1524 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1520 | 1525 | ||
1521 | int YSize = YBottom - YTop + 1; | 1526 | int YSize = YBottom - YTop + 1; |
1522 | if (YSize < 0) { | 1527 | if (YSize < 0) { |
1523 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1528 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1524 | YSize = 1; | 1529 | YSize = 1; |
1525 | } | 1530 | } |
1526 | int iheight = mGridSpacingY * YSize; | 1531 | int iheight = mGridSpacingY * YSize; |
1527 | 1532 | ||
1528 | agendaItem->resize(mGridSpacingX,iheight ); | 1533 | agendaItem->resize(mGridSpacingX,iheight ); |
1529 | agendaItem->setCellXY(X,YTop,YBottom); | 1534 | agendaItem->setCellXY(X,YTop,YBottom); |
1530 | agendaItem->setCellXWidth(X); | 1535 | agendaItem->setCellXWidth(X); |
1531 | 1536 | ||
1532 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1537 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1533 | mItems.append(agendaItem); | 1538 | mItems.append(agendaItem); |
1534 | 1539 | ||
1535 | placeSubCells(agendaItem); | 1540 | placeSubCells(agendaItem); |
1536 | 1541 | ||
1537 | //agendaItem->show(); | 1542 | //agendaItem->show(); |
1538 | 1543 | ||
1539 | marcus_bains(); | 1544 | marcus_bains(); |
1540 | 1545 | ||
1541 | return agendaItem; | 1546 | return agendaItem; |
1542 | } | 1547 | } |
1543 | 1548 | ||
1544 | 1549 | ||
1545 | /* | 1550 | /* |
1546 | Insert all-day KOAgendaItem into agenda. | 1551 | Insert all-day KOAgendaItem into agenda. |
1547 | */ | 1552 | */ |
1548 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1553 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1549 | { | 1554 | { |
1550 | if (!mAllDayMode) { | 1555 | if (!mAllDayMode) { |
1551 | return 0; | 1556 | return 0; |
1552 | } | 1557 | } |
1553 | 1558 | ||
1554 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1559 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1555 | 1560 | ||
1556 | agendaItem->setCellXY(XBegin,0,0); | 1561 | agendaItem->setCellXY(XBegin,0,0); |
1557 | agendaItem->setCellXWidth(XEnd); | 1562 | agendaItem->setCellXWidth(XEnd); |
1558 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1563 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1559 | 1564 | ||
1560 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1565 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1561 | mItems.append(agendaItem); | 1566 | mItems.append(agendaItem); |
1562 | 1567 | ||
1563 | placeSubCells(agendaItem); | 1568 | placeSubCells(agendaItem); |
1564 | 1569 | ||
1565 | //agendaItem->show(); | 1570 | //agendaItem->show(); |
1566 | 1571 | ||
1567 | return agendaItem; | 1572 | return agendaItem; |
1568 | } | 1573 | } |
1569 | 1574 | ||
1570 | 1575 | ||
1571 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1576 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1572 | int YTop,int YBottom) | 1577 | int YTop,int YBottom) |
1573 | { | 1578 | { |
1574 | if (mAllDayMode) { | 1579 | if (mAllDayMode) { |
1575 | ; | 1580 | ; |
1576 | return; | 1581 | return; |
1577 | } | 1582 | } |
1578 | 1583 | ||
1579 | int cellX,cellYTop,cellYBottom; | 1584 | int cellX,cellYTop,cellYBottom; |
1580 | QString newtext; | 1585 | QString newtext; |
1581 | int width = XEnd - XBegin + 1; | 1586 | int width = XEnd - XBegin + 1; |
1582 | int count = 0; | 1587 | int count = 0; |
1583 | KOAgendaItem *current = 0; | 1588 | KOAgendaItem *current = 0; |
1584 | QPtrList<KOAgendaItem> multiItems; | 1589 | QPtrList<KOAgendaItem> multiItems; |
1585 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1590 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1586 | if (cellX == XBegin) cellYTop = YTop; | 1591 | if (cellX == XBegin) cellYTop = YTop; |
1587 | else cellYTop = 0; | 1592 | else cellYTop = 0; |
1588 | if (cellX == XEnd) cellYBottom = YBottom; | 1593 | if (cellX == XEnd) cellYBottom = YBottom; |
1589 | else cellYBottom = rows() - 1; | 1594 | else cellYBottom = rows() - 1; |
1590 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1595 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1591 | newtext.append(event->summary()); | 1596 | newtext.append(event->summary()); |
1592 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1597 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1593 | current->setText(newtext); | 1598 | current->setText(newtext); |
1594 | multiItems.append(current); | 1599 | multiItems.append(current); |
1595 | } | 1600 | } |
1596 | 1601 | ||
1597 | KOAgendaItem *next = 0; | 1602 | KOAgendaItem *next = 0; |
1598 | KOAgendaItem *last = multiItems.last(); | 1603 | KOAgendaItem *last = multiItems.last(); |
1599 | KOAgendaItem *first = multiItems.first(); | 1604 | KOAgendaItem *first = multiItems.first(); |
1600 | KOAgendaItem *setFirst,*setLast; | 1605 | KOAgendaItem *setFirst,*setLast; |
1601 | current = first; | 1606 | current = first; |
1602 | while (current) { | 1607 | while (current) { |
1603 | next = multiItems.next(); | 1608 | next = multiItems.next(); |
1604 | if (current == first) setFirst = 0; | 1609 | if (current == first) setFirst = 0; |
1605 | else setFirst = first; | 1610 | else setFirst = first; |
1606 | if (current == last) setLast = 0; | 1611 | if (current == last) setLast = 0; |
1607 | else setLast = last; | 1612 | else setLast = last; |
1608 | 1613 | ||
1609 | current->setMultiItem(setFirst,next,setLast); | 1614 | current->setMultiItem(setFirst,next,setLast); |
1610 | current = next; | 1615 | current = next; |
1611 | } | 1616 | } |
1612 | 1617 | ||
1613 | marcus_bains(); | 1618 | marcus_bains(); |
1614 | } | 1619 | } |
1615 | 1620 | ||
1616 | 1621 | ||
1617 | //QSizePolicy KOAgenda::sizePolicy() const | 1622 | //QSizePolicy KOAgenda::sizePolicy() const |
1618 | //{ | 1623 | //{ |
1619 | // Thought this would make the all-day event agenda minimum size and the | 1624 | // Thought this would make the all-day event agenda minimum size and the |
1620 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1625 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1621 | // don´t seem to think that an Expanding widget needs more space than a | 1626 | // don´t seem to think that an Expanding widget needs more space than a |
1622 | // Preferred one. | 1627 | // Preferred one. |
1623 | // But it doesn´t hurt, so it stays. | 1628 | // But it doesn´t hurt, so it stays. |
1624 | // if (mAllDayMode) { | 1629 | // if (mAllDayMode) { |
1625 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1630 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1626 | // } else { | 1631 | // } else { |
1627 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1632 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1628 | // } | 1633 | // } |
1629 | //} | 1634 | //} |
1630 | void KOAgenda::finishResize ( ) | 1635 | void KOAgenda::finishResize ( ) |
1631 | { | 1636 | { |
1632 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1637 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1633 | if ( globalFlagBlockAgenda == 0 ) { | 1638 | if ( globalFlagBlockAgenda == 0 ) { |
1634 | finishUpdate(); | 1639 | finishUpdate(); |
1635 | //qDebug("finishUpdate() called "); | 1640 | //qDebug("finishUpdate() called "); |
1636 | } | 1641 | } |
1637 | } | 1642 | } |
1638 | /* | 1643 | /* |
1639 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1644 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1640 | */ | 1645 | */ |
1641 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1646 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1642 | { | 1647 | { |
1643 | 1648 | ||
1644 | mResizeTimer.start( 150 , true ); | 1649 | mResizeTimer.start( 150 , true ); |
1645 | computeSizes(); | 1650 | computeSizes(); |
1646 | return; | 1651 | return; |
1647 | 1652 | ||
1648 | } | 1653 | } |
1649 | void KOAgenda::computeSizes() | 1654 | void KOAgenda::computeSizes() |
1650 | { | 1655 | { |
1651 | if ( globalFlagBlockStartup ) | 1656 | if ( globalFlagBlockStartup ) |
1652 | return; | 1657 | return; |
1653 | 1658 | ||
1654 | if (mAllDayMode) { | 1659 | if (mAllDayMode) { |
1655 | mGridSpacingX = (width()-3) / mColumns; | 1660 | mGridSpacingX = (width()-3) / mColumns; |
1656 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1661 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1657 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1662 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1658 | // mGridSpacingY = height(); | 1663 | // mGridSpacingY = height(); |
1659 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1664 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1660 | 1665 | ||
1661 | KOAgendaItem *item; | 1666 | KOAgendaItem *item; |
1662 | int subCellWidth; | 1667 | int subCellWidth; |
1663 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1668 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1664 | subCellWidth = mGridSpacingY / item->subCells(); | 1669 | subCellWidth = mGridSpacingY / item->subCells(); |
1665 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1670 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1666 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1671 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1667 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1672 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1668 | item->cellX() * mGridSpacingX, | 1673 | item->cellX() * mGridSpacingX, |
1669 | item->subCell() * subCellWidth); | 1674 | item->subCell() * subCellWidth); |
1670 | } | 1675 | } |
1671 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1676 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1672 | } else { | 1677 | } else { |
1673 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1678 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; |
1674 | if (height() > mGridSpacingY * mRows + 1 ) { | 1679 | if (height() > mGridSpacingY * mRows + 1 ) { |
1675 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1680 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1676 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1681 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1677 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1682 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1678 | emit resizedSignal(); | 1683 | emit resizedSignal(); |
1679 | } else | 1684 | } else |
1680 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1685 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1681 | KOAgendaItem *item; | 1686 | KOAgendaItem *item; |
1682 | int subCellWidth; | 1687 | int subCellWidth; |
1683 | 1688 | ||
1684 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1689 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1685 | subCellWidth = mGridSpacingX / item->subCells(); | 1690 | subCellWidth = mGridSpacingX / item->subCells(); |
1686 | item->resize(subCellWidth,item->height()); | 1691 | item->resize(subCellWidth,item->height()); |
1687 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1692 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1688 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1693 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1689 | item->cellX() * mGridSpacingX) + | 1694 | item->cellX() * mGridSpacingX) + |
1690 | item->subCell() * subCellWidth,childY(item)); | 1695 | item->subCell() * subCellWidth,childY(item)); |
1691 | } | 1696 | } |
1692 | } | 1697 | } |
1693 | int cw = contentsWidth(); | 1698 | int cw = contentsWidth(); |
1694 | int ch = contentsHeight(); | 1699 | int ch = contentsHeight(); |
1695 | if ( mAllDayMode ) { | 1700 | if ( mAllDayMode ) { |
1696 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1701 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1697 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1702 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1698 | paintPixAll->resize( cw, ch ); | 1703 | paintPixAll->resize( cw, ch ); |
1699 | } else { | 1704 | } else { |
1700 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1705 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1701 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1706 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1702 | KOAgendaItem::resizePixmap( cw , ch ); | 1707 | KOAgendaItem::resizePixmap( cw , ch ); |
1703 | } | 1708 | } |
1704 | 1709 | ||
1705 | checkScrollBoundaries(); | 1710 | checkScrollBoundaries(); |
1706 | marcus_bains(); | 1711 | marcus_bains(); |
1707 | drawContentsToPainter(); | 1712 | drawContentsToPainter(); |
1708 | viewport()->repaint(false); | 1713 | viewport()->repaint(false); |
1709 | } | 1714 | } |
1710 | 1715 | ||
1711 | void KOAgenda::scrollUp() | 1716 | void KOAgenda::scrollUp() |
1712 | { | 1717 | { |
1713 | scrollBy(0,-mScrollOffset); | 1718 | scrollBy(0,-mScrollOffset); |
1714 | } | 1719 | } |
1715 | 1720 | ||
1716 | 1721 | ||
1717 | void KOAgenda::scrollDown() | 1722 | void KOAgenda::scrollDown() |
1718 | { | 1723 | { |
1719 | scrollBy(0,mScrollOffset); | 1724 | scrollBy(0,mScrollOffset); |
1720 | } | 1725 | } |
1721 | 1726 | ||
1722 | void KOAgenda::popupAlarm() | 1727 | void KOAgenda::popupAlarm() |
1723 | { | 1728 | { |
1724 | if (!mClickedItem) { | 1729 | if (!mClickedItem) { |
1725 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1730 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1726 | return; | 1731 | return; |
1727 | } | 1732 | } |
1728 | // TODO: deal correctly with multiple alarms | 1733 | // TODO: deal correctly with multiple alarms |
1729 | Alarm* alarm; | 1734 | Alarm* alarm; |
1730 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1735 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1731 | for(alarm=list.first();alarm;alarm=list.next()) { | 1736 | for(alarm=list.first();alarm;alarm=list.next()) { |
1732 | alarm->toggleAlarm(); | 1737 | alarm->toggleAlarm(); |
1733 | } | 1738 | } |
1734 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1739 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1735 | mClickedItem->paintMe( true ); | 1740 | mClickedItem->paintMe( true ); |
1736 | mClickedItem->repaint( false ); | 1741 | mClickedItem->repaint( false ); |
1737 | } | 1742 | } |
1738 | 1743 | ||
1739 | /* | 1744 | /* |
1740 | Calculates the minimum width | 1745 | Calculates the minimum width |
1741 | */ | 1746 | */ |
1742 | int KOAgenda::minimumWidth() const | 1747 | int KOAgenda::minimumWidth() const |
1743 | { | 1748 | { |
1744 | // TODO:: develop a way to dynamically determine the minimum width | 1749 | // TODO:: develop a way to dynamically determine the minimum width |
1745 | int min = 100; | 1750 | int min = 100; |
1746 | 1751 | ||
1747 | return min; | 1752 | return min; |
1748 | } | 1753 | } |
1749 | 1754 | ||
1750 | void KOAgenda::updateConfig() | 1755 | void KOAgenda::updateConfig() |
1751 | { | 1756 | { |
1752 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1757 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1753 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1758 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1754 | if ( mAllDayMode ) { | 1759 | if ( mAllDayMode ) { |
1755 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1760 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1756 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1761 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1757 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1762 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1758 | // setMaximumHeight( mGridSpacingY+1 ); | 1763 | // setMaximumHeight( mGridSpacingY+1 ); |
1759 | viewport()->repaint( false ); | 1764 | viewport()->repaint( false ); |
1760 | //setFixedHeight( mGridSpacingY+1 ); | 1765 | //setFixedHeight( mGridSpacingY+1 ); |
1761 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1766 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1762 | } | 1767 | } |
1763 | else { | 1768 | else { |
1764 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1769 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1765 | calculateWorkingHours(); | 1770 | calculateWorkingHours(); |
1766 | marcus_bains(); | 1771 | marcus_bains(); |
1767 | } | 1772 | } |
1768 | } | 1773 | } |
1769 | 1774 | ||
1770 | void KOAgenda::checkScrollBoundaries() | 1775 | void KOAgenda::checkScrollBoundaries() |
1771 | { | 1776 | { |
1772 | // Invalidate old values to force update | 1777 | // Invalidate old values to force update |
1773 | mOldLowerScrollValue = -1; | 1778 | mOldLowerScrollValue = -1; |
1774 | mOldUpperScrollValue = -1; | 1779 | mOldUpperScrollValue = -1; |
1775 | 1780 | ||
1776 | checkScrollBoundaries(verticalScrollBar()->value()); | 1781 | checkScrollBoundaries(verticalScrollBar()->value()); |
1777 | } | 1782 | } |
1778 | 1783 | ||
1779 | void KOAgenda::checkScrollBoundaries(int v) | 1784 | void KOAgenda::checkScrollBoundaries(int v) |
1780 | { | 1785 | { |
1781 | if ( mGridSpacingY == 0 ) | 1786 | if ( mGridSpacingY == 0 ) |
1782 | return; | 1787 | return; |
1783 | int yMin = v/mGridSpacingY; | 1788 | int yMin = v/mGridSpacingY; |
1784 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1789 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1785 | 1790 | ||
1786 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1791 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1787 | 1792 | ||
1788 | if (yMin != mOldLowerScrollValue) { | 1793 | if (yMin != mOldLowerScrollValue) { |
1789 | mOldLowerScrollValue = yMin; | 1794 | mOldLowerScrollValue = yMin; |
1790 | emit lowerYChanged(yMin); | 1795 | emit lowerYChanged(yMin); |
1791 | } | 1796 | } |
1792 | if (yMax != mOldUpperScrollValue) { | 1797 | if (yMax != mOldUpperScrollValue) { |
1793 | mOldUpperScrollValue = yMax; | 1798 | mOldUpperScrollValue = yMax; |
1794 | emit upperYChanged(yMax); | 1799 | emit upperYChanged(yMax); |
1795 | } | 1800 | } |
1796 | } | 1801 | } |
1797 | 1802 | ||
1798 | void KOAgenda::deselectItem() | 1803 | void KOAgenda::deselectItem() |
1799 | { | 1804 | { |
1800 | if (mSelectedItem.isNull()) return; | 1805 | if (mSelectedItem.isNull()) return; |
1801 | mSelectedItem->select(false); | 1806 | mSelectedItem->select(false); |
1802 | mSelectedItem = 0; | 1807 | mSelectedItem = 0; |
1803 | } | 1808 | } |
1804 | 1809 | ||
1805 | void KOAgenda::selectItem(KOAgendaItem *item) | 1810 | void KOAgenda::selectItem(KOAgendaItem *item) |
1806 | { | 1811 | { |
1807 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1812 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1808 | deselectItem(); | 1813 | deselectItem(); |
1809 | if (item == 0) { | 1814 | if (item == 0) { |
1810 | emit incidenceSelected( 0 ); | 1815 | emit incidenceSelected( 0 ); |
1811 | return; | 1816 | return; |
1812 | } | 1817 | } |
1813 | mSelectedItem = item; | 1818 | mSelectedItem = item; |
1814 | mSelectedItem->select(); | 1819 | mSelectedItem->select(); |
1815 | emit incidenceSelected( mSelectedItem->incidence() ); | 1820 | emit incidenceSelected( mSelectedItem->incidence() ); |
1816 | } | 1821 | } |
1817 | 1822 | ||
1818 | // This function seems never be called. | 1823 | // This function seems never be called. |
1819 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1824 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1820 | { | 1825 | { |
1821 | switch(kev->key()) { | 1826 | switch(kev->key()) { |
1822 | case Key_PageDown: | 1827 | case Key_PageDown: |
1823 | verticalScrollBar()->addPage(); | 1828 | verticalScrollBar()->addPage(); |
1824 | break; | 1829 | break; |
1825 | case Key_PageUp: | 1830 | case Key_PageUp: |
1826 | verticalScrollBar()->subtractPage(); | 1831 | verticalScrollBar()->subtractPage(); |
1827 | break; | 1832 | break; |
1828 | case Key_Down: | 1833 | case Key_Down: |
1829 | verticalScrollBar()->addLine(); | 1834 | verticalScrollBar()->addLine(); |
1830 | break; | 1835 | break; |
1831 | case Key_Up: | 1836 | case Key_Up: |
1832 | verticalScrollBar()->subtractLine(); | 1837 | verticalScrollBar()->subtractLine(); |
1833 | break; | 1838 | break; |
1834 | default: | 1839 | default: |
1835 | ; | 1840 | ; |
1836 | } | 1841 | } |
1837 | } | 1842 | } |
1838 | 1843 | ||
1839 | void KOAgenda::calculateWorkingHours() | 1844 | void KOAgenda::calculateWorkingHours() |
1840 | { | 1845 | { |
1841 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1846 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1842 | mWorkingHoursEnable = !mAllDayMode; | 1847 | mWorkingHoursEnable = !mAllDayMode; |
1843 | 1848 | ||
1844 | mWorkingHoursYTop = mGridSpacingY * | 1849 | mWorkingHoursYTop = mGridSpacingY * |
1845 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1850 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1846 | mWorkingHoursYBottom = mGridSpacingY * | 1851 | mWorkingHoursYBottom = mGridSpacingY * |
1847 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1852 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1848 | } | 1853 | } |
1849 | 1854 | ||
1850 | 1855 | ||
1851 | DateList KOAgenda::dateList() const | 1856 | DateList KOAgenda::dateList() const |
1852 | { | 1857 | { |
1853 | return mSelectedDates; | 1858 | return mSelectedDates; |
1854 | } | 1859 | } |
1855 | 1860 | ||
1856 | void KOAgenda::setDateList(const DateList &selectedDates) | 1861 | void KOAgenda::setDateList(const DateList &selectedDates) |
1857 | { | 1862 | { |
1858 | mSelectedDates = selectedDates; | 1863 | mSelectedDates = selectedDates; |
1859 | marcus_bains(); | 1864 | marcus_bains(); |
1860 | } | 1865 | } |
1861 | 1866 | ||
1862 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1867 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1863 | { | 1868 | { |
1864 | mHolidayMask = mask; | 1869 | mHolidayMask = mask; |
1865 | 1870 | ||
1866 | /* | 1871 | /* |
1867 | kdDebug() << "HolidayMask: "; | 1872 | kdDebug() << "HolidayMask: "; |
1868 | for(uint i=0;i<mask->count();++i) { | 1873 | for(uint i=0;i<mask->count();++i) { |
1869 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1874 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1870 | } | 1875 | } |
1871 | kdDebug() << endl; | 1876 | kdDebug() << endl; |
1872 | */ | 1877 | */ |
1873 | } | 1878 | } |
1874 | 1879 | ||
1875 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1880 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1876 | { | 1881 | { |
1877 | 1882 | ||
1878 | QScrollView::contentsMousePressEvent(event); | 1883 | QScrollView::contentsMousePressEvent(event); |
1879 | } | 1884 | } |
1880 | 1885 | ||
1881 | void KOAgenda::storePosition() | 1886 | void KOAgenda::storePosition() |
1882 | { | 1887 | { |
1883 | //mContentPosition | 1888 | //mContentPosition |
1884 | int max = mGridSpacingY*4*24; | 1889 | int max = mGridSpacingY*4*24; |
1885 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 1890 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1886 | mContentPosition = 0; | 1891 | mContentPosition = 0; |
1887 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 1892 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1888 | mContentPosition = -1.0; | 1893 | mContentPosition = -1.0; |
1889 | else | 1894 | else |
1890 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 1895 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1891 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 1896 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1892 | 1897 | ||
1893 | } | 1898 | } |
1894 | void KOAgenda::restorePosition() | 1899 | void KOAgenda::restorePosition() |
1895 | { | 1900 | { |
1896 | int posY; | 1901 | int posY; |
1897 | int max = mGridSpacingY*4*24; | 1902 | int max = mGridSpacingY*4*24; |
1898 | if ( mContentPosition < 0 ) | 1903 | if ( mContentPosition < 0 ) |
1899 | posY = max-viewport()->height(); | 1904 | posY = max-viewport()->height(); |
1900 | else | 1905 | else |
1901 | if ( mContentPosition == 0 ) | 1906 | if ( mContentPosition == 0 ) |
1902 | posY = 0; | 1907 | posY = 0; |
1903 | else | 1908 | else |
1904 | posY = (max/mContentPosition)-(viewport()->height()/2); | 1909 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1905 | setContentsPos (0, posY ); | 1910 | setContentsPos (0, posY ); |
1906 | //qDebug("posY %d hei %d", posY, max); | 1911 | //qDebug("posY %d hei %d", posY, max); |
1907 | 1912 | ||
1908 | } | 1913 | } |
1909 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 1914 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1910 | { | 1915 | { |
1911 | ++x; | 1916 | ++x; |
1912 | QScrollView::moveChild( w, x , y ); | 1917 | QScrollView::moveChild( w, x , y ); |
1913 | } | 1918 | } |
1914 | #include <qmessagebox.h> | 1919 | #include <qmessagebox.h> |
1915 | #ifdef DESKTOP_VERSION | 1920 | #ifdef DESKTOP_VERSION |
1916 | #include <qprinter.h> | 1921 | #include <qprinter.h> |
1917 | #include <qpainter.h> | 1922 | #include <qpainter.h> |
1918 | #include <qpaintdevicemetrics.h> | 1923 | #include <qpaintdevicemetrics.h> |
1919 | 1924 | ||
1920 | #endif | 1925 | #endif |
1921 | void KOAgenda::printSelection() | 1926 | void KOAgenda::printSelection() |
1922 | { | 1927 | { |
1923 | #ifdef DESKTOP_VERSION | 1928 | #ifdef DESKTOP_VERSION |
1924 | if ( mStartCellY == mCurrentCellY ) { | 1929 | if ( mStartCellY == mCurrentCellY ) { |
1925 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1930 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1926 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 1931 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1927 | i18n("OK"), 0, 0, | 1932 | i18n("OK"), 0, 0, |
1928 | 0, 1 ); | 1933 | 0, 1 ); |
1929 | return; | 1934 | return; |
1930 | } | 1935 | } |
1931 | 1936 | ||
1932 | float dx, dy; | 1937 | float dx, dy; |
1933 | int x,y,w,h; | 1938 | int x,y,w,h; |
1934 | x= 0; | 1939 | x= 0; |
1935 | w= contentsWidth()+2; | 1940 | w= contentsWidth()+2; |
1936 | // h= contentsHeight(); | 1941 | // h= contentsHeight(); |
1937 | y = mGridSpacingY*mStartCellY; | 1942 | y = mGridSpacingY*mStartCellY; |
1938 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 1943 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1939 | 1944 | ||
1940 | //return; | 1945 | //return; |
1941 | QPrinter* printer = new QPrinter(); | 1946 | QPrinter* printer = new QPrinter(); |
1942 | if ( !printer->setup()) { | 1947 | if ( !printer->setup()) { |
1943 | delete printer; | 1948 | delete printer; |
1944 | return; | 1949 | return; |
1945 | } | 1950 | } |
1946 | QPainter p( printer ); | 1951 | QPainter p( printer ); |
1947 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 1952 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
1948 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 1953 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
1949 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 1954 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
1950 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 1955 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
1951 | // p.drawText( 0, 0, date ); | 1956 | // p.drawText( 0, 0, date ); |
1952 | int offset = m.width()/8; | 1957 | int offset = m.width()/8; |
1953 | // compute the scale | 1958 | // compute the scale |
1954 | dx = ((float) m.width()-offset) / (float)w; | 1959 | dx = ((float) m.width()-offset) / (float)w; |
1955 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 1960 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
1956 | float scale; | 1961 | float scale; |
1957 | // scale to fit the width or height of the paper | 1962 | // scale to fit the width or height of the paper |
1958 | if ( dx < dy ) | 1963 | if ( dx < dy ) |
1959 | scale = dx; | 1964 | scale = dx; |
1960 | else | 1965 | else |
1961 | scale = dy; | 1966 | scale = dy; |
1962 | // set the scale | 1967 | // set the scale |
1963 | p.drawText( offset* scale, offset* scale*3/4, date ); | 1968 | p.drawText( offset* scale, offset* scale*3/4, date ); |
1964 | 1969 | ||
1965 | int selDay; | 1970 | int selDay; |
1966 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 1971 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
1967 | float startX = 1; | 1972 | float startX = 1; |
1968 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1973 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1969 | { | 1974 | { |
1970 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 1975 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
1971 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 1976 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
1972 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 1977 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
1973 | startX += widOffset; | 1978 | startX += widOffset; |
1974 | 1979 | ||
1975 | } | 1980 | } |
1976 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 1981 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
1977 | p.scale( scale, scale ); | 1982 | p.scale( scale, scale ); |
1978 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 1983 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
1979 | // now printing with y offset: 2 hei | 1984 | // now printing with y offset: 2 hei |
1980 | // p.translate( 0, -y*scale); | 1985 | // p.translate( 0, -y*scale); |
1981 | 1986 | ||
1982 | drawContentsToPainter(&p, true ); | 1987 | drawContentsToPainter(&p, true ); |
1983 | globalFlagBlockAgendaItemUpdate = false; | 1988 | globalFlagBlockAgendaItemUpdate = false; |
1984 | KOAgendaItem *item; | 1989 | KOAgendaItem *item; |
1985 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1990 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1986 | item->select(false); | 1991 | item->select(false); |
1987 | item->paintMe( false, &p ); | 1992 | item->paintMe( false, &p ); |
1988 | } | 1993 | } |
1989 | globalFlagBlockAgendaItemUpdate = true; | 1994 | globalFlagBlockAgendaItemUpdate = true; |
1990 | p.end(); | 1995 | p.end(); |
1991 | delete printer; | 1996 | delete printer; |
1992 | #else | 1997 | #else |
1993 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1998 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1994 | i18n("Not supported \non PDA!\n"), | 1999 | i18n("Not supported \non PDA!\n"), |
1995 | i18n("OK"), 0, 0, | 2000 | i18n("OK"), 0, 0, |
1996 | 0, 1 ); | 2001 | 0, 1 ); |
1997 | #endif | 2002 | #endif |
1998 | } | 2003 | } |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 060b4c4..faa2c21 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,634 +1,633 @@ | |||
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 code for Qt in the source distribution. | 22 | without including the source code 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 | 28 | ||
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | 32 | ||
33 | #include <libkcal/vcaldrag.h> | 33 | #include <libkcal/vcaldrag.h> |
34 | #include <libkcal/icaldrag.h> | 34 | #include <libkcal/icaldrag.h> |
35 | #include <libkcal/dndfactory.h> | 35 | #include <libkcal/dndfactory.h> |
36 | #include <libkcal/calendarresources.h> | 36 | #include <libkcal/calendarresources.h> |
37 | #include <libkcal/resourcecalendar.h> | 37 | #include <libkcal/resourcecalendar.h> |
38 | #include <kresources/resourceselectdialog.h> | 38 | #include <kresources/resourceselectdialog.h> |
39 | 39 | ||
40 | #include <kcalendarsystem.h> | 40 | #include <kcalendarsystem.h> |
41 | 41 | ||
42 | #ifndef KORG_NOPLUGINS | 42 | #ifndef KORG_NOPLUGINS |
43 | #include "kocore.h" | 43 | #include "kocore.h" |
44 | #endif | 44 | #endif |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "kodaymatrix.h" | 48 | #include "kodaymatrix.h" |
49 | 49 | ||
50 | // ============================================================================ | 50 | // ============================================================================ |
51 | // D Y N A M I C T I P | 51 | // D Y N A M I C T I P |
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | 53 | ||
54 | DynamicTip::DynamicTip( QWidget * parent ) | 54 | DynamicTip::DynamicTip( QWidget * parent ) |
55 | : QToolTip( parent ) | 55 | : QToolTip( parent ) |
56 | { | 56 | { |
57 | matrix = (KODayMatrix*)parent; | 57 | matrix = (KODayMatrix*)parent; |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | void DynamicTip::maybeTip( const QPoint &pos ) | 61 | void DynamicTip::maybeTip( const QPoint &pos ) |
62 | { | 62 | { |
63 | //calculate which cell of the matrix the mouse is in | 63 | //calculate which cell of the matrix the mouse is in |
64 | QRect sz = matrix->frameRect(); | 64 | QRect sz = matrix->frameRect(); |
65 | int dheight = sz.height()*7 / 42; | 65 | int dheight = sz.height()*7 / 42; |
66 | int dwidth = sz.width() / 7; | 66 | int dwidth = sz.width() / 7; |
67 | int row = pos.y()/dheight; | 67 | int row = pos.y()/dheight; |
68 | int col = pos.x()/dwidth; | 68 | int col = pos.x()/dwidth; |
69 | 69 | ||
70 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 70 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
71 | 71 | ||
72 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 72 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
73 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 73 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
74 | 74 | ||
75 | //show holiday names only | 75 | //show holiday names only |
76 | QString str = matrix->getHolidayLabel(col+row*7); | 76 | QString str = matrix->getHolidayLabel(col+row*7); |
77 | if (str.isEmpty()) return; | 77 | if (str.isEmpty()) return; |
78 | tip(rct, str); | 78 | tip(rct, str); |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | // ============================================================================ | 82 | // ============================================================================ |
83 | // K O D A Y M A T R I X | 83 | // K O D A Y M A T R I X |
84 | // ============================================================================ | 84 | // ============================================================================ |
85 | 85 | ||
86 | const int KODayMatrix::NOSELECTION = -1000; | 86 | const int KODayMatrix::NOSELECTION = -1000; |
87 | const int KODayMatrix::NUMDAYS = 42; | 87 | const int KODayMatrix::NUMDAYS = 42; |
88 | 88 | ||
89 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 89 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
90 | QFrame(parent, name) | 90 | QFrame(parent, name) |
91 | { | 91 | { |
92 | mCalendar = calendar; | 92 | mCalendar = calendar; |
93 | 93 | ||
94 | // initialize dynamic arrays | 94 | // initialize dynamic arrays |
95 | days = new QDate[NUMDAYS]; | 95 | days = new QDate[NUMDAYS]; |
96 | daylbls = new QString[NUMDAYS]; | 96 | daylbls = new QString[NUMDAYS]; |
97 | events = new int[NUMDAYS]; | 97 | events = new int[NUMDAYS]; |
98 | mToolTip = new DynamicTip(this); | 98 | mToolTip = new DynamicTip(this); |
99 | 99 | ||
100 | // set default values used for drawing the matrix | 100 | // set default values used for drawing the matrix |
101 | mDefaultBackColor = palette().active().base(); | 101 | mDefaultBackColor = palette().active().base(); |
102 | mDefaultTextColor = palette().active().foreground(); | 102 | mDefaultTextColor = palette().active().foreground(); |
103 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 103 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
104 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 104 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
105 | mSelectedDaysColor = QColor("white"); | 105 | mSelectedDaysColor = QColor("white"); |
106 | mTodayMarginWidth = 2; | 106 | mTodayMarginWidth = 2; |
107 | mSelEnd = mSelStart = NOSELECTION; | 107 | mSelEnd = mSelStart = NOSELECTION; |
108 | 108 | ||
109 | setAcceptDrops(true); | 109 | setAcceptDrops(true); |
110 | //setFont( QFont("Arial", 10) ); | 110 | //setFont( QFont("Arial", 10) ); |
111 | 111 | ||
112 | mUpdateTimer = new QTimer( this ); | 112 | mUpdateTimer = new QTimer( this ); |
113 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 113 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
114 | mRepaintTimer = new QTimer( this ); | 114 | mRepaintTimer = new QTimer( this ); |
115 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 115 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
116 | mDayChanged = false; | 116 | mDayChanged = false; |
117 | updateView(); | 117 | updateView(); |
118 | } | 118 | } |
119 | 119 | ||
120 | QColor KODayMatrix::getShadedColor(QColor color) | 120 | QColor KODayMatrix::getShadedColor(QColor color) |
121 | { | 121 | { |
122 | QColor shaded; | 122 | QColor shaded; |
123 | int h=0; | 123 | int h=0; |
124 | int s=0; | 124 | int s=0; |
125 | int v=0; | 125 | int v=0; |
126 | color.hsv(&h,&s,&v); | 126 | color.hsv(&h,&s,&v); |
127 | s = s/4; | 127 | s = s/4; |
128 | v = 192+v/4; | 128 | v = 192+v/4; |
129 | shaded.setHsv(h,s,v); | 129 | shaded.setHsv(h,s,v); |
130 | 130 | ||
131 | return shaded; | 131 | return shaded; |
132 | } | 132 | } |
133 | 133 | ||
134 | KODayMatrix::~KODayMatrix() | 134 | KODayMatrix::~KODayMatrix() |
135 | { | 135 | { |
136 | delete [] days; | 136 | delete [] days; |
137 | delete [] daylbls; | 137 | delete [] daylbls; |
138 | delete [] events; | 138 | delete [] events; |
139 | delete mToolTip; | 139 | delete mToolTip; |
140 | } | 140 | } |
141 | 141 | ||
142 | /* | 142 | /* |
143 | void KODayMatrix::setStartDate(QDate start) | 143 | void KODayMatrix::setStartDate(QDate start) |
144 | { | 144 | { |
145 | updateView(start); | 145 | updateView(start); |
146 | } | 146 | } |
147 | */ | 147 | */ |
148 | 148 | ||
149 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 149 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
150 | { | 150 | { |
151 | kdDebug() << "KODayMatrix::addSelectedDaysTo() - " << "mSelStart:" << mSelStart << endl; | 151 | |
152 | |||
153 | if (mSelStart == NOSELECTION) { | 152 | if (mSelStart == NOSELECTION) { |
154 | return; | 153 | return; |
155 | } | 154 | } |
156 | 155 | ||
157 | //cope with selection being out of matrix limits at top (< 0) | 156 | //cope with selection being out of matrix limits at top (< 0) |
158 | int i0 = mSelStart; | 157 | int i0 = mSelStart; |
159 | if (i0 < 0) { | 158 | if (i0 < 0) { |
160 | for (int i = i0; i < 0; i++) { | 159 | for (int i = i0; i < 0; i++) { |
161 | selDays.append(days[0].addDays(i)); | 160 | selDays.append(days[0].addDays(i)); |
162 | } | 161 | } |
163 | i0 = 0; | 162 | i0 = 0; |
164 | } | 163 | } |
165 | 164 | ||
166 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 165 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
167 | if (mSelEnd > NUMDAYS-1) { | 166 | if (mSelEnd > NUMDAYS-1) { |
168 | for (int i = i0; i <= NUMDAYS-1; i++) { | 167 | for (int i = i0; i <= NUMDAYS-1; i++) { |
169 | selDays.append(days[i]); | 168 | selDays.append(days[i]); |
170 | } | 169 | } |
171 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 170 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
172 | selDays.append(days[0].addDays(i)); | 171 | selDays.append(days[0].addDays(i)); |
173 | } | 172 | } |
174 | 173 | ||
175 | // apply normal routine to selection being entirely within matrix limits | 174 | // apply normal routine to selection being entirely within matrix limits |
176 | } else { | 175 | } else { |
177 | for (int i = i0; i <= mSelEnd; i++) { | 176 | for (int i = i0; i <= mSelEnd; i++) { |
178 | selDays.append(days[i]); | 177 | selDays.append(days[i]); |
179 | } | 178 | } |
180 | } | 179 | } |
181 | } | 180 | } |
182 | 181 | ||
183 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 182 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
184 | { | 183 | { |
185 | mSelStart = startdate.daysTo(start); | 184 | mSelStart = startdate.daysTo(start); |
186 | mSelEnd = startdate.daysTo(end); | 185 | mSelEnd = startdate.daysTo(end); |
187 | } | 186 | } |
188 | 187 | ||
189 | 188 | ||
190 | void KODayMatrix::recalculateToday() | 189 | void KODayMatrix::recalculateToday() |
191 | { | 190 | { |
192 | today = -1; | 191 | today = -1; |
193 | for (int i=0; i<NUMDAYS; i++) { | 192 | for (int i=0; i<NUMDAYS; i++) { |
194 | days[i] = startdate.addDays(i); | 193 | days[i] = startdate.addDays(i); |
195 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 194 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
196 | 195 | ||
197 | // if today is in the currently displayed month, hilight today | 196 | // if today is in the currently displayed month, hilight today |
198 | if (days[i].year() == QDate::currentDate().year() && | 197 | if (days[i].year() == QDate::currentDate().year() && |
199 | days[i].month() == QDate::currentDate().month() && | 198 | days[i].month() == QDate::currentDate().month() && |
200 | days[i].day() == QDate::currentDate().day()) { | 199 | days[i].day() == QDate::currentDate().day()) { |
201 | today = i; | 200 | today = i; |
202 | } | 201 | } |
203 | } | 202 | } |
204 | // qDebug(QString("Today is visible at %1.").arg(today)); | 203 | // qDebug(QString("Today is visible at %1.").arg(today)); |
205 | } | 204 | } |
206 | 205 | ||
207 | void KODayMatrix::updateView() | 206 | void KODayMatrix::updateView() |
208 | { | 207 | { |
209 | updateView(startdate); | 208 | updateView(startdate); |
210 | } | 209 | } |
211 | void KODayMatrix::repaintViewTimed() | 210 | void KODayMatrix::repaintViewTimed() |
212 | { | 211 | { |
213 | qDebug("KODayMatrix::repaintViewTimed "); | 212 | qDebug("KODayMatrix::repaintViewTimed "); |
214 | mRepaintTimer->stop(); | 213 | mRepaintTimer->stop(); |
215 | repaint(false); | 214 | repaint(false); |
216 | } | 215 | } |
217 | void KODayMatrix::updateViewTimed() | 216 | void KODayMatrix::updateViewTimed() |
218 | { | 217 | { |
219 | 218 | ||
220 | mUpdateTimer->stop(); | 219 | mUpdateTimer->stop(); |
221 | //QDate actdate = mPendingNewDate; | 220 | //QDate actdate = mPendingNewDate; |
222 | 221 | ||
223 | static int iii = 0; | 222 | static int iii = 0; |
224 | qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); | 223 | qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii ); |
225 | 224 | ||
226 | if (mDayChanged) { | 225 | if (mDayChanged) { |
227 | recalculateToday(); | 226 | recalculateToday(); |
228 | mDayChanged = false; | 227 | mDayChanged = false; |
229 | } | 228 | } |
230 | 229 | ||
231 | for(int i = 0; i < NUMDAYS; i++) { | 230 | for(int i = 0; i < NUMDAYS; i++) { |
232 | 231 | ||
233 | // if events are set for the day then remember to draw it bold | 232 | // if events are set for the day then remember to draw it bold |
234 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 233 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
235 | Event *event; | 234 | Event *event; |
236 | int numEvents = eventlist.count(); | 235 | int numEvents = eventlist.count(); |
237 | 236 | ||
238 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 237 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
239 | ushort recurType = event->recurrence()->doesRecur(); | 238 | ushort recurType = event->recurrence()->doesRecur(); |
240 | 239 | ||
241 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 240 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
242 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 241 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
243 | numEvents--; | 242 | numEvents--; |
244 | } | 243 | } |
245 | } | 244 | } |
246 | events[i] = numEvents; | 245 | events[i] = numEvents; |
247 | 246 | ||
248 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 247 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
249 | #ifndef KORG_NOPLUGINS | 248 | #ifndef KORG_NOPLUGINS |
250 | QString holiStr = KOCore::self()->holiday(days[i]); | 249 | QString holiStr = KOCore::self()->holiday(days[i]); |
251 | #else | 250 | #else |
252 | QString holiStr = QString::null; | 251 | QString holiStr = QString::null; |
253 | #endif | 252 | #endif |
254 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 253 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
255 | !holiStr.isEmpty()) { | 254 | !holiStr.isEmpty()) { |
256 | if (holiStr.isNull()) holiStr = ""; | 255 | if (holiStr.isNull()) holiStr = ""; |
257 | mHolidays[i] = holiStr; | 256 | mHolidays[i] = holiStr; |
258 | 257 | ||
259 | } else { | 258 | } else { |
260 | mHolidays[i] = QString::null; | 259 | mHolidays[i] = QString::null; |
261 | } | 260 | } |
262 | } | 261 | } |
263 | repaint(false); | 262 | repaint(false); |
264 | } | 263 | } |
265 | void KODayMatrix::updateView(QDate actdate) | 264 | void KODayMatrix::updateView(QDate actdate) |
266 | { | 265 | { |
267 | 266 | ||
268 | //flag to indicate if the starting day of the matrix has changed by this call | 267 | //flag to indicate if the starting day of the matrix has changed by this call |
269 | //mDayChanged = false; | 268 | //mDayChanged = false; |
270 | // if a new startdate is to be set then apply Cornelius's calculation | 269 | // if a new startdate is to be set then apply Cornelius's calculation |
271 | // of the first day to be shown | 270 | // of the first day to be shown |
272 | if (actdate != startdate) { | 271 | if (actdate != startdate) { |
273 | // reset index of selection according to shift of starting date from startdate to actdate | 272 | // reset index of selection according to shift of starting date from startdate to actdate |
274 | if (mSelStart != NOSELECTION) { | 273 | if (mSelStart != NOSELECTION) { |
275 | int tmp = actdate.daysTo(startdate); | 274 | int tmp = actdate.daysTo(startdate); |
276 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 275 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
277 | // shift selection if new one would be visible at least partly ! | 276 | // shift selection if new one would be visible at least partly ! |
278 | 277 | ||
279 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 278 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
280 | // nested if is required for next X display pushed from a different month - correction required | 279 | // nested if is required for next X display pushed from a different month - correction required |
281 | // otherwise, for month forward and backward, it must be avoided | 280 | // otherwise, for month forward and backward, it must be avoided |
282 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 281 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
283 | mSelStart = mSelStart + tmp; | 282 | mSelStart = mSelStart + tmp; |
284 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 283 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
285 | mSelEnd = mSelEnd + tmp; | 284 | mSelEnd = mSelEnd + tmp; |
286 | } | 285 | } |
287 | } | 286 | } |
288 | 287 | ||
289 | startdate = actdate; | 288 | startdate = actdate; |
290 | mDayChanged = true; | 289 | mDayChanged = true; |
291 | } | 290 | } |
292 | qDebug("restart Timer %d", mDayChanged ); | 291 | qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
293 | static int iii = 0; | 292 | static int iii = 0; |
294 | if ( iii < 5 ) { | 293 | if ( iii < 2 ) { |
295 | ++iii; | 294 | ++iii; |
296 | updateViewTimed(); | 295 | updateViewTimed(); |
297 | } else { | 296 | } else { |
298 | if ( !isVisible() ) { | 297 | if ( !isVisible() ) { |
299 | mUpdateTimer->start( 2000 ); | 298 | mUpdateTimer->start( 2000 ); |
300 | } else { | 299 | } else { |
301 | if ( mDayChanged ) { | 300 | if ( mDayChanged ) { |
302 | mUpdateTimer->start( 250 ); | 301 | mUpdateTimer->start( 250 ); |
303 | } else { | 302 | } else { |
304 | mRepaintTimer->start( 250 ); | 303 | mRepaintTimer->start( 250 ); |
305 | mUpdateTimer->start( 2000 ); | 304 | mUpdateTimer->start( 2000 ); |
306 | } | 305 | } |
307 | } | 306 | } |
308 | } | 307 | } |
309 | 308 | ||
310 | } | 309 | } |
311 | 310 | ||
312 | const QDate& KODayMatrix::getDate(int offset) | 311 | const QDate& KODayMatrix::getDate(int offset) |
313 | { | 312 | { |
314 | if (offset < 0 || offset > NUMDAYS-1) { | 313 | if (offset < 0 || offset > NUMDAYS-1) { |
315 | qDebug("Wrong offset2 "); | 314 | qDebug("Wrong offset2 "); |
316 | return days[0]; | 315 | return days[0]; |
317 | } | 316 | } |
318 | return days[offset]; | 317 | return days[offset]; |
319 | } | 318 | } |
320 | 319 | ||
321 | QString KODayMatrix::getHolidayLabel(int offset) | 320 | QString KODayMatrix::getHolidayLabel(int offset) |
322 | { | 321 | { |
323 | if (offset < 0 || offset > NUMDAYS-1) { | 322 | if (offset < 0 || offset > NUMDAYS-1) { |
324 | qDebug("Wrong offset1 "); | 323 | qDebug("Wrong offset1 "); |
325 | return 0; | 324 | return 0; |
326 | } | 325 | } |
327 | return mHolidays[offset]; | 326 | return mHolidays[offset]; |
328 | } | 327 | } |
329 | 328 | ||
330 | int KODayMatrix::getDayIndexFrom(int x, int y) | 329 | int KODayMatrix::getDayIndexFrom(int x, int y) |
331 | { | 330 | { |
332 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 331 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
333 | 6 - x/daysize.width() : x/daysize.width()); | 332 | 6 - x/daysize.width() : x/daysize.width()); |
334 | } | 333 | } |
335 | 334 | ||
336 | // ---------------------------------------------------------------------------- | 335 | // ---------------------------------------------------------------------------- |
337 | // M O U S E E V E N T H A N D L I N G | 336 | // M O U S E E V E N T H A N D L I N G |
338 | // ---------------------------------------------------------------------------- | 337 | // ---------------------------------------------------------------------------- |
339 | 338 | ||
340 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 339 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
341 | { | 340 | { |
342 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 341 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
343 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 342 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
344 | mSelInit = mSelStart; | 343 | mSelInit = mSelStart; |
345 | } | 344 | } |
346 | 345 | ||
347 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 346 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
348 | { | 347 | { |
349 | 348 | ||
350 | int tmp = getDayIndexFrom(e->x(), e->y()); | 349 | int tmp = getDayIndexFrom(e->x(), e->y()); |
351 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 350 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
352 | 351 | ||
353 | if (mSelInit > tmp) { | 352 | if (mSelInit > tmp) { |
354 | mSelEnd = mSelInit; | 353 | mSelEnd = mSelInit; |
355 | if (tmp != mSelStart) { | 354 | if (tmp != mSelStart) { |
356 | mSelStart = tmp; | 355 | mSelStart = tmp; |
357 | repaint(); | 356 | repaint(); |
358 | } | 357 | } |
359 | } else { | 358 | } else { |
360 | mSelStart = mSelInit; | 359 | mSelStart = mSelInit; |
361 | 360 | ||
362 | //repaint only if selection has changed | 361 | //repaint only if selection has changed |
363 | if (tmp != mSelEnd) { | 362 | if (tmp != mSelEnd) { |
364 | mSelEnd = tmp; | 363 | mSelEnd = tmp; |
365 | repaint(); | 364 | repaint(); |
366 | } | 365 | } |
367 | } | 366 | } |
368 | 367 | ||
369 | DateList daylist; | 368 | DateList daylist; |
370 | if ( mSelStart < 0 ) | 369 | if ( mSelStart < 0 ) |
371 | mSelStart = 0; | 370 | mSelStart = 0; |
372 | for (int i = mSelStart; i <= mSelEnd; i++) { | 371 | for (int i = mSelStart; i <= mSelEnd; i++) { |
373 | daylist.append(days[i]); | 372 | daylist.append(days[i]); |
374 | } | 373 | } |
375 | emit selected((const DateList)daylist); | 374 | emit selected((const DateList)daylist); |
376 | 375 | ||
377 | } | 376 | } |
378 | 377 | ||
379 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 378 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
380 | { | 379 | { |
381 | int tmp = getDayIndexFrom(e->x(), e->y()); | 380 | int tmp = getDayIndexFrom(e->x(), e->y()); |
382 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 381 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
383 | 382 | ||
384 | if (mSelInit > tmp) { | 383 | if (mSelInit > tmp) { |
385 | mSelEnd = mSelInit; | 384 | mSelEnd = mSelInit; |
386 | if (tmp != mSelStart) { | 385 | if (tmp != mSelStart) { |
387 | mSelStart = tmp; | 386 | mSelStart = tmp; |
388 | repaint(); | 387 | repaint(); |
389 | } | 388 | } |
390 | } else { | 389 | } else { |
391 | mSelStart = mSelInit; | 390 | mSelStart = mSelInit; |
392 | 391 | ||
393 | //repaint only if selection has changed | 392 | //repaint only if selection has changed |
394 | if (tmp != mSelEnd) { | 393 | if (tmp != mSelEnd) { |
395 | mSelEnd = tmp; | 394 | mSelEnd = tmp; |
396 | repaint(); | 395 | repaint(); |
397 | } | 396 | } |
398 | } | 397 | } |
399 | } | 398 | } |
400 | 399 | ||
401 | // ---------------------------------------------------------------------------- | 400 | // ---------------------------------------------------------------------------- |
402 | // D R A G ' N D R O P H A N D L I N G | 401 | // D R A G ' N D R O P H A N D L I N G |
403 | // ---------------------------------------------------------------------------- | 402 | // ---------------------------------------------------------------------------- |
404 | 403 | ||
405 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 404 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
406 | { | 405 | { |
407 | #ifndef KORG_NODND | 406 | #ifndef KORG_NODND |
408 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 407 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
409 | e->ignore(); | 408 | e->ignore(); |
410 | return; | 409 | return; |
411 | } | 410 | } |
412 | 411 | ||
413 | // some visual feedback | 412 | // some visual feedback |
414 | // oldPalette = palette(); | 413 | // oldPalette = palette(); |
415 | // setPalette(my_HilitePalette); | 414 | // setPalette(my_HilitePalette); |
416 | // update(); | 415 | // update(); |
417 | #endif | 416 | #endif |
418 | } | 417 | } |
419 | 418 | ||
420 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 419 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
421 | { | 420 | { |
422 | #ifndef KORG_NODND | 421 | #ifndef KORG_NODND |
423 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 422 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
424 | e->ignore(); | 423 | e->ignore(); |
425 | return; | 424 | return; |
426 | } | 425 | } |
427 | 426 | ||
428 | e->accept(); | 427 | e->accept(); |
429 | #endif | 428 | #endif |
430 | } | 429 | } |
431 | 430 | ||
432 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 431 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
433 | { | 432 | { |
434 | #ifndef KORG_NODND | 433 | #ifndef KORG_NODND |
435 | // setPalette(oldPalette); | 434 | // setPalette(oldPalette); |
436 | // update(); | 435 | // update(); |
437 | #endif | 436 | #endif |
438 | } | 437 | } |
439 | 438 | ||
440 | void KODayMatrix::dropEvent(QDropEvent *e) | 439 | void KODayMatrix::dropEvent(QDropEvent *e) |
441 | { | 440 | { |
442 | #ifndef KORG_NODND | 441 | #ifndef KORG_NODND |
443 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 442 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
444 | 443 | ||
445 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 444 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
446 | e->ignore(); | 445 | e->ignore(); |
447 | return; | 446 | return; |
448 | } | 447 | } |
449 | 448 | ||
450 | DndFactory factory( mCalendar ); | 449 | DndFactory factory( mCalendar ); |
451 | Event *event = factory.createDrop(e); | 450 | Event *event = factory.createDrop(e); |
452 | 451 | ||
453 | if (event) { | 452 | if (event) { |
454 | e->acceptAction(); | 453 | e->acceptAction(); |
455 | 454 | ||
456 | Event *existingEvent = mCalendar->event(event->uid()); | 455 | Event *existingEvent = mCalendar->event(event->uid()); |
457 | 456 | ||
458 | if(existingEvent) { | 457 | if(existingEvent) { |
459 | // uniquify event | 458 | // uniquify event |
460 | event->recreate(); | 459 | event->recreate(); |
461 | /* | 460 | /* |
462 | KMessageBox::sorry(this, | 461 | KMessageBox::sorry(this, |
463 | i18n("Event already exists in this calendar."), | 462 | i18n("Event already exists in this calendar."), |
464 | i18n("Drop Event")); | 463 | i18n("Drop Event")); |
465 | delete event; | 464 | delete event; |
466 | return; | 465 | return; |
467 | */ | 466 | */ |
468 | } | 467 | } |
469 | // kdDebug() << "Drop new Event" << endl; | 468 | // kdDebug() << "Drop new Event" << endl; |
470 | // Adjust date | 469 | // Adjust date |
471 | QDateTime start = event->dtStart(); | 470 | QDateTime start = event->dtStart(); |
472 | QDateTime end = event->dtEnd(); | 471 | QDateTime end = event->dtEnd(); |
473 | int duration = start.daysTo(end); | 472 | int duration = start.daysTo(end); |
474 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 473 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
475 | 474 | ||
476 | start.setDate(days[idx]); | 475 | start.setDate(days[idx]); |
477 | end.setDate(days[idx].addDays(duration)); | 476 | end.setDate(days[idx].addDays(duration)); |
478 | 477 | ||
479 | event->setDtStart(start); | 478 | event->setDtStart(start); |
480 | event->setDtEnd(end); | 479 | event->setDtEnd(end); |
481 | mCalendar->addEvent(event); | 480 | mCalendar->addEvent(event); |
482 | 481 | ||
483 | emit eventDropped(event); | 482 | emit eventDropped(event); |
484 | } else { | 483 | } else { |
485 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 484 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
486 | e->ignore(); | 485 | e->ignore(); |
487 | } | 486 | } |
488 | #endif | 487 | #endif |
489 | } | 488 | } |
490 | 489 | ||
491 | // ---------------------------------------------------------------------------- | 490 | // ---------------------------------------------------------------------------- |
492 | // P A I N T E V E N T H A N D L I N G | 491 | // P A I N T E V E N T H A N D L I N G |
493 | // ---------------------------------------------------------------------------- | 492 | // ---------------------------------------------------------------------------- |
494 | 493 | ||
495 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 494 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
496 | { | 495 | { |
497 | //kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; | 496 | //kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; |
498 | 497 | ||
499 | QPainter p(this); | 498 | QPainter p(this); |
500 | 499 | ||
501 | QRect sz = frameRect(); | 500 | QRect sz = frameRect(); |
502 | int dheight = daysize.height(); | 501 | int dheight = daysize.height(); |
503 | int dwidth = daysize.width(); | 502 | int dwidth = daysize.width(); |
504 | int row,col; | 503 | int row,col; |
505 | int selw, selh; | 504 | int selw, selh; |
506 | bool isRTL = KOGlobals::self()->reverseLayout(); | 505 | bool isRTL = KOGlobals::self()->reverseLayout(); |
507 | 506 | ||
508 | // draw background and topleft frame | 507 | // draw background and topleft frame |
509 | p.fillRect(pevent->rect(), mDefaultBackColor); | 508 | p.fillRect(pevent->rect(), mDefaultBackColor); |
510 | p.setPen(mDefaultTextColor); | 509 | p.setPen(mDefaultTextColor); |
511 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 510 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
512 | 511 | ||
513 | // draw selected days with highlighted background color | 512 | // draw selected days with highlighted background color |
514 | if (mSelStart != NOSELECTION) { | 513 | if (mSelStart != NOSELECTION) { |
515 | 514 | ||
516 | row = mSelStart/7; | 515 | row = mSelStart/7; |
517 | col = mSelStart -row*7; | 516 | col = mSelStart -row*7; |
518 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 517 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
519 | 518 | ||
520 | if (row == mSelEnd/7) { | 519 | if (row == mSelEnd/7) { |
521 | // Single row selection | 520 | // Single row selection |
522 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 521 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
523 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 522 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
524 | } else { | 523 | } else { |
525 | // draw first row to the right | 524 | // draw first row to the right |
526 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 525 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
527 | dheight, selcol); | 526 | dheight, selcol); |
528 | // draw full block till last line | 527 | // draw full block till last line |
529 | selh = mSelEnd/7-row; | 528 | selh = mSelEnd/7-row; |
530 | if (selh > 1) { | 529 | if (selh > 1) { |
531 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 530 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
532 | } | 531 | } |
533 | // draw last block from left to mSelEnd | 532 | // draw last block from left to mSelEnd |
534 | selw = mSelEnd-7*(mSelEnd/7)+1; | 533 | selw = mSelEnd-7*(mSelEnd/7)+1; |
535 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 534 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
536 | selw*dwidth, dheight, selcol); | 535 | selw*dwidth, dheight, selcol); |
537 | } | 536 | } |
538 | } | 537 | } |
539 | 538 | ||
540 | // iterate over all days in the matrix and draw the day label in appropriate colors | 539 | // iterate over all days in the matrix and draw the day label in appropriate colors |
541 | QColor actcol = mDefaultTextColorShaded; | 540 | QColor actcol = mDefaultTextColorShaded; |
542 | p.setPen(actcol); | 541 | p.setPen(actcol); |
543 | QPen tmppen; | 542 | QPen tmppen; |
544 | for(int i = 0; i < NUMDAYS; i++) { | 543 | for(int i = 0; i < NUMDAYS; i++) { |
545 | row = i/7; | 544 | row = i/7; |
546 | col = isRTL ? 6-(i-row*7) : i-row*7; | 545 | col = isRTL ? 6-(i-row*7) : i-row*7; |
547 | 546 | ||
548 | // if it is the first day of a month switch color from normal to shaded and vice versa | 547 | // if it is the first day of a month switch color from normal to shaded and vice versa |
549 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 548 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
550 | if (actcol == mDefaultTextColorShaded) { | 549 | if (actcol == mDefaultTextColorShaded) { |
551 | actcol = mDefaultTextColor; | 550 | actcol = mDefaultTextColor; |
552 | } else { | 551 | } else { |
553 | actcol = mDefaultTextColorShaded; | 552 | actcol = mDefaultTextColorShaded; |
554 | } | 553 | } |
555 | p.setPen(actcol); | 554 | p.setPen(actcol); |
556 | } | 555 | } |
557 | 556 | ||
558 | //Reset pen color after selected days block | 557 | //Reset pen color after selected days block |
559 | if (i == mSelEnd+1) { | 558 | if (i == mSelEnd+1) { |
560 | p.setPen(actcol); | 559 | p.setPen(actcol); |
561 | } | 560 | } |
562 | 561 | ||
563 | // if today then draw rectangle around day | 562 | // if today then draw rectangle around day |
564 | if (today == i) { | 563 | if (today == i) { |
565 | tmppen = p.pen(); | 564 | tmppen = p.pen(); |
566 | QPen mTodayPen(p.pen()); | 565 | QPen mTodayPen(p.pen()); |
567 | 566 | ||
568 | mTodayPen.setWidth(mTodayMarginWidth); | 567 | mTodayPen.setWidth(mTodayMarginWidth); |
569 | //draw red rectangle for holidays | 568 | //draw red rectangle for holidays |
570 | if (!mHolidays[i].isNull()) { | 569 | if (!mHolidays[i].isNull()) { |
571 | if (actcol == mDefaultTextColor) { | 570 | if (actcol == mDefaultTextColor) { |
572 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 571 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
573 | } else { | 572 | } else { |
574 | mTodayPen.setColor(mHolidayColorShaded); | 573 | mTodayPen.setColor(mHolidayColorShaded); |
575 | } | 574 | } |
576 | } | 575 | } |
577 | //draw gray rectangle for today if in selection | 576 | //draw gray rectangle for today if in selection |
578 | if (i >= mSelStart && i <= mSelEnd) { | 577 | if (i >= mSelStart && i <= mSelEnd) { |
579 | QColor grey("grey"); | 578 | QColor grey("grey"); |
580 | mTodayPen.setColor(grey); | 579 | mTodayPen.setColor(grey); |
581 | } | 580 | } |
582 | p.setPen(mTodayPen); | 581 | p.setPen(mTodayPen); |
583 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 582 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
584 | p.setPen(tmppen); | 583 | p.setPen(tmppen); |
585 | } | 584 | } |
586 | 585 | ||
587 | // if any events are on that day then draw it using a bold font | 586 | // if any events are on that day then draw it using a bold font |
588 | if (events[i] > 0) { | 587 | if (events[i] > 0) { |
589 | QFont myFont = font(); | 588 | QFont myFont = font(); |
590 | myFont.setBold(true); | 589 | myFont.setBold(true); |
591 | p.setFont(myFont); | 590 | p.setFont(myFont); |
592 | } | 591 | } |
593 | 592 | ||
594 | // if it is a holiday then use the default holiday color | 593 | // if it is a holiday then use the default holiday color |
595 | if (!mHolidays[i].isNull()) { | 594 | if (!mHolidays[i].isNull()) { |
596 | if (actcol == mDefaultTextColor) { | 595 | if (actcol == mDefaultTextColor) { |
597 | p.setPen(KOPrefs::instance()->mHolidayColor); | 596 | p.setPen(KOPrefs::instance()->mHolidayColor); |
598 | } else { | 597 | } else { |
599 | p.setPen(mHolidayColorShaded); | 598 | p.setPen(mHolidayColorShaded); |
600 | } | 599 | } |
601 | } | 600 | } |
602 | 601 | ||
603 | // draw selected days with special color | 602 | // draw selected days with special color |
604 | // DO NOT specially highlight holidays in selection ! | 603 | // DO NOT specially highlight holidays in selection ! |
605 | if (i >= mSelStart && i <= mSelEnd) { | 604 | if (i >= mSelStart && i <= mSelEnd) { |
606 | p.setPen(mSelectedDaysColor); | 605 | p.setPen(mSelectedDaysColor); |
607 | } | 606 | } |
608 | 607 | ||
609 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 608 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
610 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 609 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
611 | 610 | ||
612 | // reset color to actual color | 611 | // reset color to actual color |
613 | if (!mHolidays[i].isNull()) { | 612 | if (!mHolidays[i].isNull()) { |
614 | p.setPen(actcol); | 613 | p.setPen(actcol); |
615 | } | 614 | } |
616 | // reset bold font to plain font | 615 | // reset bold font to plain font |
617 | if (events[i] > 0) { | 616 | if (events[i] > 0) { |
618 | QFont myFont = font(); | 617 | QFont myFont = font(); |
619 | myFont.setBold(false); | 618 | myFont.setBold(false); |
620 | p.setFont(myFont); | 619 | p.setFont(myFont); |
621 | } | 620 | } |
622 | } | 621 | } |
623 | } | 622 | } |
624 | 623 | ||
625 | // ---------------------------------------------------------------------------- | 624 | // ---------------------------------------------------------------------------- |
626 | // R E SI Z E E V E N T H A N D L I N G | 625 | // R E SI Z E E V E N T H A N D L I N G |
627 | // ---------------------------------------------------------------------------- | 626 | // ---------------------------------------------------------------------------- |
628 | 627 | ||
629 | void KODayMatrix::resizeEvent(QResizeEvent *) | 628 | void KODayMatrix::resizeEvent(QResizeEvent *) |
630 | { | 629 | { |
631 | QRect sz = frameRect(); | 630 | QRect sz = frameRect(); |
632 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 631 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
633 | daysize.setWidth(sz.width() / 7); | 632 | daysize.setWidth(sz.width() / 7); |
634 | } | 633 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 2f5259f..8d8fc2a 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1245 +1,1245 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | 27 | ||
28 | #include <qvbox.h> | 28 | #include <qvbox.h> |
29 | #include <kdebug.h> | 29 | #include <kdebug.h> |
30 | #include "koprefs.h" | 30 | #include "koprefs.h" |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/vcaldrag.h> | 37 | #include <libkcal/vcaldrag.h> |
38 | #include <libkcal/calfilter.h> | 38 | #include <libkcal/calfilter.h> |
39 | #include <libkcal/dndfactory.h> | 39 | #include <libkcal/dndfactory.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <kresources/resourceselectdialog.h> | 42 | #include <kresources/resourceselectdialog.h> |
43 | #ifndef DESKTOP_VERSION | 43 | #ifndef DESKTOP_VERSION |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #else | 45 | #else |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | #endif | 47 | #endif |
48 | #ifndef KORG_NOPRINTER | 48 | #ifndef KORG_NOPRINTER |
49 | #include "calprinter.h" | 49 | #include "calprinter.h" |
50 | #endif | 50 | #endif |
51 | #include "docprefs.h" | 51 | #include "docprefs.h" |
52 | 52 | ||
53 | #include "kotodoview.h" | 53 | #include "kotodoview.h" |
54 | using namespace KOrg; | 54 | using namespace KOrg; |
55 | 55 | ||
56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 56 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
57 | const char *name) : | 57 | const char *name) : |
58 | KListView(parent,name) | 58 | KListView(parent,name) |
59 | { | 59 | { |
60 | mName = QString ( name ); | 60 | mName = QString ( name ); |
61 | mCalendar = calendar; | 61 | mCalendar = calendar; |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
64 | #endif | 64 | #endif |
65 | mOldCurrent = 0; | 65 | mOldCurrent = 0; |
66 | mMousePressed = false; | 66 | mMousePressed = false; |
67 | 67 | ||
68 | setAcceptDrops(true); | 68 | setAcceptDrops(true); |
69 | viewport()->setAcceptDrops(true); | 69 | viewport()->setAcceptDrops(true); |
70 | int size = 16; | 70 | int size = 16; |
71 | if (qApp->desktop()->width() < 300 ) | 71 | if (qApp->desktop()->width() < 300 ) |
72 | size = 12; | 72 | size = 12; |
73 | setTreeStepSize( size + 6 ); | 73 | setTreeStepSize( size + 6 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
78 | { | 78 | { |
79 | #ifndef KORG_NODND | 79 | #ifndef KORG_NODND |
80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
82 | !QTextDrag::canDecode( e ) ) { | 82 | !QTextDrag::canDecode( e ) ) { |
83 | e->ignore(); | 83 | e->ignore(); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | mOldCurrent = currentItem(); | 87 | mOldCurrent = currentItem(); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
93 | { | 93 | { |
94 | #ifndef KORG_NODND | 94 | #ifndef KORG_NODND |
95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
96 | 96 | ||
97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
98 | !QTextDrag::canDecode( e ) ) { | 98 | !QTextDrag::canDecode( e ) ) { |
99 | e->ignore(); | 99 | e->ignore(); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | e->accept(); | 103 | e->accept(); |
104 | #endif | 104 | #endif |
105 | } | 105 | } |
106 | 106 | ||
107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
108 | { | 108 | { |
109 | #ifndef KORG_NODND | 109 | #ifndef KORG_NODND |
110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
111 | 111 | ||
112 | setCurrentItem(mOldCurrent); | 112 | setCurrentItem(mOldCurrent); |
113 | setSelected(mOldCurrent,true); | 113 | setSelected(mOldCurrent,true); |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | Incidence *to = destinationEvent; | 142 | Incidence *to = destinationEvent; |
143 | while(to) { | 143 | while(to) { |
144 | if (to->uid() == todo->uid()) { | 144 | if (to->uid() == todo->uid()) { |
145 | KMessageBox::sorry(this, | 145 | KMessageBox::sorry(this, |
146 | i18n("Cannot move To-Do to itself\nor a child of itself"), | 146 | i18n("Cannot move To-Do to itself\nor a child of itself"), |
147 | i18n("Drop To-Do")); | 147 | i18n("Drop To-Do")); |
148 | delete todo; | 148 | delete todo; |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | to = to->relatedTo(); | 151 | to = to->relatedTo(); |
152 | } | 152 | } |
153 | internalDrop = true; | 153 | internalDrop = true; |
154 | if ( destinationEvent ) | 154 | if ( destinationEvent ) |
155 | reparentTodoSignal( destinationEvent, existingTodo ); | 155 | reparentTodoSignal( destinationEvent, existingTodo ); |
156 | else | 156 | else |
157 | unparentTodoSignal(existingTodo); | 157 | unparentTodoSignal(existingTodo); |
158 | delete todo; | 158 | delete todo; |
159 | } else { | 159 | } else { |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 161 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
162 | if ( destinationEvent ) | 162 | if ( destinationEvent ) |
163 | reparentTodoSignal( destinationEvent, todo ); | 163 | reparentTodoSignal( destinationEvent, todo ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | QString text; | 167 | QString text; |
168 | if (QTextDrag::decode(e,text)) { | 168 | if (QTextDrag::decode(e,text)) { |
169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
171 | qDebug("Dropped : " + text); | 171 | qDebug("Dropped : " + text); |
172 | QStringList emails = QStringList::split(",",text); | 172 | QStringList emails = QStringList::split(",",text); |
173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 183 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | #ifndef KORG_NODND | 192 | #ifndef KORG_NODND |
193 | QPoint p(contentsToViewport(e->pos())); | 193 | QPoint p(contentsToViewport(e->pos())); |
194 | QListViewItem *i = itemAt(p); | 194 | QListViewItem *i = itemAt(p); |
195 | mMousePressed = false; | 195 | mMousePressed = false; |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | QListView::contentsMousePressEvent(e); | 210 | QListView::contentsMousePressEvent(e); |
211 | } | 211 | } |
212 | 212 | ||
213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
214 | { | 214 | { |
215 | 215 | ||
216 | #ifndef KORG_NODND | 216 | #ifndef KORG_NODND |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | DndFactory factory( mCalendar ); | 223 | DndFactory factory( mCalendar ); |
224 | ICalDrag *vd = factory.createDrag( | 224 | ICalDrag *vd = factory.createDrag( |
225 | ((KOTodoViewItem *)item)->todo(),viewport()); | 225 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | internalDrop = false; | 226 | internalDrop = false; |
227 | // we cannot do any senseful here, because the DnD is still broken in Qt | 227 | // we cannot do any senseful here, because the DnD is still broken in Qt |
228 | if (vd->drag()) { | 228 | if (vd->drag()) { |
229 | if ( !internalDrop ) { | 229 | if ( !internalDrop ) { |
230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
231 | qDebug("Dnd: External move: Delete drag source "); | 231 | qDebug("Dnd: External move: Delete drag source "); |
232 | } else | 232 | } else |
233 | qDebug("Dnd: Internal move "); | 233 | qDebug("Dnd: Internal move "); |
234 | 234 | ||
235 | } else { | 235 | } else { |
236 | if ( !internalDrop ) { | 236 | if ( !internalDrop ) { |
237 | qDebug("Dnd: External Copy"); | 237 | qDebug("Dnd: External Copy"); |
238 | } else | 238 | } else |
239 | qDebug("DnD: Internal copy: Copy pending"); | 239 | qDebug("DnD: Internal copy: Copy pending"); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | #endif | 243 | #endif |
244 | } | 244 | } |
245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 245 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
246 | { | 246 | { |
247 | 247 | ||
248 | QListViewItem* cn; | 248 | QListViewItem* cn; |
249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 249 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
250 | cn = currentItem(); | 250 | cn = currentItem(); |
251 | if ( cn ) { | 251 | if ( cn ) { |
252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 252 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
253 | if ( ci ){ | 253 | if ( ci ){ |
254 | if ( e->state() == ShiftButton ) | 254 | if ( e->state() == ShiftButton ) |
255 | ci->setOn( false ); | 255 | ci->setOn( false ); |
256 | else | 256 | else |
257 | ci->setOn( true ); | 257 | ci->setOn( true ); |
258 | cn = cn->itemBelow(); | 258 | cn = cn->itemBelow(); |
259 | if ( cn ) { | 259 | if ( cn ) { |
260 | setCurrentItem ( cn ); | 260 | setCurrentItem ( cn ); |
261 | ensureItemVisible ( cn ); | 261 | ensureItemVisible ( cn ); |
262 | } | 262 | } |
263 | 263 | ||
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | 269 | ||
270 | // qDebug("KOTodoListView::keyPressEvent "); | 270 | // qDebug("KOTodoListView::keyPressEvent "); |
271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 271 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
272 | switch ( e->key() ) { | 272 | switch ( e->key() ) { |
273 | case Qt::Key_Down: | 273 | case Qt::Key_Down: |
274 | case Qt::Key_Up: | 274 | case Qt::Key_Up: |
275 | QListView::keyPressEvent ( e ); | 275 | QListView::keyPressEvent ( e ); |
276 | break; | 276 | break; |
277 | case Qt::Key_Left: | 277 | case Qt::Key_Left: |
278 | case Qt::Key_Right: | 278 | case Qt::Key_Right: |
279 | QListView::keyPressEvent ( e ); | 279 | QListView::keyPressEvent ( e ); |
280 | e->accept(); | 280 | e->accept(); |
281 | return; | 281 | return; |
282 | break; | 282 | break; |
283 | default: | 283 | default: |
284 | e->ignore(); | 284 | e->ignore(); |
285 | break; | 285 | break; |
286 | } | 286 | } |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | e->ignore(); | 289 | e->ignore(); |
290 | } | 290 | } |
291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 291 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
292 | { | 292 | { |
293 | QListView::contentsMouseReleaseEvent(e); | 293 | QListView::contentsMouseReleaseEvent(e); |
294 | mMousePressed = false; | 294 | mMousePressed = false; |
295 | } | 295 | } |
296 | 296 | ||
297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 297 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
298 | { | 298 | { |
299 | if (!e) return; | 299 | if (!e) return; |
300 | 300 | ||
301 | QPoint vp = contentsToViewport(e->pos()); | 301 | QPoint vp = contentsToViewport(e->pos()); |
302 | 302 | ||
303 | QListViewItem *item = itemAt(vp); | 303 | QListViewItem *item = itemAt(vp); |
304 | 304 | ||
305 | emit double_Clicked(item); | 305 | emit double_Clicked(item); |
306 | if (!item) return; | 306 | if (!item) return; |
307 | 307 | ||
308 | emit doubleClicked(item,vp,0); | 308 | emit doubleClicked(item,vp,0); |
309 | } | 309 | } |
310 | 310 | ||
311 | ///////////////////////////////////////////////////////////////////////////// | 311 | ///////////////////////////////////////////////////////////////////////////// |
312 | 312 | ||
313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 313 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
314 | QLineEdit(parent) | 314 | QLineEdit(parent) |
315 | { | 315 | { |
316 | setText(i18n("Click to add a new Todo")); | 316 | setText(i18n("Click to add a new Todo")); |
317 | } | 317 | } |
318 | 318 | ||
319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 319 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
320 | { | 320 | { |
321 | if ( text()==i18n("Click to add a new Todo") ) | 321 | if ( text()==i18n("Click to add a new Todo") ) |
322 | setText(""); | 322 | setText(""); |
323 | QLineEdit::focusInEvent(ev); | 323 | QLineEdit::focusInEvent(ev); |
324 | } | 324 | } |
325 | 325 | ||
326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 326 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
327 | { | 327 | { |
328 | setText(i18n("Click to add a new Todo")); | 328 | setText(i18n("Click to add a new Todo")); |
329 | QLineEdit::focusOutEvent(ev); | 329 | QLineEdit::focusOutEvent(ev); |
330 | } | 330 | } |
331 | 331 | ||
332 | ///////////////////////////////////////////////////////////////////////////// | 332 | ///////////////////////////////////////////////////////////////////////////// |
333 | 333 | ||
334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 334 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
335 | KOrg::BaseView(calendar,parent,name) | 335 | KOrg::BaseView(calendar,parent,name) |
336 | { | 336 | { |
337 | isFlatDisplay = false; | 337 | isFlatDisplay = false; |
338 | mNavigator = 0; | 338 | mNavigator = 0; |
339 | QBoxLayout *topLayout = new QVBoxLayout(this); | 339 | QBoxLayout *topLayout = new QVBoxLayout(this); |
340 | mName = QString ( name ); | 340 | mName = QString ( name ); |
341 | mBlockUpdate = false; | 341 | mBlockUpdate = false; |
342 | mQuickAdd = new KOQuickTodo(this); | 342 | mQuickAdd = new KOQuickTodo(this); |
343 | topLayout->addWidget(mQuickAdd); | 343 | topLayout->addWidget(mQuickAdd); |
344 | 344 | ||
345 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 345 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
346 | 346 | ||
347 | mTodoListView = new KOTodoListView(calendar,this, name ); | 347 | mTodoListView = new KOTodoListView(calendar,this, name ); |
348 | topLayout->addWidget(mTodoListView); | 348 | topLayout->addWidget(mTodoListView); |
349 | //mTodoListView->header()->setMaximumHeight(30); | 349 | //mTodoListView->header()->setMaximumHeight(30); |
350 | mTodoListView->setRootIsDecorated(true); | 350 | mTodoListView->setRootIsDecorated(true); |
351 | mTodoListView->setAllColumnsShowFocus(true); | 351 | mTodoListView->setAllColumnsShowFocus(true); |
352 | 352 | ||
353 | mTodoListView->setShowSortIndicator(true); | 353 | mTodoListView->setShowSortIndicator(true); |
354 | 354 | ||
355 | mTodoListView->addColumn(i18n("Todo")); | 355 | mTodoListView->addColumn(i18n("Todo")); |
356 | mTodoListView->addColumn(i18n("Prio")); | 356 | mTodoListView->addColumn(i18n("Prio")); |
357 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 357 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
358 | mTodoListView->addColumn(i18n("Complete")); | 358 | mTodoListView->addColumn(i18n("Complete")); |
359 | mTodoListView->setColumnAlignment(2,AlignCenter); | 359 | mTodoListView->setColumnAlignment(2,AlignCenter); |
360 | 360 | ||
361 | mTodoListView->addColumn(i18n("Due Date")); | 361 | mTodoListView->addColumn(i18n("Due Date")); |
362 | mTodoListView->setColumnAlignment(3,AlignLeft); | 362 | mTodoListView->setColumnAlignment(3,AlignLeft); |
363 | mTodoListView->addColumn(i18n("Due Time")); | 363 | mTodoListView->addColumn(i18n("Due Time")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | 365 | ||
366 | mTodoListView->addColumn(i18n("Start Date")); | 366 | mTodoListView->addColumn(i18n("Start Date")); |
367 | mTodoListView->setColumnAlignment(5,AlignLeft); | 367 | mTodoListView->setColumnAlignment(5,AlignLeft); |
368 | mTodoListView->addColumn(i18n("Start Time")); | 368 | mTodoListView->addColumn(i18n("Start Time")); |
369 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 369 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
370 | 370 | ||
371 | mTodoListView->addColumn(i18n("Cancelled")); | 371 | mTodoListView->addColumn(i18n("Cancelled")); |
372 | mTodoListView->addColumn(i18n("Categories")); | 372 | mTodoListView->addColumn(i18n("Categories")); |
373 | #if 0 | 373 | #if 0 |
374 | mTodoListView->addColumn(i18n("Sort Id")); | 374 | mTodoListView->addColumn(i18n("Sort Id")); |
375 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 375 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
376 | #endif | 376 | #endif |
377 | 377 | ||
378 | mTodoListView->setMinimumHeight( 60 ); | 378 | mTodoListView->setMinimumHeight( 60 ); |
379 | mTodoListView->setItemsRenameable( true ); | 379 | mTodoListView->setItemsRenameable( true ); |
380 | mTodoListView->setRenameable( 0 ); | 380 | mTodoListView->setRenameable( 0 ); |
381 | mTodoListView->setColumnWidth( 0, 120 ); | 381 | mTodoListView->setColumnWidth( 0, 120 ); |
382 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 382 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
383 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 383 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
384 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 384 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
385 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 385 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
386 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 386 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
387 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 387 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
388 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 388 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
389 | mTodoListView->setColumnWidthMode(7, QListView::Manual); | 389 | mTodoListView->setColumnWidthMode(7, QListView::Manual); |
390 | mTodoListView->setColumnWidthMode(8, QListView::Manual); | 390 | mTodoListView->setColumnWidthMode(8, QListView::Manual); |
391 | 391 | ||
392 | 392 | ||
393 | mPriorityPopupMenu = new QPopupMenu(this); | 393 | mPriorityPopupMenu = new QPopupMenu(this); |
394 | for (int i = 1; i <= 5; i++) { | 394 | for (int i = 1; i <= 5; i++) { |
395 | QString label = QString ("%1").arg (i); | 395 | QString label = QString ("%1").arg (i); |
396 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 396 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
397 | } | 397 | } |
398 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 398 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
399 | 399 | ||
400 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 400 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
401 | for (int i = 0; i <= 100; i+=20) { | 401 | for (int i = 0; i <= 100; i+=20) { |
402 | QString label = QString ("%1 %").arg (i); | 402 | QString label = QString ("%1 %").arg (i); |
403 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 403 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
404 | } | 404 | } |
405 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 405 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
406 | 406 | ||
407 | 407 | ||
408 | 408 | ||
409 | mItemPopupMenu = new QPopupMenu(this); | 409 | mItemPopupMenu = new QPopupMenu(this); |
410 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 410 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
411 | SLOT (showTodo())); | 411 | SLOT (showTodo())); |
412 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 412 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
413 | SLOT (editTodo())); | 413 | SLOT (editTodo())); |
414 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 414 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
415 | SLOT (deleteTodo())); | 415 | SLOT (deleteTodo())); |
416 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 416 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
417 | SLOT (cloneTodo())); | 417 | SLOT (cloneTodo())); |
418 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 418 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
419 | SLOT (moveTodo())); | 419 | SLOT (moveTodo())); |
420 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 420 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
421 | SLOT (beamTodo())); | 421 | SLOT (beamTodo())); |
422 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 422 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
423 | SLOT (cancelTodo())); | 423 | SLOT (cancelTodo())); |
424 | mItemPopupMenu->insertSeparator(); | 424 | mItemPopupMenu->insertSeparator(); |
425 | 425 | ||
426 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 426 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
427 | SLOT (newTodo())); | 427 | SLOT (newTodo())); |
428 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 428 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
429 | SLOT (newSubTodo())); | 429 | SLOT (newSubTodo())); |
430 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 430 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
431 | SLOT (unparentTodo()),0,21); | 431 | SLOT (unparentTodo()),0,21); |
432 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 432 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
433 | SLOT (reparentTodo()),0,22); | 433 | SLOT (reparentTodo()),0,22); |
434 | mItemPopupMenu->insertSeparator(); | 434 | mItemPopupMenu->insertSeparator(); |
435 | #if 0 | 435 | #if 0 |
436 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 436 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
437 | this, SLOT( purgeCompleted() ) ); | 437 | this, SLOT( purgeCompleted() ) ); |
438 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 438 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
439 | this, SLOT( toggleCompleted() ),0, 33 ); | 439 | this, SLOT( toggleCompleted() ),0, 33 ); |
440 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 440 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
441 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 441 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
442 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 442 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
443 | this, SLOT( toggleRunning() ),0, 35 ); | 443 | this, SLOT( toggleRunning() ),0, 35 ); |
444 | 444 | ||
445 | #endif | 445 | #endif |
446 | mPopupMenu = new QPopupMenu(this); | 446 | mPopupMenu = new QPopupMenu(this); |
447 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 447 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
448 | SLOT (newTodo()),0,1); | 448 | SLOT (newTodo()),0,1); |
449 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 449 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
450 | this, SLOT(purgeCompleted()),0,2); | 450 | this, SLOT(purgeCompleted()),0,2); |
451 | mPopupMenu->insertItem(i18n("Show Completed"), | 451 | mPopupMenu->insertItem(i18n("Show Completed"), |
452 | this, SLOT( toggleCompleted() ),0,3 ); | 452 | this, SLOT( toggleCompleted() ),0,3 ); |
453 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 453 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
454 | this, SLOT( toggleQuickTodo() ),0,4 ); | 454 | this, SLOT( toggleQuickTodo() ),0,4 ); |
455 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 455 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
456 | this, SLOT( toggleRunning() ),0,5 ); | 456 | this, SLOT( toggleRunning() ),0,5 ); |
457 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 457 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
458 | this, SLOT( setAllOpen() ),0,6 ); | 458 | this, SLOT( setAllOpen() ),0,6 ); |
459 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 459 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
460 | this, SLOT( setAllClose() ),0,7 ); | 460 | this, SLOT( setAllClose() ),0,7 ); |
461 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 461 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
462 | this, SLOT( setAllFlat() ),0,8 ); | 462 | this, SLOT( setAllFlat() ),0,8 ); |
463 | mDocPrefs = new DocPrefs( name ); | 463 | mDocPrefs = new DocPrefs( name ); |
464 | 464 | ||
465 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 465 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
466 | mPopupMenu->setCheckable( true ); | 466 | mPopupMenu->setCheckable( true ); |
467 | mItemPopupMenu->setCheckable( true ); | 467 | mItemPopupMenu->setCheckable( true ); |
468 | 468 | ||
469 | 469 | ||
470 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 470 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
471 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 471 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
472 | 472 | ||
473 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 473 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
474 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 474 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
475 | 475 | ||
476 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 476 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
477 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 477 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
478 | 478 | ||
479 | 479 | ||
480 | // Double clicking conflicts with opening/closing the subtree | 480 | // Double clicking conflicts with opening/closing the subtree |
481 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 481 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
482 | SLOT( editItem( QListViewItem *) ) ); | 482 | SLOT( editItem( QListViewItem *) ) ); |
483 | /* | 483 | /* |
484 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 484 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
485 | const QPoint &,int ) ), | 485 | const QPoint &,int ) ), |
486 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 486 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
487 | */ | 487 | */ |
488 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 488 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
489 | const QPoint &,int ) ), | 489 | const QPoint &,int ) ), |
490 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 490 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
491 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 491 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
492 | SLOT( itemClicked( QListViewItem * ) ) ); | 492 | SLOT( itemClicked( QListViewItem * ) ) ); |
493 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 493 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
494 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 494 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
495 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 495 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
496 | SLOT( updateView() ) ); | 496 | SLOT( updateView() ) ); |
497 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 497 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
498 | SLOT( todoModified(Todo *, int) ) ); | 498 | SLOT( todoModified(Todo *, int) ) ); |
499 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 499 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
500 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 500 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
501 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 501 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
502 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 502 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
503 | 503 | ||
504 | #if 0 | 504 | #if 0 |
505 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 505 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
506 | SLOT(selectionChanged(QListViewItem *))); | 506 | SLOT(selectionChanged(QListViewItem *))); |
507 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 507 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
508 | SLOT(selectionChanged(QListViewItem *))); | 508 | SLOT(selectionChanged(QListViewItem *))); |
509 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 509 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
510 | SLOT(selectionChanged(QListViewItem *))); | 510 | SLOT(selectionChanged(QListViewItem *))); |
511 | #endif | 511 | #endif |
512 | 512 | ||
513 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 513 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
514 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 514 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
515 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 515 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
516 | 516 | ||
517 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 517 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
518 | SLOT( processSelectionChange() ) ); | 518 | SLOT( processSelectionChange() ) ); |
519 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 519 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
520 | SLOT( addQuickTodo() ) ); | 520 | SLOT( addQuickTodo() ) ); |
521 | 521 | ||
522 | } | 522 | } |
523 | 523 | ||
524 | KOTodoView::~KOTodoView() | 524 | KOTodoView::~KOTodoView() |
525 | { | 525 | { |
526 | delete mDocPrefs; | 526 | delete mDocPrefs; |
527 | } | 527 | } |
528 | 528 | ||
529 | void KOTodoView::jumpToDate () | 529 | void KOTodoView::jumpToDate () |
530 | { | 530 | { |
531 | // if (mActiveItem) { | 531 | // if (mActiveItem) { |
532 | // mActiveItem->todo()); | 532 | // mActiveItem->todo()); |
533 | // if ( mActiveItem->todo()->hasDueDate() ) | 533 | // if ( mActiveItem->todo()->hasDueDate() ) |
534 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 534 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
535 | } | 535 | } |
536 | 536 | ||
537 | void KOTodoView::updateView() | 537 | void KOTodoView::updateView() |
538 | { | 538 | { |
539 | pendingSubtodo = 0; | 539 | pendingSubtodo = 0; |
540 | if ( mBlockUpdate ) { | 540 | if ( mBlockUpdate ) { |
541 | //qDebug("blocked "); | 541 | //qDebug("blocked "); |
542 | return; | 542 | return; |
543 | } | 543 | } |
544 | if ( isFlatDisplay ) { | 544 | if ( isFlatDisplay ) { |
545 | setAllFlat(); | 545 | setAllFlat(); |
546 | return; | 546 | return; |
547 | } | 547 | } |
548 | //qDebug("update "); | 548 | //qDebug("update "); |
549 | // kdDebug() << "KOTodoView::updateView()" << endl; | 549 | // kdDebug() << "KOTodoView::updateView()" << endl; |
550 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 550 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
551 | mTodoListView->clear(); | 551 | mTodoListView->clear(); |
552 | if ( mName == "todolistsmall" ) { | 552 | if ( mName == "todolistsmall" ) { |
553 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 553 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
554 | int ps = fo.pointSize() -2; | 554 | int ps = fo.pointSize() -2; |
555 | if ( ps > 12 ) | 555 | if ( ps > 12 ) |
556 | ps -= 2; | 556 | ps -= 2; |
557 | fo.setPointSize( ps ); | 557 | fo.setPointSize( ps ); |
558 | } | 558 | } |
559 | } | 559 | } |
560 | 560 | ||
561 | mTodoListView->setFont( fo ); | 561 | mTodoListView->setFont( fo ); |
562 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 562 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
563 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 563 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
564 | QPtrList<Todo> todoList = calendar()->todos(); | 564 | QPtrList<Todo> todoList = calendar()->todos(); |
565 | 565 | ||
566 | /* | 566 | /* |
567 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 567 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
568 | Event *t; | 568 | Event *t; |
569 | for(t = todoList.first(); t; t = todoList.next()) { | 569 | for(t = todoList.first(); t; t = todoList.next()) { |
570 | kdDebug() << " " << t->getSummary() << endl; | 570 | kdDebug() << " " << t->getSummary() << endl; |
571 | 571 | ||
572 | if (t->getRelatedTo()) { | 572 | if (t->getRelatedTo()) { |
573 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 573 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
574 | } | 574 | } |
575 | 575 | ||
576 | QPtrList<Event> l = t->getRelations(); | 576 | QPtrList<Event> l = t->getRelations(); |
577 | Event *c; | 577 | Event *c; |
578 | for(c=l.first();c;c=l.next()) { | 578 | for(c=l.first();c;c=l.next()) { |
579 | kdDebug() << " - relation: " << c->getSummary() << endl; | 579 | kdDebug() << " - relation: " << c->getSummary() << endl; |
580 | } | 580 | } |
581 | } | 581 | } |
582 | */ | 582 | */ |
583 | 583 | ||
584 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 584 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
585 | // specific order of events. That means that we have to generate parent items | 585 | // specific order of events. That means that we have to generate parent items |
586 | // recursively for proper hierarchical display of Todos. | 586 | // recursively for proper hierarchical display of Todos. |
587 | mTodoMap.clear(); | 587 | mTodoMap.clear(); |
588 | Todo *todo; | 588 | Todo *todo; |
589 | todo = todoList.first();// todo; todo = todoList.next()) { | 589 | todo = todoList.first();// todo; todo = todoList.next()) { |
590 | while ( todo ) { | 590 | while ( todo ) { |
591 | bool next = true; | 591 | bool next = true; |
592 | // qDebug("todo %s ", todo->summary().latin1()); | 592 | // qDebug("todo %s ", todo->summary().latin1()); |
593 | Incidence *incidence = todo->relatedTo(); | 593 | Incidence *incidence = todo->relatedTo(); |
594 | while ( incidence ) { | 594 | while ( incidence ) { |
595 | if ( incidence->type() == "Todo") { | 595 | if ( incidence->type() == "Todo") { |
596 | //qDebug("related %s ",incidence->summary().latin1() ); | 596 | //qDebug("related %s ",incidence->summary().latin1() ); |
597 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 597 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
598 | //qDebug("related not found "); | 598 | //qDebug("related not found "); |
599 | todoList.remove( ); | 599 | todoList.remove( ); |
600 | todo = todoList.current(); | 600 | todo = todoList.current(); |
601 | next = false; | 601 | next = false; |
602 | incidence = 0; | 602 | incidence = 0; |
603 | 603 | ||
604 | } else { | 604 | } else { |
605 | //qDebug("related found "); | 605 | //qDebug("related found "); |
606 | incidence = incidence->relatedTo(); | 606 | incidence = incidence->relatedTo(); |
607 | } | 607 | } |
608 | } else | 608 | } else |
609 | incidence = 0; | 609 | incidence = 0; |
610 | } | 610 | } |
611 | if ( next ) | 611 | if ( next ) |
612 | todo = todoList.next(); | 612 | todo = todoList.next(); |
613 | } | 613 | } |
614 | // qDebug("again .... "); | 614 | // qDebug("again .... "); |
615 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 615 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
616 | 616 | ||
617 | // qDebug("yytodo %s ", todo->summary().latin1()); | 617 | // qDebug("yytodo %s ", todo->summary().latin1()); |
618 | // } | 618 | // } |
619 | //qDebug("for "); | 619 | //qDebug("for "); |
620 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 620 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
621 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 621 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
622 | { | 622 | { |
623 | insertTodoItem(todo); | 623 | insertTodoItem(todo); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | //qDebug("for end "); | 626 | //qDebug("for end "); |
627 | // Restore opened/closed state | 627 | // Restore opened/closed state |
628 | mTodoListView->blockSignals( true ); | 628 | mTodoListView->blockSignals( true ); |
629 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 629 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
630 | mTodoListView->blockSignals( false ); | 630 | mTodoListView->blockSignals( false ); |
631 | mTodoListView->setFocus(); | 631 | mTodoListView->setFocus(); |
632 | processSelectionChange(); | 632 | processSelectionChange(); |
633 | } | 633 | } |
634 | 634 | ||
635 | bool KOTodoView::checkTodo( Todo * todo ) | 635 | bool KOTodoView::checkTodo( Todo * todo ) |
636 | { | 636 | { |
637 | 637 | ||
638 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 638 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
639 | return false; | 639 | return false; |
640 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 640 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
641 | if ( todo->hasStartDate() ) | 641 | if ( todo->hasStartDate() ) |
642 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 642 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
643 | return false; | 643 | return false; |
644 | if ( todo->hasDueDate() ) | 644 | if ( todo->hasDueDate() ) |
645 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 645 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
646 | return false; | 646 | return false; |
647 | } | 647 | } |
648 | return true; | 648 | return true; |
649 | } | 649 | } |
650 | 650 | ||
651 | void KOTodoView::restoreItemState( QListViewItem *item ) | 651 | void KOTodoView::restoreItemState( QListViewItem *item ) |
652 | { | 652 | { |
653 | pendingSubtodo = 0; | 653 | pendingSubtodo = 0; |
654 | while( item ) { | 654 | while( item ) { |
655 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 655 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
656 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 656 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
657 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 657 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
658 | item = item->nextSibling(); | 658 | item = item->nextSibling(); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | 661 | ||
662 | 662 | ||
663 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 663 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
664 | KOTodoView::insertTodoItem(Todo *todo) | 664 | KOTodoView::insertTodoItem(Todo *todo) |
665 | { | 665 | { |
666 | 666 | ||
667 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 667 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
668 | // TODO: Check, if dynmaic cast is necessary | 668 | // TODO: Check, if dynmaic cast is necessary |
669 | 669 | ||
670 | pendingSubtodo = 0; | 670 | pendingSubtodo = 0; |
671 | Incidence *incidence = todo->relatedTo(); | 671 | Incidence *incidence = todo->relatedTo(); |
672 | if (incidence && incidence->type() == "Todo") { | 672 | if (incidence && incidence->type() == "Todo") { |
673 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 673 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
674 | 674 | ||
675 | // kdDebug() << " has Related" << endl; | 675 | // kdDebug() << " has Related" << endl; |
676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 676 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
677 | itemIterator = mTodoMap.find(relatedTodo); | 677 | itemIterator = mTodoMap.find(relatedTodo); |
678 | if (itemIterator == mTodoMap.end()) { | 678 | if (itemIterator == mTodoMap.end()) { |
679 | // kdDebug() << " related not yet in list" << endl; | 679 | // kdDebug() << " related not yet in list" << endl; |
680 | itemIterator = insertTodoItem (relatedTodo); | 680 | itemIterator = insertTodoItem (relatedTodo); |
681 | } | 681 | } |
682 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 682 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
683 | // and one into the map. Sure finding is more easy but why? -zecke | 683 | // and one into the map. Sure finding is more easy but why? -zecke |
684 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 684 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
685 | return mTodoMap.insert(todo,todoItem); | 685 | return mTodoMap.insert(todo,todoItem); |
686 | } else { | 686 | } else { |
687 | // kdDebug() << " no Related" << endl; | 687 | // kdDebug() << " no Related" << endl; |
688 | // see above -zecke | 688 | // see above -zecke |
689 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 689 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
690 | return mTodoMap.insert(todo,todoItem); | 690 | return mTodoMap.insert(todo,todoItem); |
691 | } | 691 | } |
692 | } | 692 | } |
693 | 693 | ||
694 | 694 | ||
695 | void KOTodoView::updateConfig() | 695 | void KOTodoView::updateConfig() |
696 | { | 696 | { |
697 | updateView(); | 697 | updateView(); |
698 | mTodoListView->repaintContents(); | 698 | mTodoListView->repaintContents(); |
699 | } | 699 | } |
700 | 700 | ||
701 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 701 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
702 | { | 702 | { |
703 | QPtrList<Incidence> selected; | 703 | QPtrList<Incidence> selected; |
704 | 704 | ||
705 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 705 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
706 | // if (!item) item = mActiveItem; | 706 | // if (!item) item = mActiveItem; |
707 | if (item) selected.append(item->todo()); | 707 | if (item) selected.append(item->todo()); |
708 | 708 | ||
709 | return selected; | 709 | return selected; |
710 | } | 710 | } |
711 | 711 | ||
712 | QPtrList<Todo> KOTodoView::selectedTodos() | 712 | QPtrList<Todo> KOTodoView::selectedTodos() |
713 | { | 713 | { |
714 | QPtrList<Todo> selected; | 714 | QPtrList<Todo> selected; |
715 | 715 | ||
716 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 716 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
717 | // if (!item) item = mActiveItem; | 717 | // if (!item) item = mActiveItem; |
718 | if (item) selected.append(item->todo()); | 718 | if (item) selected.append(item->todo()); |
719 | 719 | ||
720 | return selected; | 720 | return selected; |
721 | } | 721 | } |
722 | 722 | ||
723 | void KOTodoView::changeEventDisplay(Event *, int) | 723 | void KOTodoView::changeEventDisplay(Event *, int) |
724 | { | 724 | { |
725 | updateView(); | 725 | updateView(); |
726 | } | 726 | } |
727 | 727 | ||
728 | void KOTodoView::showDates(const QDate &, const QDate &) | 728 | void KOTodoView::showDates(const QDate &, const QDate &) |
729 | { | 729 | { |
730 | } | 730 | } |
731 | 731 | ||
732 | void KOTodoView::showEvents(QPtrList<Event>) | 732 | void KOTodoView::showEvents(QPtrList<Event>) |
733 | { | 733 | { |
734 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 734 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
735 | } | 735 | } |
736 | 736 | ||
737 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 737 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
738 | const QDate &td) | 738 | const QDate &td) |
739 | { | 739 | { |
740 | #ifndef KORG_NOPRINTER | 740 | #ifndef KORG_NOPRINTER |
741 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 741 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
742 | #endif | 742 | #endif |
743 | } | 743 | } |
744 | 744 | ||
745 | void KOTodoView::editItem(QListViewItem *item ) | 745 | void KOTodoView::editItem(QListViewItem *item ) |
746 | { | 746 | { |
747 | // qDebug("editItem(QListViewItem *item ) "); | 747 | // qDebug("editItem(QListViewItem *item ) "); |
748 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 748 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
749 | } | 749 | } |
750 | 750 | ||
751 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 751 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
752 | { | 752 | { |
753 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 753 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
754 | } | 754 | } |
755 | 755 | ||
756 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 756 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
757 | { | 757 | { |
758 | pendingSubtodo = 0; | 758 | pendingSubtodo = 0; |
759 | mActiveItem = (KOTodoViewItem *)item; | 759 | mActiveItem = (KOTodoViewItem *)item; |
760 | if (item) { | 760 | if (item) { |
761 | switch (column){ | 761 | switch (column){ |
762 | case 1: | 762 | case 1: |
763 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 763 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
764 | case 2: | 764 | case 2: |
765 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 765 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
766 | case 3: | 766 | case 3: |
767 | moveTodo(); | 767 | moveTodo(); |
768 | break; | 768 | break; |
769 | case 8: | 769 | case 8: |
770 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 770 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
771 | default: | 771 | default: |
772 | mItemPopupMenu->popup(QCursor::pos()); | 772 | mItemPopupMenu->popup(QCursor::pos()); |
773 | } | 773 | } |
774 | } else mPopupMenu->popup(QCursor::pos()); | 774 | } else mPopupMenu->popup(QCursor::pos()); |
775 | } | 775 | } |
776 | void KOTodoView::newTodo() | 776 | void KOTodoView::newTodo() |
777 | { | 777 | { |
778 | emit newTodoSignal(); | 778 | emit newTodoSignal(); |
779 | } | 779 | } |
780 | 780 | ||
781 | void KOTodoView::newSubTodo() | 781 | void KOTodoView::newSubTodo() |
782 | { | 782 | { |
783 | if (mActiveItem) { | 783 | if (mActiveItem) { |
784 | emit newSubTodoSignal(mActiveItem->todo()); | 784 | emit newSubTodoSignal(mActiveItem->todo()); |
785 | } | 785 | } |
786 | } | 786 | } |
787 | void KOTodoView::unparentTodo() | 787 | void KOTodoView::unparentTodo() |
788 | { | 788 | { |
789 | if (mActiveItem) { | 789 | if (mActiveItem) { |
790 | emit unparentTodoSignal(mActiveItem->todo()); | 790 | emit unparentTodoSignal(mActiveItem->todo()); |
791 | } | 791 | } |
792 | } | 792 | } |
793 | 793 | ||
794 | void KOTodoView::reparentTodo() | 794 | void KOTodoView::reparentTodo() |
795 | { | 795 | { |
796 | if (mActiveItem) { | 796 | if (mActiveItem) { |
797 | qDebug("KOTodoView::reparentTodo() "); | 797 | qDebug("KOTodoView::reparentTodo() "); |
798 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 798 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
799 | pendingSubtodo = mActiveItem; | 799 | pendingSubtodo = mActiveItem; |
800 | } | 800 | } |
801 | } | 801 | } |
802 | void KOTodoView::editTodo() | 802 | void KOTodoView::editTodo() |
803 | { | 803 | { |
804 | if (mActiveItem) { | 804 | if (mActiveItem) { |
805 | emit editTodoSignal(mActiveItem->todo()); | 805 | emit editTodoSignal(mActiveItem->todo()); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | void KOTodoView::cloneTodo() | 808 | void KOTodoView::cloneTodo() |
809 | { | 809 | { |
810 | if (mActiveItem) { | 810 | if (mActiveItem) { |
811 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 811 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | void KOTodoView::cancelTodo() | 814 | void KOTodoView::cancelTodo() |
815 | { | 815 | { |
816 | if (mActiveItem) { | 816 | if (mActiveItem) { |
817 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 817 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | void KOTodoView::moveTodo() | 820 | void KOTodoView::moveTodo() |
821 | { | 821 | { |
822 | if (mActiveItem) { | 822 | if (mActiveItem) { |
823 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 823 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | void KOTodoView::beamTodo() | 826 | void KOTodoView::beamTodo() |
827 | { | 827 | { |
828 | if (mActiveItem) { | 828 | if (mActiveItem) { |
829 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 829 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
830 | } | 830 | } |
831 | } | 831 | } |
832 | 832 | ||
833 | 833 | ||
834 | void KOTodoView::showTodo() | 834 | void KOTodoView::showTodo() |
835 | { | 835 | { |
836 | if (mActiveItem) { | 836 | if (mActiveItem) { |
837 | emit showTodoSignal(mActiveItem->todo()); | 837 | emit showTodoSignal(mActiveItem->todo()); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | 840 | ||
841 | void KOTodoView::deleteTodo() | 841 | void KOTodoView::deleteTodo() |
842 | { | 842 | { |
843 | if (mActiveItem) { | 843 | if (mActiveItem) { |
844 | emit deleteTodoSignal(mActiveItem->todo()); | 844 | emit deleteTodoSignal(mActiveItem->todo()); |
845 | } | 845 | } |
846 | } | 846 | } |
847 | 847 | ||
848 | void KOTodoView::setNewPriority(int index) | 848 | void KOTodoView::setNewPriority(int index) |
849 | { | 849 | { |
850 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 850 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
851 | mActiveItem->todo()->setPriority(mPriority[index]); | 851 | mActiveItem->todo()->setPriority(mPriority[index]); |
852 | mActiveItem->construct(); | 852 | mActiveItem->construct(); |
853 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 853 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
854 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 854 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
855 | } | 855 | } |
856 | } | 856 | } |
857 | 857 | ||
858 | void KOTodoView::setNewPercentage(int index) | 858 | void KOTodoView::setNewPercentage(int index) |
859 | { | 859 | { |
860 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 860 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
861 | 861 | ||
862 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 862 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
863 | mActiveItem->setOn( true ); | 863 | mActiveItem->setOn( true ); |
864 | return; | 864 | return; |
865 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 865 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
866 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 866 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
867 | if ( par && par->isOn() ) | 867 | if ( par && par->isOn() ) |
868 | par->setOn( false ); | 868 | par->setOn( false ); |
869 | } | 869 | } |
870 | if (mPercentage[index] == 100) { | 870 | if (mPercentage[index] == 100) { |
871 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 871 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
872 | } else { | 872 | } else { |
873 | mActiveItem->todo()->setCompleted(false); | 873 | mActiveItem->todo()->setCompleted(false); |
874 | } | 874 | } |
875 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 875 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
876 | mActiveItem->construct(); | 876 | mActiveItem->construct(); |
877 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 877 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
878 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 878 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
879 | } | 879 | } |
880 | } | 880 | } |
881 | 881 | ||
882 | 882 | ||
883 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 883 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
884 | { | 884 | { |
885 | QPopupMenu* tempMenu = new QPopupMenu (this); | 885 | QPopupMenu* tempMenu = new QPopupMenu (this); |
886 | QStringList checkedCategories = todoItem->todo()->categories (); | 886 | QStringList checkedCategories = todoItem->todo()->categories (); |
887 | 887 | ||
888 | tempMenu->setCheckable (true); | 888 | tempMenu->setCheckable (true); |
889 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 889 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
890 | it != KOPrefs::instance()->mCustomCategories.end (); | 890 | it != KOPrefs::instance()->mCustomCategories.end (); |
891 | ++it) { | 891 | ++it) { |
892 | int index = tempMenu->insertItem (*it); | 892 | int index = tempMenu->insertItem (*it); |
893 | mCategory[index] = *it; | 893 | mCategory[index] = *it; |
894 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 894 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
895 | } | 895 | } |
896 | 896 | ||
897 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 897 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
898 | return tempMenu; | 898 | return tempMenu; |
899 | 899 | ||
900 | 900 | ||
901 | } | 901 | } |
902 | void KOTodoView::changedCategories(int index) | 902 | void KOTodoView::changedCategories(int index) |
903 | { | 903 | { |
904 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 904 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
905 | QStringList categories = mActiveItem->todo()->categories (); | 905 | QStringList categories = mActiveItem->todo()->categories (); |
906 | if (categories.find (mCategory[index]) != categories.end ()) | 906 | if (categories.find (mCategory[index]) != categories.end ()) |
907 | categories.remove (mCategory[index]); | 907 | categories.remove (mCategory[index]); |
908 | else | 908 | else |
909 | categories.insert (categories.end(), mCategory[index]); | 909 | categories.insert (categories.end(), mCategory[index]); |
910 | categories.sort (); | 910 | categories.sort (); |
911 | mActiveItem->todo()->setCategories (categories); | 911 | mActiveItem->todo()->setCategories (categories); |
912 | mActiveItem->construct(); | 912 | mActiveItem->construct(); |
913 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 913 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
914 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 914 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
915 | } | 915 | } |
916 | } | 916 | } |
917 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 917 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
918 | { | 918 | { |
919 | if ( pendingSubtodo != 0 ) { | 919 | if ( pendingSubtodo != 0 ) { |
920 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 920 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
921 | } | 921 | } |
922 | pendingSubtodo = 0; | 922 | pendingSubtodo = 0; |
923 | if (!item) { | 923 | if (!item) { |
924 | newTodo(); | 924 | newTodo(); |
925 | return; | 925 | return; |
926 | } | 926 | } |
927 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 927 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
928 | editItem( item ); | 928 | editItem( item ); |
929 | else | 929 | else |
930 | showItem( item , QPoint(), 0 ); | 930 | showItem( item , QPoint(), 0 ); |
931 | } | 931 | } |
932 | void KOTodoView::itemClicked(QListViewItem *item) | 932 | void KOTodoView::itemClicked(QListViewItem *item) |
933 | { | 933 | { |
934 | 934 | ||
935 | if (!item) { | 935 | if (!item) { |
936 | if ( pendingSubtodo != 0 ) { | 936 | if ( pendingSubtodo != 0 ) { |
937 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 937 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
938 | } | 938 | } |
939 | pendingSubtodo = 0; | 939 | pendingSubtodo = 0; |
940 | return; | 940 | return; |
941 | } | 941 | } |
942 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 942 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
943 | if ( pendingSubtodo != 0 ) { | 943 | if ( pendingSubtodo != 0 ) { |
944 | bool allowReparent = true; | 944 | bool allowReparent = true; |
945 | QListViewItem *par = item; | 945 | QListViewItem *par = item; |
946 | while ( par ) { | 946 | while ( par ) { |
947 | if ( par == pendingSubtodo ) { | 947 | if ( par == pendingSubtodo ) { |
948 | allowReparent = false; | 948 | allowReparent = false; |
949 | break; | 949 | break; |
950 | } | 950 | } |
951 | par = par->parent(); | 951 | par = par->parent(); |
952 | } | 952 | } |
953 | if ( !allowReparent ) { | 953 | if ( !allowReparent ) { |
954 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 954 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
955 | qDebug("Recursive reparenting not possible "); | 955 | qDebug("Recursive reparenting not possible "); |
956 | pendingSubtodo = 0; | 956 | pendingSubtodo = 0; |
957 | } else { | 957 | } else { |
958 | Todo* newParent = todoItem->todo(); | 958 | Todo* newParent = todoItem->todo(); |
959 | Todo* newSub = pendingSubtodo->todo(); | 959 | Todo* newSub = pendingSubtodo->todo(); |
960 | pendingSubtodo = 0; | 960 | pendingSubtodo = 0; |
961 | emit reparentTodoSignal( newParent,newSub ); | 961 | emit reparentTodoSignal( newParent,newSub ); |
962 | return; | 962 | return; |
963 | } | 963 | } |
964 | } | 964 | } |
965 | #if 0 | 965 | #if 0 |
966 | // handled by the item itself | 966 | // handled by the item itself |
967 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? | 967 | bool completed = todoItem->todo()->isCompleted(); // Completed or not? |
968 | qDebug("com %d ",completed ); | 968 | qDebug("com %d ",completed ); |
969 | qDebug("itemclicked "); | 969 | qDebug("itemclicked "); |
970 | if (todoItem->isOn()) { | 970 | if (todoItem->isOn()) { |
971 | qDebug("on "); | 971 | qDebug("on "); |
972 | if (!completed) { | 972 | if (!completed) { |
973 | qDebug("set true "); | 973 | qDebug("set true "); |
974 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 974 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
975 | } | 975 | } |
976 | } else { | 976 | } else { |
977 | qDebug("not on "); | 977 | qDebug("not on "); |
978 | if (completed) { | 978 | if (completed) { |
979 | qDebug("set false "); | 979 | qDebug("set false "); |
980 | todoItem->todo()->setCompleted(false); | 980 | todoItem->todo()->setCompleted(false); |
981 | } | 981 | } |
982 | } | 982 | } |
983 | #endif | 983 | #endif |
984 | } | 984 | } |
985 | 985 | ||
986 | void KOTodoView::setDocumentId( const QString &id ) | 986 | void KOTodoView::setDocumentId( const QString &id ) |
987 | { | 987 | { |
988 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 988 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
989 | 989 | ||
990 | mDocPrefs->setDoc( id ); | 990 | mDocPrefs->setDoc( id ); |
991 | } | 991 | } |
992 | 992 | ||
993 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 993 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
994 | { | 994 | { |
995 | if (!item) return; | 995 | if (!item) return; |
996 | 996 | ||
997 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 997 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
998 | 998 | ||
999 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 999 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1000 | 1000 | ||
1001 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1001 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1004 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1005 | { | 1005 | { |
1006 | mTodoListView->saveLayout(config,group); | 1006 | mTodoListView->saveLayout(config,group); |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1009 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1010 | { | 1010 | { |
1011 | mTodoListView->restoreLayout(config,group); | 1011 | mTodoListView->restoreLayout(config,group); |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | void KOTodoView::processSelectionChange() | 1014 | void KOTodoView::processSelectionChange() |
1015 | { | 1015 | { |
1016 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1016 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1017 | 1017 | ||
1018 | KOTodoViewItem *item = | 1018 | KOTodoViewItem *item = |
1019 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1019 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1020 | 1020 | ||
1021 | if ( !item ) { | 1021 | if ( !item ) { |
1022 | emit incidenceSelected( 0 ); | 1022 | emit incidenceSelected( 0 ); |
1023 | } else { | 1023 | } else { |
1024 | emit incidenceSelected( item->todo() ); | 1024 | emit incidenceSelected( item->todo() ); |
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | void KOTodoView::modified(bool b) | 1028 | void KOTodoView::modified(bool b) |
1029 | { | 1029 | { |
1030 | emit isModified(b); | 1030 | emit isModified(b); |
1031 | } | 1031 | } |
1032 | void KOTodoView::setTodoModified( Todo* todo ) | 1032 | void KOTodoView::setTodoModified( Todo* todo ) |
1033 | { | 1033 | { |
1034 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1034 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1035 | } | 1035 | } |
1036 | void KOTodoView::clearSelection() | 1036 | void KOTodoView::clearSelection() |
1037 | { | 1037 | { |
1038 | mTodoListView->selectAll( false ); | 1038 | mTodoListView->selectAll( false ); |
1039 | } | 1039 | } |
1040 | void KOTodoView::setAllOpen() | 1040 | void KOTodoView::setAllOpen() |
1041 | { | 1041 | { |
1042 | if ( isFlatDisplay ) { | 1042 | if ( isFlatDisplay ) { |
1043 | isFlatDisplay = false; | 1043 | isFlatDisplay = false; |
1044 | mPopupMenu->setItemChecked( 8,false ); | 1044 | mPopupMenu->setItemChecked( 8,false ); |
1045 | updateView(); | 1045 | updateView(); |
1046 | } | 1046 | } |
1047 | setOpen(mTodoListView->firstChild(), true); | 1047 | setOpen(mTodoListView->firstChild(), true); |
1048 | } | 1048 | } |
1049 | void KOTodoView::setAllClose() | 1049 | void KOTodoView::setAllClose() |
1050 | { | 1050 | { |
1051 | if ( isFlatDisplay ) { | 1051 | if ( isFlatDisplay ) { |
1052 | isFlatDisplay = false; | 1052 | isFlatDisplay = false; |
1053 | mPopupMenu->setItemChecked( 8,false ); | 1053 | mPopupMenu->setItemChecked( 8,false ); |
1054 | updateView(); | 1054 | updateView(); |
1055 | } | 1055 | } |
1056 | setOpen(mTodoListView->firstChild(), false); | 1056 | setOpen(mTodoListView->firstChild(), false); |
1057 | } | 1057 | } |
1058 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1058 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1059 | { | 1059 | { |
1060 | 1060 | ||
1061 | while ( item ) { | 1061 | while ( item ) { |
1062 | setOpen( item->firstChild(), setOpenI ); | 1062 | setOpen( item->firstChild(), setOpenI ); |
1063 | item->setOpen( setOpenI ); | 1063 | item->setOpen( setOpenI ); |
1064 | item = item->nextSibling(); | 1064 | item = item->nextSibling(); |
1065 | } | 1065 | } |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void KOTodoView::setAllFlat() | 1068 | void KOTodoView::setAllFlat() |
1069 | { | 1069 | { |
1070 | if ( isFlatDisplay ) { | 1070 | if ( isFlatDisplay ) { |
1071 | isFlatDisplay = false; | 1071 | isFlatDisplay = false; |
1072 | mPopupMenu->setItemChecked( 8,false ); | 1072 | mPopupMenu->setItemChecked( 8,false ); |
1073 | updateView(); | 1073 | updateView(); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | pendingSubtodo = 0; | 1076 | pendingSubtodo = 0; |
1077 | if ( mBlockUpdate ) { | 1077 | if ( mBlockUpdate ) { |
1078 | return; | 1078 | return; |
1079 | } | 1079 | } |
1080 | mPopupMenu->setItemChecked( 8,true ); | 1080 | mPopupMenu->setItemChecked( 8,true ); |
1081 | isFlatDisplay = true; | 1081 | isFlatDisplay = true; |
1082 | QPtrList<Todo> todoList = calendar()->todos(); | 1082 | QPtrList<Todo> todoList = calendar()->todos(); |
1083 | mTodoMap.clear(); | 1083 | mTodoMap.clear(); |
1084 | mTodoListView->clear(); | 1084 | mTodoListView->clear(); |
1085 | Todo *todo; | 1085 | Todo *todo; |
1086 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1086 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1087 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1087 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1088 | mTodoMap.insert(todo,todoItem); | 1088 | mTodoMap.insert(todo,todoItem); |
1089 | } | 1089 | } |
1090 | mTodoListView->setFocus(); | 1090 | mTodoListView->setFocus(); |
1091 | processSelectionChange(); | 1091 | processSelectionChange(); |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | void KOTodoView::purgeCompleted() | 1094 | void KOTodoView::purgeCompleted() |
1095 | { | 1095 | { |
1096 | emit purgeCompletedSignal(); | 1096 | emit purgeCompletedSignal(); |
1097 | } | 1097 | } |
1098 | void KOTodoView::toggleQuickTodo() | 1098 | void KOTodoView::toggleQuickTodo() |
1099 | { | 1099 | { |
1100 | if ( mQuickAdd->isVisible() ) { | 1100 | if ( mQuickAdd->isVisible() ) { |
1101 | mQuickAdd->hide(); | 1101 | mQuickAdd->hide(); |
1102 | KOPrefs::instance()->mEnableQuickTodo = false; | 1102 | KOPrefs::instance()->mEnableQuickTodo = false; |
1103 | } | 1103 | } |
1104 | else { | 1104 | else { |
1105 | mQuickAdd->show(); | 1105 | mQuickAdd->show(); |
1106 | KOPrefs::instance()->mEnableQuickTodo = true; | 1106 | KOPrefs::instance()->mEnableQuickTodo = true; |
1107 | } | 1107 | } |
1108 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1108 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1109 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1109 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | void KOTodoView::toggleRunning() | 1112 | void KOTodoView::toggleRunning() |
1113 | { | 1113 | { |
1114 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1114 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1115 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1115 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1116 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1116 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1117 | updateView(); | 1117 | updateView(); |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | void KOTodoView::toggleCompleted() | 1120 | void KOTodoView::toggleCompleted() |
1121 | { | 1121 | { |
1122 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1122 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1123 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1123 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1124 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1124 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1125 | updateView(); | 1125 | updateView(); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | void KOTodoView::addQuickTodo() | 1128 | void KOTodoView::addQuickTodo() |
1129 | { | 1129 | { |
1130 | Todo *todo = new Todo(); | 1130 | Todo *todo = new Todo(); |
1131 | todo->setSummary(mQuickAdd->text()); | 1131 | todo->setSummary(mQuickAdd->text()); |
1132 | todo->setOrganizer(KOPrefs::instance()->email()); | 1132 | todo->setOrganizer(KOPrefs::instance()->email()); |
1133 | CalFilter * cf = mCalendar->filter(); | 1133 | CalFilter * cf = mCalendar->filter(); |
1134 | if ( cf ) { | 1134 | if ( cf ) { |
1135 | if ( cf->isEnabled()&& cf->showCategories()) { | 1135 | if ( cf->isEnabled()&& cf->showCategories()) { |
1136 | todo->setCategories(cf->categoryList()); | 1136 | todo->setCategories(cf->categoryList()); |
1137 | } | 1137 | } |
1138 | if ( cf->isEnabled() ) | 1138 | if ( cf->isEnabled() ) |
1139 | todo->setSecrecy( cf->getSecrecy()); | 1139 | todo->setSecrecy( cf->getSecrecy()); |
1140 | } | 1140 | } |
1141 | mCalendar->addTodo(todo); | 1141 | mCalendar->addTodo(todo); |
1142 | mQuickAdd->setText(""); | 1142 | mQuickAdd->setText(""); |
1143 | todoModified (todo, KOGlobals::EVENTADDED ); | 1143 | todoModified (todo, KOGlobals::EVENTADDED ); |
1144 | updateView(); | 1144 | updateView(); |
1145 | } | 1145 | } |
1146 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1146 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1147 | { | 1147 | { |
1148 | // e->ignore(); | 1148 | // e->ignore(); |
1149 | //return; | 1149 | //return; |
1150 | //qDebug("KOTodoView::keyPressEvent "); | 1150 | //qDebug("KOTodoView::keyPressEvent "); |
1151 | switch ( e->key() ) { | 1151 | switch ( e->key() ) { |
1152 | case Qt::Key_Down: | 1152 | case Qt::Key_Down: |
1153 | case Qt::Key_Up: | 1153 | case Qt::Key_Up: |
1154 | QWidget::keyPressEvent ( e ); | 1154 | QWidget::keyPressEvent ( e ); |
1155 | break; | 1155 | break; |
1156 | 1156 | ||
1157 | case Qt::Key_Q: | 1157 | case Qt::Key_Q: |
1158 | toggleQuickTodo(); | 1158 | toggleQuickTodo(); |
1159 | break; | 1159 | break; |
1160 | case Qt::Key_U: | 1160 | case Qt::Key_U: |
1161 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1161 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1162 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1162 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1163 | unparentTodo(); | 1163 | unparentTodo(); |
1164 | e->accept(); | 1164 | e->accept(); |
1165 | } else | 1165 | } else |
1166 | e->ignore(); | 1166 | e->ignore(); |
1167 | break; | 1167 | break; |
1168 | case Qt::Key_S: | 1168 | case Qt::Key_S: |
1169 | if ( e->state() == Qt::ControlButton ) { | 1169 | if ( e->state() == Qt::ControlButton ) { |
1170 | e->ignore(); | 1170 | e->ignore(); |
1171 | break; | 1171 | break; |
1172 | } | 1172 | } |
1173 | if ( e->state() == Qt::ShiftButton ) { | 1173 | if ( e->state() == Qt::ShiftButton ) { |
1174 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1174 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1175 | reparentTodo(); | 1175 | reparentTodo(); |
1176 | e->accept(); | 1176 | e->accept(); |
1177 | } else | 1177 | } else |
1178 | e->ignore(); | 1178 | e->ignore(); |
1179 | break; | 1179 | break; |
1180 | case Qt::Key_P: | 1180 | case Qt::Key_P: |
1181 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1181 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1182 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1182 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1183 | if ( pendingSubtodo ) | 1183 | if ( pendingSubtodo ) |
1184 | itemClicked(mActiveItem); | 1184 | itemClicked(mActiveItem); |
1185 | e->accept(); | 1185 | e->accept(); |
1186 | } else | 1186 | } else |
1187 | e->ignore(); | 1187 | e->ignore(); |
1188 | break; | 1188 | break; |
1189 | case Qt::Key_Escape: | 1189 | case Qt::Key_Escape: |
1190 | if ( pendingSubtodo ) { | 1190 | if ( pendingSubtodo ) { |
1191 | itemClicked(0); | 1191 | itemClicked(0); |
1192 | e->accept(); | 1192 | e->accept(); |
1193 | } else | 1193 | } else |
1194 | e->ignore(); | 1194 | e->ignore(); |
1195 | break; | 1195 | break; |
1196 | default: | 1196 | default: |
1197 | e->ignore(); | 1197 | e->ignore(); |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | if ( true ) { | 1200 | if ( true ) { |
1201 | if ( e->key() == Qt::Key_I ) { | 1201 | if ( e->key() == Qt::Key_I ) { |
1202 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1202 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1203 | if ( cn ) { | 1203 | if ( cn ) { |
1204 | mActiveItem = cn; | 1204 | mActiveItem = cn; |
1205 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1205 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1206 | if ( ci ){ | 1206 | if ( ci ){ |
1207 | showTodo(); | 1207 | showTodo(); |
1208 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1208 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1209 | if ( cn ) { | 1209 | if ( cn ) { |
1210 | mTodoListView->setCurrentItem ( cn ); | 1210 | mTodoListView->setCurrentItem ( cn ); |
1211 | mTodoListView->ensureItemVisible ( cn ); | 1211 | mTodoListView->ensureItemVisible ( cn ); |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | } | 1214 | } |
1215 | } | 1215 | } |
1216 | e->accept(); | 1216 | e->accept(); |
1217 | 1217 | ||
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | } | 1222 | } |
1223 | void KOTodoView::updateTodo( Todo * t, int type ) | 1223 | void KOTodoView::updateTodo( Todo * t, int type ) |
1224 | { | 1224 | { |
1225 | if ( mBlockUpdate) | 1225 | if ( mBlockUpdate) |
1226 | return; | 1226 | return; |
1227 | 1227 | ||
1228 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1228 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1229 | itemIterator = mTodoMap.find(t); | 1229 | itemIterator = mTodoMap.find(t); |
1230 | if (itemIterator != mTodoMap.end()) { | 1230 | if (itemIterator != mTodoMap.end()) { |
1231 | (*itemIterator)->construct(); | 1231 | (*itemIterator)->construct(); |
1232 | } else { | 1232 | } else { |
1233 | if ( type == KOGlobals::EVENTADDED ) { | 1233 | if ( type == KOGlobals::EVENTADDED ) { |
1234 | insertTodoItem( t ); | 1234 | insertTodoItem( t ); |
1235 | } | 1235 | } |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | void KOTodoView::todoModified(Todo * t , int p ) | 1240 | void KOTodoView::todoModified(Todo * t , int p ) |
1241 | { | 1241 | { |
1242 | mBlockUpdate = true; | 1242 | mBlockUpdate = true; |
1243 | emit todoModifiedSignal ( t, p ); | 1243 | emit todoModifiedSignal ( t, p ); |
1244 | mBlockUpdate = false; | 1244 | mBlockUpdate = false; |
1245 | } | 1245 | } |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 4c03f9a..35774d6 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -1,645 +1,647 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001 | 4 | Copyright (c) 2001 |
5 | Cornelius Schumacher <schumacher@kde.org> | 5 | Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void KOViewManager::showDateView( int view, QDate date) | 102 | void KOViewManager::showDateView( int view, QDate date) |
103 | { | 103 | { |
104 | 104 | ||
105 | //qDebug("date %d %s", view, date.toString().latin1()); | 105 | //qDebug("date %d %s", view, date.toString().latin1()); |
106 | #if 0 | 106 | #if 0 |
107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); | 108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); |
109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); | 109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); |
110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); | 110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); |
111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
112 | #endif | 112 | #endif |
113 | if ( view == 3 ) { | 113 | if ( view == 3 ) { |
114 | mMainView->showDay( date ); | 114 | mMainView->showDay( date ); |
115 | } else if (view == 4 ) { | 115 | } else if (view == 4 ) { |
116 | mMainView->dateNavigator()->selectDates( date, 7 ); | 116 | mMainView->dateNavigator()->selectDates( date, 7 ); |
117 | } else if (view == 5 ) { | 117 | } else if (view == 5 ) { |
118 | mMainView->dateNavigator()->selectDates( date, 14); | 118 | mMainView->dateNavigator()->selectDates( date, 14); |
119 | } else if (view == 6 ) { | 119 | } else if (view == 6 ) { |
120 | showMonthView(); | 120 | mMainView->dateNavigator()->blockSignals( true ); |
121 | mMainView->dateNavigator()->selectMonthByDate( date ); | 121 | mMainView->dateNavigator()->selectMonthByDate( date ); |
122 | mMainView->dateNavigator()->selectDate( date ); | 122 | mMainView->dateNavigator()->selectDate( date ); |
123 | mMainView->dateNavigator()->blockSignals( false ); | ||
124 | showMonthView(); | ||
123 | } else if (view == 7 ) { | 125 | } else if (view == 7 ) { |
124 | mMainView->dateNavigator()->selectDate( date ); | 126 | mMainView->dateNavigator()->selectDate( date ); |
125 | showJournalView(); | 127 | showJournalView(); |
126 | } else if (view == 8 ) { | 128 | } else if (view == 8 ) { |
127 | globalFlagBlockAgenda = 1; | 129 | globalFlagBlockAgenda = 1; |
128 | if ( mCurrentAgendaView != 3 ) | 130 | if ( mCurrentAgendaView != 3 ) |
129 | mCurrentAgendaView = -1; | 131 | mCurrentAgendaView = -1; |
130 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 132 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
131 | globalFlagBlockAgenda = 2; | 133 | globalFlagBlockAgenda = 2; |
132 | mMainView->dateNavigator()->selectDates( date , | 134 | mMainView->dateNavigator()->selectDates( date , |
133 | KOPrefs::instance()->mNextXDays ); | 135 | KOPrefs::instance()->mNextXDays ); |
134 | mFlagShowNextxDays = true; | 136 | mFlagShowNextxDays = true; |
135 | mCurrentAgendaView = 3 ; | 137 | mCurrentAgendaView = 3 ; |
136 | } | 138 | } |
137 | 139 | ||
138 | #if 0 | 140 | #if 0 |
139 | dateNavigator()->blockSignals( true ); | 141 | dateNavigator()->blockSignals( true ); |
140 | dateNavigator()->selectDate( d ); | 142 | dateNavigator()->selectDate( d ); |
141 | dateNavigator()->blockSignals( false ); | 143 | dateNavigator()->blockSignals( false ); |
142 | mViewManager->showDayView(); | 144 | mViewManager->showDayView(); |
143 | #endif | 145 | #endif |
144 | 146 | ||
145 | } | 147 | } |
146 | 148 | ||
147 | 149 | ||
148 | 150 | ||
149 | void KOViewManager::writeSettings(KConfig *config) | 151 | void KOViewManager::writeSettings(KConfig *config) |
150 | { | 152 | { |
151 | config->setGroup("General"); | 153 | config->setGroup("General"); |
152 | 154 | ||
153 | QString view; | 155 | QString view; |
154 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 156 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
155 | else if (mCurrentView == mMonthView) view = "Month"; | 157 | else if (mCurrentView == mMonthView) view = "Month"; |
156 | else if (mCurrentView == mListView) view = "List"; | 158 | else if (mCurrentView == mListView) view = "List"; |
157 | else if (mCurrentView == mJournalView) view = "Journal"; | 159 | else if (mCurrentView == mJournalView) view = "Journal"; |
158 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 160 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
159 | else if (mCurrentView == mTodoView) view = "Todo"; | 161 | else if (mCurrentView == mTodoView) view = "Todo"; |
160 | else view = "Agenda"; | 162 | else view = "Agenda"; |
161 | 163 | ||
162 | config->writeEntry("Current View",view); | 164 | config->writeEntry("Current View",view); |
163 | 165 | ||
164 | if (mAgendaView) { | 166 | if (mAgendaView) { |
165 | mAgendaView->writeSettings(config); | 167 | mAgendaView->writeSettings(config); |
166 | } | 168 | } |
167 | if (mTimeSpanView) { | 169 | if (mTimeSpanView) { |
168 | mTimeSpanView->writeSettings(config); | 170 | mTimeSpanView->writeSettings(config); |
169 | } | 171 | } |
170 | if (mListView) { | 172 | if (mListView) { |
171 | mListView->writeSettings(config); | 173 | mListView->writeSettings(config); |
172 | } | 174 | } |
173 | if (mTodoView) { | 175 | if (mTodoView) { |
174 | mTodoView->saveLayout(config,"Todo View"); | 176 | mTodoView->saveLayout(config,"Todo View"); |
175 | } | 177 | } |
176 | } | 178 | } |
177 | 179 | ||
178 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 180 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
179 | { | 181 | { |
180 | 182 | ||
181 | //mFlagShowNextxDays = false; | 183 | //mFlagShowNextxDays = false; |
182 | //if(view == mCurrentView) return; | 184 | //if(view == mCurrentView) return; |
183 | if ( view == 0 ) { | 185 | if ( view == 0 ) { |
184 | view = mCurrentView; | 186 | view = mCurrentView; |
185 | if ( view == 0 ) | 187 | if ( view == 0 ) |
186 | return; | 188 | return; |
187 | } | 189 | } |
188 | bool full = fullScreen; | 190 | bool full = fullScreen; |
189 | if(view == mCurrentView && view != mWhatsNextView ) { | 191 | if(view == mCurrentView && view != mWhatsNextView ) { |
190 | if ( mCurrentAgendaView < 0 ) | 192 | if ( mCurrentAgendaView < 0 ) |
191 | return; | 193 | return; |
192 | full = mMainView->leftFrame()->isVisible(); | 194 | full = mMainView->leftFrame()->isVisible(); |
193 | } else { | 195 | } else { |
194 | mCurrentView = view; | 196 | mCurrentView = view; |
195 | // bool full = fullScreen; | 197 | // bool full = fullScreen; |
196 | bool isFull = !mMainView->leftFrame()->isVisible(); | 198 | bool isFull = !mMainView->leftFrame()->isVisible(); |
197 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 199 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
198 | full = true; | 200 | full = true; |
199 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 201 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
200 | full = false; | 202 | full = false; |
201 | } | 203 | } |
202 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 204 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
203 | //raiseCurrentView( full ); | 205 | //raiseCurrentView( full ); |
204 | mMainView->processIncidenceSelection( 0 ); | 206 | mMainView->processIncidenceSelection( 0 ); |
205 | mMainView->updateView(); | 207 | mMainView->updateView(); |
206 | raiseCurrentView( full ); | 208 | raiseCurrentView( full ); |
207 | mMainView->adaptNavigationUnits(); | 209 | mMainView->adaptNavigationUnits(); |
208 | } | 210 | } |
209 | 211 | ||
210 | void KOViewManager::raiseCurrentView( bool fullScreen ) | 212 | void KOViewManager::raiseCurrentView( bool fullScreen ) |
211 | { | 213 | { |
212 | mCurrentAgendaView = 0; | 214 | mCurrentAgendaView = 0; |
213 | int wid = mMainView->width() ; | 215 | int wid = mMainView->width() ; |
214 | int hei = mMainView->height(); | 216 | int hei = mMainView->height(); |
215 | if ( mCurrentView == mMonthView ) { | 217 | if ( mCurrentView == mMonthView ) { |
216 | mMainView->navigatorBar()->show(); | 218 | mMainView->navigatorBar()->show(); |
217 | hei -= mMainView->navigatorBar()->sizeHint().height(); | 219 | hei -= mMainView->navigatorBar()->sizeHint().height(); |
218 | //mMainView->navigatorBar()->hide(); | 220 | //mMainView->navigatorBar()->hide(); |
219 | } else { | 221 | } else { |
220 | mMainView->navigatorBar()->hide(); | 222 | mMainView->navigatorBar()->hide(); |
221 | } | 223 | } |
222 | if ( fullScreen ) { | 224 | if ( fullScreen ) { |
223 | mMainView->leftFrame()->hide(); | 225 | mMainView->leftFrame()->hide(); |
224 | } else { | 226 | } else { |
225 | mMainView->leftFrame()->show(); | 227 | mMainView->leftFrame()->show(); |
226 | if ( KOPrefs::instance()->mVerticalScreen ) | 228 | if ( KOPrefs::instance()->mVerticalScreen ) |
227 | hei -= mMainView->leftFrame()->height(); | 229 | hei -= mMainView->leftFrame()->height(); |
228 | else | 230 | else |
229 | wid -= mMainView->leftFrame()->width(); | 231 | wid -= mMainView->leftFrame()->width(); |
230 | } | 232 | } |
231 | emit signalFullScreen( !fullScreen ); | 233 | emit signalFullScreen( !fullScreen ); |
232 | if ( globalFlagBlockAgenda == 5 ) { | 234 | if ( globalFlagBlockAgenda == 5 ) { |
233 | globalFlagBlockAgenda = 4; | 235 | globalFlagBlockAgenda = 4; |
234 | globalFlagBlockAgendaItemPaint = 1; | 236 | globalFlagBlockAgendaItemPaint = 1; |
235 | } | 237 | } |
236 | mMainView->viewStack()->raiseWidget(mCurrentView); | 238 | mMainView->viewStack()->raiseWidget(mCurrentView); |
237 | if ( globalFlagBlockAgenda == 4 ) { | 239 | if ( globalFlagBlockAgenda == 4 ) { |
238 | if ( mCurrentView == mAgendaView ) { | 240 | if ( mCurrentView == mAgendaView ) { |
239 | //globalFlagBlockAgenda =1 ; | 241 | //globalFlagBlockAgenda =1 ; |
240 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 242 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
241 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); | 243 | mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); |
242 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 244 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
243 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); | 245 | mAgendaView->setStartHour( QTime::currentTime ().hour() ); |
244 | qApp->processEvents(); | 246 | qApp->processEvents(); |
245 | //qDebug("qApp->processEvents() "); | 247 | //qDebug("qApp->processEvents() "); |
246 | globalFlagBlockAgenda = 0; | 248 | globalFlagBlockAgenda = 0; |
247 | mAgendaView->repaintAgenda(); | 249 | mAgendaView->repaintAgenda(); |
248 | 250 | ||
249 | } | 251 | } |
250 | globalFlagBlockAgenda = 0; | 252 | globalFlagBlockAgenda = 0; |
251 | } | 253 | } |
252 | emit signalAgendaView( mCurrentView == mAgendaView ); | 254 | emit signalAgendaView( mCurrentView == mAgendaView ); |
253 | //qDebug("raiseCurrentView ende "); | 255 | //qDebug("raiseCurrentView ende "); |
254 | 256 | ||
255 | } | 257 | } |
256 | 258 | ||
257 | void KOViewManager::updateView() | 259 | void KOViewManager::updateView() |
258 | { | 260 | { |
259 | // qDebug("KOViewManager::updateView() "); | 261 | // qDebug("KOViewManager::updateView() "); |
260 | // if we are updating mTodoView, we get endless recursion | 262 | // if we are updating mTodoView, we get endless recursion |
261 | if ( mTodoView == mCurrentView ) | 263 | if ( mTodoView == mCurrentView ) |
262 | return; | 264 | return; |
263 | if ( mCurrentView ) mCurrentView->updateView(); | 265 | if ( mCurrentView ) mCurrentView->updateView(); |
264 | 266 | ||
265 | } | 267 | } |
266 | 268 | ||
267 | void KOViewManager::updateView(const QDate &start, const QDate &end) | 269 | void KOViewManager::updateView(const QDate &start, const QDate &end) |
268 | { | 270 | { |
269 | // kdDebug() << "KOViewManager::updateView()" << endl; | 271 | // kdDebug() << "KOViewManager::updateView()" << endl; |
270 | 272 | ||
271 | if (mCurrentView) mCurrentView->showDates(start, end); | 273 | if (mCurrentView) mCurrentView->showDates(start, end); |
272 | 274 | ||
273 | if (mTodoView) mTodoView->updateView(); | 275 | if (mTodoView) mTodoView->updateView(); |
274 | } | 276 | } |
275 | 277 | ||
276 | 278 | ||
277 | void KOViewManager::updateWNview() | 279 | void KOViewManager::updateWNview() |
278 | { | 280 | { |
279 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) | 281 | if ( mCurrentView == mWhatsNextView && mWhatsNextView ) |
280 | mWhatsNextView->updateView(); | 282 | mWhatsNextView->updateView(); |
281 | 283 | ||
282 | } | 284 | } |
283 | void KOViewManager::showWhatsNextView() | 285 | void KOViewManager::showWhatsNextView() |
284 | { | 286 | { |
285 | if (!mWhatsNextView) { | 287 | if (!mWhatsNextView) { |
286 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), | 288 | mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), |
287 | "KOViewManager::WhatsNextView"); | 289 | "KOViewManager::WhatsNextView"); |
288 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); | 290 | mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); |
289 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); | 291 | connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); |
290 | addView(mWhatsNextView); | 292 | addView(mWhatsNextView); |
291 | connect(this, SIGNAL( printWNV() ), | 293 | connect(this, SIGNAL( printWNV() ), |
292 | mWhatsNextView, SLOT( printMe() ) ); | 294 | mWhatsNextView, SLOT( printMe() ) ); |
293 | } | 295 | } |
294 | globalFlagBlockAgenda = 1; | 296 | globalFlagBlockAgenda = 1; |
295 | showView(mWhatsNextView, true ); | 297 | showView(mWhatsNextView, true ); |
296 | //mWhatsNextView->updateView(); | 298 | //mWhatsNextView->updateView(); |
297 | 299 | ||
298 | } | 300 | } |
299 | 301 | ||
300 | void KOViewManager::showListView() | 302 | void KOViewManager::showListView() |
301 | { | 303 | { |
302 | if (!mListView) { | 304 | if (!mListView) { |
303 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); | 305 | mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); |
304 | addView(mListView); | 306 | addView(mListView); |
305 | 307 | ||
306 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), | 308 | connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), |
307 | mMainView, SLOT(showIncidence(Incidence *))); | 309 | mMainView, SLOT(showIncidence(Incidence *))); |
308 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), | 310 | connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), |
309 | mMainView, SLOT(editIncidence(Incidence *))); | 311 | mMainView, SLOT(editIncidence(Incidence *))); |
310 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 312 | connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
311 | mMainView, SLOT(deleteIncidence(Incidence *))); | 313 | mMainView, SLOT(deleteIncidence(Incidence *))); |
312 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), | 314 | connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), |
313 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 315 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
314 | connect( mListView, SIGNAL( signalNewEvent() ), | 316 | connect( mListView, SIGNAL( signalNewEvent() ), |
315 | mMainView, SLOT( newEvent() ) ); | 317 | mMainView, SLOT( newEvent() ) ); |
316 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); | 318 | connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); |
317 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 319 | connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
318 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 320 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
319 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 321 | connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
320 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 322 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
321 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 323 | connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
322 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 324 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
323 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 325 | connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
324 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 326 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
325 | } | 327 | } |
326 | // bool temp = mFlagShowNextxDays; | 328 | // bool temp = mFlagShowNextxDays; |
327 | //globalFlagBlockPainting = true; | 329 | //globalFlagBlockPainting = true; |
328 | globalFlagBlockAgenda = 1; | 330 | globalFlagBlockAgenda = 1; |
329 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { | 331 | if ( KOPrefs::instance()->mListViewMonthTimespan ) { |
330 | mMainView->setBlockShowDates( true ); | 332 | mMainView->setBlockShowDates( true ); |
331 | mMainView->dateNavigator()->selectMonth(); | 333 | mMainView->dateNavigator()->selectMonth(); |
332 | mMainView->setBlockShowDates( false ); | 334 | mMainView->setBlockShowDates( false ); |
333 | } | 335 | } |
334 | showView(mListView, KOPrefs::instance()->mFullViewTodo); | 336 | showView(mListView, KOPrefs::instance()->mFullViewTodo); |
335 | //mFlagShowNextxDays = temp; | 337 | //mFlagShowNextxDays = temp; |
336 | } | 338 | } |
337 | 339 | ||
338 | void KOViewManager::showAgendaView( bool fullScreen ) | 340 | void KOViewManager::showAgendaView( bool fullScreen ) |
339 | { | 341 | { |
340 | 342 | ||
341 | mMainView->dialogManager()->hideSearchDialog(); | 343 | mMainView->dialogManager()->hideSearchDialog(); |
342 | // qDebug("KOViewManager::showAgendaView "); | 344 | // qDebug("KOViewManager::showAgendaView "); |
343 | bool full; | 345 | bool full; |
344 | full = fullScreen; | 346 | full = fullScreen; |
345 | if (!mAgendaView) { | 347 | if (!mAgendaView) { |
346 | full = false; | 348 | full = false; |
347 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); | 349 | mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); |
348 | addView(mAgendaView); | 350 | addView(mAgendaView); |
349 | #ifndef DESKTOP_VERSION | 351 | #ifndef DESKTOP_VERSION |
350 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); | 352 | QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); |
351 | #endif | 353 | #endif |
352 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), | 354 | connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), |
353 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); | 355 | mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); |
354 | 356 | ||
355 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW | 357 | // SIGNALS/SLOTS FOR DAY/WEEK VIEW |
356 | 358 | ||
357 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); | 359 | connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); |
358 | 360 | ||
359 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), | 361 | connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), |
360 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); | 362 | mMainView, SLOT(newTodoDateTime(QDateTime,bool))); |
361 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), | 363 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), |
362 | mMainView, SLOT(newEvent(QDateTime))); | 364 | mMainView, SLOT(newEvent(QDateTime))); |
363 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), | 365 | connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), |
364 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); | 366 | mMainView, SLOT(newEvent(QDateTime,QDateTime))); |
365 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), | 367 | connect(mAgendaView,SIGNAL(newEventSignal(QDate)), |
366 | mMainView, SLOT(newEvent(QDate))); | 368 | mMainView, SLOT(newEvent(QDate))); |
367 | 369 | ||
368 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), | 370 | connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), |
369 | mMainView, SLOT(editIncidence(Incidence *))); | 371 | mMainView, SLOT(editIncidence(Incidence *))); |
370 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), | 372 | connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), |
371 | mMainView, SLOT(showIncidence(Incidence *))); | 373 | mMainView, SLOT(showIncidence(Incidence *))); |
372 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 374 | connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
373 | mMainView, SLOT(deleteIncidence(Incidence *))); | 375 | mMainView, SLOT(deleteIncidence(Incidence *))); |
374 | 376 | ||
375 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), | 377 | connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), |
376 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 378 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
377 | 379 | ||
378 | connect(mAgendaView, SIGNAL( toggleExpand() ), | 380 | connect(mAgendaView, SIGNAL( toggleExpand() ), |
379 | mMainView, SLOT( toggleExpand() ) ); | 381 | mMainView, SLOT( toggleExpand() ) ); |
380 | 382 | ||
381 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), | 383 | connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), |
382 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); | 384 | mAgendaView, SLOT( setExpandedButton( bool ) ) ); |
383 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), | 385 | connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), |
384 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; | 386 | mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; |
385 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), | 387 | connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), |
386 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; | 388 | mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; |
387 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); | 389 | connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); |
388 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, | 390 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, |
389 | SLOT( updateTodo( Todo *, int ) ) ); | 391 | SLOT( updateTodo( Todo *, int ) ) ); |
390 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), | 392 | connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), |
391 | mMainView, SIGNAL( todoModified( Todo *, int ))); | 393 | mMainView, SIGNAL( todoModified( Todo *, int ))); |
392 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 394 | connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
393 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 395 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
394 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 396 | connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
395 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 397 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
396 | mAgendaView->readSettings(); | 398 | mAgendaView->readSettings(); |
397 | mAgendaView->updateConfig(); | 399 | mAgendaView->updateConfig(); |
398 | } | 400 | } |
399 | 401 | ||
400 | showView( mAgendaView, full); | 402 | showView( mAgendaView, full); |
401 | 403 | ||
402 | } | 404 | } |
403 | 405 | ||
404 | void KOViewManager::showDayView() | 406 | void KOViewManager::showDayView() |
405 | { | 407 | { |
406 | mFlagShowNextxDays = false; | 408 | mFlagShowNextxDays = false; |
407 | globalFlagBlockLabel = 1; | 409 | globalFlagBlockLabel = 1; |
408 | globalFlagBlockAgenda = 1; | 410 | globalFlagBlockAgenda = 1; |
409 | if ( mCurrentAgendaView != 1 ) | 411 | if ( mCurrentAgendaView != 1 ) |
410 | mCurrentAgendaView = -1; | 412 | mCurrentAgendaView = -1; |
411 | showAgendaView(); | 413 | showAgendaView(); |
412 | qApp->processEvents(); | 414 | qApp->processEvents(); |
413 | globalFlagBlockAgenda = 2; | 415 | globalFlagBlockAgenda = 2; |
414 | globalFlagBlockLabel = 0; | 416 | globalFlagBlockLabel = 0; |
415 | mMainView->dateNavigator()->selectDates( 1 ); | 417 | mMainView->dateNavigator()->selectDates( 1 ); |
416 | mCurrentAgendaView = 1 ; | 418 | mCurrentAgendaView = 1 ; |
417 | 419 | ||
418 | } | 420 | } |
419 | 421 | ||
420 | void KOViewManager::showWorkWeekView() | 422 | void KOViewManager::showWorkWeekView() |
421 | { | 423 | { |
422 | mFlagShowNextxDays = false; | 424 | mFlagShowNextxDays = false; |
423 | globalFlagBlockAgenda = 1; | 425 | globalFlagBlockAgenda = 1; |
424 | globalFlagBlockLabel = 1; | 426 | globalFlagBlockLabel = 1; |
425 | if ( mCurrentAgendaView != 5 ) | 427 | if ( mCurrentAgendaView != 5 ) |
426 | mCurrentAgendaView = -1; | 428 | mCurrentAgendaView = -1; |
427 | showAgendaView(); | 429 | showAgendaView(); |
428 | qApp->processEvents(); | 430 | qApp->processEvents(); |
429 | globalFlagBlockAgenda = 2; | 431 | globalFlagBlockAgenda = 2; |
430 | globalFlagBlockLabel = 0; | 432 | globalFlagBlockLabel = 0; |
431 | mMainView->dateNavigator()->selectWorkWeek(); | 433 | mMainView->dateNavigator()->selectWorkWeek(); |
432 | mCurrentAgendaView = 5 ; | 434 | mCurrentAgendaView = 5 ; |
433 | 435 | ||
434 | } | 436 | } |
435 | 437 | ||
436 | void KOViewManager::showWeekView() | 438 | void KOViewManager::showWeekView() |
437 | { | 439 | { |
438 | /* | 440 | /* |
439 | globalFlagBlockAgenda = 2; | 441 | globalFlagBlockAgenda = 2; |
440 | qDebug("4globalFlagBlockAgenda = 2; "); | 442 | qDebug("4globalFlagBlockAgenda = 2; "); |
441 | //globalFlagBlockPainting = true; | 443 | //globalFlagBlockPainting = true; |
442 | mMainView->dateNavigator()->selectWeek(); | 444 | mMainView->dateNavigator()->selectWeek(); |
443 | showAgendaView(); | 445 | showAgendaView(); |
444 | */ | 446 | */ |
445 | 447 | ||
446 | 448 | ||
447 | mFlagShowNextxDays = false; | 449 | mFlagShowNextxDays = false; |
448 | globalFlagBlockAgenda = 1; | 450 | globalFlagBlockAgenda = 1; |
449 | globalFlagBlockLabel = 1; | 451 | globalFlagBlockLabel = 1; |
450 | if ( mCurrentAgendaView != 7 ) | 452 | if ( mCurrentAgendaView != 7 ) |
451 | mCurrentAgendaView = -1; | 453 | mCurrentAgendaView = -1; |
452 | showAgendaView(); | 454 | showAgendaView(); |
453 | qApp->processEvents(); | 455 | qApp->processEvents(); |
454 | globalFlagBlockAgenda = 2; | 456 | globalFlagBlockAgenda = 2; |
455 | globalFlagBlockLabel = 0; | 457 | globalFlagBlockLabel = 0; |
456 | mMainView->dateNavigator()->selectWeek(); | 458 | mMainView->dateNavigator()->selectWeek(); |
457 | mCurrentAgendaView = 7 ; | 459 | mCurrentAgendaView = 7 ; |
458 | } | 460 | } |
459 | 461 | ||
460 | void KOViewManager::showNextXView() | 462 | void KOViewManager::showNextXView() |
461 | { | 463 | { |
462 | 464 | ||
463 | globalFlagBlockAgenda = 1; | 465 | globalFlagBlockAgenda = 1; |
464 | if ( mCurrentAgendaView != 3 ) | 466 | if ( mCurrentAgendaView != 3 ) |
465 | mCurrentAgendaView = -1; | 467 | mCurrentAgendaView = -1; |
466 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 468 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
467 | globalFlagBlockAgenda = 2; | 469 | globalFlagBlockAgenda = 2; |
468 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), | 470 | mMainView->dateNavigator()->selectDates( QDate::currentDate(), |
469 | KOPrefs::instance()->mNextXDays ); | 471 | KOPrefs::instance()->mNextXDays ); |
470 | mFlagShowNextxDays = true; | 472 | mFlagShowNextxDays = true; |
471 | mCurrentAgendaView = 3 ; | 473 | mCurrentAgendaView = 3 ; |
472 | } | 474 | } |
473 | bool KOViewManager::showsNextDays() | 475 | bool KOViewManager::showsNextDays() |
474 | { | 476 | { |
475 | return mFlagShowNextxDays; | 477 | return mFlagShowNextxDays; |
476 | } | 478 | } |
477 | void KOViewManager::showMonthView() | 479 | void KOViewManager::showMonthView() |
478 | { | 480 | { |
479 | if (!mMonthView) { | 481 | if (!mMonthView) { |
480 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); | 482 | mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); |
481 | 483 | ||
482 | addView(mMonthView); | 484 | addView(mMonthView); |
483 | // mMonthView->show(); | 485 | // mMonthView->show(); |
484 | // SIGNALS/SLOTS FOR MONTH VIEW | 486 | // SIGNALS/SLOTS FOR MONTH VIEW |
485 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), | 487 | connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), |
486 | mMainView, SLOT(newEvent(QDateTime))); | 488 | mMainView, SLOT(newEvent(QDateTime))); |
487 | 489 | ||
488 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), | 490 | connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), |
489 | mMainView, SLOT(showIncidence(Incidence *))); | 491 | mMainView, SLOT(showIncidence(Incidence *))); |
490 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), | 492 | connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), |
491 | mMainView, SLOT(editIncidence(Incidence *))); | 493 | mMainView, SLOT(editIncidence(Incidence *))); |
492 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), | 494 | connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), |
493 | mMainView, SLOT(deleteIncidence(Incidence *))); | 495 | mMainView, SLOT(deleteIncidence(Incidence *))); |
494 | 496 | ||
495 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), | 497 | connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), |
496 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 498 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
497 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), | 499 | connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), |
498 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 500 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
499 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), | 501 | connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), |
500 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 502 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
501 | 503 | ||
502 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), | 504 | connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), |
503 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 505 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
504 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), | 506 | connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), |
505 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 507 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
506 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), | 508 | connect( mMonthView, SIGNAL( selectWeekNum( int ) ), |
507 | mMainView, SLOT ( selectWeekNum( int ) ) ); | 509 | mMainView, SLOT ( selectWeekNum( int ) ) ); |
508 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), | 510 | connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), |
509 | mMainView, SLOT ( showDay( QDate ) ) ); | 511 | mMainView, SLOT ( showDay( QDate ) ) ); |
510 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); | 512 | connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); |
511 | connect( mMonthView, SIGNAL(nextMonth() ), | 513 | connect( mMonthView, SIGNAL(nextMonth() ), |
512 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); | 514 | mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); |
513 | connect( mMonthView, SIGNAL(prevMonth() ), | 515 | connect( mMonthView, SIGNAL(prevMonth() ), |
514 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); | 516 | mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); |
515 | mMonthView->updateConfig(); | 517 | mMonthView->updateConfig(); |
516 | } | 518 | } |
517 | 519 | ||
518 | globalFlagBlockAgenda = 1; | 520 | globalFlagBlockAgenda = 1; |
519 | //mFlagShowNextxDays = false; | 521 | //mFlagShowNextxDays = false; |
520 | // if(mMonthView == mCurrentView) return; | 522 | // if(mMonthView == mCurrentView) return; |
521 | mMainView->dateNavigator()->selectMonth(); | 523 | mMainView->dateNavigator()->selectMonth(); |
522 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); | 524 | // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); |
523 | //mMonthView->showDates(tmpList.first(), tmpList.last()); | 525 | //mMonthView->showDates(tmpList.first(), tmpList.last()); |
524 | 526 | ||
525 | showView(mMonthView, true ); | 527 | showView(mMonthView, true ); |
526 | 528 | ||
527 | } | 529 | } |
528 | 530 | ||
529 | void KOViewManager::showTodoView() | 531 | void KOViewManager::showTodoView() |
530 | { | 532 | { |
531 | //mFlagShowNextxDays = false; | 533 | //mFlagShowNextxDays = false; |
532 | if ( !mTodoView ) { | 534 | if ( !mTodoView ) { |
533 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), | 535 | mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), |
534 | "KOViewManager::TodoView" ); | 536 | "KOViewManager::TodoView" ); |
535 | 537 | ||
536 | addView( mTodoView ); | 538 | addView( mTodoView ); |
537 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); | 539 | // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); |
538 | 540 | ||
539 | // SIGNALS/SLOTS FOR TODO VIEW | 541 | // SIGNALS/SLOTS FOR TODO VIEW |
540 | connect( mTodoView, SIGNAL( newTodoSignal() ), | 542 | connect( mTodoView, SIGNAL( newTodoSignal() ), |
541 | mMainView, SLOT( newTodo() ) ); | 543 | mMainView, SLOT( newTodo() ) ); |
542 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), | 544 | connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), |
543 | mMainView, SLOT( newSubTodo( Todo *) ) ); | 545 | mMainView, SLOT( newSubTodo( Todo *) ) ); |
544 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), | 546 | connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), |
545 | mMainView, SLOT( showTodo( Todo * ) ) ); | 547 | mMainView, SLOT( showTodo( Todo * ) ) ); |
546 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), | 548 | connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), |
547 | mMainView, SLOT( editTodo( Todo * ) ) ); | 549 | mMainView, SLOT( editTodo( Todo * ) ) ); |
548 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), | 550 | connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), |
549 | mMainView, SLOT( deleteTodo( Todo * ) ) ); | 551 | mMainView, SLOT( deleteTodo( Todo * ) ) ); |
550 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), | 552 | connect( mTodoView, SIGNAL( purgeCompletedSignal() ), |
551 | mMainView, SLOT( purgeCompleted() ) ); | 553 | mMainView, SLOT( purgeCompleted() ) ); |
552 | 554 | ||
553 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), | 555 | connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), |
554 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); | 556 | mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); |
555 | 557 | ||
556 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, | 558 | connect( mMainView, SIGNAL( configChanged() ), mTodoView, |
557 | SLOT( updateConfig() ) ); | 559 | SLOT( updateConfig() ) ); |
558 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, | 560 | connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, |
559 | SLOT( updateTodo( Todo *, int ) ) ); | 561 | SLOT( updateTodo( Todo *, int ) ) ); |
560 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 562 | connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
561 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); | 563 | mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); |
562 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), | 564 | connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), |
563 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); | 565 | mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); |
564 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), | 566 | connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), |
565 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); | 567 | mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); |
566 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), | 568 | connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), |
567 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); | 569 | mMainView, SLOT ( todo_unsub( Todo * ) ) ); |
568 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 570 | connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
569 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); | 571 | mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); |
570 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), | 572 | connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), |
571 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); | 573 | mMainView, SLOT ( moveIncidence( Incidence * ) ) ); |
572 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), | 574 | connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), |
573 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); | 575 | mMainView, SLOT ( beamIncidence( Incidence * ) ) ); |
574 | KConfig *config = KOGlobals::config(); | 576 | KConfig *config = KOGlobals::config(); |
575 | mTodoView->restoreLayout(config,"Todo View"); | 577 | mTodoView->restoreLayout(config,"Todo View"); |
576 | mTodoView->setNavigator( mMainView->dateNavigator() ); | 578 | mTodoView->setNavigator( mMainView->dateNavigator() ); |
577 | } | 579 | } |
578 | 580 | ||
579 | globalFlagBlockAgenda = 1; | 581 | globalFlagBlockAgenda = 1; |
580 | showView( mTodoView, true ); | 582 | showView( mTodoView, true ); |
581 | 583 | ||
582 | } | 584 | } |
583 | 585 | ||
584 | void KOViewManager::showJournalView() | 586 | void KOViewManager::showJournalView() |
585 | { | 587 | { |
586 | //mFlagShowNextxDays = false; | 588 | //mFlagShowNextxDays = false; |
587 | if (!mJournalView) { | 589 | if (!mJournalView) { |
588 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), | 590 | mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), |
589 | "KOViewManager::JournalView"); | 591 | "KOViewManager::JournalView"); |
590 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, | 592 | connect( mMainView, SIGNAL( configChanged() ), mJournalView, |
591 | SLOT( updateConfig() ) ); | 593 | SLOT( updateConfig() ) ); |
592 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); | 594 | connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); |
593 | addView(mJournalView); | 595 | addView(mJournalView); |
594 | } | 596 | } |
595 | 597 | ||
596 | showView(mJournalView); | 598 | showView(mJournalView); |
597 | } | 599 | } |
598 | 600 | ||
599 | void KOViewManager::showTimeSpanView() | 601 | void KOViewManager::showTimeSpanView() |
600 | { | 602 | { |
601 | //mFlagShowNextxDays = false; | 603 | //mFlagShowNextxDays = false; |
602 | if (!mTimeSpanView) { | 604 | if (!mTimeSpanView) { |
603 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), | 605 | mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), |
604 | "KOViewManager::TimeSpanView"); | 606 | "KOViewManager::TimeSpanView"); |
605 | addView(mTimeSpanView); | 607 | addView(mTimeSpanView); |
606 | 608 | ||
607 | mTimeSpanView->readSettings(); | 609 | mTimeSpanView->readSettings(); |
608 | } | 610 | } |
609 | 611 | ||
610 | showView(mTimeSpanView); | 612 | showView(mTimeSpanView); |
611 | } | 613 | } |
612 | 614 | ||
613 | Incidence *KOViewManager::currentSelection() | 615 | Incidence *KOViewManager::currentSelection() |
614 | { | 616 | { |
615 | if (!mCurrentView) return 0; | 617 | if (!mCurrentView) return 0; |
616 | if ( mCurrentView == mListView ) { | 618 | if ( mCurrentView == mListView ) { |
617 | if ( mListView->currentItem() ) | 619 | if ( mListView->currentItem() ) |
618 | return mListView->currentItem(); | 620 | return mListView->currentItem(); |
619 | } | 621 | } |
620 | return mCurrentView->selectedIncidences().first(); | 622 | return mCurrentView->selectedIncidences().first(); |
621 | } | 623 | } |
622 | 624 | ||
623 | QDate KOViewManager::currentSelectionDate() | 625 | QDate KOViewManager::currentSelectionDate() |
624 | { | 626 | { |
625 | QDate qd; | 627 | QDate qd; |
626 | if (mCurrentView) { | 628 | if (mCurrentView) { |
627 | DateList qvl = mCurrentView->selectedDates(); | 629 | DateList qvl = mCurrentView->selectedDates(); |
628 | if (!qvl.isEmpty()) qd = qvl.first(); | 630 | if (!qvl.isEmpty()) qd = qvl.first(); |
629 | } | 631 | } |
630 | return qd; | 632 | return qd; |
631 | } | 633 | } |
632 | 634 | ||
633 | void KOViewManager::addView(KOrg::BaseView *view) | 635 | void KOViewManager::addView(KOrg::BaseView *view) |
634 | { | 636 | { |
635 | #if QT_VERSION >= 0x030000 | 637 | #if QT_VERSION >= 0x030000 |
636 | mMainView->viewStack()->addWidget( view ); | 638 | mMainView->viewStack()->addWidget( view ); |
637 | #else | 639 | #else |
638 | mMainView->viewStack()->addWidget( view, 1 ); | 640 | mMainView->viewStack()->addWidget( view, 1 ); |
639 | #endif | 641 | #endif |
640 | } | 642 | } |
641 | 643 | ||
642 | void KOViewManager::setDocumentId( const QString &id ) | 644 | void KOViewManager::setDocumentId( const QString &id ) |
643 | { | 645 | { |
644 | if (mTodoView) mTodoView->setDocumentId( id ); | 646 | if (mTodoView) mTodoView->setDocumentId( id ); |
645 | } | 647 | } |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index d7ff9f2..10665f4 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -1,763 +1,764 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #ifdef DESKTOP_VERSION | 27 | #ifdef DESKTOP_VERSION |
28 | #include <qpaintdevicemetrics.h> | 28 | #include <qpaintdevicemetrics.h> |
29 | #endif | 29 | #endif |
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOPRINTER | 38 | #ifndef KORG_NOPRINTER |
39 | #include "calprinter.h" | 39 | #include "calprinter.h" |
40 | #endif | 40 | #endif |
41 | #include "koglobals.h" | 41 | #include "koglobals.h" |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "koeventviewerdialog.h" | 43 | #include "koeventviewerdialog.h" |
44 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
45 | #include "kowhatsnextview.h" | 45 | #include "kowhatsnextview.h" |
46 | using namespace KOrg; | 46 | using namespace KOrg; |
47 | 47 | ||
48 | void WhatsNextTextBrowser::setSource(const QString& n) | 48 | void WhatsNextTextBrowser::setSource(const QString& n) |
49 | { | 49 | { |
50 | 50 | ||
51 | if (n.startsWith("event:")) { | 51 | if (n.startsWith("event:")) { |
52 | emit showIncidence(n); | 52 | emit showIncidence(n); |
53 | return; | 53 | return; |
54 | } else if (n.startsWith("todo:")) { | 54 | } else if (n.startsWith("todo:")) { |
55 | emit showIncidence(n); | 55 | emit showIncidence(n); |
56 | return; | 56 | return; |
57 | } else { | 57 | } else { |
58 | QTextBrowser::setSource(n); | 58 | QTextBrowser::setSource(n); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | void WhatsNextTextBrowser::printMe() | 61 | void WhatsNextTextBrowser::printMe() |
62 | { | 62 | { |
63 | #ifdef DESKTOP_VERSION | 63 | #ifdef DESKTOP_VERSION |
64 | QPrinter printer; | 64 | QPrinter printer; |
65 | if (!printer.setup() ) | 65 | if (!printer.setup() ) |
66 | return; | 66 | return; |
67 | QPainter p; | 67 | QPainter p; |
68 | p.begin ( &printer ); | 68 | p.begin ( &printer ); |
69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
70 | float dx, dy; | 70 | float dx, dy; |
71 | int wid = (m.width() * 9)/10; | 71 | int wid = (m.width() * 9)/10; |
72 | dx = (float) wid/(float)contentsWidth (); | 72 | dx = (float) wid/(float)contentsWidth (); |
73 | dy = (float)(m.height()) / (float)contentsHeight (); | 73 | dy = (float)(m.height()) / (float)contentsHeight (); |
74 | float scale; | 74 | float scale; |
75 | // scale to fit the width or height of the paper | 75 | // scale to fit the width or height of the paper |
76 | if ( dx < dy ) | 76 | if ( dx < dy ) |
77 | scale = dx; | 77 | scale = dx; |
78 | else | 78 | else |
79 | scale = dy; | 79 | scale = dy; |
80 | p.translate( m.width()/10,0 ); | 80 | p.translate( m.width()/10,0 ); |
81 | p.scale( scale, scale ); | 81 | p.scale( scale, scale ); |
82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
83 | p.end(); | 83 | p.end(); |
84 | #endif | 84 | #endif |
85 | } | 85 | } |
86 | 86 | ||
87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
88 | const char *name) | 88 | const char *name) |
89 | : KOrg::BaseView(calendar, parent, name) | 89 | : KOrg::BaseView(calendar, parent, name) |
90 | { | 90 | { |
91 | // mDateLabel = | 91 | // mDateLabel = |
92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
93 | // mDateLabel->setMargin(2); | 93 | // mDateLabel->setMargin(2); |
94 | // mDateLabel->setAlignment(AlignCenter); | 94 | // mDateLabel->setAlignment(AlignCenter); |
95 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 95 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
96 | mView = new WhatsNextTextBrowser(this); | 96 | mView = new WhatsNextTextBrowser(this); |
97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
98 | QStyleSheet* stsh = mView->styleSheet(); | 98 | QStyleSheet* stsh = mView->styleSheet(); |
99 | QStyleSheetItem * style ; | 99 | QStyleSheetItem * style ; |
100 | style = stsh->item ("h2" ); | 100 | style = stsh->item ("h2" ); |
101 | if ( style ) { | 101 | if ( style ) { |
102 | style->setMargin(QStyleSheetItem::MarginAll,0); | 102 | style->setMargin(QStyleSheetItem::MarginAll,0); |
103 | } | 103 | } |
104 | style = stsh->item ("h3" ); | 104 | style = stsh->item ("h3" ); |
105 | if ( style ) { | 105 | if ( style ) { |
106 | style->setMargin(QStyleSheetItem::MarginAll,0); | 106 | style->setMargin(QStyleSheetItem::MarginAll,0); |
107 | } | 107 | } |
108 | mEventViewer = 0; | 108 | mEventViewer = 0; |
109 | 109 | ||
110 | QBoxLayout *topLayout = new QVBoxLayout(this); | 110 | QBoxLayout *topLayout = new QVBoxLayout(this); |
111 | // topLayout->addWidget(mDateLabel); | 111 | // topLayout->addWidget(mDateLabel); |
112 | topLayout->addWidget(mView); | 112 | topLayout->addWidget(mView); |
113 | mTimer = new QTimer( this ); | 113 | mTimer = new QTimer( this ); |
114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
115 | 115 | ||
116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
118 | } | 118 | } |
119 | 119 | ||
120 | KOWhatsNextView::~KOWhatsNextView() | 120 | KOWhatsNextView::~KOWhatsNextView() |
121 | { | 121 | { |
122 | } | 122 | } |
123 | 123 | ||
124 | int KOWhatsNextView::maxDatesHint() | 124 | int KOWhatsNextView::maxDatesHint() |
125 | { | 125 | { |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
129 | int KOWhatsNextView::currentDateCount() | 129 | int KOWhatsNextView::currentDateCount() |
130 | { | 130 | { |
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
135 | { | 135 | { |
136 | QPtrList<Incidence> eventList; | 136 | QPtrList<Incidence> eventList; |
137 | 137 | ||
138 | return eventList; | 138 | return eventList; |
139 | } | 139 | } |
140 | 140 | ||
141 | void KOWhatsNextView::printMe() | 141 | void KOWhatsNextView::printMe() |
142 | { | 142 | { |
143 | #ifdef DESKTOP_VERSION | 143 | #ifdef DESKTOP_VERSION |
144 | mView->printMe(); | 144 | mView->printMe(); |
145 | #endif | 145 | #endif |
146 | } | 146 | } |
147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
148 | const QDate &td) | 148 | const QDate &td) |
149 | { | 149 | { |
150 | #ifndef KORG_NOPRINTER | 150 | #ifndef KORG_NOPRINTER |
151 | calPrinter->preview(CalPrinter::Day, fd, td); | 151 | calPrinter->preview(CalPrinter::Day, fd, td); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | void KOWhatsNextView::updateConfig() | 154 | void KOWhatsNextView::updateConfig() |
155 | { | 155 | { |
156 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 156 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
157 | updateView(); | 157 | updateView(); |
158 | 158 | ||
159 | } | 159 | } |
160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
161 | { | 161 | { |
162 | //qDebug("KOWhatsNextView::showEvent "); | 162 | //qDebug("KOWhatsNextView::showEvent "); |
163 | restartTimer(); | 163 | restartTimer(); |
164 | QWidget::showEvent ( e ); | 164 | QWidget::showEvent ( e ); |
165 | } | 165 | } |
166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
167 | { | 167 | { |
168 | //qDebug(" KOWhatsNextView::hideEvent"); | 168 | //qDebug(" KOWhatsNextView::hideEvent"); |
169 | mTimer->stop(); | 169 | mTimer->stop(); |
170 | QWidget::hideEvent ( e ); | 170 | QWidget::hideEvent ( e ); |
171 | } | 171 | } |
172 | void KOWhatsNextView::restartTimer() | 172 | void KOWhatsNextView::restartTimer() |
173 | { | 173 | { |
174 | //qDebug("KOWhatsNextView::restartTimer() "); | 174 | //qDebug("KOWhatsNextView::restartTimer() "); |
175 | mTimer->start( 300000 ); | 175 | mTimer->start( 300000 ); |
176 | //mTimer->start( 5000 ); | 176 | //mTimer->start( 5000 ); |
177 | } | 177 | } |
178 | void KOWhatsNextView::updateView() | 178 | void KOWhatsNextView::updateView() |
179 | { | 179 | { |
180 | //qDebug("KOWhatsNextView::updateView() "); | ||
180 | if ( mTimer->isActive() ) | 181 | if ( mTimer->isActive() ) |
181 | restartTimer(); | 182 | restartTimer(); |
182 | //qDebug("KOWhatsNextView::updateView() "); | 183 | //qDebug("KOWhatsNextView::updateView() "); |
183 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 184 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
184 | KIconLoader kil("korganizer"); | 185 | KIconLoader kil("korganizer"); |
185 | QString ipath;// = new QString(); | 186 | QString ipath;// = new QString(); |
186 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 187 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
187 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 188 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
188 | mText = "<table width=\"100%\">\n"; | 189 | mText = "<table width=\"100%\">\n"; |
189 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 190 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
190 | #ifdef DESKTOP_VERSION | 191 | #ifdef DESKTOP_VERSION |
191 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 192 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
192 | #else | 193 | #else |
193 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 194 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
194 | #endif | 195 | #endif |
195 | // mText += "<img src=\""; | 196 | // mText += "<img src=\""; |
196 | // mText += ipath; | 197 | // mText += ipath; |
197 | // mText += "\">"; | 198 | // mText += "\">"; |
198 | mEventDate = QDate::currentDate(); | 199 | mEventDate = QDate::currentDate(); |
199 | #ifdef DESKTOP_VERSION | 200 | #ifdef DESKTOP_VERSION |
200 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 201 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
201 | #else | 202 | #else |
202 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 203 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
203 | #endif | 204 | #endif |
204 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 205 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
205 | int iii; | 206 | int iii; |
206 | mTodos.clear(); | 207 | mTodos.clear(); |
207 | QPtrList<Event> events; | 208 | QPtrList<Event> events; |
208 | QPtrList<Todo> todos = calendar()->todos(); | 209 | QPtrList<Todo> todos = calendar()->todos(); |
209 | Todo * todo; | 210 | Todo * todo; |
210 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 211 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
211 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 212 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
212 | bool itemAdded = false; | 213 | bool itemAdded = false; |
213 | for ( iii = 0; iii < daysToShow; ++iii ) { | 214 | for ( iii = 0; iii < daysToShow; ++iii ) { |
214 | QString date; | 215 | QString date; |
215 | itemAdded = false; | 216 | itemAdded = false; |
216 | events = calendar()->events( mEventDate, true ); | 217 | events = calendar()->events( mEventDate, true ); |
217 | 218 | ||
218 | if ( iii == 0 ) { // today !!! | 219 | if ( iii == 0 ) { // today !!! |
219 | todo = todos.first(); | 220 | todo = todos.first(); |
220 | while(todo) { | 221 | while(todo) { |
221 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 222 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
222 | if ( ! itemAdded ) { | 223 | if ( ! itemAdded ) { |
223 | appendDay ( iii, mEventDate ); | 224 | appendDay ( iii, mEventDate ); |
224 | //itemAdded = true; | 225 | //itemAdded = true; |
225 | 226 | ||
226 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 227 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
227 | appendEvent(todo, false, false, !itemAdded ); | 228 | appendEvent(todo, false, false, !itemAdded ); |
228 | itemAdded = true; | 229 | itemAdded = true; |
229 | } | 230 | } |
230 | todo = todos.next(); | 231 | todo = todos.next(); |
231 | } | 232 | } |
232 | } | 233 | } |
233 | 234 | ||
234 | 235 | ||
235 | if (events.count() > 0) { | 236 | if (events.count() > 0) { |
236 | // mText += "<p></p>"; | 237 | // mText += "<p></p>"; |
237 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 238 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
238 | // mText += "<h2>"; | 239 | // mText += "<h2>"; |
239 | //mText += " <img src=\""; | 240 | //mText += " <img src=\""; |
240 | //mText += ipath; | 241 | //mText += ipath; |
241 | //mText += "\">"; | 242 | //mText += "\">"; |
242 | if ( ! itemAdded ) { | 243 | if ( ! itemAdded ) { |
243 | appendDay ( iii, mEventDate ); | 244 | appendDay ( iii, mEventDate ); |
244 | 245 | ||
245 | } | 246 | } |
246 | // for first day (iii == 0) | 247 | // for first day (iii == 0) |
247 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 248 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
248 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 249 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
249 | // we must append it in the first successful call of appendEvent() | 250 | // we must append it in the first successful call of appendEvent() |
250 | Event *ev = events.first(); | 251 | Event *ev = events.first(); |
251 | while(ev) { | 252 | while(ev) { |
252 | //qDebug("+++++event append %s", ev->summary().latin1()); | 253 | //qDebug("+++++event append %s", ev->summary().latin1()); |
253 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 254 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
254 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 255 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
255 | itemAdded = true; | 256 | itemAdded = true; |
256 | } | 257 | } |
257 | ev = events.next(); | 258 | ev = events.next(); |
258 | } | 259 | } |
259 | 260 | ||
260 | //mText += "</table>\n"; | 261 | //mText += "</table>\n"; |
261 | } | 262 | } |
262 | 263 | ||
263 | todo = todos.first(); | 264 | todo = todos.first(); |
264 | while(todo) { | 265 | while(todo) { |
265 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 266 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
266 | if ( ! itemAdded ) { | 267 | if ( ! itemAdded ) { |
267 | appendDay ( iii, mEventDate ); | 268 | appendDay ( iii, mEventDate ); |
268 | //itemAdded = true; | 269 | //itemAdded = true; |
269 | } | 270 | } |
270 | appendEvent(todo, false , iii!= 0,!itemAdded); | 271 | appendEvent(todo, false , iii!= 0,!itemAdded); |
271 | itemAdded = true; | 272 | itemAdded = true; |
272 | } | 273 | } |
273 | todo = todos.next(); | 274 | todo = todos.next(); |
274 | } | 275 | } |
275 | if ( !itemAdded && iii == 0 ) { | 276 | if ( !itemAdded && iii == 0 ) { |
276 | // appendDay ( iii, mEventDate ); | 277 | // appendDay ( iii, mEventDate ); |
277 | //mText += "<table>"; | 278 | //mText += "<table>"; |
278 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; | 279 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; |
279 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; | 280 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; |
280 | //mText +="</table>"; | 281 | //mText +="</table>"; |
281 | } | 282 | } |
282 | if ( itemAdded ) | 283 | if ( itemAdded ) |
283 | mText += "</table>\n"; | 284 | mText += "</table>\n"; |
284 | mEventDate = mEventDate.addDays( 1 ); | 285 | mEventDate = mEventDate.addDays( 1 ); |
285 | } | 286 | } |
286 | 287 | ||
287 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; | 288 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; |
288 | if (todos.count() > 0 && topmostPrios > 0 ) { | 289 | if (todos.count() > 0 && topmostPrios > 0 ) { |
289 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 290 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
290 | // mText += "<h2>"; | 291 | // mText += "<h2>"; |
291 | //<img src=\""; | 292 | //<img src=\""; |
292 | // mText += ipath; | 293 | // mText += ipath; |
293 | // mText += "\">"; | 294 | // mText += "\">"; |
294 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; | 295 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; |
295 | 296 | ||
296 | //mText += "<ul>\n"; | 297 | //mText += "<ul>\n"; |
297 | bool gotone = false; | 298 | bool gotone = false; |
298 | int priority = 1; | 299 | int priority = 1; |
299 | int priosFound = 0; | 300 | int priosFound = 0; |
300 | #ifdef DESKTOP_VERSION | 301 | #ifdef DESKTOP_VERSION |
301 | mText +="<p></p>"; | 302 | mText +="<p></p>"; |
302 | #endif | 303 | #endif |
303 | 304 | ||
304 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; | 305 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; |
305 | mText += "<ul>\n"; | 306 | mText += "<ul>\n"; |
306 | while (!gotone && priority<6) { | 307 | while (!gotone && priority<6) { |
307 | todo = todos.first(); | 308 | todo = todos.first(); |
308 | while(todo) { | 309 | while(todo) { |
309 | if (!todo->isCompleted() && (todo->priority() == priority) ) { | 310 | if (!todo->isCompleted() && (todo->priority() == priority) ) { |
310 | if ( appendTodo(todo) ) | 311 | if ( appendTodo(todo) ) |
311 | gotone = true; | 312 | gotone = true; |
312 | } | 313 | } |
313 | todo = todos.next(); | 314 | todo = todos.next(); |
314 | } | 315 | } |
315 | if ( gotone ) { | 316 | if ( gotone ) { |
316 | gotone = false; | 317 | gotone = false; |
317 | ++priosFound; | 318 | ++priosFound; |
318 | if ( priosFound == topmostPrios ) | 319 | if ( priosFound == topmostPrios ) |
319 | break; | 320 | break; |
320 | } | 321 | } |
321 | priority++; | 322 | priority++; |
322 | // kdDebug() << "adding the todos..." << endl; | 323 | // kdDebug() << "adding the todos..." << endl; |
323 | } | 324 | } |
324 | mText += "</ul>\n"; | 325 | mText += "</ul>\n"; |
325 | } | 326 | } |
326 | 327 | ||
327 | int replys = 0; | 328 | int replys = 0; |
328 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); | 329 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); |
329 | if (events.count() > 0) { | 330 | if (events.count() > 0) { |
330 | Event *ev = events.first(); | 331 | Event *ev = events.first(); |
331 | while(ev) { | 332 | while(ev) { |
332 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 333 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
333 | if (me!=0) { | 334 | if (me!=0) { |
334 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 335 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
335 | if (replys == 0) { | 336 | if (replys == 0) { |
336 | mText += "<p></p>"; | 337 | mText += "<p></p>"; |
337 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 338 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
338 | //mText += "<h2>"; | 339 | //mText += "<h2>"; |
339 | //<img src=\""; | 340 | //<img src=\""; |
340 | // mText += ipath; | 341 | // mText += ipath; |
341 | // mText += "\">"; | 342 | // mText += "\">"; |
342 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 343 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
343 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 344 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
344 | mText += "<table>\n"; | 345 | mText += "<table>\n"; |
345 | } | 346 | } |
346 | replys++; | 347 | replys++; |
347 | appendEvent(ev,true); | 348 | appendEvent(ev,true); |
348 | } | 349 | } |
349 | } | 350 | } |
350 | ev = events.next(); | 351 | ev = events.next(); |
351 | } | 352 | } |
352 | } | 353 | } |
353 | todos = calendar()->todos(); | 354 | todos = calendar()->todos(); |
354 | if (todos.count() > 0) { | 355 | if (todos.count() > 0) { |
355 | Todo *to = todos.first(); | 356 | Todo *to = todos.first(); |
356 | while(to) { | 357 | while(to) { |
357 | if ( !to->isCompleted() ){ | 358 | if ( !to->isCompleted() ){ |
358 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 359 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
359 | if (me!=0) { | 360 | if (me!=0) { |
360 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 361 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
361 | if (replys == 0) { | 362 | if (replys == 0) { |
362 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 363 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
363 | mText += "<table>\n"; | 364 | mText += "<table>\n"; |
364 | } | 365 | } |
365 | replys++; | 366 | replys++; |
366 | appendEvent(to, true); | 367 | appendEvent(to, true); |
367 | } | 368 | } |
368 | } | 369 | } |
369 | } | 370 | } |
370 | to = todos.next(); | 371 | to = todos.next(); |
371 | } | 372 | } |
372 | } | 373 | } |
373 | if (replys > 0 ) mText += "</table>\n"; | 374 | if (replys > 0 ) mText += "</table>\n"; |
374 | 375 | ||
375 | 376 | ||
376 | mText += "</td></tr>\n</table>\n"; | 377 | mText += "</td></tr>\n</table>\n"; |
377 | 378 | ||
378 | mView->setText(mText); | 379 | mView->setText(mText); |
379 | mView->setFocus(); | 380 | mView->setFocus(); |
380 | 381 | ||
381 | // QPixmap bPix = SmallIcon( "back" ); | 382 | // QPixmap bPix = SmallIcon( "back" ); |
382 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); | 383 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); |
383 | // QWidget* test = new QWidget(); | 384 | // QWidget* test = new QWidget(); |
384 | // test->setBackgroundMode(FixedPixmap ); | 385 | // test->setBackgroundMode(FixedPixmap ); |
385 | // test->setBackgroundPixmap ( bPix ); | 386 | // test->setBackgroundPixmap ( bPix ); |
386 | // test->resize( 300, 400 ); | 387 | // test->resize( 300, 400 ); |
387 | // test->show(); | 388 | // test->show(); |
388 | // mView->setBackgroundMode(FixedPixmap ); | 389 | // mView->setBackgroundMode(FixedPixmap ); |
389 | // mView->setBackgroundPixmap ( bPix ); | 390 | // mView->setBackgroundPixmap ( bPix ); |
390 | // qDebug("%s ",mText.latin1()); | 391 | // qDebug("%s ",mText.latin1()); |
391 | } | 392 | } |
392 | 393 | ||
393 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) | 394 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) |
394 | { | 395 | { |
395 | QString date; | 396 | QString date; |
396 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); | 397 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); |
397 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { | 398 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { |
398 | if ( i == 0 ) { | 399 | if ( i == 0 ) { |
399 | //mText += "<table>\n"; | 400 | //mText += "<table>\n"; |
400 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; | 401 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; |
401 | } | 402 | } |
402 | else if ( i == 1 ) | 403 | else if ( i == 1 ) |
403 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; | 404 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; |
404 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; | 405 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; |
405 | mText += "<h2>" + date + "</h2>\n"; | 406 | mText += "<h2>" + date + "</h2>\n"; |
406 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 407 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
407 | mText += "<table>\n"; | 408 | mText += "<table>\n"; |
408 | 409 | ||
409 | 410 | ||
410 | 411 | ||
411 | } else { | 412 | } else { |
412 | if ( i == 0 ) { | 413 | if ( i == 0 ) { |
413 | //mText += "<table>\n"; | 414 | //mText += "<table>\n"; |
414 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; | 415 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; |
415 | } | 416 | } |
416 | 417 | ||
417 | #ifdef DESKTOP_VERSION | 418 | #ifdef DESKTOP_VERSION |
418 | else if ( i == 1 ) { | 419 | else if ( i == 1 ) { |
419 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; | 420 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; |
420 | } | 421 | } |
421 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; | 422 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; |
422 | #else | 423 | #else |
423 | else if ( i == 1 ) { | 424 | else if ( i == 1 ) { |
424 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; | 425 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; |
425 | } | 426 | } |
426 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 427 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
427 | 428 | ||
428 | #endif | 429 | #endif |
429 | mText += "<h2>" + date + "</h2>\n"; | 430 | mText += "<h2>" + date + "</h2>\n"; |
430 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 431 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
431 | mText += "<table>\n"; | 432 | mText += "<table>\n"; |
432 | } | 433 | } |
433 | } | 434 | } |
434 | 435 | ||
435 | 436 | ||
436 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 437 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
437 | { | 438 | { |
438 | updateView(); | 439 | updateView(); |
439 | } | 440 | } |
440 | 441 | ||
441 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 442 | void KOWhatsNextView::showEvents(QPtrList<Event>) |
442 | { | 443 | { |
443 | } | 444 | } |
444 | 445 | ||
445 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 446 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
446 | { | 447 | { |
447 | switch(action) { | 448 | switch(action) { |
448 | case KOGlobals::EVENTADDED: | 449 | case KOGlobals::EVENTADDED: |
449 | updateView(); | 450 | updateView(); |
450 | break; | 451 | break; |
451 | case KOGlobals::EVENTEDITED: | 452 | case KOGlobals::EVENTEDITED: |
452 | updateView(); | 453 | updateView(); |
453 | break; | 454 | break; |
454 | case KOGlobals::EVENTDELETED: | 455 | case KOGlobals::EVENTDELETED: |
455 | updateView(); | 456 | updateView(); |
456 | break; | 457 | break; |
457 | default: | 458 | default: |
458 | updateView(); | 459 | updateView(); |
459 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; | 460 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; |
460 | } | 461 | } |
461 | } | 462 | } |
462 | 463 | ||
463 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) | 464 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) |
464 | { | 465 | { |
465 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) | 466 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) |
466 | return false; | 467 | return false; |
467 | QDateTime cdt = QDateTime::currentDateTime(); | 468 | QDateTime cdt = QDateTime::currentDateTime(); |
468 | QDateTime noc; | 469 | QDateTime noc; |
469 | QString tempText; | 470 | QString tempText; |
470 | if ( appendTable && !notRed ) { | 471 | if ( appendTable && !notRed ) { |
471 | tempText = "<table>"; | 472 | tempText = "<table>"; |
472 | } | 473 | } |
473 | bool ok = true; | 474 | bool ok = true; |
474 | if ( reply ) { | 475 | if ( reply ) { |
475 | noc = ev->getNextOccurence( cdt, &ok ); | 476 | noc = ev->getNextOccurence( cdt, &ok ); |
476 | if (! ok && ev->type() == "Event") | 477 | if (! ok && ev->type() == "Event") |
477 | return false; | 478 | return false; |
478 | } | 479 | } |
479 | bool bDay = false; | 480 | bool bDay = false; |
480 | if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) | 481 | if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) |
481 | bDay = true; | 482 | bDay = true; |
482 | tempText += "<tr><td><b>"; | 483 | tempText += "<tr><td><b>"; |
483 | if (ev->type()=="Event") { | 484 | if (ev->type()=="Event") { |
484 | if (reply) { | 485 | if (reply) { |
485 | if (!ev->doesFloat()) | 486 | if (!ev->doesFloat()) |
486 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; | 487 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; |
487 | else | 488 | else |
488 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 489 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
489 | 490 | ||
490 | } else { | 491 | } else { |
491 | if (!ev->doesFloat()) { | 492 | if (!ev->doesFloat()) { |
492 | Event *event = static_cast<Event *>(ev); | 493 | Event *event = static_cast<Event *>(ev); |
493 | QDateTime st,end; | 494 | QDateTime st,end; |
494 | if ( event->recurrence()->doesRecur() ) { | 495 | if ( event->recurrence()->doesRecur() ) { |
495 | QDate recDate= mEventDate; | 496 | QDate recDate= mEventDate; |
496 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); | 497 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); |
497 | while ( ! event->recursOn( recDate ) ) { | 498 | while ( ! event->recursOn( recDate ) ) { |
498 | recDate = recDate.addDays( -1 ); | 499 | recDate = recDate.addDays( -1 ); |
499 | 500 | ||
500 | } | 501 | } |
501 | st = QDateTime ( recDate, event->dtStart().time() ); | 502 | st = QDateTime ( recDate, event->dtStart().time() ); |
502 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); | 503 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); |
503 | } | 504 | } |
504 | else { | 505 | else { |
505 | st = event->dtStart(); | 506 | st = event->dtStart(); |
506 | end = event->dtEnd(); | 507 | end = event->dtEnd(); |
507 | } | 508 | } |
508 | 509 | ||
509 | 510 | ||
510 | QString dateText; | 511 | QString dateText; |
511 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); | 512 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); |
512 | if ( st.date() < mEventDate ) | 513 | if ( st.date() < mEventDate ) |
513 | dateText = "++:++-"; | 514 | dateText = "++:++-"; |
514 | else | 515 | else |
515 | dateText = event->dtStartTimeStr() + "-"; | 516 | dateText = event->dtStartTimeStr() + "-"; |
516 | if ( end.date() > mEventDate ) | 517 | if ( end.date() > mEventDate ) |
517 | dateText += "++:++"; | 518 | dateText += "++:++"; |
518 | else | 519 | else |
519 | dateText += event->dtEndTimeStr(); | 520 | dateText += event->dtEndTimeStr(); |
520 | if ( notRed ) | 521 | if ( notRed ) |
521 | tempText += dateText; | 522 | tempText += dateText; |
522 | else { | 523 | else { |
523 | if ( end < cdt ) { | 524 | if ( end < cdt ) { |
524 | if ( !KOPrefs::instance()->mWNViewShowsPast ) | 525 | if ( !KOPrefs::instance()->mWNViewShowsPast ) |
525 | return false; | 526 | return false; |
526 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; | 527 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; |
527 | } | 528 | } |
528 | else if ( st < cdt ) | 529 | else if ( st < cdt ) |
529 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; | 530 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; |
530 | else | 531 | else |
531 | tempText += dateText; | 532 | tempText += dateText; |
532 | 533 | ||
533 | } | 534 | } |
534 | 535 | ||
535 | } else { | 536 | } else { |
536 | if ( bDay ) { | 537 | if ( bDay ) { |
537 | 538 | ||
538 | if ( ev->categories().contains( i18n("Birthday") )) | 539 | if ( ev->categories().contains( i18n("Birthday") )) |
539 | tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; | 540 | tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; |
540 | else | 541 | else |
541 | tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; | 542 | tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; |
542 | } else { | 543 | } else { |
543 | tempText += i18n("Allday:"); | 544 | tempText += i18n("Allday:"); |
544 | } | 545 | } |
545 | 546 | ||
546 | } | 547 | } |
547 | } | 548 | } |
548 | } else { | 549 | } else { |
549 | mTodos.append( ev ); | 550 | mTodos.append( ev ); |
550 | tempText += i18n("ToDo:"); | 551 | tempText += i18n("ToDo:"); |
551 | if (reply) { | 552 | if (reply) { |
552 | tempText += " "; | 553 | tempText += " "; |
553 | if ( noc != cdt ) { | 554 | if ( noc != cdt ) { |
554 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 555 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
555 | } | 556 | } |
556 | } else { | 557 | } else { |
557 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { | 558 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { |
558 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 559 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
559 | QString dfs = KGlobal::locale()->dateFormatShort(); | 560 | QString dfs = KGlobal::locale()->dateFormatShort(); |
560 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 561 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
561 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; | 562 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; |
562 | KGlobal::locale()->setDateFormatShort(dfs); | 563 | KGlobal::locale()->setDateFormatShort(dfs); |
563 | } else { | 564 | } else { |
564 | if (!ev->doesFloat() ) | 565 | if (!ev->doesFloat() ) |
565 | if( ( (Todo*)ev)->dtDue() < cdt ) { | 566 | if( ( (Todo*)ev)->dtDue() < cdt ) { |
566 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; | 567 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; |
567 | 568 | ||
568 | 569 | ||
569 | } else | 570 | } else |
570 | tempText +=((Todo*)ev)->dtDueTimeStr(); | 571 | tempText +=((Todo*)ev)->dtDueTimeStr(); |
571 | mTodos.append( ev ); | 572 | mTodos.append( ev ); |
572 | } | 573 | } |
573 | } | 574 | } |
574 | } | 575 | } |
575 | tempText += "</b></td><td>"; | 576 | tempText += "</b></td><td>"; |
576 | bool needClose = false; | 577 | bool needClose = false; |
577 | if ( ev->cancelled() ) { | 578 | if ( ev->cancelled() ) { |
578 | tempText += "<font color=\"#F00000\">[c"; | 579 | tempText += "<font color=\"#F00000\">[c"; |
579 | needClose =true; | 580 | needClose =true; |
580 | 581 | ||
581 | } | 582 | } |
582 | if ( ev->isAlarmEnabled() ) { | 583 | if ( ev->isAlarmEnabled() ) { |
583 | if ( !needClose) | 584 | if ( !needClose) |
584 | tempText +="["; | 585 | tempText +="["; |
585 | tempText += "a"; | 586 | tempText += "a"; |
586 | needClose =true; | 587 | needClose =true; |
587 | 588 | ||
588 | } | 589 | } |
589 | if ( ev->description().length() > 0 ) { | 590 | if ( ev->description().length() > 0 ) { |
590 | if ( !needClose) | 591 | if ( !needClose) |
591 | tempText +="["; | 592 | tempText +="["; |
592 | tempText += "i"; | 593 | tempText += "i"; |
593 | needClose =true; | 594 | needClose =true; |
594 | } | 595 | } |
595 | if ( ev->recurrence()->doesRecur() ) { | 596 | if ( ev->recurrence()->doesRecur() ) { |
596 | if ( !needClose) | 597 | if ( !needClose) |
597 | tempText +="["; | 598 | tempText +="["; |
598 | tempText += "r"; | 599 | tempText += "r"; |
599 | needClose =true; | 600 | needClose =true; |
600 | } | 601 | } |
601 | if ( needClose ) { | 602 | if ( needClose ) { |
602 | tempText += "] "; | 603 | tempText += "] "; |
603 | } | 604 | } |
604 | if ( ev->cancelled() ) | 605 | if ( ev->cancelled() ) |
605 | tempText += "</font>"; | 606 | tempText += "</font>"; |
606 | tempText += "<a "; | 607 | tempText += "<a "; |
607 | if (ev->type()=="Event") tempText += "href=\"event:"; | 608 | if (ev->type()=="Event") tempText += "href=\"event:"; |
608 | if (ev->type()=="Todo") tempText += "href=\"todo:"; | 609 | if (ev->type()=="Todo") tempText += "href=\"todo:"; |
609 | tempText += ev->uid() + "\">"; | 610 | tempText += ev->uid() + "\">"; |
610 | if ( ev->summary().length() > 0 ) | 611 | if ( ev->summary().length() > 0 ) |
611 | tempText += ev->summary(); | 612 | tempText += ev->summary(); |
612 | else | 613 | else |
613 | tempText += i18n("-no summary-"); | 614 | tempText += i18n("-no summary-"); |
614 | if ( bDay ) { | 615 | if ( bDay ) { |
615 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); | 616 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); |
616 | if ( ok ) { | 617 | if ( ok ) { |
617 | int years = noc.date().year() - ev->dtStart().date().year(); | 618 | int years = noc.date().year() - ev->dtStart().date().year(); |
618 | tempText += i18n(" (%1 y.)"). arg( years ); | 619 | tempText += i18n(" (%1 y.)"). arg( years ); |
619 | } | 620 | } |
620 | } | 621 | } |
621 | 622 | ||
622 | tempText += "</a>"; | 623 | tempText += "</a>"; |
623 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 624 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
624 | if ( !ev->location().isEmpty() ) | 625 | if ( !ev->location().isEmpty() ) |
625 | tempText += " ("+ev->location() +")"; | 626 | tempText += " ("+ev->location() +")"; |
626 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) | 627 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) |
627 | tempText += " ["+ev->relatedTo()->summary() +"]"; | 628 | tempText += " ["+ev->relatedTo()->summary() +"]"; |
628 | tempText += "</td></tr>\n"; | 629 | tempText += "</td></tr>\n"; |
629 | mText += tempText; | 630 | mText += tempText; |
630 | return true; | 631 | return true; |
631 | } | 632 | } |
632 | 633 | ||
633 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | 634 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) |
634 | { | 635 | { |
635 | if ( mTodos.find( ev ) != mTodos.end() ) return false; | 636 | if ( mTodos.find( ev ) != mTodos.end() ) return false; |
636 | 637 | ||
637 | mTodos.append( ev ); | 638 | mTodos.append( ev ); |
638 | if ( !isSub ) | 639 | if ( !isSub ) |
639 | mText += "<p>"; | 640 | mText += "<p>"; |
640 | else | 641 | else |
641 | mText += "<li>"; | 642 | mText += "<li>"; |
642 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; | 643 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; |
643 | 644 | ||
644 | 645 | ||
645 | mText += ind; | 646 | mText += ind; |
646 | bool needClose = false; | 647 | bool needClose = false; |
647 | if ( ev->cancelled() ) { | 648 | if ( ev->cancelled() ) { |
648 | mText += "<font color=\"#F00000\">[c"; | 649 | mText += "<font color=\"#F00000\">[c"; |
649 | needClose =true; | 650 | needClose =true; |
650 | 651 | ||
651 | } | 652 | } |
652 | if ( ev->isAlarmEnabled() ) { | 653 | if ( ev->isAlarmEnabled() ) { |
653 | if ( !needClose) | 654 | if ( !needClose) |
654 | mText +="["; | 655 | mText +="["; |
655 | mText += "a"; | 656 | mText += "a"; |
656 | needClose =true; | 657 | needClose =true; |
657 | 658 | ||
658 | } | 659 | } |
659 | 660 | ||
660 | if ( ev->description().length() > 0 ) { | 661 | if ( ev->description().length() > 0 ) { |
661 | if ( !needClose) | 662 | if ( !needClose) |
662 | mText +="["; | 663 | mText +="["; |
663 | mText += "i"; | 664 | mText += "i"; |
664 | needClose =true; | 665 | needClose =true; |
665 | } | 666 | } |
666 | // if ( ev->recurrence()->doesRecur() ) { | 667 | // if ( ev->recurrence()->doesRecur() ) { |
667 | // if ( !needClose) | 668 | // if ( !needClose) |
668 | // mText +="("; | 669 | // mText +="("; |
669 | // mText += "r"; | 670 | // mText += "r"; |
670 | // needClose =true; | 671 | // needClose =true; |
671 | // } | 672 | // } |
672 | if ( needClose ) | 673 | if ( needClose ) |
673 | mText += "] "; | 674 | mText += "] "; |
674 | if ( ev->cancelled() ) | 675 | if ( ev->cancelled() ) |
675 | mText += "</font>"; | 676 | mText += "</font>"; |
676 | mText += "<a href=\"todo:" + ev->uid() + "\">"; | 677 | mText += "<a href=\"todo:" + ev->uid() + "\">"; |
677 | if ( ev->summary().length() > 0 ) | 678 | if ( ev->summary().length() > 0 ) |
678 | mText += ev->summary(); | 679 | mText += ev->summary(); |
679 | else | 680 | else |
680 | mText += i18n("-no summary-"); | 681 | mText += i18n("-no summary-"); |
681 | mText += "</a>"; | 682 | mText += "</a>"; |
682 | if ( ((Todo*)ev)->hasDueDate () ) { | 683 | if ( ((Todo*)ev)->hasDueDate () ) { |
683 | QString year = ""; | 684 | QString year = ""; |
684 | int ye = ((Todo*)ev)->dtDue().date().year(); | 685 | int ye = ((Todo*)ev)->dtDue().date().year(); |
685 | if ( QDateTime::currentDateTime().date().year() != ye ) | 686 | if ( QDateTime::currentDateTime().date().year() != ye ) |
686 | year = QString::number( ye ); | 687 | year = QString::number( ye ); |
687 | QString dfs = KGlobal::locale()->dateFormatShort(); | 688 | QString dfs = KGlobal::locale()->dateFormatShort(); |
688 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 689 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
689 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 690 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
690 | KGlobal::locale()->setDateFormatShort(dfs); | 691 | KGlobal::locale()->setDateFormatShort(dfs); |
691 | } | 692 | } |
692 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 693 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
693 | if ( !ev->location().isEmpty() ) | 694 | if ( !ev->location().isEmpty() ) |
694 | mText += " ("+ev->location() +")"; | 695 | mText += " ("+ev->location() +")"; |
695 | if ( !isSub ) { | 696 | if ( !isSub ) { |
696 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 697 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
697 | mText += " ["+ev->relatedTo()->summary() +"]"; | 698 | mText += " ["+ev->relatedTo()->summary() +"]"; |
698 | mText += "</p>\n"; | 699 | mText += "</p>\n"; |
699 | } | 700 | } |
700 | else { | 701 | else { |
701 | ind += "-"; | 702 | ind += "-"; |
702 | mText += "</li>\n"; | 703 | mText += "</li>\n"; |
703 | } | 704 | } |
704 | QPtrList<Incidence> Relations = ev->relations(); | 705 | QPtrList<Incidence> Relations = ev->relations(); |
705 | Incidence *to; | 706 | Incidence *to; |
706 | for (to=Relations.first();to;to=Relations.next()) { | 707 | for (to=Relations.first();to;to=Relations.next()) { |
707 | if (!((Todo*)to)->isCompleted()) | 708 | if (!((Todo*)to)->isCompleted()) |
708 | appendTodo( to, ind , true ); | 709 | appendTodo( to, ind , true ); |
709 | } | 710 | } |
710 | 711 | ||
711 | return true; | 712 | return true; |
712 | } | 713 | } |
713 | 714 | ||
714 | /* | 715 | /* |
715 | void KOWhatsNextView::createEventViewer() | 716 | void KOWhatsNextView::createEventViewer() |
716 | { | 717 | { |
717 | if (!mEventViewer) { | 718 | if (!mEventViewer) { |
718 | 719 | ||
719 | mEventViewer = new KOEventViewerDialog(this); | 720 | mEventViewer = new KOEventViewerDialog(this); |
720 | } | 721 | } |
721 | } | 722 | } |
722 | */ | 723 | */ |
723 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 724 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
724 | { | 725 | { |
725 | mEventViewer = v; | 726 | mEventViewer = v; |
726 | } | 727 | } |
727 | 728 | ||
728 | // TODO: Create this function in CalendarView and remove it from here | 729 | // TODO: Create this function in CalendarView and remove it from here |
729 | void KOWhatsNextView::showIncidence(const QString &uid) | 730 | void KOWhatsNextView::showIncidence(const QString &uid) |
730 | { | 731 | { |
731 | 732 | ||
732 | if ( !mEventViewer ) { | 733 | if ( !mEventViewer ) { |
733 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 734 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
734 | return; | 735 | return; |
735 | } | 736 | } |
736 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 737 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
737 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 738 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
738 | if (uid.startsWith("event:")) { | 739 | if (uid.startsWith("event:")) { |
739 | #ifdef DESKTOP_VERSION | 740 | #ifdef DESKTOP_VERSION |
740 | Event *event = calendar()->event(uid.mid(8)); | 741 | Event *event = calendar()->event(uid.mid(8)); |
741 | #else | 742 | #else |
742 | Event *event = calendar()->event(uid.mid(6)); | 743 | Event *event = calendar()->event(uid.mid(6)); |
743 | #endif | 744 | #endif |
744 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 745 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
745 | if (!event) return; | 746 | if (!event) return; |
746 | //createEventViewer(); | 747 | //createEventViewer(); |
747 | mEventViewer->setEvent(event); | 748 | mEventViewer->setEvent(event); |
748 | } else if (uid.startsWith("todo:")) { | 749 | } else if (uid.startsWith("todo:")) { |
749 | #ifdef DESKTOP_VERSION | 750 | #ifdef DESKTOP_VERSION |
750 | Todo *todo = calendar()->todo(uid.mid(7)); | 751 | Todo *todo = calendar()->todo(uid.mid(7)); |
751 | #else | 752 | #else |
752 | Todo *todo = calendar()->todo(uid.mid(5)); | 753 | Todo *todo = calendar()->todo(uid.mid(5)); |
753 | #endif | 754 | #endif |
754 | if (!todo) return; | 755 | if (!todo) return; |
755 | //createEventViewer(); | 756 | //createEventViewer(); |
756 | mEventViewer->setTodo(todo); | 757 | mEventViewer->setTodo(todo); |
757 | } else { | 758 | } else { |
758 | return; | 759 | return; |
759 | 760 | ||
760 | } | 761 | } |
761 | mEventViewer->showMe(); | 762 | mEventViewer->showMe(); |
762 | mEventViewer->raise(); | 763 | mEventViewer->raise(); |
763 | } | 764 | } |