author | zautrix <zautrix> | 2005-03-27 23:25:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-27 23:25:35 (UTC) |
commit | 67dc8738c14716e18e4c433e5c0da474456c9859 (patch) (unidiff) | |
tree | b6bd7d0d0dcc0a389bd9dce57d124d035495aeeb | |
parent | e73b9d31e463f39f666a008bdde8160a9e5c5dbf (diff) | |
download | kdepimpi-67dc8738c14716e18e4c433e5c0da474456c9859.zip kdepimpi-67dc8738c14716e18e4c433e5c0da474456c9859.tar.gz kdepimpi-67dc8738c14716e18e4c433e5c0da474456c9859.tar.bz2 |
small fixes
-rw-r--r-- | korganizer/koagenda.cpp | 8 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 3 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 6 |
4 files changed, 18 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index ed7a443..1a24887 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,1483 +1,1491 @@ | |||
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 | mTimeBox = new QLabel(this); | 73 | mTimeBox = new QLabel(this); |
74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 74 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
75 | QPalette pal = mTimeBox->palette(); | 75 | QPalette pal = mTimeBox->palette(); |
76 | pal.setColor(QColorGroup::Foreground, Qt::red); | 76 | pal.setColor(QColorGroup::Foreground, Qt::red); |
77 | mTimeBox->setPalette(pal); | 77 | mTimeBox->setPalette(pal); |
78 | //mTimeBox->setAutoMask(true); | 78 | //mTimeBox->setAutoMask(true); |
79 | 79 | ||
80 | agenda->addChild(mTimeBox); | 80 | agenda->addChild(mTimeBox); |
81 | 81 | ||
82 | oldToday = -1; | 82 | oldToday = -1; |
83 | } | 83 | } |
84 | 84 | ||
85 | MarcusBains::~MarcusBains() | 85 | MarcusBains::~MarcusBains() |
86 | { | 86 | { |
87 | delete minutes; | 87 | delete minutes; |
88 | } | 88 | } |
89 | 89 | ||
90 | int MarcusBains::todayColumn() | 90 | int MarcusBains::todayColumn() |
91 | { | 91 | { |
92 | QDate currentDate = QDate::currentDate(); | 92 | QDate currentDate = QDate::currentDate(); |
93 | 93 | ||
94 | DateList dateList = agenda->dateList(); | 94 | DateList dateList = agenda->dateList(); |
95 | DateList::ConstIterator it; | 95 | DateList::ConstIterator it; |
96 | int col = 0; | 96 | int col = 0; |
97 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 97 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
98 | if((*it) == currentDate) | 98 | if((*it) == currentDate) |
99 | return KOGlobals::self()->reverseLayout() ? | 99 | return KOGlobals::self()->reverseLayout() ? |
100 | agenda->columns() - 1 - col : col; | 100 | agenda->columns() - 1 - col : col; |
101 | ++col; | 101 | ++col; |
102 | } | 102 | } |
103 | 103 | ||
104 | return -1; | 104 | return -1; |
105 | } | 105 | } |
106 | void MarcusBains::updateLoc() | 106 | void MarcusBains::updateLoc() |
107 | { | 107 | { |
108 | updateLocation(); | 108 | updateLocation(); |
109 | } | 109 | } |
110 | void MarcusBains::updateLocation(bool recalculate) | 110 | void MarcusBains::updateLocation(bool recalculate) |
111 | { | 111 | { |
112 | 112 | ||
113 | QTime tim = QTime::currentTime(); | 113 | QTime tim = QTime::currentTime(); |
114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 114 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
115 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 115 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
116 | recalculate = true; | 116 | recalculate = true; |
117 | 117 | ||
118 | int mins = tim.hour()*60 + tim.minute(); | 118 | int mins = tim.hour()*60 + tim.minute(); |
119 | int minutesPerCell = 24 * 60 / agenda->rows(); | 119 | int minutesPerCell = 24 * 60 / agenda->rows(); |
120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 120 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
121 | int today = recalculate ? todayColumn() : oldToday; | 121 | int today = recalculate ? todayColumn() : oldToday; |
122 | int x = agenda->gridSpacingX()*today; | 122 | int x = agenda->gridSpacingX()*today; |
123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 123 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
124 | 124 | ||
125 | oldTime = tim; | 125 | oldTime = tim; |
126 | oldToday = today; | 126 | oldToday = today; |
127 | 127 | ||
128 | if(disabled || (today<0)) { | 128 | if(disabled || (today<0)) { |
129 | hide(); mTimeBox->hide(); | 129 | hide(); mTimeBox->hide(); |
130 | return; | 130 | return; |
131 | } else { | 131 | } else { |
132 | show(); mTimeBox->show(); | 132 | show(); mTimeBox->show(); |
133 | } | 133 | } |
134 | 134 | ||
135 | if(recalculate) | 135 | if(recalculate) |
136 | setFixedSize(agenda->gridSpacingX(),1); | 136 | setFixedSize(agenda->gridSpacingX(),1); |
137 | agenda->moveChild(this, x, y); | 137 | agenda->moveChild(this, x, y); |
138 | raise(); | 138 | raise(); |
139 | 139 | ||
140 | if(recalculate) | 140 | if(recalculate) |
141 | //mTimeBox->setFont(QFont("helvetica",10)); | 141 | //mTimeBox->setFont(QFont("helvetica",10)); |
142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 142 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
143 | 143 | ||
144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 144 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
145 | mTimeBox->adjustSize(); | 145 | mTimeBox->adjustSize(); |
146 | // the -2 below is there because there is a bug in this program | 146 | // the -2 below is there because there is a bug in this program |
147 | // somewhere, where the last column of this widget is a few pixels | 147 | // somewhere, where the last column of this widget is a few pixels |
148 | // narrower than the other columns. | 148 | // narrower than the other columns. |
149 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 149 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
150 | agenda->moveChild(mTimeBox, | 150 | agenda->moveChild(mTimeBox, |
151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 151 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
152 | y-mTimeBox->height()); | 152 | y-mTimeBox->height()); |
153 | 153 | ||
154 | mTimeBox->raise(); | 154 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 155 | //mTimeBox->setAutoMask(true); |
156 | minutes->start(5000,true); | 156 | minutes->start(5000,true); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | //////////////////////////////////////////////////////////////////////////// | 160 | //////////////////////////////////////////////////////////////////////////// |
161 | 161 | ||
162 | 162 | ||
163 | /* | 163 | /* |
164 | Create an agenda widget with rows rows and columns columns. | 164 | Create an agenda widget with rows rows and columns columns. |
165 | */ | 165 | */ |
166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 166 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
167 | const char *name,WFlags f) : | 167 | const char *name,WFlags f) : |
168 | QScrollView(parent,name,f) | 168 | QScrollView(parent,name,f) |
169 | { | 169 | { |
170 | 170 | ||
171 | 171 | ||
172 | mColumns = columns; | 172 | mColumns = columns; |
173 | mRows = rows; | 173 | mRows = rows; |
174 | mGridSpacingY = rowSize; | 174 | mGridSpacingY = rowSize; |
175 | mAllDayMode = false; | 175 | mAllDayMode = false; |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 177 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
178 | #endif | 178 | #endif |
179 | mHolidayMask = 0; | 179 | mHolidayMask = 0; |
180 | init(); | 180 | init(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /* | 183 | /* |
184 | Create an agenda widget with columns columns and one row. This is used for | 184 | Create an agenda widget with columns columns and one row. This is used for |
185 | all-day events. | 185 | all-day events. |
186 | */ | 186 | */ |
187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 187 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
188 | QScrollView(parent,name,f) | 188 | QScrollView(parent,name,f) |
189 | { | 189 | { |
190 | blockResize = false; | 190 | blockResize = false; |
191 | mColumns = columns; | 191 | mColumns = columns; |
192 | mRows = 1; | 192 | mRows = 1; |
193 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 193 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
194 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 194 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
195 | mAllDayMode = true; | 195 | mAllDayMode = true; |
196 | #ifndef DESKTOP_VERSION | 196 | #ifndef DESKTOP_VERSION |
197 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 197 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
198 | #endif | 198 | #endif |
199 | mHolidayMask = 0; | 199 | mHolidayMask = 0; |
200 | init(); | 200 | init(); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | KOAgenda::~KOAgenda() | 204 | KOAgenda::~KOAgenda() |
205 | { | 205 | { |
206 | if(mMarcusBains) delete mMarcusBains; | 206 | if(mMarcusBains) delete mMarcusBains; |
207 | 207 | ||
208 | } | 208 | } |
209 | 209 | ||
210 | Incidence *KOAgenda::selectedIncidence() const | 210 | Incidence *KOAgenda::selectedIncidence() const |
211 | { | 211 | { |
212 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 212 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | QDate KOAgenda::selectedIncidenceDate() const | 216 | QDate KOAgenda::selectedIncidenceDate() const |
217 | { | 217 | { |
218 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 218 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | void KOAgenda::init() | 222 | void KOAgenda::init() |
223 | { | 223 | { |
224 | mPopupTimer = new QTimer(this); | 224 | mPopupTimer = new QTimer(this); |
225 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 225 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
226 | 226 | ||
227 | mNewItemPopup = new QPopupMenu( this ); | 227 | mNewItemPopup = new QPopupMenu( this ); |
228 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 228 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
229 | QString pathString = ""; | 229 | QString pathString = ""; |
230 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 230 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
231 | if ( QApplication::desktop()->width() < 480 ) | 231 | if ( QApplication::desktop()->width() < 480 ) |
232 | pathString += "icons16/"; | 232 | pathString += "icons16/"; |
233 | } else | 233 | } else |
234 | pathString += "iconsmini/"; | 234 | pathString += "iconsmini/"; |
235 | 235 | ||
236 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 236 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
238 | mNewItemPopup->insertSeparator ( ); | 238 | mNewItemPopup->insertSeparator ( ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
245 | #ifndef _WIN32_ | 245 | #ifndef _WIN32_ |
246 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 246 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
247 | viewport()->setWFlags ( wflags); | 247 | viewport()->setWFlags ( wflags); |
248 | #endif | 248 | #endif |
249 | mGridSpacingX = 80; | 249 | mGridSpacingX = 80; |
250 | mResizeBorderWidth = 8; | 250 | mResizeBorderWidth = 8; |
251 | mScrollBorderWidth = 8; | 251 | mScrollBorderWidth = 8; |
252 | mScrollDelay = 30; | 252 | mScrollDelay = 30; |
253 | mScrollOffset = 10; | 253 | mScrollOffset = 10; |
254 | mPaintPixmap.resize( 20,20); | 254 | mPaintPixmap.resize( 20,20); |
255 | //enableClipper(true); | 255 | //enableClipper(true); |
256 | 256 | ||
257 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 257 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
258 | // effect. Has to be fixed. | 258 | // effect. Has to be fixed. |
259 | setFocusPolicy(WheelFocus); | 259 | setFocusPolicy(WheelFocus); |
260 | 260 | ||
261 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 261 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
262 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 262 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
263 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 263 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
264 | 264 | ||
265 | mStartCellX = 0; | 265 | mStartCellX = 0; |
266 | mStartCellY = 0; | 266 | mStartCellY = 0; |
267 | mCurrentCellX = 0; | 267 | mCurrentCellX = 0; |
268 | mCurrentCellY = 0; | 268 | mCurrentCellY = 0; |
269 | 269 | ||
270 | mSelectionCellX = 0; | 270 | mSelectionCellX = 0; |
271 | mSelectionYTop = 0; | 271 | mSelectionYTop = 0; |
272 | mSelectionHeight = 0; | 272 | mSelectionHeight = 0; |
273 | 273 | ||
274 | mOldLowerScrollValue = -1; | 274 | mOldLowerScrollValue = -1; |
275 | mOldUpperScrollValue = -1; | 275 | mOldUpperScrollValue = -1; |
276 | 276 | ||
277 | mClickedItem = 0; | 277 | mClickedItem = 0; |
278 | 278 | ||
279 | mActionItem = 0; | 279 | mActionItem = 0; |
280 | mActionType = NOP; | 280 | mActionType = NOP; |
281 | mItemMoved = false; | 281 | mItemMoved = false; |
282 | 282 | ||
283 | mSelectedItem = 0; | 283 | mSelectedItem = 0; |
284 | 284 | ||
285 | // mItems.setAutoDelete(true); | 285 | // mItems.setAutoDelete(true); |
286 | 286 | ||
287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 287 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
288 | 288 | ||
289 | viewport()->update(); | 289 | viewport()->update(); |
290 | 290 | ||
291 | setMinimumSize(30, 1); | 291 | setMinimumSize(30, 1); |
292 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 292 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
293 | 293 | ||
294 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 294 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
295 | // controlled in a way that the contents horizontally always fits. Then it is | 295 | // controlled in a way that the contents horizontally always fits. Then it is |
296 | // not necessary to turn off the scrollbar. | 296 | // not necessary to turn off the scrollbar. |
297 | setHScrollBarMode(AlwaysOff); | 297 | setHScrollBarMode(AlwaysOff); |
298 | if ( ! mAllDayMode ) | 298 | if ( ! mAllDayMode ) |
299 | setVScrollBarMode(AlwaysOn); | 299 | setVScrollBarMode(AlwaysOn); |
300 | else | 300 | else |
301 | setVScrollBarMode(AlwaysOff); | 301 | setVScrollBarMode(AlwaysOff); |
302 | 302 | ||
303 | setStartHour(KOPrefs::instance()->mDayBegins); | 303 | setStartHour(KOPrefs::instance()->mDayBegins); |
304 | 304 | ||
305 | calculateWorkingHours(); | 305 | calculateWorkingHours(); |
306 | 306 | ||
307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 307 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
308 | SLOT(checkScrollBoundaries(int))); | 308 | SLOT(checkScrollBoundaries(int))); |
309 | 309 | ||
310 | // Create the Marcus Bains line. | 310 | // Create the Marcus Bains line. |
311 | if(mAllDayMode) | 311 | if(mAllDayMode) |
312 | mMarcusBains = 0; | 312 | mMarcusBains = 0; |
313 | else { | 313 | else { |
314 | mMarcusBains = new MarcusBains(this); | 314 | mMarcusBains = new MarcusBains(this); |
315 | addChild(mMarcusBains); | 315 | addChild(mMarcusBains); |
316 | } | 316 | } |
317 | mPopupKind = 0; | 317 | mPopupKind = 0; |
318 | mPopupItem = 0; | 318 | mPopupItem = 0; |
319 | } | 319 | } |
320 | 320 | ||
321 | void KOAgenda::clear() | 321 | void KOAgenda::clear() |
322 | { | 322 | { |
323 | KOAgendaItem *item; | 323 | KOAgendaItem *item; |
324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 324 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
325 | mUnusedItems.append( item ); | 325 | mUnusedItems.append( item ); |
326 | //item->hide(); | 326 | //item->hide(); |
327 | } | 327 | } |
328 | mItems.clear(); | 328 | mItems.clear(); |
329 | mSelectedItem = 0; | 329 | mSelectedItem = 0; |
330 | clearSelection(); | 330 | clearSelection(); |
331 | } | 331 | } |
332 | 332 | ||
333 | void KOAgenda::clearSelection() | 333 | void KOAgenda::clearSelection() |
334 | { | 334 | { |
335 | mSelectionCellX = 0; | 335 | mSelectionCellX = 0; |
336 | mSelectionYTop = 0; | 336 | mSelectionYTop = 0; |
337 | mSelectionHeight = 0; | 337 | mSelectionHeight = 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | void KOAgenda::marcus_bains() | 340 | void KOAgenda::marcus_bains() |
341 | { | 341 | { |
342 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 342 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | void KOAgenda::changeColumns(int columns) | 346 | void KOAgenda::changeColumns(int columns) |
347 | { | 347 | { |
348 | if (columns == 0) { | 348 | if (columns == 0) { |
349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 349 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | clear(); | 352 | clear(); |
353 | mColumns = columns; | 353 | mColumns = columns; |
354 | computeSizes(); | 354 | computeSizes(); |
355 | } | 355 | } |
356 | 356 | ||
357 | /* | 357 | /* |
358 | This is the eventFilter function, which gets all events from the KOAgendaItems | 358 | This is the eventFilter function, which gets all events from the KOAgendaItems |
359 | contained in the agenda. It has to handle moving and resizing for all items. | 359 | contained in the agenda. It has to handle moving and resizing for all items. |
360 | */ | 360 | */ |
361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 361 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
362 | { | 362 | { |
363 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 363 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
364 | switch(event->type()) { | 364 | switch(event->type()) { |
365 | case QEvent::MouseButtonPress: | 365 | case QEvent::MouseButtonPress: |
366 | case QEvent::MouseButtonDblClick: | 366 | case QEvent::MouseButtonDblClick: |
367 | case QEvent::MouseButtonRelease: | 367 | case QEvent::MouseButtonRelease: |
368 | case QEvent::MouseMove: | 368 | case QEvent::MouseMove: |
369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 369 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
370 | 370 | ||
371 | case (QEvent::Leave): | 371 | case (QEvent::Leave): |
372 | if (!mActionItem) | 372 | if (!mActionItem) |
373 | setCursor(arrowCursor); | 373 | setCursor(arrowCursor); |
374 | return true; | 374 | return true; |
375 | 375 | ||
376 | default: | 376 | default: |
377 | return QScrollView::eventFilter(object,event); | 377 | return QScrollView::eventFilter(object,event); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | void KOAgenda::popupMenu() | 380 | void KOAgenda::popupMenu() |
381 | { | 381 | { |
382 | mPopupTimer->stop(); | 382 | mPopupTimer->stop(); |
383 | if ( mPopupKind == 1 ) { | 383 | if ( mPopupKind == 1 ) { |
384 | if (mActionItem ) { | 384 | if (mActionItem ) { |
385 | endItemAction(); | 385 | endItemAction(); |
386 | } | 386 | } |
387 | mLeftMouseDown = false; // no more leftMouse computation | 387 | mLeftMouseDown = false; // no more leftMouse computation |
388 | if (mPopupItem) { | 388 | if (mPopupItem) { |
389 | selectItem(mPopupItem); | 389 | selectItem(mPopupItem); |
390 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 390 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
391 | 391 | ||
392 | } | 392 | } |
393 | } else if ( mPopupKind == 2 ) { | 393 | } else if ( mPopupKind == 2 ) { |
394 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 394 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
395 | endSelectAction( false ); // do not emit new event signal | 395 | endSelectAction( false ); // do not emit new event signal |
396 | mLeftMouseDown = false; // no more leftMouse computation | 396 | mLeftMouseDown = false; // no more leftMouse computation |
397 | } | 397 | } |
398 | mNewItemPopup->popup( mPopupPos); | 398 | mNewItemPopup->popup( mPopupPos); |
399 | } | 399 | } |
400 | mLeftMouseDown = false; | 400 | mLeftMouseDown = false; |
401 | mPopupItem = 0; | 401 | mPopupItem = 0; |
402 | mPopupKind = 0; | 402 | mPopupKind = 0; |
403 | } | 403 | } |
404 | 404 | ||
405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 405 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
406 | { | 406 | { |
407 | //qDebug("KOAgenda::eventFilter_mous "); | 407 | //qDebug("KOAgenda::eventFilter_mous "); |
408 | QPoint viewportPos; | 408 | QPoint viewportPos; |
409 | if (object != viewport()) { | 409 | if (object != viewport()) { |
410 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 410 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
411 | } else { | 411 | } else { |
412 | viewportPos = me->pos(); | 412 | viewportPos = me->pos(); |
413 | } | 413 | } |
414 | static int startX = 0; | 414 | static int startX = 0; |
415 | static int startY = 0; | 415 | static int startY = 0; |
416 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 416 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
417 | static bool blockMoving = true; | 417 | static bool blockMoving = true; |
418 | switch (me->type()) { | 418 | switch (me->type()) { |
419 | case QEvent::MouseButtonPress: | 419 | case QEvent::MouseButtonPress: |
420 | if (me->button() == LeftButton) { | 420 | if (me->button() == LeftButton) { |
421 | mPopupTimer->start( 600 ); | 421 | mPopupTimer->start( 600 ); |
422 | mLeftMouseDown = true; | 422 | mLeftMouseDown = true; |
423 | } | 423 | } |
424 | blockMoving = true; | 424 | blockMoving = true; |
425 | startX = viewportPos.x(); | 425 | startX = viewportPos.x(); |
426 | startY = viewportPos.y(); | 426 | startY = viewportPos.y(); |
427 | if (object != viewport()) { | 427 | if (object != viewport()) { |
428 | mPopupItem = (KOAgendaItem *)object; | 428 | mPopupItem = (KOAgendaItem *)object; |
429 | mPopupKind = 1; | 429 | mPopupKind = 1; |
430 | if (me->button() == RightButton) { | 430 | if (me->button() == RightButton) { |
431 | popupMenu(); | 431 | popupMenu(); |
432 | } else if (me->button() == LeftButton) { | 432 | } else if (me->button() == LeftButton) { |
433 | mActionItem = (KOAgendaItem *)object; | 433 | mActionItem = (KOAgendaItem *)object; |
434 | if (mActionItem) { | 434 | if (mActionItem) { |
435 | if ( mSelectionHeight > 0 ) { | 435 | if ( mSelectionHeight > 0 ) { |
436 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 436 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
437 | int selectionYTop = mSelectionYTop; | 437 | int selectionYTop = mSelectionYTop; |
438 | int gridSpacingX = mGridSpacingX; | 438 | int gridSpacingX = mGridSpacingX; |
439 | int selectionHeight = mSelectionHeight; | 439 | int selectionHeight = mSelectionHeight; |
440 | clearSelection(); | 440 | clearSelection(); |
441 | repaintContents( selectionCellX, selectionYTop, | 441 | repaintContents( selectionCellX, selectionYTop, |
442 | gridSpacingX, selectionHeight,false ); | 442 | gridSpacingX, selectionHeight,false ); |
443 | } | 443 | } |
444 | selectItem(mActionItem); | 444 | selectItem(mActionItem); |
445 | Incidence *incidence = mActionItem->incidence(); | 445 | Incidence *incidence = mActionItem->incidence(); |
446 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 446 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
447 | mActionItem = 0; | 447 | mActionItem = 0; |
448 | } else { | 448 | } else { |
449 | startItemAction(viewportPos); | 449 | startItemAction(viewportPos); |
450 | } | 450 | } |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } else { // ---------- viewport() | 453 | } else { // ---------- viewport() |
454 | mPopupItem = 0; | 454 | mPopupItem = 0; |
455 | mPopupKind = 2; | 455 | mPopupKind = 2; |
456 | selectItem(0); | 456 | selectItem(0); |
457 | mActionItem = 0; | 457 | mActionItem = 0; |
458 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 458 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
459 | if (me->button() == RightButton) { | 459 | if (me->button() == RightButton) { |
460 | int x,y; | ||
461 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | ||
462 | int gx,gy; | ||
463 | contentsToGrid(x,y,gx,gy); | ||
464 | mCurrentCellX = gx; | ||
465 | mCurrentCellY = gy; | ||
466 | mStartCellX = gx; | ||
467 | mStartCellY = gy; | ||
460 | popupMenu(); | 468 | popupMenu(); |
461 | } else if (me->button() == LeftButton) { | 469 | } else if (me->button() == LeftButton) { |
462 | setCursor(arrowCursor); | 470 | setCursor(arrowCursor); |
463 | startSelectAction(viewportPos); | 471 | startSelectAction(viewportPos); |
464 | } | 472 | } |
465 | } | 473 | } |
466 | break; | 474 | break; |
467 | 475 | ||
468 | case QEvent::MouseButtonRelease: | 476 | case QEvent::MouseButtonRelease: |
469 | if (me->button() == LeftButton ) { | 477 | if (me->button() == LeftButton ) { |
470 | mPopupTimer->stop(); | 478 | mPopupTimer->stop(); |
471 | } | 479 | } |
472 | if (object != viewport()) { | 480 | if (object != viewport()) { |
473 | if (me->button() == LeftButton && mLeftMouseDown) { | 481 | if (me->button() == LeftButton && mLeftMouseDown) { |
474 | if (mActionItem) { | 482 | if (mActionItem) { |
475 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 483 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
476 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 484 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
477 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 485 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
478 | mScrollUpTimer.stop(); | 486 | mScrollUpTimer.stop(); |
479 | mScrollDownTimer.stop(); | 487 | mScrollDownTimer.stop(); |
480 | mActionItem->resetMove(); | 488 | mActionItem->resetMove(); |
481 | placeSubCells( mActionItem ); | 489 | placeSubCells( mActionItem ); |
482 | // emit startDragSignal( mActionItem->incidence() ); | 490 | // emit startDragSignal( mActionItem->incidence() ); |
483 | setCursor( arrowCursor ); | 491 | setCursor( arrowCursor ); |
484 | mActionItem = 0; | 492 | mActionItem = 0; |
485 | mActionType = NOP; | 493 | mActionType = NOP; |
486 | mItemMoved = 0; | 494 | mItemMoved = 0; |
487 | mLeftMouseDown = false; | 495 | mLeftMouseDown = false; |
488 | return true; | 496 | return true; |
489 | } | 497 | } |
490 | endItemAction(); | 498 | endItemAction(); |
491 | } | 499 | } |
492 | } | 500 | } |
493 | 501 | ||
494 | } else { // ---------- viewport() | 502 | } else { // ---------- viewport() |
495 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 503 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
496 | endSelectAction( true ); // emit new event signal | 504 | endSelectAction( true ); // emit new event signal |
497 | } | 505 | } |
498 | } | 506 | } |
499 | if (me->button() == LeftButton) | 507 | if (me->button() == LeftButton) |
500 | mLeftMouseDown = false; | 508 | mLeftMouseDown = false; |
501 | 509 | ||
502 | break; | 510 | break; |
503 | 511 | ||
504 | case QEvent::MouseMove: | 512 | case QEvent::MouseMove: |
505 | if ( !mLeftMouseDown ) | 513 | if ( !mLeftMouseDown ) |
506 | return true; | 514 | return true; |
507 | if ( blockMoving ) { | 515 | if ( blockMoving ) { |
508 | int dX, dY; | 516 | int dX, dY; |
509 | dX = startX - viewportPos.x(); | 517 | dX = startX - viewportPos.x(); |
510 | if ( dX < 0 ) | 518 | if ( dX < 0 ) |
511 | dX = -dX; | 519 | dX = -dX; |
512 | dY = viewportPos.y() - startY; | 520 | dY = viewportPos.y() - startY; |
513 | if ( dY < 0 ) | 521 | if ( dY < 0 ) |
514 | dY = -dY; | 522 | dY = -dY; |
515 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 523 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
516 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 524 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
517 | blockMoving = false; | 525 | blockMoving = false; |
518 | } | 526 | } |
519 | } | 527 | } |
520 | if ( ! blockMoving ) | 528 | if ( ! blockMoving ) |
521 | mPopupTimer->stop(); | 529 | mPopupTimer->stop(); |
522 | if (object != viewport()) { | 530 | if (object != viewport()) { |
523 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 531 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
524 | if (!moveItem->incidence()->isReadOnly() ) { | 532 | if (!moveItem->incidence()->isReadOnly() ) { |
525 | if (!mActionItem) | 533 | if (!mActionItem) |
526 | setNoActionCursor(moveItem,viewportPos); | 534 | setNoActionCursor(moveItem,viewportPos); |
527 | else { | 535 | else { |
528 | if ( !blockMoving ) | 536 | if ( !blockMoving ) |
529 | performItemAction(viewportPos); | 537 | performItemAction(viewportPos); |
530 | } | 538 | } |
531 | } | 539 | } |
532 | } else { // ---------- viewport() | 540 | } else { // ---------- viewport() |
533 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 541 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
534 | if ( mActionType == SELECT ) { | 542 | if ( mActionType == SELECT ) { |
535 | performSelectAction( viewportPos ); | 543 | performSelectAction( viewportPos ); |
536 | } | 544 | } |
537 | } | 545 | } |
538 | break; | 546 | break; |
539 | 547 | ||
540 | case QEvent::MouseButtonDblClick: | 548 | case QEvent::MouseButtonDblClick: |
541 | mPopupTimer->stop(); | 549 | mPopupTimer->stop(); |
542 | if (object == viewport()) { | 550 | if (object == viewport()) { |
543 | selectItem(0); | 551 | selectItem(0); |
544 | int x,y; | 552 | int x,y; |
545 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 553 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
546 | int gx,gy; | 554 | int gx,gy; |
547 | contentsToGrid(x,y,gx,gy); | 555 | contentsToGrid(x,y,gx,gy); |
548 | emit newEventSignal(gx,gy); | 556 | emit newEventSignal(gx,gy); |
549 | } else { | 557 | } else { |
550 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 558 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
551 | selectItem(doubleClickedItem); | 559 | selectItem(doubleClickedItem); |
552 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 560 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
553 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 561 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
554 | else | 562 | else |
555 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 563 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
556 | } | 564 | } |
557 | break; | 565 | break; |
558 | 566 | ||
559 | default: | 567 | default: |
560 | break; | 568 | break; |
561 | } | 569 | } |
562 | return true; | 570 | return true; |
563 | #if 0 | 571 | #if 0 |
564 | //qDebug("KOAgenda::eventFilter_mous "); | 572 | //qDebug("KOAgenda::eventFilter_mous "); |
565 | QPoint viewportPos; | 573 | QPoint viewportPos; |
566 | if (object != viewport()) { | 574 | if (object != viewport()) { |
567 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 575 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
568 | } else { | 576 | } else { |
569 | viewportPos = me->pos(); | 577 | viewportPos = me->pos(); |
570 | } | 578 | } |
571 | static int startX = 0; | 579 | static int startX = 0; |
572 | static int startY = 0; | 580 | static int startY = 0; |
573 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); | 581 | static int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 15 : 20 ); |
574 | static bool blockMoving = true; | 582 | static bool blockMoving = true; |
575 | static bool leftMouseDown = false; | 583 | static bool leftMouseDown = false; |
576 | bool rightButtonPressed = false; | 584 | bool rightButtonPressed = false; |
577 | switch (me->type()) { | 585 | switch (me->type()) { |
578 | case QEvent::MouseButtonPress: | 586 | case QEvent::MouseButtonPress: |
579 | if (me->button() == LeftButton) { | 587 | if (me->button() == LeftButton) { |
580 | leftMouseDown = true; | 588 | leftMouseDown = true; |
581 | } | 589 | } |
582 | else if (me->button() == RightButton) { | 590 | else if (me->button() == RightButton) { |
583 | leftMouseDown = false; | 591 | leftMouseDown = false; |
584 | } | 592 | } |
585 | blockMoving = true; | 593 | blockMoving = true; |
586 | startX = viewportPos.x(); | 594 | startX = viewportPos.x(); |
587 | startY = viewportPos.y(); | 595 | startY = viewportPos.y(); |
588 | if (object != viewport()) { // item clicked ************** | 596 | if (object != viewport()) { // item clicked ************** |
589 | if (me->button() == RightButton) { | 597 | if (me->button() == RightButton) { |
590 | leftMouseDown = false; | 598 | leftMouseDown = false; |
591 | mClickedItem = (KOAgendaItem *)object; | 599 | mClickedItem = (KOAgendaItem *)object; |
592 | if (mActionItem ) { | 600 | if (mActionItem ) { |
593 | endItemAction(); | 601 | endItemAction(); |
594 | } | 602 | } |
595 | if (mClickedItem) { | 603 | if (mClickedItem) { |
596 | selectItem(mClickedItem); | 604 | selectItem(mClickedItem); |
597 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 605 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
598 | } | 606 | } |
599 | return true; | 607 | return true; |
600 | } else if (me->button() == LeftButton) { | 608 | } else if (me->button() == LeftButton) { |
601 | mActionItem = (KOAgendaItem *)object; | 609 | mActionItem = (KOAgendaItem *)object; |
602 | if (mActionItem) { | 610 | if (mActionItem) { |
603 | if ( mSelectionHeight > 0 ) { | 611 | if ( mSelectionHeight > 0 ) { |
604 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 612 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
605 | int selectionYTop = mSelectionYTop; | 613 | int selectionYTop = mSelectionYTop; |
606 | int gridSpacingX = mGridSpacingX; | 614 | int gridSpacingX = mGridSpacingX; |
607 | int selectionHeight = mSelectionHeight; | 615 | int selectionHeight = mSelectionHeight; |
608 | clearSelection(); | 616 | clearSelection(); |
609 | repaintContents( selectionCellX, selectionYTop, | 617 | repaintContents( selectionCellX, selectionYTop, |
610 | gridSpacingX, selectionHeight,false ); | 618 | gridSpacingX, selectionHeight,false ); |
611 | } | 619 | } |
612 | selectItem(mActionItem); | 620 | selectItem(mActionItem); |
613 | Incidence *incidence = mActionItem->incidence(); | 621 | Incidence *incidence = mActionItem->incidence(); |
614 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 622 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
615 | mActionItem = 0; | 623 | mActionItem = 0; |
616 | } else { | 624 | } else { |
617 | startItemAction(viewportPos); | 625 | startItemAction(viewportPos); |
618 | } | 626 | } |
619 | } | 627 | } |
620 | } | 628 | } |
621 | } else { // ---------- viewport() | 629 | } else { // ---------- viewport() |
622 | selectItem(0); | 630 | selectItem(0); |
623 | mActionItem = 0; | 631 | mActionItem = 0; |
624 | if (me->button() == LeftButton ) { | 632 | if (me->button() == LeftButton ) { |
625 | setCursor(arrowCursor); | 633 | setCursor(arrowCursor); |
626 | startSelectAction(viewportPos); | 634 | startSelectAction(viewportPos); |
627 | } else if (me->button() == RightButton ) { | 635 | } else if (me->button() == RightButton ) { |
628 | setCursor(arrowCursor); | 636 | setCursor(arrowCursor); |
629 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action | 637 | if ( leftMouseDown ) { // we have a simulated right click - clear left mouse action |
630 | endSelectAction( false ); // do not emit new event signal | 638 | endSelectAction( false ); // do not emit new event signal |
631 | leftMouseDown = false; // no more leftMouse computation | 639 | leftMouseDown = false; // no more leftMouse computation |
632 | } | 640 | } |
633 | int x,y; | 641 | int x,y; |
634 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 642 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
635 | int gx,gy; | 643 | int gx,gy; |
636 | contentsToGrid(x,y,gx,gy); | 644 | contentsToGrid(x,y,gx,gy); |
637 | mCurrentCellX = gx; | 645 | mCurrentCellX = gx; |
638 | mCurrentCellY = gy; | 646 | mCurrentCellY = gy; |
639 | mStartCellX = gx; | 647 | mStartCellX = gx; |
640 | mStartCellY = gy; | 648 | mStartCellY = gy; |
641 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 649 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
642 | } | 650 | } |
643 | } | 651 | } |
644 | break; | 652 | break; |
645 | 653 | ||
646 | case QEvent::MouseButtonRelease: | 654 | case QEvent::MouseButtonRelease: |
647 | 655 | ||
648 | if (object != viewport()) { | 656 | if (object != viewport()) { |
649 | if (me->button() == LeftButton && leftMouseDown) { | 657 | if (me->button() == LeftButton && leftMouseDown) { |
650 | if (mActionItem) { | 658 | if (mActionItem) { |
651 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 659 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
652 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 660 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
653 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 661 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
654 | mScrollUpTimer.stop(); | 662 | mScrollUpTimer.stop(); |
655 | mScrollDownTimer.stop(); | 663 | mScrollDownTimer.stop(); |
656 | mActionItem->resetMove(); | 664 | mActionItem->resetMove(); |
657 | placeSubCells( mActionItem ); | 665 | placeSubCells( mActionItem ); |
658 | // emit startDragSignal( mActionItem->incidence() ); | 666 | // emit startDragSignal( mActionItem->incidence() ); |
659 | setCursor( arrowCursor ); | 667 | setCursor( arrowCursor ); |
660 | mActionItem = 0; | 668 | mActionItem = 0; |
661 | mActionType = NOP; | 669 | mActionType = NOP; |
662 | mItemMoved = 0; | 670 | mItemMoved = 0; |
663 | leftMouseDown = false; | 671 | leftMouseDown = false; |
664 | return true; | 672 | return true; |
665 | } | 673 | } |
666 | endItemAction(); | 674 | endItemAction(); |
667 | } | 675 | } |
668 | } | 676 | } |
669 | 677 | ||
670 | } else { // ---------- viewport() | 678 | } else { // ---------- viewport() |
671 | if (me->button() == LeftButton && leftMouseDown ) { //left click | 679 | if (me->button() == LeftButton && leftMouseDown ) { //left click |
672 | endSelectAction( true ); // emit new event signal | 680 | endSelectAction( true ); // emit new event signal |
673 | } | 681 | } |
674 | } | 682 | } |
675 | if (me->button() == LeftButton) | 683 | if (me->button() == LeftButton) |
676 | leftMouseDown = false; | 684 | leftMouseDown = false; |
677 | 685 | ||
678 | break; | 686 | break; |
679 | 687 | ||
680 | case QEvent::MouseMove: | 688 | case QEvent::MouseMove: |
681 | if ( !leftMouseDown ) | 689 | if ( !leftMouseDown ) |
682 | return true; | 690 | return true; |
683 | if ( blockMoving ) { | 691 | if ( blockMoving ) { |
684 | int dX, dY; | 692 | int dX, dY; |
685 | dX = startX - viewportPos.x(); | 693 | dX = startX - viewportPos.x(); |
686 | if ( dX < 0 ) | 694 | if ( dX < 0 ) |
687 | dX = -dX; | 695 | dX = -dX; |
688 | dY = viewportPos.y() - startY; | 696 | dY = viewportPos.y() - startY; |
689 | if ( dY < 0 ) | 697 | if ( dY < 0 ) |
690 | dY = -dY; | 698 | dY = -dY; |
691 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 699 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
692 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 700 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
693 | blockMoving = false; | 701 | blockMoving = false; |
694 | } | 702 | } |
695 | } | 703 | } |
696 | if (object != viewport()) { | 704 | if (object != viewport()) { |
697 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 705 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
698 | if (!moveItem->incidence()->isReadOnly() ) { | 706 | if (!moveItem->incidence()->isReadOnly() ) { |
699 | if (!mActionItem) | 707 | if (!mActionItem) |
700 | setNoActionCursor(moveItem,viewportPos); | 708 | setNoActionCursor(moveItem,viewportPos); |
701 | else { | 709 | else { |
702 | if ( !blockMoving ) | 710 | if ( !blockMoving ) |
703 | performItemAction(viewportPos); | 711 | performItemAction(viewportPos); |
704 | } | 712 | } |
705 | } | 713 | } |
706 | } else { // ---------- viewport() | 714 | } else { // ---------- viewport() |
707 | if ( mActionType == SELECT ) { | 715 | if ( mActionType == SELECT ) { |
708 | performSelectAction( viewportPos ); | 716 | performSelectAction( viewportPos ); |
709 | } | 717 | } |
710 | } | 718 | } |
711 | break; | 719 | break; |
712 | 720 | ||
713 | case QEvent::MouseButtonDblClick: | 721 | case QEvent::MouseButtonDblClick: |
714 | blockMoving = false; | 722 | blockMoving = false; |
715 | leftMouseDown = false; | 723 | leftMouseDown = false; |
716 | if (object == viewport()) { | 724 | if (object == viewport()) { |
717 | selectItem(0); | 725 | selectItem(0); |
718 | int x,y; | 726 | int x,y; |
719 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 727 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
720 | int gx,gy; | 728 | int gx,gy; |
721 | contentsToGrid(x,y,gx,gy); | 729 | contentsToGrid(x,y,gx,gy); |
722 | emit newEventSignal(gx,gy); | 730 | emit newEventSignal(gx,gy); |
723 | } else { | 731 | } else { |
724 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 732 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
725 | selectItem(doubleClickedItem); | 733 | selectItem(doubleClickedItem); |
726 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 734 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
727 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 735 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
728 | else | 736 | else |
729 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 737 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
730 | } | 738 | } |
731 | break; | 739 | break; |
732 | 740 | ||
733 | default: | 741 | default: |
734 | break; | 742 | break; |
735 | } | 743 | } |
736 | return true; | 744 | return true; |
737 | #endif | 745 | #endif |
738 | } | 746 | } |
739 | 747 | ||
740 | void KOAgenda::newItem( int item ) | 748 | void KOAgenda::newItem( int item ) |
741 | { | 749 | { |
742 | if ( item == 1 ) { //new event | 750 | if ( item == 1 ) { //new event |
743 | newEventSignal(mStartCellX ,mStartCellY ); | 751 | newEventSignal(mStartCellX ,mStartCellY ); |
744 | } else | 752 | } else |
745 | if ( item == 2 ) { //new event | 753 | if ( item == 2 ) { //new event |
746 | newTodoSignal(mStartCellX ,mStartCellY ); | 754 | newTodoSignal(mStartCellX ,mStartCellY ); |
747 | } else | 755 | } else |
748 | { | 756 | { |
749 | QDate day = mSelectedDates[mStartCellX]; | 757 | QDate day = mSelectedDates[mStartCellX]; |
750 | emit showDateView( item, day ); | 758 | emit showDateView( item, day ); |
751 | // 3Day view | 759 | // 3Day view |
752 | // 4Week view | 760 | // 4Week view |
753 | // 5Month view | 761 | // 5Month view |
754 | // 6Journal view | 762 | // 6Journal view |
755 | } | 763 | } |
756 | } | 764 | } |
757 | void KOAgenda::startSelectAction(QPoint viewportPos) | 765 | void KOAgenda::startSelectAction(QPoint viewportPos) |
758 | { | 766 | { |
759 | //emit newStartSelectSignal(); | 767 | //emit newStartSelectSignal(); |
760 | 768 | ||
761 | mActionType = SELECT; | 769 | mActionType = SELECT; |
762 | 770 | ||
763 | int x,y; | 771 | int x,y; |
764 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 772 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
765 | int gx,gy; | 773 | int gx,gy; |
766 | contentsToGrid(x,y,gx,gy); | 774 | contentsToGrid(x,y,gx,gy); |
767 | 775 | ||
768 | mStartCellX = gx; | 776 | mStartCellX = gx; |
769 | mStartCellY = gy; | 777 | mStartCellY = gy; |
770 | mCurrentCellX = gx; | 778 | mCurrentCellX = gx; |
771 | mCurrentCellY = gy; | 779 | mCurrentCellY = gy; |
772 | 780 | ||
773 | // Store coordinates of old selection | 781 | // Store coordinates of old selection |
774 | int selectionX = mSelectionCellX * mGridSpacingX; | 782 | int selectionX = mSelectionCellX * mGridSpacingX; |
775 | int selectionYTop = mSelectionYTop; | 783 | int selectionYTop = mSelectionYTop; |
776 | int selectionHeight = mSelectionHeight; | 784 | int selectionHeight = mSelectionHeight; |
777 | 785 | ||
778 | // Store new selection | 786 | // Store new selection |
779 | mSelectionCellX = gx; | 787 | mSelectionCellX = gx; |
780 | mSelectionYTop = gy * mGridSpacingY; | 788 | mSelectionYTop = gy * mGridSpacingY; |
781 | mSelectionHeight = mGridSpacingY; | 789 | mSelectionHeight = mGridSpacingY; |
782 | 790 | ||
783 | // Clear old selection | 791 | // Clear old selection |
784 | repaintContents( selectionX, selectionYTop, | 792 | repaintContents( selectionX, selectionYTop, |
785 | mGridSpacingX, selectionHeight,false ); | 793 | mGridSpacingX, selectionHeight,false ); |
786 | 794 | ||
787 | // Paint new selection | 795 | // Paint new selection |
788 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 796 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
789 | // mGridSpacingX, mSelectionHeight ); | 797 | // mGridSpacingX, mSelectionHeight ); |
790 | } | 798 | } |
791 | 799 | ||
792 | void KOAgenda::performSelectAction(QPoint viewportPos) | 800 | void KOAgenda::performSelectAction(QPoint viewportPos) |
793 | { | 801 | { |
794 | int x,y; | 802 | int x,y; |
795 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 803 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
796 | int gx,gy; | 804 | int gx,gy; |
797 | contentsToGrid(x,y,gx,gy); | 805 | contentsToGrid(x,y,gx,gy); |
798 | 806 | ||
799 | QPoint clipperPos = clipper()-> | 807 | QPoint clipperPos = clipper()-> |
800 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 808 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
801 | 809 | ||
802 | // Scroll if cursor was moved to upper or lower end of agenda. | 810 | // Scroll if cursor was moved to upper or lower end of agenda. |
803 | if (clipperPos.y() < mScrollBorderWidth) { | 811 | if (clipperPos.y() < mScrollBorderWidth) { |
804 | mScrollUpTimer.start(mScrollDelay); | 812 | mScrollUpTimer.start(mScrollDelay); |
805 | } else if (visibleHeight() - clipperPos.y() < | 813 | } else if (visibleHeight() - clipperPos.y() < |
806 | mScrollBorderWidth) { | 814 | mScrollBorderWidth) { |
807 | mScrollDownTimer.start(mScrollDelay); | 815 | mScrollDownTimer.start(mScrollDelay); |
808 | } else { | 816 | } else { |
809 | mScrollUpTimer.stop(); | 817 | mScrollUpTimer.stop(); |
810 | mScrollDownTimer.stop(); | 818 | mScrollDownTimer.stop(); |
811 | } | 819 | } |
812 | 820 | ||
813 | if ( gy > mCurrentCellY ) { | 821 | if ( gy > mCurrentCellY ) { |
814 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 822 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
815 | 823 | ||
816 | #if 0 | 824 | #if 0 |
817 | // FIXME: Repaint only the newly selected region | 825 | // FIXME: Repaint only the newly selected region |
818 | repaintContents( mSelectionCellX * mGridSpacingX, | 826 | repaintContents( mSelectionCellX * mGridSpacingX, |
819 | mCurrentCellY + mGridSpacingY, | 827 | mCurrentCellY + mGridSpacingY, |
820 | mGridSpacingX, | 828 | mGridSpacingX, |
821 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 829 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
822 | #else | 830 | #else |
823 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 831 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
824 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 832 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
825 | mGridSpacingX, mSelectionYTop, | 833 | mGridSpacingX, mSelectionYTop, |
826 | mGridSpacingX, mSelectionHeight , false); | 834 | mGridSpacingX, mSelectionHeight , false); |
827 | #endif | 835 | #endif |
828 | 836 | ||
829 | mCurrentCellY = gy; | 837 | mCurrentCellY = gy; |
830 | } else if ( gy < mCurrentCellY ) { | 838 | } else if ( gy < mCurrentCellY ) { |
831 | if ( gy >= mStartCellY ) { | 839 | if ( gy >= mStartCellY ) { |
832 | int selectionHeight = mSelectionHeight; | 840 | int selectionHeight = mSelectionHeight; |
833 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 841 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
834 | 842 | ||
835 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 843 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
836 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 844 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
837 | mGridSpacingX, mSelectionYTop, | 845 | mGridSpacingX, mSelectionYTop, |
838 | mGridSpacingX, selectionHeight,false ); | 846 | mGridSpacingX, selectionHeight,false ); |
839 | 847 | ||
840 | mCurrentCellY = gy; | 848 | mCurrentCellY = gy; |
841 | } else { | 849 | } else { |
842 | } | 850 | } |
843 | } | 851 | } |
844 | } | 852 | } |
845 | 853 | ||
846 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 854 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
847 | { | 855 | { |
848 | mActionType = NOP; | 856 | mActionType = NOP; |
849 | mScrollUpTimer.stop(); | 857 | mScrollUpTimer.stop(); |
850 | mScrollDownTimer.stop(); | 858 | mScrollDownTimer.stop(); |
851 | 859 | ||
852 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 860 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
853 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 861 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
854 | qDebug("ew event signal "); | 862 | qDebug("ew event signal "); |
855 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 863 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
856 | } | 864 | } |
857 | } | 865 | } |
858 | 866 | ||
859 | void KOAgenda::startItemAction(QPoint viewportPos) | 867 | void KOAgenda::startItemAction(QPoint viewportPos) |
860 | { | 868 | { |
861 | int x,y; | 869 | int x,y; |
862 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 870 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
863 | int gx,gy; | 871 | int gx,gy; |
864 | contentsToGrid(x,y,gx,gy); | 872 | contentsToGrid(x,y,gx,gy); |
865 | 873 | ||
866 | mStartCellX = gx; | 874 | mStartCellX = gx; |
867 | mStartCellY = gy; | 875 | mStartCellY = gy; |
868 | mCurrentCellX = gx; | 876 | mCurrentCellX = gx; |
869 | mCurrentCellY = gy; | 877 | mCurrentCellY = gy; |
870 | 878 | ||
871 | if (mAllDayMode) { | 879 | if (mAllDayMode) { |
872 | int gridDistanceX = (x - gx * mGridSpacingX); | 880 | int gridDistanceX = (x - gx * mGridSpacingX); |
873 | if (gridDistanceX < mResizeBorderWidth && | 881 | if (gridDistanceX < mResizeBorderWidth && |
874 | mActionItem->cellX() == mCurrentCellX) { | 882 | mActionItem->cellX() == mCurrentCellX) { |
875 | mActionType = RESIZELEFT; | 883 | mActionType = RESIZELEFT; |
876 | setCursor(sizeHorCursor); | 884 | setCursor(sizeHorCursor); |
877 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 885 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
878 | mActionItem->cellXWidth() == mCurrentCellX) { | 886 | mActionItem->cellXWidth() == mCurrentCellX) { |
879 | mActionType = RESIZERIGHT; | 887 | mActionType = RESIZERIGHT; |
880 | setCursor(sizeHorCursor); | 888 | setCursor(sizeHorCursor); |
881 | } else { | 889 | } else { |
882 | mActionType = MOVE; | 890 | mActionType = MOVE; |
883 | mActionItem->startMove(); | 891 | mActionItem->startMove(); |
884 | setCursor(sizeAllCursor); | 892 | setCursor(sizeAllCursor); |
885 | } | 893 | } |
886 | } else { | 894 | } else { |
887 | int gridDistanceY = (y - gy * mGridSpacingY); | 895 | int gridDistanceY = (y - gy * mGridSpacingY); |
888 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 896 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
889 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 897 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
890 | mActionItem->cellYTop() == mCurrentCellY && | 898 | mActionItem->cellYTop() == mCurrentCellY && |
891 | !mActionItem->firstMultiItem()) { | 899 | !mActionItem->firstMultiItem()) { |
892 | mActionType = RESIZETOP; | 900 | mActionType = RESIZETOP; |
893 | setCursor(sizeVerCursor); | 901 | setCursor(sizeVerCursor); |
894 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 902 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
895 | mActionItem->cellYBottom() == mCurrentCellY && | 903 | mActionItem->cellYBottom() == mCurrentCellY && |
896 | !mActionItem->lastMultiItem()) { | 904 | !mActionItem->lastMultiItem()) { |
897 | mActionType = RESIZEBOTTOM; | 905 | mActionType = RESIZEBOTTOM; |
898 | setCursor(sizeVerCursor); | 906 | setCursor(sizeVerCursor); |
899 | } else { | 907 | } else { |
900 | mActionType = MOVE; | 908 | mActionType = MOVE; |
901 | mActionItem->startMove(); | 909 | mActionItem->startMove(); |
902 | setCursor(sizeAllCursor); | 910 | setCursor(sizeAllCursor); |
903 | } | 911 | } |
904 | } | 912 | } |
905 | } | 913 | } |
906 | 914 | ||
907 | void KOAgenda::performItemAction(QPoint viewportPos) | 915 | void KOAgenda::performItemAction(QPoint viewportPos) |
908 | { | 916 | { |
909 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 917 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
910 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 918 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
911 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 919 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
912 | // point = clipper()->mapFromGlobal(point); | 920 | // point = clipper()->mapFromGlobal(point); |
913 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 921 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
914 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 922 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
915 | int x,y; | 923 | int x,y; |
916 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 924 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
917 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 925 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
918 | int gx,gy; | 926 | int gx,gy; |
919 | contentsToGrid(x,y,gx,gy); | 927 | contentsToGrid(x,y,gx,gy); |
920 | QPoint clipperPos = clipper()-> | 928 | QPoint clipperPos = clipper()-> |
921 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 929 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
922 | 930 | ||
923 | // Cursor left active agenda area. | 931 | // Cursor left active agenda area. |
924 | // This starts a drag. | 932 | // This starts a drag. |
925 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 933 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
926 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 934 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
927 | if ( mActionType == MOVE ) { | 935 | if ( mActionType == MOVE ) { |
928 | mScrollUpTimer.stop(); | 936 | mScrollUpTimer.stop(); |
929 | mScrollDownTimer.stop(); | 937 | mScrollDownTimer.stop(); |
930 | mActionItem->resetMove(); | 938 | mActionItem->resetMove(); |
931 | placeSubCells( mActionItem ); | 939 | placeSubCells( mActionItem ); |
932 | // emit startDragSignal( mActionItem->incidence() ); | 940 | // emit startDragSignal( mActionItem->incidence() ); |
933 | setCursor( arrowCursor ); | 941 | setCursor( arrowCursor ); |
934 | mActionItem = 0; | 942 | mActionItem = 0; |
935 | mActionType = NOP; | 943 | mActionType = NOP; |
936 | mItemMoved = 0; | 944 | mItemMoved = 0; |
937 | return; | 945 | return; |
938 | } | 946 | } |
939 | } else { | 947 | } else { |
940 | switch ( mActionType ) { | 948 | switch ( mActionType ) { |
941 | case MOVE: | 949 | case MOVE: |
942 | setCursor( sizeAllCursor ); | 950 | setCursor( sizeAllCursor ); |
943 | break; | 951 | break; |
944 | case RESIZETOP: | 952 | case RESIZETOP: |
945 | case RESIZEBOTTOM: | 953 | case RESIZEBOTTOM: |
946 | setCursor( sizeVerCursor ); | 954 | setCursor( sizeVerCursor ); |
947 | break; | 955 | break; |
948 | case RESIZELEFT: | 956 | case RESIZELEFT: |
949 | case RESIZERIGHT: | 957 | case RESIZERIGHT: |
950 | setCursor( sizeHorCursor ); | 958 | setCursor( sizeHorCursor ); |
951 | break; | 959 | break; |
952 | default: | 960 | default: |
953 | setCursor( arrowCursor ); | 961 | setCursor( arrowCursor ); |
954 | } | 962 | } |
955 | } | 963 | } |
956 | 964 | ||
957 | // Scroll if item was moved to upper or lower end of agenda. | 965 | // Scroll if item was moved to upper or lower end of agenda. |
958 | if (clipperPos.y() < mScrollBorderWidth) { | 966 | if (clipperPos.y() < mScrollBorderWidth) { |
959 | mScrollUpTimer.start(mScrollDelay); | 967 | mScrollUpTimer.start(mScrollDelay); |
960 | } else if (visibleHeight() - clipperPos.y() < | 968 | } else if (visibleHeight() - clipperPos.y() < |
961 | mScrollBorderWidth) { | 969 | mScrollBorderWidth) { |
962 | mScrollDownTimer.start(mScrollDelay); | 970 | mScrollDownTimer.start(mScrollDelay); |
963 | } else { | 971 | } else { |
964 | mScrollUpTimer.stop(); | 972 | mScrollUpTimer.stop(); |
965 | mScrollDownTimer.stop(); | 973 | mScrollDownTimer.stop(); |
966 | } | 974 | } |
967 | 975 | ||
968 | // Move or resize item if necessary | 976 | // Move or resize item if necessary |
969 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 977 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
970 | mItemMoved = true; | 978 | mItemMoved = true; |
971 | mActionItem->raise(); | 979 | mActionItem->raise(); |
972 | if (mActionType == MOVE) { | 980 | if (mActionType == MOVE) { |
973 | // Move all items belonging to a multi item | 981 | // Move all items belonging to a multi item |
974 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 982 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
975 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 983 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
976 | if (!moveItem) moveItem = mActionItem; | 984 | if (!moveItem) moveItem = mActionItem; |
977 | while (moveItem) { | 985 | while (moveItem) { |
978 | int dy; | 986 | int dy; |
979 | if (isMultiItem) dy = 0; | 987 | if (isMultiItem) dy = 0; |
980 | else dy = gy - mCurrentCellY; | 988 | else dy = gy - mCurrentCellY; |
981 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 989 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
982 | int x,y; | 990 | int x,y; |
983 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 991 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
984 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 992 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
985 | mGridSpacingY * moveItem->cellHeight()); | 993 | mGridSpacingY * moveItem->cellHeight()); |
986 | moveChild(moveItem,x,y); | 994 | moveChild(moveItem,x,y); |
987 | moveItem = moveItem->nextMultiItem(); | 995 | moveItem = moveItem->nextMultiItem(); |
988 | } | 996 | } |
989 | } else if (mActionType == RESIZETOP) { | 997 | } else if (mActionType == RESIZETOP) { |
990 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 998 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
991 | mActionItem->expandTop(gy - mCurrentCellY); | 999 | mActionItem->expandTop(gy - mCurrentCellY); |
992 | mActionItem->resize(mActionItem->width(), | 1000 | mActionItem->resize(mActionItem->width(), |
993 | mGridSpacingY * mActionItem->cellHeight()); | 1001 | mGridSpacingY * mActionItem->cellHeight()); |
994 | int x,y; | 1002 | int x,y; |
995 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 1003 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
996 | //moveChild(mActionItem,childX(mActionItem),y); | 1004 | //moveChild(mActionItem,childX(mActionItem),y); |
997 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 1005 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
998 | } | 1006 | } |
999 | } else if (mActionType == RESIZEBOTTOM) { | 1007 | } else if (mActionType == RESIZEBOTTOM) { |
1000 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 1008 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
1001 | mActionItem->expandBottom(gy - mCurrentCellY); | 1009 | mActionItem->expandBottom(gy - mCurrentCellY); |
1002 | mActionItem->resize(mActionItem->width(), | 1010 | mActionItem->resize(mActionItem->width(), |
1003 | mGridSpacingY * mActionItem->cellHeight()); | 1011 | mGridSpacingY * mActionItem->cellHeight()); |
1004 | } | 1012 | } |
1005 | } else if (mActionType == RESIZELEFT) { | 1013 | } else if (mActionType == RESIZELEFT) { |
1006 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 1014 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
1007 | mActionItem->expandLeft(gx - mCurrentCellX); | 1015 | mActionItem->expandLeft(gx - mCurrentCellX); |
1008 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 1016 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
1009 | mActionItem->height()); | 1017 | mActionItem->height()); |
1010 | int x,y; | 1018 | int x,y; |
1011 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 1019 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
1012 | moveChild(mActionItem,x,childY(mActionItem)); | 1020 | moveChild(mActionItem,x,childY(mActionItem)); |
1013 | } | 1021 | } |
1014 | } else if (mActionType == RESIZERIGHT) { | 1022 | } else if (mActionType == RESIZERIGHT) { |
1015 | if (mCurrentCellX >= mActionItem->cellX()) { | 1023 | if (mCurrentCellX >= mActionItem->cellX()) { |
1016 | mActionItem->expandRight(gx - mCurrentCellX); | 1024 | mActionItem->expandRight(gx - mCurrentCellX); |
1017 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 1025 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
1018 | mActionItem->height()); | 1026 | mActionItem->height()); |
1019 | } | 1027 | } |
1020 | } | 1028 | } |
1021 | mCurrentCellX = gx; | 1029 | mCurrentCellX = gx; |
1022 | mCurrentCellY = gy; | 1030 | mCurrentCellY = gy; |
1023 | } | 1031 | } |
1024 | } | 1032 | } |
1025 | 1033 | ||
1026 | void KOAgenda::endItemAction() | 1034 | void KOAgenda::endItemAction() |
1027 | { | 1035 | { |
1028 | 1036 | ||
1029 | if ( mItemMoved ) { | 1037 | if ( mItemMoved ) { |
1030 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 1038 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
1031 | if ( !placeItem ) { | 1039 | if ( !placeItem ) { |
1032 | placeItem = mActionItem; | 1040 | placeItem = mActionItem; |
1033 | } | 1041 | } |
1034 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 1042 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
1035 | Incidence* oldInc = placeItem->incidence(); | 1043 | Incidence* oldInc = placeItem->incidence(); |
1036 | placeItem->recreateIncidence(); | 1044 | placeItem->recreateIncidence(); |
1037 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1045 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1038 | } | 1046 | } |
1039 | int type = mActionType; | 1047 | int type = mActionType; |
1040 | if ( mAllDayMode ) | 1048 | if ( mAllDayMode ) |
1041 | type = -1; | 1049 | type = -1; |
1042 | KOAgendaItem *modifiedItem = placeItem; | 1050 | KOAgendaItem *modifiedItem = placeItem; |
1043 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1051 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1044 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1052 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1045 | KOAgendaItem *item; | 1053 | KOAgendaItem *item; |
1046 | 1054 | ||
1047 | if ( placeItem->incidence()->type() == "Todo" ) { | 1055 | if ( placeItem->incidence()->type() == "Todo" ) { |
1048 | mSelectedItem = 0; | 1056 | mSelectedItem = 0; |
1049 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1057 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1050 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1058 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1051 | emit itemModified( modifiedItem, mActionType ); | 1059 | emit itemModified( modifiedItem, mActionType ); |
1052 | } | 1060 | } |
1053 | else { | 1061 | else { |
1054 | #if 0 | 1062 | #if 0 |
1055 | for ( item=oldconflictItems.first(); item != 0; | 1063 | for ( item=oldconflictItems.first(); item != 0; |
1056 | item=oldconflictItems.next() ) { | 1064 | item=oldconflictItems.next() ) { |
1057 | placeSubCells(item); | 1065 | placeSubCells(item); |
1058 | } | 1066 | } |
1059 | while ( placeItem ) { | 1067 | while ( placeItem ) { |
1060 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1068 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1061 | placeSubCells( placeItem ); | 1069 | placeSubCells( placeItem ); |
1062 | placeItem = placeItem->nextMultiItem(); | 1070 | placeItem = placeItem->nextMultiItem(); |
1063 | } | 1071 | } |
1064 | #endif | 1072 | #endif |
1065 | 1073 | ||
1066 | globalFlagBlockAgendaItemPaint = 1; | 1074 | globalFlagBlockAgendaItemPaint = 1; |
1067 | for ( item=oldconflictItems.first(); item != 0; | 1075 | for ( item=oldconflictItems.first(); item != 0; |
1068 | item=oldconflictItems.next() ) { | 1076 | item=oldconflictItems.next() ) { |
1069 | placeSubCells(item); | 1077 | placeSubCells(item); |
1070 | } | 1078 | } |
1071 | while ( placeItem ) { | 1079 | while ( placeItem ) { |
1072 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1080 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1073 | oldconflictItems = placeItem->conflictItems(); | 1081 | oldconflictItems = placeItem->conflictItems(); |
1074 | for ( item=oldconflictItems.first(); item != 0; | 1082 | for ( item=oldconflictItems.first(); item != 0; |
1075 | item=oldconflictItems.next() ) { | 1083 | item=oldconflictItems.next() ) { |
1076 | placeSubCells(item); | 1084 | placeSubCells(item); |
1077 | } | 1085 | } |
1078 | placeSubCells( placeItem ); | 1086 | placeSubCells( placeItem ); |
1079 | placeItem = placeItem->nextMultiItem(); | 1087 | placeItem = placeItem->nextMultiItem(); |
1080 | } | 1088 | } |
1081 | globalFlagBlockAgendaItemPaint = 0; | 1089 | globalFlagBlockAgendaItemPaint = 0; |
1082 | for ( item=oldconflictItems.first(); item != 0; | 1090 | for ( item=oldconflictItems.first(); item != 0; |
1083 | item=oldconflictItems.next() ) { | 1091 | item=oldconflictItems.next() ) { |
1084 | globalFlagBlockAgendaItemUpdate = 0; | 1092 | globalFlagBlockAgendaItemUpdate = 0; |
1085 | item->repaintMe(); | 1093 | item->repaintMe(); |
1086 | globalFlagBlockAgendaItemUpdate = 1; | 1094 | globalFlagBlockAgendaItemUpdate = 1; |
1087 | item->repaint( false ); | 1095 | item->repaint( false ); |
1088 | } | 1096 | } |
1089 | placeItem = modifiedItem; | 1097 | placeItem = modifiedItem; |
1090 | 1098 | ||
1091 | while ( placeItem ) { | 1099 | while ( placeItem ) { |
1092 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1100 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1093 | globalFlagBlockAgendaItemUpdate = 0; | 1101 | globalFlagBlockAgendaItemUpdate = 0; |
1094 | placeItem->repaintMe(); | 1102 | placeItem->repaintMe(); |
1095 | globalFlagBlockAgendaItemUpdate = 1; | 1103 | globalFlagBlockAgendaItemUpdate = 1; |
1096 | placeItem->repaint(false); | 1104 | placeItem->repaint(false); |
1097 | placeItem = placeItem->nextMultiItem(); | 1105 | placeItem = placeItem->nextMultiItem(); |
1098 | } | 1106 | } |
1099 | emit itemModified( modifiedItem, mActionType ); | 1107 | emit itemModified( modifiedItem, mActionType ); |
1100 | 1108 | ||
1101 | 1109 | ||
1102 | placeItem = modifiedItem; | 1110 | placeItem = modifiedItem; |
1103 | while ( placeItem ) { | 1111 | while ( placeItem ) { |
1104 | oldconflictItems = placeItem->conflictItems(); | 1112 | oldconflictItems = placeItem->conflictItems(); |
1105 | for ( item=oldconflictItems.first(); item != 0; | 1113 | for ( item=oldconflictItems.first(); item != 0; |
1106 | item=oldconflictItems.next() ) { | 1114 | item=oldconflictItems.next() ) { |
1107 | placeSubCells(item); | 1115 | placeSubCells(item); |
1108 | } | 1116 | } |
1109 | placeSubCells( placeItem ); | 1117 | placeSubCells( placeItem ); |
1110 | placeItem = placeItem->nextMultiItem(); | 1118 | placeItem = placeItem->nextMultiItem(); |
1111 | 1119 | ||
1112 | } | 1120 | } |
1113 | placeItem = modifiedItem; | 1121 | placeItem = modifiedItem; |
1114 | while ( placeItem ) { | 1122 | while ( placeItem ) { |
1115 | oldconflictItems = placeItem->conflictItems(); | 1123 | oldconflictItems = placeItem->conflictItems(); |
1116 | for ( item=oldconflictItems.first(); item != 0; | 1124 | for ( item=oldconflictItems.first(); item != 0; |
1117 | item=oldconflictItems.next() ) { | 1125 | item=oldconflictItems.next() ) { |
1118 | globalFlagBlockAgendaItemUpdate = 0; | 1126 | globalFlagBlockAgendaItemUpdate = 0; |
1119 | item->repaintMe(); | 1127 | item->repaintMe(); |
1120 | globalFlagBlockAgendaItemUpdate = 1; | 1128 | globalFlagBlockAgendaItemUpdate = 1; |
1121 | item->repaint(false); | 1129 | item->repaint(false); |
1122 | } | 1130 | } |
1123 | placeItem = placeItem->nextMultiItem(); | 1131 | placeItem = placeItem->nextMultiItem(); |
1124 | } | 1132 | } |
1125 | /* | 1133 | /* |
1126 | 1134 | ||
1127 | oldconflictItems = modifiedItem->conflictItems(); | 1135 | oldconflictItems = modifiedItem->conflictItems(); |
1128 | for ( item=oldconflictItems.first(); item != 0; | 1136 | for ( item=oldconflictItems.first(); item != 0; |
1129 | item=oldconflictItems.next() ) { | 1137 | item=oldconflictItems.next() ) { |
1130 | globalFlagBlockAgendaItemUpdate = 0; | 1138 | globalFlagBlockAgendaItemUpdate = 0; |
1131 | item->paintMe(false); | 1139 | item->paintMe(false); |
1132 | globalFlagBlockAgendaItemUpdate = 1; | 1140 | globalFlagBlockAgendaItemUpdate = 1; |
1133 | item->repaint(false); | 1141 | item->repaint(false); |
1134 | } | 1142 | } |
1135 | */ | 1143 | */ |
1136 | 1144 | ||
1137 | 1145 | ||
1138 | } | 1146 | } |
1139 | 1147 | ||
1140 | } | 1148 | } |
1141 | 1149 | ||
1142 | mScrollUpTimer.stop(); | 1150 | mScrollUpTimer.stop(); |
1143 | mScrollDownTimer.stop(); | 1151 | mScrollDownTimer.stop(); |
1144 | setCursor( arrowCursor ); | 1152 | setCursor( arrowCursor ); |
1145 | mActionItem = 0; | 1153 | mActionItem = 0; |
1146 | mActionType = NOP; | 1154 | mActionType = NOP; |
1147 | mItemMoved = 0; | 1155 | mItemMoved = 0; |
1148 | 1156 | ||
1149 | } | 1157 | } |
1150 | 1158 | ||
1151 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1159 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1152 | { | 1160 | { |
1153 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1161 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1154 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1162 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1155 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1163 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1156 | // point = clipper()->mapFromGlobal(point); | 1164 | // point = clipper()->mapFromGlobal(point); |
1157 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1165 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1158 | 1166 | ||
1159 | int x,y; | 1167 | int x,y; |
1160 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1168 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1161 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1169 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1162 | int gx,gy; | 1170 | int gx,gy; |
1163 | contentsToGrid(x,y,gx,gy); | 1171 | contentsToGrid(x,y,gx,gy); |
1164 | 1172 | ||
1165 | // Change cursor to resize cursor if appropriate | 1173 | // Change cursor to resize cursor if appropriate |
1166 | if (mAllDayMode) { | 1174 | if (mAllDayMode) { |
1167 | int gridDistanceX = (x - gx * mGridSpacingX); | 1175 | int gridDistanceX = (x - gx * mGridSpacingX); |
1168 | if (gridDistanceX < mResizeBorderWidth && | 1176 | if (gridDistanceX < mResizeBorderWidth && |
1169 | moveItem->cellX() == gx) { | 1177 | moveItem->cellX() == gx) { |
1170 | setCursor(sizeHorCursor); | 1178 | setCursor(sizeHorCursor); |
1171 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1179 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1172 | moveItem->cellXWidth() == gx) { | 1180 | moveItem->cellXWidth() == gx) { |
1173 | setCursor(sizeHorCursor); | 1181 | setCursor(sizeHorCursor); |
1174 | } else { | 1182 | } else { |
1175 | setCursor(arrowCursor); | 1183 | setCursor(arrowCursor); |
1176 | } | 1184 | } |
1177 | } else { | 1185 | } else { |
1178 | int gridDistanceY = (y - gy * mGridSpacingY); | 1186 | int gridDistanceY = (y - gy * mGridSpacingY); |
1179 | if (gridDistanceY < mResizeBorderWidth && | 1187 | if (gridDistanceY < mResizeBorderWidth && |
1180 | moveItem->cellYTop() == gy && | 1188 | moveItem->cellYTop() == gy && |
1181 | !moveItem->firstMultiItem()) { | 1189 | !moveItem->firstMultiItem()) { |
1182 | setCursor(sizeVerCursor); | 1190 | setCursor(sizeVerCursor); |
1183 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1191 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1184 | moveItem->cellYBottom() == gy && | 1192 | moveItem->cellYBottom() == gy && |
1185 | !moveItem->lastMultiItem()) { | 1193 | !moveItem->lastMultiItem()) { |
1186 | setCursor(sizeVerCursor); | 1194 | setCursor(sizeVerCursor); |
1187 | } else { | 1195 | } else { |
1188 | setCursor(arrowCursor); | 1196 | setCursor(arrowCursor); |
1189 | } | 1197 | } |
1190 | } | 1198 | } |
1191 | } | 1199 | } |
1192 | 1200 | ||
1193 | 1201 | ||
1194 | /* | 1202 | /* |
1195 | Place item in cell and take care that multiple items using the same cell do | 1203 | Place item in cell and take care that multiple items using the same cell do |
1196 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1204 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1197 | it can get in all cases. | 1205 | it can get in all cases. |
1198 | At the moment the method has a bug: When an item is placed only the sub cell | 1206 | At the moment the method has a bug: When an item is placed only the sub cell |
1199 | widths of the items are changed, which are within the Y region the item to | 1207 | widths of the items are changed, which are within the Y region the item to |
1200 | place spans. When the sub cell width change of one of this items affects a | 1208 | place spans. When the sub cell width change of one of this items affects a |
1201 | cell, where other items are, which do not overlap in Y with the item to place, | 1209 | cell, where other items are, which do not overlap in Y with the item to place, |
1202 | the display gets corrupted, although the corruption looks quite nice. | 1210 | the display gets corrupted, although the corruption looks quite nice. |
1203 | */ | 1211 | */ |
1204 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1212 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1205 | { | 1213 | { |
1206 | 1214 | ||
1207 | QPtrList<KOAgendaItem> conflictItems; | 1215 | QPtrList<KOAgendaItem> conflictItems; |
1208 | int maxSubCells = 0; | 1216 | int maxSubCells = 0; |
1209 | QIntDict<KOAgendaItem> subCellDict(5); | 1217 | QIntDict<KOAgendaItem> subCellDict(5); |
1210 | 1218 | ||
1211 | KOAgendaItem *item; | 1219 | KOAgendaItem *item; |
1212 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1220 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1213 | if (item != placeItem) { | 1221 | if (item != placeItem) { |
1214 | if (placeItem->cellX() <= item->cellXWidth() && | 1222 | if (placeItem->cellX() <= item->cellXWidth() && |
1215 | placeItem->cellXWidth() >= item->cellX()) { | 1223 | placeItem->cellXWidth() >= item->cellX()) { |
1216 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1224 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1217 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1225 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1218 | conflictItems.append(item); | 1226 | conflictItems.append(item); |
1219 | if (item->subCells() > maxSubCells) | 1227 | if (item->subCells() > maxSubCells) |
1220 | maxSubCells = item->subCells(); | 1228 | maxSubCells = item->subCells(); |
1221 | subCellDict.insert(item->subCell(),item); | 1229 | subCellDict.insert(item->subCell(),item); |
1222 | } | 1230 | } |
1223 | } | 1231 | } |
1224 | } | 1232 | } |
1225 | } | 1233 | } |
1226 | 1234 | ||
1227 | if (conflictItems.count() > 0) { | 1235 | if (conflictItems.count() > 0) { |
1228 | // Look for unused sub cell and insert item | 1236 | // Look for unused sub cell and insert item |
1229 | int i; | 1237 | int i; |
1230 | for(i=0;i<maxSubCells;++i) { | 1238 | for(i=0;i<maxSubCells;++i) { |
1231 | if (!subCellDict.find(i)) { | 1239 | if (!subCellDict.find(i)) { |
1232 | placeItem->setSubCell(i); | 1240 | placeItem->setSubCell(i); |
1233 | break; | 1241 | break; |
1234 | } | 1242 | } |
1235 | } | 1243 | } |
1236 | if (i == maxSubCells) { | 1244 | if (i == maxSubCells) { |
1237 | placeItem->setSubCell(maxSubCells); | 1245 | placeItem->setSubCell(maxSubCells); |
1238 | maxSubCells++; // add new item to number of sub cells | 1246 | maxSubCells++; // add new item to number of sub cells |
1239 | } | 1247 | } |
1240 | 1248 | ||
1241 | // Prepare for sub cell geometry adjustment | 1249 | // Prepare for sub cell geometry adjustment |
1242 | int newSubCellWidth; | 1250 | int newSubCellWidth; |
1243 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1251 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1244 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1252 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1245 | conflictItems.append(placeItem); | 1253 | conflictItems.append(placeItem); |
1246 | 1254 | ||
1247 | 1255 | ||
1248 | // Adjust sub cell geometry of all direct conflict items | 1256 | // Adjust sub cell geometry of all direct conflict items |
1249 | for ( item=conflictItems.first(); item != 0; | 1257 | for ( item=conflictItems.first(); item != 0; |
1250 | item=conflictItems.next() ) { | 1258 | item=conflictItems.next() ) { |
1251 | item->setSubCells(maxSubCells); | 1259 | item->setSubCells(maxSubCells); |
1252 | if (mAllDayMode) { | 1260 | if (mAllDayMode) { |
1253 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1261 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1254 | } else { | 1262 | } else { |
1255 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1263 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1256 | } | 1264 | } |
1257 | int x,y; | 1265 | int x,y; |
1258 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1266 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1259 | if (mAllDayMode) { | 1267 | if (mAllDayMode) { |
1260 | y += item->subCell() * newSubCellWidth; | 1268 | y += item->subCell() * newSubCellWidth; |
1261 | } else { | 1269 | } else { |
1262 | x += item->subCell() * newSubCellWidth; | 1270 | x += item->subCell() * newSubCellWidth; |
1263 | } | 1271 | } |
1264 | moveChild(item,x,y); | 1272 | moveChild(item,x,y); |
1265 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1273 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1266 | //item->updateItem(); | 1274 | //item->updateItem(); |
1267 | } | 1275 | } |
1268 | // Adjust sub cell geometry of all conflict items of all conflict items | 1276 | // Adjust sub cell geometry of all conflict items of all conflict items |
1269 | for ( item=conflictItems.first(); item != 0; | 1277 | for ( item=conflictItems.first(); item != 0; |
1270 | item=conflictItems.next() ) { | 1278 | item=conflictItems.next() ) { |
1271 | if ( placeItem != item ) { | 1279 | if ( placeItem != item ) { |
1272 | KOAgendaItem *item2; | 1280 | KOAgendaItem *item2; |
1273 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1281 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1274 | for ( item2=conflictItems2.first(); item2 != 0; | 1282 | for ( item2=conflictItems2.first(); item2 != 0; |
1275 | item2=conflictItems2.next() ) { | 1283 | item2=conflictItems2.next() ) { |
1276 | if ( item2->subCells() != maxSubCells) { | 1284 | if ( item2->subCells() != maxSubCells) { |
1277 | item2->setSubCells(maxSubCells); | 1285 | item2->setSubCells(maxSubCells); |
1278 | if (mAllDayMode) { | 1286 | if (mAllDayMode) { |
1279 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1287 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1280 | } else { | 1288 | } else { |
1281 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1289 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1282 | } | 1290 | } |
1283 | int x,y; | 1291 | int x,y; |
1284 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1292 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1285 | if (mAllDayMode) { | 1293 | if (mAllDayMode) { |
1286 | y += item2->subCell() * newSubCellWidth; | 1294 | y += item2->subCell() * newSubCellWidth; |
1287 | } else { | 1295 | } else { |
1288 | x += item2->subCell() * newSubCellWidth; | 1296 | x += item2->subCell() * newSubCellWidth; |
1289 | } | 1297 | } |
1290 | moveChild(item2,x,y); | 1298 | moveChild(item2,x,y); |
1291 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1299 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1292 | } | 1300 | } |
1293 | } | 1301 | } |
1294 | } | 1302 | } |
1295 | } | 1303 | } |
1296 | } else { | 1304 | } else { |
1297 | placeItem->setSubCell(0); | 1305 | placeItem->setSubCell(0); |
1298 | placeItem->setSubCells(1); | 1306 | placeItem->setSubCells(1); |
1299 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1307 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1300 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1308 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1301 | int x,y; | 1309 | int x,y; |
1302 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1310 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1303 | moveChild(placeItem,x,y); | 1311 | moveChild(placeItem,x,y); |
1304 | } | 1312 | } |
1305 | placeItem->setConflictItems(conflictItems); | 1313 | placeItem->setConflictItems(conflictItems); |
1306 | // for ( item=conflictItems.first(); item != 0; | 1314 | // for ( item=conflictItems.first(); item != 0; |
1307 | // item=conflictItems.next() ) { | 1315 | // item=conflictItems.next() ) { |
1308 | // //item->updateItem(); | 1316 | // //item->updateItem(); |
1309 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1317 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1310 | // } | 1318 | // } |
1311 | // placeItem->updateItem(); | 1319 | // placeItem->updateItem(); |
1312 | } | 1320 | } |
1313 | 1321 | ||
1314 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1322 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1315 | { | 1323 | { |
1316 | if ( globalFlagBlockAgenda ) | 1324 | if ( globalFlagBlockAgenda ) |
1317 | return; | 1325 | return; |
1318 | //qDebug("KOAgenda::drawContents "); | 1326 | //qDebug("KOAgenda::drawContents "); |
1319 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1327 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1320 | ;//drawContentsToPainter(); | 1328 | ;//drawContentsToPainter(); |
1321 | 1329 | ||
1322 | QPaintDevice* pd = p->device(); | 1330 | QPaintDevice* pd = p->device(); |
1323 | p->end(); | 1331 | p->end(); |
1324 | int vx, vy; | 1332 | int vx, vy; |
1325 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1333 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1326 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1334 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1327 | mSelectionCellX * mGridSpacingX; | 1335 | mSelectionCellX * mGridSpacingX; |
1328 | contentsToViewport ( cx, cy, vx,vy); | 1336 | contentsToViewport ( cx, cy, vx,vy); |
1329 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1337 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1330 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1338 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1331 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1339 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1332 | 1340 | ||
1333 | if ( mSelectionHeight > 0 ) { | 1341 | if ( mSelectionHeight > 0 ) { |
1334 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1342 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1335 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1343 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1336 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1344 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1337 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1345 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1338 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1346 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1339 | } | 1347 | } |
1340 | } | 1348 | } |
1341 | //qDebug("btbl "); | 1349 | //qDebug("btbl "); |
1342 | p->begin( pd ); | 1350 | p->begin( pd ); |
1343 | //qDebug("end "); | 1351 | //qDebug("end "); |
1344 | } | 1352 | } |
1345 | 1353 | ||
1346 | void KOAgenda::finishUpdate() | 1354 | void KOAgenda::finishUpdate() |
1347 | { | 1355 | { |
1348 | 1356 | ||
1349 | KOAgendaItem *item; | 1357 | KOAgendaItem *item; |
1350 | globalFlagBlockAgendaItemPaint = 1; | 1358 | globalFlagBlockAgendaItemPaint = 1; |
1351 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1359 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1352 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1360 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1353 | if ( !item->checkLayout() ) { | 1361 | if ( !item->checkLayout() ) { |
1354 | //qDebug(" conflictitem found "); | 1362 | //qDebug(" conflictitem found "); |
1355 | int newSubCellWidth; | 1363 | int newSubCellWidth; |
1356 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1364 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1357 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1365 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1358 | 1366 | ||
1359 | if (mAllDayMode) { | 1367 | if (mAllDayMode) { |
1360 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1368 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1361 | } else { | 1369 | } else { |
1362 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1370 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1363 | } | 1371 | } |
1364 | int x,y; | 1372 | int x,y; |
1365 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1373 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1366 | if (mAllDayMode) { | 1374 | if (mAllDayMode) { |
1367 | y += item->subCell() * newSubCellWidth; | 1375 | y += item->subCell() * newSubCellWidth; |
1368 | } else { | 1376 | } else { |
1369 | x += item->subCell() * newSubCellWidth; | 1377 | x += item->subCell() * newSubCellWidth; |
1370 | } | 1378 | } |
1371 | moveChild(item,x,y); | 1379 | moveChild(item,x,y); |
1372 | } | 1380 | } |
1373 | } | 1381 | } |
1374 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1382 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1375 | if ( !item->isVisible() ) | 1383 | if ( !item->isVisible() ) |
1376 | item->show(); | 1384 | item->show(); |
1377 | 1385 | ||
1378 | } | 1386 | } |
1379 | globalFlagBlockAgendaItemUpdate = 0; | 1387 | globalFlagBlockAgendaItemUpdate = 0; |
1380 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1388 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1381 | item->repaintMe( ); | 1389 | item->repaintMe( ); |
1382 | } | 1390 | } |
1383 | globalFlagBlockAgendaItemUpdate = 1; | 1391 | globalFlagBlockAgendaItemUpdate = 1; |
1384 | qApp->processEvents(); | 1392 | qApp->processEvents(); |
1385 | globalFlagBlockAgendaItemPaint = 0; | 1393 | globalFlagBlockAgendaItemPaint = 0; |
1386 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1394 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1387 | item->repaint( false ); | 1395 | item->repaint( false ); |
1388 | } | 1396 | } |
1389 | 1397 | ||
1390 | } | 1398 | } |
1391 | 1399 | ||
1392 | /* | 1400 | /* |
1393 | Draw grid in the background of the agenda. | 1401 | Draw grid in the background of the agenda. |
1394 | */ | 1402 | */ |
1395 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1403 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1396 | { | 1404 | { |
1397 | 1405 | ||
1398 | 1406 | ||
1399 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1407 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1400 | return; | 1408 | return; |
1401 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1409 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1402 | return; | 1410 | return; |
1403 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1411 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1404 | if ( ch < 1 ) | 1412 | if ( ch < 1 ) |
1405 | ch = 1; | 1413 | ch = 1; |
1406 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1414 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1407 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1415 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1408 | } | 1416 | } |
1409 | mCurPixWid = contentsWidth(); | 1417 | mCurPixWid = contentsWidth(); |
1410 | mCurPixHei = ch; | 1418 | mCurPixHei = ch; |
1411 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1419 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1412 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1420 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1413 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1421 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1414 | } | 1422 | } |
1415 | mPixPainter.begin( &mPaintPixmap) ; | 1423 | mPixPainter.begin( &mPaintPixmap) ; |
1416 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1424 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1417 | QPainter * p ; | 1425 | QPainter * p ; |
1418 | if (paint == 0) { | 1426 | if (paint == 0) { |
1419 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1427 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1420 | p = &mPixPainter; | 1428 | p = &mPixPainter; |
1421 | } | 1429 | } |
1422 | else | 1430 | else |
1423 | p = paint ; | 1431 | p = paint ; |
1424 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1432 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1425 | 1433 | ||
1426 | //--cx;++cw; | 1434 | //--cx;++cw; |
1427 | int lGridSpacingY = mGridSpacingY*2; | 1435 | int lGridSpacingY = mGridSpacingY*2; |
1428 | int selDay; | 1436 | int selDay; |
1429 | if ( !backgroundOnly ) | 1437 | if ( !backgroundOnly ) |
1430 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1438 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1431 | { | 1439 | { |
1432 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1440 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1433 | int x1 = cx; | 1441 | int x1 = cx; |
1434 | int y1 = 0; | 1442 | int y1 = 0; |
1435 | if (y1 < cy) y1 = cy; | 1443 | if (y1 < cy) y1 = cy; |
1436 | int x2 = cx+cw-1; | 1444 | int x2 = cx+cw-1; |
1437 | int y2 = contentsHeight(); | 1445 | int y2 = contentsHeight(); |
1438 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1446 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1439 | if (x2 >= x1 && y2 >= y1) { | 1447 | if (x2 >= x1 && y2 >= y1) { |
1440 | int gxStart = selDay; | 1448 | int gxStart = selDay; |
1441 | int gxEnd = gxStart ; | 1449 | int gxEnd = gxStart ; |
1442 | int xStart = KOGlobals::self()->reverseLayout() ? | 1450 | int xStart = KOGlobals::self()->reverseLayout() ? |
1443 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1451 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1444 | gxStart*mGridSpacingX; | 1452 | gxStart*mGridSpacingX; |
1445 | if (xStart < x1) xStart = x1; | 1453 | if (xStart < x1) xStart = x1; |
1446 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1454 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1447 | (mColumns - gxStart)*mGridSpacingX-1 : | 1455 | (mColumns - gxStart)*mGridSpacingX-1 : |
1448 | (gxStart+1)*mGridSpacingX-1; | 1456 | (gxStart+1)*mGridSpacingX-1; |
1449 | if (xEnd > x2) xEnd = x2; | 1457 | if (xEnd > x2) xEnd = x2; |
1450 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1458 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1451 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1459 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1452 | KOPrefs::instance()->mAgendaBgColor.light()); | 1460 | KOPrefs::instance()->mAgendaBgColor.light()); |
1453 | else | 1461 | else |
1454 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1462 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1455 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1463 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1456 | 1464 | ||
1457 | } | 1465 | } |
1458 | } | 1466 | } |
1459 | } | 1467 | } |
1460 | // Highlight working hours | 1468 | // Highlight working hours |
1461 | 1469 | ||
1462 | if ( !backgroundOnly ) | 1470 | if ( !backgroundOnly ) |
1463 | if (mWorkingHoursEnable) { | 1471 | if (mWorkingHoursEnable) { |
1464 | int x1 = cx; | 1472 | int x1 = cx; |
1465 | int y1 = mWorkingHoursYTop; | 1473 | int y1 = mWorkingHoursYTop; |
1466 | if (y1 < cy) y1 = cy; | 1474 | if (y1 < cy) y1 = cy; |
1467 | int x2 = cx+cw-1; | 1475 | int x2 = cx+cw-1; |
1468 | // int x2 = mGridSpacingX * 5 - 1; | 1476 | // int x2 = mGridSpacingX * 5 - 1; |
1469 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1477 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1470 | int y2 = mWorkingHoursYBottom; | 1478 | int y2 = mWorkingHoursYBottom; |
1471 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1479 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1472 | 1480 | ||
1473 | if (x2 >= x1 && y2 >= y1) { | 1481 | if (x2 >= x1 && y2 >= y1) { |
1474 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1482 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1475 | int gxStart = x1/mGridSpacingX; | 1483 | int gxStart = x1/mGridSpacingX; |
1476 | int gxEnd = x2/mGridSpacingX; | 1484 | int gxEnd = x2/mGridSpacingX; |
1477 | while(gxStart <= gxEnd) { | 1485 | while(gxStart <= gxEnd) { |
1478 | if (gxStart < int(mHolidayMask->count()) && | 1486 | if (gxStart < int(mHolidayMask->count()) && |
1479 | !mHolidayMask->at(gxStart)) { | 1487 | !mHolidayMask->at(gxStart)) { |
1480 | int xStart = KOGlobals::self()->reverseLayout() ? | 1488 | int xStart = KOGlobals::self()->reverseLayout() ? |
1481 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1489 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1482 | gxStart*mGridSpacingX; | 1490 | gxStart*mGridSpacingX; |
1483 | if (xStart < x1) xStart = x1; | 1491 | if (xStart < x1) xStart = x1; |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f6f390b..f452db0 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1590 +1,1592 @@ | |||
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 | 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 <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | mRows = rows; | 84 | mRows = rows; |
85 | 85 | ||
86 | setMinimumHeight( 20 ); | 86 | setMinimumHeight( 20 ); |
87 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 87 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
88 | 88 | ||
89 | enableClipper(true); | 89 | enableClipper(true); |
90 | 90 | ||
91 | setHScrollBarMode(AlwaysOff); | 91 | setHScrollBarMode(AlwaysOff); |
92 | setVScrollBarMode(AlwaysOff); | 92 | setVScrollBarMode(AlwaysOff); |
93 | 93 | ||
94 | resizeContents(50,mRows * mCellHeight); | 94 | resizeContents(50,mRows * mCellHeight); |
95 | 95 | ||
96 | viewport()->setBackgroundMode( PaletteBackground ); | 96 | viewport()->setBackgroundMode( PaletteBackground ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void TimeLabels::setCellHeight(int height) |
100 | { | 100 | { |
101 | mCellHeight = height; | 101 | mCellHeight = height; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | Optimization so that only the "dirty" portion of the scroll view | 105 | Optimization so that only the "dirty" portion of the scroll view |
106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
107 | */ | 107 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
109 | { | 109 | { |
110 | 110 | ||
111 | // if ( globalFlagBlockAgenda ) | 111 | // if ( globalFlagBlockAgenda ) |
112 | // return; | 112 | // return; |
113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
114 | // redrawn, not the area of the widget. unfortunately, this | 114 | // redrawn, not the area of the widget. unfortunately, this |
115 | // code assumes the latter... | 115 | // code assumes the latter... |
116 | 116 | ||
117 | // now, for a workaround... | 117 | // now, for a workaround... |
118 | // these two assignments fix the weird redraw bug | 118 | // these two assignments fix the weird redraw bug |
119 | cx = contentsX() + 2; | 119 | cx = contentsX() + 2; |
120 | cw = contentsWidth() - 2; | 120 | cw = contentsWidth() - 2; |
121 | // end of workaround | 121 | // end of workaround |
122 | 122 | ||
123 | int cell = ((int)(cy/mCellHeight)); | 123 | int cell = ((int)(cy/mCellHeight)); |
124 | int y = cell * mCellHeight; | 124 | int y = cell * mCellHeight; |
125 | QFontMetrics fm = fontMetrics(); | 125 | QFontMetrics fm = fontMetrics(); |
126 | QString hour; | 126 | QString hour; |
127 | QString suffix; | 127 | QString suffix; |
128 | int tW = fm.width("24:00i"); | 128 | int tW = fm.width("24:00i"); |
129 | int timeHeight = fm.height(); | 129 | int timeHeight = fm.height(); |
130 | //timeHeight -= (timeHeight/4-2); | 130 | //timeHeight -= (timeHeight/4-2); |
131 | int borderWidth = 0; | 131 | int borderWidth = 0; |
132 | QFont nFont = p->font(); | 132 | QFont nFont = p->font(); |
133 | 133 | ||
134 | if (!KGlobal::locale()->use12Clock()) | 134 | if (!KGlobal::locale()->use12Clock()) |
135 | suffix = "00"; | 135 | suffix = "00"; |
136 | else | 136 | else |
137 | borderWidth = 0; | 137 | borderWidth = 0; |
138 | if ( timeHeight > mCellHeight ) { | 138 | if ( timeHeight > mCellHeight ) { |
139 | timeHeight = mCellHeight-1; | 139 | timeHeight = mCellHeight-1; |
140 | int pointS = nFont.pointSize(); | 140 | int pointS = nFont.pointSize(); |
141 | while ( pointS > 4 ) { | 141 | while ( pointS > 4 ) { |
142 | nFont.setPointSize( pointS ); | 142 | nFont.setPointSize( pointS ); |
143 | fm = QFontMetrics( nFont ); | 143 | fm = QFontMetrics( nFont ); |
144 | if ( fm.height() < mCellHeight ) | 144 | if ( fm.height() < mCellHeight ) |
145 | break; | 145 | break; |
146 | -- pointS; | 146 | -- pointS; |
147 | } | 147 | } |
148 | fm = QFontMetrics( nFont ); | 148 | fm = QFontMetrics( nFont ); |
149 | borderWidth = 4; | 149 | borderWidth = 4; |
150 | timeHeight = fm.height(); | 150 | timeHeight = fm.height(); |
151 | } | 151 | } |
152 | timeHeight -= (timeHeight/4-2); | 152 | timeHeight -= (timeHeight/4-2); |
153 | QFont sFont = nFont; | 153 | QFont sFont = nFont; |
154 | sFont.setPointSize( sFont.pointSize()/2+2 ); | 154 | sFont.setPointSize( sFont.pointSize()/2+2 ); |
155 | QFontMetrics fmS( sFont ); | 155 | QFontMetrics fmS( sFont ); |
156 | int sHei = fmS.height(); | 156 | int sHei = fmS.height(); |
157 | sHei -= (sHei/4-2); | 157 | sHei -= (sHei/4-2); |
158 | int startW = this->width() - frameWidth(); | 158 | int startW = this->width() - frameWidth(); |
159 | while (y < cy + ch) { | 159 | while (y < cy + ch) { |
160 | p->drawLine(cx,y,cx+tW,y); | 160 | p->drawLine(cx,y,cx+tW,y); |
161 | hour.setNum(cell); | 161 | hour.setNum(cell); |
162 | 162 | ||
163 | // handle 24h and am/pm time formats | 163 | // handle 24h and am/pm time formats |
164 | if (KGlobal::locale()->use12Clock()) { | 164 | if (KGlobal::locale()->use12Clock()) { |
165 | if (cell > 11) suffix = "pm"; | 165 | if (cell > 11) suffix = "pm"; |
166 | else | 166 | else |
167 | suffix = "am"; | 167 | suffix = "am"; |
168 | if (cell == 0) hour.setNum(12); | 168 | if (cell == 0) hour.setNum(12); |
169 | if (cell > 12) hour.setNum(cell - 12); | 169 | if (cell > 12) hour.setNum(cell - 12); |
170 | } | 170 | } |
171 | 171 | ||
172 | // center and draw the time label | 172 | // center and draw the time label |
173 | int timeWidth = fm.width(hour+"i"); | 173 | int timeWidth = fm.width(hour+"i"); |
174 | int tw2 = fm.width(suffix); | 174 | int tw2 = fm.width(suffix); |
175 | int offset = startW - timeWidth - tw2 ; | 175 | int offset = startW - timeWidth - tw2 ; |
176 | p->setFont( nFont ); | 176 | p->setFont( nFont ); |
177 | p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); | 177 | p->drawText(cx - borderWidth + offset, y+ timeHeight, hour); |
178 | p->setFont( sFont ); | 178 | p->setFont( sFont ); |
179 | offset = startW - tw2-1; | 179 | offset = startW - tw2-1; |
180 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); | 180 | p->drawText(cx - borderWidth + offset, y+ sHei, suffix); |
181 | 181 | ||
182 | // increment indices | 182 | // increment indices |
183 | y += mCellHeight; | 183 | y += mCellHeight; |
184 | cell++; | 184 | cell++; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | /** | 188 | /** |
189 | Calculates the minimum width. | 189 | Calculates the minimum width. |
190 | */ | 190 | */ |
191 | int TimeLabels::minimumWidth() const | 191 | int TimeLabels::minimumWidth() const |
192 | { | 192 | { |
193 | return mMiniWidth; | 193 | return mMiniWidth; |
194 | } | 194 | } |
195 | 195 | ||
196 | /** updates widget's internal state */ | 196 | /** updates widget's internal state */ |
197 | void TimeLabels::updateConfig() | 197 | void TimeLabels::updateConfig() |
198 | { | 198 | { |
199 | // set the font | 199 | // set the font |
200 | // config->setGroup("Fonts"); | 200 | // config->setGroup("Fonts"); |
201 | // QFont font = config->readFontEntry("TimeBar Font"); | 201 | // QFont font = config->readFontEntry("TimeBar Font"); |
202 | setFont(KOPrefs::instance()->mTimeBarFont); | 202 | setFont(KOPrefs::instance()->mTimeBarFont); |
203 | QString test = "88:88"; | 203 | QString test = "88:88"; |
204 | if (KGlobal::locale()->use12Clock()) | 204 | if (KGlobal::locale()->use12Clock()) |
205 | test += "i"; | 205 | test += "i"; |
206 | mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; | 206 | mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ; |
207 | // update geometry restrictions based on new settings | 207 | // update geometry restrictions based on new settings |
208 | setFixedWidth(minimumWidth()); | 208 | setFixedWidth(minimumWidth()); |
209 | 209 | ||
210 | // update HourSize | 210 | // update HourSize |
211 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 211 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
212 | resizeContents(50,mRows * mCellHeight); | 212 | resizeContents(50,mRows * mCellHeight); |
213 | } | 213 | } |
214 | 214 | ||
215 | /** update time label positions */ | 215 | /** update time label positions */ |
216 | void TimeLabels::positionChanged() | 216 | void TimeLabels::positionChanged() |
217 | { | 217 | { |
218 | int adjustment = mAgenda->contentsY(); | 218 | int adjustment = mAgenda->contentsY(); |
219 | setContentsPos(0, adjustment); | 219 | setContentsPos(0, adjustment); |
220 | } | 220 | } |
221 | 221 | ||
222 | /** */ | 222 | /** */ |
223 | void TimeLabels::setAgenda(KOAgenda* agenda) | 223 | void TimeLabels::setAgenda(KOAgenda* agenda) |
224 | { | 224 | { |
225 | mAgenda = agenda; | 225 | mAgenda = agenda; |
226 | } | 226 | } |
227 | 227 | ||
228 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 228 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
229 | { | 229 | { |
230 | mMouseDownY = e->pos().y(); | 230 | mMouseDownY = e->pos().y(); |
231 | mOrgCap = topLevelWidget()->caption(); | 231 | mOrgCap = topLevelWidget()->caption(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 234 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
235 | { | 235 | { |
236 | int diff = mMouseDownY - e->pos().y(); | 236 | int diff = mMouseDownY - e->pos().y(); |
237 | if ( diff < 10 && diff > -10 ) | 237 | if ( diff < 10 && diff > -10 ) |
238 | return; | 238 | return; |
239 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 239 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
240 | if ( tSize < 4 ) | 240 | if ( tSize < 4 ) |
241 | tSize = 4; | 241 | tSize = 4; |
242 | if ( tSize > 22 ) | 242 | if ( tSize > 22 ) |
243 | tSize = 22; | 243 | tSize = 22; |
244 | tSize = (tSize-2)/2; | 244 | tSize = (tSize-2)/2; |
245 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 245 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
246 | 246 | ||
247 | } | 247 | } |
248 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 248 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
249 | { | 249 | { |
250 | topLevelWidget()->setCaption( mOrgCap ); | 250 | topLevelWidget()->setCaption( mOrgCap ); |
251 | int diff = mMouseDownY - e->pos().y(); | 251 | int diff = mMouseDownY - e->pos().y(); |
252 | if ( diff < 10 && diff > -10 ) | 252 | if ( diff < 10 && diff > -10 ) |
253 | return; | 253 | return; |
254 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 254 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
255 | if ( tSize < 4 ) | 255 | if ( tSize < 4 ) |
256 | tSize = 4; | 256 | tSize = 4; |
257 | if ( tSize > 22 ) | 257 | if ( tSize > 22 ) |
258 | tSize = 22; | 258 | tSize = 22; |
259 | tSize = (tSize/2)*2; | 259 | tSize = (tSize/2)*2; |
260 | if ( tSize == KOPrefs::instance()->mHourSize ) | 260 | if ( tSize == KOPrefs::instance()->mHourSize ) |
261 | return; | 261 | return; |
262 | KOPrefs::instance()->mHourSize = tSize; | 262 | KOPrefs::instance()->mHourSize = tSize; |
263 | emit scaleChanged(); | 263 | emit scaleChanged(); |
264 | } | 264 | } |
265 | 265 | ||
266 | /** This is called in response to repaint() */ | 266 | /** This is called in response to repaint() */ |
267 | void TimeLabels::paintEvent(QPaintEvent*) | 267 | void TimeLabels::paintEvent(QPaintEvent*) |
268 | { | 268 | { |
269 | 269 | ||
270 | // kdDebug() << "paintevent..." << endl; | 270 | // kdDebug() << "paintevent..." << endl; |
271 | // this is another hack! | 271 | // this is another hack! |
272 | // QPainter painter(this); | 272 | // QPainter painter(this); |
273 | //QString c | 273 | //QString c |
274 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 274 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
275 | } | 275 | } |
276 | 276 | ||
277 | //////////////////////////////////////////////////////////////////////////// | 277 | //////////////////////////////////////////////////////////////////////////// |
278 | 278 | ||
279 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 279 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
280 | : QFrame(parent,name) | 280 | : QFrame(parent,name) |
281 | { | 281 | { |
282 | mColumns = 1; | 282 | mColumns = 1; |
283 | mTopBox = 0; | 283 | mTopBox = 0; |
284 | mLocation = loc; | 284 | mLocation = loc; |
285 | mTopLayout = 0; | 285 | mTopLayout = 0; |
286 | mPaintWidget = 0; | 286 | mPaintWidget = 0; |
287 | mXOffset = 0; | 287 | mXOffset = 0; |
288 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 288 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
289 | else mPixmap = SmallIcon("1downarrow"); | 289 | else mPixmap = SmallIcon("1downarrow"); |
290 | mEnabled.resize(mColumns); | 290 | mEnabled.resize(mColumns); |
291 | mEnabled.fill( false ); | 291 | mEnabled.fill( false ); |
292 | setMinimumHeight(mPixmap.height()); | 292 | setMinimumHeight(mPixmap.height()); |
293 | } | 293 | } |
294 | 294 | ||
295 | EventIndicator::~EventIndicator() | 295 | EventIndicator::~EventIndicator() |
296 | { | 296 | { |
297 | } | 297 | } |
298 | 298 | ||
299 | void EventIndicator::drawContents(QPainter *p) | 299 | void EventIndicator::drawContents(QPainter *p) |
300 | { | 300 | { |
301 | 301 | ||
302 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 302 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
303 | KDGanttSplitterHandle* han = 0; | 303 | KDGanttSplitterHandle* han = 0; |
304 | if ( mPaintWidget ) | 304 | if ( mPaintWidget ) |
305 | han = mPaintWidget->firstHandle(); | 305 | han = mPaintWidget->firstHandle(); |
306 | if ( ! han ) { | 306 | if ( ! han ) { |
307 | int i; | 307 | int i; |
308 | for(i=0;i<mColumns;++i) { | 308 | for(i=0;i<mColumns;++i) { |
309 | if (mEnabled[i]) { | 309 | if (mEnabled[i]) { |
310 | int cellWidth = contentsRect().right()/mColumns; | 310 | int cellWidth = contentsRect().right()/mColumns; |
311 | int xOffset = KOGlobals::self()->reverseLayout() ? | 311 | int xOffset = KOGlobals::self()->reverseLayout() ? |
312 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 312 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
313 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 313 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
314 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 314 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | } else { | 317 | } else { |
318 | han->repaint(); | 318 | han->repaint(); |
319 | //mPaintWidget->setBackgroundColor( red ); | 319 | //mPaintWidget->setBackgroundColor( red ); |
320 | 320 | ||
321 | QPainter pa( han ); | 321 | QPainter pa( han ); |
322 | int i; | 322 | int i; |
323 | bool setColor = false; | 323 | bool setColor = false; |
324 | for(i=0;i<mColumns;++i) { | 324 | for(i=0;i<mColumns;++i) { |
325 | if (mEnabled[i]) { | 325 | if (mEnabled[i]) { |
326 | setColor = true; | 326 | setColor = true; |
327 | 327 | ||
328 | int cellWidth = contentsRect().right()/mColumns; | 328 | int cellWidth = contentsRect().right()/mColumns; |
329 | int xOffset = KOGlobals::self()->reverseLayout() ? | 329 | int xOffset = KOGlobals::self()->reverseLayout() ? |
330 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 330 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
331 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 331 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
332 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 332 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
333 | //qDebug("222draw pix %d ",xOffset ); | 333 | //qDebug("222draw pix %d ",xOffset ); |
334 | 334 | ||
335 | } | 335 | } |
336 | 336 | ||
337 | } | 337 | } |
338 | pa.end(); | 338 | pa.end(); |
339 | 339 | ||
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | void EventIndicator::setXOffset( int x ) | 343 | void EventIndicator::setXOffset( int x ) |
344 | { | 344 | { |
345 | mXOffset = x; | 345 | mXOffset = x; |
346 | } | 346 | } |
347 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 347 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
348 | { | 348 | { |
349 | mPaintWidget = w; | 349 | mPaintWidget = w; |
350 | setMaximumHeight(0); | 350 | setMaximumHeight(0); |
351 | setMinimumHeight(0); | 351 | setMinimumHeight(0); |
352 | } | 352 | } |
353 | void EventIndicator::changeColumns(int columns) | 353 | void EventIndicator::changeColumns(int columns) |
354 | { | 354 | { |
355 | mColumns = columns; | 355 | mColumns = columns; |
356 | mEnabled.resize(mColumns); | 356 | mEnabled.resize(mColumns); |
357 | 357 | ||
358 | update(); | 358 | update(); |
359 | } | 359 | } |
360 | 360 | ||
361 | void EventIndicator::enableColumn(int column, bool enable) | 361 | void EventIndicator::enableColumn(int column, bool enable) |
362 | { | 362 | { |
363 | mEnabled[column] = enable; | 363 | mEnabled[column] = enable; |
364 | } | 364 | } |
365 | 365 | ||
366 | 366 | ||
367 | //////////////////////////////////////////////////////////////////////////// | 367 | //////////////////////////////////////////////////////////////////////////// |
368 | //////////////////////////////////////////////////////////////////////////// | 368 | //////////////////////////////////////////////////////////////////////////// |
369 | //////////////////////////////////////////////////////////////////////////// | 369 | //////////////////////////////////////////////////////////////////////////// |
370 | 370 | ||
371 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 371 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
372 | KOEventView (cal,parent,name) | 372 | KOEventView (cal,parent,name) |
373 | { | 373 | { |
374 | mBlockUpdating = true; | 374 | mBlockUpdating = true; |
375 | mStartHour = 8; | 375 | mStartHour = 8; |
376 | mSelectedDates.append(QDate::currentDate()); | 376 | mSelectedDates.append(QDate::currentDate()); |
377 | 377 | ||
378 | mLayoutDayLabels = 0; | 378 | mLayoutDayLabels = 0; |
379 | mDayLabelsFrame = 0; | 379 | mDayLabelsFrame = 0; |
380 | mDayLabels = 0; | 380 | mDayLabels = 0; |
381 | bool isRTL = KOGlobals::self()->reverseLayout(); | 381 | bool isRTL = KOGlobals::self()->reverseLayout(); |
382 | QPixmap expandPix; | 382 | QPixmap expandPix; |
383 | if ( KOPrefs::instance()->mVerticalScreen ) { | 383 | if ( KOPrefs::instance()->mVerticalScreen ) { |
384 | expandPix = SmallIcon( "1updownarrow" ); | 384 | expandPix = SmallIcon( "1updownarrow" ); |
385 | } else { | 385 | } else { |
386 | expandPix = SmallIcon("1leftrightarrow" ); | 386 | expandPix = SmallIcon("1leftrightarrow" ); |
387 | } | 387 | } |
388 | 388 | ||
389 | QBoxLayout *topLayout = new QVBoxLayout(this); | 389 | QBoxLayout *topLayout = new QVBoxLayout(this); |
390 | 390 | ||
391 | // Create day name labels for agenda columns | 391 | // Create day name labels for agenda columns |
392 | // Create agenda splitter | 392 | // Create agenda splitter |
393 | 393 | ||
394 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 394 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
395 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 395 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
396 | topLayout->addWidget( mSplitterAgenda ); | 396 | topLayout->addWidget( mSplitterAgenda ); |
397 | mAllDayFrame = new QHBox(mSplitterAgenda); | 397 | mAllDayFrame = new QHBox(mSplitterAgenda); |
398 | mAllDayFrame->setFocusPolicy(NoFocus); | 398 | mAllDayFrame->setFocusPolicy(NoFocus); |
399 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 399 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
400 | agendaFrame->setFocusPolicy(NoFocus); | 400 | agendaFrame->setFocusPolicy(NoFocus); |
401 | 401 | ||
402 | // Create all-day agenda widget | 402 | // Create all-day agenda widget |
403 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 403 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
404 | 404 | ||
405 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 405 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
406 | mExpandButton->setPixmap( expandPix ); | 406 | mExpandButton->setPixmap( expandPix ); |
407 | int widebut = mExpandButton->sizeHint().width()+4; | 407 | int widebut = mExpandButton->sizeHint().width()+4; |
408 | int heibut = mExpandButton->sizeHint().height()+4; | 408 | int heibut = mExpandButton->sizeHint().height()+4; |
409 | if ( heibut > widebut ) | 409 | if ( heibut > widebut ) |
410 | widebut = heibut ; | 410 | widebut = heibut ; |
411 | if ( QApplication::desktop()->width() < 480 ) | 411 | if ( QApplication::desktop()->width() < 480 ) |
412 | widebut = widebut*3/2; | 412 | widebut = widebut*3/2; |
413 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 413 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
414 | // QSizePolicy::Fixed ) ); | 414 | // QSizePolicy::Fixed ) ); |
415 | mExpandButton->setFixedSize( widebut, widebut); | 415 | mExpandButton->setFixedSize( widebut, widebut); |
416 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 416 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
417 | mExpandButton->setFocusPolicy(NoFocus); | 417 | mExpandButton->setFocusPolicy(NoFocus); |
418 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 418 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
419 | mAllDayAgenda->setFocusPolicy(NoFocus); | 419 | mAllDayAgenda->setFocusPolicy(NoFocus); |
420 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 420 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
421 | 421 | ||
422 | // Create event context menu for all day agenda | 422 | // Create event context menu for all day agenda |
423 | mAllDayAgendaPopup = eventPopup(); | 423 | mAllDayAgendaPopup = eventPopup(); |
424 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 424 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
425 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 425 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
426 | 426 | ||
427 | // Create agenda frame | 427 | // Create agenda frame |
428 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 428 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
429 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 429 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
430 | 430 | ||
431 | // create event indicator bars | 431 | // create event indicator bars |
432 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 432 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
433 | #ifndef DESKTOP_VERSION | 433 | #ifndef DESKTOP_VERSION |
434 | // FIX | 434 | // FIX |
435 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 435 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
436 | #endif | 436 | #endif |
437 | mDayLabelsFrame = new QHBox(agendaFrame); | 437 | mDayLabelsFrame = new QHBox(agendaFrame); |
438 | //topLayout->addWidget(mDayLabelsFrame); | 438 | //topLayout->addWidget(mDayLabelsFrame); |
439 | mDayLabels = new QFrame (mDayLabelsFrame); | 439 | mDayLabels = new QFrame (mDayLabelsFrame); |
440 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 440 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
441 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 441 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
442 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 442 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
443 | 443 | ||
444 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 444 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
445 | agendaFrame); | 445 | agendaFrame); |
446 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 446 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
447 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 447 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
448 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 448 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
449 | 449 | ||
450 | // Create time labels | 450 | // Create time labels |
451 | mTimeLabels = new TimeLabels(24,agendaFrame); | 451 | mTimeLabels = new TimeLabels(24,agendaFrame); |
452 | agendaLayout->addWidget(mTimeLabels,2,0); | 452 | agendaLayout->addWidget(mTimeLabels,2,0); |
453 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 453 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
454 | this,SLOT(updateConfig())); | 454 | this,SLOT(updateConfig())); |
455 | 455 | ||
456 | // Create agenda | 456 | // Create agenda |
457 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 457 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
458 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 458 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
459 | agendaLayout->setColStretch(1,1); | 459 | agendaLayout->setColStretch(1,1); |
460 | mAgenda->setFocusPolicy(NoFocus); | 460 | mAgenda->setFocusPolicy(NoFocus); |
461 | // Create event context menu for agenda | 461 | // Create event context menu for agenda |
462 | mAgendaPopup = eventPopup(); | 462 | mAgendaPopup = eventPopup(); |
463 | 463 | ||
464 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 464 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
465 | i18n("Toggle Alarm"),mAgenda, | 465 | i18n("Toggle Alarm"),mAgenda, |
466 | SLOT(popupAlarm()),true); | 466 | SLOT(popupAlarm()),true); |
467 | 467 | ||
468 | 468 | ||
469 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 469 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
470 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 470 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
471 | 471 | ||
472 | // make connections between dependent widgets | 472 | // make connections between dependent widgets |
473 | mTimeLabels->setAgenda(mAgenda); | 473 | mTimeLabels->setAgenda(mAgenda); |
474 | 474 | ||
475 | // Update widgets to reflect user preferences | 475 | // Update widgets to reflect user preferences |
476 | // updateConfig(); | 476 | // updateConfig(); |
477 | 477 | ||
478 | // createDayLabels(); | 478 | // createDayLabels(); |
479 | 479 | ||
480 | // these blank widgets make the All Day Event box line up with the agenda | 480 | // these blank widgets make the All Day Event box line up with the agenda |
481 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 481 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
482 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 482 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
483 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 483 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
484 | 484 | ||
485 | // Scrolling | 485 | // Scrolling |
486 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 486 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
487 | mTimeLabels, SLOT(positionChanged())); | 487 | mTimeLabels, SLOT(positionChanged())); |
488 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 488 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
489 | SLOT(setContentsPos(int))); | 489 | SLOT(setContentsPos(int))); |
490 | 490 | ||
491 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 491 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
492 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 492 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
493 | 493 | ||
494 | // Create/Show/Edit/Delete Event | 494 | // Create/Show/Edit/Delete Event |
495 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 495 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
496 | SLOT(newEvent(int,int))); | 496 | SLOT(newEvent(int,int))); |
497 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 497 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
498 | SLOT(newTodo(int,int))); | 498 | SLOT(newTodo(int,int))); |
499 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 499 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
500 | SLOT(newEvent(int,int,int,int))); | 500 | SLOT(newEvent(int,int,int,int))); |
501 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 501 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
502 | SLOT(newEventAllDay(int,int))); | 502 | SLOT(newEventAllDay(int,int))); |
503 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 503 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
504 | SLOT(newTodoAllDay(int,int))); | 504 | SLOT(newTodoAllDay(int,int))); |
505 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 505 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
506 | SLOT(newEventAllDay(int,int))); | 506 | SLOT(newEventAllDay(int,int))); |
507 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 507 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
508 | SLOT(newTimeSpanSelected(int,int,int,int))); | 508 | SLOT(newTimeSpanSelected(int,int,int,int))); |
509 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 509 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
510 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 510 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
511 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 511 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
512 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 512 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
513 | 513 | ||
514 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 514 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
515 | SIGNAL(editIncidenceSignal(Incidence *))); | 515 | SIGNAL(editIncidenceSignal(Incidence *))); |
516 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 516 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
517 | SIGNAL(editIncidenceSignal(Incidence *))); | 517 | SIGNAL(editIncidenceSignal(Incidence *))); |
518 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 518 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
519 | SIGNAL(showIncidenceSignal(Incidence *))); | 519 | SIGNAL(showIncidenceSignal(Incidence *))); |
520 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 520 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
521 | SIGNAL(showIncidenceSignal(Incidence *))); | 521 | SIGNAL(showIncidenceSignal(Incidence *))); |
522 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 522 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
523 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 523 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
524 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 524 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
525 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 525 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
526 | 526 | ||
527 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 527 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
528 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 528 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
529 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 529 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
530 | SLOT(updateEventDates(KOAgendaItem *, int))); | 530 | SLOT(updateEventDates(KOAgendaItem *, int))); |
531 | 531 | ||
532 | // event indicator update | 532 | // event indicator update |
533 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 533 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
534 | SLOT(updateEventIndicatorTop(int))); | 534 | SLOT(updateEventIndicatorTop(int))); |
535 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 535 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
536 | SLOT(updateEventIndicatorBottom(int))); | 536 | SLOT(updateEventIndicatorBottom(int))); |
537 | // drag signals | 537 | // drag signals |
538 | /* | 538 | /* |
539 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 539 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
540 | SLOT(startDrag(Event *))); | 540 | SLOT(startDrag(Event *))); |
541 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 541 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
542 | SLOT(startDrag(Event *))); | 542 | SLOT(startDrag(Event *))); |
543 | */ | 543 | */ |
544 | // synchronize selections | 544 | // synchronize selections |
545 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 545 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
546 | mAllDayAgenda, SLOT( deselectItem() ) ); | 546 | mAllDayAgenda, SLOT( deselectItem() ) ); |
547 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 547 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
548 | mAgenda, SLOT( deselectItem() ) ); | 548 | mAgenda, SLOT( deselectItem() ) ); |
549 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 549 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
550 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 550 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
551 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 551 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
552 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 552 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
553 | connect( mAgenda, SIGNAL( resizedSignal() ), | 553 | connect( mAgenda, SIGNAL( resizedSignal() ), |
554 | SLOT( updateConfig( ) ) ); | 554 | SLOT( updateConfig( ) ) ); |
555 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 555 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
556 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 556 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
557 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 557 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
558 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 558 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
559 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 559 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
560 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 560 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
561 | 561 | ||
562 | 562 | ||
563 | } | 563 | } |
564 | 564 | ||
565 | void KOAgendaView::toggleAllDay() | 565 | void KOAgendaView::toggleAllDay() |
566 | { | 566 | { |
567 | if ( mSplitterAgenda->firstHandle() ) | 567 | if ( mSplitterAgenda->firstHandle() ) |
568 | mSplitterAgenda->firstHandle()->toggle(); | 568 | mSplitterAgenda->firstHandle()->toggle(); |
569 | } | 569 | } |
570 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 570 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
571 | { | 571 | { |
572 | calendar()->addIncidence( inc ); | 572 | calendar()->addIncidence( inc ); |
573 | 573 | ||
574 | if ( incOld ) { | 574 | if ( incOld ) { |
575 | if ( incOld->type() == "Todo" ) | 575 | if ( incOld->type() == "Todo" ) |
576 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 576 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
577 | else | 577 | else |
578 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 578 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
579 | } | 579 | } |
580 | 580 | ||
581 | } | 581 | } |
582 | 582 | ||
583 | KOAgendaView::~KOAgendaView() | 583 | KOAgendaView::~KOAgendaView() |
584 | { | 584 | { |
585 | delete mAgendaPopup; | 585 | delete mAgendaPopup; |
586 | delete mAllDayAgendaPopup; | 586 | delete mAllDayAgendaPopup; |
587 | delete KOAgendaItem::paintPix(); | 587 | delete KOAgendaItem::paintPix(); |
588 | delete KOAgendaItem::paintPixSel(); | 588 | delete KOAgendaItem::paintPixSel(); |
589 | } | 589 | } |
590 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 590 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
591 | { | 591 | { |
592 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 592 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
593 | bool uc = false; | 593 | bool uc = false; |
594 | int ow = e->oldSize().width(); | 594 | int ow = e->oldSize().width(); |
595 | int oh = e->oldSize().height(); | 595 | int oh = e->oldSize().height(); |
596 | int w = e->size().width(); | 596 | int w = e->size().width(); |
597 | int h = e->size().height(); | 597 | int h = e->size().height(); |
598 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 598 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
599 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 599 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
600 | uc = true; | 600 | uc = true; |
601 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 601 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
602 | } | 602 | } |
603 | mUpcomingWidth = e->size().width() ; | 603 | mUpcomingWidth = e->size().width() ; |
604 | if ( mBlockUpdating || uc ) { | 604 | if ( mBlockUpdating || uc ) { |
605 | mBlockUpdating = false; | 605 | mBlockUpdating = false; |
606 | //mAgenda->setMinimumSize(800 , 600 ); | 606 | //mAgenda->setMinimumSize(800 , 600 ); |
607 | //qDebug("mAgenda->resize+++++++++++++++ "); | 607 | //qDebug("mAgenda->resize+++++++++++++++ "); |
608 | updateConfig(); | 608 | updateConfig(); |
609 | //qDebug("KOAgendaView::Updating now possible "); | 609 | //qDebug("KOAgendaView::Updating now possible "); |
610 | } else | 610 | } else |
611 | createDayLabels(); | 611 | createDayLabels(); |
612 | //qDebug("resizeEvent end "); | 612 | //qDebug("resizeEvent end "); |
613 | 613 | ||
614 | } | 614 | } |
615 | void KOAgendaView::slotDaylabelClicked( int num ) | 615 | void KOAgendaView::slotDaylabelClicked( int num ) |
616 | { | 616 | { |
617 | 617 | ||
618 | QDate firstDate = mSelectedDates.first(); | 618 | QDate firstDate = mSelectedDates.first(); |
619 | if ( num == -1 ) | 619 | if ( num == -1 ) |
620 | emit showDateView( 6, firstDate ); | 620 | emit showDateView( 6, firstDate ); |
621 | else if (num >= 0 ) { | 621 | else if (num >= 0 ) { |
622 | if ( mSelectedDates.count() == 1) | 622 | if ( mSelectedDates.count() == 1) |
623 | emit showDateView( 9, firstDate.addDays( num ) ); | 623 | emit showDateView( 9, firstDate.addDays( num ) ); |
624 | else | 624 | else |
625 | emit showDateView( 3, firstDate.addDays( num ) ); | 625 | emit showDateView( 3, firstDate.addDays( num ) ); |
626 | } | 626 | } |
627 | else | 627 | else |
628 | showDateView( 10, firstDate.addDays(1) ); | 628 | showDateView( 10, firstDate.addDays(1) ); |
629 | } | 629 | } |
630 | 630 | ||
631 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 631 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
632 | { | 632 | { |
633 | 633 | ||
634 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 634 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
635 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 635 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
636 | mDayLabelsList.append( dayLabel ); | 636 | mDayLabelsList.append( dayLabel ); |
637 | mLayoutDayLabels->addWidget(dayLabel); | 637 | mLayoutDayLabels->addWidget(dayLabel); |
638 | return dayLabel ; | 638 | return dayLabel ; |
639 | } | 639 | } |
640 | 640 | ||
641 | void KOAgendaView::createDayLabels() | 641 | void KOAgendaView::createDayLabels() |
642 | { | 642 | { |
643 | 643 | ||
644 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 644 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
645 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 645 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
646 | return; | 646 | return; |
647 | 647 | ||
648 | } | 648 | } |
649 | int newHight; | 649 | int newHight; |
650 | 650 | ||
651 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 651 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
652 | // It would remove some flickering and gain speed (since this is called by | 652 | // It would remove some flickering and gain speed (since this is called by |
653 | // each updateView() call) | 653 | // each updateView() call) |
654 | 654 | ||
655 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 655 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
656 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 656 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
657 | if ( maxWid < 0 ) | 657 | if ( maxWid < 0 ) |
658 | maxWid = 20; | 658 | maxWid = 20; |
659 | 659 | ||
660 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 660 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
661 | QFontMetrics fm ( dlf ); | 661 | QFontMetrics fm ( dlf ); |
662 | int selCount = mSelectedDates.count(); | 662 | int selCount = mSelectedDates.count(); |
663 | QString dayTest = "Mon 20"; | 663 | QString dayTest = "Mon 20"; |
664 | //QString dayTest = "Mon 20"; | 664 | //QString dayTest = "Mon 20"; |
665 | int wid = fm.width( dayTest ); | 665 | int wid = fm.width( dayTest ); |
666 | //maxWid -= ( selCount * 3 ); //working for QLabels | 666 | //maxWid -= ( selCount * 3 ); //working for QLabels |
667 | maxWid -= ( selCount * 3 ); //working for QPushButton | 667 | maxWid -= ( selCount * 3 ); //working for QPushButton |
668 | if ( maxWid < 0 ) | 668 | if ( maxWid < 0 ) |
669 | maxWid = 20; | 669 | maxWid = 20; |
670 | int needWid = wid * selCount; | 670 | int needWid = wid * selCount; |
671 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 671 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
672 | //if ( needWid > maxWid ) | 672 | //if ( needWid > maxWid ) |
673 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 673 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
674 | while ( needWid > maxWid ) { | 674 | while ( needWid > maxWid ) { |
675 | dayTest = dayTest.left( dayTest.length() - 1 ); | 675 | dayTest = dayTest.left( dayTest.length() - 1 ); |
676 | wid = fm.width( dayTest ); | 676 | wid = fm.width( dayTest ); |
677 | needWid = wid * selCount; | 677 | needWid = wid * selCount; |
678 | } | 678 | } |
679 | int maxLen = dayTest.length(); | 679 | int maxLen = dayTest.length(); |
680 | int fontPoint = dlf.pointSize(); | 680 | int fontPoint = dlf.pointSize(); |
681 | if ( maxLen < 2 ) { | 681 | if ( maxLen < 2 ) { |
682 | int fontPoint = dlf.pointSize(); | 682 | int fontPoint = dlf.pointSize(); |
683 | while ( fontPoint > 4 ) { | 683 | while ( fontPoint > 4 ) { |
684 | --fontPoint; | 684 | --fontPoint; |
685 | dlf.setPointSize( fontPoint ); | 685 | dlf.setPointSize( fontPoint ); |
686 | QFontMetrics f( dlf ); | 686 | QFontMetrics f( dlf ); |
687 | wid = f.width( "30" ); | 687 | wid = f.width( "30" ); |
688 | needWid = wid * selCount; | 688 | needWid = wid * selCount; |
689 | if ( needWid < maxWid ) | 689 | if ( needWid < maxWid ) |
690 | break; | 690 | break; |
691 | } | 691 | } |
692 | maxLen = 2; | 692 | maxLen = 2; |
693 | } | 693 | } |
694 | //qDebug("Max len %d ", dayTest.length() ); | 694 | //qDebug("Max len %d ", dayTest.length() ); |
695 | 695 | ||
696 | QFontMetrics tempF( dlf ); | 696 | QFontMetrics tempF( dlf ); |
697 | newHight = tempF.height(); | 697 | newHight = tempF.height(); |
698 | mDayLabels->setFont( dlf ); | 698 | mDayLabels->setFont( dlf ); |
699 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 699 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
700 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 700 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
701 | //mLayoutDayLabels->addSpacing( 2 ); | 701 | //mLayoutDayLabels->addSpacing( 2 ); |
702 | // QFont lFont = dlf; | 702 | // QFont lFont = dlf; |
703 | bool appendLabels = false; | 703 | bool appendLabels = false; |
704 | KOAgendaButton *dayLabel; | 704 | KOAgendaButton *dayLabel; |
705 | dayLabel = mDayLabelsList.first(); | 705 | dayLabel = mDayLabelsList.first(); |
706 | if ( !dayLabel ) { | 706 | if ( !dayLabel ) { |
707 | appendLabels = true; | 707 | appendLabels = true; |
708 | dayLabel = getNewDaylabel(); | 708 | dayLabel = getNewDaylabel(); |
709 | } | 709 | } |
710 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 710 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
711 | dayLabel->setFont( dlf ); | 711 | dayLabel->setFont( dlf ); |
712 | dayLabel->setNum( -1 ); | 712 | dayLabel->setNum( -1 ); |
713 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 713 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
714 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 714 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
715 | dayLabel->show(); | 715 | dayLabel->show(); |
716 | DateList::ConstIterator dit; | 716 | DateList::ConstIterator dit; |
717 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 717 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
718 | int counter = -1; | 718 | int counter = -1; |
719 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 719 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
720 | ++counter; | 720 | ++counter; |
721 | QDate date = *dit; | 721 | QDate date = *dit; |
722 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 722 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
723 | if ( ! appendLabels ) { | 723 | if ( ! appendLabels ) { |
724 | dayLabel = mDayLabelsList.next(); | 724 | dayLabel = mDayLabelsList.next(); |
725 | if ( !dayLabel ) | 725 | if ( !dayLabel ) |
726 | appendLabels = true; | 726 | appendLabels = true; |
727 | } | 727 | } |
728 | if ( appendLabels ) { | 728 | if ( appendLabels ) { |
729 | dayLabel = getNewDaylabel(); | 729 | dayLabel = getNewDaylabel(); |
730 | } | 730 | } |
731 | dayLabel->setMinimumWidth( 1 ); | 731 | dayLabel->setMinimumWidth( 1 ); |
732 | dayLabel->setMaximumWidth( 10240 ); | 732 | dayLabel->setMaximumWidth( 10240 ); |
733 | dayLabel->setFont( dlf ); | 733 | dayLabel->setFont( dlf ); |
734 | dayLabel->show(); | 734 | dayLabel->show(); |
735 | dayLabel->setAutoRepeat( false ); | ||
735 | dayLabel->setNum( counter ); | 736 | dayLabel->setNum( counter ); |
736 | QString str; | 737 | QString str; |
737 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 738 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
738 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 739 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
739 | switch ( maxLen ) { | 740 | switch ( maxLen ) { |
740 | case 2: | 741 | case 2: |
741 | str = QString::number( date.day() ); | 742 | str = QString::number( date.day() ); |
742 | break; | 743 | break; |
743 | 744 | ||
744 | case 3: | 745 | case 3: |
745 | str = dayName.left( 1 ) +QString::number( date.day()); | 746 | str = dayName.left( 1 ) +QString::number( date.day()); |
746 | 747 | ||
747 | break; | 748 | break; |
748 | case 4: | 749 | case 4: |
749 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 750 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
750 | 751 | ||
751 | break; | 752 | break; |
752 | case 5: | 753 | case 5: |
753 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 754 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
754 | 755 | ||
755 | break; | 756 | break; |
756 | case 6: | 757 | case 6: |
757 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 758 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
758 | break; | 759 | break; |
759 | 760 | ||
760 | default: | 761 | default: |
761 | break; | 762 | break; |
762 | } | 763 | } |
763 | if ( oneday ) { | 764 | if ( oneday ) { |
764 | QString addString; | 765 | QString addString; |
765 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 766 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
766 | addString = i18n("Today"); | 767 | addString = i18n("Today"); |
767 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
768 | addString = i18n("Tomorrow"); | 769 | addString = i18n("Tomorrow"); |
769 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 770 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
770 | addString = i18n("Yesterday"); | 771 | addString = i18n("Yesterday"); |
771 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 772 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
772 | addString = i18n("Day before yesterday"); | 773 | addString = i18n("Day before yesterday"); |
773 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 774 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
774 | addString = i18n("Day after tomorrow"); | 775 | addString = i18n("Day after tomorrow"); |
775 | if ( !addString.isEmpty() ) { | 776 | if ( !addString.isEmpty() ) { |
776 | str = addString+", " + str; | 777 | str = addString+", " + str; |
777 | } else { | 778 | } else { |
778 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 779 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
779 | } | 780 | } |
780 | } | 781 | } |
781 | dayLabel->setText(str); | 782 | dayLabel->setText(str); |
782 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 783 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
783 | if (date == QDate::currentDate()) { | 784 | if (date == QDate::currentDate()) { |
784 | QFont bFont = dlf; | 785 | QFont bFont = dlf; |
785 | bFont.setBold( true ); | 786 | bFont.setBold( true ); |
786 | dayLabel->setFont(bFont); | 787 | dayLabel->setFont(bFont); |
787 | } | 788 | } |
788 | //dayLayout->addWidget(dayLabel); | 789 | //dayLayout->addWidget(dayLabel); |
789 | 790 | ||
790 | #ifndef KORG_NOPLUGINS | 791 | #ifndef KORG_NOPLUGINS |
791 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 792 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
792 | CalendarDecoration *it; | 793 | CalendarDecoration *it; |
793 | for(it = cds.first(); it; it = cds.next()) { | 794 | for(it = cds.first(); it; it = cds.next()) { |
794 | QString text = it->shortText( date ); | 795 | QString text = it->shortText( date ); |
795 | if ( !text.isEmpty() ) { | 796 | if ( !text.isEmpty() ) { |
796 | QLabel *label = new QLabel(text,mDayLabels); | 797 | QLabel *label = new QLabel(text,mDayLabels); |
797 | label->setAlignment(AlignCenter); | 798 | label->setAlignment(AlignCenter); |
798 | dayLayout->addWidget(label); | 799 | dayLayout->addWidget(label); |
799 | } | 800 | } |
800 | } | 801 | } |
801 | 802 | ||
802 | for(it = cds.first(); it; it = cds.next()) { | 803 | for(it = cds.first(); it; it = cds.next()) { |
803 | QWidget *wid = it->smallWidget(mDayLabels,date); | 804 | QWidget *wid = it->smallWidget(mDayLabels,date); |
804 | if ( wid ) { | 805 | if ( wid ) { |
805 | // wid->setHeight(20); | 806 | // wid->setHeight(20); |
806 | dayLayout->addWidget(wid); | 807 | dayLayout->addWidget(wid); |
807 | } | 808 | } |
808 | } | 809 | } |
809 | #endif | 810 | #endif |
810 | } | 811 | } |
811 | if ( ! appendLabels ) { | 812 | if ( ! appendLabels ) { |
812 | dayLabel = mDayLabelsList.next(); | 813 | dayLabel = mDayLabelsList.next(); |
813 | if ( !dayLabel ) | 814 | if ( !dayLabel ) |
814 | appendLabels = true; | 815 | appendLabels = true; |
815 | } | 816 | } |
816 | if ( appendLabels ) { | 817 | if ( appendLabels ) { |
817 | dayLabel = getNewDaylabel(); | 818 | dayLabel = getNewDaylabel(); |
818 | } | 819 | } |
819 | //dayLabel->hide();//test only | 820 | //dayLabel->hide();//test only |
820 | 821 | ||
821 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 822 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
822 | if ( offset < 0 ) offset = 0; | 823 | if ( offset < 0 ) offset = 0; |
823 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 824 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
824 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 825 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
825 | dayLabel->setFont( dlf ); | 826 | dayLabel->setFont( dlf ); |
827 | dayLabel->setAutoRepeat( true ); | ||
826 | dayLabel->show(); | 828 | dayLabel->show(); |
827 | dayLabel->setNum( -2 ); | 829 | dayLabel->setNum( -2 ); |
828 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 830 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
829 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 831 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
830 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 832 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
831 | if ( !appendLabels ) { | 833 | if ( !appendLabels ) { |
832 | dayLabel = mDayLabelsList.next(); | 834 | dayLabel = mDayLabelsList.next(); |
833 | while ( dayLabel ) { | 835 | while ( dayLabel ) { |
834 | //qDebug("!dayLabel %d",dayLabel ); | 836 | //qDebug("!dayLabel %d",dayLabel ); |
835 | dayLabel->hide(); | 837 | dayLabel->hide(); |
836 | dayLabel = mDayLabelsList.next(); | 838 | dayLabel = mDayLabelsList.next(); |
837 | } | 839 | } |
838 | } | 840 | } |
839 | 841 | ||
840 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 842 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
841 | } | 843 | } |
842 | 844 | ||
843 | int KOAgendaView::maxDatesHint() | 845 | int KOAgendaView::maxDatesHint() |
844 | { | 846 | { |
845 | // Not sure about the max number of events, so return 0 for now. | 847 | // Not sure about the max number of events, so return 0 for now. |
846 | return 0; | 848 | return 0; |
847 | } | 849 | } |
848 | 850 | ||
849 | int KOAgendaView::currentDateCount() | 851 | int KOAgendaView::currentDateCount() |
850 | { | 852 | { |
851 | return mSelectedDates.count(); | 853 | return mSelectedDates.count(); |
852 | } | 854 | } |
853 | 855 | ||
854 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 856 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
855 | { | 857 | { |
856 | QPtrList<Incidence> selected; | 858 | QPtrList<Incidence> selected; |
857 | Incidence *incidence; | 859 | Incidence *incidence; |
858 | 860 | ||
859 | incidence = mAgenda->selectedIncidence(); | 861 | incidence = mAgenda->selectedIncidence(); |
860 | if (incidence) selected.append(incidence); | 862 | if (incidence) selected.append(incidence); |
861 | 863 | ||
862 | incidence = mAllDayAgenda->selectedIncidence(); | 864 | incidence = mAllDayAgenda->selectedIncidence(); |
863 | if (incidence) selected.append(incidence); | 865 | if (incidence) selected.append(incidence); |
864 | 866 | ||
865 | return selected; | 867 | return selected; |
866 | } | 868 | } |
867 | 869 | ||
868 | DateList KOAgendaView::selectedDates() | 870 | DateList KOAgendaView::selectedDates() |
869 | { | 871 | { |
870 | DateList selected; | 872 | DateList selected; |
871 | QDate qd; | 873 | QDate qd; |
872 | 874 | ||
873 | qd = mAgenda->selectedIncidenceDate(); | 875 | qd = mAgenda->selectedIncidenceDate(); |
874 | if (qd.isValid()) selected.append(qd); | 876 | if (qd.isValid()) selected.append(qd); |
875 | 877 | ||
876 | qd = mAllDayAgenda->selectedIncidenceDate(); | 878 | qd = mAllDayAgenda->selectedIncidenceDate(); |
877 | if (qd.isValid()) selected.append(qd); | 879 | if (qd.isValid()) selected.append(qd); |
878 | 880 | ||
879 | return selected; | 881 | return selected; |
880 | } | 882 | } |
881 | 883 | ||
882 | 884 | ||
883 | void KOAgendaView::updateView() | 885 | void KOAgendaView::updateView() |
884 | { | 886 | { |
885 | if ( mBlockUpdating ) | 887 | if ( mBlockUpdating ) |
886 | return; | 888 | return; |
887 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 889 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
888 | fillAgenda(); | 890 | fillAgenda(); |
889 | 891 | ||
890 | } | 892 | } |
891 | 893 | ||
892 | 894 | ||
893 | /* | 895 | /* |
894 | Update configuration settings for the agenda view. This method is not | 896 | Update configuration settings for the agenda view. This method is not |
895 | complete. | 897 | complete. |
896 | */ | 898 | */ |
897 | void KOAgendaView::updateConfig() | 899 | void KOAgendaView::updateConfig() |
898 | { | 900 | { |
899 | if ( mBlockUpdating ) | 901 | if ( mBlockUpdating ) |
900 | return; | 902 | return; |
901 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 903 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
902 | int old = KOPrefs::instance()->mHourSize; | 904 | int old = KOPrefs::instance()->mHourSize; |
903 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 905 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
904 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 906 | qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
905 | } | 907 | } |
906 | 908 | ||
907 | 909 | ||
908 | // update config for children | 910 | // update config for children |
909 | mTimeLabels->updateConfig(); | 911 | mTimeLabels->updateConfig(); |
910 | mAgenda->storePosition(); | 912 | mAgenda->storePosition(); |
911 | mAgenda->updateConfig(); | 913 | mAgenda->updateConfig(); |
912 | mAllDayAgenda->updateConfig(); | 914 | mAllDayAgenda->updateConfig(); |
913 | // widget synchronization | 915 | // widget synchronization |
914 | //TODO: find a better way, maybe signal/slot | 916 | //TODO: find a better way, maybe signal/slot |
915 | mTimeLabels->positionChanged(); | 917 | mTimeLabels->positionChanged(); |
916 | 918 | ||
917 | // for some reason, this needs to be called explicitly | 919 | // for some reason, this needs to be called explicitly |
918 | mTimeLabels->repaint(); | 920 | mTimeLabels->repaint(); |
919 | 921 | ||
920 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 922 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
921 | 923 | ||
922 | // ToolTips displaying summary of events | 924 | // ToolTips displaying summary of events |
923 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 925 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
924 | ->mEnableToolTips); | 926 | ->mEnableToolTips); |
925 | 927 | ||
926 | //setHolidayMasks(); | 928 | //setHolidayMasks(); |
927 | 929 | ||
928 | //createDayLabels(); called by via updateView(); | 930 | //createDayLabels(); called by via updateView(); |
929 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 931 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
930 | updateView(); | 932 | updateView(); |
931 | mAgenda->restorePosition(); | 933 | mAgenda->restorePosition(); |
932 | } | 934 | } |
933 | 935 | ||
934 | 936 | ||
935 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 937 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
936 | { | 938 | { |
937 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 939 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
938 | //qDebug("KOAgendaView::updateEventDates "); | 940 | //qDebug("KOAgendaView::updateEventDates "); |
939 | QDateTime startDt,endDt; | 941 | QDateTime startDt,endDt; |
940 | QDate startDate; | 942 | QDate startDate; |
941 | int lenInSecs; | 943 | int lenInSecs; |
942 | // if ( type == KOAgenda::RESIZETOP ) | 944 | // if ( type == KOAgenda::RESIZETOP ) |
943 | // qDebug("RESIZETOP "); | 945 | // qDebug("RESIZETOP "); |
944 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 946 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
945 | // qDebug("RESIZEBOTTOM "); | 947 | // qDebug("RESIZEBOTTOM "); |
946 | // if ( type == KOAgenda::MOVE ) | 948 | // if ( type == KOAgenda::MOVE ) |
947 | // qDebug("MOVE "); | 949 | // qDebug("MOVE "); |
948 | if ( item->incidence()->type() == "Event" ) { | 950 | if ( item->incidence()->type() == "Event" ) { |
949 | startDt =item->incidence()->dtStart(); | 951 | startDt =item->incidence()->dtStart(); |
950 | endDt = item->incidence()->dtEnd(); | 952 | endDt = item->incidence()->dtEnd(); |
951 | lenInSecs = startDt.secsTo( endDt ); | 953 | lenInSecs = startDt.secsTo( endDt ); |
952 | } | 954 | } |
953 | 955 | ||
954 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 956 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
955 | 957 | ||
956 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 958 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
957 | startDate = mSelectedDates[item->mLastMoveXPos]; | 959 | startDate = mSelectedDates[item->mLastMoveXPos]; |
958 | } else { | 960 | } else { |
959 | if (item->cellX() < 0) { | 961 | if (item->cellX() < 0) { |
960 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 962 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
961 | } else { | 963 | } else { |
962 | startDate = mSelectedDates[item->cellX()]; | 964 | startDate = mSelectedDates[item->cellX()]; |
963 | } | 965 | } |
964 | } | 966 | } |
965 | startDt.setDate(startDate); | 967 | startDt.setDate(startDate); |
966 | 968 | ||
967 | if (item->incidence()->doesFloat()) { | 969 | if (item->incidence()->doesFloat()) { |
968 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 970 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
969 | } else { | 971 | } else { |
970 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 972 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
971 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 973 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
972 | if ( item->incidence()->type() == "Event" ) { | 974 | if ( item->incidence()->type() == "Event" ) { |
973 | if ( type == KOAgenda::MOVE ) { | 975 | if ( type == KOAgenda::MOVE ) { |
974 | endDt = startDt.addSecs(lenInSecs); | 976 | endDt = startDt.addSecs(lenInSecs); |
975 | 977 | ||
976 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 978 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
977 | if (item->lastMultiItem()) { | 979 | if (item->lastMultiItem()) { |
978 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 980 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
979 | endDt.setDate(startDate. | 981 | endDt.setDate(startDate. |
980 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 982 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
981 | } else { | 983 | } else { |
982 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 984 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
983 | endDt.setDate(startDate); | 985 | endDt.setDate(startDate); |
984 | } | 986 | } |
985 | } | 987 | } |
986 | } else { | 988 | } else { |
987 | // todo | 989 | // todo |
988 | if (item->lastMultiItem()) { | 990 | if (item->lastMultiItem()) { |
989 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 991 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
990 | endDt.setDate(startDate. | 992 | endDt.setDate(startDate. |
991 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 993 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
992 | } else { | 994 | } else { |
993 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 995 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
994 | if ( item->cellYBottom() > 0 ) | 996 | if ( item->cellYBottom() > 0 ) |
995 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 997 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
996 | else | 998 | else |
997 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 999 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
998 | endDt.setDate(startDate); | 1000 | endDt.setDate(startDate); |
999 | } | 1001 | } |
1000 | } | 1002 | } |
1001 | } | 1003 | } |
1002 | if ( item->incidence()->type() == "Event" ) { | 1004 | if ( item->incidence()->type() == "Event" ) { |
1003 | item->incidence()->setDtStart(startDt); | 1005 | item->incidence()->setDtStart(startDt); |
1004 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1006 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1005 | } else if ( item->incidence()->type() == "Todo" ) { | 1007 | } else if ( item->incidence()->type() == "Todo" ) { |
1006 | Todo* to = static_cast<Todo*>(item->incidence()); | 1008 | Todo* to = static_cast<Todo*>(item->incidence()); |
1007 | 1009 | ||
1008 | to->setDtDue(endDt); | 1010 | to->setDtDue(endDt); |
1009 | if ( to->hasStartDate() ) { | 1011 | if ( to->hasStartDate() ) { |
1010 | if (to->dtStart() >= to->dtDue() ) | 1012 | if (to->dtStart() >= to->dtDue() ) |
1011 | to->setDtStart(to->dtDue().addDays( -2 )); | 1013 | to->setDtStart(to->dtDue().addDays( -2 )); |
1012 | } | 1014 | } |
1013 | 1015 | ||
1014 | } | 1016 | } |
1015 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1017 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1016 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1018 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1017 | item->setItemDate(startDt.date()); | 1019 | item->setItemDate(startDt.date()); |
1018 | //item->updateItem(); | 1020 | //item->updateItem(); |
1019 | if ( item->incidence()->type() == "Todo" ) { | 1021 | if ( item->incidence()->type() == "Todo" ) { |
1020 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1022 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1021 | 1023 | ||
1022 | } | 1024 | } |
1023 | else | 1025 | else |
1024 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1026 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1025 | item->updateItem(); | 1027 | item->updateItem(); |
1026 | } | 1028 | } |
1027 | 1029 | ||
1028 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1030 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1029 | { | 1031 | { |
1030 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1032 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1031 | 1033 | ||
1032 | mSelectedDates.clear(); | 1034 | mSelectedDates.clear(); |
1033 | // qDebug("KOAgendaView::showDates "); | 1035 | // qDebug("KOAgendaView::showDates "); |
1034 | QDate d = start; | 1036 | QDate d = start; |
1035 | while (d <= end) { | 1037 | while (d <= end) { |
1036 | mSelectedDates.append(d); | 1038 | mSelectedDates.append(d); |
1037 | d = d.addDays( 1 ); | 1039 | d = d.addDays( 1 ); |
1038 | } | 1040 | } |
1039 | 1041 | ||
1040 | // and update the view | 1042 | // and update the view |
1041 | fillAgenda(); | 1043 | fillAgenda(); |
1042 | } | 1044 | } |
1043 | 1045 | ||
1044 | 1046 | ||
1045 | void KOAgendaView::showEvents(QPtrList<Event>) | 1047 | void KOAgendaView::showEvents(QPtrList<Event>) |
1046 | { | 1048 | { |
1047 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1049 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1048 | } | 1050 | } |
1049 | 1051 | ||
1050 | void KOAgendaView::changeEventDisplay(Event *, int) | 1052 | void KOAgendaView::changeEventDisplay(Event *, int) |
1051 | { | 1053 | { |
1052 | // qDebug("KOAgendaView::changeEventDisplay "); | 1054 | // qDebug("KOAgendaView::changeEventDisplay "); |
1053 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1055 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1054 | // this should be re-written to be MUCH smarter. Right now we | 1056 | // this should be re-written to be MUCH smarter. Right now we |
1055 | // are just playing dumb. | 1057 | // are just playing dumb. |
1056 | fillAgenda(); | 1058 | fillAgenda(); |
1057 | } | 1059 | } |
1058 | 1060 | ||
1059 | void KOAgendaView::fillAgenda(const QDate &) | 1061 | void KOAgendaView::fillAgenda(const QDate &) |
1060 | { | 1062 | { |
1061 | // qDebug("KOAgendaView::fillAgenda "); | 1063 | // qDebug("KOAgendaView::fillAgenda "); |
1062 | fillAgenda(); | 1064 | fillAgenda(); |
1063 | } | 1065 | } |
1064 | 1066 | ||
1065 | void KOAgendaView::fillAgenda() | 1067 | void KOAgendaView::fillAgenda() |
1066 | { | 1068 | { |
1067 | if ( globalFlagBlockStartup ) | 1069 | if ( globalFlagBlockStartup ) |
1068 | return; | 1070 | return; |
1069 | if ( globalFlagBlockAgenda == 1 ) | 1071 | if ( globalFlagBlockAgenda == 1 ) |
1070 | return; | 1072 | return; |
1071 | //if ( globalFlagBlockAgenda == 2 ) | 1073 | //if ( globalFlagBlockAgenda == 2 ) |
1072 | //globalFlagBlockAgenda = 0; | 1074 | //globalFlagBlockAgenda = 0; |
1073 | // globalFlagBlockPainting = false; | 1075 | // globalFlagBlockPainting = false; |
1074 | if ( globalFlagBlockAgenda == 0 ) | 1076 | if ( globalFlagBlockAgenda == 0 ) |
1075 | globalFlagBlockAgenda = 1; | 1077 | globalFlagBlockAgenda = 1; |
1076 | // clearView(); | 1078 | // clearView(); |
1077 | //qDebug("fillAgenda()++++ "); | 1079 | //qDebug("fillAgenda()++++ "); |
1078 | globalFlagBlockAgendaItemPaint = 1; | 1080 | globalFlagBlockAgendaItemPaint = 1; |
1079 | 1081 | ||
1080 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1082 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1081 | mAgenda->changeColumns(mSelectedDates.count()); | 1083 | mAgenda->changeColumns(mSelectedDates.count()); |
1082 | qApp->processEvents(); | 1084 | qApp->processEvents(); |
1083 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1085 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1084 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1086 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1085 | setHolidayMasks(); | 1087 | setHolidayMasks(); |
1086 | 1088 | ||
1087 | //mAgenda->hideUnused(); | 1089 | //mAgenda->hideUnused(); |
1088 | //mAllDayAgenda->hideUnused(); | 1090 | //mAllDayAgenda->hideUnused(); |
1089 | 1091 | ||
1090 | // mAgenda->blockNextRepaint( false ); | 1092 | // mAgenda->blockNextRepaint( false ); |
1091 | // mAgenda->viewport()->repaint(); | 1093 | // mAgenda->viewport()->repaint(); |
1092 | // mAgenda->blockNextRepaint( true ); | 1094 | // mAgenda->blockNextRepaint( true ); |
1093 | mMinY.resize(mSelectedDates.count()); | 1095 | mMinY.resize(mSelectedDates.count()); |
1094 | mMaxY.resize(mSelectedDates.count()); | 1096 | mMaxY.resize(mSelectedDates.count()); |
1095 | 1097 | ||
1096 | QPtrList<Event> dayEvents; | 1098 | QPtrList<Event> dayEvents; |
1097 | 1099 | ||
1098 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1100 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1099 | // Therefore, gtodoset all of them. | 1101 | // Therefore, gtodoset all of them. |
1100 | QPtrList<Todo> todos = calendar()->todos(); | 1102 | QPtrList<Todo> todos = calendar()->todos(); |
1101 | 1103 | ||
1102 | mAgenda->setDateList(mSelectedDates); | 1104 | mAgenda->setDateList(mSelectedDates); |
1103 | 1105 | ||
1104 | QDate today = QDate::currentDate(); | 1106 | QDate today = QDate::currentDate(); |
1105 | 1107 | ||
1106 | DateList::ConstIterator dit; | 1108 | DateList::ConstIterator dit; |
1107 | int curCol = 0; | 1109 | int curCol = 0; |
1108 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1110 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1109 | QDate currentDate = *dit; | 1111 | QDate currentDate = *dit; |
1110 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1112 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1111 | // << endl; | 1113 | // << endl; |
1112 | 1114 | ||
1113 | dayEvents = calendar()->events(currentDate,true); | 1115 | dayEvents = calendar()->events(currentDate,true); |
1114 | 1116 | ||
1115 | // Default values, which can never be reached | 1117 | // Default values, which can never be reached |
1116 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1118 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1117 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1119 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1118 | 1120 | ||
1119 | unsigned int numEvent; | 1121 | unsigned int numEvent; |
1120 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1122 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1121 | Event *event = dayEvents.at(numEvent); | 1123 | Event *event = dayEvents.at(numEvent); |
1122 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1124 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1123 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1125 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1124 | continue; | 1126 | continue; |
1125 | // kdDebug() << " Event: " << event->summary() << endl; | 1127 | // kdDebug() << " Event: " << event->summary() << endl; |
1126 | 1128 | ||
1127 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1129 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1128 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1130 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1129 | 1131 | ||
1130 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1132 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1131 | 1133 | ||
1132 | if (event->doesFloat()) { | 1134 | if (event->doesFloat()) { |
1133 | if (event->recurrence()->doesRecur()) { | 1135 | if (event->recurrence()->doesRecur()) { |
1134 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1136 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1135 | } else { | 1137 | } else { |
1136 | if (beginX <= 0 && curCol == 0) { | 1138 | if (beginX <= 0 && curCol == 0) { |
1137 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1139 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1138 | } else if (beginX == curCol) { | 1140 | } else if (beginX == curCol) { |
1139 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1141 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1140 | } | 1142 | } |
1141 | } | 1143 | } |
1142 | } else if (event->isMultiDay()) { | 1144 | } else if (event->isMultiDay()) { |
1143 | if ( event->doesRecur () ) { | 1145 | if ( event->doesRecur () ) { |
1144 | QDate dateit = currentDate; | 1146 | QDate dateit = currentDate; |
1145 | int count = 0; | 1147 | int count = 0; |
1146 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1148 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1147 | while (! event->recursOn( dateit ) && count <= max ) { | 1149 | while (! event->recursOn( dateit ) && count <= max ) { |
1148 | ++count; | 1150 | ++count; |
1149 | dateit = dateit.addDays( -1 ); | 1151 | dateit = dateit.addDays( -1 ); |
1150 | } | 1152 | } |
1151 | bool ok; | 1153 | bool ok; |
1152 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1154 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1153 | if ( ok ) | 1155 | if ( ok ) |
1154 | { | 1156 | { |
1155 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1157 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1156 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1158 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1157 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1159 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1158 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1160 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1159 | 1161 | ||
1160 | } | 1162 | } |
1161 | } | 1163 | } |
1162 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1164 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1163 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1165 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1164 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1166 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1165 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1167 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1166 | //qDebug("insert!!! "); | 1168 | //qDebug("insert!!! "); |
1167 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1169 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1168 | } | 1170 | } |
1169 | if (beginX == curCol) { | 1171 | if (beginX == curCol) { |
1170 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1172 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1171 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1173 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1172 | } else if (endX == curCol) { | 1174 | } else if (endX == curCol) { |
1173 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1175 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1174 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1176 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1175 | } else { | 1177 | } else { |
1176 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1178 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1177 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1179 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1178 | } | 1180 | } |
1179 | } else { | 1181 | } else { |
1180 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1182 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1181 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1183 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1182 | if (endY < startY) endY = startY; | 1184 | if (endY < startY) endY = startY; |
1183 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1185 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1184 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1186 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1185 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1187 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1186 | } | 1188 | } |
1187 | } | 1189 | } |
1188 | // ---------- [display Todos -------------- | 1190 | // ---------- [display Todos -------------- |
1189 | unsigned int numTodo; | 1191 | unsigned int numTodo; |
1190 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1192 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1191 | Todo *todo = todos.at(numTodo); | 1193 | Todo *todo = todos.at(numTodo); |
1192 | 1194 | ||
1193 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1195 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1194 | 1196 | ||
1195 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1197 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1196 | // Already completed items can be displayed on their original due date | 1198 | // Already completed items can be displayed on their original due date |
1197 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1199 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1198 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1200 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1199 | bool fillIn = false; | 1201 | bool fillIn = false; |
1200 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1202 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1201 | fillIn = true; | 1203 | fillIn = true; |
1202 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1204 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1203 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1205 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1204 | if ( fillIn ) { | 1206 | if ( fillIn ) { |
1205 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1207 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1206 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1208 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1207 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1209 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1208 | } | 1210 | } |
1209 | else { | 1211 | else { |
1210 | QDateTime dt; | 1212 | QDateTime dt; |
1211 | if ( todo->hasCompletedDate() ) | 1213 | if ( todo->hasCompletedDate() ) |
1212 | dt = todo->completed(); | 1214 | dt = todo->completed(); |
1213 | else | 1215 | else |
1214 | dt = todo->dtDue();; | 1216 | dt = todo->dtDue();; |
1215 | 1217 | ||
1216 | 1218 | ||
1217 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1219 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1218 | int hi = (18/KOPrefs::instance()->mHourSize); | 1220 | int hi = (18/KOPrefs::instance()->mHourSize); |
1219 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1221 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1220 | int startY = endY -hi; | 1222 | int startY = endY -hi; |
1221 | 1223 | ||
1222 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1224 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1223 | 1225 | ||
1224 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1226 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1225 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1227 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1226 | } | 1228 | } |
1227 | } | 1229 | } |
1228 | } | 1230 | } |
1229 | // ---------- display Todos] -------------- | 1231 | // ---------- display Todos] -------------- |
1230 | 1232 | ||
1231 | ++curCol; | 1233 | ++curCol; |
1232 | } | 1234 | } |
1233 | mAgenda->hideUnused(); | 1235 | mAgenda->hideUnused(); |
1234 | mAllDayAgenda->hideUnused(); | 1236 | mAllDayAgenda->hideUnused(); |
1235 | mAgenda->checkScrollBoundaries(); | 1237 | mAgenda->checkScrollBoundaries(); |
1236 | 1238 | ||
1237 | deleteSelectedDateTime(); | 1239 | deleteSelectedDateTime(); |
1238 | 1240 | ||
1239 | createDayLabels(); | 1241 | createDayLabels(); |
1240 | emit incidenceSelected( 0 ); | 1242 | emit incidenceSelected( 0 ); |
1241 | 1243 | ||
1242 | if ( globalFlagBlockAgenda == 2 ) { | 1244 | if ( globalFlagBlockAgenda == 2 ) { |
1243 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1245 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1244 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1246 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1245 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1247 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1246 | setStartHour( QTime::currentTime ().hour() ); | 1248 | setStartHour( QTime::currentTime ().hour() ); |
1247 | // qApp->processEvents(); | 1249 | // qApp->processEvents(); |
1248 | } | 1250 | } |
1249 | qApp->processEvents(); | 1251 | qApp->processEvents(); |
1250 | //qDebug("qApp->processEvents(); END "); | 1252 | //qDebug("qApp->processEvents(); END "); |
1251 | globalFlagBlockAgenda = 0; | 1253 | globalFlagBlockAgenda = 0; |
1252 | 1254 | ||
1253 | // mAgenda->hideUnused(); | 1255 | // mAgenda->hideUnused(); |
1254 | //mAllDayAgenda->hideUnused(); | 1256 | //mAllDayAgenda->hideUnused(); |
1255 | mAllDayAgenda->drawContentsToPainter(); | 1257 | mAllDayAgenda->drawContentsToPainter(); |
1256 | mAgenda->drawContentsToPainter(); | 1258 | mAgenda->drawContentsToPainter(); |
1257 | repaintAgenda(); | 1259 | repaintAgenda(); |
1258 | // mAgenda->finishUpdate(); | 1260 | // mAgenda->finishUpdate(); |
1259 | //mAllDayAgenda->finishUpdate(); | 1261 | //mAllDayAgenda->finishUpdate(); |
1260 | 1262 | ||
1261 | // repaintAgenda(); | 1263 | // repaintAgenda(); |
1262 | //qApp->processEvents(); | 1264 | //qApp->processEvents(); |
1263 | // globalFlagBlockAgenda = 0; | 1265 | // globalFlagBlockAgenda = 0; |
1264 | } | 1266 | } |
1265 | void KOAgendaView::repaintAgenda() | 1267 | void KOAgendaView::repaintAgenda() |
1266 | { | 1268 | { |
1267 | // mAllDayAgenda->drawContentsToPainter(); | 1269 | // mAllDayAgenda->drawContentsToPainter(); |
1268 | // mAllDayAgenda->viewport()->repaint( false ); | 1270 | // mAllDayAgenda->viewport()->repaint( false ); |
1269 | // mAgenda->drawContentsToPainter(); | 1271 | // mAgenda->drawContentsToPainter(); |
1270 | // mAgenda->viewport()->repaint( false ); | 1272 | // mAgenda->viewport()->repaint( false ); |
1271 | // qApp->processEvents(); | 1273 | // qApp->processEvents(); |
1272 | 1274 | ||
1273 | //qDebug("KOAgendaView::repaintAgenda() "); | 1275 | //qDebug("KOAgendaView::repaintAgenda() "); |
1274 | //qApp->processEvents(); | 1276 | //qApp->processEvents(); |
1275 | mAgenda->viewport()->repaint( false ); | 1277 | mAgenda->viewport()->repaint( false ); |
1276 | mAllDayAgenda->viewport()->repaint( false ); | 1278 | mAllDayAgenda->viewport()->repaint( false ); |
1277 | mAgenda->finishUpdate(); | 1279 | mAgenda->finishUpdate(); |
1278 | mAllDayAgenda->finishUpdate(); | 1280 | mAllDayAgenda->finishUpdate(); |
1279 | } | 1281 | } |
1280 | 1282 | ||
1281 | 1283 | ||
1282 | void KOAgendaView::clearView() | 1284 | void KOAgendaView::clearView() |
1283 | { | 1285 | { |
1284 | // kdDebug() << "ClearView" << endl; | 1286 | // kdDebug() << "ClearView" << endl; |
1285 | mAllDayAgenda->clear(); | 1287 | mAllDayAgenda->clear(); |
1286 | mAgenda->clear(); | 1288 | mAgenda->clear(); |
1287 | } | 1289 | } |
1288 | 1290 | ||
1289 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1291 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1290 | const QDate &td) | 1292 | const QDate &td) |
1291 | { | 1293 | { |
1292 | #ifndef KORG_NOPRINTER | 1294 | #ifndef KORG_NOPRINTER |
1293 | if (fd == td) | 1295 | if (fd == td) |
1294 | calPrinter->preview(CalPrinter::Day, fd, td); | 1296 | calPrinter->preview(CalPrinter::Day, fd, td); |
1295 | else | 1297 | else |
1296 | calPrinter->preview(CalPrinter::Week, fd, td); | 1298 | calPrinter->preview(CalPrinter::Week, fd, td); |
1297 | #endif | 1299 | #endif |
1298 | } | 1300 | } |
1299 | 1301 | ||
1300 | // void KOAgendaView::updateMovedTodo() | 1302 | // void KOAgendaView::updateMovedTodo() |
1301 | // { | 1303 | // { |
1302 | // // updateConfig(); | 1304 | // // updateConfig(); |
1303 | // // emit updateTodoViews(); | 1305 | // // emit updateTodoViews(); |
1304 | // } | 1306 | // } |
1305 | 1307 | ||
1306 | void KOAgendaView::newEvent(int gx, int gy) | 1308 | void KOAgendaView::newEvent(int gx, int gy) |
1307 | { | 1309 | { |
1308 | if (!mSelectedDates.count()) return; | 1310 | if (!mSelectedDates.count()) return; |
1309 | 1311 | ||
1310 | QDate day = mSelectedDates[gx]; | 1312 | QDate day = mSelectedDates[gx]; |
1311 | 1313 | ||
1312 | QTime time = mAgenda->gyToTime(gy); | 1314 | QTime time = mAgenda->gyToTime(gy); |
1313 | QDateTime dt(day,time); | 1315 | QDateTime dt(day,time); |
1314 | // if ( dt < QDateTime::currentDateTime () ) | 1316 | // if ( dt < QDateTime::currentDateTime () ) |
1315 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1317 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1316 | emit newEventSignal(dt); | 1318 | emit newEventSignal(dt); |
1317 | } | 1319 | } |
1318 | 1320 | ||
1319 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1321 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1320 | { | 1322 | { |
1321 | if (!mSelectedDates.count()) return; | 1323 | if (!mSelectedDates.count()) return; |
1322 | 1324 | ||
1323 | QDate dayStart = mSelectedDates[gxStart]; | 1325 | QDate dayStart = mSelectedDates[gxStart]; |
1324 | QDate dayEnd = mSelectedDates[gxEnd]; | 1326 | QDate dayEnd = mSelectedDates[gxEnd]; |
1325 | 1327 | ||
1326 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1328 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1327 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1329 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1328 | 1330 | ||
1329 | QDateTime dtStart(dayStart,timeStart); | 1331 | QDateTime dtStart(dayStart,timeStart); |
1330 | QDateTime dtEnd(dayEnd,timeEnd); | 1332 | QDateTime dtEnd(dayEnd,timeEnd); |
1331 | 1333 | ||
1332 | emit newEventSignal(dtStart,dtEnd); | 1334 | emit newEventSignal(dtStart,dtEnd); |
1333 | } | 1335 | } |
1334 | 1336 | ||
1335 | void KOAgendaView::newEventAllDay(int gx, int ) | 1337 | void KOAgendaView::newEventAllDay(int gx, int ) |
1336 | { | 1338 | { |
1337 | if (!mSelectedDates.count()) return; | 1339 | if (!mSelectedDates.count()) return; |
1338 | 1340 | ||
1339 | QDate day = mSelectedDates[gx]; | 1341 | QDate day = mSelectedDates[gx]; |
1340 | 1342 | ||
1341 | emit newEventSignal(day); | 1343 | emit newEventSignal(day); |
1342 | } | 1344 | } |
1343 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1345 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1344 | { | 1346 | { |
1345 | if (!mSelectedDates.count()) return; | 1347 | if (!mSelectedDates.count()) return; |
1346 | 1348 | ||
1347 | QDateTime day (mSelectedDates[gx] ); | 1349 | QDateTime day (mSelectedDates[gx] ); |
1348 | emit newTodoSignal(day, true); | 1350 | emit newTodoSignal(day, true); |
1349 | } | 1351 | } |
1350 | void KOAgendaView::newTodo(int gx, int gy ) | 1352 | void KOAgendaView::newTodo(int gx, int gy ) |
1351 | { | 1353 | { |
1352 | if (!mSelectedDates.count()) return; | 1354 | if (!mSelectedDates.count()) return; |
1353 | QDate dayStart = mSelectedDates[gx]; | 1355 | QDate dayStart = mSelectedDates[gx]; |
1354 | QTime timeStart = mAgenda->gyToTime(gy); | 1356 | QTime timeStart = mAgenda->gyToTime(gy); |
1355 | QDateTime dt (dayStart,timeStart); | 1357 | QDateTime dt (dayStart,timeStart); |
1356 | emit newTodoSignal( dt, false ); | 1358 | emit newTodoSignal( dt, false ); |
1357 | } | 1359 | } |
1358 | 1360 | ||
1359 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1361 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1360 | { | 1362 | { |
1361 | uint i; | 1363 | uint i; |
1362 | for(i=0;i<mMinY.size();++i) { | 1364 | for(i=0;i<mMinY.size();++i) { |
1363 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1365 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1364 | else mEventIndicatorTop->enableColumn(i,false); | 1366 | else mEventIndicatorTop->enableColumn(i,false); |
1365 | } | 1367 | } |
1366 | 1368 | ||
1367 | mEventIndicatorTop->update(); | 1369 | mEventIndicatorTop->update(); |
1368 | } | 1370 | } |
1369 | 1371 | ||
1370 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1372 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1371 | { | 1373 | { |
1372 | uint i; | 1374 | uint i; |
1373 | for(i=0;i<mMaxY.size();++i) { | 1375 | for(i=0;i<mMaxY.size();++i) { |
1374 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1376 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1375 | else mEventIndicatorBottom->enableColumn(i,false); | 1377 | else mEventIndicatorBottom->enableColumn(i,false); |
1376 | } | 1378 | } |
1377 | 1379 | ||
1378 | mEventIndicatorBottom->update(); | 1380 | mEventIndicatorBottom->update(); |
1379 | } | 1381 | } |
1380 | 1382 | ||
1381 | void KOAgendaView::startDrag(Event *event) | 1383 | void KOAgendaView::startDrag(Event *event) |
1382 | { | 1384 | { |
1383 | #ifndef KORG_NODND | 1385 | #ifndef KORG_NODND |
1384 | DndFactory factory( calendar() ); | 1386 | DndFactory factory( calendar() ); |
1385 | ICalDrag *vd = factory.createDrag(event,this); | 1387 | ICalDrag *vd = factory.createDrag(event,this); |
1386 | if (vd->drag()) { | 1388 | if (vd->drag()) { |
1387 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1389 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1388 | } | 1390 | } |
1389 | #endif | 1391 | #endif |
1390 | } | 1392 | } |
1391 | 1393 | ||
1392 | void KOAgendaView::readSettings() | 1394 | void KOAgendaView::readSettings() |
1393 | { | 1395 | { |
1394 | readSettings(KOGlobals::config()); | 1396 | readSettings(KOGlobals::config()); |
1395 | } | 1397 | } |
1396 | 1398 | ||
1397 | void KOAgendaView::readSettings(KConfig *config) | 1399 | void KOAgendaView::readSettings(KConfig *config) |
1398 | { | 1400 | { |
1399 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1401 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1400 | 1402 | ||
1401 | config->setGroup("Views"); | 1403 | config->setGroup("Views"); |
1402 | 1404 | ||
1403 | //#ifndef KORG_NOSPLITTER | 1405 | //#ifndef KORG_NOSPLITTER |
1404 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1406 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1405 | if (sizes.count() == 2) { | 1407 | if (sizes.count() == 2) { |
1406 | if ( sizes[0] < 20 ) { | 1408 | if ( sizes[0] < 20 ) { |
1407 | sizes[1] = sizes[1] +20 - sizes[0]; | 1409 | sizes[1] = sizes[1] +20 - sizes[0]; |
1408 | sizes[0] = 20; | 1410 | sizes[0] = 20; |
1409 | } | 1411 | } |
1410 | mSplitterAgenda->setSizes(sizes); | 1412 | mSplitterAgenda->setSizes(sizes); |
1411 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1413 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1412 | } | 1414 | } |
1413 | //#endif | 1415 | //#endif |
1414 | 1416 | ||
1415 | // updateConfig(); | 1417 | // updateConfig(); |
1416 | } | 1418 | } |
1417 | 1419 | ||
1418 | void KOAgendaView::writeSettings(KConfig *config) | 1420 | void KOAgendaView::writeSettings(KConfig *config) |
1419 | { | 1421 | { |
1420 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1422 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1421 | 1423 | ||
1422 | config->setGroup("Views"); | 1424 | config->setGroup("Views"); |
1423 | 1425 | ||
1424 | //#ifndef KORG_NOSPLITTER | 1426 | //#ifndef KORG_NOSPLITTER |
1425 | QValueList<int> list = mSplitterAgenda->sizes(); | 1427 | QValueList<int> list = mSplitterAgenda->sizes(); |
1426 | config->writeEntry("Separator AgendaView",list); | 1428 | config->writeEntry("Separator AgendaView",list); |
1427 | //qDebug("write %d %d ", list[0],list[1] ); | 1429 | //qDebug("write %d %d ", list[0],list[1] ); |
1428 | //#endif | 1430 | //#endif |
1429 | } | 1431 | } |
1430 | 1432 | ||
1431 | void KOAgendaView::setHolidayMasks() | 1433 | void KOAgendaView::setHolidayMasks() |
1432 | { | 1434 | { |
1433 | mHolidayMask.resize(mSelectedDates.count()); | 1435 | mHolidayMask.resize(mSelectedDates.count()); |
1434 | 1436 | ||
1435 | uint i; | 1437 | uint i; |
1436 | for(i=0;i<mSelectedDates.count();++i) { | 1438 | for(i=0;i<mSelectedDates.count();++i) { |
1437 | QDate date = mSelectedDates[i]; | 1439 | QDate date = mSelectedDates[i]; |
1438 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1440 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1439 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1441 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1440 | bool showHoliday = false; | 1442 | bool showHoliday = false; |
1441 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1443 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1442 | QPtrList<Event> events = calendar()->events( date, true ); | 1444 | QPtrList<Event> events = calendar()->events( date, true ); |
1443 | Event *event; | 1445 | Event *event; |
1444 | for( event = events.first(); event; event = events.next() ) { | 1446 | for( event = events.first(); event; event = events.next() ) { |
1445 | if ( event->isHoliday()) { | 1447 | if ( event->isHoliday()) { |
1446 | showHoliday = true; | 1448 | showHoliday = true; |
1447 | break; | 1449 | break; |
1448 | } | 1450 | } |
1449 | } | 1451 | } |
1450 | 1452 | ||
1451 | } | 1453 | } |
1452 | 1454 | ||
1453 | #ifndef KORG_NOPLUGINS | 1455 | #ifndef KORG_NOPLUGINS |
1454 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1456 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1455 | !KOCore::self()->holiday(date).isEmpty(); | 1457 | !KOCore::self()->holiday(date).isEmpty(); |
1456 | #endif | 1458 | #endif |
1457 | bool showDay = showSaturday || showSunday || showHoliday; | 1459 | bool showDay = showSaturday || showSunday || showHoliday; |
1458 | 1460 | ||
1459 | if (showDay) { | 1461 | if (showDay) { |
1460 | mHolidayMask.at(i) = true; | 1462 | mHolidayMask.at(i) = true; |
1461 | } else { | 1463 | } else { |
1462 | mHolidayMask.at(i) = false; | 1464 | mHolidayMask.at(i) = false; |
1463 | } | 1465 | } |
1464 | } | 1466 | } |
1465 | 1467 | ||
1466 | mAgenda->setHolidayMask(&mHolidayMask); | 1468 | mAgenda->setHolidayMask(&mHolidayMask); |
1467 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1469 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1468 | } | 1470 | } |
1469 | 1471 | ||
1470 | void KOAgendaView::setContentsPos(int y) | 1472 | void KOAgendaView::setContentsPos(int y) |
1471 | { | 1473 | { |
1472 | mAgenda->setContentsPos(0,y); | 1474 | mAgenda->setContentsPos(0,y); |
1473 | } | 1475 | } |
1474 | 1476 | ||
1475 | void KOAgendaView::clearSelection() | 1477 | void KOAgendaView::clearSelection() |
1476 | { | 1478 | { |
1477 | mAgenda->deselectItem(); | 1479 | mAgenda->deselectItem(); |
1478 | mAllDayAgenda->deselectItem(); | 1480 | mAllDayAgenda->deselectItem(); |
1479 | } | 1481 | } |
1480 | 1482 | ||
1481 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1483 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1482 | int gxEnd, int gyEnd) | 1484 | int gxEnd, int gyEnd) |
1483 | { | 1485 | { |
1484 | mTimeSpanInAllDay = true; | 1486 | mTimeSpanInAllDay = true; |
1485 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1487 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1486 | } | 1488 | } |
1487 | 1489 | ||
1488 | 1490 | ||
1489 | 1491 | ||
1490 | 1492 | ||
1491 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1493 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1492 | int gxEnd, int gyEnd) | 1494 | int gxEnd, int gyEnd) |
1493 | { | 1495 | { |
1494 | if (!mSelectedDates.count()) return; | 1496 | if (!mSelectedDates.count()) return; |
1495 | 1497 | ||
1496 | QDate dayStart = mSelectedDates[gxStart]; | 1498 | QDate dayStart = mSelectedDates[gxStart]; |
1497 | QDate dayEnd = mSelectedDates[gxEnd]; | 1499 | QDate dayEnd = mSelectedDates[gxEnd]; |
1498 | 1500 | ||
1499 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1501 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1500 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1502 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1501 | 1503 | ||
1502 | QDateTime dtStart(dayStart,timeStart); | 1504 | QDateTime dtStart(dayStart,timeStart); |
1503 | QDateTime dtEnd(dayEnd,timeEnd); | 1505 | QDateTime dtEnd(dayEnd,timeEnd); |
1504 | 1506 | ||
1505 | mTimeSpanBegin = dtStart; | 1507 | mTimeSpanBegin = dtStart; |
1506 | mTimeSpanEnd = dtEnd; | 1508 | mTimeSpanEnd = dtEnd; |
1507 | 1509 | ||
1508 | } | 1510 | } |
1509 | 1511 | ||
1510 | void KOAgendaView::deleteSelectedDateTime() | 1512 | void KOAgendaView::deleteSelectedDateTime() |
1511 | { | 1513 | { |
1512 | mTimeSpanBegin.setDate(QDate()); | 1514 | mTimeSpanBegin.setDate(QDate()); |
1513 | mTimeSpanEnd.setDate(QDate()); | 1515 | mTimeSpanEnd.setDate(QDate()); |
1514 | mTimeSpanInAllDay = false; | 1516 | mTimeSpanInAllDay = false; |
1515 | } | 1517 | } |
1516 | 1518 | ||
1517 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1519 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1518 | { | 1520 | { |
1519 | e->ignore(); | 1521 | e->ignore(); |
1520 | } | 1522 | } |
1521 | 1523 | ||
1522 | void KOAgendaView::scrollOneHourUp() | 1524 | void KOAgendaView::scrollOneHourUp() |
1523 | { | 1525 | { |
1524 | 1526 | ||
1525 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1527 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1526 | } | 1528 | } |
1527 | void KOAgendaView::scrollOneHourDown() | 1529 | void KOAgendaView::scrollOneHourDown() |
1528 | { | 1530 | { |
1529 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1531 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1530 | } | 1532 | } |
1531 | 1533 | ||
1532 | void KOAgendaView::setStartHour( int h ) | 1534 | void KOAgendaView::setStartHour( int h ) |
1533 | { | 1535 | { |
1534 | mAgenda->setStartHour( h ); | 1536 | mAgenda->setStartHour( h ); |
1535 | 1537 | ||
1536 | } | 1538 | } |
1537 | void KOAgendaView::setInitStartHour() | 1539 | void KOAgendaView::setInitStartHour() |
1538 | { | 1540 | { |
1539 | 1541 | ||
1540 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1542 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1541 | setStartHour( QTime::currentTime ().hour() ); | 1543 | setStartHour( QTime::currentTime ().hour() ); |
1542 | else | 1544 | else |
1543 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1545 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1544 | 1546 | ||
1545 | } | 1547 | } |
1546 | 1548 | ||
1547 | 1549 | ||
1548 | void KOAgendaView::updateTodo( Todo * t, int ) | 1550 | void KOAgendaView::updateTodo( Todo * t, int ) |
1549 | { | 1551 | { |
1550 | if ( !isVisible() ) | 1552 | if ( !isVisible() ) |
1551 | return; | 1553 | return; |
1552 | bool remove = false; | 1554 | bool remove = false; |
1553 | bool removeAD = false; | 1555 | bool removeAD = false; |
1554 | QDate da; | 1556 | QDate da; |
1555 | if ( t->hasCompletedDate() ) | 1557 | if ( t->hasCompletedDate() ) |
1556 | da = t->completed().date(); | 1558 | da = t->completed().date(); |
1557 | else | 1559 | else |
1558 | da = t->dtDue().date(); | 1560 | da = t->dtDue().date(); |
1559 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1561 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1560 | remove = true; | 1562 | remove = true; |
1561 | removeAD = true; | 1563 | removeAD = true; |
1562 | } | 1564 | } |
1563 | else { | 1565 | else { |
1564 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1566 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1565 | if ( overdue && | 1567 | if ( overdue && |
1566 | QDate::currentDate() >= mSelectedDates.first() && | 1568 | QDate::currentDate() >= mSelectedDates.first() && |
1567 | QDate::currentDate() <= mSelectedDates.last()) { | 1569 | QDate::currentDate() <= mSelectedDates.last()) { |
1568 | removeAD = false; | 1570 | removeAD = false; |
1569 | remove = true; | 1571 | remove = true; |
1570 | } | 1572 | } |
1571 | else { | 1573 | else { |
1572 | 1574 | ||
1573 | if ( da < mSelectedDates.first() || | 1575 | if ( da < mSelectedDates.first() || |
1574 | da > mSelectedDates.last() ) { | 1576 | da > mSelectedDates.last() ) { |
1575 | remove = true; | 1577 | remove = true; |
1576 | removeAD = true; | 1578 | removeAD = true; |
1577 | } else { | 1579 | } else { |
1578 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1580 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1579 | removeAD = !remove; | 1581 | removeAD = !remove; |
1580 | } | 1582 | } |
1581 | } | 1583 | } |
1582 | } | 1584 | } |
1583 | int days = mSelectedDates.first().daysTo( da ); | 1585 | int days = mSelectedDates.first().daysTo( da ); |
1584 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1586 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1585 | mAgenda->updateTodo( t , days, remove); | 1587 | mAgenda->updateTodo( t , days, remove); |
1586 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1588 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1587 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1589 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1588 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1590 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1589 | 1591 | ||
1590 | } | 1592 | } |
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index a9d1ed3..a03ec52 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -1,499 +1,500 @@ | |||
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 <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qfiledialog.h> | 25 | #include <qfiledialog.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
37 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <krestrictedline.h> | 39 | #include <krestrictedline.h> |
40 | #include <kstandarddirs.h> | 40 | #include <kstandarddirs.h> |
41 | #include <kfiledialog.h> | 41 | #include <kfiledialog.h> |
42 | 42 | ||
43 | #include <libkcal/todo.h> | 43 | #include <libkcal/todo.h> |
44 | 44 | ||
45 | #include <libkdepim/kdateedit.h> | 45 | #include <libkdepim/kdateedit.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "ktimeedit.h" | 48 | #include "ktimeedit.h" |
49 | 49 | ||
50 | #include "koeditorgeneraltodo.h" | 50 | #include "koeditorgeneraltodo.h" |
51 | #include "kolocationbox.h" | 51 | #include "kolocationbox.h" |
52 | 52 | ||
53 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, | 53 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, |
54 | const char* name) | 54 | const char* name) |
55 | : KOEditorGeneral( parent, name) | 55 | : KOEditorGeneral( parent, name) |
56 | { | 56 | { |
57 | } | 57 | } |
58 | 58 | ||
59 | KOEditorGeneralTodo::~KOEditorGeneralTodo() | 59 | KOEditorGeneralTodo::~KOEditorGeneralTodo() |
60 | { | 60 | { |
61 | } | 61 | } |
62 | 62 | ||
63 | void KOEditorGeneralTodo::finishSetup() | 63 | void KOEditorGeneralTodo::finishSetup() |
64 | { | 64 | { |
65 | 65 | ||
66 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); | 66 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); |
67 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); | 67 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); |
68 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); | 68 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); |
69 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); | 69 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); |
70 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); | 70 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); |
71 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); | 71 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); |
72 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); | 72 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); |
73 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); | 73 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); |
74 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); | 74 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); |
75 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); | 75 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); |
76 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); | 76 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); |
77 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); | 77 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); |
78 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); | 78 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); |
79 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); | 79 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); |
80 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 80 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
81 | mSummaryEdit->setFocus(); | 81 | mSummaryEdit->setFocus(); |
82 | } | 82 | } |
83 | 83 | ||
84 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) | 84 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) |
85 | { | 85 | { |
86 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); | 86 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); |
87 | 87 | ||
88 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, | 88 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, |
89 | i18n("Date && Time"),parent); | 89 | i18n("Date && Time"),parent); |
90 | timeLayout->addWidget(timeGroupBox); | 90 | timeLayout->addWidget(timeGroupBox); |
91 | timeGroupBox->layout()->setSpacing( 0 ); | 91 | timeGroupBox->layout()->setSpacing( 0 ); |
92 | timeGroupBox->layout()->setMargin( 5 ); | 92 | timeGroupBox->layout()->setMargin( 5 ); |
93 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); | 93 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); |
94 | 94 | ||
95 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); | 95 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); |
96 | layoutTimeBox->setSpacing(topLayout->spacing()); | 96 | layoutTimeBox->setSpacing(topLayout->spacing()); |
97 | layoutTimeBox->setColStretch( 1, 1 ); | 97 | layoutTimeBox->setColStretch( 1, 1 ); |
98 | 98 | ||
99 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); | 99 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); |
100 | layoutTimeBox->addWidget(mDueCheck,0,0); | 100 | layoutTimeBox->addWidget(mDueCheck,0,0); |
101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); | 101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); |
102 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); | 102 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); |
103 | 103 | ||
104 | 104 | ||
105 | mDueDateEdit = new KDateEdit(timeBoxFrame); | 105 | mDueDateEdit = new KDateEdit(timeBoxFrame); |
106 | layoutTimeBox->addWidget(mDueDateEdit,0,1); | 106 | layoutTimeBox->addWidget(mDueDateEdit,0,1); |
107 | 107 | ||
108 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); | 108 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); |
109 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); | 109 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); |
110 | 110 | ||
111 | 111 | ||
112 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); | 112 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); |
113 | layoutTimeBox->addWidget(mStartCheck,1,0); | 113 | layoutTimeBox->addWidget(mStartCheck,1,0); |
114 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); | 114 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); |
115 | 115 | ||
116 | mStartDateEdit = new KDateEdit(timeBoxFrame); | 116 | mStartDateEdit = new KDateEdit(timeBoxFrame); |
117 | layoutTimeBox->addWidget(mStartDateEdit,1,1); | 117 | layoutTimeBox->addWidget(mStartDateEdit,1,1); |
118 | 118 | ||
119 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); | 119 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); |
120 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); | 120 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); |
121 | 121 | ||
122 | 122 | ||
123 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); | 123 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); |
124 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); | 124 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); |
125 | 125 | ||
126 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); | 126 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); |
127 | 127 | ||
128 | // some more layouting | 128 | // some more layouting |
129 | //layoutTimeBox->setColStretch(3,1); | 129 | //layoutTimeBox->setColStretch(3,1); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) | 133 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) |
134 | { | 134 | { |
135 | mCompletedCombo = new QComboBox(parent); | 135 | mCompletedCombo = new QComboBox(parent); |
136 | // xgettext:no-c-format | 136 | // xgettext:no-c-format |
137 | mCompletedCombo->insertItem(i18n(" 0 %")); | 137 | mCompletedCombo->insertItem(i18n(" 0 %")); |
138 | // xgettext:no-c-format | 138 | // xgettext:no-c-format |
139 | mCompletedCombo->insertItem(i18n(" 20 %")); | 139 | mCompletedCombo->insertItem(i18n(" 20 %")); |
140 | // xgettext:no-c-format | 140 | // xgettext:no-c-format |
141 | mCompletedCombo->insertItem(i18n(" 40 %")); | 141 | mCompletedCombo->insertItem(i18n(" 40 %")); |
142 | // xgettext:no-c-format | 142 | // xgettext:no-c-format |
143 | mCompletedCombo->insertItem(i18n(" 60 %")); | 143 | mCompletedCombo->insertItem(i18n(" 60 %")); |
144 | // xgettext:no-c-format | 144 | // xgettext:no-c-format |
145 | mCompletedCombo->insertItem(i18n(" 80 %")); | 145 | mCompletedCombo->insertItem(i18n(" 80 %")); |
146 | // xgettext:no-c-format | 146 | // xgettext:no-c-format |
147 | mCompletedCombo->insertItem(i18n("100 %")); | 147 | mCompletedCombo->insertItem(i18n("100 %")); |
148 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); | 148 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); |
149 | topLayout->addWidget(mCompletedCombo); | 149 | topLayout->addWidget(mCompletedCombo); |
150 | 150 | ||
151 | mCompletedLabel = new QLabel(i18n("completed"),parent); | 151 | mCompletedLabel = new QLabel(i18n("completed"),parent); |
152 | topLayout->addWidget(mCompletedLabel); | 152 | topLayout->addWidget(mCompletedLabel); |
153 | 153 | ||
154 | mCompleteDateEdit = new KDateEdit(parent); | 154 | mCompleteDateEdit = new KDateEdit(parent); |
155 | topLayout->addWidget(mCompleteDateEdit ); | 155 | topLayout->addWidget(mCompleteDateEdit ); |
156 | 156 | ||
157 | mCompleteTimeEdit = new KOTimeEdit(parent); | 157 | mCompleteTimeEdit = new KOTimeEdit(parent); |
158 | topLayout->addWidget( mCompleteTimeEdit); | 158 | topLayout->addWidget( mCompleteTimeEdit); |
159 | 159 | ||
160 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); | 160 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); |
161 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); | 161 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); |
162 | 162 | ||
163 | if ( QApplication::desktop()->width() <= 480 ) { | 163 | if ( QApplication::desktop()->width() <= 480 ) { |
164 | if ( QApplication::desktop()->width() < 320 ) | 164 | if ( QApplication::desktop()->width() < 320 ) |
165 | mCompleteDateEdit->setMaximumWidth( 85 ); | 165 | mCompleteDateEdit->setMaximumWidth( 85 ); |
166 | else | 166 | else |
167 | mCompleteDateEdit->setMaximumWidth( 140 ); | 167 | mCompleteDateEdit->setMaximumWidth( 140 ); |
168 | topLayout->setSpacing( 0 ); | 168 | topLayout->setSpacing( 0 ); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) | 172 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) |
173 | { | 173 | { |
174 | 174 | ||
175 | QHBox* h = new QHBox ( parent ); | 175 | QHBox* h = new QHBox ( parent ); |
176 | topLayout->addWidget( h ); | 176 | topLayout->addWidget( h ); |
177 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); | 177 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); |
178 | // topLayout->addWidget(priorityLabel); | 178 | // topLayout->addWidget(priorityLabel); |
179 | mPriorityCombo = new QComboBox( h ); | 179 | mPriorityCombo = new QComboBox( h ); |
180 | mPriorityCombo->insertItem(i18n("1 (high)")); | 180 | mPriorityCombo->insertItem(i18n("1 (high)")); |
181 | mPriorityCombo->insertItem(i18n("2")); | 181 | mPriorityCombo->insertItem(i18n("2")); |
182 | mPriorityCombo->insertItem(i18n("3")); | 182 | mPriorityCombo->insertItem(i18n("3")); |
183 | mPriorityCombo->insertItem(i18n("4")); | 183 | mPriorityCombo->insertItem(i18n("4")); |
184 | mPriorityCombo->insertItem(i18n("5 (low)")); | 184 | mPriorityCombo->insertItem(i18n("5 (low)")); |
185 | //topLayout->addWidget(mPriorityCombo); | 185 | //topLayout->addWidget(mPriorityCombo); |
186 | } | 186 | } |
187 | 187 | ||
188 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) | 188 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) |
189 | { | 189 | { |
190 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); | 190 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); |
191 | 191 | ||
192 | initCompletion( parent, statusLayout ); | 192 | initCompletion( parent, statusLayout ); |
193 | 193 | ||
194 | statusLayout->addStretch( 1 ); | 194 | statusLayout->addStretch( 1 ); |
195 | 195 | ||
196 | initPriority( parent, statusLayout ); | 196 | initPriority( parent, statusLayout ); |
197 | } | 197 | } |
198 | 198 | ||
199 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) | 199 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) |
200 | { | 200 | { |
201 | 201 | ||
202 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 202 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
203 | mLocationEdit->load(KOLocationBox::LOCATION); | 203 | mLocationEdit->load(KOLocationBox::LOCATION); |
204 | KOEditorGeneral::setDefaults(allDay); | 204 | KOEditorGeneral::setDefaults(allDay); |
205 | 205 | ||
206 | mTimeButton->setChecked( !allDay ); | 206 | mTimeButton->setChecked( !allDay ); |
207 | if(mTimeButton->isChecked()) { | 207 | if(mTimeButton->isChecked()) { |
208 | mTimeButton->setEnabled(true); | 208 | mTimeButton->setEnabled(true); |
209 | } | 209 | } |
210 | else { | 210 | else { |
211 | mTimeButton->setEnabled(false); | 211 | mTimeButton->setEnabled(false); |
212 | } | 212 | } |
213 | 213 | ||
214 | enableTimeEdits( !allDay ); | 214 | enableTimeEdits( !allDay ); |
215 | if ( due.isValid() ) { | 215 | if ( due.isValid() ) { |
216 | mDueCheck->setChecked(true); | 216 | mDueCheck->setChecked(true); |
217 | enableDueEdit(true); | 217 | enableDueEdit(true); |
218 | alarmDisable(false); | ||
218 | } else { | 219 | } else { |
219 | mDueCheck->setChecked(false); | 220 | mDueCheck->setChecked(false); |
220 | enableDueEdit(false); | 221 | enableDueEdit(false); |
221 | due = QDateTime::currentDateTime().addDays(7); | 222 | due = QDateTime::currentDateTime().addDays(7); |
223 | alarmDisable(true); | ||
222 | } | 224 | } |
223 | 225 | ||
224 | alarmDisable(true); | ||
225 | 226 | ||
226 | mStartCheck->setChecked(false); | 227 | mStartCheck->setChecked(false); |
227 | enableStartEdit(false); | 228 | enableStartEdit(false); |
228 | 229 | ||
229 | mDueDateEdit->setDate(due.date()); | 230 | mDueDateEdit->setDate(due.date()); |
230 | mDueTimeEdit->setTime(due.time()); | 231 | mDueTimeEdit->setTime(due.time()); |
231 | due = due.addDays(-7); | 232 | due = due.addDays(-7); |
232 | mStartDateEdit->setDate(due.date()); | 233 | mStartDateEdit->setDate(due.date()); |
233 | mStartTimeEdit->setTime(due.time()); | 234 | mStartTimeEdit->setTime(due.time()); |
234 | 235 | ||
235 | mPriorityCombo->setCurrentItem(2); | 236 | mPriorityCombo->setCurrentItem(2); |
236 | mCompletedLabel->setText(i18n(" completed"));; | 237 | mCompletedLabel->setText(i18n(" completed"));; |
237 | mCompletedCombo->setCurrentItem(0); | 238 | mCompletedCombo->setCurrentItem(0); |
238 | mCompleteDateEdit->hide(); | 239 | mCompleteDateEdit->hide(); |
239 | mCompleteTimeEdit->hide(); | 240 | mCompleteTimeEdit->hide(); |
240 | } | 241 | } |
241 | 242 | ||
242 | void KOEditorGeneralTodo::readTodo(Todo *todo) | 243 | void KOEditorGeneralTodo::readTodo(Todo *todo) |
243 | { | 244 | { |
244 | 245 | ||
245 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 246 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
246 | mLocationEdit->load(KOLocationBox::LOCATION); | 247 | mLocationEdit->load(KOLocationBox::LOCATION); |
247 | KOEditorGeneral::readIncidence(todo); | 248 | KOEditorGeneral::readIncidence(todo); |
248 | 249 | ||
249 | QDateTime dueDT; | 250 | QDateTime dueDT; |
250 | 251 | ||
251 | if (todo->hasDueDate()) { | 252 | if (todo->hasDueDate()) { |
252 | enableAlarmEdit(true); | 253 | enableAlarmEdit(true); |
253 | dueDT = todo->dtDue(); | 254 | dueDT = todo->dtDue(); |
254 | mDueDateEdit->setDate(todo->dtDue().date()); | 255 | mDueDateEdit->setDate(todo->dtDue().date()); |
255 | mDueTimeEdit->setTime(todo->dtDue().time()); | 256 | mDueTimeEdit->setTime(todo->dtDue().time()); |
256 | mDueCheck->setChecked(true); | 257 | mDueCheck->setChecked(true); |
257 | } else { | 258 | } else { |
258 | alarmDisable(true); | 259 | alarmDisable(true); |
259 | mDueDateEdit->setEnabled(false); | 260 | mDueDateEdit->setEnabled(false); |
260 | mDueTimeEdit->setEnabled(false); | 261 | mDueTimeEdit->setEnabled(false); |
261 | mDueDateEdit->setDate(QDate::currentDate()); | 262 | mDueDateEdit->setDate(QDate::currentDate()); |
262 | mDueTimeEdit->setTime(QTime::currentTime()); | 263 | mDueTimeEdit->setTime(QTime::currentTime()); |
263 | mDueCheck->setChecked(false); | 264 | mDueCheck->setChecked(false); |
264 | } | 265 | } |
265 | 266 | ||
266 | if (todo->hasStartDate()) { | 267 | if (todo->hasStartDate()) { |
267 | mStartDateEdit->setDate(todo->dtStart().date()); | 268 | mStartDateEdit->setDate(todo->dtStart().date()); |
268 | mStartTimeEdit->setTime(todo->dtStart().time()); | 269 | mStartTimeEdit->setTime(todo->dtStart().time()); |
269 | mStartCheck->setChecked(true); | 270 | mStartCheck->setChecked(true); |
270 | } else { | 271 | } else { |
271 | mStartDateEdit->setEnabled(false); | 272 | mStartDateEdit->setEnabled(false); |
272 | mStartTimeEdit->setEnabled(false); | 273 | mStartTimeEdit->setEnabled(false); |
273 | mStartDateEdit->setDate(QDate::currentDate()); | 274 | mStartDateEdit->setDate(QDate::currentDate()); |
274 | mStartTimeEdit->setTime(QTime::currentTime()); | 275 | mStartTimeEdit->setTime(QTime::currentTime()); |
275 | mStartCheck->setChecked(false); | 276 | mStartCheck->setChecked(false); |
276 | } | 277 | } |
277 | 278 | ||
278 | mTimeButton->setChecked( !todo->doesFloat() ); | 279 | mTimeButton->setChecked( !todo->doesFloat() ); |
279 | 280 | ||
280 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 281 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
281 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 282 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
282 | mCompleted = todo->completed(); | 283 | mCompleted = todo->completed(); |
283 | } | 284 | } |
284 | setCompletedDate(); | 285 | setCompletedDate(); |
285 | 286 | ||
286 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 287 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
287 | } | 288 | } |
288 | 289 | ||
289 | void KOEditorGeneralTodo::writeTodo(Todo *todo) | 290 | void KOEditorGeneralTodo::writeTodo(Todo *todo) |
290 | { | 291 | { |
291 | KOEditorGeneral::writeIncidence(todo); | 292 | KOEditorGeneral::writeIncidence(todo); |
292 | 293 | ||
293 | // temp. until something better happens. | 294 | // temp. until something better happens. |
294 | QString tmpStr; | 295 | QString tmpStr; |
295 | 296 | ||
296 | todo->setHasDueDate(mDueCheck->isChecked()); | 297 | todo->setHasDueDate(mDueCheck->isChecked()); |
297 | todo->setHasStartDate(mStartCheck->isChecked()); | 298 | todo->setHasStartDate(mStartCheck->isChecked()); |
298 | 299 | ||
299 | QDate tmpDate; | 300 | QDate tmpDate; |
300 | QTime tmpTime; | 301 | QTime tmpTime; |
301 | QDateTime tmpDT; | 302 | QDateTime tmpDT; |
302 | if ( mTimeButton->isChecked() ) { | 303 | if ( mTimeButton->isChecked() ) { |
303 | todo->setFloats(false); | 304 | todo->setFloats(false); |
304 | 305 | ||
305 | // set due date/time | 306 | // set due date/time |
306 | tmpDate = mDueDateEdit->date(); | 307 | tmpDate = mDueDateEdit->date(); |
307 | tmpTime = mDueTimeEdit->getTime(); | 308 | tmpTime = mDueTimeEdit->getTime(); |
308 | tmpDT.setDate(tmpDate); | 309 | tmpDT.setDate(tmpDate); |
309 | tmpDT.setTime(tmpTime); | 310 | tmpDT.setTime(tmpTime); |
310 | todo->setDtDue(tmpDT); | 311 | todo->setDtDue(tmpDT); |
311 | 312 | ||
312 | // set start date/time | 313 | // set start date/time |
313 | tmpDate = mStartDateEdit->date(); | 314 | tmpDate = mStartDateEdit->date(); |
314 | tmpTime = mStartTimeEdit->getTime(); | 315 | tmpTime = mStartTimeEdit->getTime(); |
315 | tmpDT.setDate(tmpDate); | 316 | tmpDT.setDate(tmpDate); |
316 | tmpDT.setTime(tmpTime); | 317 | tmpDT.setTime(tmpTime); |
317 | todo->setDtStart(tmpDT); | 318 | todo->setDtStart(tmpDT); |
318 | } else { | 319 | } else { |
319 | todo->setFloats(true); | 320 | todo->setFloats(true); |
320 | 321 | ||
321 | // need to change this. | 322 | // need to change this. |
322 | tmpDate = mDueDateEdit->date(); | 323 | tmpDate = mDueDateEdit->date(); |
323 | tmpTime.setHMS(0,0,0); | 324 | tmpTime.setHMS(0,0,0); |
324 | tmpDT.setDate(tmpDate); | 325 | tmpDT.setDate(tmpDate); |
325 | tmpDT.setTime(tmpTime); | 326 | tmpDT.setTime(tmpTime); |
326 | todo->setDtDue(tmpDT); | 327 | todo->setDtDue(tmpDT); |
327 | 328 | ||
328 | tmpDate = mStartDateEdit->date(); | 329 | tmpDate = mStartDateEdit->date(); |
329 | tmpTime.setHMS(0,0,0); | 330 | tmpTime.setHMS(0,0,0); |
330 | tmpDT.setDate(tmpDate); | 331 | tmpDT.setDate(tmpDate); |
331 | tmpDT.setTime(tmpTime); | 332 | tmpDT.setTime(tmpTime); |
332 | todo->setDtStart(tmpDT); | 333 | todo->setDtStart(tmpDT); |
333 | } | 334 | } |
334 | todo->setPriority(mPriorityCombo->currentItem()+1); | 335 | todo->setPriority(mPriorityCombo->currentItem()+1); |
335 | 336 | ||
336 | // set completion state | 337 | // set completion state |
337 | if ( mCompletedCombo->currentItem() == 5 ) { | 338 | if ( mCompletedCombo->currentItem() == 5 ) { |
338 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); | 339 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); |
339 | if ( comp.isValid () ) { | 340 | if ( comp.isValid () ) { |
340 | todo->setPercentComplete(0); | 341 | todo->setPercentComplete(0); |
341 | todo->setPercentComplete(100); | 342 | todo->setPercentComplete(100); |
342 | todo->setCompleted(comp); | 343 | todo->setCompleted(comp); |
343 | } else { | 344 | } else { |
344 | todo->setPercentComplete( 100 ); | 345 | todo->setPercentComplete( 100 ); |
345 | if ( mCompleted.isValid() ) | 346 | if ( mCompleted.isValid() ) |
346 | todo->setCompleted(mCompleted); | 347 | todo->setCompleted(mCompleted); |
347 | } | 348 | } |
348 | } else { | 349 | } else { |
349 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 350 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); |
350 | } | 351 | } |
351 | 352 | ||
352 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 353 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
353 | } | 354 | } |
354 | 355 | ||
355 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 356 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
356 | { | 357 | { |
357 | mDueDateEdit->setEnabled( enable ); | 358 | mDueDateEdit->setEnabled( enable ); |
358 | 359 | ||
359 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 360 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
360 | mTimeButton->setEnabled(true); | 361 | mTimeButton->setEnabled(true); |
361 | } | 362 | } |
362 | else { | 363 | else { |
363 | mTimeButton->setEnabled(false); | 364 | mTimeButton->setEnabled(false); |
364 | mTimeButton->setChecked(false); | 365 | mTimeButton->setChecked(false); |
365 | } | 366 | } |
366 | 367 | ||
367 | if (enable) { | 368 | if (enable) { |
368 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); | 369 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); |
369 | } else { | 370 | } else { |
370 | mDueTimeEdit->setEnabled( false ); | 371 | mDueTimeEdit->setEnabled( false ); |
371 | } | 372 | } |
372 | emit datesChecked(); | 373 | emit datesChecked(); |
373 | } | 374 | } |
374 | 375 | ||
375 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) | 376 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) |
376 | { | 377 | { |
377 | mStartDateEdit->setEnabled( enable ); | 378 | mStartDateEdit->setEnabled( enable ); |
378 | 379 | ||
379 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 380 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
380 | mTimeButton->setEnabled(true); | 381 | mTimeButton->setEnabled(true); |
381 | } | 382 | } |
382 | else { | 383 | else { |
383 | mTimeButton->setEnabled(false); | 384 | mTimeButton->setEnabled(false); |
384 | mTimeButton->setChecked(false); | 385 | mTimeButton->setChecked(false); |
385 | } | 386 | } |
386 | 387 | ||
387 | if (enable) { | 388 | if (enable) { |
388 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); | 389 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); |
389 | } else { | 390 | } else { |
390 | mStartTimeEdit->setEnabled( false ); | 391 | mStartTimeEdit->setEnabled( false ); |
391 | } | 392 | } |
392 | emit datesChecked(); | 393 | emit datesChecked(); |
393 | } | 394 | } |
394 | 395 | ||
395 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) | 396 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) |
396 | { | 397 | { |
397 | if(mStartCheck->isChecked()) { | 398 | if(mStartCheck->isChecked()) { |
398 | mStartTimeEdit->setEnabled( enable ); | 399 | mStartTimeEdit->setEnabled( enable ); |
399 | } | 400 | } |
400 | if(mDueCheck->isChecked()) { | 401 | if(mDueCheck->isChecked()) { |
401 | mDueTimeEdit->setEnabled( enable ); | 402 | mDueTimeEdit->setEnabled( enable ); |
402 | } | 403 | } |
403 | } | 404 | } |
404 | 405 | ||
405 | void KOEditorGeneralTodo::showAlarm() | 406 | void KOEditorGeneralTodo::showAlarm() |
406 | { | 407 | { |
407 | if ( mDueCheck->isChecked() ) { | 408 | if ( mDueCheck->isChecked() ) { |
408 | alarmDisable(false); | 409 | alarmDisable(false); |
409 | } | 410 | } |
410 | else { | 411 | else { |
411 | alarmDisable(true); | 412 | alarmDisable(true); |
412 | } | 413 | } |
413 | } | 414 | } |
414 | 415 | ||
415 | bool KOEditorGeneralTodo::validateInput() | 416 | bool KOEditorGeneralTodo::validateInput() |
416 | { | 417 | { |
417 | if (mDueCheck->isChecked()) { | 418 | if (mDueCheck->isChecked()) { |
418 | if (!mDueDateEdit->inputIsValid()) { | 419 | if (!mDueDateEdit->inputIsValid()) { |
419 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); | 420 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); |
420 | return false; | 421 | return false; |
421 | } | 422 | } |
422 | } | 423 | } |
423 | 424 | ||
424 | if (mStartCheck->isChecked()) { | 425 | if (mStartCheck->isChecked()) { |
425 | if (!mStartDateEdit->inputIsValid()) { | 426 | if (!mStartDateEdit->inputIsValid()) { |
426 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); | 427 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); |
427 | return false; | 428 | return false; |
428 | } | 429 | } |
429 | } | 430 | } |
430 | 431 | ||
431 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { | 432 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { |
432 | QDateTime startDate; | 433 | QDateTime startDate; |
433 | QDateTime dueDate; | 434 | QDateTime dueDate; |
434 | startDate.setDate(mStartDateEdit->date()); | 435 | startDate.setDate(mStartDateEdit->date()); |
435 | dueDate.setDate(mDueDateEdit->date()); | 436 | dueDate.setDate(mDueDateEdit->date()); |
436 | if (mTimeButton->isChecked()) { | 437 | if (mTimeButton->isChecked()) { |
437 | startDate.setTime(mStartTimeEdit->getTime()); | 438 | startDate.setTime(mStartTimeEdit->getTime()); |
438 | dueDate.setTime(mDueTimeEdit->getTime()); | 439 | dueDate.setTime(mDueTimeEdit->getTime()); |
439 | } | 440 | } |
440 | if (startDate > dueDate) { | 441 | if (startDate > dueDate) { |
441 | KMessageBox::sorry(0, | 442 | KMessageBox::sorry(0, |
442 | i18n("The start date cannot be after the due date.")); | 443 | i18n("The start date cannot be after the due date.")); |
443 | return false; | 444 | return false; |
444 | } | 445 | } |
445 | } | 446 | } |
446 | 447 | ||
447 | return KOEditorGeneral::validateInput(); | 448 | return KOEditorGeneral::validateInput(); |
448 | } | 449 | } |
449 | 450 | ||
450 | void KOEditorGeneralTodo::completedChanged(int index) | 451 | void KOEditorGeneralTodo::completedChanged(int index) |
451 | { | 452 | { |
452 | if (index == 5) { | 453 | if (index == 5) { |
453 | //get rid of milli sec | 454 | //get rid of milli sec |
454 | mCompleted = QDateTime::currentDateTime(); | 455 | mCompleted = QDateTime::currentDateTime(); |
455 | } | 456 | } |
456 | setCompletedDate(); | 457 | setCompletedDate(); |
457 | } | 458 | } |
458 | 459 | ||
459 | void KOEditorGeneralTodo::setCompletedDate() | 460 | void KOEditorGeneralTodo::setCompletedDate() |
460 | { | 461 | { |
461 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 462 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { |
462 | if ( QApplication::desktop()->width() < 480 ) { | 463 | if ( QApplication::desktop()->width() < 480 ) { |
463 | mCompletedLabel->setText(i18n(" on")); | 464 | mCompletedLabel->setText(i18n(" on")); |
464 | } | 465 | } |
465 | else | 466 | else |
466 | mCompletedLabel->setText(i18n(" completed on ")); | 467 | mCompletedLabel->setText(i18n(" completed on ")); |
467 | mCompleteDateEdit->show(); | 468 | mCompleteDateEdit->show(); |
468 | mCompleteTimeEdit->show(); | 469 | mCompleteTimeEdit->show(); |
469 | mCompleteTimeEdit->setTime( mCompleted.time() ); | 470 | mCompleteTimeEdit->setTime( mCompleted.time() ); |
470 | mCompleteDateEdit->setDate( mCompleted.date() ); | 471 | mCompleteDateEdit->setDate( mCompleted.date() ); |
471 | } else { | 472 | } else { |
472 | mCompletedLabel->setText(i18n(" completed")); | 473 | mCompletedLabel->setText(i18n(" completed")); |
473 | mCompleteDateEdit->hide(); | 474 | mCompleteDateEdit->hide(); |
474 | mCompleteTimeEdit->hide(); | 475 | mCompleteTimeEdit->hide(); |
475 | } | 476 | } |
476 | } | 477 | } |
477 | 478 | ||
478 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) | 479 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) |
479 | { | 480 | { |
480 | switch (modification) { | 481 | switch (modification) { |
481 | case KOGlobals::PRIORITY_MODIFIED: | 482 | case KOGlobals::PRIORITY_MODIFIED: |
482 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 483 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
483 | break; | 484 | break; |
484 | case KOGlobals::COMPLETION_MODIFIED: | 485 | case KOGlobals::COMPLETION_MODIFIED: |
485 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 486 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
486 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 487 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
487 | mCompleted = todo->completed(); | 488 | mCompleted = todo->completed(); |
488 | } | 489 | } |
489 | setCompletedDate(); | 490 | setCompletedDate(); |
490 | break; | 491 | break; |
491 | case KOGlobals::CATEGORY_MODIFIED: | 492 | case KOGlobals::CATEGORY_MODIFIED: |
492 | setCategories (todo->categoriesStr ()); | 493 | setCategories (todo->categoriesStr ()); |
493 | break; | 494 | break; |
494 | case KOGlobals::UNKNOWN_MODIFIED: // fall through | 495 | case KOGlobals::UNKNOWN_MODIFIED: // fall through |
495 | default: | 496 | default: |
496 | readTodo( todo ); | 497 | readTodo( todo ); |
497 | break; | 498 | break; |
498 | } | 499 | } |
499 | } | 500 | } |
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index eca7c14..49149f2 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,272 +1,278 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
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 <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include "libkdepim/kdatepicker.h" | 38 | #include "libkdepim/kdatepicker.h" |
39 | #include <knotifyclient.h> | 39 | #include <knotifyclient.h> |
40 | #include "kdatetbl.h" | 40 | #include "kdatetbl.h" |
41 | 41 | ||
42 | #include "koglobals.h" | 42 | #include "koglobals.h" |
43 | #include <kglobalsettings.h> | 43 | #include <kglobalsettings.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #ifndef KORG_NOPLUGINS | 45 | #ifndef KORG_NOPLUGINS |
46 | #include "kocore.h" | 46 | #include "kocore.h" |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <kcalendarsystem.h> | 49 | #include <kcalendarsystem.h> |
50 | 50 | ||
51 | #include "navigatorbar.h" | 51 | #include "navigatorbar.h" |
52 | 52 | ||
53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) | 53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) |
54 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ) |
55 | { | 55 | { |
56 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 56 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
57 | 57 | ||
58 | // Set up the control buttons and date label | 58 | // Set up the control buttons and date label |
59 | mCtrlFrame = new QFrame( this ); | 59 | mCtrlFrame = new QFrame( this ); |
60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
61 | mCtrlFrame->setLineWidth(1); | 61 | mCtrlFrame->setLineWidth(1); |
62 | 62 | ||
63 | topLayout->addWidget( mCtrlFrame ); | 63 | topLayout->addWidget( mCtrlFrame ); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | bool isRTL = KOGlobals::self()->reverseLayout(); | 67 | bool isRTL = KOGlobals::self()->reverseLayout(); |
68 | #ifndef DESKTOP_VERSION | 68 | #ifndef DESKTOP_VERSION |
69 | bool isDesktop = false; | 69 | bool isDesktop = false; |
70 | #else | 70 | #else |
71 | bool isDesktop = true; | 71 | bool isDesktop = true; |
72 | #endif | 72 | #endif |
73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
74 | isDesktop = true; | 74 | isDesktop = true; |
75 | // Create backward navigation buttons | 75 | // Create backward navigation buttons |
76 | mPrevYear = new QPushButton( mCtrlFrame ); | 76 | mPrevYear = new QPushButton( mCtrlFrame ); |
77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); | 77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "3leftarrowB" : "3leftarrow" ) ); |
78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
79 | 79 | ||
80 | mPrevMonth = new QPushButton( mCtrlFrame ); | 80 | mPrevMonth = new QPushButton( mCtrlFrame ); |
81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); | 81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow") ); |
82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
83 | 83 | ||
84 | // Create forward navigation buttons | 84 | // Create forward navigation buttons |
85 | mNextMonth = new QPushButton( mCtrlFrame ); | 85 | mNextMonth = new QPushButton( mCtrlFrame ); |
86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); | 86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "2rightarrowB" : "2rightarrow") ); |
87 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 87 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
88 | 88 | ||
89 | mPrevWeek = new QPushButton( mCtrlFrame ); | 89 | mPrevWeek = new QPushButton( mCtrlFrame ); |
90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); | 91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); |
92 | 92 | ||
93 | // Create forward navigation buttons | 93 | // Create forward navigation buttons |
94 | mNextWeek = new QPushButton( mCtrlFrame ); | 94 | mNextWeek = new QPushButton( mCtrlFrame ); |
95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
96 | QToolTip::add( mNextWeek, i18n("Next Week") ); | 96 | QToolTip::add( mNextWeek, i18n("Next Week") ); |
97 | 97 | ||
98 | mNextYear = new QPushButton( mCtrlFrame ); | 98 | mNextYear = new QPushButton( mCtrlFrame ); |
99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); | 99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "3rightarrowB": "3rightarrow") ); |
100 | QToolTip::add( mNextYear, i18n("Next Year") ); | 100 | QToolTip::add( mNextYear, i18n("Next Year") ); |
101 | mSelectMonth = new QPushButton( mCtrlFrame ); | 101 | mSelectMonth = new QPushButton( mCtrlFrame ); |
102 | // Create month name label | 102 | // Create month name label |
103 | //selectMonth->setFont( tfont ); | 103 | //selectMonth->setFont( tfont ); |
104 | // selectMonth->setAlignment( AlignCenter ); | 104 | // selectMonth->setAlignment( AlignCenter ); |
105 | //mDateLabel = new QLabel( selectMonth ); | 105 | //mDateLabel = new QLabel( selectMonth ); |
106 | //mDateLabel->setFont( tfont ); | 106 | //mDateLabel->setFont( tfont ); |
107 | //mDateLabel->setAlignment( AlignCenter ); | 107 | //mDateLabel->setAlignment( AlignCenter ); |
108 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 108 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
109 | mNextMonth->setFlat( true); | 109 | mNextMonth->setFlat( true); |
110 | mNextWeek->setFlat( true); | 110 | mNextWeek->setFlat( true); |
111 | mNextYear->setFlat( true); | 111 | mNextYear->setFlat( true); |
112 | mSelectMonth->setFlat( true); | 112 | mSelectMonth->setFlat( true); |
113 | mPrevYear->setFlat( true); | 113 | mPrevYear->setFlat( true); |
114 | mPrevMonth->setFlat( true); | 114 | mPrevMonth->setFlat( true); |
115 | mPrevWeek->setFlat( true); | 115 | mPrevWeek->setFlat( true); |
116 | } else { | 116 | } else { |
117 | mPrevWeek->hide(); | 117 | mPrevWeek->hide(); |
118 | mNextWeek->hide(); | 118 | mNextWeek->hide(); |
119 | } | 119 | } |
120 | 120 | ||
121 | resetFont( font() ); | 121 | resetFont( font() ); |
122 | 122 | ||
123 | 123 | ||
124 | // set up control frame layout | 124 | // set up control frame layout |
125 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 125 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
126 | ctrlLayout->addWidget( mPrevYear, 3 ); | 126 | ctrlLayout->addWidget( mPrevYear, 3 ); |
127 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 127 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
128 | ctrlLayout->addWidget( mPrevWeek, 3 ); | 128 | ctrlLayout->addWidget( mPrevWeek, 3 ); |
129 | //ctrlLayout->addStretch( 1 ); | 129 | //ctrlLayout->addStretch( 1 ); |
130 | // ctrlLayout->addSpacing( 1 ); | 130 | // ctrlLayout->addSpacing( 1 ); |
131 | // ctrlLayout->addWidget( mDateLabel ); | 131 | // ctrlLayout->addWidget( mDateLabel ); |
132 | ctrlLayout->addWidget( mSelectMonth ); | 132 | ctrlLayout->addWidget( mSelectMonth ); |
133 | // ctrlLayout->addSpacing( 1 ); | 133 | // ctrlLayout->addSpacing( 1 ); |
134 | // ctrlLayout->addStretch( 1 ); | 134 | // ctrlLayout->addStretch( 1 ); |
135 | ctrlLayout->addWidget( mNextWeek, 3 ); | 135 | ctrlLayout->addWidget( mNextWeek, 3 ); |
136 | ctrlLayout->addWidget( mNextMonth, 3 ); | 136 | ctrlLayout->addWidget( mNextMonth, 3 ); |
137 | ctrlLayout->addWidget( mNextYear, 3 ); | 137 | ctrlLayout->addWidget( mNextYear, 3 ); |
138 | 138 | ||
139 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 139 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
140 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 140 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
141 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 141 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
142 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); | 142 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); |
143 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); | 143 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); |
144 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 144 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
145 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 145 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
146 | mPrevYear->setFocusPolicy(NoFocus); | 146 | mPrevYear->setFocusPolicy(NoFocus); |
147 | mPrevMonth->setFocusPolicy(NoFocus); | 147 | mPrevMonth->setFocusPolicy(NoFocus); |
148 | mNextMonth->setFocusPolicy(NoFocus); | 148 | mNextMonth->setFocusPolicy(NoFocus); |
149 | mPrevWeek->setFocusPolicy(NoFocus); | 149 | mPrevWeek->setFocusPolicy(NoFocus); |
150 | mNextWeek->setFocusPolicy(NoFocus); | 150 | mNextWeek->setFocusPolicy(NoFocus); |
151 | mNextYear->setFocusPolicy(NoFocus); | 151 | mNextYear->setFocusPolicy(NoFocus); |
152 | mSelectMonth->setFocusPolicy(NoFocus); | 152 | mSelectMonth->setFocusPolicy(NoFocus); |
153 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 153 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
154 | mPrevYear->setAutoRepeat( true ); | ||
155 | mPrevMonth->setAutoRepeat( true ); | ||
156 | mNextMonth->setAutoRepeat( true ); | ||
157 | mPrevWeek->setAutoRepeat( true ); | ||
158 | mNextWeek->setAutoRepeat( true ); | ||
159 | mNextYear->setAutoRepeat( true ); | ||
154 | 160 | ||
155 | } | 161 | } |
156 | 162 | ||
157 | NavigatorBar::~NavigatorBar() | 163 | NavigatorBar::~NavigatorBar() |
158 | { | 164 | { |
159 | } | 165 | } |
160 | QSize NavigatorBar::sizeHint() const | 166 | QSize NavigatorBar::sizeHint() const |
161 | { | 167 | { |
162 | int wid = mCurrentMinWid ; | 168 | int wid = mCurrentMinWid ; |
163 | if ( mPrevYear->isVisible() ) | 169 | if ( mPrevYear->isVisible() ) |
164 | wid += mCurrentButtonMinWid; | 170 | wid += mCurrentButtonMinWid; |
165 | if ( mPrevMonth->isVisible() ) | 171 | if ( mPrevMonth->isVisible() ) |
166 | wid += mCurrentButtonMinWid; | 172 | wid += mCurrentButtonMinWid; |
167 | if ( mPrevWeek->isVisible() ) | 173 | if ( mPrevWeek->isVisible() ) |
168 | wid += mCurrentButtonMinWid; | 174 | wid += mCurrentButtonMinWid; |
169 | if ( mNextMonth->isVisible() ) | 175 | if ( mNextMonth->isVisible() ) |
170 | wid += mCurrentButtonMinWid; | 176 | wid += mCurrentButtonMinWid; |
171 | if ( mNextWeek->isVisible() ) | 177 | if ( mNextWeek->isVisible() ) |
172 | wid += mCurrentButtonMinWid; | 178 | wid += mCurrentButtonMinWid; |
173 | if ( mNextYear->isVisible() ) | 179 | if ( mNextYear->isVisible() ) |
174 | wid += mCurrentButtonMinWid; | 180 | wid += mCurrentButtonMinWid; |
175 | //qDebug("ret %d %d ", wid, mCurrentHei); | 181 | //qDebug("ret %d %d ", wid, mCurrentHei); |
176 | return QSize ( wid, mCurrentHei ); | 182 | return QSize ( wid, mCurrentHei ); |
177 | } | 183 | } |
178 | QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const | 184 | QSize NavigatorBar::sizeHintTwoButtons( int butNum ) const |
179 | { | 185 | { |
180 | return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); | 186 | return QSize ( mCurrentMinWid + butNum * mCurrentButtonMinWid , mCurrentHei ); |
181 | } | 187 | } |
182 | void NavigatorBar::resetFont ( QFont fo ) | 188 | void NavigatorBar::resetFont ( QFont fo ) |
183 | { | 189 | { |
184 | 190 | ||
185 | QFont tfont = fo; | 191 | QFont tfont = fo; |
186 | if ( QApplication::desktop()->width() >= 480 ) | 192 | if ( QApplication::desktop()->width() >= 480 ) |
187 | tfont.setPointSize(tfont.pointSize()+2); | 193 | tfont.setPointSize(tfont.pointSize()+2); |
188 | tfont.setBold(true); | 194 | tfont.setBold(true); |
189 | 195 | ||
190 | mSelectMonth->setFont( tfont ); | 196 | mSelectMonth->setFont( tfont ); |
191 | // Set minimum width to width of widest month name label | 197 | // Set minimum width to width of widest month name label |
192 | int i; | 198 | int i; |
193 | int maxwidth = 0; | 199 | int maxwidth = 0; |
194 | QFontMetrics fm ( mSelectMonth->font() ); | 200 | QFontMetrics fm ( mSelectMonth->font() ); |
195 | int width = fm.width("September '00" ); | 201 | int width = fm.width("September '00" ); |
196 | maxwidth = width+2; | 202 | maxwidth = width+2; |
197 | int size = fm.height()+2; | 203 | int size = fm.height()+2; |
198 | if ( QApplication::desktop()->width() >= 480 ) { | 204 | if ( QApplication::desktop()->width() >= 480 ) { |
199 | size += 6; | 205 | size += 6; |
200 | maxwidth+= 6; | 206 | maxwidth+= 6; |
201 | } | 207 | } |
202 | mSelectMonth->setMinimumWidth( maxwidth ); | 208 | mSelectMonth->setMinimumWidth( maxwidth ); |
203 | mSelectMonth->setFixedHeight( size ); | 209 | mSelectMonth->setFixedHeight( size ); |
204 | mPrevYear->setFixedHeight( size ); | 210 | mPrevYear->setFixedHeight( size ); |
205 | mPrevMonth->setFixedHeight( size ); | 211 | mPrevMonth->setFixedHeight( size ); |
206 | mPrevWeek->setFixedHeight( size ); | 212 | mPrevWeek->setFixedHeight( size ); |
207 | mNextMonth->setFixedHeight( size ); | 213 | mNextMonth->setFixedHeight( size ); |
208 | mNextWeek->setFixedHeight( size ); | 214 | mNextWeek->setFixedHeight( size ); |
209 | mNextYear->setFixedHeight ( size ); | 215 | mNextYear->setFixedHeight ( size ); |
210 | mCurrentHei = size +2; | 216 | mCurrentHei = size +2; |
211 | mCurrentMinWid = maxwidth+2; | 217 | mCurrentMinWid = maxwidth+2; |
212 | mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; | 218 | mCurrentButtonMinWid = mPrevYear->sizeHint().width()+2; |
213 | } | 219 | } |
214 | 220 | ||
215 | void NavigatorBar::showButtons( bool left, bool right ) | 221 | void NavigatorBar::showButtons( bool left, bool right ) |
216 | { | 222 | { |
217 | if ( left ) { | 223 | if ( left ) { |
218 | mPrevYear->show(); | 224 | mPrevYear->show(); |
219 | mPrevMonth->show(); | 225 | mPrevMonth->show(); |
220 | } else { | 226 | } else { |
221 | mPrevYear->hide(); | 227 | mPrevYear->hide(); |
222 | mPrevMonth->hide(); | 228 | mPrevMonth->hide(); |
223 | } | 229 | } |
224 | 230 | ||
225 | if ( right ) { | 231 | if ( right ) { |
226 | mNextYear->show(); | 232 | mNextYear->show(); |
227 | mNextMonth->show(); | 233 | mNextMonth->show(); |
228 | } else { | 234 | } else { |
229 | mNextYear->hide(); | 235 | mNextYear->hide(); |
230 | mNextMonth->hide(); | 236 | mNextMonth->hide(); |
231 | } | 237 | } |
232 | if ( !left && !right ) { | 238 | if ( !left && !right ) { |
233 | //mSelectMonth->setMaximumWidth( 1024 ); | 239 | //mSelectMonth->setMaximumWidth( 1024 ); |
234 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 240 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
235 | } | 241 | } |
236 | } | 242 | } |
237 | 243 | ||
238 | void NavigatorBar::selectMonth() | 244 | void NavigatorBar::selectMonth() |
239 | { | 245 | { |
240 | 246 | ||
241 | int month; | 247 | int month; |
242 | KPopupFrame* popup = new KPopupFrame(this); | 248 | KPopupFrame* popup = new KPopupFrame(this); |
243 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 249 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
244 | // ----- | 250 | // ----- |
245 | picker->resize(picker->sizeHint()); | 251 | picker->resize(picker->sizeHint()); |
246 | popup->setMainWidget(picker); | 252 | popup->setMainWidget(picker); |
247 | picker->setFocus(); | 253 | picker->setFocus(); |
248 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 254 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
249 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 255 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
250 | { | 256 | { |
251 | month = picker->getResult(); | 257 | month = picker->getResult(); |
252 | emit monthSelected ( month ); | 258 | emit monthSelected ( month ); |
253 | } else { | 259 | } else { |
254 | KNotifyClient::beep(); | 260 | KNotifyClient::beep(); |
255 | } | 261 | } |
256 | delete popup; | 262 | delete popup; |
257 | } | 263 | } |
258 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 264 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
259 | { | 265 | { |
260 | if (dateList.count() > 0) { | 266 | if (dateList.count() > 0) { |
261 | QDate date = dateList.first(); | 267 | QDate date = dateList.first(); |
262 | 268 | ||
263 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 269 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
264 | 270 | ||
265 | // compute the label at the top of the navigator | 271 | // compute the label at the top of the navigator |
266 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 272 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
267 | QString::number( calSys->year( date ) ).right(2); | 273 | QString::number( calSys->year( date ) ).right(2); |
268 | 274 | ||
269 | mSelectMonth->setText( dtstr ); | 275 | mSelectMonth->setText( dtstr ); |
270 | } | 276 | } |
271 | } | 277 | } |
272 | 278 | ||