-rw-r--r-- | korganizer/calendarview.cpp | 16 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 25 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 18 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 11 |
5 files changed, 68 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1009956..d6918d3 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -99,768 +99,769 @@ | |||
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init(); | 232 | init(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void CalendarView::init() | 235 | void CalendarView::init() |
236 | { | 236 | { |
237 | 237 | ||
238 | setFocusPolicy ( WheelFocus ); | 238 | setFocusPolicy ( WheelFocus ); |
239 | mViewerCallerIsSearchDialog = false; | 239 | mViewerCallerIsSearchDialog = false; |
240 | mBlockShowDates = false; | 240 | mBlockShowDates = false; |
241 | beamDialog = new KOBeamPrefs(); | 241 | beamDialog = new KOBeamPrefs(); |
242 | mDatePickerMode = 0; | 242 | mDatePickerMode = 0; |
243 | mCurrentSyncDevice = ""; | 243 | mCurrentSyncDevice = ""; |
244 | writeLocale(); | 244 | writeLocale(); |
245 | mViewManager = new KOViewManager( this ); | 245 | mViewManager = new KOViewManager( this ); |
246 | mDialogManager = new KODialogManager( this ); | 246 | mDialogManager = new KODialogManager( this ); |
247 | mEventViewerDialog = 0; | 247 | mEventViewerDialog = 0; |
248 | mModified = false; | 248 | mModified = false; |
249 | mReadOnly = false; | 249 | mReadOnly = false; |
250 | mSelectedIncidence = 0; | 250 | mSelectedIncidence = 0; |
251 | mCalPrinter = 0; | 251 | mCalPrinter = 0; |
252 | mFilters.setAutoDelete(true); | 252 | mFilters.setAutoDelete(true); |
253 | 253 | ||
254 | mCalendar->registerObserver( this ); | 254 | mCalendar->registerObserver( this ); |
255 | // TODO: Make sure that view is updated, when calendar is changed. | 255 | // TODO: Make sure that view is updated, when calendar is changed. |
256 | 256 | ||
257 | mStorage = new FileStorage( mCalendar ); | 257 | mStorage = new FileStorage( mCalendar ); |
258 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 258 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
259 | 259 | ||
260 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 260 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
261 | #ifndef KORG_NOSPLITTER | 261 | #ifndef KORG_NOSPLITTER |
262 | // create the main layout frames. | 262 | // create the main layout frames. |
263 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 263 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
264 | topLayout->addWidget(mPanner); | 264 | topLayout->addWidget(mPanner); |
265 | 265 | ||
266 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 266 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
267 | "CalendarView::LeftFrame"); | 267 | "CalendarView::LeftFrame"); |
268 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 268 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
269 | 269 | ||
270 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 270 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
271 | "CalendarView::DateNavigator", QDate::currentDate() ); | 271 | "CalendarView::DateNavigator", QDate::currentDate() ); |
272 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 272 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
273 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 273 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
274 | mTodoList->setNavigator( mNavigator ); | 274 | mTodoList->setNavigator( mNavigator ); |
275 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 275 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
276 | 276 | ||
277 | #ifdef KORG_NORESOURCEVIEW | 277 | #ifdef KORG_NORESOURCEVIEW |
278 | mResourceView = 0; | 278 | mResourceView = 0; |
279 | #else | 279 | #else |
280 | if ( mResourceManager ) { | 280 | if ( mResourceManager ) { |
281 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 281 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
282 | mResourceView->updateView(); | 282 | mResourceView->updateView(); |
283 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 283 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
284 | SLOT( updateView() ) ); | 284 | SLOT( updateView() ) ); |
285 | } else { | 285 | } else { |
286 | mResourceView = 0; | 286 | mResourceView = 0; |
287 | } | 287 | } |
288 | #endif | 288 | #endif |
289 | QWidget *rightBox = new QWidget( mPanner ); | 289 | QWidget *rightBox = new QWidget( mPanner ); |
290 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 290 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
291 | 291 | ||
292 | mRightFrame = new QWidgetStack( rightBox ); | 292 | mRightFrame = new QWidgetStack( rightBox ); |
293 | rightLayout->addWidget( mRightFrame, 1 ); | 293 | rightLayout->addWidget( mRightFrame, 1 ); |
294 | 294 | ||
295 | mLeftFrame = mLeftSplitter; | 295 | mLeftFrame = mLeftSplitter; |
296 | #else | 296 | #else |
297 | QWidget *mainBox = new QWidget( this ); | 297 | QWidget *mainBox = new QWidget( this ); |
298 | QWidget *leftFrame = new QWidget( mainBox ); | 298 | QWidget *leftFrame = new QWidget( mainBox ); |
299 | 299 | ||
300 | QBoxLayout * mainBoxLayout; | 300 | QBoxLayout * mainBoxLayout; |
301 | QBoxLayout * leftFrameLayout; | 301 | QBoxLayout * leftFrameLayout; |
302 | if ( KOPrefs::instance()->mVerticalScreen ) { | 302 | if ( KOPrefs::instance()->mVerticalScreen ) { |
303 | mainBoxLayout = new QVBoxLayout(mainBox); | 303 | mainBoxLayout = new QVBoxLayout(mainBox); |
304 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
305 | } else { | 305 | } else { |
306 | mainBoxLayout = new QHBoxLayout(mainBox); | 306 | mainBoxLayout = new QHBoxLayout(mainBox); |
307 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 307 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
308 | } | 308 | } |
309 | topLayout->addWidget( mainBox ); | 309 | topLayout->addWidget( mainBox ); |
310 | mainBoxLayout->addWidget (leftFrame); | 310 | mainBoxLayout->addWidget (leftFrame); |
311 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 311 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
312 | "CalendarView::DateNavigator", QDate::currentDate()); | 312 | "CalendarView::DateNavigator", QDate::currentDate()); |
313 | // mDateNavigator->blockSignals( true ); | 313 | // mDateNavigator->blockSignals( true ); |
314 | leftFrameLayout->addWidget( mDateNavigator ); | 314 | leftFrameLayout->addWidget( mDateNavigator ); |
315 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 315 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
316 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 316 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
317 | mTodoList->setNavigator( mNavigator ); | 317 | mTodoList->setNavigator( mNavigator ); |
318 | 318 | ||
319 | if ( QApplication::desktop()->width() < 480 ) { | 319 | if ( QApplication::desktop()->width() < 480 ) { |
320 | leftFrameLayout->addWidget(mFilterView); | 320 | leftFrameLayout->addWidget(mFilterView); |
321 | leftFrameLayout->addWidget(mTodoList, 2 ); | 321 | leftFrameLayout->addWidget(mTodoList, 2 ); |
322 | 322 | ||
323 | } else { | 323 | } else { |
324 | leftFrameLayout->addWidget(mTodoList,2 ); | 324 | leftFrameLayout->addWidget(mTodoList,2 ); |
325 | leftFrameLayout->addWidget(mFilterView ); | 325 | leftFrameLayout->addWidget(mFilterView ); |
326 | } | 326 | } |
327 | mFilterView->hide(); | 327 | mFilterView->hide(); |
328 | QWidget *rightBox = new QWidget( mainBox ); | 328 | QWidget *rightBox = new QWidget( mainBox ); |
329 | mainBoxLayout->addWidget ( rightBox, 10 ); | 329 | mainBoxLayout->addWidget ( rightBox, 10 ); |
330 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 330 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
331 | mRightFrame = new QWidgetStack( rightBox ); | 331 | mRightFrame = new QWidgetStack( rightBox ); |
332 | rightLayout->addWidget( mRightFrame, 10 ); | 332 | rightLayout->addWidget( mRightFrame, 10 ); |
333 | 333 | ||
334 | mLeftFrame = leftFrame; | 334 | mLeftFrame = leftFrame; |
335 | if ( KOPrefs::instance()->mVerticalScreen ) { | 335 | if ( KOPrefs::instance()->mVerticalScreen ) { |
336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
338 | } else { | 338 | } else { |
339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
341 | } | 341 | } |
342 | if ( !KOPrefs::instance()->mShowDateNavigator) | 342 | if ( !KOPrefs::instance()->mShowDateNavigator) |
343 | mDateNavigator->hide(); | 343 | mDateNavigator->hide(); |
344 | //qDebug("Calendarview Size %d %d ", width(), height()); | 344 | //qDebug("Calendarview Size %d %d ", width(), height()); |
345 | #endif | 345 | #endif |
346 | 346 | ||
347 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 347 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
348 | SLOT( showDates( const KCal::DateList & ) ) ); | 348 | SLOT( showDates( const KCal::DateList & ) ) ); |
349 | 349 | ||
350 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 350 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
351 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 351 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
352 | 352 | ||
353 | 353 | ||
354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
356 | 356 | ||
357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
358 | mNavigator, SLOT( selectPreviousYear() ) ); | 358 | mNavigator, SLOT( selectPreviousYear() ) ); |
359 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 359 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
360 | mNavigator, SLOT( selectNextYear() ) ); | 360 | mNavigator, SLOT( selectNextYear() ) ); |
361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
362 | mNavigator, SLOT( selectPreviousMonth() ) ); | 362 | mNavigator, SLOT( selectPreviousMonth() ) ); |
363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
364 | mNavigator, SLOT( selectNextMonth() ) ); | 364 | mNavigator, SLOT( selectNextMonth() ) ); |
365 | 365 | ||
366 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 366 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
367 | mNavigator, SLOT( selectPrevious() ) ); | 367 | mNavigator, SLOT( selectPrevious() ) ); |
368 | connect( mDateNavigator, SIGNAL( goNext() ), | 368 | connect( mDateNavigator, SIGNAL( goNext() ), |
369 | mNavigator, SLOT( selectNext() ) ); | 369 | mNavigator, SLOT( selectNext() ) ); |
370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 373 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
374 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 374 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
375 | 375 | ||
376 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 376 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
377 | SLOT( eventAdded( Event *) ) ); | 377 | SLOT( eventAdded( Event *) ) ); |
378 | 378 | ||
379 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 379 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
380 | 380 | ||
381 | connect( this, SIGNAL( configChanged() ), | 381 | connect( this, SIGNAL( configChanged() ), |
382 | mDateNavigator, SLOT( updateConfig() ) ); | 382 | mDateNavigator, SLOT( updateConfig() ) ); |
383 | 383 | ||
384 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 384 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
385 | SLOT( newTodo() ) ); | 385 | SLOT( newTodo() ) ); |
386 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 386 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
387 | SLOT( newSubTodo( Todo * ) ) ); | 387 | SLOT( newSubTodo( Todo * ) ) ); |
388 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 388 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
389 | SLOT( editTodo( Todo * ) ) ); | 389 | SLOT( editTodo( Todo * ) ) ); |
390 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 390 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
391 | SLOT( showTodo( Todo *) ) ); | 391 | SLOT( showTodo( Todo *) ) ); |
392 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 392 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
393 | SLOT( deleteTodo( Todo *) ) ); | 393 | SLOT( deleteTodo( Todo *) ) ); |
394 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 394 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
395 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 395 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
396 | SLOT( purgeCompleted() ) ); | 396 | SLOT( purgeCompleted() ) ); |
397 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 397 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
398 | SIGNAL( todoModified( Todo *, int ) ) ); | 398 | SIGNAL( todoModified( Todo *, int ) ) ); |
399 | 399 | ||
400 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 400 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
401 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 401 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
402 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 402 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
403 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 403 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
404 | 404 | ||
405 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 405 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
406 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 406 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
407 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 407 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
408 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 408 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
409 | 409 | ||
410 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 410 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
411 | this, SLOT ( todo_unsub( Todo * ) ) ); | 411 | this, SLOT ( todo_unsub( Todo * ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 413 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
414 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 414 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
416 | SLOT( updateTodo( Todo *, int ) ) ); | 416 | SLOT( updateTodo( Todo *, int ) ) ); |
417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
419 | 419 | ||
420 | 420 | ||
421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
425 | 425 | ||
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
431 | SLOT(checkClipboard())); | 431 | SLOT(checkClipboard())); |
432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
433 | SLOT( processTodoListSelection( Incidence * ) ) ); | 433 | SLOT( processTodoListSelection( Incidence * ) ) ); |
434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
435 | 435 | ||
436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
437 | 437 | ||
438 | mDateFrame = new QVBox(0,0,WType_Popup); | 438 | mDateFrame = new QVBox(0,0,WType_Popup); |
439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
441 | mDateFrame->setLineWidth(3); | 441 | mDateFrame->setLineWidth(3); |
442 | mDateFrame->hide(); | 442 | mDateFrame->hide(); |
443 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 443 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
445 | 445 | ||
446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
447 | 447 | ||
448 | mEventEditor = mDialogManager->getEventEditor(); | 448 | mEventEditor = mDialogManager->getEventEditor(); |
449 | mTodoEditor = mDialogManager->getTodoEditor(); | 449 | mTodoEditor = mDialogManager->getTodoEditor(); |
450 | 450 | ||
451 | mFlagEditDescription = false; | 451 | mFlagEditDescription = false; |
452 | 452 | ||
453 | mSuspendTimer = new QTimer( this ); | 453 | mSuspendTimer = new QTimer( this ); |
454 | mAlarmTimer = new QTimer( this ); | 454 | mAlarmTimer = new QTimer( this ); |
455 | mRecheckAlarmTimer = new QTimer( this ); | 455 | mRecheckAlarmTimer = new QTimer( this ); |
456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
459 | mAlarmDialog = new AlarmDialog( this ); | 459 | mAlarmDialog = new AlarmDialog( this ); |
460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
461 | mAlarmDialog->setServerNotification( false ); | 461 | mAlarmDialog->setServerNotification( false ); |
462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
463 | 463 | ||
464 | 464 | ||
465 | #ifndef DESKTOP_VERSION | 465 | #ifndef DESKTOP_VERSION |
466 | //US listen for arriving address resultsets | 466 | //US listen for arriving address resultsets |
467 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 467 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
468 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 468 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
469 | #endif | 469 | #endif |
470 | 470 | ||
471 | } | 471 | } |
472 | 472 | ||
473 | 473 | ||
474 | CalendarView::~CalendarView() | 474 | CalendarView::~CalendarView() |
475 | { | 475 | { |
476 | // kdDebug() << "~CalendarView()" << endl; | 476 | // kdDebug() << "~CalendarView()" << endl; |
477 | //qDebug("CalendarView::~CalendarView() "); | 477 | //qDebug("CalendarView::~CalendarView() "); |
478 | delete mDialogManager; | 478 | delete mDialogManager; |
479 | delete mViewManager; | 479 | delete mViewManager; |
480 | delete mStorage; | 480 | delete mStorage; |
481 | delete mDateFrame ; | 481 | delete mDateFrame ; |
482 | delete beamDialog; | 482 | delete beamDialog; |
483 | delete mEventViewerDialog; | ||
483 | //kdDebug() << "~CalendarView() done" << endl; | 484 | //kdDebug() << "~CalendarView() done" << endl; |
484 | } | 485 | } |
485 | 486 | ||
486 | void CalendarView::showDay( QDate d ) | 487 | void CalendarView::showDay( QDate d ) |
487 | { | 488 | { |
488 | dateNavigator()->blockSignals( true ); | 489 | dateNavigator()->blockSignals( true ); |
489 | dateNavigator()->selectDate( d ); | 490 | dateNavigator()->selectDate( d ); |
490 | dateNavigator()->blockSignals( false ); | 491 | dateNavigator()->blockSignals( false ); |
491 | mViewManager->showDayView(); | 492 | mViewManager->showDayView(); |
492 | //dateNavigator()->selectDate( d ); | 493 | //dateNavigator()->selectDate( d ); |
493 | } | 494 | } |
494 | void CalendarView::timerAlarm() | 495 | void CalendarView::timerAlarm() |
495 | { | 496 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 497 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 498 | computeAlarm(mAlarmNotification ); |
498 | } | 499 | } |
499 | 500 | ||
500 | void CalendarView::suspendAlarm() | 501 | void CalendarView::suspendAlarm() |
501 | { | 502 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 503 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 504 | computeAlarm(mSuspendAlarmNotification ); |
504 | 505 | ||
505 | } | 506 | } |
506 | 507 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 508 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 509 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 510 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 511 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 512 | ||
512 | } | 513 | } |
513 | 514 | ||
514 | void CalendarView::checkNextTimerAlarm() | 515 | void CalendarView::checkNextTimerAlarm() |
515 | { | 516 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 517 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 518 | } |
518 | 519 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 520 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 521 | { |
521 | 522 | ||
522 | QString mess = msg; | 523 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 524 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 525 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 526 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 527 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 528 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 529 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 530 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 531 | if ( len < 2 ) |
531 | error = true; | 532 | error = true; |
532 | else { | 533 | else { |
533 | tempfilename = mess.mid( 13, len ); | 534 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 535 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 536 | error = true; |
536 | } | 537 | } |
537 | if ( ! error ) { | 538 | if ( ! error ) { |
538 | filename = tempfilename; | 539 | filename = tempfilename; |
539 | } | 540 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 541 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 542 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 543 | startAlarm( mAlarmMessage, filename); |
543 | return; | 544 | return; |
544 | } | 545 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 546 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 547 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 548 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 549 | return; |
549 | } | 550 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 551 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 552 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 553 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 554 | if ( len < 2 ) |
554 | error = true; | 555 | error = true; |
555 | else { | 556 | else { |
556 | tempfilename = mess.mid( 10, len ); | 557 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 558 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 559 | error = true; |
559 | } | 560 | } |
560 | if ( error ) { | 561 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 562 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 563 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 564 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 565 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 566 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 567 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 568 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 569 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 570 | return; |
570 | } | 571 | } |
571 | #else | 572 | #else |
572 | QProcess* p = new QProcess(); | 573 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 574 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 575 | p->start(); |
575 | return; | 576 | return; |
576 | #endif | 577 | #endif |
577 | 578 | ||
578 | return; | 579 | return; |
579 | } | 580 | } |
580 | 581 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 582 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 583 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 584 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 585 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 586 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 587 | if ( len < 2 ) |
587 | error = true; | 588 | error = true; |
588 | else { | 589 | else { |
589 | tempfilename = mess.mid( 11, len ); | 590 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 591 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 592 | error = true; |
592 | } | 593 | } |
593 | if ( ! error ) { | 594 | if ( ! error ) { |
594 | filename = tempfilename; | 595 | filename = tempfilename; |
595 | } | 596 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 597 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 598 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 599 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 600 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 601 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 602 | } |
602 | 603 | ||
603 | startAlarm( mAlarmMessage, filename ); | 604 | startAlarm( mAlarmMessage, filename ); |
604 | 605 | ||
605 | 606 | ||
606 | } | 607 | } |
607 | 608 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 609 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 610 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 611 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 612 | ||
612 | mSuspendAlarmNotification = noti; | 613 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 614 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 615 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 616 | mSuspendTimer->start( ms , true ); |
616 | 617 | ||
617 | } | 618 | } |
618 | 619 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 620 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 621 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 622 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 623 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 624 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 625 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 626 | #endif |
626 | return; | 627 | return; |
627 | } | 628 | } |
628 | int maxSec; | 629 | int maxSec; |
629 | //maxSec = 5; //testing only | 630 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 631 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 632 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 633 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 634 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 635 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 636 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 637 | return; |
637 | } else { | 638 | } else { |
638 | mRecheckAlarmTimer->stop(); | 639 | mRecheckAlarmTimer->stop(); |
639 | } | 640 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 641 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 642 | mAlarmTimer->start( sec *1000 , true ); |
642 | 643 | ||
643 | } | 644 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 645 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 646 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 647 | void CalendarView::recheckTimerAlarm() |
647 | { | 648 | { |
648 | mAlarmTimer->stop(); | 649 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 650 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 651 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 652 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 653 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 654 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 655 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 656 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 657 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 658 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 659 | #endif |
659 | return; | 660 | return; |
660 | } | 661 | } |
661 | mAlarmTimer->stop(); | 662 | mAlarmTimer->stop(); |
662 | } | 663 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 664 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 665 | { |
665 | dateNavigator()->blockSignals( true ); | 666 | dateNavigator()->blockSignals( true ); |
666 | dateNavigator()->selectWeek( num ); | 667 | dateNavigator()->selectWeek( num ); |
667 | dateNavigator()->blockSignals( false ); | 668 | dateNavigator()->blockSignals( false ); |
668 | mViewManager->showWeekView(); | 669 | mViewManager->showWeekView(); |
669 | } | 670 | } |
670 | KOViewManager *CalendarView::viewManager() | 671 | KOViewManager *CalendarView::viewManager() |
671 | { | 672 | { |
672 | return mViewManager; | 673 | return mViewManager; |
673 | } | 674 | } |
674 | 675 | ||
675 | KODialogManager *CalendarView::dialogManager() | 676 | KODialogManager *CalendarView::dialogManager() |
676 | { | 677 | { |
677 | return mDialogManager; | 678 | return mDialogManager; |
678 | } | 679 | } |
679 | 680 | ||
680 | QDate CalendarView::startDate() | 681 | QDate CalendarView::startDate() |
681 | { | 682 | { |
682 | DateList dates = mNavigator->selectedDates(); | 683 | DateList dates = mNavigator->selectedDates(); |
683 | 684 | ||
684 | return dates.first(); | 685 | return dates.first(); |
685 | } | 686 | } |
686 | 687 | ||
687 | QDate CalendarView::endDate() | 688 | QDate CalendarView::endDate() |
688 | { | 689 | { |
689 | DateList dates = mNavigator->selectedDates(); | 690 | DateList dates = mNavigator->selectedDates(); |
690 | 691 | ||
691 | return dates.last(); | 692 | return dates.last(); |
692 | } | 693 | } |
693 | 694 | ||
694 | 695 | ||
695 | void CalendarView::createPrinter() | 696 | void CalendarView::createPrinter() |
696 | { | 697 | { |
697 | #ifndef KORG_NOPRINTER | 698 | #ifndef KORG_NOPRINTER |
698 | if (!mCalPrinter) { | 699 | if (!mCalPrinter) { |
699 | mCalPrinter = new CalPrinter(this, mCalendar); | 700 | mCalPrinter = new CalPrinter(this, mCalendar); |
700 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 701 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
701 | } | 702 | } |
702 | #endif | 703 | #endif |
703 | } | 704 | } |
704 | 705 | ||
705 | 706 | ||
706 | //KOPrefs::instance()->mWriteBackFile | 707 | //KOPrefs::instance()->mWriteBackFile |
707 | //KOPrefs::instance()->mWriteBackExistingOnly | 708 | //KOPrefs::instance()->mWriteBackExistingOnly |
708 | 709 | ||
709 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 710 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
710 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 711 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
711 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 712 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
712 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 713 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
713 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 714 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
714 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 715 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
715 | 716 | ||
716 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 717 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
717 | { | 718 | { |
718 | 719 | ||
719 | // 0 equal | 720 | // 0 equal |
720 | // 1 take local | 721 | // 1 take local |
721 | // 2 take remote | 722 | // 2 take remote |
722 | // 3 cancel | 723 | // 3 cancel |
723 | QDateTime lastSync = mLastCalendarSync; | 724 | QDateTime lastSync = mLastCalendarSync; |
724 | QDateTime localMod = local->lastModified(); | 725 | QDateTime localMod = local->lastModified(); |
725 | QDateTime remoteMod = remote->lastModified(); | 726 | QDateTime remoteMod = remote->lastModified(); |
726 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 727 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
727 | bool remCh, locCh; | 728 | bool remCh, locCh; |
728 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 729 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
729 | //if ( remCh ) | 730 | //if ( remCh ) |
730 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 731 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
731 | locCh = ( localMod > mLastCalendarSync ); | 732 | locCh = ( localMod > mLastCalendarSync ); |
732 | if ( !remCh && ! locCh ) { | 733 | if ( !remCh && ! locCh ) { |
733 | //qDebug("both not changed "); | 734 | //qDebug("both not changed "); |
734 | lastSync = localMod.addDays(1); | 735 | lastSync = localMod.addDays(1); |
735 | if ( mode <= SYNC_PREF_ASK ) | 736 | if ( mode <= SYNC_PREF_ASK ) |
736 | return 0; | 737 | return 0; |
737 | } else { | 738 | } else { |
738 | if ( locCh ) { | 739 | if ( locCh ) { |
739 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 740 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
740 | lastSync = localMod.addDays( -1 ); | 741 | lastSync = localMod.addDays( -1 ); |
741 | if ( !remCh ) | 742 | if ( !remCh ) |
742 | remoteMod = ( lastSync.addDays( -1 ) ); | 743 | remoteMod = ( lastSync.addDays( -1 ) ); |
743 | } else { | 744 | } else { |
744 | //qDebug(" not loc changed "); | 745 | //qDebug(" not loc changed "); |
745 | lastSync = localMod.addDays( 1 ); | 746 | lastSync = localMod.addDays( 1 ); |
746 | if ( remCh ) | 747 | if ( remCh ) |
747 | remoteMod =( lastSync.addDays( 1 ) ); | 748 | remoteMod =( lastSync.addDays( 1 ) ); |
748 | 749 | ||
749 | } | 750 | } |
750 | } | 751 | } |
751 | full = true; | 752 | full = true; |
752 | if ( mode < SYNC_PREF_ASK ) | 753 | if ( mode < SYNC_PREF_ASK ) |
753 | mode = SYNC_PREF_ASK; | 754 | mode = SYNC_PREF_ASK; |
754 | } else { | 755 | } else { |
755 | if ( localMod == remoteMod ) | 756 | if ( localMod == remoteMod ) |
756 | // if ( local->revision() == remote->revision() ) | 757 | // if ( local->revision() == remote->revision() ) |
757 | return 0; | 758 | return 0; |
758 | 759 | ||
759 | } | 760 | } |
760 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 761 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
761 | 762 | ||
762 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 763 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
763 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 764 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
764 | //full = true; //debug only | 765 | //full = true; //debug only |
765 | if ( full ) { | 766 | if ( full ) { |
766 | bool equ = false; | 767 | bool equ = false; |
767 | if ( local->type() == "Event" ) { | 768 | if ( local->type() == "Event" ) { |
768 | equ = (*((Event*) local) == *((Event*) remote)); | 769 | equ = (*((Event*) local) == *((Event*) remote)); |
769 | } | 770 | } |
770 | else if ( local->type() =="Todo" ) | 771 | else if ( local->type() =="Todo" ) |
771 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 772 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
772 | else if ( local->type() =="Journal" ) | 773 | else if ( local->type() =="Journal" ) |
773 | equ = (*((Journal*) local) == *((Journal*) remote)); | 774 | equ = (*((Journal*) local) == *((Journal*) remote)); |
774 | if ( equ ) { | 775 | if ( equ ) { |
775 | //qDebug("equal "); | 776 | //qDebug("equal "); |
776 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
777 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 778 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
778 | } | 779 | } |
779 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 780 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
780 | return 0; | 781 | return 0; |
781 | 782 | ||
782 | }//else //debug only | 783 | }//else //debug only |
783 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 784 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
784 | } | 785 | } |
785 | int result; | 786 | int result; |
786 | bool localIsNew; | 787 | bool localIsNew; |
787 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 788 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
788 | 789 | ||
789 | if ( full && mode < SYNC_PREF_NEWEST ) | 790 | if ( full && mode < SYNC_PREF_NEWEST ) |
790 | mode = SYNC_PREF_ASK; | 791 | mode = SYNC_PREF_ASK; |
791 | 792 | ||
792 | switch( mode ) { | 793 | switch( mode ) { |
793 | case SYNC_PREF_LOCAL: | 794 | case SYNC_PREF_LOCAL: |
794 | if ( lastSync > remoteMod ) | 795 | if ( lastSync > remoteMod ) |
795 | return 1; | 796 | return 1; |
796 | if ( lastSync > localMod ) | 797 | if ( lastSync > localMod ) |
797 | return 2; | 798 | return 2; |
798 | return 1; | 799 | return 1; |
799 | break; | 800 | break; |
800 | case SYNC_PREF_REMOTE: | 801 | case SYNC_PREF_REMOTE: |
801 | if ( lastSync > remoteMod ) | 802 | if ( lastSync > remoteMod ) |
802 | return 1; | 803 | return 1; |
803 | if ( lastSync > localMod ) | 804 | if ( lastSync > localMod ) |
804 | return 2; | 805 | return 2; |
805 | return 2; | 806 | return 2; |
806 | break; | 807 | break; |
807 | case SYNC_PREF_NEWEST: | 808 | case SYNC_PREF_NEWEST: |
808 | if ( localMod > remoteMod ) | 809 | if ( localMod > remoteMod ) |
809 | return 1; | 810 | return 1; |
810 | else | 811 | else |
811 | return 2; | 812 | return 2; |
812 | break; | 813 | break; |
813 | case SYNC_PREF_ASK: | 814 | case SYNC_PREF_ASK: |
814 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 815 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
815 | if ( lastSync > remoteMod ) | 816 | if ( lastSync > remoteMod ) |
816 | return 1; | 817 | return 1; |
817 | if ( lastSync > localMod ) | 818 | if ( lastSync > localMod ) |
818 | return 2; | 819 | return 2; |
819 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
820 | localIsNew = localMod >= remoteMod; | 821 | localIsNew = localMod >= remoteMod; |
821 | if ( localIsNew ) | 822 | if ( localIsNew ) |
822 | getEventViewerDialog()->setColorMode( 1 ); | 823 | getEventViewerDialog()->setColorMode( 1 ); |
823 | else | 824 | else |
824 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
825 | getEventViewerDialog()->setIncidence(local); | 826 | getEventViewerDialog()->setIncidence(local); |
826 | if ( localIsNew ) | 827 | if ( localIsNew ) |
827 | getEventViewerDialog()->setColorMode( 2 ); | 828 | getEventViewerDialog()->setColorMode( 2 ); |
828 | else | 829 | else |
829 | getEventViewerDialog()->setColorMode( 1 ); | 830 | getEventViewerDialog()->setColorMode( 1 ); |
830 | getEventViewerDialog()->addIncidence(remote); | 831 | getEventViewerDialog()->addIncidence(remote); |
831 | getEventViewerDialog()->setColorMode( 0 ); | 832 | getEventViewerDialog()->setColorMode( 0 ); |
832 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 833 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
833 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 834 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
834 | getEventViewerDialog()->showMe(); | 835 | getEventViewerDialog()->showMe(); |
835 | result = getEventViewerDialog()->executeS( localIsNew ); | 836 | result = getEventViewerDialog()->executeS( localIsNew ); |
836 | return result; | 837 | return result; |
837 | 838 | ||
838 | break; | 839 | break; |
839 | case SYNC_PREF_FORCE_LOCAL: | 840 | case SYNC_PREF_FORCE_LOCAL: |
840 | return 1; | 841 | return 1; |
841 | break; | 842 | break; |
842 | case SYNC_PREF_FORCE_REMOTE: | 843 | case SYNC_PREF_FORCE_REMOTE: |
843 | return 2; | 844 | return 2; |
844 | break; | 845 | break; |
845 | 846 | ||
846 | default: | 847 | default: |
847 | // SYNC_PREF_TAKE_BOTH not implemented | 848 | // SYNC_PREF_TAKE_BOTH not implemented |
848 | break; | 849 | break; |
849 | } | 850 | } |
850 | return 0; | 851 | return 0; |
851 | } | 852 | } |
852 | Event* CalendarView::getLastSyncEvent() | 853 | Event* CalendarView::getLastSyncEvent() |
853 | { | 854 | { |
854 | Event* lse; | 855 | Event* lse; |
855 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 856 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
856 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
857 | if (!lse) { | 858 | if (!lse) { |
858 | lse = new Event(); | 859 | lse = new Event(); |
859 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 860 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
860 | QString sum = ""; | 861 | QString sum = ""; |
861 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 862 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
862 | sum = "E: "; | 863 | sum = "E: "; |
863 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 864 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
864 | lse->setDtStart( mLastCalendarSync ); | 865 | lse->setDtStart( mLastCalendarSync ); |
865 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 866 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
866 | lse->setCategories( i18n("SyncEvent") ); | 867 | lse->setCategories( i18n("SyncEvent") ); |
@@ -2146,1035 +2147,1047 @@ void CalendarView::changeEventDisplay(Event *which, int action) | |||
2146 | } | 2147 | } |
2147 | 2148 | ||
2148 | 2149 | ||
2149 | void CalendarView::updateTodoViews() | 2150 | void CalendarView::updateTodoViews() |
2150 | { | 2151 | { |
2151 | mTodoList->updateView(); | 2152 | mTodoList->updateView(); |
2152 | mViewManager->currentView()->updateView(); | 2153 | mViewManager->currentView()->updateView(); |
2153 | 2154 | ||
2154 | } | 2155 | } |
2155 | 2156 | ||
2156 | 2157 | ||
2157 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2158 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2158 | { | 2159 | { |
2159 | mTodoList->updateView(); | 2160 | mTodoList->updateView(); |
2160 | mViewManager->updateView(start, end); | 2161 | mViewManager->updateView(start, end); |
2161 | //mDateNavigator->updateView(); | 2162 | //mDateNavigator->updateView(); |
2162 | } | 2163 | } |
2163 | 2164 | ||
2164 | void CalendarView::updateView() | 2165 | void CalendarView::updateView() |
2165 | { | 2166 | { |
2166 | DateList tmpList = mNavigator->selectedDates(); | 2167 | DateList tmpList = mNavigator->selectedDates(); |
2167 | 2168 | ||
2168 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2169 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2169 | mTodoList->updateView(); | 2170 | mTodoList->updateView(); |
2170 | // We assume that the navigator only selects consecutive days. | 2171 | // We assume that the navigator only selects consecutive days. |
2171 | updateView( tmpList.first(), tmpList.last() ); | 2172 | updateView( tmpList.first(), tmpList.last() ); |
2172 | } | 2173 | } |
2173 | 2174 | ||
2174 | void CalendarView::updateUnmanagedViews() | 2175 | void CalendarView::updateUnmanagedViews() |
2175 | { | 2176 | { |
2176 | mDateNavigator->updateDayMatrix(); | 2177 | mDateNavigator->updateDayMatrix(); |
2177 | } | 2178 | } |
2178 | 2179 | ||
2179 | int CalendarView::msgItemDelete(const QString name) | 2180 | int CalendarView::msgItemDelete(const QString name) |
2180 | { | 2181 | { |
2181 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2182 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2182 | i18n("This item will be\npermanently deleted."), | 2183 | i18n("This item will be\npermanently deleted."), |
2183 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2184 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2184 | } | 2185 | } |
2185 | 2186 | ||
2186 | 2187 | ||
2187 | void CalendarView::edit_cut() | 2188 | void CalendarView::edit_cut() |
2188 | { | 2189 | { |
2189 | Event *anEvent=0; | 2190 | Event *anEvent=0; |
2190 | 2191 | ||
2191 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2192 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2192 | 2193 | ||
2193 | if (mViewManager->currentView()->isEventView()) { | 2194 | if (mViewManager->currentView()->isEventView()) { |
2194 | if ( incidence && incidence->type() == "Event" ) { | 2195 | if ( incidence && incidence->type() == "Event" ) { |
2195 | anEvent = static_cast<Event *>(incidence); | 2196 | anEvent = static_cast<Event *>(incidence); |
2196 | } | 2197 | } |
2197 | } | 2198 | } |
2198 | 2199 | ||
2199 | if (!anEvent) { | 2200 | if (!anEvent) { |
2200 | KNotifyClient::beep(); | 2201 | KNotifyClient::beep(); |
2201 | return; | 2202 | return; |
2202 | } | 2203 | } |
2203 | DndFactory factory( mCalendar ); | 2204 | DndFactory factory( mCalendar ); |
2204 | factory.cutIncidence(anEvent); | 2205 | factory.cutIncidence(anEvent); |
2205 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2206 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2206 | } | 2207 | } |
2207 | 2208 | ||
2208 | void CalendarView::edit_copy() | 2209 | void CalendarView::edit_copy() |
2209 | { | 2210 | { |
2210 | Event *anEvent=0; | 2211 | Event *anEvent=0; |
2211 | 2212 | ||
2212 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2213 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2213 | 2214 | ||
2214 | if (mViewManager->currentView()->isEventView()) { | 2215 | if (mViewManager->currentView()->isEventView()) { |
2215 | if ( incidence && incidence->type() == "Event" ) { | 2216 | if ( incidence && incidence->type() == "Event" ) { |
2216 | anEvent = static_cast<Event *>(incidence); | 2217 | anEvent = static_cast<Event *>(incidence); |
2217 | } | 2218 | } |
2218 | } | 2219 | } |
2219 | 2220 | ||
2220 | if (!anEvent) { | 2221 | if (!anEvent) { |
2221 | KNotifyClient::beep(); | 2222 | KNotifyClient::beep(); |
2222 | return; | 2223 | return; |
2223 | } | 2224 | } |
2224 | DndFactory factory( mCalendar ); | 2225 | DndFactory factory( mCalendar ); |
2225 | factory.copyIncidence(anEvent); | 2226 | factory.copyIncidence(anEvent); |
2226 | } | 2227 | } |
2227 | 2228 | ||
2228 | void CalendarView::edit_paste() | 2229 | void CalendarView::edit_paste() |
2229 | { | 2230 | { |
2230 | QDate date = mNavigator->selectedDates().first(); | 2231 | QDate date = mNavigator->selectedDates().first(); |
2231 | 2232 | ||
2232 | DndFactory factory( mCalendar ); | 2233 | DndFactory factory( mCalendar ); |
2233 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2234 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2234 | 2235 | ||
2235 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2236 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2236 | } | 2237 | } |
2237 | 2238 | ||
2238 | void CalendarView::edit_options() | 2239 | void CalendarView::edit_options() |
2239 | { | 2240 | { |
2240 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2241 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2241 | emit save(); | 2242 | emit save(); |
2242 | emit saveStopTimer(); | 2243 | emit saveStopTimer(); |
2243 | mDialogManager->showOptionsDialog(); | 2244 | mDialogManager->showOptionsDialog(); |
2244 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2245 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2245 | emit saveStopTimer(); | 2246 | emit saveStopTimer(); |
2246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2247 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2247 | i18n("Timezone settings"),i18n("Reload"))) { | 2248 | i18n("Timezone settings"),i18n("Reload"))) { |
2248 | qDebug("KO: TZ reload cancelled "); | 2249 | qDebug("KO: TZ reload cancelled "); |
2249 | return; | 2250 | return; |
2250 | } | 2251 | } |
2251 | qDebug("KO: Timezone change "); | 2252 | qDebug("KO: Timezone change "); |
2252 | openCalendar( MainWindow::defaultFileName() ); | 2253 | openCalendar( MainWindow::defaultFileName() ); |
2253 | setModified(true); | 2254 | setModified(true); |
2254 | } | 2255 | } |
2255 | else | 2256 | else |
2256 | qDebug("KO: No tz change "); | 2257 | qDebug("KO: No tz change "); |
2257 | 2258 | ||
2258 | } | 2259 | } |
2259 | 2260 | ||
2260 | 2261 | ||
2261 | void CalendarView::slotSelectPickerDate( QDate d) | 2262 | void CalendarView::slotSelectPickerDate( QDate d) |
2262 | { | 2263 | { |
2263 | mDateFrame->hide(); | 2264 | mDateFrame->hide(); |
2264 | if ( mDatePickerMode == 1 ) { | 2265 | if ( mDatePickerMode == 1 ) { |
2265 | mNavigator->slotDaySelect( d ); | 2266 | mNavigator->slotDaySelect( d ); |
2266 | } else if ( mDatePickerMode == 2 ) { | 2267 | } else if ( mDatePickerMode == 2 ) { |
2267 | if ( mMoveIncidence->type() == "Todo" ) { | 2268 | if ( mMoveIncidence->type() == "Todo" ) { |
2268 | Todo * to = (Todo *) mMoveIncidence; | 2269 | Todo * to = (Todo *) mMoveIncidence; |
2269 | QTime tim; | 2270 | QTime tim; |
2270 | int len = 0; | 2271 | int len = 0; |
2271 | if ( to->hasStartDate() && to->hasDueDate() ) | 2272 | if ( to->hasStartDate() && to->hasDueDate() ) |
2272 | len = to->dtStart().secsTo( to->dtDue()); | 2273 | len = to->dtStart().secsTo( to->dtDue()); |
2273 | if ( to->hasDueDate() ) | 2274 | if ( to->hasDueDate() ) |
2274 | tim = to->dtDue().time(); | 2275 | tim = to->dtDue().time(); |
2275 | else { | 2276 | else { |
2276 | tim = QTime ( 0,0,0 ); | 2277 | tim = QTime ( 0,0,0 ); |
2277 | to->setFloats( true ); | 2278 | to->setFloats( true ); |
2278 | to->setHasDueDate( true ); | 2279 | to->setHasDueDate( true ); |
2279 | } | 2280 | } |
2280 | QDateTime dt ( d,tim ); | 2281 | QDateTime dt ( d,tim ); |
2281 | to->setDtDue( dt ); | 2282 | to->setDtDue( dt ); |
2282 | 2283 | ||
2283 | if ( to->hasStartDate() ) { | 2284 | if ( to->hasStartDate() ) { |
2284 | if ( len>0 ) | 2285 | if ( len>0 ) |
2285 | to->setDtStart(to->dtDue().addSecs( -len )); | 2286 | to->setDtStart(to->dtDue().addSecs( -len )); |
2286 | else | 2287 | else |
2287 | if (to->dtStart() > to->dtDue() ) | 2288 | if (to->dtStart() > to->dtDue() ) |
2288 | to->setDtStart(to->dtDue().addDays( -3 )); | 2289 | to->setDtStart(to->dtDue().addDays( -3 )); |
2289 | } | 2290 | } |
2290 | 2291 | ||
2291 | todoChanged( to ); | 2292 | todoChanged( to ); |
2292 | } else { | 2293 | } else { |
2293 | if ( mMoveIncidence->doesRecur() ) { | 2294 | if ( mMoveIncidence->doesRecur() ) { |
2294 | #if 0 | 2295 | #if 0 |
2295 | // PENDING implement this | 2296 | // PENDING implement this |
2296 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2297 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2297 | mCalendar()->addIncidence( newInc ); | 2298 | mCalendar()->addIncidence( newInc ); |
2298 | if ( mMoveIncidence->type() == "Todo" ) | 2299 | if ( mMoveIncidence->type() == "Todo" ) |
2299 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2300 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2300 | else | 2301 | else |
2301 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2302 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2302 | mMoveIncidence = newInc; | 2303 | mMoveIncidence = newInc; |
2303 | 2304 | ||
2304 | #endif | 2305 | #endif |
2305 | } | 2306 | } |
2306 | QTime tim = mMoveIncidence->dtStart().time(); | 2307 | QTime tim = mMoveIncidence->dtStart().time(); |
2307 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2308 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2308 | QDateTime dt ( d,tim ); | 2309 | QDateTime dt ( d,tim ); |
2309 | mMoveIncidence->setDtStart( dt ); | 2310 | mMoveIncidence->setDtStart( dt ); |
2310 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2311 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2311 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2312 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2312 | } | 2313 | } |
2313 | 2314 | ||
2314 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2315 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2315 | } | 2316 | } |
2316 | } | 2317 | } |
2317 | 2318 | ||
2318 | void CalendarView::removeCategories() | 2319 | void CalendarView::removeCategories() |
2319 | { | 2320 | { |
2320 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2321 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2321 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2322 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2322 | QStringList catIncList; | 2323 | QStringList catIncList; |
2323 | QStringList newCatList; | 2324 | QStringList newCatList; |
2324 | Incidence* inc = incList.first(); | 2325 | Incidence* inc = incList.first(); |
2325 | int i; | 2326 | int i; |
2326 | int count = 0; | 2327 | int count = 0; |
2327 | while ( inc ) { | 2328 | while ( inc ) { |
2328 | newCatList.clear(); | 2329 | newCatList.clear(); |
2329 | catIncList = inc->categories() ; | 2330 | catIncList = inc->categories() ; |
2330 | for( i = 0; i< catIncList.count(); ++i ) { | 2331 | for( i = 0; i< catIncList.count(); ++i ) { |
2331 | if ( catList.contains (catIncList[i])) | 2332 | if ( catList.contains (catIncList[i])) |
2332 | newCatList.append( catIncList[i] ); | 2333 | newCatList.append( catIncList[i] ); |
2333 | } | 2334 | } |
2334 | newCatList.sort(); | 2335 | newCatList.sort(); |
2335 | inc->setCategories( newCatList.join(",") ); | 2336 | inc->setCategories( newCatList.join(",") ); |
2336 | inc = incList.next(); | 2337 | inc = incList.next(); |
2337 | } | 2338 | } |
2338 | } | 2339 | } |
2339 | 2340 | ||
2340 | int CalendarView::addCategories() | 2341 | int CalendarView::addCategories() |
2341 | { | 2342 | { |
2342 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2343 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2343 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2344 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2344 | QStringList catIncList; | 2345 | QStringList catIncList; |
2345 | Incidence* inc = incList.first(); | 2346 | Incidence* inc = incList.first(); |
2346 | int i; | 2347 | int i; |
2347 | int count = 0; | 2348 | int count = 0; |
2348 | while ( inc ) { | 2349 | while ( inc ) { |
2349 | catIncList = inc->categories() ; | 2350 | catIncList = inc->categories() ; |
2350 | for( i = 0; i< catIncList.count(); ++i ) { | 2351 | for( i = 0; i< catIncList.count(); ++i ) { |
2351 | if ( !catList.contains (catIncList[i])) { | 2352 | if ( !catList.contains (catIncList[i])) { |
2352 | catList.append( catIncList[i] ); | 2353 | catList.append( catIncList[i] ); |
2353 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2354 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2354 | ++count; | 2355 | ++count; |
2355 | } | 2356 | } |
2356 | } | 2357 | } |
2357 | inc = incList.next(); | 2358 | inc = incList.next(); |
2358 | } | 2359 | } |
2359 | catList.sort(); | 2360 | catList.sort(); |
2360 | KOPrefs::instance()->mCustomCategories = catList; | 2361 | KOPrefs::instance()->mCustomCategories = catList; |
2361 | return count; | 2362 | return count; |
2362 | } | 2363 | } |
2363 | 2364 | ||
2364 | void CalendarView::manageCategories() | 2365 | void CalendarView::manageCategories() |
2365 | { | 2366 | { |
2366 | KOCatPrefs* cp = new KOCatPrefs(); | 2367 | KOCatPrefs* cp = new KOCatPrefs(); |
2367 | cp->show(); | 2368 | cp->show(); |
2368 | int w =cp->sizeHint().width() ; | 2369 | int w =cp->sizeHint().width() ; |
2369 | int h = cp->sizeHint().height() ; | 2370 | int h = cp->sizeHint().height() ; |
2370 | int dw = QApplication::desktop()->width(); | 2371 | int dw = QApplication::desktop()->width(); |
2371 | int dh = QApplication::desktop()->height(); | 2372 | int dh = QApplication::desktop()->height(); |
2372 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2373 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2373 | if ( !cp->exec() ) { | 2374 | if ( !cp->exec() ) { |
2374 | delete cp; | 2375 | delete cp; |
2375 | return; | 2376 | return; |
2376 | } | 2377 | } |
2377 | int count = 0; | 2378 | int count = 0; |
2378 | if ( cp->addCat() ) { | 2379 | if ( cp->addCat() ) { |
2379 | count = addCategories(); | 2380 | count = addCategories(); |
2380 | if ( count ) { | 2381 | if ( count ) { |
2381 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2382 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2382 | writeSettings(); | 2383 | writeSettings(); |
2383 | } else | 2384 | } else |
2384 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2385 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2385 | } else { | 2386 | } else { |
2386 | removeCategories(); | 2387 | removeCategories(); |
2387 | updateView(); | 2388 | updateView(); |
2388 | } | 2389 | } |
2389 | delete cp; | 2390 | delete cp; |
2390 | } | 2391 | } |
2391 | 2392 | ||
2392 | void CalendarView::beamIncidence(Incidence * Inc) | 2393 | void CalendarView::beamIncidence(Incidence * Inc) |
2393 | { | 2394 | { |
2394 | QPtrList<Incidence> delSel ; | 2395 | QPtrList<Incidence> delSel ; |
2395 | delSel.append(Inc); | 2396 | delSel.append(Inc); |
2396 | beamIncidenceList( delSel ); | 2397 | beamIncidenceList( delSel ); |
2397 | } | 2398 | } |
2398 | void CalendarView::beamCalendar() | 2399 | void CalendarView::beamCalendar() |
2399 | { | 2400 | { |
2400 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2401 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2401 | //qDebug("beamCalendar() "); | 2402 | //qDebug("beamCalendar() "); |
2402 | beamIncidenceList( delSel ); | 2403 | beamIncidenceList( delSel ); |
2403 | } | 2404 | } |
2404 | void CalendarView::beamFilteredCalendar() | 2405 | void CalendarView::beamFilteredCalendar() |
2405 | { | 2406 | { |
2406 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2407 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2407 | //qDebug("beamFilteredCalendar() "); | 2408 | //qDebug("beamFilteredCalendar() "); |
2408 | beamIncidenceList( delSel ); | 2409 | beamIncidenceList( delSel ); |
2409 | } | 2410 | } |
2410 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2411 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2411 | { | 2412 | { |
2412 | if ( beamDialog->exec () == QDialog::Rejected ) | 2413 | if ( beamDialog->exec () == QDialog::Rejected ) |
2413 | return; | 2414 | return; |
2414 | #ifdef DESKTOP_VERSION | 2415 | #ifdef DESKTOP_VERSION |
2415 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2416 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2416 | #else | 2417 | #else |
2417 | QString fn = "/tmp/kopibeamfile"; | 2418 | QString fn = "/tmp/kopibeamfile"; |
2418 | #endif | 2419 | #endif |
2419 | QString mes; | 2420 | QString mes; |
2420 | bool createbup = true; | 2421 | bool createbup = true; |
2421 | if ( createbup ) { | 2422 | if ( createbup ) { |
2422 | QString description = "\n"; | 2423 | QString description = "\n"; |
2423 | CalendarLocal* cal = new CalendarLocal(); | 2424 | CalendarLocal* cal = new CalendarLocal(); |
2424 | if ( beamDialog->beamLocal() ) | 2425 | if ( beamDialog->beamLocal() ) |
2425 | cal->setLocalTime(); | 2426 | cal->setLocalTime(); |
2426 | else | 2427 | else |
2427 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2428 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2428 | Incidence *incidence = delSel.first(); | 2429 | Incidence *incidence = delSel.first(); |
2429 | bool addText = false; | 2430 | bool addText = false; |
2430 | if ( delSel.count() < 10 ) | 2431 | if ( delSel.count() < 10 ) |
2431 | addText = true; | 2432 | addText = true; |
2432 | else { | 2433 | else { |
2433 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2434 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2434 | } | 2435 | } |
2435 | while ( incidence ) { | 2436 | while ( incidence ) { |
2436 | Incidence *in = incidence->clone(); | 2437 | Incidence *in = incidence->clone(); |
2437 | if ( ! in->summary().isEmpty() ) { | 2438 | if ( ! in->summary().isEmpty() ) { |
2438 | in->setDescription(""); | 2439 | in->setDescription(""); |
2439 | } else { | 2440 | } else { |
2440 | in->setSummary( in->description().left(20)); | 2441 | in->setSummary( in->description().left(20)); |
2441 | in->setDescription(""); | 2442 | in->setDescription(""); |
2442 | } | 2443 | } |
2443 | if ( addText ) | 2444 | if ( addText ) |
2444 | description += in->summary() + "\n"; | 2445 | description += in->summary() + "\n"; |
2445 | cal->addIncidence( in ); | 2446 | cal->addIncidence( in ); |
2446 | incidence = delSel.next(); | 2447 | incidence = delSel.next(); |
2447 | } | 2448 | } |
2448 | if ( beamDialog->beamVcal() ) { | 2449 | if ( beamDialog->beamVcal() ) { |
2449 | fn += ".vcs"; | 2450 | fn += ".vcs"; |
2450 | FileStorage storage( cal, fn, new VCalFormat ); | 2451 | FileStorage storage( cal, fn, new VCalFormat ); |
2451 | storage.save(); | 2452 | storage.save(); |
2452 | } else { | 2453 | } else { |
2453 | fn += ".ics"; | 2454 | fn += ".ics"; |
2454 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2455 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2455 | storage.save(); | 2456 | storage.save(); |
2456 | } | 2457 | } |
2457 | delete cal; | 2458 | delete cal; |
2458 | mes = i18n("KO/Pi: Ready for beaming"); | 2459 | mes = i18n("KO/Pi: Ready for beaming"); |
2459 | topLevelWidget()->setCaption(mes); | 2460 | topLevelWidget()->setCaption(mes); |
2460 | KApplication::convert2latin1( fn ); | 2461 | KApplication::convert2latin1( fn ); |
2461 | #ifndef DESKTOP_VERSION | 2462 | #ifndef DESKTOP_VERSION |
2462 | Ir *ir = new Ir( this ); | 2463 | Ir *ir = new Ir( this ); |
2463 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2464 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2464 | ir->send( fn, description, "text/x-vCalendar" ); | 2465 | ir->send( fn, description, "text/x-vCalendar" ); |
2465 | #endif | 2466 | #endif |
2466 | } | 2467 | } |
2467 | } | 2468 | } |
2468 | void CalendarView::beamDone( Ir *ir ) | 2469 | void CalendarView::beamDone( Ir *ir ) |
2469 | { | 2470 | { |
2470 | #ifndef DESKTOP_VERSION | 2471 | #ifndef DESKTOP_VERSION |
2471 | delete ir; | 2472 | delete ir; |
2472 | #endif | 2473 | #endif |
2473 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2474 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2474 | topLevelWidget()->raise(); | 2475 | topLevelWidget()->raise(); |
2475 | } | 2476 | } |
2476 | 2477 | ||
2477 | void CalendarView::moveIncidence(Incidence * inc ) | 2478 | void CalendarView::moveIncidence(Incidence * inc ) |
2478 | { | 2479 | { |
2479 | if ( !inc ) return; | 2480 | if ( !inc ) return; |
2480 | showDatePickerPopup(); | 2481 | showDatePickerPopup(); |
2481 | mDatePickerMode = 2; | 2482 | mDatePickerMode = 2; |
2482 | mMoveIncidence = inc ; | 2483 | mMoveIncidence = inc ; |
2483 | QDate da; | 2484 | QDate da; |
2484 | if ( mMoveIncidence->type() == "Todo" ) { | 2485 | if ( mMoveIncidence->type() == "Todo" ) { |
2485 | Todo * to = (Todo *) mMoveIncidence; | 2486 | Todo * to = (Todo *) mMoveIncidence; |
2486 | if ( to->hasDueDate() ) | 2487 | if ( to->hasDueDate() ) |
2487 | da = to->dtDue().date(); | 2488 | da = to->dtDue().date(); |
2488 | else | 2489 | else |
2489 | da = QDate::currentDate(); | 2490 | da = QDate::currentDate(); |
2490 | } else { | 2491 | } else { |
2491 | da = mMoveIncidence->dtStart().date(); | 2492 | da = mMoveIncidence->dtStart().date(); |
2492 | } | 2493 | } |
2493 | //PENDING set date for recurring incidence to date of recurrence | 2494 | //PENDING set date for recurring incidence to date of recurrence |
2494 | //mMoveIncidenceOldDate; | 2495 | //mMoveIncidenceOldDate; |
2495 | mDatePicker->setDate( da ); | 2496 | mDatePicker->setDate( da ); |
2496 | } | 2497 | } |
2497 | void CalendarView::showDatePickerPopup() | 2498 | void CalendarView::showDatePickerPopup() |
2498 | { | 2499 | { |
2499 | if ( mDateFrame->isVisible() ) | 2500 | if ( mDateFrame->isVisible() ) |
2500 | mDateFrame->hide(); | 2501 | mDateFrame->hide(); |
2501 | else { | 2502 | else { |
2502 | int offX = 0, offY = 0; | 2503 | int offX = 0, offY = 0; |
2503 | #ifdef DESKTOP_VERSION | 2504 | #ifdef DESKTOP_VERSION |
2504 | int w =mDatePicker->sizeHint().width() ; | 2505 | int w =mDatePicker->sizeHint().width() ; |
2505 | int h = mDatePicker->sizeHint().height() ; | 2506 | int h = mDatePicker->sizeHint().height() ; |
2506 | int dw = topLevelWidget()->width(); | 2507 | int dw = topLevelWidget()->width(); |
2507 | int dh = topLevelWidget()->height(); | 2508 | int dh = topLevelWidget()->height(); |
2508 | offX = topLevelWidget()->x(); | 2509 | offX = topLevelWidget()->x(); |
2509 | offY = topLevelWidget()->y(); | 2510 | offY = topLevelWidget()->y(); |
2510 | #else | 2511 | #else |
2511 | int w =mDatePicker->sizeHint().width() ; | 2512 | int w =mDatePicker->sizeHint().width() ; |
2512 | int h = mDatePicker->sizeHint().height() ; | 2513 | int h = mDatePicker->sizeHint().height() ; |
2513 | int dw = QApplication::desktop()->width(); | 2514 | int dw = QApplication::desktop()->width(); |
2514 | int dh = QApplication::desktop()->height(); | 2515 | int dh = QApplication::desktop()->height(); |
2515 | #endif | 2516 | #endif |
2516 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2517 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2517 | mDateFrame->show(); | 2518 | mDateFrame->show(); |
2518 | } | 2519 | } |
2519 | } | 2520 | } |
2520 | void CalendarView::showDatePicker( ) | 2521 | void CalendarView::showDatePicker( ) |
2521 | { | 2522 | { |
2522 | showDatePickerPopup(); | 2523 | showDatePickerPopup(); |
2523 | mDatePickerMode = 1; | 2524 | mDatePickerMode = 1; |
2524 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2525 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2525 | } | 2526 | } |
2526 | 2527 | ||
2527 | void CalendarView::showEventEditor() | 2528 | void CalendarView::showEventEditor() |
2528 | { | 2529 | { |
2529 | #ifdef DESKTOP_VERSION | 2530 | #ifdef DESKTOP_VERSION |
2531 | int x,y,w,h; | ||
2532 | x = mEventEditor->geometry().x(); | ||
2533 | y = mEventEditor->geometry().y(); | ||
2534 | w = mEventEditor->width(); | ||
2535 | h = mEventEditor->height(); | ||
2530 | mEventEditor->show(); | 2536 | mEventEditor->show(); |
2537 | mEventEditor->setGeometry(x,y,w,h); | ||
2531 | #else | 2538 | #else |
2532 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2539 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2533 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2540 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2534 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2541 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2535 | qApp->processEvents(); | 2542 | qApp->processEvents(); |
2536 | delete mEventEditor; | 2543 | delete mEventEditor; |
2537 | mEventEditor = mDialogManager->getEventEditor(); | 2544 | mEventEditor = mDialogManager->getEventEditor(); |
2538 | topLevelWidget()->setCaption( i18n("") ); | 2545 | topLevelWidget()->setCaption( i18n("") ); |
2539 | } | 2546 | } |
2540 | mEventEditor->showMaximized(); | 2547 | mEventEditor->showMaximized(); |
2541 | #endif | 2548 | #endif |
2542 | } | 2549 | } |
2543 | void CalendarView::showTodoEditor() | 2550 | void CalendarView::showTodoEditor() |
2544 | { | 2551 | { |
2545 | #ifdef DESKTOP_VERSION | 2552 | #ifdef DESKTOP_VERSION |
2553 | int x,y,w,h; | ||
2554 | x = mTodoEditor->geometry().x(); | ||
2555 | y = mTodoEditor->geometry().y(); | ||
2556 | w = mTodoEditor->width(); | ||
2557 | h = mTodoEditor->height(); | ||
2546 | mTodoEditor->show(); | 2558 | mTodoEditor->show(); |
2559 | mTodoEditor->setGeometry(x,y,w,h); | ||
2547 | #else | 2560 | #else |
2548 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2561 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2549 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2562 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2550 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2563 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2551 | qApp->processEvents(); | 2564 | qApp->processEvents(); |
2552 | delete mTodoEditor; | 2565 | delete mTodoEditor; |
2553 | mTodoEditor = mDialogManager->getTodoEditor(); | 2566 | mTodoEditor = mDialogManager->getTodoEditor(); |
2554 | topLevelWidget()->setCaption( i18n("") ); | 2567 | topLevelWidget()->setCaption( i18n("") ); |
2555 | } | 2568 | } |
2556 | mTodoEditor->showMaximized(); | 2569 | mTodoEditor->showMaximized(); |
2557 | #endif | 2570 | #endif |
2558 | } | 2571 | } |
2559 | 2572 | ||
2560 | void CalendarView::cloneIncidence() | 2573 | void CalendarView::cloneIncidence() |
2561 | { | 2574 | { |
2562 | Incidence *incidence = currentSelection(); | 2575 | Incidence *incidence = currentSelection(); |
2563 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2576 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2564 | if ( incidence ) { | 2577 | if ( incidence ) { |
2565 | cloneIncidence(incidence); | 2578 | cloneIncidence(incidence); |
2566 | } | 2579 | } |
2567 | } | 2580 | } |
2568 | void CalendarView::moveIncidence() | 2581 | void CalendarView::moveIncidence() |
2569 | { | 2582 | { |
2570 | Incidence *incidence = currentSelection(); | 2583 | Incidence *incidence = currentSelection(); |
2571 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2584 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2572 | if ( incidence ) { | 2585 | if ( incidence ) { |
2573 | moveIncidence(incidence); | 2586 | moveIncidence(incidence); |
2574 | } | 2587 | } |
2575 | } | 2588 | } |
2576 | void CalendarView::beamIncidence() | 2589 | void CalendarView::beamIncidence() |
2577 | { | 2590 | { |
2578 | Incidence *incidence = currentSelection(); | 2591 | Incidence *incidence = currentSelection(); |
2579 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2592 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2580 | if ( incidence ) { | 2593 | if ( incidence ) { |
2581 | beamIncidence(incidence); | 2594 | beamIncidence(incidence); |
2582 | } | 2595 | } |
2583 | } | 2596 | } |
2584 | void CalendarView::toggleCancelIncidence() | 2597 | void CalendarView::toggleCancelIncidence() |
2585 | { | 2598 | { |
2586 | Incidence *incidence = currentSelection(); | 2599 | Incidence *incidence = currentSelection(); |
2587 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2600 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2588 | if ( incidence ) { | 2601 | if ( incidence ) { |
2589 | cancelIncidence(incidence); | 2602 | cancelIncidence(incidence); |
2590 | } | 2603 | } |
2591 | } | 2604 | } |
2592 | 2605 | ||
2593 | 2606 | ||
2594 | void CalendarView::cancelIncidence(Incidence * inc ) | 2607 | void CalendarView::cancelIncidence(Incidence * inc ) |
2595 | { | 2608 | { |
2596 | inc->setCancelled( ! inc->cancelled() ); | 2609 | inc->setCancelled( ! inc->cancelled() ); |
2597 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2610 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2598 | updateView(); | 2611 | updateView(); |
2599 | } | 2612 | } |
2600 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2613 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2601 | { | 2614 | { |
2602 | Incidence * newInc = orgInc->clone(); | 2615 | Incidence * newInc = orgInc->clone(); |
2603 | newInc->recreate(); | 2616 | newInc->recreate(); |
2604 | 2617 | ||
2605 | if ( newInc->type() == "Todo" ) { | 2618 | if ( newInc->type() == "Todo" ) { |
2606 | Todo* t = (Todo*) newInc; | 2619 | Todo* t = (Todo*) newInc; |
2607 | showTodoEditor(); | 2620 | showTodoEditor(); |
2608 | mTodoEditor->editTodo( t ); | 2621 | mTodoEditor->editTodo( t ); |
2609 | if ( mTodoEditor->exec() ) { | 2622 | if ( mTodoEditor->exec() ) { |
2610 | mCalendar->addTodo( t ); | 2623 | mCalendar->addTodo( t ); |
2611 | updateView(); | 2624 | updateView(); |
2612 | } else { | 2625 | } else { |
2613 | delete t; | 2626 | delete t; |
2614 | } | 2627 | } |
2615 | } | 2628 | } |
2616 | else { | 2629 | else { |
2617 | Event* e = (Event*) newInc; | 2630 | Event* e = (Event*) newInc; |
2618 | showEventEditor(); | 2631 | showEventEditor(); |
2619 | mEventEditor->editEvent( e ); | 2632 | mEventEditor->editEvent( e ); |
2620 | if ( mEventEditor->exec() ) { | 2633 | if ( mEventEditor->exec() ) { |
2621 | mCalendar->addEvent( e ); | 2634 | mCalendar->addEvent( e ); |
2622 | updateView(); | 2635 | updateView(); |
2623 | } else { | 2636 | } else { |
2624 | delete e; | 2637 | delete e; |
2625 | } | 2638 | } |
2626 | } | 2639 | } |
2627 | setActiveWindow(); | 2640 | setActiveWindow(); |
2628 | } | 2641 | } |
2629 | 2642 | ||
2630 | void CalendarView::newEvent() | 2643 | void CalendarView::newEvent() |
2631 | { | 2644 | { |
2632 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2645 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2633 | KOAgendaView *aView = mViewManager->agendaView(); | 2646 | KOAgendaView *aView = mViewManager->agendaView(); |
2634 | if (aView) { | 2647 | if (aView) { |
2635 | if (aView->selectionStart().isValid()) { | 2648 | if (aView->selectionStart().isValid()) { |
2636 | if (aView->selectedIsAllDay()) { | 2649 | if (aView->selectedIsAllDay()) { |
2637 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2650 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2638 | } else { | 2651 | } else { |
2639 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2652 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2640 | } | 2653 | } |
2641 | return; | 2654 | return; |
2642 | } | 2655 | } |
2643 | } | 2656 | } |
2644 | 2657 | ||
2645 | QDate date = mNavigator->selectedDates().first(); | 2658 | QDate date = mNavigator->selectedDates().first(); |
2646 | QDateTime current = QDateTime::currentDateTime(); | 2659 | QDateTime current = QDateTime::currentDateTime(); |
2647 | if ( date <= current.date() ) { | 2660 | if ( date <= current.date() ) { |
2648 | int hour = current.time().hour() +1; | 2661 | int hour = current.time().hour() +1; |
2649 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2662 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2650 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2663 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2651 | } else | 2664 | } else |
2652 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2665 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2653 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2666 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2654 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2667 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2655 | } | 2668 | } |
2656 | 2669 | ||
2657 | void CalendarView::newEvent(QDateTime fh) | 2670 | void CalendarView::newEvent(QDateTime fh) |
2658 | { | 2671 | { |
2659 | newEvent(fh, | 2672 | newEvent(fh, |
2660 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2673 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2661 | } | 2674 | } |
2662 | 2675 | ||
2663 | void CalendarView::newEvent(QDate dt) | 2676 | void CalendarView::newEvent(QDate dt) |
2664 | { | 2677 | { |
2665 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2678 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2666 | QDateTime(dt, QTime(0,0,0)), true); | 2679 | QDateTime(dt, QTime(0,0,0)), true); |
2667 | } | 2680 | } |
2668 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2681 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2669 | { | 2682 | { |
2670 | newEvent(fromHint, toHint, false); | 2683 | newEvent(fromHint, toHint, false); |
2671 | } | 2684 | } |
2672 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2685 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2673 | { | 2686 | { |
2674 | 2687 | ||
2675 | showEventEditor(); | 2688 | showEventEditor(); |
2676 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2689 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2677 | if ( mFilterView->filtersEnabled() ) { | 2690 | if ( mFilterView->filtersEnabled() ) { |
2678 | CalFilter *filter = mFilterView->selectedFilter(); | 2691 | CalFilter *filter = mFilterView->selectedFilter(); |
2679 | if (filter && filter->showCategories()) { | 2692 | if (filter && filter->showCategories()) { |
2680 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2693 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2681 | } | 2694 | } |
2682 | if ( filter ) | 2695 | if ( filter ) |
2683 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2696 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2684 | } | 2697 | } |
2685 | mEventEditor->exec(); | 2698 | mEventEditor->exec(); |
2686 | setActiveWindow(); | 2699 | setActiveWindow(); |
2687 | } | 2700 | } |
2688 | void CalendarView::todoAdded(Todo * t) | 2701 | void CalendarView::todoAdded(Todo * t) |
2689 | { | 2702 | { |
2690 | 2703 | ||
2691 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2704 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2692 | updateTodoViews(); | 2705 | updateTodoViews(); |
2693 | } | 2706 | } |
2694 | void CalendarView::todoChanged(Todo * t) | 2707 | void CalendarView::todoChanged(Todo * t) |
2695 | { | 2708 | { |
2696 | emit todoModified( t, 4 ); | 2709 | emit todoModified( t, 4 ); |
2697 | // updateTodoViews(); | 2710 | // updateTodoViews(); |
2698 | } | 2711 | } |
2699 | void CalendarView::todoToBeDeleted(Todo *) | 2712 | void CalendarView::todoToBeDeleted(Todo *) |
2700 | { | 2713 | { |
2701 | //qDebug("todoToBeDeleted(Todo *) "); | 2714 | //qDebug("todoToBeDeleted(Todo *) "); |
2702 | updateTodoViews(); | 2715 | updateTodoViews(); |
2703 | } | 2716 | } |
2704 | void CalendarView::todoDeleted() | 2717 | void CalendarView::todoDeleted() |
2705 | { | 2718 | { |
2706 | //qDebug(" todoDeleted()"); | 2719 | //qDebug(" todoDeleted()"); |
2707 | updateTodoViews(); | 2720 | updateTodoViews(); |
2708 | } | 2721 | } |
2709 | 2722 | ||
2710 | 2723 | ||
2711 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2724 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2712 | { | 2725 | { |
2713 | showTodoEditor(); | 2726 | showTodoEditor(); |
2714 | mTodoEditor->newTodo(dt,0,allday); | 2727 | mTodoEditor->newTodo(dt,0,allday); |
2715 | if ( mFilterView->filtersEnabled() ) { | 2728 | if ( mFilterView->filtersEnabled() ) { |
2716 | CalFilter *filter = mFilterView->selectedFilter(); | 2729 | CalFilter *filter = mFilterView->selectedFilter(); |
2717 | if (filter && filter->showCategories()) { | 2730 | if (filter && filter->showCategories()) { |
2718 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2731 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2719 | } | 2732 | } |
2720 | if ( filter ) | 2733 | if ( filter ) |
2721 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2734 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2722 | } | 2735 | } |
2723 | mTodoEditor->exec(); | 2736 | mTodoEditor->exec(); |
2724 | setActiveWindow(); | 2737 | setActiveWindow(); |
2725 | } | 2738 | } |
2726 | 2739 | ||
2727 | void CalendarView::newTodo() | 2740 | void CalendarView::newTodo() |
2728 | { | 2741 | { |
2729 | newTodoDateTime( QDateTime(),true ); | 2742 | newTodoDateTime( QDateTime(),true ); |
2730 | } | 2743 | } |
2731 | 2744 | ||
2732 | void CalendarView::newSubTodo() | 2745 | void CalendarView::newSubTodo() |
2733 | { | 2746 | { |
2734 | Todo *todo = selectedTodo(); | 2747 | Todo *todo = selectedTodo(); |
2735 | if ( todo ) newSubTodo( todo ); | 2748 | if ( todo ) newSubTodo( todo ); |
2736 | } | 2749 | } |
2737 | 2750 | ||
2738 | void CalendarView::newSubTodo(Todo *parentEvent) | 2751 | void CalendarView::newSubTodo(Todo *parentEvent) |
2739 | { | 2752 | { |
2740 | 2753 | ||
2741 | showTodoEditor(); | 2754 | showTodoEditor(); |
2742 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2755 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2743 | mTodoEditor->exec(); | 2756 | mTodoEditor->exec(); |
2744 | setActiveWindow(); | 2757 | setActiveWindow(); |
2745 | } | 2758 | } |
2746 | 2759 | ||
2747 | void CalendarView::newFloatingEvent() | 2760 | void CalendarView::newFloatingEvent() |
2748 | { | 2761 | { |
2749 | DateList tmpList = mNavigator->selectedDates(); | 2762 | DateList tmpList = mNavigator->selectedDates(); |
2750 | QDate date = tmpList.first(); | 2763 | QDate date = tmpList.first(); |
2751 | 2764 | ||
2752 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2765 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2753 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2766 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2754 | } | 2767 | } |
2755 | 2768 | ||
2756 | 2769 | ||
2757 | void CalendarView::editEvent( Event *event ) | 2770 | void CalendarView::editEvent( Event *event ) |
2758 | { | 2771 | { |
2759 | 2772 | ||
2760 | if ( !event ) return; | 2773 | if ( !event ) return; |
2761 | if ( event->isReadOnly() ) { | 2774 | if ( event->isReadOnly() ) { |
2762 | showEvent( event ); | 2775 | showEvent( event ); |
2763 | return; | 2776 | return; |
2764 | } | 2777 | } |
2765 | showEventEditor(); | 2778 | showEventEditor(); |
2766 | mEventEditor->editEvent( event , mFlagEditDescription); | 2779 | mEventEditor->editEvent( event , mFlagEditDescription); |
2767 | mEventEditor->exec(); | 2780 | mEventEditor->exec(); |
2768 | setActiveWindow(); | 2781 | setActiveWindow(); |
2769 | 2782 | ||
2770 | } | 2783 | } |
2771 | void CalendarView::editJournal( Journal *jour ) | 2784 | void CalendarView::editJournal( Journal *jour ) |
2772 | { | 2785 | { |
2773 | if ( !jour ) return; | 2786 | if ( !jour ) return; |
2774 | mDialogManager->hideSearchDialog(); | 2787 | mDialogManager->hideSearchDialog(); |
2775 | mViewManager->showJournalView(); | 2788 | mViewManager->showJournalView(); |
2776 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2789 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2777 | } | 2790 | } |
2778 | void CalendarView::editTodo( Todo *todo ) | 2791 | void CalendarView::editTodo( Todo *todo ) |
2779 | { | 2792 | { |
2780 | if ( !todo ) return; | 2793 | if ( !todo ) return; |
2781 | 2794 | ||
2782 | if ( todo->isReadOnly() ) { | 2795 | if ( todo->isReadOnly() ) { |
2783 | showTodo( todo ); | 2796 | showTodo( todo ); |
2784 | return; | 2797 | return; |
2785 | } | 2798 | } |
2786 | showTodoEditor(); | 2799 | showTodoEditor(); |
2787 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2800 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2788 | mTodoEditor->exec(); | 2801 | mTodoEditor->exec(); |
2789 | setActiveWindow(); | 2802 | setActiveWindow(); |
2790 | 2803 | ||
2791 | } | 2804 | } |
2792 | 2805 | ||
2793 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2806 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2794 | { | 2807 | { |
2795 | if ( !mEventViewerDialog ) { | 2808 | if ( !mEventViewerDialog ) { |
2796 | mEventViewerDialog = new KOEventViewerDialog(this); | 2809 | mEventViewerDialog = new KOEventViewerDialog(0); |
2797 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2810 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2798 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2811 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2799 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2812 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2800 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2813 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2801 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2814 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2802 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2815 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2803 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 2816 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
2804 | this, SLOT( slotViewerClosed() ) ); | 2817 | this, SLOT( slotViewerClosed() ) ); |
2805 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2818 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2806 | this, SLOT( todoChanged(Todo *) ) ); | 2819 | this, SLOT( todoChanged(Todo *) ) ); |
2807 | mEventViewerDialog->resize( 640, 480 ); | 2820 | mEventViewerDialog->resize( 640, 480 ); |
2808 | 2821 | ||
2809 | } | 2822 | } |
2810 | return mEventViewerDialog; | 2823 | return mEventViewerDialog; |
2811 | } | 2824 | } |
2812 | void CalendarView::showEvent(Event *event) | 2825 | void CalendarView::showEvent(Event *event) |
2813 | { | 2826 | { |
2814 | getEventViewerDialog()->setEvent(event); | 2827 | getEventViewerDialog()->setEvent(event); |
2815 | getEventViewerDialog()->showMe(); | 2828 | getEventViewerDialog()->showMe(); |
2816 | } | 2829 | } |
2817 | 2830 | ||
2818 | void CalendarView::showTodo(Todo *event) | 2831 | void CalendarView::showTodo(Todo *event) |
2819 | { | 2832 | { |
2820 | getEventViewerDialog()->setTodo(event); | 2833 | getEventViewerDialog()->setTodo(event); |
2821 | getEventViewerDialog()->showMe(); | 2834 | getEventViewerDialog()->showMe(); |
2822 | } | 2835 | } |
2823 | void CalendarView::showJournal( Journal *jour ) | 2836 | void CalendarView::showJournal( Journal *jour ) |
2824 | { | 2837 | { |
2825 | getEventViewerDialog()->setJournal(jour); | 2838 | getEventViewerDialog()->setJournal(jour); |
2826 | getEventViewerDialog()->showMe(); | 2839 | getEventViewerDialog()->showMe(); |
2827 | 2840 | ||
2828 | } | 2841 | } |
2829 | // void CalendarView::todoModified (Todo *event, int changed) | 2842 | // void CalendarView::todoModified (Todo *event, int changed) |
2830 | // { | 2843 | // { |
2831 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2844 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2832 | // // kdDebug() << "Todo modified and open" << endl; | 2845 | // // kdDebug() << "Todo modified and open" << endl; |
2833 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2846 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2834 | // // temp->modified (changed); | 2847 | // // temp->modified (changed); |
2835 | 2848 | ||
2836 | // // } | 2849 | // // } |
2837 | 2850 | ||
2838 | // mViewManager->updateView(); | 2851 | // mViewManager->updateView(); |
2839 | // } | 2852 | // } |
2840 | 2853 | ||
2841 | void CalendarView::appointment_show() | 2854 | void CalendarView::appointment_show() |
2842 | { | 2855 | { |
2843 | Event *anEvent = 0; | 2856 | Event *anEvent = 0; |
2844 | 2857 | ||
2845 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2858 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2846 | 2859 | ||
2847 | if (mViewManager->currentView()->isEventView()) { | 2860 | if (mViewManager->currentView()->isEventView()) { |
2848 | if ( incidence && incidence->type() == "Event" ) { | 2861 | if ( incidence && incidence->type() == "Event" ) { |
2849 | anEvent = static_cast<Event *>(incidence); | 2862 | anEvent = static_cast<Event *>(incidence); |
2850 | } | 2863 | } |
2851 | } | 2864 | } |
2852 | 2865 | ||
2853 | if (!anEvent) { | 2866 | if (!anEvent) { |
2854 | KNotifyClient::beep(); | 2867 | KNotifyClient::beep(); |
2855 | return; | 2868 | return; |
2856 | } | 2869 | } |
2857 | 2870 | ||
2858 | showEvent(anEvent); | 2871 | showEvent(anEvent); |
2859 | } | 2872 | } |
2860 | 2873 | ||
2861 | void CalendarView::appointment_edit() | 2874 | void CalendarView::appointment_edit() |
2862 | { | 2875 | { |
2863 | Event *anEvent = 0; | 2876 | Event *anEvent = 0; |
2864 | 2877 | ||
2865 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2878 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2866 | 2879 | ||
2867 | if (mViewManager->currentView()->isEventView()) { | 2880 | if (mViewManager->currentView()->isEventView()) { |
2868 | if ( incidence && incidence->type() == "Event" ) { | 2881 | if ( incidence && incidence->type() == "Event" ) { |
2869 | anEvent = static_cast<Event *>(incidence); | 2882 | anEvent = static_cast<Event *>(incidence); |
2870 | } | 2883 | } |
2871 | } | 2884 | } |
2872 | 2885 | ||
2873 | if (!anEvent) { | 2886 | if (!anEvent) { |
2874 | KNotifyClient::beep(); | 2887 | KNotifyClient::beep(); |
2875 | return; | 2888 | return; |
2876 | } | 2889 | } |
2877 | 2890 | ||
2878 | editEvent(anEvent); | 2891 | editEvent(anEvent); |
2879 | } | 2892 | } |
2880 | 2893 | ||
2881 | void CalendarView::appointment_delete() | 2894 | void CalendarView::appointment_delete() |
2882 | { | 2895 | { |
2883 | Event *anEvent = 0; | 2896 | Event *anEvent = 0; |
2884 | 2897 | ||
2885 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2898 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2886 | 2899 | ||
2887 | if (mViewManager->currentView()->isEventView()) { | 2900 | if (mViewManager->currentView()->isEventView()) { |
2888 | if ( incidence && incidence->type() == "Event" ) { | 2901 | if ( incidence && incidence->type() == "Event" ) { |
2889 | anEvent = static_cast<Event *>(incidence); | 2902 | anEvent = static_cast<Event *>(incidence); |
2890 | } | 2903 | } |
2891 | } | 2904 | } |
2892 | 2905 | ||
2893 | if (!anEvent) { | 2906 | if (!anEvent) { |
2894 | KNotifyClient::beep(); | 2907 | KNotifyClient::beep(); |
2895 | return; | 2908 | return; |
2896 | } | 2909 | } |
2897 | 2910 | ||
2898 | deleteEvent(anEvent); | 2911 | deleteEvent(anEvent); |
2899 | } | 2912 | } |
2900 | 2913 | ||
2901 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2914 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2902 | { | 2915 | { |
2903 | if (!sub) return; | 2916 | if (!sub) return; |
2904 | if (!parent) return; | 2917 | if (!parent) return; |
2905 | if ( sub->relatedTo() ) | 2918 | if ( sub->relatedTo() ) |
2906 | sub->relatedTo()->removeRelation(sub); | 2919 | sub->relatedTo()->removeRelation(sub); |
2907 | sub->setRelatedTo(parent); | 2920 | sub->setRelatedTo(parent); |
2908 | sub->setRelatedToUid(parent->uid()); | 2921 | sub->setRelatedToUid(parent->uid()); |
2909 | parent->addRelation(sub); | 2922 | parent->addRelation(sub); |
2910 | sub->updated(); | 2923 | sub->updated(); |
2911 | parent->updated(); | 2924 | parent->updated(); |
2912 | setModified(true); | 2925 | setModified(true); |
2913 | updateView(); | 2926 | updateView(); |
2914 | } | 2927 | } |
2915 | void CalendarView::todo_unsub(Todo *anTodo ) | 2928 | void CalendarView::todo_unsub(Todo *anTodo ) |
2916 | { | 2929 | { |
2917 | // Todo *anTodo = selectedTodo(); | 2930 | // Todo *anTodo = selectedTodo(); |
2918 | if (!anTodo) return; | 2931 | if (!anTodo) return; |
2919 | if (!anTodo->relatedTo()) return; | 2932 | if (!anTodo->relatedTo()) return; |
2920 | anTodo->relatedTo()->removeRelation(anTodo); | 2933 | anTodo->relatedTo()->removeRelation(anTodo); |
2921 | anTodo->setRelatedTo(0); | 2934 | anTodo->setRelatedTo(0); |
2922 | anTodo->updated(); | 2935 | anTodo->updated(); |
2923 | anTodo->setRelatedToUid(""); | 2936 | anTodo->setRelatedToUid(""); |
2924 | setModified(true); | 2937 | setModified(true); |
2925 | updateView(); | 2938 | updateView(); |
2926 | } | 2939 | } |
2927 | 2940 | ||
2928 | void CalendarView::deleteTodo(Todo *todo) | 2941 | void CalendarView::deleteTodo(Todo *todo) |
2929 | { | 2942 | { |
2930 | if (!todo) { | 2943 | if (!todo) { |
2931 | KNotifyClient::beep(); | 2944 | KNotifyClient::beep(); |
2932 | return; | 2945 | return; |
2933 | } | 2946 | } |
2934 | if (KOPrefs::instance()->mConfirm) { | 2947 | if (KOPrefs::instance()->mConfirm) { |
2935 | QString text = todo->summary().left(20); | 2948 | QString text = todo->summary().left(20); |
2936 | if (!todo->relations().isEmpty()) { | 2949 | if (!todo->relations().isEmpty()) { |
2937 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2950 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2938 | 2951 | ||
2939 | } | 2952 | } |
2940 | switch (msgItemDelete(text)) { | 2953 | switch (msgItemDelete(text)) { |
2941 | case KMessageBox::Continue: // OK | 2954 | case KMessageBox::Continue: // OK |
2942 | bool deleteT = false; | 2955 | bool deleteT = false; |
2943 | if (!todo->relations().isEmpty()) { | 2956 | if (!todo->relations().isEmpty()) { |
2944 | deleteT = removeCompletedSubTodos( todo ); | 2957 | deleteT = removeCompletedSubTodos( todo ); |
2945 | } | 2958 | } |
2946 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2959 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2947 | if ( !deleteT ) { | 2960 | if ( !deleteT ) { |
2948 | checkExternalId( todo ); | 2961 | checkExternalId( todo ); |
2949 | calendar()->deleteTodo(todo); | 2962 | calendar()->deleteTodo(todo); |
2950 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2963 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2951 | updateView(); | 2964 | updateView(); |
2952 | } | 2965 | } |
2953 | break; | 2966 | break; |
2954 | } // switch | 2967 | } // switch |
2955 | } else { | 2968 | } else { |
2956 | checkExternalId( todo ); | 2969 | checkExternalId( todo ); |
2957 | mCalendar->deleteTodo(todo); | 2970 | mCalendar->deleteTodo(todo); |
2958 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2971 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2959 | updateView(); | 2972 | updateView(); |
2960 | } | 2973 | } |
2961 | 2974 | ||
2962 | emit updateSearchDialog(); | 2975 | emit updateSearchDialog(); |
2963 | } | 2976 | } |
2964 | void CalendarView::deleteJournal(Journal *jour) | 2977 | void CalendarView::deleteJournal(Journal *jour) |
2965 | { | 2978 | { |
2966 | if (!jour) { | 2979 | if (!jour) { |
2967 | KNotifyClient::beep(); | 2980 | KNotifyClient::beep(); |
2968 | return; | 2981 | return; |
2969 | } | 2982 | } |
2970 | if (KOPrefs::instance()->mConfirm) { | 2983 | if (KOPrefs::instance()->mConfirm) { |
2971 | switch (msgItemDelete( jour->description().left(20))) { | 2984 | switch (msgItemDelete( jour->description().left(20))) { |
2972 | case KMessageBox::Continue: // OK | 2985 | case KMessageBox::Continue: // OK |
2973 | calendar()->deleteJournal(jour); | 2986 | calendar()->deleteJournal(jour); |
2974 | updateView(); | 2987 | updateView(); |
2975 | break; | 2988 | break; |
2976 | } // switch | 2989 | } // switch |
2977 | } else { | 2990 | } else { |
2978 | calendar()->deleteJournal(jour);; | 2991 | calendar()->deleteJournal(jour);; |
2979 | updateView(); | 2992 | updateView(); |
2980 | } | 2993 | } |
2981 | emit updateSearchDialog(); | 2994 | emit updateSearchDialog(); |
2982 | } | 2995 | } |
2983 | 2996 | ||
2984 | void CalendarView::deleteEvent(Event *anEvent) | 2997 | void CalendarView::deleteEvent(Event *anEvent) |
2985 | { | 2998 | { |
2986 | if (!anEvent) { | 2999 | if (!anEvent) { |
2987 | KNotifyClient::beep(); | 3000 | KNotifyClient::beep(); |
2988 | return; | 3001 | return; |
2989 | } | 3002 | } |
2990 | 3003 | ||
2991 | if (anEvent->recurrence()->doesRecur()) { | 3004 | if (anEvent->recurrence()->doesRecur()) { |
2992 | QDate itemDate = mViewManager->currentSelectionDate(); | 3005 | QDate itemDate = mViewManager->currentSelectionDate(); |
2993 | int km; | 3006 | int km; |
2994 | if (!itemDate.isValid()) { | 3007 | if (!itemDate.isValid()) { |
2995 | //kdDebug() << "Date Not Valid" << endl; | 3008 | //kdDebug() << "Date Not Valid" << endl; |
2996 | if (KOPrefs::instance()->mConfirm) { | 3009 | if (KOPrefs::instance()->mConfirm) { |
2997 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3010 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2998 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3011 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2999 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3012 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3000 | if ( km == KMessageBox::Continue ) | 3013 | if ( km == KMessageBox::Continue ) |
3001 | km = KMessageBox::No; // No = all below | 3014 | km = KMessageBox::No; // No = all below |
3002 | } else | 3015 | } else |
3003 | km = KMessageBox::No; | 3016 | km = KMessageBox::No; |
3004 | } else { | 3017 | } else { |
3005 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3018 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3006 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3019 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3007 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3020 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3008 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3021 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3009 | i18n("All")); | 3022 | i18n("All")); |
3010 | } | 3023 | } |
3011 | switch(km) { | 3024 | switch(km) { |
3012 | 3025 | ||
3013 | case KMessageBox::No: // Continue // all | 3026 | case KMessageBox::No: // Continue // all |
3014 | //qDebug("KMessageBox::No "); | 3027 | //qDebug("KMessageBox::No "); |
3015 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3028 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3016 | schedule(Scheduler::Cancel,anEvent); | 3029 | schedule(Scheduler::Cancel,anEvent); |
3017 | 3030 | ||
3018 | checkExternalId( anEvent); | 3031 | checkExternalId( anEvent); |
3019 | mCalendar->deleteEvent(anEvent); | 3032 | mCalendar->deleteEvent(anEvent); |
3020 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3033 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3021 | break; | 3034 | break; |
3022 | 3035 | ||
3023 | // Disabled because it does not work | 3036 | // Disabled because it does not work |
3024 | //#if 0 | 3037 | //#if 0 |
3025 | case KMessageBox::Yes: // just this one | 3038 | case KMessageBox::Yes: // just this one |
3026 | //QDate qd = mNavigator->selectedDates().first(); | 3039 | //QDate qd = mNavigator->selectedDates().first(); |
3027 | //if (!qd.isValid()) { | 3040 | //if (!qd.isValid()) { |
3028 | // kdDebug() << "no date selected, or invalid date" << endl; | 3041 | // kdDebug() << "no date selected, or invalid date" << endl; |
3029 | // KNotifyClient::beep(); | 3042 | // KNotifyClient::beep(); |
3030 | // return; | 3043 | // return; |
3031 | //} | 3044 | //} |
3032 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3045 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3033 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3046 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3034 | anEvent->addExDate(itemDate); | 3047 | anEvent->addExDate(itemDate); |
3035 | int duration = anEvent->recurrence()->duration(); | 3048 | int duration = anEvent->recurrence()->duration(); |
3036 | if ( duration > 0 ) { | 3049 | if ( duration > 0 ) { |
3037 | anEvent->recurrence()->setDuration( duration - 1 ); | 3050 | anEvent->recurrence()->setDuration( duration - 1 ); |
3038 | } | 3051 | } |
3039 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3052 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3040 | } | 3053 | } |
3041 | break; | 3054 | break; |
3042 | //#endif | 3055 | //#endif |
3043 | } // switch | 3056 | } // switch |
3044 | } else { | 3057 | } else { |
3045 | if (KOPrefs::instance()->mConfirm) { | 3058 | if (KOPrefs::instance()->mConfirm) { |
3046 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3059 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3047 | i18n("\nAre you sure you want\nto delete this event?"), | 3060 | i18n("\nAre you sure you want\nto delete this event?"), |
3048 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3061 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3049 | case KMessageBox::Continue: // OK | 3062 | case KMessageBox::Continue: // OK |
3050 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3063 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3051 | schedule(Scheduler::Cancel,anEvent); | 3064 | schedule(Scheduler::Cancel,anEvent); |
3052 | checkExternalId( anEvent); | 3065 | checkExternalId( anEvent); |
3053 | mCalendar->deleteEvent(anEvent); | 3066 | mCalendar->deleteEvent(anEvent); |
3054 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3067 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3055 | break; | 3068 | break; |
3056 | } // switch | 3069 | } // switch |
3057 | } else { | 3070 | } else { |
3058 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3071 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3059 | schedule(Scheduler::Cancel,anEvent); | 3072 | schedule(Scheduler::Cancel,anEvent); |
3060 | checkExternalId( anEvent); | 3073 | checkExternalId( anEvent); |
3061 | mCalendar->deleteEvent(anEvent); | 3074 | mCalendar->deleteEvent(anEvent); |
3062 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3075 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3063 | } | 3076 | } |
3064 | } // if-else | 3077 | } // if-else |
3065 | emit updateSearchDialog(); | 3078 | emit updateSearchDialog(); |
3066 | } | 3079 | } |
3067 | 3080 | ||
3068 | bool CalendarView::deleteEvent(const QString &uid) | 3081 | bool CalendarView::deleteEvent(const QString &uid) |
3069 | { | 3082 | { |
3070 | Event *ev = mCalendar->event(uid); | 3083 | Event *ev = mCalendar->event(uid); |
3071 | if (ev) { | 3084 | if (ev) { |
3072 | deleteEvent(ev); | 3085 | deleteEvent(ev); |
3073 | return true; | 3086 | return true; |
3074 | } else { | 3087 | } else { |
3075 | return false; | 3088 | return false; |
3076 | } | 3089 | } |
3077 | } | 3090 | } |
3078 | 3091 | ||
3079 | /*****************************************************************************/ | 3092 | /*****************************************************************************/ |
3080 | 3093 | ||
3081 | void CalendarView::action_mail() | 3094 | void CalendarView::action_mail() |
3082 | { | 3095 | { |
3083 | #ifndef KORG_NOMAIL | 3096 | #ifndef KORG_NOMAIL |
3084 | KOMailClient mailClient; | 3097 | KOMailClient mailClient; |
3085 | 3098 | ||
3086 | Incidence *incidence = currentSelection(); | 3099 | Incidence *incidence = currentSelection(); |
3087 | 3100 | ||
3088 | if (!incidence) { | 3101 | if (!incidence) { |
3089 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3102 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3090 | return; | 3103 | return; |
3091 | } | 3104 | } |
3092 | if(incidence->attendeeCount() == 0 ) { | 3105 | if(incidence->attendeeCount() == 0 ) { |
3093 | KMessageBox::sorry(this, | 3106 | KMessageBox::sorry(this, |
3094 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3107 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3095 | return; | 3108 | return; |
3096 | } | 3109 | } |
3097 | 3110 | ||
3098 | CalendarLocal cal_tmp; | 3111 | CalendarLocal cal_tmp; |
3099 | Event *event = 0; | 3112 | Event *event = 0; |
3100 | Event *ev = 0; | 3113 | Event *ev = 0; |
3101 | if ( incidence && incidence->type() == "Event" ) { | 3114 | if ( incidence && incidence->type() == "Event" ) { |
3102 | event = static_cast<Event *>(incidence); | 3115 | event = static_cast<Event *>(incidence); |
3103 | ev = new Event(*event); | 3116 | ev = new Event(*event); |
3104 | cal_tmp.addEvent(ev); | 3117 | cal_tmp.addEvent(ev); |
3105 | } | 3118 | } |
3106 | ICalFormat mForm(); | 3119 | ICalFormat mForm(); |
3107 | QString attachment = mForm.toString( &cal_tmp ); | 3120 | QString attachment = mForm.toString( &cal_tmp ); |
3108 | if (ev) delete(ev); | 3121 | if (ev) delete(ev); |
3109 | 3122 | ||
3110 | mailClient.mailAttendees(currentSelection(), attachment); | 3123 | mailClient.mailAttendees(currentSelection(), attachment); |
3111 | 3124 | ||
3112 | #endif | 3125 | #endif |
3113 | 3126 | ||
3114 | #if 0 | 3127 | #if 0 |
3115 | Event *anEvent = 0; | 3128 | Event *anEvent = 0; |
3116 | if (mViewManager->currentView()->isEventView()) { | 3129 | if (mViewManager->currentView()->isEventView()) { |
3117 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3130 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3118 | } | 3131 | } |
3119 | 3132 | ||
3120 | if (!anEvent) { | 3133 | if (!anEvent) { |
3121 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3134 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3122 | return; | 3135 | return; |
3123 | } | 3136 | } |
3124 | if(anEvent->attendeeCount() == 0 ) { | 3137 | if(anEvent->attendeeCount() == 0 ) { |
3125 | KMessageBox::sorry(this, | 3138 | KMessageBox::sorry(this, |
3126 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3139 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3127 | return; | 3140 | return; |
3128 | } | 3141 | } |
3129 | 3142 | ||
3130 | mailobject.emailEvent(anEvent); | 3143 | mailobject.emailEvent(anEvent); |
3131 | #endif | 3144 | #endif |
3132 | } | 3145 | } |
3133 | 3146 | ||
3134 | 3147 | ||
3135 | void CalendarView::schedule_publish(Incidence *incidence) | 3148 | void CalendarView::schedule_publish(Incidence *incidence) |
3136 | { | 3149 | { |
3137 | Event *event = 0; | 3150 | Event *event = 0; |
3138 | Todo *todo = 0; | 3151 | Todo *todo = 0; |
3139 | 3152 | ||
3140 | if (incidence == 0) { | 3153 | if (incidence == 0) { |
3141 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3154 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3142 | if (incidence == 0) { | 3155 | if (incidence == 0) { |
3143 | incidence = mTodoList->selectedIncidences().first(); | 3156 | incidence = mTodoList->selectedIncidences().first(); |
3144 | } | 3157 | } |
3145 | } | 3158 | } |
3146 | if ( incidence && incidence->type() == "Event" ) { | 3159 | if ( incidence && incidence->type() == "Event" ) { |
3147 | event = static_cast<Event *>(incidence); | 3160 | event = static_cast<Event *>(incidence); |
3148 | } else { | 3161 | } else { |
3149 | if ( incidence && incidence->type() == "Todo" ) { | 3162 | if ( incidence && incidence->type() == "Todo" ) { |
3150 | todo = static_cast<Todo *>(incidence); | 3163 | todo = static_cast<Todo *>(incidence); |
3151 | } | 3164 | } |
3152 | } | 3165 | } |
3153 | 3166 | ||
3154 | if (!event && !todo) { | 3167 | if (!event && !todo) { |
3155 | KMessageBox::sorry(this,i18n("No event selected.")); | 3168 | KMessageBox::sorry(this,i18n("No event selected.")); |
3156 | return; | 3169 | return; |
3157 | } | 3170 | } |
3158 | 3171 | ||
3159 | PublishDialog *publishdlg = new PublishDialog(); | 3172 | PublishDialog *publishdlg = new PublishDialog(); |
3160 | if (incidence->attendeeCount()>0) { | 3173 | if (incidence->attendeeCount()>0) { |
3161 | QPtrList<Attendee> attendees = incidence->attendees(); | 3174 | QPtrList<Attendee> attendees = incidence->attendees(); |
3162 | attendees.first(); | 3175 | attendees.first(); |
3163 | while ( attendees.current()!=0 ) { | 3176 | while ( attendees.current()!=0 ) { |
3164 | publishdlg->addAttendee(attendees.current()); | 3177 | publishdlg->addAttendee(attendees.current()); |
3165 | attendees.next(); | 3178 | attendees.next(); |
3166 | } | 3179 | } |
3167 | } | 3180 | } |
3168 | bool send = true; | 3181 | bool send = true; |
3169 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3182 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3170 | if ( publishdlg->exec() != QDialog::Accepted ) | 3183 | if ( publishdlg->exec() != QDialog::Accepted ) |
3171 | send = false; | 3184 | send = false; |
3172 | } | 3185 | } |
3173 | if ( send ) { | 3186 | if ( send ) { |
3174 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3187 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3175 | if ( event ) { | 3188 | if ( event ) { |
3176 | Event *ev = new Event(*event); | 3189 | Event *ev = new Event(*event); |
3177 | ev->registerObserver(0); | 3190 | ev->registerObserver(0); |
3178 | ev->clearAttendees(); | 3191 | ev->clearAttendees(); |
3179 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3192 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3180 | delete(ev); | 3193 | delete(ev); |
@@ -3586,389 +3599,390 @@ void CalendarView::showFilter(bool visible) | |||
3586 | if (visible) mFilterView->show(); | 3599 | if (visible) mFilterView->show(); |
3587 | else mFilterView->hide(); | 3600 | else mFilterView->hide(); |
3588 | } | 3601 | } |
3589 | void CalendarView::toggleFilerEnabled( ) | 3602 | void CalendarView::toggleFilerEnabled( ) |
3590 | { | 3603 | { |
3591 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3604 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3592 | if ( !mFilterView->filtersEnabled() ) | 3605 | if ( !mFilterView->filtersEnabled() ) |
3593 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3606 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3594 | 3607 | ||
3595 | } | 3608 | } |
3596 | void CalendarView::updateFilter() | 3609 | void CalendarView::updateFilter() |
3597 | { | 3610 | { |
3598 | CalFilter *filter = mFilterView->selectedFilter(); | 3611 | CalFilter *filter = mFilterView->selectedFilter(); |
3599 | if (filter) { | 3612 | if (filter) { |
3600 | if (mFilterView->filtersEnabled()) { | 3613 | if (mFilterView->filtersEnabled()) { |
3601 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3614 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3602 | filter->setEnabled(true); | 3615 | filter->setEnabled(true); |
3603 | } | 3616 | } |
3604 | else filter->setEnabled(false); | 3617 | else filter->setEnabled(false); |
3605 | mCalendar->setFilter(filter); | 3618 | mCalendar->setFilter(filter); |
3606 | updateView(); | 3619 | updateView(); |
3607 | } | 3620 | } |
3608 | } | 3621 | } |
3609 | 3622 | ||
3610 | void CalendarView::filterEdited() | 3623 | void CalendarView::filterEdited() |
3611 | { | 3624 | { |
3612 | mFilterView->updateFilters(); | 3625 | mFilterView->updateFilters(); |
3613 | updateFilter(); | 3626 | updateFilter(); |
3614 | writeSettings(); | 3627 | writeSettings(); |
3615 | } | 3628 | } |
3616 | 3629 | ||
3617 | 3630 | ||
3618 | void CalendarView::takeOverEvent() | 3631 | void CalendarView::takeOverEvent() |
3619 | { | 3632 | { |
3620 | Incidence *incidence = currentSelection(); | 3633 | Incidence *incidence = currentSelection(); |
3621 | 3634 | ||
3622 | if (!incidence) return; | 3635 | if (!incidence) return; |
3623 | 3636 | ||
3624 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3637 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3625 | incidence->recreate(); | 3638 | incidence->recreate(); |
3626 | incidence->setReadOnly(false); | 3639 | incidence->setReadOnly(false); |
3627 | 3640 | ||
3628 | updateView(); | 3641 | updateView(); |
3629 | } | 3642 | } |
3630 | 3643 | ||
3631 | void CalendarView::takeOverCalendar() | 3644 | void CalendarView::takeOverCalendar() |
3632 | { | 3645 | { |
3633 | // TODO: Create Calendar::allIncidences() function and use it here | 3646 | // TODO: Create Calendar::allIncidences() function and use it here |
3634 | 3647 | ||
3635 | QPtrList<Event> events = mCalendar->events(); | 3648 | QPtrList<Event> events = mCalendar->events(); |
3636 | for(uint i=0; i<events.count(); ++i) { | 3649 | for(uint i=0; i<events.count(); ++i) { |
3637 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3650 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3638 | events.at(i)->recreate(); | 3651 | events.at(i)->recreate(); |
3639 | events.at(i)->setReadOnly(false); | 3652 | events.at(i)->setReadOnly(false); |
3640 | } | 3653 | } |
3641 | 3654 | ||
3642 | QPtrList<Todo> todos = mCalendar->todos(); | 3655 | QPtrList<Todo> todos = mCalendar->todos(); |
3643 | for(uint i=0; i<todos.count(); ++i) { | 3656 | for(uint i=0; i<todos.count(); ++i) { |
3644 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3657 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3645 | todos.at(i)->recreate(); | 3658 | todos.at(i)->recreate(); |
3646 | todos.at(i)->setReadOnly(false); | 3659 | todos.at(i)->setReadOnly(false); |
3647 | } | 3660 | } |
3648 | 3661 | ||
3649 | QPtrList<Journal> journals = mCalendar->journals(); | 3662 | QPtrList<Journal> journals = mCalendar->journals(); |
3650 | for(uint i=0; i<journals.count(); ++i) { | 3663 | for(uint i=0; i<journals.count(); ++i) { |
3651 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3664 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3652 | journals.at(i)->recreate(); | 3665 | journals.at(i)->recreate(); |
3653 | journals.at(i)->setReadOnly(false); | 3666 | journals.at(i)->setReadOnly(false); |
3654 | } | 3667 | } |
3655 | 3668 | ||
3656 | updateView(); | 3669 | updateView(); |
3657 | } | 3670 | } |
3658 | 3671 | ||
3659 | void CalendarView::showIntro() | 3672 | void CalendarView::showIntro() |
3660 | { | 3673 | { |
3661 | kdDebug() << "To be implemented." << endl; | 3674 | kdDebug() << "To be implemented." << endl; |
3662 | } | 3675 | } |
3663 | 3676 | ||
3664 | QWidgetStack *CalendarView::viewStack() | 3677 | QWidgetStack *CalendarView::viewStack() |
3665 | { | 3678 | { |
3666 | return mRightFrame; | 3679 | return mRightFrame; |
3667 | } | 3680 | } |
3668 | 3681 | ||
3669 | QWidget *CalendarView::leftFrame() | 3682 | QWidget *CalendarView::leftFrame() |
3670 | { | 3683 | { |
3671 | return mLeftFrame; | 3684 | return mLeftFrame; |
3672 | } | 3685 | } |
3673 | 3686 | ||
3674 | DateNavigator *CalendarView::dateNavigator() | 3687 | DateNavigator *CalendarView::dateNavigator() |
3675 | { | 3688 | { |
3676 | return mNavigator; | 3689 | return mNavigator; |
3677 | } | 3690 | } |
3678 | 3691 | ||
3679 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3692 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3680 | { | 3693 | { |
3681 | return mDateNavigator; | 3694 | return mDateNavigator; |
3682 | } | 3695 | } |
3683 | void CalendarView::toggleDateNavigatorWidget() | 3696 | void CalendarView::toggleDateNavigatorWidget() |
3684 | { | 3697 | { |
3685 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3698 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3686 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3699 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3687 | mDateNavigator->hide(); | 3700 | mDateNavigator->hide(); |
3688 | else | 3701 | else |
3689 | mDateNavigator->show(); | 3702 | mDateNavigator->show(); |
3690 | } | 3703 | } |
3691 | void CalendarView::addView(KOrg::BaseView *view) | 3704 | void CalendarView::addView(KOrg::BaseView *view) |
3692 | { | 3705 | { |
3693 | mViewManager->addView(view); | 3706 | mViewManager->addView(view); |
3694 | } | 3707 | } |
3695 | 3708 | ||
3696 | void CalendarView::showView(KOrg::BaseView *view) | 3709 | void CalendarView::showView(KOrg::BaseView *view) |
3697 | { | 3710 | { |
3698 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3711 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3699 | } | 3712 | } |
3700 | 3713 | ||
3701 | Incidence *CalendarView::currentSelection() | 3714 | Incidence *CalendarView::currentSelection() |
3702 | { | 3715 | { |
3703 | return mViewManager->currentSelection(); | 3716 | return mViewManager->currentSelection(); |
3704 | } | 3717 | } |
3705 | void CalendarView::toggleAllDaySize() | 3718 | void CalendarView::toggleAllDaySize() |
3706 | { | 3719 | { |
3707 | /* | 3720 | /* |
3708 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3721 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3709 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3722 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3710 | else | 3723 | else |
3711 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3724 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3712 | */ | 3725 | */ |
3713 | viewManager()->agendaView()->toggleAllDay(); | 3726 | viewManager()->agendaView()->toggleAllDay(); |
3714 | } | 3727 | } |
3715 | void CalendarView::toggleExpand() | 3728 | void CalendarView::toggleExpand() |
3716 | { | 3729 | { |
3717 | // if ( mLeftFrame->isHidden() ) { | 3730 | // if ( mLeftFrame->isHidden() ) { |
3718 | // mLeftFrame->show(); | 3731 | // mLeftFrame->show(); |
3719 | // emit calendarViewExpanded( false ); | 3732 | // emit calendarViewExpanded( false ); |
3720 | // } else { | 3733 | // } else { |
3721 | // mLeftFrame->hide(); | 3734 | // mLeftFrame->hide(); |
3722 | // emit calendarViewExpanded( true ); | 3735 | // emit calendarViewExpanded( true ); |
3723 | // } | 3736 | // } |
3724 | //qDebug(" CalendarView::toggleExpand()"); | 3737 | //qDebug(" CalendarView::toggleExpand()"); |
3725 | globalFlagBlockAgenda = 1; | 3738 | globalFlagBlockAgenda = 1; |
3726 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3739 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3727 | globalFlagBlockAgenda = 5; | 3740 | globalFlagBlockAgenda = 5; |
3728 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3741 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3729 | //mViewManager->showView( 0, true ); | 3742 | //mViewManager->showView( 0, true ); |
3730 | } | 3743 | } |
3731 | 3744 | ||
3732 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3745 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3733 | { | 3746 | { |
3734 | setModified( modified ); | 3747 | setModified( modified ); |
3735 | } | 3748 | } |
3736 | 3749 | ||
3737 | Todo *CalendarView::selectedTodo() | 3750 | Todo *CalendarView::selectedTodo() |
3738 | { | 3751 | { |
3739 | Incidence *incidence = currentSelection(); | 3752 | Incidence *incidence = currentSelection(); |
3740 | if ( incidence && incidence->type() == "Todo" ) { | 3753 | if ( incidence && incidence->type() == "Todo" ) { |
3741 | return static_cast<Todo *>( incidence ); | 3754 | return static_cast<Todo *>( incidence ); |
3742 | } | 3755 | } |
3743 | 3756 | ||
3744 | incidence = mTodoList->selectedIncidences().first(); | 3757 | incidence = mTodoList->selectedIncidences().first(); |
3745 | if ( incidence && incidence->type() == "Todo" ) { | 3758 | if ( incidence && incidence->type() == "Todo" ) { |
3746 | return static_cast<Todo *>( incidence ); | 3759 | return static_cast<Todo *>( incidence ); |
3747 | } | 3760 | } |
3748 | 3761 | ||
3749 | return 0; | 3762 | return 0; |
3750 | } | 3763 | } |
3751 | 3764 | ||
3752 | void CalendarView::dialogClosing(Incidence *in) | 3765 | void CalendarView::dialogClosing(Incidence *in) |
3753 | { | 3766 | { |
3754 | // mDialogList.remove(in); | 3767 | // mDialogList.remove(in); |
3755 | } | 3768 | } |
3756 | 3769 | ||
3757 | void CalendarView::showIncidence() | 3770 | void CalendarView::showIncidence() |
3758 | { | 3771 | { |
3759 | mViewerCallerIsSearchDialog = false; | 3772 | mViewerCallerIsSearchDialog = false; |
3760 | Incidence *incidence = currentSelection(); | 3773 | Incidence *incidence = currentSelection(); |
3761 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3774 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3762 | if ( incidence ) { | 3775 | if ( incidence ) { |
3763 | ShowIncidenceVisitor v; | 3776 | ShowIncidenceVisitor v; |
3764 | v.act( incidence, this ); | 3777 | v.act( incidence, this ); |
3765 | } | 3778 | } |
3766 | } | 3779 | } |
3767 | void CalendarView::editIncidenceDescription() | 3780 | void CalendarView::editIncidenceDescription() |
3768 | { | 3781 | { |
3769 | mFlagEditDescription = true; | 3782 | mFlagEditDescription = true; |
3770 | editIncidence(); | 3783 | editIncidence(); |
3771 | mFlagEditDescription = false; | 3784 | mFlagEditDescription = false; |
3772 | } | 3785 | } |
3773 | void CalendarView::editIncidence() | 3786 | void CalendarView::editIncidence() |
3774 | { | 3787 | { |
3775 | // qDebug("editIncidence() "); | 3788 | // qDebug("editIncidence() "); |
3776 | Incidence *incidence = currentSelection(); | 3789 | Incidence *incidence = currentSelection(); |
3777 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3790 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3778 | if ( incidence ) { | 3791 | if ( incidence ) { |
3779 | EditIncidenceVisitor v; | 3792 | EditIncidenceVisitor v; |
3780 | v.act( incidence, this ); | 3793 | v.act( incidence, this ); |
3781 | } | 3794 | } |
3782 | } | 3795 | } |
3783 | 3796 | ||
3784 | void CalendarView::deleteIncidence() | 3797 | void CalendarView::deleteIncidence() |
3785 | { | 3798 | { |
3786 | Incidence *incidence = currentSelection(); | 3799 | Incidence *incidence = currentSelection(); |
3787 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3800 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3788 | if ( incidence ) { | 3801 | if ( incidence ) { |
3789 | deleteIncidence(incidence); | 3802 | deleteIncidence(incidence); |
3790 | } | 3803 | } |
3791 | } | 3804 | } |
3792 | 3805 | ||
3793 | void CalendarView::showIncidence(Incidence *incidence) | 3806 | void CalendarView::showIncidence(Incidence *incidence) |
3794 | { | 3807 | { |
3795 | mViewerCallerIsSearchDialog = false; | 3808 | mViewerCallerIsSearchDialog = false; |
3796 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3809 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3797 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3810 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3798 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3811 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3799 | mViewerCallerIsSearchDialog = true; | 3812 | mViewerCallerIsSearchDialog = true; |
3800 | } | 3813 | } |
3801 | } | 3814 | } |
3802 | if ( incidence ) { | 3815 | if ( incidence ) { |
3803 | ShowIncidenceVisitor v; | 3816 | ShowIncidenceVisitor v; |
3804 | v.act( incidence, this ); | 3817 | v.act( incidence, this ); |
3805 | } | 3818 | } |
3806 | } | 3819 | } |
3807 | 3820 | ||
3808 | void CalendarView::editIncidence(Incidence *incidence) | 3821 | void CalendarView::editIncidence(Incidence *incidence) |
3809 | { | 3822 | { |
3810 | if ( incidence ) { | 3823 | if ( incidence ) { |
3811 | 3824 | ||
3812 | EditIncidenceVisitor v; | 3825 | EditIncidenceVisitor v; |
3813 | v.act( incidence, this ); | 3826 | v.act( incidence, this ); |
3814 | 3827 | ||
3815 | } | 3828 | } |
3816 | } | 3829 | } |
3817 | 3830 | ||
3818 | void CalendarView::deleteIncidence(Incidence *incidence) | 3831 | void CalendarView::deleteIncidence(Incidence *incidence) |
3819 | { | 3832 | { |
3820 | //qDebug(" CalendarView::deleteIncidence "); | 3833 | //qDebug(" CalendarView::deleteIncidence "); |
3821 | if ( incidence ) { | 3834 | if ( incidence ) { |
3822 | DeleteIncidenceVisitor v; | 3835 | DeleteIncidenceVisitor v; |
3823 | v.act( incidence, this ); | 3836 | v.act( incidence, this ); |
3824 | } | 3837 | } |
3825 | } | 3838 | } |
3826 | 3839 | ||
3827 | 3840 | ||
3828 | void CalendarView::lookForOutgoingMessages() | 3841 | void CalendarView::lookForOutgoingMessages() |
3829 | { | 3842 | { |
3830 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3843 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3831 | ogd->loadMessages(); | 3844 | ogd->loadMessages(); |
3832 | } | 3845 | } |
3833 | 3846 | ||
3834 | void CalendarView::lookForIncomingMessages() | 3847 | void CalendarView::lookForIncomingMessages() |
3835 | { | 3848 | { |
3836 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3849 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3837 | icd->retrieve(); | 3850 | icd->retrieve(); |
3838 | } | 3851 | } |
3839 | 3852 | ||
3840 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3853 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3841 | { | 3854 | { |
3842 | bool deleteTodo = true; | 3855 | bool deleteTodo = true; |
3843 | QPtrList<Incidence> subTodos; | 3856 | QPtrList<Incidence> subTodos; |
3844 | Incidence *aTodo; | 3857 | Incidence *aTodo; |
3845 | subTodos = t->relations(); | 3858 | subTodos = t->relations(); |
3846 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3859 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3847 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3860 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3848 | deleteTodo = false; | 3861 | deleteTodo = false; |
3849 | } | 3862 | } |
3850 | if ( deleteTodo ) { | 3863 | if ( deleteTodo ) { |
3851 | if ( t->isCompleted() && !t->doesRecur()) { | 3864 | if ( t->isCompleted() && !t->doesRecur()) { |
3852 | checkExternalId( t ); | 3865 | checkExternalId( t ); |
3853 | mCalendar->deleteTodo( t ); | 3866 | mCalendar->deleteTodo( t ); |
3854 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3867 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3855 | } | 3868 | } |
3856 | else | 3869 | else |
3857 | deleteTodo = false; | 3870 | deleteTodo = false; |
3858 | } | 3871 | } |
3859 | return deleteTodo; | 3872 | return deleteTodo; |
3860 | 3873 | ||
3861 | } | 3874 | } |
3862 | void CalendarView::purgeCompleted() | 3875 | void CalendarView::purgeCompleted() |
3863 | { | 3876 | { |
3864 | int result = KMessageBox::warningContinueCancel(this, | 3877 | int result = KMessageBox::warningContinueCancel(this, |
3865 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3878 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3866 | 3879 | ||
3867 | if (result == KMessageBox::Continue) { | 3880 | if (result == KMessageBox::Continue) { |
3868 | 3881 | ||
3869 | QPtrList<Todo> todoCal; | 3882 | QPtrList<Todo> todoCal; |
3870 | QPtrList<Todo> rootTodos; | 3883 | QPtrList<Todo> rootTodos; |
3871 | //QPtrList<Incidence> rel; | 3884 | //QPtrList<Incidence> rel; |
3872 | Todo *aTodo;//, *rTodo; | 3885 | Todo *aTodo;//, *rTodo; |
3873 | Incidence *rIncidence; | 3886 | Incidence *rIncidence; |
3874 | bool childDelete = false; | 3887 | bool childDelete = false; |
3875 | bool deletedOne = true; | 3888 | bool deletedOne = true; |
3876 | todoCal = calendar()->todos(); | 3889 | todoCal = calendar()->todos(); |
3877 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3890 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3878 | if ( !aTodo->relatedTo() ) | 3891 | if ( !aTodo->relatedTo() ) |
3879 | rootTodos.append( aTodo ); | 3892 | rootTodos.append( aTodo ); |
3880 | } | 3893 | } |
3881 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3894 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3882 | removeCompletedSubTodos( aTodo ); | 3895 | removeCompletedSubTodos( aTodo ); |
3883 | } | 3896 | } |
3884 | 3897 | ||
3885 | updateView(); | 3898 | updateView(); |
3886 | } | 3899 | } |
3887 | } | 3900 | } |
3888 | 3901 | ||
3889 | void CalendarView::slotCalendarChanged() | 3902 | void CalendarView::slotCalendarChanged() |
3890 | { | 3903 | { |
3891 | ; | 3904 | ; |
3892 | } | 3905 | } |
3893 | 3906 | ||
3894 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3907 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3895 | { | 3908 | { |
3896 | //qDebug(" alendarView::keyPressEvent "); | 3909 | //qDebug(" alendarView::keyPressEvent "); |
3897 | e->ignore(); | 3910 | e->ignore(); |
3898 | } | 3911 | } |
3899 | 3912 | ||
3900 | 3913 | ||
3901 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3914 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3902 | { | 3915 | { |
3903 | // mSyncManager = manager; | 3916 | // mSyncManager = manager; |
3904 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3917 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3905 | qDebug("KO: SyncKDE request detected!"); | 3918 | qDebug("KO: SyncKDE request detected!"); |
3906 | } | 3919 | } |
3907 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3920 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3908 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3921 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3909 | return syncCalendar( filename, mode ); | 3922 | return syncCalendar( filename, mode ); |
3910 | } | 3923 | } |
3911 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3924 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3912 | { | 3925 | { |
3913 | //mSyncManager = manager; | 3926 | //mSyncManager = manager; |
3914 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3927 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3915 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3928 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3916 | if ( resource == "sharp" ) | 3929 | if ( resource == "sharp" ) |
3917 | syncExternal( 0 ); | 3930 | syncExternal( 0 ); |
3918 | if ( resource == "phone" ) | 3931 | if ( resource == "phone" ) |
3919 | syncExternal( 1 ); | 3932 | syncExternal( 1 ); |
3920 | // pending setmodified | 3933 | // pending setmodified |
3921 | return true; | 3934 | return true; |
3922 | } | 3935 | } |
3923 | void CalendarView::setSyncManager(KSyncManager* manager) | 3936 | void CalendarView::setSyncManager(KSyncManager* manager) |
3924 | { | 3937 | { |
3925 | mSyncManager = manager; | 3938 | mSyncManager = manager; |
3926 | } | 3939 | } |
3927 | 3940 | ||
3928 | void CalendarView::removeSyncInfo( QString syncProfile) | 3941 | void CalendarView::removeSyncInfo( QString syncProfile) |
3929 | { | 3942 | { |
3930 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3943 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3931 | mCalendar->removeSyncInfo( syncProfile ); | 3944 | mCalendar->removeSyncInfo( syncProfile ); |
3932 | 3945 | ||
3933 | } | 3946 | } |
3934 | 3947 | ||
3935 | void CalendarView::undo_delete() | 3948 | void CalendarView::undo_delete() |
3936 | { | 3949 | { |
3937 | //qDebug("undo_delete() "); | 3950 | //qDebug("undo_delete() "); |
3938 | Incidence* undo = mCalendar->undoIncidence(); | 3951 | Incidence* undo = mCalendar->undoIncidence(); |
3939 | if ( !undo ) { | 3952 | if ( !undo ) { |
3940 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3953 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3941 | i18n("KO/Pi")); | 3954 | i18n("KO/Pi")); |
3942 | return; | 3955 | return; |
3943 | } | 3956 | } |
3944 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3957 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3945 | i18n("\nAre you sure you want\nto restore this?"), | 3958 | i18n("\nAre you sure you want\nto restore this?"), |
3946 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3959 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3947 | mCalendar->undoDeleteIncidence(); | 3960 | mCalendar->undoDeleteIncidence(); |
3948 | updateView(); | 3961 | updateView(); |
3949 | } | 3962 | } |
3950 | } | 3963 | } |
3951 | 3964 | ||
3952 | void CalendarView::slotViewerClosed() | 3965 | void CalendarView::slotViewerClosed() |
3953 | { | 3966 | { |
3954 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 3967 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
3955 | } | 3968 | } |
3956 | 3969 | ||
3957 | void CalendarView::resetFocus() | 3970 | void CalendarView::resetFocus() |
3958 | { | 3971 | { |
3959 | if ( mViewerCallerIsSearchDialog ) { | 3972 | if ( mViewerCallerIsSearchDialog ) { |
3960 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 3973 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
3961 | mDialogManager->getSearchDialog()->raise(); | 3974 | mDialogManager->getSearchDialog()->raise(); |
3962 | mDialogManager->getSearchDialog()->setActiveWindow(); | 3975 | mDialogManager->getSearchDialog()->setActiveWindow(); |
3963 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 3976 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
3964 | } else | 3977 | } else |
3965 | mViewerCallerIsSearchDialog = false; | 3978 | mViewerCallerIsSearchDialog = false; |
3966 | } | 3979 | } |
3967 | if ( !mViewerCallerIsSearchDialog ) { | 3980 | if ( !mViewerCallerIsSearchDialog ) { |
3968 | //mViewManager->currentView()->setFocus(); | 3981 | //mViewManager->currentView()->setFocus(); |
3969 | //qDebug("sssssssssssssssset focus "); | 3982 | //qDebug("sssssssssssssssset focus "); |
3983 | topLevelWidget()->raise(); | ||
3970 | setActiveWindow(); | 3984 | setActiveWindow(); |
3971 | //setFocus(); | 3985 | //setFocus(); |
3972 | } | 3986 | } |
3973 | mViewerCallerIsSearchDialog = false; | 3987 | mViewerCallerIsSearchDialog = false; |
3974 | } | 3988 | } |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 195b1fa..ec81d44 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -800,769 +800,792 @@ void KOAgenda::performItemAction(QPoint viewportPos) | |||
800 | } | 800 | } |
801 | 801 | ||
802 | // Move or resize item if necessary | 802 | // Move or resize item if necessary |
803 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 803 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
804 | mItemMoved = true; | 804 | mItemMoved = true; |
805 | mActionItem->raise(); | 805 | mActionItem->raise(); |
806 | if (mActionType == MOVE) { | 806 | if (mActionType == MOVE) { |
807 | // Move all items belonging to a multi item | 807 | // Move all items belonging to a multi item |
808 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 808 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
809 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 809 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
810 | if (!moveItem) moveItem = mActionItem; | 810 | if (!moveItem) moveItem = mActionItem; |
811 | while (moveItem) { | 811 | while (moveItem) { |
812 | int dy; | 812 | int dy; |
813 | if (isMultiItem) dy = 0; | 813 | if (isMultiItem) dy = 0; |
814 | else dy = gy - mCurrentCellY; | 814 | else dy = gy - mCurrentCellY; |
815 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 815 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
816 | int x,y; | 816 | int x,y; |
817 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 817 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
818 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 818 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
819 | mGridSpacingY * moveItem->cellHeight()); | 819 | mGridSpacingY * moveItem->cellHeight()); |
820 | moveChild(moveItem,x,y); | 820 | moveChild(moveItem,x,y); |
821 | moveItem = moveItem->nextMultiItem(); | 821 | moveItem = moveItem->nextMultiItem(); |
822 | } | 822 | } |
823 | } else if (mActionType == RESIZETOP) { | 823 | } else if (mActionType == RESIZETOP) { |
824 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 824 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
825 | mActionItem->expandTop(gy - mCurrentCellY); | 825 | mActionItem->expandTop(gy - mCurrentCellY); |
826 | mActionItem->resize(mActionItem->width(), | 826 | mActionItem->resize(mActionItem->width(), |
827 | mGridSpacingY * mActionItem->cellHeight()); | 827 | mGridSpacingY * mActionItem->cellHeight()); |
828 | int x,y; | 828 | int x,y; |
829 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 829 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
830 | //moveChild(mActionItem,childX(mActionItem),y); | 830 | //moveChild(mActionItem,childX(mActionItem),y); |
831 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 831 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
832 | } | 832 | } |
833 | } else if (mActionType == RESIZEBOTTOM) { | 833 | } else if (mActionType == RESIZEBOTTOM) { |
834 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 834 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
835 | mActionItem->expandBottom(gy - mCurrentCellY); | 835 | mActionItem->expandBottom(gy - mCurrentCellY); |
836 | mActionItem->resize(mActionItem->width(), | 836 | mActionItem->resize(mActionItem->width(), |
837 | mGridSpacingY * mActionItem->cellHeight()); | 837 | mGridSpacingY * mActionItem->cellHeight()); |
838 | } | 838 | } |
839 | } else if (mActionType == RESIZELEFT) { | 839 | } else if (mActionType == RESIZELEFT) { |
840 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 840 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
841 | mActionItem->expandLeft(gx - mCurrentCellX); | 841 | mActionItem->expandLeft(gx - mCurrentCellX); |
842 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 842 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
843 | mActionItem->height()); | 843 | mActionItem->height()); |
844 | int x,y; | 844 | int x,y; |
845 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 845 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
846 | moveChild(mActionItem,x,childY(mActionItem)); | 846 | moveChild(mActionItem,x,childY(mActionItem)); |
847 | } | 847 | } |
848 | } else if (mActionType == RESIZERIGHT) { | 848 | } else if (mActionType == RESIZERIGHT) { |
849 | if (mCurrentCellX >= mActionItem->cellX()) { | 849 | if (mCurrentCellX >= mActionItem->cellX()) { |
850 | mActionItem->expandRight(gx - mCurrentCellX); | 850 | mActionItem->expandRight(gx - mCurrentCellX); |
851 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 851 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
852 | mActionItem->height()); | 852 | mActionItem->height()); |
853 | } | 853 | } |
854 | } | 854 | } |
855 | mCurrentCellX = gx; | 855 | mCurrentCellX = gx; |
856 | mCurrentCellY = gy; | 856 | mCurrentCellY = gy; |
857 | } | 857 | } |
858 | } | 858 | } |
859 | 859 | ||
860 | void KOAgenda::endItemAction() | 860 | void KOAgenda::endItemAction() |
861 | { | 861 | { |
862 | 862 | ||
863 | if ( mItemMoved ) { | 863 | if ( mItemMoved ) { |
864 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 864 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
865 | if ( !placeItem ) { | 865 | if ( !placeItem ) { |
866 | placeItem = mActionItem; | 866 | placeItem = mActionItem; |
867 | } | 867 | } |
868 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 868 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
869 | Incidence* oldInc = placeItem->incidence(); | 869 | Incidence* oldInc = placeItem->incidence(); |
870 | placeItem->recreateIncidence(); | 870 | placeItem->recreateIncidence(); |
871 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 871 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
872 | } | 872 | } |
873 | int type = mActionType; | 873 | int type = mActionType; |
874 | if ( mAllDayMode ) | 874 | if ( mAllDayMode ) |
875 | type = -1; | 875 | type = -1; |
876 | KOAgendaItem *modifiedItem = placeItem; | 876 | KOAgendaItem *modifiedItem = placeItem; |
877 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 877 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
878 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 878 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
879 | KOAgendaItem *item; | 879 | KOAgendaItem *item; |
880 | 880 | ||
881 | if ( placeItem->incidence()->type() == "Todo" ) { | 881 | if ( placeItem->incidence()->type() == "Todo" ) { |
882 | mSelectedItem = 0; | 882 | mSelectedItem = 0; |
883 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 883 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
884 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 884 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
885 | emit itemModified( modifiedItem, mActionType ); | 885 | emit itemModified( modifiedItem, mActionType ); |
886 | } | 886 | } |
887 | else { | 887 | else { |
888 | #if 0 | 888 | #if 0 |
889 | for ( item=oldconflictItems.first(); item != 0; | 889 | for ( item=oldconflictItems.first(); item != 0; |
890 | item=oldconflictItems.next() ) { | 890 | item=oldconflictItems.next() ) { |
891 | placeSubCells(item); | 891 | placeSubCells(item); |
892 | } | 892 | } |
893 | while ( placeItem ) { | 893 | while ( placeItem ) { |
894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
895 | placeSubCells( placeItem ); | 895 | placeSubCells( placeItem ); |
896 | placeItem = placeItem->nextMultiItem(); | 896 | placeItem = placeItem->nextMultiItem(); |
897 | } | 897 | } |
898 | #endif | 898 | #endif |
899 | 899 | ||
900 | globalFlagBlockAgendaItemPaint = 1; | 900 | globalFlagBlockAgendaItemPaint = 1; |
901 | for ( item=oldconflictItems.first(); item != 0; | 901 | for ( item=oldconflictItems.first(); item != 0; |
902 | item=oldconflictItems.next() ) { | 902 | item=oldconflictItems.next() ) { |
903 | placeSubCells(item); | 903 | placeSubCells(item); |
904 | } | 904 | } |
905 | while ( placeItem ) { | 905 | while ( placeItem ) { |
906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
907 | oldconflictItems = placeItem->conflictItems(); | 907 | oldconflictItems = placeItem->conflictItems(); |
908 | for ( item=oldconflictItems.first(); item != 0; | 908 | for ( item=oldconflictItems.first(); item != 0; |
909 | item=oldconflictItems.next() ) { | 909 | item=oldconflictItems.next() ) { |
910 | placeSubCells(item); | 910 | placeSubCells(item); |
911 | } | 911 | } |
912 | placeSubCells( placeItem ); | 912 | placeSubCells( placeItem ); |
913 | placeItem = placeItem->nextMultiItem(); | 913 | placeItem = placeItem->nextMultiItem(); |
914 | } | 914 | } |
915 | globalFlagBlockAgendaItemPaint = 0; | 915 | globalFlagBlockAgendaItemPaint = 0; |
916 | for ( item=oldconflictItems.first(); item != 0; | 916 | for ( item=oldconflictItems.first(); item != 0; |
917 | item=oldconflictItems.next() ) { | 917 | item=oldconflictItems.next() ) { |
918 | globalFlagBlockAgendaItemUpdate = 0; | 918 | globalFlagBlockAgendaItemUpdate = 0; |
919 | item->repaintMe(); | 919 | item->repaintMe(); |
920 | globalFlagBlockAgendaItemUpdate = 1; | 920 | globalFlagBlockAgendaItemUpdate = 1; |
921 | item->repaint( false ); | 921 | item->repaint( false ); |
922 | } | 922 | } |
923 | placeItem = modifiedItem; | 923 | placeItem = modifiedItem; |
924 | 924 | ||
925 | while ( placeItem ) { | 925 | while ( placeItem ) { |
926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
927 | globalFlagBlockAgendaItemUpdate = 0; | 927 | globalFlagBlockAgendaItemUpdate = 0; |
928 | placeItem->repaintMe(); | 928 | placeItem->repaintMe(); |
929 | globalFlagBlockAgendaItemUpdate = 1; | 929 | globalFlagBlockAgendaItemUpdate = 1; |
930 | placeItem->repaint(false); | 930 | placeItem->repaint(false); |
931 | placeItem = placeItem->nextMultiItem(); | 931 | placeItem = placeItem->nextMultiItem(); |
932 | } | 932 | } |
933 | emit itemModified( modifiedItem, mActionType ); | 933 | emit itemModified( modifiedItem, mActionType ); |
934 | 934 | ||
935 | 935 | ||
936 | placeItem = modifiedItem; | 936 | placeItem = modifiedItem; |
937 | while ( placeItem ) { | 937 | while ( placeItem ) { |
938 | oldconflictItems = placeItem->conflictItems(); | 938 | oldconflictItems = placeItem->conflictItems(); |
939 | for ( item=oldconflictItems.first(); item != 0; | 939 | for ( item=oldconflictItems.first(); item != 0; |
940 | item=oldconflictItems.next() ) { | 940 | item=oldconflictItems.next() ) { |
941 | placeSubCells(item); | 941 | placeSubCells(item); |
942 | } | 942 | } |
943 | placeSubCells( placeItem ); | 943 | placeSubCells( placeItem ); |
944 | placeItem = placeItem->nextMultiItem(); | 944 | placeItem = placeItem->nextMultiItem(); |
945 | 945 | ||
946 | } | 946 | } |
947 | placeItem = modifiedItem; | 947 | placeItem = modifiedItem; |
948 | while ( placeItem ) { | 948 | while ( placeItem ) { |
949 | oldconflictItems = placeItem->conflictItems(); | 949 | oldconflictItems = placeItem->conflictItems(); |
950 | for ( item=oldconflictItems.first(); item != 0; | 950 | for ( item=oldconflictItems.first(); item != 0; |
951 | item=oldconflictItems.next() ) { | 951 | item=oldconflictItems.next() ) { |
952 | globalFlagBlockAgendaItemUpdate = 0; | 952 | globalFlagBlockAgendaItemUpdate = 0; |
953 | item->repaintMe(); | 953 | item->repaintMe(); |
954 | globalFlagBlockAgendaItemUpdate = 1; | 954 | globalFlagBlockAgendaItemUpdate = 1; |
955 | item->repaint(false); | 955 | item->repaint(false); |
956 | } | 956 | } |
957 | placeItem = placeItem->nextMultiItem(); | 957 | placeItem = placeItem->nextMultiItem(); |
958 | } | 958 | } |
959 | /* | 959 | /* |
960 | 960 | ||
961 | oldconflictItems = modifiedItem->conflictItems(); | 961 | oldconflictItems = modifiedItem->conflictItems(); |
962 | for ( item=oldconflictItems.first(); item != 0; | 962 | for ( item=oldconflictItems.first(); item != 0; |
963 | item=oldconflictItems.next() ) { | 963 | item=oldconflictItems.next() ) { |
964 | globalFlagBlockAgendaItemUpdate = 0; | 964 | globalFlagBlockAgendaItemUpdate = 0; |
965 | item->paintMe(false); | 965 | item->paintMe(false); |
966 | globalFlagBlockAgendaItemUpdate = 1; | 966 | globalFlagBlockAgendaItemUpdate = 1; |
967 | item->repaint(false); | 967 | item->repaint(false); |
968 | } | 968 | } |
969 | */ | 969 | */ |
970 | 970 | ||
971 | 971 | ||
972 | } | 972 | } |
973 | 973 | ||
974 | } | 974 | } |
975 | 975 | ||
976 | mScrollUpTimer.stop(); | 976 | mScrollUpTimer.stop(); |
977 | mScrollDownTimer.stop(); | 977 | mScrollDownTimer.stop(); |
978 | setCursor( arrowCursor ); | 978 | setCursor( arrowCursor ); |
979 | mActionItem = 0; | 979 | mActionItem = 0; |
980 | mActionType = NOP; | 980 | mActionType = NOP; |
981 | mItemMoved = 0; | 981 | mItemMoved = 0; |
982 | 982 | ||
983 | } | 983 | } |
984 | 984 | ||
985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
986 | { | 986 | { |
987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
988 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 988 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
990 | // point = clipper()->mapFromGlobal(point); | 990 | // point = clipper()->mapFromGlobal(point); |
991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
992 | 992 | ||
993 | int x,y; | 993 | int x,y; |
994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
996 | int gx,gy; | 996 | int gx,gy; |
997 | contentsToGrid(x,y,gx,gy); | 997 | contentsToGrid(x,y,gx,gy); |
998 | 998 | ||
999 | // Change cursor to resize cursor if appropriate | 999 | // Change cursor to resize cursor if appropriate |
1000 | if (mAllDayMode) { | 1000 | if (mAllDayMode) { |
1001 | int gridDistanceX = (x - gx * mGridSpacingX); | 1001 | int gridDistanceX = (x - gx * mGridSpacingX); |
1002 | if (gridDistanceX < mResizeBorderWidth && | 1002 | if (gridDistanceX < mResizeBorderWidth && |
1003 | moveItem->cellX() == gx) { | 1003 | moveItem->cellX() == gx) { |
1004 | setCursor(sizeHorCursor); | 1004 | setCursor(sizeHorCursor); |
1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1006 | moveItem->cellXWidth() == gx) { | 1006 | moveItem->cellXWidth() == gx) { |
1007 | setCursor(sizeHorCursor); | 1007 | setCursor(sizeHorCursor); |
1008 | } else { | 1008 | } else { |
1009 | setCursor(arrowCursor); | 1009 | setCursor(arrowCursor); |
1010 | } | 1010 | } |
1011 | } else { | 1011 | } else { |
1012 | int gridDistanceY = (y - gy * mGridSpacingY); | 1012 | int gridDistanceY = (y - gy * mGridSpacingY); |
1013 | if (gridDistanceY < mResizeBorderWidth && | 1013 | if (gridDistanceY < mResizeBorderWidth && |
1014 | moveItem->cellYTop() == gy && | 1014 | moveItem->cellYTop() == gy && |
1015 | !moveItem->firstMultiItem()) { | 1015 | !moveItem->firstMultiItem()) { |
1016 | setCursor(sizeVerCursor); | 1016 | setCursor(sizeVerCursor); |
1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1018 | moveItem->cellYBottom() == gy && | 1018 | moveItem->cellYBottom() == gy && |
1019 | !moveItem->lastMultiItem()) { | 1019 | !moveItem->lastMultiItem()) { |
1020 | setCursor(sizeVerCursor); | 1020 | setCursor(sizeVerCursor); |
1021 | } else { | 1021 | } else { |
1022 | setCursor(arrowCursor); | 1022 | setCursor(arrowCursor); |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | /* | 1028 | /* |
1029 | Place item in cell and take care that multiple items using the same cell do | 1029 | Place item in cell and take care that multiple items using the same cell do |
1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1031 | it can get in all cases. | 1031 | it can get in all cases. |
1032 | At the moment the method has a bug: When an item is placed only the sub cell | 1032 | At the moment the method has a bug: When an item is placed only the sub cell |
1033 | widths of the items are changed, which are within the Y region the item to | 1033 | widths of the items are changed, which are within the Y region the item to |
1034 | place spans. When the sub cell width change of one of this items affects a | 1034 | place spans. When the sub cell width change of one of this items affects a |
1035 | cell, where other items are, which do not overlap in Y with the item to place, | 1035 | cell, where other items are, which do not overlap in Y with the item to place, |
1036 | the display gets corrupted, although the corruption looks quite nice. | 1036 | the display gets corrupted, although the corruption looks quite nice. |
1037 | */ | 1037 | */ |
1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1039 | { | 1039 | { |
1040 | 1040 | ||
1041 | QPtrList<KOAgendaItem> conflictItems; | 1041 | QPtrList<KOAgendaItem> conflictItems; |
1042 | int maxSubCells = 0; | 1042 | int maxSubCells = 0; |
1043 | QIntDict<KOAgendaItem> subCellDict(5); | 1043 | QIntDict<KOAgendaItem> subCellDict(5); |
1044 | 1044 | ||
1045 | KOAgendaItem *item; | 1045 | KOAgendaItem *item; |
1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1047 | if (item != placeItem) { | 1047 | if (item != placeItem) { |
1048 | if (placeItem->cellX() <= item->cellXWidth() && | 1048 | if (placeItem->cellX() <= item->cellXWidth() && |
1049 | placeItem->cellXWidth() >= item->cellX()) { | 1049 | placeItem->cellXWidth() >= item->cellX()) { |
1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1051 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1051 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1052 | conflictItems.append(item); | 1052 | conflictItems.append(item); |
1053 | if (item->subCells() > maxSubCells) | 1053 | if (item->subCells() > maxSubCells) |
1054 | maxSubCells = item->subCells(); | 1054 | maxSubCells = item->subCells(); |
1055 | subCellDict.insert(item->subCell(),item); | 1055 | subCellDict.insert(item->subCell(),item); |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | if (conflictItems.count() > 0) { | 1061 | if (conflictItems.count() > 0) { |
1062 | // Look for unused sub cell and insert item | 1062 | // Look for unused sub cell and insert item |
1063 | int i; | 1063 | int i; |
1064 | for(i=0;i<maxSubCells;++i) { | 1064 | for(i=0;i<maxSubCells;++i) { |
1065 | if (!subCellDict.find(i)) { | 1065 | if (!subCellDict.find(i)) { |
1066 | placeItem->setSubCell(i); | 1066 | placeItem->setSubCell(i); |
1067 | break; | 1067 | break; |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | if (i == maxSubCells) { | 1070 | if (i == maxSubCells) { |
1071 | placeItem->setSubCell(maxSubCells); | 1071 | placeItem->setSubCell(maxSubCells); |
1072 | maxSubCells++; // add new item to number of sub cells | 1072 | maxSubCells++; // add new item to number of sub cells |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | // Prepare for sub cell geometry adjustment | 1075 | // Prepare for sub cell geometry adjustment |
1076 | int newSubCellWidth; | 1076 | int newSubCellWidth; |
1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1079 | conflictItems.append(placeItem); | 1079 | conflictItems.append(placeItem); |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | // Adjust sub cell geometry of all direct conflict items | 1082 | // Adjust sub cell geometry of all direct conflict items |
1083 | for ( item=conflictItems.first(); item != 0; | 1083 | for ( item=conflictItems.first(); item != 0; |
1084 | item=conflictItems.next() ) { | 1084 | item=conflictItems.next() ) { |
1085 | item->setSubCells(maxSubCells); | 1085 | item->setSubCells(maxSubCells); |
1086 | if (mAllDayMode) { | 1086 | if (mAllDayMode) { |
1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1088 | } else { | 1088 | } else { |
1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1090 | } | 1090 | } |
1091 | int x,y; | 1091 | int x,y; |
1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1093 | if (mAllDayMode) { | 1093 | if (mAllDayMode) { |
1094 | y += item->subCell() * newSubCellWidth; | 1094 | y += item->subCell() * newSubCellWidth; |
1095 | } else { | 1095 | } else { |
1096 | x += item->subCell() * newSubCellWidth; | 1096 | x += item->subCell() * newSubCellWidth; |
1097 | } | 1097 | } |
1098 | moveChild(item,x,y); | 1098 | moveChild(item,x,y); |
1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1100 | //item->updateItem(); | 1100 | //item->updateItem(); |
1101 | } | 1101 | } |
1102 | // Adjust sub cell geometry of all conflict items of all conflict items | 1102 | // Adjust sub cell geometry of all conflict items of all conflict items |
1103 | for ( item=conflictItems.first(); item != 0; | 1103 | for ( item=conflictItems.first(); item != 0; |
1104 | item=conflictItems.next() ) { | 1104 | item=conflictItems.next() ) { |
1105 | if ( placeItem != item ) { | 1105 | if ( placeItem != item ) { |
1106 | KOAgendaItem *item2; | 1106 | KOAgendaItem *item2; |
1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1108 | for ( item2=conflictItems2.first(); item2 != 0; | 1108 | for ( item2=conflictItems2.first(); item2 != 0; |
1109 | item2=conflictItems2.next() ) { | 1109 | item2=conflictItems2.next() ) { |
1110 | if ( item2->subCells() != maxSubCells) { | 1110 | if ( item2->subCells() != maxSubCells) { |
1111 | item2->setSubCells(maxSubCells); | 1111 | item2->setSubCells(maxSubCells); |
1112 | if (mAllDayMode) { | 1112 | if (mAllDayMode) { |
1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1114 | } else { | 1114 | } else { |
1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1116 | } | 1116 | } |
1117 | int x,y; | 1117 | int x,y; |
1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1119 | if (mAllDayMode) { | 1119 | if (mAllDayMode) { |
1120 | y += item2->subCell() * newSubCellWidth; | 1120 | y += item2->subCell() * newSubCellWidth; |
1121 | } else { | 1121 | } else { |
1122 | x += item2->subCell() * newSubCellWidth; | 1122 | x += item2->subCell() * newSubCellWidth; |
1123 | } | 1123 | } |
1124 | moveChild(item2,x,y); | 1124 | moveChild(item2,x,y); |
1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | } else { | 1130 | } else { |
1131 | placeItem->setSubCell(0); | 1131 | placeItem->setSubCell(0); |
1132 | placeItem->setSubCells(1); | 1132 | placeItem->setSubCells(1); |
1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1135 | int x,y; | 1135 | int x,y; |
1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1137 | moveChild(placeItem,x,y); | 1137 | moveChild(placeItem,x,y); |
1138 | } | 1138 | } |
1139 | placeItem->setConflictItems(conflictItems); | 1139 | placeItem->setConflictItems(conflictItems); |
1140 | // for ( item=conflictItems.first(); item != 0; | 1140 | // for ( item=conflictItems.first(); item != 0; |
1141 | // item=conflictItems.next() ) { | 1141 | // item=conflictItems.next() ) { |
1142 | // //item->updateItem(); | 1142 | // //item->updateItem(); |
1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1144 | // } | 1144 | // } |
1145 | // placeItem->updateItem(); | 1145 | // placeItem->updateItem(); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1149 | { | 1149 | { |
1150 | if ( globalFlagBlockAgenda ) | 1150 | if ( globalFlagBlockAgenda ) |
1151 | return; | 1151 | return; |
1152 | //qDebug("KOAgenda::drawContents "); | 1152 | //qDebug("KOAgenda::drawContents "); |
1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1154 | ;//drawContentsToPainter(); | 1154 | ;//drawContentsToPainter(); |
1155 | 1155 | ||
1156 | QPaintDevice* pd = p->device(); | 1156 | QPaintDevice* pd = p->device(); |
1157 | p->end(); | 1157 | p->end(); |
1158 | int vx, vy; | 1158 | int vx, vy; |
1159 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1159 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1161 | mSelectionCellX * mGridSpacingX; | 1161 | mSelectionCellX * mGridSpacingX; |
1162 | contentsToViewport ( cx, cy, vx,vy); | 1162 | contentsToViewport ( cx, cy, vx,vy); |
1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1166 | 1166 | ||
1167 | if ( mSelectionHeight > 0 ) { | 1167 | if ( mSelectionHeight > 0 ) { |
1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | //qDebug("btbl "); | 1175 | //qDebug("btbl "); |
1176 | p->begin( pd ); | 1176 | p->begin( pd ); |
1177 | //qDebug("end "); | 1177 | //qDebug("end "); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | void KOAgenda::finishUpdate() | 1180 | void KOAgenda::finishUpdate() |
1181 | { | 1181 | { |
1182 | 1182 | ||
1183 | KOAgendaItem *item; | 1183 | KOAgendaItem *item; |
1184 | globalFlagBlockAgendaItemPaint = 1; | 1184 | globalFlagBlockAgendaItemPaint = 1; |
1185 | // 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 | ||
1186 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | ||
1187 | if ( !item->checkLayout() ) { | ||
1188 | //qDebug(" conflictitem found "); | ||
1189 | int newSubCellWidth; | ||
1190 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | ||
1191 | else newSubCellWidth = mGridSpacingX / item->subCells(); | ||
1192 | |||
1193 | if (mAllDayMode) { | ||
1194 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | ||
1195 | } else { | ||
1196 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | ||
1197 | } | ||
1198 | int x,y; | ||
1199 | gridToContents(item->cellX(),item->cellYTop(),x,y); | ||
1200 | if (mAllDayMode) { | ||
1201 | y += item->subCell() * newSubCellWidth; | ||
1202 | } else { | ||
1203 | x += item->subCell() * newSubCellWidth; | ||
1204 | } | ||
1205 | moveChild(item,x,y); | ||
1206 | } | ||
1207 | } | ||
1185 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1208 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1186 | if ( !item->isVisible() ) | 1209 | if ( !item->isVisible() ) |
1187 | item->show(); | 1210 | item->show(); |
1188 | 1211 | ||
1189 | } | 1212 | } |
1190 | globalFlagBlockAgendaItemUpdate = 0; | 1213 | globalFlagBlockAgendaItemUpdate = 0; |
1191 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1214 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1192 | item->repaintMe( ); | 1215 | item->repaintMe( ); |
1193 | } | 1216 | } |
1194 | globalFlagBlockAgendaItemUpdate = 1; | 1217 | globalFlagBlockAgendaItemUpdate = 1; |
1195 | qApp->processEvents(); | 1218 | qApp->processEvents(); |
1196 | globalFlagBlockAgendaItemPaint = 0; | 1219 | globalFlagBlockAgendaItemPaint = 0; |
1197 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1220 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1198 | item->repaint( false ); | 1221 | item->repaint( false ); |
1199 | } | 1222 | } |
1200 | 1223 | ||
1201 | } | 1224 | } |
1202 | 1225 | ||
1203 | /* | 1226 | /* |
1204 | Draw grid in the background of the agenda. | 1227 | Draw grid in the background of the agenda. |
1205 | */ | 1228 | */ |
1206 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1229 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1207 | { | 1230 | { |
1208 | 1231 | ||
1209 | 1232 | ||
1210 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1233 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1211 | return; | 1234 | return; |
1212 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1235 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1213 | return; | 1236 | return; |
1214 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1237 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1215 | if ( ch < 1 ) | 1238 | if ( ch < 1 ) |
1216 | ch = 1; | 1239 | ch = 1; |
1217 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1240 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1218 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1241 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1219 | } | 1242 | } |
1220 | mCurPixWid = contentsWidth(); | 1243 | mCurPixWid = contentsWidth(); |
1221 | mCurPixHei = ch; | 1244 | mCurPixHei = ch; |
1222 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1245 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1223 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1246 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1224 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1247 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1225 | } | 1248 | } |
1226 | mPixPainter.begin( &mPaintPixmap) ; | 1249 | mPixPainter.begin( &mPaintPixmap) ; |
1227 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1250 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1228 | QPainter * p ; | 1251 | QPainter * p ; |
1229 | if (paint == 0) { | 1252 | if (paint == 0) { |
1230 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1253 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1231 | p = &mPixPainter; | 1254 | p = &mPixPainter; |
1232 | } | 1255 | } |
1233 | else | 1256 | else |
1234 | p = paint ; | 1257 | p = paint ; |
1235 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1258 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1236 | 1259 | ||
1237 | //--cx;++cw; | 1260 | //--cx;++cw; |
1238 | int lGridSpacingY = mGridSpacingY*2; | 1261 | int lGridSpacingY = mGridSpacingY*2; |
1239 | int selDay; | 1262 | int selDay; |
1240 | if ( !backgroundOnly ) | 1263 | if ( !backgroundOnly ) |
1241 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1264 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1242 | { | 1265 | { |
1243 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1266 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1244 | int x1 = cx; | 1267 | int x1 = cx; |
1245 | int y1 = 0; | 1268 | int y1 = 0; |
1246 | if (y1 < cy) y1 = cy; | 1269 | if (y1 < cy) y1 = cy; |
1247 | int x2 = cx+cw-1; | 1270 | int x2 = cx+cw-1; |
1248 | int y2 = contentsHeight(); | 1271 | int y2 = contentsHeight(); |
1249 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1272 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1250 | if (x2 >= x1 && y2 >= y1) { | 1273 | if (x2 >= x1 && y2 >= y1) { |
1251 | int gxStart = selDay; | 1274 | int gxStart = selDay; |
1252 | int gxEnd = gxStart ; | 1275 | int gxEnd = gxStart ; |
1253 | int xStart = KOGlobals::self()->reverseLayout() ? | 1276 | int xStart = KOGlobals::self()->reverseLayout() ? |
1254 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1277 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1255 | gxStart*mGridSpacingX; | 1278 | gxStart*mGridSpacingX; |
1256 | if (xStart < x1) xStart = x1; | 1279 | if (xStart < x1) xStart = x1; |
1257 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1280 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1258 | (mColumns - gxStart)*mGridSpacingX-1 : | 1281 | (mColumns - gxStart)*mGridSpacingX-1 : |
1259 | (gxStart+1)*mGridSpacingX-1; | 1282 | (gxStart+1)*mGridSpacingX-1; |
1260 | if (xEnd > x2) xEnd = x2; | 1283 | if (xEnd > x2) xEnd = x2; |
1261 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1284 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1262 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1285 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1263 | KOPrefs::instance()->mAgendaBgColor.light()); | 1286 | KOPrefs::instance()->mAgendaBgColor.light()); |
1264 | else | 1287 | else |
1265 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1288 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1266 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1289 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1267 | 1290 | ||
1268 | } | 1291 | } |
1269 | } | 1292 | } |
1270 | } | 1293 | } |
1271 | // Highlight working hours | 1294 | // Highlight working hours |
1272 | 1295 | ||
1273 | if ( !backgroundOnly ) | 1296 | if ( !backgroundOnly ) |
1274 | if (mWorkingHoursEnable) { | 1297 | if (mWorkingHoursEnable) { |
1275 | int x1 = cx; | 1298 | int x1 = cx; |
1276 | int y1 = mWorkingHoursYTop; | 1299 | int y1 = mWorkingHoursYTop; |
1277 | if (y1 < cy) y1 = cy; | 1300 | if (y1 < cy) y1 = cy; |
1278 | int x2 = cx+cw-1; | 1301 | int x2 = cx+cw-1; |
1279 | // int x2 = mGridSpacingX * 5 - 1; | 1302 | // int x2 = mGridSpacingX * 5 - 1; |
1280 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1303 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1281 | int y2 = mWorkingHoursYBottom; | 1304 | int y2 = mWorkingHoursYBottom; |
1282 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1305 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1283 | 1306 | ||
1284 | if (x2 >= x1 && y2 >= y1) { | 1307 | if (x2 >= x1 && y2 >= y1) { |
1285 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1308 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1286 | int gxStart = x1/mGridSpacingX; | 1309 | int gxStart = x1/mGridSpacingX; |
1287 | int gxEnd = x2/mGridSpacingX; | 1310 | int gxEnd = x2/mGridSpacingX; |
1288 | while(gxStart <= gxEnd) { | 1311 | while(gxStart <= gxEnd) { |
1289 | if (gxStart < int(mHolidayMask->count()) && | 1312 | if (gxStart < int(mHolidayMask->count()) && |
1290 | !mHolidayMask->at(gxStart)) { | 1313 | !mHolidayMask->at(gxStart)) { |
1291 | int xStart = KOGlobals::self()->reverseLayout() ? | 1314 | int xStart = KOGlobals::self()->reverseLayout() ? |
1292 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1315 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1293 | gxStart*mGridSpacingX; | 1316 | gxStart*mGridSpacingX; |
1294 | if (xStart < x1) xStart = x1; | 1317 | if (xStart < x1) xStart = x1; |
1295 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1318 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1296 | (mColumns - gxStart)*mGridSpacingX-1 : | 1319 | (mColumns - gxStart)*mGridSpacingX-1 : |
1297 | (gxStart+1)*mGridSpacingX-1; | 1320 | (gxStart+1)*mGridSpacingX-1; |
1298 | if (xEnd > x2) xEnd = x2; | 1321 | if (xEnd > x2) xEnd = x2; |
1299 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1322 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1300 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1323 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1301 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1324 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1302 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1325 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1303 | else | 1326 | else |
1304 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1327 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1305 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1328 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1306 | } else { | 1329 | } else { |
1307 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1330 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1308 | KOPrefs::instance()->mWorkingHoursColor); | 1331 | KOPrefs::instance()->mWorkingHoursColor); |
1309 | } | 1332 | } |
1310 | } | 1333 | } |
1311 | ++gxStart; | 1334 | ++gxStart; |
1312 | } | 1335 | } |
1313 | } | 1336 | } |
1314 | } | 1337 | } |
1315 | /* | 1338 | /* |
1316 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1339 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1317 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1340 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1318 | mSelectionCellX * mGridSpacingX; | 1341 | mSelectionCellX * mGridSpacingX; |
1319 | 1342 | ||
1320 | // Draw selection | 1343 | // Draw selection |
1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1344 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1345 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1323 | // TODO: paint only part within cx,cy,cw,ch | 1346 | // TODO: paint only part within cx,cy,cw,ch |
1324 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1347 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1325 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1348 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1326 | } | 1349 | } |
1327 | */ | 1350 | */ |
1328 | // Draw vertical lines of grid | 1351 | // Draw vertical lines of grid |
1329 | 1352 | ||
1330 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1353 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1331 | if ( mGridSpacingX > 0 ) { | 1354 | if ( mGridSpacingX > 0 ) { |
1332 | while (x < cx + cw) { | 1355 | while (x < cx + cw) { |
1333 | p->drawLine(x,cy,x,cy+ch); | 1356 | p->drawLine(x,cy,x,cy+ch); |
1334 | x+=mGridSpacingX; | 1357 | x+=mGridSpacingX; |
1335 | } | 1358 | } |
1336 | } | 1359 | } |
1337 | // Draw horizontal lines of grid | 1360 | // Draw horizontal lines of grid |
1338 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1361 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1339 | if ( lGridSpacingY > 0 ) { | 1362 | if ( lGridSpacingY > 0 ) { |
1340 | while (y < cy + ch) { | 1363 | while (y < cy + ch) { |
1341 | p->setPen( SolidLine ); | 1364 | p->setPen( SolidLine ); |
1342 | p->drawLine(cx,y,cx+cw,y); | 1365 | p->drawLine(cx,y,cx+cw,y); |
1343 | y+=lGridSpacingY; | 1366 | y+=lGridSpacingY; |
1344 | p->setPen( DotLine ); | 1367 | p->setPen( DotLine ); |
1345 | p->drawLine(cx,y,cx+cw,y); | 1368 | p->drawLine(cx,y,cx+cw,y); |
1346 | y+=lGridSpacingY; | 1369 | y+=lGridSpacingY; |
1347 | } | 1370 | } |
1348 | p->setPen( SolidLine ); | 1371 | p->setPen( SolidLine ); |
1349 | } | 1372 | } |
1350 | mPixPainter.end() ; | 1373 | mPixPainter.end() ; |
1351 | } | 1374 | } |
1352 | 1375 | ||
1353 | /* | 1376 | /* |
1354 | Convert srcollview contents coordinates to agenda grid coordinates. | 1377 | Convert srcollview contents coordinates to agenda grid coordinates. |
1355 | */ | 1378 | */ |
1356 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1379 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1357 | { | 1380 | { |
1358 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1381 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1359 | x/mGridSpacingX; | 1382 | x/mGridSpacingX; |
1360 | gy = y/mGridSpacingY; | 1383 | gy = y/mGridSpacingY; |
1361 | } | 1384 | } |
1362 | 1385 | ||
1363 | /* | 1386 | /* |
1364 | Convert agenda grid coordinates to scrollview contents coordinates. | 1387 | Convert agenda grid coordinates to scrollview contents coordinates. |
1365 | */ | 1388 | */ |
1366 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1389 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1367 | { | 1390 | { |
1368 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1391 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1369 | gx*mGridSpacingX; | 1392 | gx*mGridSpacingX; |
1370 | y = gy*mGridSpacingY; | 1393 | y = gy*mGridSpacingY; |
1371 | } | 1394 | } |
1372 | 1395 | ||
1373 | 1396 | ||
1374 | /* | 1397 | /* |
1375 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1398 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1376 | the grid. | 1399 | the grid. |
1377 | */ | 1400 | */ |
1378 | int KOAgenda::timeToY(const QTime &time) | 1401 | int KOAgenda::timeToY(const QTime &time) |
1379 | { | 1402 | { |
1380 | int minutesPerCell = 24 * 60 / mRows; | 1403 | int minutesPerCell = 24 * 60 / mRows; |
1381 | int timeMinutes = time.hour() * 60 + time.minute(); | 1404 | int timeMinutes = time.hour() * 60 + time.minute(); |
1382 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1405 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1383 | return Y; | 1406 | return Y; |
1384 | } | 1407 | } |
1385 | 1408 | ||
1386 | 1409 | ||
1387 | /* | 1410 | /* |
1388 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1411 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1389 | fit into the grid. | 1412 | fit into the grid. |
1390 | */ | 1413 | */ |
1391 | QTime KOAgenda::gyToTime(int gy) | 1414 | QTime KOAgenda::gyToTime(int gy) |
1392 | { | 1415 | { |
1393 | 1416 | ||
1394 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1417 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1395 | 1418 | ||
1396 | int timeSeconds = secondsPerCell * gy; | 1419 | int timeSeconds = secondsPerCell * gy; |
1397 | 1420 | ||
1398 | QTime time( 0, 0, 0 ); | 1421 | QTime time( 0, 0, 0 ); |
1399 | if ( timeSeconds < 24 * 60 * 60 ) { | 1422 | if ( timeSeconds < 24 * 60 * 60 ) { |
1400 | time = time.addSecs(timeSeconds); | 1423 | time = time.addSecs(timeSeconds); |
1401 | } else { | 1424 | } else { |
1402 | time.setHMS( 23, 59, 59 ); | 1425 | time.setHMS( 23, 59, 59 ); |
1403 | } | 1426 | } |
1404 | 1427 | ||
1405 | return time; | 1428 | return time; |
1406 | } | 1429 | } |
1407 | 1430 | ||
1408 | void KOAgenda::setStartHour(int startHour) | 1431 | void KOAgenda::setStartHour(int startHour) |
1409 | { | 1432 | { |
1410 | int startCell = startHour * mRows / 24; | 1433 | int startCell = startHour * mRows / 24; |
1411 | setContentsPos(0,startCell * gridSpacingY()); | 1434 | setContentsPos(0,startCell * gridSpacingY()); |
1412 | } | 1435 | } |
1413 | void KOAgenda::hideUnused() | 1436 | void KOAgenda::hideUnused() |
1414 | { | 1437 | { |
1415 | // experimental only | 1438 | // experimental only |
1416 | // return; | 1439 | // return; |
1417 | KOAgendaItem *item; | 1440 | KOAgendaItem *item; |
1418 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1441 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1419 | item->hide(); | 1442 | item->hide(); |
1420 | } | 1443 | } |
1421 | } | 1444 | } |
1422 | 1445 | ||
1423 | 1446 | ||
1424 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1447 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1425 | { | 1448 | { |
1426 | 1449 | ||
1427 | KOAgendaItem *fi; | 1450 | KOAgendaItem *fi; |
1428 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1451 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1429 | if ( fi->incidence() == event ) { | 1452 | if ( fi->incidence() == event ) { |
1430 | mUnusedItems.remove(); | 1453 | mUnusedItems.remove(); |
1431 | fi->init( event, qd ); | 1454 | fi->init( event, qd ); |
1432 | return fi; | 1455 | return fi; |
1433 | } | 1456 | } |
1434 | } | 1457 | } |
1435 | fi=mUnusedItems.first(); | 1458 | fi=mUnusedItems.first(); |
1436 | if ( fi ) { | 1459 | if ( fi ) { |
1437 | mUnusedItems.remove(); | 1460 | mUnusedItems.remove(); |
1438 | fi->init( event, qd ); | 1461 | fi->init( event, qd ); |
1439 | return fi; | 1462 | return fi; |
1440 | } | 1463 | } |
1441 | // qDebug("new KOAgendaItem "); | 1464 | // qDebug("new KOAgendaItem "); |
1442 | 1465 | ||
1443 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1466 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1444 | agendaItem->installEventFilter(this); | 1467 | agendaItem->installEventFilter(this); |
1445 | addChild(agendaItem,0,0); | 1468 | addChild(agendaItem,0,0); |
1446 | return agendaItem; | 1469 | return agendaItem; |
1447 | } | 1470 | } |
1448 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1471 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1449 | { | 1472 | { |
1450 | KOAgendaItem *item; | 1473 | KOAgendaItem *item; |
1451 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1474 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1452 | if ( item->incidence() == todo ) { | 1475 | if ( item->incidence() == todo ) { |
1453 | mItems.remove(); | 1476 | mItems.remove(); |
1454 | return item; | 1477 | return item; |
1455 | } | 1478 | } |
1456 | } | 1479 | } |
1457 | return 0; | 1480 | return 0; |
1458 | } | 1481 | } |
1459 | 1482 | ||
1460 | 1483 | ||
1461 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1484 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1462 | { | 1485 | { |
1463 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1486 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1464 | KOAgendaItem *item; | 1487 | KOAgendaItem *item; |
1465 | item = getItemForTodo ( todo ); | 1488 | item = getItemForTodo ( todo ); |
1466 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1489 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1467 | if ( item ) { | 1490 | if ( item ) { |
1468 | blockSignals( true ); | 1491 | blockSignals( true ); |
1469 | //qDebug("item found "); | 1492 | //qDebug("item found "); |
1470 | item->hide(); | 1493 | item->hide(); |
1471 | item->setCellX(-2, -1 ); | 1494 | item->setCellX(-2, -1 ); |
1472 | item->select(false); | 1495 | item->select(false); |
1473 | mUnusedItems.append( item ); | 1496 | mUnusedItems.append( item ); |
1474 | mItems.remove( item ); | 1497 | mItems.remove( item ); |
1475 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1498 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1476 | KOAgendaItem *itemit; | 1499 | KOAgendaItem *itemit; |
1477 | //globalFlagBlockAgendaItemPaint = 1; | 1500 | //globalFlagBlockAgendaItemPaint = 1; |
1478 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1501 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1479 | itemit=oldconflictItems.next() ) { | 1502 | itemit=oldconflictItems.next() ) { |
1480 | if ( itemit != item ) | 1503 | if ( itemit != item ) |
1481 | placeSubCells(itemit); | 1504 | placeSubCells(itemit); |
1482 | } | 1505 | } |
1483 | qApp->processEvents(); | 1506 | qApp->processEvents(); |
1484 | //globalFlagBlockAgendaItemPaint = 0; | 1507 | //globalFlagBlockAgendaItemPaint = 0; |
1485 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1508 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1486 | itemit=oldconflictItems.next() ) { | 1509 | itemit=oldconflictItems.next() ) { |
1487 | globalFlagBlockAgendaItemUpdate = 0; | 1510 | globalFlagBlockAgendaItemUpdate = 0; |
1488 | if ( itemit != item ) | 1511 | if ( itemit != item ) |
1489 | itemit->repaintMe(); | 1512 | itemit->repaintMe(); |
1490 | globalFlagBlockAgendaItemUpdate = 1; | 1513 | globalFlagBlockAgendaItemUpdate = 1; |
1491 | itemit->repaint(); | 1514 | itemit->repaint(); |
1492 | } | 1515 | } |
1493 | blockSignals( false ); | 1516 | blockSignals( false ); |
1494 | } | 1517 | } |
1495 | if ( remove ) { | 1518 | if ( remove ) { |
1496 | //qDebug("remove****************************************** "); | 1519 | //qDebug("remove****************************************** "); |
1497 | return; | 1520 | return; |
1498 | } | 1521 | } |
1499 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1522 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1500 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1523 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1501 | QDate currentDate; | 1524 | QDate currentDate; |
1502 | QDateTime dt; | 1525 | QDateTime dt; |
1503 | if ( todo->hasCompletedDate() ) | 1526 | if ( todo->hasCompletedDate() ) |
1504 | dt = todo->completed(); | 1527 | dt = todo->completed(); |
1505 | else | 1528 | else |
1506 | dt = todo->dtDue(); | 1529 | dt = todo->dtDue(); |
1507 | if ( overdue ) { | 1530 | if ( overdue ) { |
1508 | currentDate = QDate::currentDate(); | 1531 | currentDate = QDate::currentDate(); |
1509 | days += todo->dtDue().date().daysTo( currentDate ); | 1532 | days += todo->dtDue().date().daysTo( currentDate ); |
1510 | } | 1533 | } |
1511 | else | 1534 | else |
1512 | currentDate = dt.date(); | 1535 | currentDate = dt.date(); |
1513 | 1536 | ||
1514 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1537 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1515 | if ( ! mAllDayMode ) return; | 1538 | if ( ! mAllDayMode ) return; |
1516 | // aldayagenda | 1539 | // aldayagenda |
1517 | globalFlagBlockAgendaItemPaint = 1; | 1540 | globalFlagBlockAgendaItemPaint = 1; |
1518 | item = insertAllDayItem(todo, currentDate,days, days); | 1541 | item = insertAllDayItem(todo, currentDate,days, days); |
1519 | item->show(); | 1542 | item->show(); |
1520 | 1543 | ||
1521 | } | 1544 | } |
1522 | else { | 1545 | else { |
1523 | if ( mAllDayMode ) return; | 1546 | if ( mAllDayMode ) return; |
1524 | // mAgenda | 1547 | // mAgenda |
1525 | globalFlagBlockAgendaItemPaint = 1; | 1548 | globalFlagBlockAgendaItemPaint = 1; |
1526 | int endY = timeToY(dt.time()) - 1; | 1549 | int endY = timeToY(dt.time()) - 1; |
1527 | int hi = 12/KOPrefs::instance()->mHourSize; | 1550 | int hi = 12/KOPrefs::instance()->mHourSize; |
1528 | int startY = endY - 1-hi; | 1551 | int startY = endY - 1-hi; |
1529 | item = insertItem(todo,currentDate,days,startY,endY); | 1552 | item = insertItem(todo,currentDate,days,startY,endY); |
1530 | item->show(); | 1553 | item->show(); |
1531 | } | 1554 | } |
1532 | qApp->processEvents(); | 1555 | qApp->processEvents(); |
1533 | globalFlagBlockAgendaItemPaint = 0; | 1556 | globalFlagBlockAgendaItemPaint = 0; |
1534 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1557 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1535 | KOAgendaItem *itemit; | 1558 | KOAgendaItem *itemit; |
1536 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1559 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1537 | itemit=oldconflictItems.next() ) { | 1560 | itemit=oldconflictItems.next() ) { |
1538 | globalFlagBlockAgendaItemUpdate = 0; | 1561 | globalFlagBlockAgendaItemUpdate = 0; |
1539 | itemit->repaintMe(); | 1562 | itemit->repaintMe(); |
1540 | globalFlagBlockAgendaItemUpdate = 1; | 1563 | globalFlagBlockAgendaItemUpdate = 1; |
1541 | itemit->repaint(); | 1564 | itemit->repaint(); |
1542 | } | 1565 | } |
1543 | globalFlagBlockAgendaItemUpdate = 0; | 1566 | globalFlagBlockAgendaItemUpdate = 0; |
1544 | item->repaintMe(); | 1567 | item->repaintMe(); |
1545 | globalFlagBlockAgendaItemUpdate = 1; | 1568 | globalFlagBlockAgendaItemUpdate = 1; |
1546 | item->repaint(); | 1569 | item->repaint(); |
1547 | } | 1570 | } |
1548 | /* | 1571 | /* |
1549 | Insert KOAgendaItem into agenda. | 1572 | Insert KOAgendaItem into agenda. |
1550 | */ | 1573 | */ |
1551 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1574 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1552 | { | 1575 | { |
1553 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1576 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1554 | 1577 | ||
1555 | if (mAllDayMode) { | 1578 | if (mAllDayMode) { |
1556 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1579 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1557 | return 0; | 1580 | return 0; |
1558 | } | 1581 | } |
1559 | 1582 | ||
1560 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1583 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1561 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1584 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1562 | 1585 | ||
1563 | int YSize = YBottom - YTop + 1; | 1586 | int YSize = YBottom - YTop + 1; |
1564 | if (YSize < 0) { | 1587 | if (YSize < 0) { |
1565 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1588 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1566 | YSize = 1; | 1589 | YSize = 1; |
1567 | } | 1590 | } |
1568 | int iheight = mGridSpacingY * YSize; | 1591 | int iheight = mGridSpacingY * YSize; |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 38bd93a..042a789 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -383,384 +383,402 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | |||
383 | if ( nfh < h -2 ) | 383 | if ( nfh < h -2 ) |
384 | ++yy; | 384 | ++yy; |
385 | } | 385 | } |
386 | int align; | 386 | int align; |
387 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
388 | align = ( AlignLeft|WordBreak|AlignTop); | 388 | align = ( AlignLeft|WordBreak|AlignTop); |
389 | #else | 389 | #else |
390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
391 | #endif | 391 | #endif |
392 | if ( addIcon ) { | 392 | if ( addIcon ) { |
393 | if ( ! horLayout ) { | 393 | if ( ! horLayout ) { |
394 | x += AGENDA_ICON_SIZE+3; | 394 | x += AGENDA_ICON_SIZE+3; |
395 | w -= (AGENDA_ICON_SIZE+3); | 395 | w -= (AGENDA_ICON_SIZE+3); |
396 | } | 396 | } |
397 | else { | 397 | else { |
398 | yy+= AGENDA_ICON_SIZE+2; | 398 | yy+= AGENDA_ICON_SIZE+2; |
399 | h -=(AGENDA_ICON_SIZE+3); | 399 | h -=(AGENDA_ICON_SIZE+3); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
403 | if ( colsum < 250 ) | 403 | if ( colsum < 250 ) |
404 | paint->setPen ( white); | 404 | paint->setPen ( white); |
405 | if ( x < 0 ) { | 405 | if ( x < 0 ) { |
406 | w = w+x-3; | 406 | w = w+x-3; |
407 | x = 3; | 407 | x = 3; |
408 | if ( w > parentWidget()->width() ){ | 408 | if ( w > parentWidget()->width() ){ |
409 | w = parentWidget()->width() - 6; | 409 | w = parentWidget()->width() - 6; |
410 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
411 | align = ( AlignHCenter|WordBreak|AlignTop); | 411 | align = ( AlignHCenter|WordBreak|AlignTop); |
412 | #else | 412 | #else |
413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | } | 416 | } |
417 | } | 417 | } |
418 | QRect dr; | 418 | QRect dr; |
419 | if ( w + x > parentWidget()->width() ) | 419 | if ( w + x > parentWidget()->width() ) |
420 | w = parentWidget()->width()-x; | 420 | w = parentWidget()->width()-x; |
421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
422 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 422 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
423 | if ( mIncidence->cancelled() ){ | 423 | if ( mIncidence->cancelled() ){ |
424 | if ( ! small ) { | 424 | if ( ! small ) { |
425 | QFontMetrics fm ( paint->font() ); | 425 | QFontMetrics fm ( paint->font() ); |
426 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 426 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
427 | } | 427 | } |
428 | 428 | ||
429 | } | 429 | } |
430 | pa.end(); | 430 | pa.end(); |
431 | 431 | ||
432 | } | 432 | } |
433 | void KOAgendaItem::resizePixmap( int w , int h ) | 433 | void KOAgendaItem::resizePixmap( int w , int h ) |
434 | { | 434 | { |
435 | paintPix()->resize( w, h ); | 435 | paintPix()->resize( w, h ); |
436 | paintPixSel()->resize( w, h ); | 436 | paintPixSel()->resize( w, h ); |
437 | 437 | ||
438 | } | 438 | } |
439 | QPixmap * KOAgendaItem::paintPix() | 439 | QPixmap * KOAgendaItem::paintPix() |
440 | { | 440 | { |
441 | static QPixmap* mPaintPix = 0; | 441 | static QPixmap* mPaintPix = 0; |
442 | if ( ! mPaintPix ) | 442 | if ( ! mPaintPix ) |
443 | mPaintPix = new QPixmap(1,1); | 443 | mPaintPix = new QPixmap(1,1); |
444 | return mPaintPix ; | 444 | return mPaintPix ; |
445 | } | 445 | } |
446 | QPixmap * KOAgendaItem::paintPixAllday() | 446 | QPixmap * KOAgendaItem::paintPixAllday() |
447 | { | 447 | { |
448 | static QPixmap* mPaintPixA = 0; | 448 | static QPixmap* mPaintPixA = 0; |
449 | if ( ! mPaintPixA ) | 449 | if ( ! mPaintPixA ) |
450 | mPaintPixA = new QPixmap(1,1); | 450 | mPaintPixA = new QPixmap(1,1); |
451 | return mPaintPixA ; | 451 | return mPaintPixA ; |
452 | } | 452 | } |
453 | QPixmap * KOAgendaItem::paintPixSel() | 453 | QPixmap * KOAgendaItem::paintPixSel() |
454 | { | 454 | { |
455 | static QPixmap* mPaintPixSel = 0; | 455 | static QPixmap* mPaintPixSel = 0; |
456 | if ( ! mPaintPixSel ) | 456 | if ( ! mPaintPixSel ) |
457 | mPaintPixSel = new QPixmap(1,1); | 457 | mPaintPixSel = new QPixmap(1,1); |
458 | return mPaintPixSel ; | 458 | return mPaintPixSel ; |
459 | } | 459 | } |
460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
461 | { | 461 | { |
462 | 462 | ||
463 | if ( globalFlagBlockAgendaItemPaint ) | 463 | if ( globalFlagBlockAgendaItemPaint ) |
464 | return; | 464 | return; |
465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
466 | return; | 466 | return; |
467 | int yy; | 467 | int yy; |
468 | if ( mAllDay ) | 468 | if ( mAllDay ) |
469 | yy = y(); | 469 | yy = y(); |
470 | else | 470 | else |
471 | yy = mCellYTop * ( height() / cellHeight() ); | 471 | yy = mCellYTop * ( height() / cellHeight() ); |
472 | int xx = x(); | 472 | int xx = x(); |
473 | if ( xPaintCoord != xx || yPaintCoord != yy || | 473 | if ( xPaintCoord != xx || yPaintCoord != yy || |
474 | wPaintCoord != width() || hPaintCoord != height()) { | 474 | wPaintCoord != width() || hPaintCoord != height()) { |
475 | xPaintCoord= xx; | 475 | xPaintCoord= xx; |
476 | yPaintCoord = yy; | 476 | yPaintCoord = yy; |
477 | wPaintCoord = width(); | 477 | wPaintCoord = width(); |
478 | hPaintCoord = height(); | 478 | hPaintCoord = height(); |
479 | globalFlagBlockAgendaItemUpdate = 0; | 479 | globalFlagBlockAgendaItemUpdate = 0; |
480 | paintMe( mSelected ); | 480 | paintMe( mSelected ); |
481 | //qDebug("calling paintMe "); | 481 | //qDebug("calling paintMe "); |
482 | globalFlagBlockAgendaItemUpdate = 1; | 482 | globalFlagBlockAgendaItemUpdate = 1; |
483 | } | 483 | } |
484 | int rx, ry, rw, rh; | 484 | int rx, ry, rw, rh; |
485 | rx = e->rect().x(); | 485 | rx = e->rect().x(); |
486 | ry = e->rect().y(); | 486 | ry = e->rect().y(); |
487 | rw = e->rect().width(); | 487 | rw = e->rect().width(); |
488 | rh = e->rect().height(); | 488 | rh = e->rect().height(); |
489 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 489 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
490 | 490 | ||
491 | QPixmap* paintFrom ; | 491 | QPixmap* paintFrom ; |
492 | if ( mSelected ) { | 492 | if ( mSelected ) { |
493 | paintFrom = paintPixSel(); | 493 | paintFrom = paintPixSel(); |
494 | } else { | 494 | } else { |
495 | if ( mAllDay ) | 495 | if ( mAllDay ) |
496 | paintFrom = paintPixAllday(); | 496 | paintFrom = paintPixAllday(); |
497 | else | 497 | else |
498 | paintFrom = paintPix(); | 498 | paintFrom = paintPix(); |
499 | } | 499 | } |
500 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 500 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
501 | } | 501 | } |
502 | void KOAgendaItem::computeText() | 502 | void KOAgendaItem::computeText() |
503 | { | 503 | { |
504 | 504 | ||
505 | mDisplayedText = mIncidence->summary(); | 505 | mDisplayedText = mIncidence->summary(); |
506 | if ( (mIncidence->type() == "Todo") ) { | 506 | if ( (mIncidence->type() == "Todo") ) { |
507 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 507 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
508 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 508 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
509 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 509 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
510 | else if ( !(mIncidence->doesFloat())) | 510 | else if ( !(mIncidence->doesFloat())) |
511 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 511 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
512 | } | 512 | } |
513 | } else { | 513 | } else { |
514 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 514 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
515 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 515 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
516 | 516 | ||
517 | if ( mAllDay ) { | 517 | if ( mAllDay ) { |
518 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 518 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
519 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 519 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !mIncidence->location().isEmpty() ) { | 525 | if ( !mIncidence->location().isEmpty() ) { |
526 | if ( mAllDay ) | 526 | if ( mAllDay ) |
527 | mDisplayedText += " ("; | 527 | mDisplayedText += " ("; |
528 | else | 528 | else |
529 | mDisplayedText += "\n("; | 529 | mDisplayedText += "\n("; |
530 | mDisplayedText += mIncidence->location() +")"; | 530 | mDisplayedText += mIncidence->location() +")"; |
531 | } | 531 | } |
532 | 532 | ||
533 | QString tipText = mIncidence->summary(); | 533 | QString tipText = mIncidence->summary(); |
534 | if ( !mIncidence->doesFloat() ) { | 534 | if ( !mIncidence->doesFloat() ) { |
535 | if ( mIncidence->type() == "Event" ) { | 535 | if ( mIncidence->type() == "Event" ) { |
536 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 536 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
537 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 537 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
538 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 538 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
539 | } | 539 | } |
540 | else { | 540 | else { |
541 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 541 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
542 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 542 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | else if ( mIncidence->type() == "Todo" ) { | 545 | else if ( mIncidence->type() == "Todo" ) { |
546 | if (mIncidence->hasStartDate()) | 546 | if (mIncidence->hasStartDate()) |
547 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 547 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
548 | if (((Todo*)mIncidence)->hasDueDate()) | 548 | if (((Todo*)mIncidence)->hasDueDate()) |
549 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 549 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
550 | } | 550 | } |
551 | } else if ( mIncidence->type() == "Todo" ) { | 551 | } else if ( mIncidence->type() == "Todo" ) { |
552 | if (mIncidence->hasStartDate()) | 552 | if (mIncidence->hasStartDate()) |
553 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 553 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
554 | if (((Todo*)mIncidence)->hasDueDate()) | 554 | if (((Todo*)mIncidence)->hasDueDate()) |
555 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 555 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
556 | } | 556 | } |
557 | 557 | ||
558 | if (!mIncidence->location().isEmpty()) { | 558 | if (!mIncidence->location().isEmpty()) { |
559 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 559 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
560 | } | 560 | } |
561 | QToolTip::add(this,tipText,toolTipGroup(),""); | 561 | QToolTip::add(this,tipText,toolTipGroup(),""); |
562 | 562 | ||
563 | } | 563 | } |
564 | void KOAgendaItem::updateItem() | 564 | void KOAgendaItem::updateItem() |
565 | { | 565 | { |
566 | computeText(); | 566 | computeText(); |
567 | 567 | ||
568 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 568 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
569 | paintMe( mSelected ); | 569 | paintMe( mSelected ); |
570 | repaint( false); | 570 | repaint( false); |
571 | } | 571 | } |
572 | 572 | ||
573 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 573 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
574 | { | 574 | { |
575 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 575 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
576 | paintMe( mSelected ); | 576 | paintMe( mSelected ); |
577 | repaint( false ); | 577 | repaint( false ); |
578 | } | 578 | } |
579 | 579 | ||
580 | /* | 580 | /* |
581 | Return height of item in units of agenda cells | 581 | Return height of item in units of agenda cells |
582 | */ | 582 | */ |
583 | int KOAgendaItem::cellHeight() | 583 | int KOAgendaItem::cellHeight() |
584 | { | 584 | { |
585 | int ret = mCellYBottom - mCellYTop + 1; | 585 | int ret = mCellYBottom - mCellYTop + 1; |
586 | if ( ret <= 0 ) { | 586 | if ( ret <= 0 ) { |
587 | ret = 1; | 587 | ret = 1; |
588 | mCellYBottom = 0; | 588 | mCellYBottom = 0; |
589 | mCellYTop = 0; | 589 | mCellYTop = 0; |
590 | } | 590 | } |
591 | return ret; | 591 | return ret; |
592 | } | 592 | } |
593 | 593 | ||
594 | /* | 594 | /* |
595 | Return height of item in units of agenda cells | 595 | Return height of item in units of agenda cells |
596 | */ | 596 | */ |
597 | int KOAgendaItem::cellWidth() | 597 | int KOAgendaItem::cellWidth() |
598 | { | 598 | { |
599 | return mCellXWidth - mCellX + 1; | 599 | return mCellXWidth - mCellX + 1; |
600 | } | 600 | } |
601 | 601 | ||
602 | void KOAgendaItem::setItemDate(QDate qd) | 602 | void KOAgendaItem::setItemDate(QDate qd) |
603 | { | 603 | { |
604 | mDate = qd; | 604 | mDate = qd; |
605 | } | 605 | } |
606 | 606 | ||
607 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 607 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
608 | { | 608 | { |
609 | mCellX = X; | 609 | mCellX = X; |
610 | mCellYTop = YTop; | 610 | mCellYTop = YTop; |
611 | mCellYBottom = YBottom; | 611 | mCellYBottom = YBottom; |
612 | } | 612 | } |
613 | 613 | ||
614 | void KOAgendaItem::setCellXWidth(int xwidth) | 614 | void KOAgendaItem::setCellXWidth(int xwidth) |
615 | { | 615 | { |
616 | mCellXWidth = xwidth; | 616 | mCellXWidth = xwidth; |
617 | } | 617 | } |
618 | 618 | ||
619 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 619 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
620 | { | 620 | { |
621 | mCellX = XLeft; | 621 | mCellX = XLeft; |
622 | mCellXWidth = XRight; | 622 | mCellXWidth = XRight; |
623 | } | 623 | } |
624 | 624 | ||
625 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 625 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
626 | { | 626 | { |
627 | mCellYTop = YTop; | 627 | mCellYTop = YTop; |
628 | mCellYBottom = YBottom; | 628 | mCellYBottom = YBottom; |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOAgendaItem::setSubCell(int subCell) | 631 | void KOAgendaItem::setSubCell(int subCell) |
632 | { | 632 | { |
633 | mSubCell = subCell; | 633 | mSubCell = subCell; |
634 | } | 634 | } |
635 | 635 | ||
636 | void KOAgendaItem::setSubCells(int subCells) | 636 | void KOAgendaItem::setSubCells(int subCells) |
637 | { | 637 | { |
638 | mSubCells = subCells; | 638 | mSubCells = subCells; |
639 | } | 639 | } |
640 | 640 | ||
641 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 641 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
642 | KOAgendaItem *last) | 642 | KOAgendaItem *last) |
643 | { | 643 | { |
644 | mFirstMultiItem = first; | 644 | mFirstMultiItem = first; |
645 | mNextMultiItem = next; | 645 | mNextMultiItem = next; |
646 | mLastMultiItem = last; | 646 | mLastMultiItem = last; |
647 | } | 647 | } |
648 | 648 | ||
649 | void KOAgendaItem::startMove() | 649 | void KOAgendaItem::startMove() |
650 | { | 650 | { |
651 | mStartCellX = mCellX; | 651 | mStartCellX = mCellX; |
652 | mStartCellXWidth = mCellXWidth; | 652 | mStartCellXWidth = mCellXWidth; |
653 | mStartCellYTop = mCellYTop; | 653 | mStartCellYTop = mCellYTop; |
654 | mStartCellYBottom = mCellYBottom; | 654 | mStartCellYBottom = mCellYBottom; |
655 | } | 655 | } |
656 | 656 | ||
657 | void KOAgendaItem::resetMove() | 657 | void KOAgendaItem::resetMove() |
658 | { | 658 | { |
659 | mCellX = mStartCellX; | 659 | mCellX = mStartCellX; |
660 | mCellXWidth = mStartCellXWidth; | 660 | mCellXWidth = mStartCellXWidth; |
661 | mCellYTop = mStartCellYTop; | 661 | mCellYTop = mStartCellYTop; |
662 | mCellYBottom = mStartCellYBottom; | 662 | mCellYBottom = mStartCellYBottom; |
663 | } | 663 | } |
664 | 664 | ||
665 | void KOAgendaItem::moveRelative(int dx, int dy) | 665 | void KOAgendaItem::moveRelative(int dx, int dy) |
666 | { | 666 | { |
667 | int newX = cellX() + dx; | 667 | int newX = cellX() + dx; |
668 | int newXWidth = cellXWidth() + dx; | 668 | int newXWidth = cellXWidth() + dx; |
669 | int newYTop = cellYTop() + dy; | 669 | int newYTop = cellYTop() + dy; |
670 | int newYBottom = cellYBottom() + dy; | 670 | int newYBottom = cellYBottom() + dy; |
671 | setCellXY(newX,newYTop,newYBottom); | 671 | setCellXY(newX,newYTop,newYBottom); |
672 | setCellXWidth(newXWidth); | 672 | setCellXWidth(newXWidth); |
673 | } | 673 | } |
674 | 674 | ||
675 | void KOAgendaItem::expandTop(int dy) | 675 | void KOAgendaItem::expandTop(int dy) |
676 | { | 676 | { |
677 | int newYTop = cellYTop() + dy; | 677 | int newYTop = cellYTop() + dy; |
678 | int newYBottom = cellYBottom(); | 678 | int newYBottom = cellYBottom(); |
679 | if (newYTop > newYBottom) newYTop = newYBottom; | 679 | if (newYTop > newYBottom) newYTop = newYBottom; |
680 | setCellY(newYTop, newYBottom); | 680 | setCellY(newYTop, newYBottom); |
681 | } | 681 | } |
682 | 682 | ||
683 | void KOAgendaItem::expandBottom(int dy) | 683 | void KOAgendaItem::expandBottom(int dy) |
684 | { | 684 | { |
685 | int newYTop = cellYTop(); | 685 | int newYTop = cellYTop(); |
686 | int newYBottom = cellYBottom() + dy; | 686 | int newYBottom = cellYBottom() + dy; |
687 | if (newYBottom < newYTop) newYBottom = newYTop; | 687 | if (newYBottom < newYTop) newYBottom = newYTop; |
688 | setCellY(newYTop, newYBottom); | 688 | setCellY(newYTop, newYBottom); |
689 | } | 689 | } |
690 | 690 | ||
691 | void KOAgendaItem::expandLeft(int dx) | 691 | void KOAgendaItem::expandLeft(int dx) |
692 | { | 692 | { |
693 | int newX = cellX() + dx; | 693 | int newX = cellX() + dx; |
694 | int newXWidth = cellXWidth(); | 694 | int newXWidth = cellXWidth(); |
695 | if (newX > newXWidth) newX = newXWidth; | 695 | if (newX > newXWidth) newX = newXWidth; |
696 | setCellX(newX,newXWidth); | 696 | setCellX(newX,newXWidth); |
697 | } | 697 | } |
698 | 698 | ||
699 | void KOAgendaItem::expandRight(int dx) | 699 | void KOAgendaItem::expandRight(int dx) |
700 | { | 700 | { |
701 | int newX = cellX(); | 701 | int newX = cellX(); |
702 | int newXWidth = cellXWidth() + dx; | 702 | int newXWidth = cellXWidth() + dx; |
703 | if (newXWidth < newX) newXWidth = newX; | 703 | if (newXWidth < newX) newXWidth = newX; |
704 | setCellX(newX,newXWidth); | 704 | setCellX(newX,newXWidth); |
705 | } | 705 | } |
706 | 706 | ||
707 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 707 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
708 | { | 708 | { |
709 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 709 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
710 | return mToolTipGroup; | 710 | return mToolTipGroup; |
711 | } | 711 | } |
712 | 712 | ||
713 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 713 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
714 | { | 714 | { |
715 | #ifndef KORG_NODND | 715 | #ifndef KORG_NODND |
716 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 716 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
717 | !QTextDrag::canDecode( e ) ) { | 717 | !QTextDrag::canDecode( e ) ) { |
718 | e->ignore(); | 718 | e->ignore(); |
719 | return; | 719 | return; |
720 | } | 720 | } |
721 | e->accept(); | 721 | e->accept(); |
722 | #endif | 722 | #endif |
723 | } | 723 | } |
724 | 724 | ||
725 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 725 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
726 | { | 726 | { |
727 | #ifndef KORG_NODND | 727 | #ifndef KORG_NODND |
728 | QString text; | 728 | QString text; |
729 | if(QTextDrag::decode(e,text)) | 729 | if(QTextDrag::decode(e,text)) |
730 | { | 730 | { |
731 | kdDebug() << "Dropped : " << text << endl; | 731 | kdDebug() << "Dropped : " << text << endl; |
732 | QStringList emails = QStringList::split(",",text); | 732 | QStringList emails = QStringList::split(",",text); |
733 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 733 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
734 | kdDebug() << " Email: " << (*it) << endl; | 734 | kdDebug() << " Email: " << (*it) << endl; |
735 | int pos = (*it).find("<"); | 735 | int pos = (*it).find("<"); |
736 | QString name = (*it).left(pos); | 736 | QString name = (*it).left(pos); |
737 | QString email = (*it).mid(pos); | 737 | QString email = (*it).mid(pos); |
738 | if (!email.isEmpty()) { | 738 | if (!email.isEmpty()) { |
739 | mIncidence->addAttendee(new Attendee(name,email)); | 739 | mIncidence->addAttendee(new Attendee(name,email)); |
740 | } | 740 | } |
741 | } | 741 | } |
742 | } | 742 | } |
743 | #endif | 743 | #endif |
744 | } | 744 | } |
745 | 745 | ||
746 | 746 | ||
747 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 747 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
748 | { | 748 | { |
749 | return mConflictItems; | 749 | return mConflictItems; |
750 | } | 750 | } |
751 | 751 | ||
752 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 752 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
753 | { | 753 | { |
754 | mConflictItems = ci; | 754 | mConflictItems = ci; |
755 | KOAgendaItem *item; | 755 | KOAgendaItem *item; |
756 | for ( item=mConflictItems.first(); item != 0; | 756 | for ( item=mConflictItems.first(); item != 0; |
757 | item=mConflictItems.next() ) { | 757 | item=mConflictItems.next() ) { |
758 | item->addConflictItem(this); | 758 | item->addConflictItem(this); |
759 | } | 759 | } |
760 | } | 760 | } |
761 | 761 | ||
762 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 762 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
763 | { | 763 | { |
764 | if (mConflictItems.find(ci)<0) | 764 | if (mConflictItems.find(ci)<0) |
765 | mConflictItems.append(ci); | 765 | mConflictItems.append(ci); |
766 | } | 766 | } |
767 | |||
768 | bool KOAgendaItem::checkLayout() | ||
769 | { | ||
770 | if ( !mConflictItems.count() ) | ||
771 | return true; | ||
772 | int max = 0; | ||
773 | KOAgendaItem *item; | ||
774 | for ( item=mConflictItems.first(); item != 0; | ||
775 | item=mConflictItems.next() ) { | ||
776 | if ( item->subCells() > max ) | ||
777 | max = item->subCells(); | ||
778 | } | ||
779 | if ( max > subCells() ) { | ||
780 | setSubCells( max ); | ||
781 | return false; | ||
782 | } | ||
783 | return true; | ||
784 | } | ||
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 5b8f420..b4dba79 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h | |||
@@ -1,161 +1,162 @@ | |||
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 | #ifndef KOAGENDAITEM_H | 19 | #ifndef KOAGENDAITEM_H |
20 | #define KOAGENDAITEM_H | 20 | #define KOAGENDAITEM_H |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qpalette.h> | 26 | #include <qpalette.h> |
27 | 27 | ||
28 | #include <libkcal/incidence.h> | 28 | #include <libkcal/incidence.h> |
29 | 29 | ||
30 | class QToolTipGroup; | 30 | class QToolTipGroup; |
31 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
32 | class QDropEvent; | 32 | class QDropEvent; |
33 | 33 | ||
34 | using namespace KCal; | 34 | using namespace KCal; |
35 | 35 | ||
36 | /* | 36 | /* |
37 | The KOAgendaItem has to make sure that it receives all mouse events, which are | 37 | The KOAgendaItem has to make sure that it receives all mouse events, which are |
38 | to be used for dragging and resizing. That means it has to be installed as | 38 | to be used for dragging and resizing. That means it has to be installed as |
39 | eventfiler for its children, if it has children, and it has to pass mouse | 39 | eventfiler for its children, if it has children, and it has to pass mouse |
40 | events from the cildren to itself. See eventFilter(). | 40 | events from the cildren to itself. See eventFilter(). |
41 | */ | 41 | */ |
42 | class KOAgendaItem : public QWidget | 42 | class KOAgendaItem : public QWidget |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, | 46 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, |
47 | WFlags f=0 ); | 47 | WFlags f=0 ); |
48 | ~KOAgendaItem(); | 48 | ~KOAgendaItem(); |
49 | QString getWhatsThisText(); | 49 | QString getWhatsThisText(); |
50 | void init ( Incidence *incidence, QDate qd ); | 50 | void init ( Incidence *incidence, QDate qd ); |
51 | int cellX() { return mCellX; } | 51 | int cellX() { return mCellX; } |
52 | int cellXWidth() { return mCellXWidth; } | 52 | int cellXWidth() { return mCellXWidth; } |
53 | int cellYTop() { return mCellYTop; } | 53 | int cellYTop() { return mCellYTop; } |
54 | int cellYBottom() { return mCellYBottom; } | 54 | int cellYBottom() { return mCellYBottom; } |
55 | int cellHeight(); | 55 | int cellHeight(); |
56 | int cellWidth(); | 56 | int cellWidth(); |
57 | int subCell() { return mSubCell; } | 57 | int subCell() { return mSubCell; } |
58 | int subCells() { return mSubCells; } | 58 | int subCells() { return mSubCells; } |
59 | 59 | ||
60 | void setCellXY(int X, int YTop, int YBottom); | 60 | void setCellXY(int X, int YTop, int YBottom); |
61 | void setCellY(int YTop, int YBottom); | 61 | void setCellY(int YTop, int YBottom); |
62 | void setCellX(int XLeft, int XRight); | 62 | void setCellX(int XLeft, int XRight); |
63 | void setCellXWidth(int xwidth); | 63 | void setCellXWidth(int xwidth); |
64 | void setSubCell(int subCell); | 64 | void setSubCell(int subCell); |
65 | void setSubCells(int subCells); | 65 | void setSubCells(int subCells); |
66 | 66 | ||
67 | /** Start movement */ | 67 | /** Start movement */ |
68 | void startMove(); | 68 | void startMove(); |
69 | /** Reset to original values */ | 69 | /** Reset to original values */ |
70 | void resetMove(); | 70 | void resetMove(); |
71 | 71 | ||
72 | void moveRelative(int dx,int dy); | 72 | void moveRelative(int dx,int dy); |
73 | void expandTop(int dy); | 73 | void expandTop(int dy); |
74 | void expandBottom(int dy); | 74 | void expandBottom(int dy); |
75 | void expandLeft(int dx); | 75 | void expandLeft(int dx); |
76 | void expandRight(int dx); | 76 | void expandRight(int dx); |
77 | int mLastMoveXPos; | 77 | int mLastMoveXPos; |
78 | 78 | ||
79 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 79 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
80 | KOAgendaItem *last); | 80 | KOAgendaItem *last); |
81 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } | 81 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } |
82 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } | 82 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } |
83 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } | 83 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } |
84 | 84 | ||
85 | Incidence *incidence() const { return mIncidence; } | 85 | Incidence *incidence() const { return mIncidence; } |
86 | QDate itemDate() { return mDate; } | 86 | QDate itemDate() { return mDate; } |
87 | 87 | ||
88 | /** Update the date of this item's occurence (not in the event) */ | 88 | /** Update the date of this item's occurence (not in the event) */ |
89 | void setItemDate(QDate qd); | 89 | void setItemDate(QDate qd); |
90 | 90 | ||
91 | void setText ( const QString & text ) { mDisplayedText = text; } | 91 | void setText ( const QString & text ) { mDisplayedText = text; } |
92 | QString text () { return mDisplayedText; } | 92 | QString text () { return mDisplayedText; } |
93 | 93 | ||
94 | virtual bool eventFilter ( QObject *, QEvent * ); | 94 | virtual bool eventFilter ( QObject *, QEvent * ); |
95 | 95 | ||
96 | static QToolTipGroup *toolTipGroup(); | 96 | static QToolTipGroup *toolTipGroup(); |
97 | 97 | ||
98 | QPtrList<KOAgendaItem> conflictItems(); | 98 | QPtrList<KOAgendaItem> conflictItems(); |
99 | void setConflictItems(QPtrList<KOAgendaItem>); | 99 | void setConflictItems(QPtrList<KOAgendaItem>); |
100 | void addConflictItem(KOAgendaItem *ci); | 100 | void addConflictItem(KOAgendaItem *ci); |
101 | void paintMe( bool, QPainter* painter = 0 ); | 101 | void paintMe( bool, QPainter* painter = 0 ); |
102 | void repaintMe(); | 102 | void repaintMe(); |
103 | static void resizePixmap( int, int ); | 103 | static void resizePixmap( int, int ); |
104 | static QPixmap * paintPix(); | 104 | static QPixmap * paintPix(); |
105 | static QPixmap * paintPixSel(); | 105 | static QPixmap * paintPixSel(); |
106 | static QPixmap * paintPixAllday(); | 106 | static QPixmap * paintPixAllday(); |
107 | void updateItem(); | 107 | void updateItem(); |
108 | void computeText(); | 108 | void computeText(); |
109 | void recreateIncidence(); | 109 | void recreateIncidence(); |
110 | bool checkLayout(); | ||
110 | public slots: | 111 | public slots: |
111 | bool updateIcons( QPainter *, bool ); | 112 | bool updateIcons( QPainter *, bool ); |
112 | void select(bool=true); | 113 | void select(bool=true); |
113 | 114 | ||
114 | protected: | 115 | protected: |
115 | void dragEnterEvent(QDragEnterEvent *e); | 116 | void dragEnterEvent(QDragEnterEvent *e); |
116 | void dropEvent(QDropEvent *e); | 117 | void dropEvent(QDropEvent *e); |
117 | void paintEvent ( QPaintEvent * ); | 118 | void paintEvent ( QPaintEvent * ); |
118 | void resizeEvent ( QResizeEvent *ev ); | 119 | void resizeEvent ( QResizeEvent *ev ); |
119 | 120 | ||
120 | private: | 121 | private: |
121 | bool mAllDay; | 122 | bool mAllDay; |
122 | int mCellX; | 123 | int mCellX; |
123 | int mCellXWidth; | 124 | int mCellXWidth; |
124 | int mCellYTop,mCellYBottom; | 125 | int mCellYTop,mCellYBottom; |
125 | int mSubCell; // subcell number of this item | 126 | int mSubCell; // subcell number of this item |
126 | int mSubCells; // Total number of subcells in cell of this item | 127 | int mSubCells; // Total number of subcells in cell of this item |
127 | int xPaintCoord; | 128 | int xPaintCoord; |
128 | int yPaintCoord; | 129 | int yPaintCoord; |
129 | int wPaintCoord; | 130 | int wPaintCoord; |
130 | int hPaintCoord; | 131 | int hPaintCoord; |
131 | // Variables to remember start position | 132 | // Variables to remember start position |
132 | int mStartCellX; | 133 | int mStartCellX; |
133 | int mStartCellXWidth; | 134 | int mStartCellXWidth; |
134 | int mStartCellYTop,mStartCellYBottom; | 135 | int mStartCellYTop,mStartCellYBottom; |
135 | int mLastMovePos; | 136 | int mLastMovePos; |
136 | 137 | ||
137 | // Multi item pointers | 138 | // Multi item pointers |
138 | KOAgendaItem *mFirstMultiItem; | 139 | KOAgendaItem *mFirstMultiItem; |
139 | KOAgendaItem *mNextMultiItem; | 140 | KOAgendaItem *mNextMultiItem; |
140 | KOAgendaItem *mLastMultiItem; | 141 | KOAgendaItem *mLastMultiItem; |
141 | 142 | ||
142 | int mFontPixelSize; | 143 | int mFontPixelSize; |
143 | Incidence *mIncidence; // corresponding event or todo | 144 | Incidence *mIncidence; // corresponding event or todo |
144 | QDate mDate; //date this events occurs (for recurrence) | 145 | QDate mDate; //date this events occurs (for recurrence) |
145 | //void showIcon( QLabel*, int ); | 146 | //void showIcon( QLabel*, int ); |
146 | //QLabel *mTodoIconLabel; | 147 | //QLabel *mTodoIconLabel; |
147 | //QLabel *mItemLabel; | 148 | //QLabel *mItemLabel; |
148 | //QWidget *mIconBox; | 149 | //QWidget *mIconBox; |
149 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; | 150 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; |
150 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; | 151 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; |
151 | //QLabel *mIconMoreInfo; | 152 | //QLabel *mIconMoreInfo; |
152 | static QToolTipGroup *mToolTipGroup; | 153 | static QToolTipGroup *mToolTipGroup; |
153 | 154 | ||
154 | QColor mBackgroundColor; | 155 | QColor mBackgroundColor; |
155 | QColorGroup mColorGroup; | 156 | QColorGroup mColorGroup; |
156 | QString mDisplayedText; | 157 | QString mDisplayedText; |
157 | bool mSelected; | 158 | bool mSelected; |
158 | QPtrList<KOAgendaItem> mConflictItems; | 159 | QPtrList<KOAgendaItem> mConflictItems; |
159 | }; | 160 | }; |
160 | 161 | ||
161 | #endif // KOAGENDAITEM_H | 162 | #endif // KOAGENDAITEM_H |
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index 8bada3b..e2c8e6e 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,283 +1,292 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | 21 | ||
22 | #include <libkcal/event.h> | 22 | #include <libkcal/event.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | 25 | ||
26 | #include "koeventviewer.h" | 26 | #include "koeventviewer.h" |
27 | #include "koprefs.h" | 27 | #include "koprefs.h" |
28 | #include <libkcal/todo.h> | 28 | #include <libkcal/todo.h> |
29 | #include "qapp.h" | 29 | #include "qapp.h" |
30 | 30 | ||
31 | #include "koeventviewerdialog.h" | 31 | #include "koeventviewerdialog.h" |
32 | extern int globalFlagBlockAgenda; | 32 | extern int globalFlagBlockAgenda; |
33 | 33 | ||
34 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 34 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
35 | : KDialogBase(parent,name, | 35 | : KDialogBase(parent,name, |
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | true , | 37 | true , |
38 | #else | 38 | #else |
39 | false, | 39 | false, |
40 | #endif | 40 | #endif |
41 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 41 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
42 | { | 42 | { |
43 | sendSignalViewerClosed = true; | 43 | sendSignalViewerClosed = true; |
44 | mEventViewer = new KOEventViewer(this); | 44 | mEventViewer = new KOEventViewer(this); |
45 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 45 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
46 | setMainWidget(mEventViewer); | 46 | setMainWidget(mEventViewer); |
47 | setButtonText(Ok, i18n("Edit") ); | 47 | setButtonText(Ok, i18n("Edit") ); |
48 | 48 | ||
49 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 49 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
50 | SLOT(editIncidence())); | 50 | SLOT(editIncidence())); |
51 | QObject::connect(this,SIGNAL(user1Clicked()), | 51 | QObject::connect(this,SIGNAL(user1Clicked()), |
52 | SLOT(showIncidence())); | 52 | SLOT(showIncidence())); |
53 | mIncidence = 0; | 53 | mIncidence = 0; |
54 | // TODO: Set a sensible size (based on the content?). | 54 | // TODO: Set a sensible size (based on the content?). |
55 | //showMaximized(); | 55 | //showMaximized(); |
56 | //qDebug("++++++++++++KOEventViewerDialog() "); | 56 | //qDebug("++++++++++++KOEventViewerDialog() "); |
57 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 57 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
58 | // setFixedSize( 240,284 ); | 58 | // setFixedSize( 240,284 ); |
59 | // move( 0, 15 ); | 59 | // move( 0, 15 ); |
60 | // } else { | 60 | // } else { |
61 | // setMinimumSize(300,200); | 61 | // setMinimumSize(300,200); |
62 | // resize(320,300); | 62 | // resize(320,300); |
63 | // } | 63 | // } |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mSyncResult = 0; | 65 | mSyncResult = 0; |
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | KOEventViewerDialog::~KOEventViewerDialog() | 69 | KOEventViewerDialog::~KOEventViewerDialog() |
70 | { | 70 | { |
71 | //qDebug("-------~KOEventViewerDialog() "); | 71 | //qDebug("-------~KOEventViewerDialog() "); |
72 | } | 72 | } |
73 | void KOEventViewerDialog::showMe() | 73 | void KOEventViewerDialog::showMe() |
74 | { | 74 | { |
75 | 75 | ||
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | int x,y,w,h; | ||
78 | x = geometry().x(); | ||
79 | y = geometry().y(); | ||
80 | w = width(); | ||
81 | h = height(); | ||
77 | show(); | 82 | show(); |
83 | setGeometry(x,y,w,h); | ||
78 | #else | 84 | #else |
79 | showMaximized(); | 85 | showMaximized(); |
80 | #endif | 86 | #endif |
87 | raise(); | ||
81 | setActiveWindow(); | 88 | setActiveWindow(); |
82 | mEventViewer->setFocus(); | 89 | mEventViewer->setFocus(); |
83 | 90 | ||
84 | } | 91 | } |
85 | void KOEventViewerDialog::setSyncMode( bool b ) | 92 | void KOEventViewerDialog::setSyncMode( bool b ) |
86 | { | 93 | { |
87 | mSyncMode = b; | 94 | mSyncMode = b; |
88 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 95 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
89 | if ( mSyncMode ) { | 96 | if ( mSyncMode ) { |
90 | findButton( Close )->setText( i18n("Cancel Sync")); | 97 | findButton( Close )->setText( i18n("Cancel Sync")); |
91 | findButton( Ok )->setText( i18n("Remote")); | 98 | findButton( Ok )->setText( i18n("Remote")); |
92 | findButton( User1 )->setText( i18n("Local")); | 99 | findButton( User1 )->setText( i18n("Local")); |
93 | } else { | 100 | } else { |
94 | findButton( Close )->setText( i18n("Close")); | 101 | findButton( Close )->setText( i18n("Close")); |
95 | findButton( Ok )->setText( i18n("Edit")); | 102 | findButton( Ok )->setText( i18n("Edit")); |
96 | findButton( User1 )->setText( i18n("Agenda")); | 103 | findButton( User1 )->setText( i18n("Agenda")); |
97 | } | 104 | } |
98 | mEventViewer->setSyncMode( b ); | 105 | mEventViewer->setSyncMode( b ); |
99 | } | 106 | } |
100 | void KOEventViewerDialog::setColorMode( int m ) | 107 | void KOEventViewerDialog::setColorMode( int m ) |
101 | { | 108 | { |
102 | mEventViewer->setColorMode( m ); | 109 | mEventViewer->setColorMode( m ); |
103 | } | 110 | } |
104 | int KOEventViewerDialog::executeS( bool local ) | 111 | int KOEventViewerDialog::executeS( bool local ) |
105 | { | 112 | { |
106 | mSyncResult = 3; | 113 | mSyncResult = 3; |
107 | if ( local ) | 114 | if ( local ) |
108 | findButton( User1 )->setFocus(); | 115 | findButton( User1 )->setFocus(); |
109 | else | 116 | else |
110 | findButton( Ok )->setFocus(); | 117 | findButton( Ok )->setFocus(); |
111 | exec(); | 118 | exec(); |
112 | return mSyncResult; | 119 | return mSyncResult; |
113 | } | 120 | } |
114 | 121 | ||
115 | void KOEventViewerDialog::updateConfig() | 122 | void KOEventViewerDialog::updateConfig() |
116 | { | 123 | { |
117 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 124 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
118 | 125 | ||
119 | } | 126 | } |
120 | void KOEventViewerDialog::setEvent(Event *event) | 127 | void KOEventViewerDialog::setEvent(Event *event) |
121 | { | 128 | { |
122 | mEventViewer->setEvent(event); | 129 | mEventViewer->setEvent(event); |
123 | mIncidence = event; | 130 | mIncidence = event; |
124 | mEventViewer->setFocus(); | 131 | mEventViewer->setFocus(); |
125 | //findButton( Close )->setFocus(); | 132 | //findButton( Close )->setFocus(); |
126 | if ( !mSyncMode ) { | 133 | if ( !mSyncMode ) { |
127 | findButton( User1 )->setText( i18n("Agenda")); | 134 | findButton( User1 )->setText( i18n("Agenda")); |
128 | } | 135 | } |
129 | } | 136 | } |
130 | void KOEventViewerDialog::setIncidence(Incidence *in ) | 137 | void KOEventViewerDialog::setIncidence(Incidence *in ) |
131 | { | 138 | { |
132 | if ( in->type() == "Event" ) | 139 | if ( in->type() == "Event" ) |
133 | setEvent( (Event*) in ); | 140 | setEvent( (Event*) in ); |
134 | else if ( in->type() =="Todo" ) | 141 | else if ( in->type() =="Todo" ) |
135 | setTodo( (Todo*) in ); | 142 | setTodo( (Todo*) in ); |
136 | else if ( in->type() =="Journal" ) | 143 | else if ( in->type() =="Journal" ) |
137 | setJournal( (Journal*) in ); | 144 | setJournal( (Journal*) in ); |
138 | } | 145 | } |
139 | void KOEventViewerDialog::addIncidence(Incidence *in) | 146 | void KOEventViewerDialog::addIncidence(Incidence *in) |
140 | { | 147 | { |
141 | if ( in->type() == "Event" ) | 148 | if ( in->type() == "Event" ) |
142 | addEvent( (Event*) in ); | 149 | addEvent( (Event*) in ); |
143 | else if ( in->type() =="Todo" ) | 150 | else if ( in->type() =="Todo" ) |
144 | mEventViewer->setTodo( (Todo*) in, false ); | 151 | mEventViewer->setTodo( (Todo*) in, false ); |
145 | else if ( in->type() =="Journal" ) | 152 | else if ( in->type() =="Journal" ) |
146 | mEventViewer->setJournal( (Journal*) in, false ); | 153 | mEventViewer->setJournal( (Journal*) in, false ); |
147 | if ( mSyncMode ) { | 154 | if ( mSyncMode ) { |
148 | findButton( User1 )->setFocus(); | 155 | findButton( User1 )->setFocus(); |
149 | setCaption(i18n("Conflict! Please choose entry")); | 156 | setCaption(i18n("Conflict! Please choose entry")); |
150 | } | 157 | } |
151 | } | 158 | } |
152 | 159 | ||
153 | void KOEventViewerDialog::addEvent(Event *event) | 160 | void KOEventViewerDialog::addEvent(Event *event) |
154 | { | 161 | { |
155 | mEventViewer->addEvent(event); | 162 | mEventViewer->addEvent(event); |
156 | mIncidence = event; | 163 | mIncidence = event; |
157 | mEventViewer->setFocus(); | 164 | mEventViewer->setFocus(); |
158 | //findButton( Close )->setFocus(); | 165 | //findButton( Close )->setFocus(); |
159 | if ( !mSyncMode ) { | 166 | if ( !mSyncMode ) { |
160 | findButton( User1 )->setText( i18n("Agenda")); | 167 | findButton( User1 )->setText( i18n("Agenda")); |
161 | } | 168 | } |
162 | } | 169 | } |
163 | 170 | ||
164 | void KOEventViewerDialog::setTodo(Todo *event) | 171 | void KOEventViewerDialog::setTodo(Todo *event) |
165 | { | 172 | { |
166 | mEventViewer->setTodo(event); | 173 | mEventViewer->setTodo(event); |
167 | mIncidence = (Incidence*)event; | 174 | mIncidence = (Incidence*)event; |
168 | mEventViewer->setFocus(); | 175 | mEventViewer->setFocus(); |
169 | //findButton( Close )->setFocus(); | 176 | //findButton( Close )->setFocus(); |
170 | if ( !mSyncMode ) { | 177 | if ( !mSyncMode ) { |
171 | findButton( User1 )->setText( i18n("Set complete")); | 178 | findButton( User1 )->setText( i18n("Set complete")); |
172 | } | 179 | } |
173 | } | 180 | } |
174 | void KOEventViewerDialog::setJournal(Journal *j) | 181 | void KOEventViewerDialog::setJournal(Journal *j) |
175 | { | 182 | { |
176 | mEventViewer->setJournal(j); | 183 | mEventViewer->setJournal(j); |
177 | mIncidence = (Incidence*)j; | 184 | mIncidence = (Incidence*)j; |
178 | mEventViewer->setFocus(); | 185 | mEventViewer->setFocus(); |
179 | //findButton( Close )->setFocus(); | 186 | //findButton( Close )->setFocus(); |
180 | if ( !mSyncMode ) { | 187 | if ( !mSyncMode ) { |
181 | findButton( User1 )->setText( i18n("Agenda")); | 188 | findButton( User1 )->setText( i18n("Agenda")); |
182 | } | 189 | } |
183 | } | 190 | } |
184 | 191 | ||
185 | void KOEventViewerDialog::addText(QString text) | 192 | void KOEventViewerDialog::addText(QString text) |
186 | { | 193 | { |
187 | mEventViewer->addText(text); | 194 | mEventViewer->addText(text); |
188 | mEventViewer->setFocus(); | 195 | mEventViewer->setFocus(); |
189 | //findButton( Close )->setFocus(); | 196 | //findButton( Close )->setFocus(); |
190 | } | 197 | } |
191 | void KOEventViewerDialog::editIncidence() | 198 | void KOEventViewerDialog::editIncidence() |
192 | { | 199 | { |
193 | sendSignalViewerClosed = false; | 200 | sendSignalViewerClosed = false; |
194 | if ( mSyncMode ) { | 201 | if ( mSyncMode ) { |
195 | mSyncResult = 2; | 202 | mSyncResult = 2; |
196 | accept(); | 203 | accept(); |
197 | return; | 204 | return; |
198 | } | 205 | } |
199 | if ( mIncidence ){ | 206 | if ( mIncidence ){ |
200 | #ifndef DESKTOP_VERSION | 207 | #ifndef DESKTOP_VERSION |
201 | hide(); | 208 | hide(); |
202 | #endif | 209 | #endif |
203 | emit editIncidence( mIncidence ); | 210 | emit editIncidence( mIncidence ); |
204 | } | 211 | } |
205 | } | 212 | } |
206 | void KOEventViewerDialog::showIncidence() | 213 | void KOEventViewerDialog::showIncidence() |
207 | { | 214 | { |
208 | sendSignalViewerClosed = false; | 215 | sendSignalViewerClosed = false; |
209 | if ( mSyncMode ) { | 216 | if ( mSyncMode ) { |
210 | mSyncResult = 1; | 217 | mSyncResult = 1; |
211 | accept(); | 218 | accept(); |
212 | return; | 219 | return; |
213 | } | 220 | } |
214 | 221 | ||
215 | if ( mIncidence ){ | 222 | if ( mIncidence ){ |
216 | #ifndef DESKTOP_VERSION | 223 | #ifndef DESKTOP_VERSION |
217 | hide(); | 224 | hide(); |
218 | #endif | 225 | #endif |
219 | QDate date; | 226 | QDate date; |
220 | if ( mIncidence->type() == "Todo" ) { | 227 | if ( mIncidence->type() == "Todo" ) { |
221 | /* | 228 | /* |
222 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 229 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
223 | date = ((Todo*)mIncidence)->dtDue().date(); | 230 | date = ((Todo*)mIncidence)->dtDue().date(); |
224 | else { | 231 | else { |
225 | globalFlagBlockAgenda = 2; | 232 | globalFlagBlockAgenda = 2; |
226 | emit showAgendaView( false ); | 233 | emit showAgendaView( false ); |
227 | return; | 234 | return; |
228 | } | 235 | } |
229 | */ | 236 | */ |
230 | ((Todo*)mIncidence)->setCompleted( true ); | 237 | ((Todo*)mIncidence)->setCompleted( true ); |
231 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 238 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
232 | hide(); | 239 | hide(); |
233 | emit todoCompleted(((Todo*)mIncidence)); | 240 | emit todoCompleted(((Todo*)mIncidence)); |
234 | return; | 241 | return; |
235 | 242 | ||
236 | } else | 243 | } else |
237 | date = mIncidence->dtStart().date(); | 244 | date = mIncidence->dtStart().date(); |
238 | globalFlagBlockAgenda = 1; | 245 | globalFlagBlockAgenda = 1; |
239 | emit showAgendaView( false ); | 246 | emit showAgendaView( false ); |
240 | globalFlagBlockAgenda = 2; | 247 | globalFlagBlockAgenda = 2; |
241 | emit jumpToTime( date ); | 248 | emit jumpToTime( date ); |
242 | } | 249 | } |
243 | } | 250 | } |
244 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 251 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
245 | { | 252 | { |
246 | switch ( e->key() ) { | 253 | switch ( e->key() ) { |
247 | 254 | ||
248 | case Qt::Key_A : | 255 | case Qt::Key_A : |
249 | case Qt::Key_L : | 256 | case Qt::Key_L : |
250 | showIncidence(); | 257 | showIncidence(); |
251 | break; | 258 | break; |
252 | case Qt::Key_E : | 259 | case Qt::Key_E : |
253 | case Qt::Key_R : | 260 | case Qt::Key_R : |
254 | editIncidence(); | 261 | editIncidence(); |
255 | break; | 262 | break; |
256 | case Qt::Key_C: | 263 | case Qt::Key_C: |
257 | case Qt::Key_Escape: | 264 | case Qt::Key_Escape: |
258 | close(); | 265 | close(); |
259 | break; | 266 | break; |
260 | case Qt::Key_I: | 267 | case Qt::Key_I: |
261 | accept(); | 268 | sendSignalViewerClosed = true; |
269 | slotViewerClosed(); | ||
270 | //accept(); | ||
262 | break; | 271 | break; |
263 | default: | 272 | default: |
264 | KDialogBase::keyPressEvent ( e ); | 273 | KDialogBase::keyPressEvent ( e ); |
265 | break; | 274 | break; |
266 | } | 275 | } |
267 | 276 | ||
268 | } | 277 | } |
269 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) | 278 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) |
270 | { | 279 | { |
271 | KDialogBase::hideEvent ( e ); | 280 | KDialogBase::hideEvent ( e ); |
272 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); | 281 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); |
273 | } | 282 | } |
274 | 283 | ||
275 | void KOEventViewerDialog::slotViewerClosed() | 284 | void KOEventViewerDialog::slotViewerClosed() |
276 | { | 285 | { |
277 | if ( sendSignalViewerClosed ) { | 286 | if ( sendSignalViewerClosed ) { |
278 | //qDebug("KOEventViewerDialog::hideEvent "); | 287 | //qDebug("KOEventViewerDialog::hideEvent "); |
279 | emit signalViewerClosed(); | 288 | emit signalViewerClosed(); |
280 | } | 289 | } |
281 | sendSignalViewerClosed = true; | 290 | sendSignalViewerClosed = true; |
282 | } | 291 | } |
283 | 292 | ||