summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/koagenda.cpp66
-rw-r--r--korganizer/koagenda.h6
-rw-r--r--korganizer/koagendaview.cpp19
-rw-r--r--korganizer/koagendaview.h3
-rw-r--r--korganizer/koeditorgeneraltodo.cpp17
-rw-r--r--korganizer/koviewmanager.cpp9
8 files changed, 119 insertions, 22 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 257a4dd..035d630 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2601,150 +2601,157 @@ void CalendarView::cloneIncidence(Incidence * orgInc )
2601 mEventEditor->editEvent( e ); 2601 mEventEditor->editEvent( e );
2602 if ( mEventEditor->exec() ) { 2602 if ( mEventEditor->exec() ) {
2603 mCalendar->addEvent( e ); 2603 mCalendar->addEvent( e );
2604 updateView(); 2604 updateView();
2605 } else { 2605 } else {
2606 delete e; 2606 delete e;
2607 } 2607 }
2608 } 2608 }
2609} 2609}
2610 2610
2611void CalendarView::newEvent() 2611void CalendarView::newEvent()
2612{ 2612{
2613 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2613 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2614 KOAgendaView *aView = mViewManager->agendaView(); 2614 KOAgendaView *aView = mViewManager->agendaView();
2615 if (aView) { 2615 if (aView) {
2616 if (aView->selectionStart().isValid()) { 2616 if (aView->selectionStart().isValid()) {
2617 if (aView->selectedIsAllDay()) { 2617 if (aView->selectedIsAllDay()) {
2618 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2618 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2619 } else { 2619 } else {
2620 newEvent(aView->selectionStart(),aView->selectionEnd()); 2620 newEvent(aView->selectionStart(),aView->selectionEnd());
2621 } 2621 }
2622 return; 2622 return;
2623 } 2623 }
2624 } 2624 }
2625 2625
2626 QDate date = mNavigator->selectedDates().first(); 2626 QDate date = mNavigator->selectedDates().first();
2627 QDateTime current = QDateTime::currentDateTime(); 2627 QDateTime current = QDateTime::currentDateTime();
2628 if ( date <= current.date() ) { 2628 if ( date <= current.date() ) {
2629 int hour = current.time().hour() +1; 2629 int hour = current.time().hour() +1;
2630 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2630 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2631 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2631 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2632 } else 2632 } else
2633 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2633 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2634 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2634 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2635 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2635 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2636} 2636}
2637 2637
2638void CalendarView::newEvent(QDateTime fh) 2638void CalendarView::newEvent(QDateTime fh)
2639{ 2639{
2640 newEvent(fh, 2640 newEvent(fh,
2641 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2641 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2642} 2642}
2643 2643
2644void CalendarView::newEvent(QDate dt) 2644void CalendarView::newEvent(QDate dt)
2645{ 2645{
2646 newEvent(QDateTime(dt, QTime(0,0,0)), 2646 newEvent(QDateTime(dt, QTime(0,0,0)),
2647 QDateTime(dt, QTime(0,0,0)), true); 2647 QDateTime(dt, QTime(0,0,0)), true);
2648} 2648}
2649 2649void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2650{
2651 newEvent(fromHint, toHint, false);
2652}
2650void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2653void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2651{ 2654{
2652 2655
2653 showEventEditor(); 2656 showEventEditor();
2654 mEventEditor->newEvent(fromHint,toHint,allDay); 2657 mEventEditor->newEvent(fromHint,toHint,allDay);
2655 if ( mFilterView->filtersEnabled() ) { 2658 if ( mFilterView->filtersEnabled() ) {
2656 CalFilter *filter = mFilterView->selectedFilter(); 2659 CalFilter *filter = mFilterView->selectedFilter();
2657 if (filter && filter->showCategories()) { 2660 if (filter && filter->showCategories()) {
2658 mEventEditor->setCategories(filter->categoryList().join(",") ); 2661 mEventEditor->setCategories(filter->categoryList().join(",") );
2659 } 2662 }
2660 if ( filter ) 2663 if ( filter )
2661 mEventEditor->setSecrecy( filter->getSecrecy() ); 2664 mEventEditor->setSecrecy( filter->getSecrecy() );
2662 } 2665 }
2663} 2666}
2664void CalendarView::todoAdded(Todo * t) 2667void CalendarView::todoAdded(Todo * t)
2665{ 2668{
2666 2669
2667 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2670 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2668 updateTodoViews(); 2671 updateTodoViews();
2669} 2672}
2670void CalendarView::todoChanged(Todo * t) 2673void CalendarView::todoChanged(Todo * t)
2671{ 2674{
2672 emit todoModified( t, 4 ); 2675 emit todoModified( t, 4 );
2673 // updateTodoViews(); 2676 // updateTodoViews();
2674} 2677}
2675void CalendarView::todoToBeDeleted(Todo *) 2678void CalendarView::todoToBeDeleted(Todo *)
2676{ 2679{
2677 //qDebug("todoToBeDeleted(Todo *) "); 2680 //qDebug("todoToBeDeleted(Todo *) ");
2678 updateTodoViews(); 2681 updateTodoViews();
2679} 2682}
2680void CalendarView::todoDeleted() 2683void CalendarView::todoDeleted()
2681{ 2684{
2682 //qDebug(" todoDeleted()"); 2685 //qDebug(" todoDeleted()");
2683 updateTodoViews(); 2686 updateTodoViews();
2684} 2687}
2685 2688
2686 2689
2687 2690void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2688void CalendarView::newTodo()
2689{ 2691{
2690 2692 qDebug("datetime ");
2691 showTodoEditor(); 2693 showTodoEditor();
2692 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2694 mTodoEditor->newTodo(dt,0,allday);
2693 if ( mFilterView->filtersEnabled() ) { 2695 if ( mFilterView->filtersEnabled() ) {
2694 CalFilter *filter = mFilterView->selectedFilter(); 2696 CalFilter *filter = mFilterView->selectedFilter();
2695 if (filter && filter->showCategories()) { 2697 if (filter && filter->showCategories()) {
2696 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2698 mTodoEditor->setCategories(filter->categoryList().join(",") );
2697 } 2699 }
2698 if ( filter ) 2700 if ( filter )
2699 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2701 mTodoEditor->setSecrecy( filter->getSecrecy() );
2700 } 2702 }
2701} 2703}
2702 2704
2705void CalendarView::newTodo()
2706{
2707 newTodoDateTime( QDateTime(),true );
2708}
2709
2703void CalendarView::newSubTodo() 2710void CalendarView::newSubTodo()
2704{ 2711{
2705 Todo *todo = selectedTodo(); 2712 Todo *todo = selectedTodo();
2706 if ( todo ) newSubTodo( todo ); 2713 if ( todo ) newSubTodo( todo );
2707} 2714}
2708 2715
2709void CalendarView::newSubTodo(Todo *parentEvent) 2716void CalendarView::newSubTodo(Todo *parentEvent)
2710{ 2717{
2711 2718
2712 showTodoEditor(); 2719 showTodoEditor();
2713 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2720 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2714} 2721}
2715 2722
2716void CalendarView::newFloatingEvent() 2723void CalendarView::newFloatingEvent()
2717{ 2724{
2718 DateList tmpList = mNavigator->selectedDates(); 2725 DateList tmpList = mNavigator->selectedDates();
2719 QDate date = tmpList.first(); 2726 QDate date = tmpList.first();
2720 2727
2721 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2728 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2722 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2729 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2723} 2730}
2724 2731
2725 2732
2726void CalendarView::editEvent( Event *event ) 2733void CalendarView::editEvent( Event *event )
2727{ 2734{
2728 2735
2729 if ( !event ) return; 2736 if ( !event ) return;
2730 if ( event->isReadOnly() ) { 2737 if ( event->isReadOnly() ) {
2731 showEvent( event ); 2738 showEvent( event );
2732 return; 2739 return;
2733 } 2740 }
2734 showEventEditor(); 2741 showEventEditor();
2735 mEventEditor->editEvent( event , mFlagEditDescription); 2742 mEventEditor->editEvent( event , mFlagEditDescription);
2736} 2743}
2737void CalendarView::editJournal( Journal *jour ) 2744void CalendarView::editJournal( Journal *jour )
2738{ 2745{
2739 if ( !jour ) return; 2746 if ( !jour ) return;
2740 mDialogManager->hideSearchDialog(); 2747 mDialogManager->hideSearchDialog();
2741 mViewManager->showJournalView(); 2748 mViewManager->showJournalView();
2742 mNavigator->slotDaySelect( jour->dtStart().date() ); 2749 mNavigator->slotDaySelect( jour->dtStart().date() );
2743} 2750}
2744void CalendarView::editTodo( Todo *todo ) 2751void CalendarView::editTodo( Todo *todo )
2745{ 2752{
2746 if ( !todo ) return; 2753 if ( !todo ) return;
2747 2754
2748 if ( todo->isReadOnly() ) { 2755 if ( todo->isReadOnly() ) {
2749 showTodo( todo ); 2756 showTodo( todo );
2750 return; 2757 return;
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index c8d6bdd..7c59a8d 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -180,131 +180,133 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
180 void checkNextTimerAlarm(); 180 void checkNextTimerAlarm();
181 void addAlarm(const QDateTime &qdt, const QString &noti ); 181 void addAlarm(const QDateTime &qdt, const QString &noti );
182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
183 void removeAlarm(const QDateTime &qdt, const QString &noti ); 183 void removeAlarm(const QDateTime &qdt, const QString &noti );
184 184
185 /** options dialog made a changed to the configuration. we catch this 185 /** options dialog made a changed to the configuration. we catch this
186 * and notify all widgets which need to update their configuration. */ 186 * and notify all widgets which need to update their configuration. */
187 void updateConfig(); 187 void updateConfig();
188 188
189 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 189 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
190 const QStringList& anniversaryList, const QStringList& realNameList, 190 const QStringList& anniversaryList, const QStringList& realNameList,
191 const QStringList& emailList, const QStringList& assembledNameList, 191 const QStringList& emailList, const QStringList& assembledNameList,
192 const QStringList& uidList); 192 const QStringList& uidList);
193 193
194 /** 194 /**
195 Load calendar from file \a filename. If \a merge is true, load 195 Load calendar from file \a filename. If \a merge is true, load
196 calendar into existing one, if it is false, clear calendar, before 196 calendar into existing one, if it is false, clear calendar, before
197 loading. Return true, if calendar could be successfully loaded. 197 loading. Return true, if calendar could be successfully loaded.
198 */ 198 */
199 bool openCalendar(QString filename, bool merge=false); 199 bool openCalendar(QString filename, bool merge=false);
200 bool syncCalendar(QString filename,int mode = 0 ); 200 bool syncCalendar(QString filename,int mode = 0 );
201 201
202 /** 202 /**
203 Save calendar data to file. Return true if calendar could be 203 Save calendar data to file. Return true if calendar could be
204 successfully saved. 204 successfully saved.
205 */ 205 */
206 bool saveCalendar(QString filename); 206 bool saveCalendar(QString filename);
207 207
208 /** 208 /**
209 Close calendar. Clear calendar data and reset views to display an empty 209 Close calendar. Clear calendar data and reset views to display an empty
210 calendar. 210 calendar.
211 */ 211 */
212 void closeCalendar(); 212 void closeCalendar();
213 213
214 /** Archive old events of calendar */ 214 /** Archive old events of calendar */
215 void archiveCalendar(); 215 void archiveCalendar();
216 216
217 void showIncidence(); 217 void showIncidence();
218 void editIncidence(); 218 void editIncidence();
219 void editIncidenceDescription(); 219 void editIncidenceDescription();
220 void deleteIncidence(); 220 void deleteIncidence();
221 void cloneIncidence(); 221 void cloneIncidence();
222 void moveIncidence(); 222 void moveIncidence();
223 void beamIncidence(); 223 void beamIncidence();
224 void toggleCancelIncidence(); 224 void toggleCancelIncidence();
225 225
226 /** create an editeventwin with supplied date/time, and if bool is true, 226 /** create an editeventwin with supplied date/time, and if bool is true,
227 * make the event take all day. */ 227 * make the event take all day. */
228 void newEvent(QDateTime, QDateTime, bool allDay = false); 228 void newEvent(QDateTime, QDateTime, bool allDay );
229 void newEvent(QDateTime, QDateTime);
229 void newEvent(QDateTime fh); 230 void newEvent(QDateTime fh);
230 void newEvent(QDate dt); 231 void newEvent(QDate dt);
231 /** create new event without having a date hint. Takes current date as 232 /** create new event without having a date hint. Takes current date as
232 default hint. */ 233 default hint. */
233 void newEvent(); 234 void newEvent();
234 void newFloatingEvent(); 235 void newFloatingEvent();
235 236
236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 237 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
237 void showIncidence(Incidence *); 238 void showIncidence(Incidence *);
238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 239 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
239 void editIncidence(Incidence *); 240 void editIncidence(Incidence *);
240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 241 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
241 void deleteIncidence(Incidence *); 242 void deleteIncidence(Incidence *);
242 void cloneIncidence(Incidence *); 243 void cloneIncidence(Incidence *);
243 void cancelIncidence(Incidence *); 244 void cancelIncidence(Incidence *);
244 /** Create an editor for the supplied event. */ 245 /** Create an editor for the supplied event. */
245 void editEvent(Event *); 246 void editEvent(Event *);
246 /** Delete the supplied event. */ 247 /** Delete the supplied event. */
247 void deleteEvent(Event *); 248 void deleteEvent(Event *);
248 /** Delete the event with the given unique ID. Returns false, if event wasn't 249 /** Delete the event with the given unique ID. Returns false, if event wasn't
249 found. */ 250 found. */
250 bool deleteEvent(const QString &uid); 251 bool deleteEvent(const QString &uid);
251 /** Create a read-only viewer dialog for the supplied event. */ 252 /** Create a read-only viewer dialog for the supplied event. */
252 void showEvent(Event *); 253 void showEvent(Event *);
253 254
254 void editJournal(Journal *); 255 void editJournal(Journal *);
255 void showJournal(Journal *); 256 void showJournal(Journal *);
256 void deleteJournal(Journal *); 257 void deleteJournal(Journal *);
257 /** Create an editor dialog for a todo */ 258 /** Create an editor dialog for a todo */
258 void editTodo(Todo *); 259 void editTodo(Todo *);
259 /** Create a read-only viewer dialog for the supplied todo */ 260 /** Create a read-only viewer dialog for the supplied todo */
260 void showTodo(Todo *); 261 void showTodo(Todo *);
261 /** create new todo */ 262 /** create new todo */
262 void newTodo(); 263 void newTodo();
264 void newTodoDateTime(QDateTime, bool allday);
263 /** create new todo with a parent todo */ 265 /** create new todo with a parent todo */
264 void newSubTodo(); 266 void newSubTodo();
265 /** create new todo with a parent todo */ 267 /** create new todo with a parent todo */
266 void newSubTodo(Todo *); 268 void newSubTodo(Todo *);
267 /** Delete todo */ 269 /** Delete todo */
268 void deleteTodo(Todo *); 270 void deleteTodo(Todo *);
269 271
270 272
271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 273 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
272 * emitted as result. */ 274 * emitted as result. */
273 void checkClipboard(); 275 void checkClipboard();
274 276
275 /** using the KConfig associated with the kapp variable, read in the 277 /** using the KConfig associated with the kapp variable, read in the
276 * settings from the config file. 278 * settings from the config file.
277 */ 279 */
278 void readSettings(); 280 void readSettings();
279 281
280 /** write current state to config file. */ 282 /** write current state to config file. */
281 void writeSettings(); 283 void writeSettings();
282 284
283 /** read settings for calendar filters */ 285 /** read settings for calendar filters */
284 void readFilterSettings(KConfig *config); 286 void readFilterSettings(KConfig *config);
285 287
286 /** write settings for calendar filters */ 288 /** write settings for calendar filters */
287 void writeFilterSettings(KConfig *config); 289 void writeFilterSettings(KConfig *config);
288 290
289 /** passes on the message that an event has changed to the currently 291 /** passes on the message that an event has changed to the currently
290 * activated view so that it can make appropriate display changes. */ 292 * activated view so that it can make appropriate display changes. */
291 void changeEventDisplay(Event *, int); 293 void changeEventDisplay(Event *, int);
292 void changeIncidenceDisplay(Incidence *, int); 294 void changeIncidenceDisplay(Incidence *, int);
293 void changeTodoDisplay(Todo *, int); 295 void changeTodoDisplay(Todo *, int);
294 296
295 void eventAdded(Event *); 297 void eventAdded(Event *);
296 void eventChanged(Event *); 298 void eventChanged(Event *);
297 void eventToBeDeleted(Event *); 299 void eventToBeDeleted(Event *);
298 void eventDeleted(); 300 void eventDeleted();
299 301
300 void todoAdded(Todo *); 302 void todoAdded(Todo *);
301 void todoChanged(Todo *); 303 void todoChanged(Todo *);
302 void todoToBeDeleted(Todo *); 304 void todoToBeDeleted(Todo *);
303 void todoDeleted(); 305 void todoDeleted();
304 306
305 void updateView(const QDate &start, const QDate &end); 307 void updateView(const QDate &start, const QDate &end);
306 void updateView(); 308 void updateView();
307 309
308 /** Full update of visible todo views */ 310 /** Full update of visible todo views */
309 void updateTodoViews(); 311 void updateTodoViews();
310 312
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7e0b216..73ee5cb 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -123,116 +123,136 @@ void MarcusBains::updateLocation(bool recalculate)
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154 154
155 mTimeBox->raise(); 155 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 157 minutes->start(5000,true);
158} 158}
159 159
160 160
161//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
162 162
163 163
164/* 164/*
165 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
166*/ 166*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 168 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
170{ 170{
171 171 mNewItemPopup = new QPopupMenu( this );
172 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
173 QString pathString = "";
174 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
175 if ( QApplication::desktop()->width() < 480 )
176 pathString += "icons16/";
177 } else
178 pathString += "iconsmini/";
179
180 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
181 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
182
172 mColumns = columns; 183 mColumns = columns;
173 mRows = rows; 184 mRows = rows;
174 mGridSpacingY = rowSize; 185 mGridSpacingY = rowSize;
175 mAllDayMode = false; 186 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 187#ifndef DESKTOP_VERSION
177 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 188 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 189#endif
179 mHolidayMask = 0; 190 mHolidayMask = 0;
180 init(); 191 init();
181} 192}
182 193
183/* 194/*
184 Create an agenda widget with columns columns and one row. This is used for 195 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 196 all-day events.
186*/ 197*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 198KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 199 QScrollView(parent,name,f)
189{ 200{
190 201 mNewItemPopup = new QPopupMenu( this );
202 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
203 QString pathString = "";
204 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
205 if ( QApplication::desktop()->width() < 480 )
206 pathString += "icons16/";
207 } else
208 pathString += "iconsmini/";
209 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."),1 );
210 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
191 blockResize = false; 211 blockResize = false;
192 mColumns = columns; 212 mColumns = columns;
193 mRows = 1; 213 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 214 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 215 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 216 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 217#ifndef DESKTOP_VERSION
198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 218 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 219#endif
200 mHolidayMask = 0; 220 mHolidayMask = 0;
201 init(); 221 init();
202} 222}
203 223
204 224
205KOAgenda::~KOAgenda() 225KOAgenda::~KOAgenda()
206{ 226{
207 if(mMarcusBains) delete mMarcusBains; 227 if(mMarcusBains) delete mMarcusBains;
208 228
209} 229}
210 230
211Incidence *KOAgenda::selectedIncidence() const 231Incidence *KOAgenda::selectedIncidence() const
212{ 232{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 233 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 234}
215 235
216 236
217QDate KOAgenda::selectedIncidenceDate() const 237QDate KOAgenda::selectedIncidenceDate() const
218{ 238{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 239 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 240}
221 241
222 242
223void KOAgenda::init() 243void KOAgenda::init()
224{ 244{
225#ifndef _WIN32_ 245#ifndef _WIN32_
226 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
227 viewport()->setWFlags ( wflags); 247 viewport()->setWFlags ( wflags);
228#endif 248#endif
229 mGridSpacingX = 80; 249 mGridSpacingX = 80;
230 mResizeBorderWidth = 8; 250 mResizeBorderWidth = 8;
231 mScrollBorderWidth = 8; 251 mScrollBorderWidth = 8;
232 mScrollDelay = 30; 252 mScrollDelay = 30;
233 mScrollOffset = 10; 253 mScrollOffset = 10;
234 mPaintPixmap.resize( 20,20); 254 mPaintPixmap.resize( 20,20);
235 //enableClipper(true); 255 //enableClipper(true);
236 256
237 // Grab key strokes for keyboard navigation of agenda. Seems to have no 257 // Grab key strokes for keyboard navigation of agenda. Seems to have no
238 // effect. Has to be fixed. 258 // effect. Has to be fixed.
@@ -373,294 +393,326 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
373 if (object != viewport()) { 393 if (object != viewport()) {
374 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 394 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
375 } else { 395 } else {
376 viewportPos = me->pos(); 396 viewportPos = me->pos();
377 } 397 }
378 static int startX = 0; 398 static int startX = 0;
379 static int startY = 0; 399 static int startY = 0;
380 static bool block = true; 400 static bool block = true;
381 switch (me->type()) { 401 switch (me->type()) {
382 case QEvent::MouseButtonPress: 402 case QEvent::MouseButtonPress:
383 //qDebug("QEvent::MouseButtonPress: "); 403 //qDebug("QEvent::MouseButtonPress: ");
384 // kdDebug() << "koagenda: filtered button press" << endl; 404 // kdDebug() << "koagenda: filtered button press" << endl;
385 if (object != viewport()) { 405 if (object != viewport()) {
386 if (me->button() == RightButton) { 406 if (me->button() == RightButton) {
387 407
388 mClickedItem = (KOAgendaItem *)object; 408 mClickedItem = (KOAgendaItem *)object;
389 if (mClickedItem) { 409 if (mClickedItem) {
390 selectItem(mClickedItem); 410 selectItem(mClickedItem);
391 // emit showIncidencePopupSignal(mClickedItem->incidence()); 411 // emit showIncidencePopupSignal(mClickedItem->incidence());
392 } 412 }
393 //mItemPopup->popup(QCursor::pos()); 413 //mItemPopup->popup(QCursor::pos());
394 } else { 414 } else {
395 mActionItem = (KOAgendaItem *)object; 415 mActionItem = (KOAgendaItem *)object;
396 if (mActionItem) { 416 if (mActionItem) {
397 if ( mSelectionHeight > 0 ) { 417 if ( mSelectionHeight > 0 ) {
398 int selectionCellX = mSelectionCellX * mGridSpacingX; 418 int selectionCellX = mSelectionCellX * mGridSpacingX;
399 int selectionYTop = mSelectionYTop; 419 int selectionYTop = mSelectionYTop;
400 int gridSpacingX = mGridSpacingX; 420 int gridSpacingX = mGridSpacingX;
401 int selectionHeight = mSelectionHeight; 421 int selectionHeight = mSelectionHeight;
402 clearSelection(); 422 clearSelection();
403 repaintContents( selectionCellX, selectionYTop, 423 repaintContents( selectionCellX, selectionYTop,
404 gridSpacingX, selectionHeight,false ); 424 gridSpacingX, selectionHeight,false );
405 } 425 }
406 selectItem(mActionItem); 426 selectItem(mActionItem);
407 Incidence *incidence = mActionItem->incidence(); 427 Incidence *incidence = mActionItem->incidence();
408 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 428 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
409 mActionItem = 0; 429 mActionItem = 0;
410 } else { 430 } else {
411 startItemAction(viewportPos); 431 startItemAction(viewportPos);
412 startX = viewportPos.x(); 432 startX = viewportPos.x();
413 startY = viewportPos.y(); 433 startY = viewportPos.y();
414 block = true; 434 block = true;
415 } 435 }
416 } 436 }
417 } 437 }
418 } else { 438 } else {
419 selectItem(0); 439 selectItem(0);
420 mActionItem = 0; 440 mActionItem = 0;
421 setCursor(arrowCursor); 441 if (me->button() == RightButton ) {
422 startSelectAction(viewportPos); 442 blockNewEvent = true;
443 qDebug("right ");
444 int x,y;
445 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
446 int gx,gy;
447 contentsToGrid(x,y,gx,gy);
448 mStartCellX = gx;
449 mStartCellY = gy;
450 mCurrentCellX = gx;
451 mCurrentCellY = gy;
452 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
453
454 } else {
455 blockNewEvent = false;
456 setCursor(arrowCursor);
457 startSelectAction(viewportPos);
458 }
423 } 459 }
424 break; 460 break;
425 461
426 case QEvent::MouseButtonRelease: 462 case QEvent::MouseButtonRelease:
427 //qDebug("QEvent::MouseButtonRelease: "); 463 //qDebug("QEvent::MouseButtonRelease: ");
428 if (me->button() == RightButton && block ) { 464 if (me->button() == RightButton && block ) {
429 if (object != viewport()) { 465 if (object != viewport()) {
430 mClickedItem = (KOAgendaItem *)object; 466 mClickedItem = (KOAgendaItem *)object;
431 if (mActionItem ) { 467 if (mActionItem ) {
432 endItemAction(); 468 endItemAction();
433 } 469 }
434 if (mClickedItem) { 470 if (mClickedItem) {
435 selectItem(mClickedItem); 471 selectItem(mClickedItem);
436 emit showIncidencePopupSignal(mClickedItem->incidence()); 472 emit showIncidencePopupSignal(mClickedItem->incidence());
437 } 473 }
438 } 474 }
439 break; 475 break;
440 } 476 }
441 block = true; 477 block = true;
442 if (mActionItem) { 478 if (mActionItem) {
443 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 479 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
444 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 480 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
445 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 481 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
446 mScrollUpTimer.stop(); 482 mScrollUpTimer.stop();
447 mScrollDownTimer.stop(); 483 mScrollDownTimer.stop();
448 mActionItem->resetMove(); 484 mActionItem->resetMove();
449 placeSubCells( mActionItem ); 485 placeSubCells( mActionItem );
450 // emit startDragSignal( mActionItem->incidence() ); 486 // emit startDragSignal( mActionItem->incidence() );
451 setCursor( arrowCursor ); 487 setCursor( arrowCursor );
452 mActionItem = 0; 488 mActionItem = 0;
453 mActionType = NOP; 489 mActionType = NOP;
454 mItemMoved = 0; 490 mItemMoved = 0;
455 return true; 491 return true;
456 } 492 }
457 endItemAction(); 493 endItemAction();
458 } else if ( mActionType == SELECT ) { 494 } else if ( mActionType == SELECT ) {
459 endSelectAction(); 495 if (me->button() == RightButton ) {
496
497 } else {
498 endSelectAction( !blockNewEvent );
499 }
460 } 500 }
461 break; 501 break;
462 502
463 case QEvent::MouseMove: 503 case QEvent::MouseMove:
464 if (object != viewport()) { 504 if (object != viewport()) {
465 KOAgendaItem *moveItem = (KOAgendaItem *)object; 505 KOAgendaItem *moveItem = (KOAgendaItem *)object;
466 //qDebug("moveItem %d ",moveItem ); 506 //qDebug("moveItem %d ",moveItem );
467 if (!moveItem->incidence()->isReadOnly() /*&& 507 if (!moveItem->incidence()->isReadOnly() /*&&
468 !moveItem->incidence()->recurrence()->doesRecur()*/ ) 508 !moveItem->incidence()->recurrence()->doesRecur()*/ )
469 if (!mActionItem) 509 if (!mActionItem)
470 setNoActionCursor(moveItem,viewportPos); 510 setNoActionCursor(moveItem,viewportPos);
471 else { 511 else {
472 if ( block ) { 512 if ( block ) {
473 int dX, dY; 513 int dX, dY;
474 dX = startX - viewportPos.x(); 514 dX = startX - viewportPos.x();
475 if ( dX < 0 ) 515 if ( dX < 0 )
476 dX = -dX; 516 dX = -dX;
477 dY = viewportPos.y() - startY; 517 dY = viewportPos.y() - startY;
478 if ( dY < 0 ) 518 if ( dY < 0 )
479 dY = -dY; 519 dY = -dY;
480 int diff = 30; 520 int diff = 30;
481 if ( QApplication::desktop()->width() < 480 ) 521 if ( QApplication::desktop()->width() < 480 )
482 diff = 15; 522 diff = 15;
483 // qDebug(" %d %d ",dX, dY ); 523 // qDebug(" %d %d ",dX, dY );
484 if ( dX > diff || dY > diff ) { 524 if ( dX > diff || dY > diff ) {
485 block = false; 525 block = false;
486 } 526 }
487 } 527 }
488 if ( !block ) 528 if ( !block )
489 performItemAction(viewportPos); 529 performItemAction(viewportPos);
490 } 530 }
491 } else { 531 } else {
492 if ( mActionType == SELECT ) { 532 if ( mActionType == SELECT ) {
493 performSelectAction( viewportPos ); 533 performSelectAction( viewportPos );
494 } 534 }
495 } 535 }
496 break; 536 break;
497 537
498 case QEvent::MouseButtonDblClick: 538 case QEvent::MouseButtonDblClick:
499 if (object == viewport()) { 539 if (object == viewport()) {
500 selectItem(0); 540 selectItem(0);
501 int x,y; 541 int x,y;
502 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 542 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
503 int gx,gy; 543 int gx,gy;
504 contentsToGrid(x,y,gx,gy); 544 contentsToGrid(x,y,gx,gy);
505 emit newEventSignal(gx,gy); 545 emit newEventSignal(gx,gy);
506 } else { 546 } else {
507 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 547 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
508 selectItem(doubleClickedItem); 548 selectItem(doubleClickedItem);
509 if ( KOPrefs::instance()->mEditOnDoubleClick ) 549 if ( KOPrefs::instance()->mEditOnDoubleClick )
510 emit editIncidenceSignal(doubleClickedItem->incidence()); 550 emit editIncidenceSignal(doubleClickedItem->incidence());
511 else 551 else
512 emit showIncidenceSignal(doubleClickedItem->incidence()); 552 emit showIncidenceSignal(doubleClickedItem->incidence());
513 } 553 }
514 break; 554 break;
515 555
516 default: 556 default:
517 break; 557 break;
518 } 558 }
519 559
520 return true; 560 return true;
521} 561}
522 562
563void KOAgenda::newItem( int item )
564{
565 qDebug("new %d ", item);
566 if ( item == 1 ) { //new event
567 newEventSignal(mStartCellX ,mStartCellY );
568 }
569 if ( item == 2 ) { //new event
570 newTodoSignal(mStartCellX ,mStartCellY );
571 }
572}
523void KOAgenda::startSelectAction(QPoint viewportPos) 573void KOAgenda::startSelectAction(QPoint viewportPos)
524{ 574{
525 //emit newStartSelectSignal(); 575 //emit newStartSelectSignal();
526 576
527 mActionType = SELECT; 577 mActionType = SELECT;
528 578
529 int x,y; 579 int x,y;
530 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 580 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
531 int gx,gy; 581 int gx,gy;
532 contentsToGrid(x,y,gx,gy); 582 contentsToGrid(x,y,gx,gy);
533 583
534 mStartCellX = gx; 584 mStartCellX = gx;
535 mStartCellY = gy; 585 mStartCellY = gy;
536 mCurrentCellX = gx; 586 mCurrentCellX = gx;
537 mCurrentCellY = gy; 587 mCurrentCellY = gy;
538 588
539 // Store coordinates of old selection 589 // Store coordinates of old selection
540 int selectionX = mSelectionCellX * mGridSpacingX; 590 int selectionX = mSelectionCellX * mGridSpacingX;
541 int selectionYTop = mSelectionYTop; 591 int selectionYTop = mSelectionYTop;
542 int selectionHeight = mSelectionHeight; 592 int selectionHeight = mSelectionHeight;
543 593
544 // Store new selection 594 // Store new selection
545 mSelectionCellX = gx; 595 mSelectionCellX = gx;
546 mSelectionYTop = gy * mGridSpacingY; 596 mSelectionYTop = gy * mGridSpacingY;
547 mSelectionHeight = mGridSpacingY; 597 mSelectionHeight = mGridSpacingY;
548 598
549 // Clear old selection 599 // Clear old selection
550 repaintContents( selectionX, selectionYTop, 600 repaintContents( selectionX, selectionYTop,
551 mGridSpacingX, selectionHeight,false ); 601 mGridSpacingX, selectionHeight,false );
552 602
553 // Paint new selection 603 // Paint new selection
554 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 604 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
555 // mGridSpacingX, mSelectionHeight ); 605 // mGridSpacingX, mSelectionHeight );
556} 606}
557 607
558void KOAgenda::performSelectAction(QPoint viewportPos) 608void KOAgenda::performSelectAction(QPoint viewportPos)
559{ 609{
560 int x,y; 610 int x,y;
561 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 611 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
562 int gx,gy; 612 int gx,gy;
563 contentsToGrid(x,y,gx,gy); 613 contentsToGrid(x,y,gx,gy);
564 614
565 QPoint clipperPos = clipper()-> 615 QPoint clipperPos = clipper()->
566 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 616 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
567 617
568 // Scroll if cursor was moved to upper or lower end of agenda. 618 // Scroll if cursor was moved to upper or lower end of agenda.
569 if (clipperPos.y() < mScrollBorderWidth) { 619 if (clipperPos.y() < mScrollBorderWidth) {
570 mScrollUpTimer.start(mScrollDelay); 620 mScrollUpTimer.start(mScrollDelay);
571 } else if (visibleHeight() - clipperPos.y() < 621 } else if (visibleHeight() - clipperPos.y() <
572 mScrollBorderWidth) { 622 mScrollBorderWidth) {
573 mScrollDownTimer.start(mScrollDelay); 623 mScrollDownTimer.start(mScrollDelay);
574 } else { 624 } else {
575 mScrollUpTimer.stop(); 625 mScrollUpTimer.stop();
576 mScrollDownTimer.stop(); 626 mScrollDownTimer.stop();
577 } 627 }
578 628
579 if ( gy > mCurrentCellY ) { 629 if ( gy > mCurrentCellY ) {
580 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 630 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
581 631
582#if 0 632#if 0
583 // FIXME: Repaint only the newly selected region 633 // FIXME: Repaint only the newly selected region
584 repaintContents( mSelectionCellX * mGridSpacingX, 634 repaintContents( mSelectionCellX * mGridSpacingX,
585 mCurrentCellY + mGridSpacingY, 635 mCurrentCellY + mGridSpacingY,
586 mGridSpacingX, 636 mGridSpacingX,
587 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 637 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
588#else 638#else
589 repaintContents( (KOGlobals::self()->reverseLayout() ? 639 repaintContents( (KOGlobals::self()->reverseLayout() ?
590 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 640 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
591 mGridSpacingX, mSelectionYTop, 641 mGridSpacingX, mSelectionYTop,
592 mGridSpacingX, mSelectionHeight , false); 642 mGridSpacingX, mSelectionHeight , false);
593#endif 643#endif
594 644
595 mCurrentCellY = gy; 645 mCurrentCellY = gy;
596 } else if ( gy < mCurrentCellY ) { 646 } else if ( gy < mCurrentCellY ) {
597 if ( gy >= mStartCellY ) { 647 if ( gy >= mStartCellY ) {
598 int selectionHeight = mSelectionHeight; 648 int selectionHeight = mSelectionHeight;
599 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 649 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
600 650
601 repaintContents( (KOGlobals::self()->reverseLayout() ? 651 repaintContents( (KOGlobals::self()->reverseLayout() ?
602 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 652 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
603 mGridSpacingX, mSelectionYTop, 653 mGridSpacingX, mSelectionYTop,
604 mGridSpacingX, selectionHeight,false ); 654 mGridSpacingX, selectionHeight,false );
605 655
606 mCurrentCellY = gy; 656 mCurrentCellY = gy;
607 } else { 657 } else {
608 } 658 }
609 } 659 }
610} 660}
611 661
612void KOAgenda::endSelectAction() 662void KOAgenda::endSelectAction( bool emitNewEvent )
613{ 663{
614 mActionType = NOP; 664 mActionType = NOP;
615 mScrollUpTimer.stop(); 665 mScrollUpTimer.stop();
616 mScrollDownTimer.stop(); 666 mScrollDownTimer.stop();
617 667
618 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 668 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
669 if ( emitNewEvent && mStartCellY < mCurrentCellY )
670 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
619} 671}
620 672
621void KOAgenda::startItemAction(QPoint viewportPos) 673void KOAgenda::startItemAction(QPoint viewportPos)
622{ 674{
623 int x,y; 675 int x,y;
624 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 676 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
625 int gx,gy; 677 int gx,gy;
626 contentsToGrid(x,y,gx,gy); 678 contentsToGrid(x,y,gx,gy);
627 679
628 mStartCellX = gx; 680 mStartCellX = gx;
629 mStartCellY = gy; 681 mStartCellY = gy;
630 mCurrentCellX = gx; 682 mCurrentCellX = gx;
631 mCurrentCellY = gy; 683 mCurrentCellY = gy;
632 684
633 if (mAllDayMode) { 685 if (mAllDayMode) {
634 int gridDistanceX = (x - gx * mGridSpacingX); 686 int gridDistanceX = (x - gx * mGridSpacingX);
635 if (gridDistanceX < mResizeBorderWidth && 687 if (gridDistanceX < mResizeBorderWidth &&
636 mActionItem->cellX() == mCurrentCellX) { 688 mActionItem->cellX() == mCurrentCellX) {
637 mActionType = RESIZELEFT; 689 mActionType = RESIZELEFT;
638 setCursor(sizeHorCursor); 690 setCursor(sizeHorCursor);
639 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 691 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
640 mActionItem->cellXWidth() == mCurrentCellX) { 692 mActionItem->cellXWidth() == mCurrentCellX) {
641 mActionType = RESIZERIGHT; 693 mActionType = RESIZERIGHT;
642 setCursor(sizeHorCursor); 694 setCursor(sizeHorCursor);
643 } else { 695 } else {
644 mActionType = MOVE; 696 mActionType = MOVE;
645 mActionItem->startMove(); 697 mActionItem->startMove();
646 setCursor(sizeAllCursor); 698 setCursor(sizeAllCursor);
647 } 699 }
648 } else { 700 } else {
649 int gridDistanceY = (y - gy * mGridSpacingY); 701 int gridDistanceY = (y - gy * mGridSpacingY);
650 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 702 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
651 if (allowResize && gridDistanceY < mResizeBorderWidth && 703 if (allowResize && gridDistanceY < mResizeBorderWidth &&
652 mActionItem->cellYTop() == mCurrentCellY && 704 mActionItem->cellYTop() == mCurrentCellY &&
653 !mActionItem->firstMultiItem()) { 705 !mActionItem->firstMultiItem()) {
654 mActionType = RESIZETOP; 706 mActionType = RESIZETOP;
655 setCursor(sizeVerCursor); 707 setCursor(sizeVerCursor);
656 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 708 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
657 mActionItem->cellYBottom() == mCurrentCellY && 709 mActionItem->cellYBottom() == mCurrentCellY &&
658 !mActionItem->lastMultiItem()) { 710 !mActionItem->lastMultiItem()) {
659 mActionType = RESIZEBOTTOM; 711 mActionType = RESIZEBOTTOM;
660 setCursor(sizeVerCursor); 712 setCursor(sizeVerCursor);
661 } else { 713 } else {
662 mActionType = MOVE; 714 mActionType = MOVE;
663 mActionItem->startMove(); 715 mActionItem->startMove();
664 setCursor(sizeAllCursor); 716 setCursor(sizeAllCursor);
665 } 717 }
666 } 718 }
@@ -1615,97 +1667,97 @@ void KOAgenda::computeSizes()
1615 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1667 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1616 emit resizedSignal(); 1668 emit resizedSignal();
1617 } else 1669 } else
1618 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1670 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1619 KOAgendaItem *item; 1671 KOAgendaItem *item;
1620 int subCellWidth; 1672 int subCellWidth;
1621 1673
1622 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1674 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1623 subCellWidth = mGridSpacingX / item->subCells(); 1675 subCellWidth = mGridSpacingX / item->subCells();
1624 item->resize(subCellWidth,item->height()); 1676 item->resize(subCellWidth,item->height());
1625 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1677 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1626 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1678 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1627 item->cellX() * mGridSpacingX) + 1679 item->cellX() * mGridSpacingX) +
1628 item->subCell() * subCellWidth,childY(item)); 1680 item->subCell() * subCellWidth,childY(item));
1629 } 1681 }
1630 } 1682 }
1631 int cw = contentsWidth(); 1683 int cw = contentsWidth();
1632 int ch = contentsHeight(); 1684 int ch = contentsHeight();
1633 if ( mAllDayMode ) { 1685 if ( mAllDayMode ) {
1634 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1686 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1635 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 1687 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1636 paintPixAll->resize( cw, ch ); 1688 paintPixAll->resize( cw, ch );
1637 } else { 1689 } else {
1638 QPixmap* paintPix = KOAgendaItem::paintPix(); 1690 QPixmap* paintPix = KOAgendaItem::paintPix();
1639 if ( paintPix->width() < cw || paintPix->height() < ch ) 1691 if ( paintPix->width() < cw || paintPix->height() < ch )
1640 KOAgendaItem::resizePixmap( cw , ch ); 1692 KOAgendaItem::resizePixmap( cw , ch );
1641 } 1693 }
1642 1694
1643 checkScrollBoundaries(); 1695 checkScrollBoundaries();
1644 marcus_bains(); 1696 marcus_bains();
1645 drawContentsToPainter(); 1697 drawContentsToPainter();
1646 viewport()->repaint(false); 1698 viewport()->repaint(false);
1647} 1699}
1648 1700
1649void KOAgenda::scrollUp() 1701void KOAgenda::scrollUp()
1650{ 1702{
1651 scrollBy(0,-mScrollOffset); 1703 scrollBy(0,-mScrollOffset);
1652} 1704}
1653 1705
1654 1706
1655void KOAgenda::scrollDown() 1707void KOAgenda::scrollDown()
1656{ 1708{
1657 scrollBy(0,mScrollOffset); 1709 scrollBy(0,mScrollOffset);
1658} 1710}
1659 1711
1660void KOAgenda::popupAlarm() 1712void KOAgenda::popupAlarm()
1661{ 1713{
1662 if (!mClickedItem) { 1714 if (!mClickedItem) {
1663 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; 1715 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1664 return; 1716 return;
1665 } 1717 }
1666// TODO: deal correctly with multiple alarms 1718// TODO: deal correctly with multiple alarms
1667 Alarm* alarm; 1719 Alarm* alarm;
1668 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1720 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1669 for(alarm=list.first();alarm;alarm=list.next()) { 1721 for(alarm=list.first();alarm;alarm=list.next()) {
1670 alarm->toggleAlarm(); 1722 alarm->toggleAlarm();
1671 } 1723 }
1672 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1724 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1673 mClickedItem->paintMe( true ); 1725 mClickedItem->paintMe( true );
1674 mClickedItem->repaint( false ); 1726 mClickedItem->repaint( false );
1675} 1727}
1676 1728
1677/* 1729/*
1678 Calculates the minimum width 1730 Calculates the minimum width
1679*/ 1731*/
1680int KOAgenda::minimumWidth() const 1732int KOAgenda::minimumWidth() const
1681{ 1733{
1682 // TODO:: develop a way to dynamically determine the minimum width 1734 // TODO:: develop a way to dynamically determine the minimum width
1683 int min = 100; 1735 int min = 100;
1684 1736
1685 return min; 1737 return min;
1686} 1738}
1687 1739
1688void KOAgenda::updateConfig() 1740void KOAgenda::updateConfig()
1689{ 1741{
1690 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1742 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1691 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1743 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1692 if ( mAllDayMode ) { 1744 if ( mAllDayMode ) {
1693 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1745 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1694 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1746 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1695 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1747 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1696 // setMaximumHeight( mGridSpacingY+1 ); 1748 // setMaximumHeight( mGridSpacingY+1 );
1697 viewport()->repaint( false ); 1749 viewport()->repaint( false );
1698 //setFixedHeight( mGridSpacingY+1 ); 1750 //setFixedHeight( mGridSpacingY+1 );
1699 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1751 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1700 } 1752 }
1701 else { 1753 else {
1702 mGridSpacingY = KOPrefs::instance()->mHourSize; 1754 mGridSpacingY = KOPrefs::instance()->mHourSize;
1703 calculateWorkingHours(); 1755 calculateWorkingHours();
1704 marcus_bains(); 1756 marcus_bains();
1705 } 1757 }
1706} 1758}
1707 1759
1708void KOAgenda::checkScrollBoundaries() 1760void KOAgenda::checkScrollBoundaries()
1709{ 1761{
1710 // Invalidate old values to force update 1762 // Invalidate old values to force update
1711 mOldLowerScrollValue = -1; 1763 mOldLowerScrollValue = -1;
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 111242f..12943d7 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -81,206 +81,210 @@ class KOAgenda : public QScrollView
81 virtual bool eventFilter ( QObject *, QEvent * ); 81 virtual bool eventFilter ( QObject *, QEvent * );
82 82
83 void contentsToGrid (int x, int y, int& gx, int& gy); 83 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y); 84 void gridToContents (int gx, int gy, int& x, int& y);
85 85
86 int timeToY (const QTime &time); 86 int timeToY (const QTime &time);
87 QTime gyToTime (int y); 87 QTime gyToTime (int y);
88 88
89 void setStartHour(int startHour); 89 void setStartHour(int startHour);
90 90
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom); 94 int YTop,int YBottom);
95 95
96 void changeColumns(int columns); 96 void changeColumns(int columns);
97 97
98 int columns() { return mColumns; } 98 int columns() { return mColumns; }
99 int rows() { return mRows; } 99 int rows() { return mRows; }
100 100
101 int gridSpacingX() const { return mGridSpacingX; } 101 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; } 102 int gridSpacingY() const { return mGridSpacingY; }
103 103
104// virtual QSizePolicy sizePolicy() const; 104// virtual QSizePolicy sizePolicy() const;
105 105
106 void clear(); 106 void clear();
107 107
108 void clearSelection(); 108 void clearSelection();
109 void hideUnused(); 109 void hideUnused();
110 110
111 /** Calculates the minimum width */ 111 /** Calculates the minimum width */
112 virtual int minimumWidth() const; 112 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */ 113 /** Update configuration from preference settings */
114 void updateConfig(); 114 void updateConfig();
115 115
116 void checkScrollBoundaries(); 116 void checkScrollBoundaries();
117 117
118 void setHolidayMask(QMemArray<bool> *); 118 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates); 119 void setDateList(const DateList &selectedDates);
120 DateList dateList() const; 120 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate(); 122 void finishUpdate();
123 void printSelection(); 123 void printSelection();
124 void storePosition(); 124 void storePosition();
125 void restorePosition(); 125 void restorePosition();
126 126
127 127
128 public slots: 128 public slots:
129 void newItem( int );
129 void moveChild( QWidget *, int, int ); 130 void moveChild( QWidget *, int, int );
130 void scrollUp(); 131 void scrollUp();
131 void scrollDown(); 132 void scrollDown();
132 void updateTodo( Todo * t, int , bool ); 133 void updateTodo( Todo * t, int , bool );
133 void popupAlarm(); 134 void popupAlarm();
134 135
135 void checkScrollBoundaries(int); 136 void checkScrollBoundaries(int);
136 137
137 /** Deselect selected items. This function does not emit any signals. */ 138 /** Deselect selected items. This function does not emit any signals. */
138 void deselectItem(); 139 void deselectItem();
139 /** Select item. If the argument is 0, the currently selected item gets 140 /** Select item. If the argument is 0, the currently selected item gets
140 deselected. This function emits the itemSelected(bool) signal to inform 141 deselected. This function emits the itemSelected(bool) signal to inform
141 about selection/deseelction of events. */ 142 about selection/deseelction of events. */
142 void selectItem(KOAgendaItem *); 143 void selectItem(KOAgendaItem *);
143 void finishResize(); 144 void finishResize();
144 145
145 signals: 146 signals:
146 void newEventSignal(); 147 void newEventSignal();
147 void newEventSignal(int gx,int gy); 148 void newEventSignal(int gx,int gy);
149 void newTodoSignal(int gx,int gy);
148 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 150 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
149 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 151 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
150 void newStartSelectSignal(); 152 void newStartSelectSignal();
151 void showIncidenceSignal(Incidence *); 153 void showIncidenceSignal(Incidence *);
152 void editIncidenceSignal(Incidence *); 154 void editIncidenceSignal(Incidence *);
153 void deleteIncidenceSignal(Incidence *); 155 void deleteIncidenceSignal(Incidence *);
154 void showIncidencePopupSignal(Incidence *); 156 void showIncidencePopupSignal(Incidence *);
155 157
156 void itemModified(KOAgendaItem *item, int ); 158 void itemModified(KOAgendaItem *item, int );
157 void incidenceSelected(Incidence *); 159 void incidenceSelected(Incidence *);
158 160
159 void lowerYChanged(int); 161 void lowerYChanged(int);
160 void upperYChanged(int); 162 void upperYChanged(int);
161 163
162 void startDragSignal(Incidence *); 164 void startDragSignal(Incidence *);
163 void addToCalSignal(Incidence *, Incidence *); 165 void addToCalSignal(Incidence *, Incidence *);
164 void resizedSignal(); 166 void resizedSignal();
165 167
166 protected: 168 protected:
167 QPainter mPixPainter; 169 QPainter mPixPainter;
168 QPixmap mPaintPixmap; 170 QPixmap mPaintPixmap;
169 QPixmap mHighlightPixmap; 171 QPixmap mHighlightPixmap;
170 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 172 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
171 virtual void resizeEvent ( QResizeEvent * ); 173 virtual void resizeEvent ( QResizeEvent * );
172 174
173 /** Handles mouse events. Called from eventFilter */ 175 /** Handles mouse events. Called from eventFilter */
174 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 176 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
175 177
176 /** Start selecting time span. */ 178 /** Start selecting time span. */
177 void startSelectAction(QPoint viewportPos); 179 void startSelectAction(QPoint viewportPos);
178 180
179 /** Select time span. */ 181 /** Select time span. */
180 void performSelectAction(QPoint viewportPos); 182 void performSelectAction(QPoint viewportPos);
181 183
182 /** Emd selecting time span. */ 184 /** Emd selecting time span. */
183 void endSelectAction(); 185 void endSelectAction( bool emitNewEvent = false );
184 186
185 /** Start moving/resizing agenda item */ 187 /** Start moving/resizing agenda item */
186 void startItemAction(QPoint viewportPos); 188 void startItemAction(QPoint viewportPos);
187 189
188 /** Move/resize agenda item */ 190 /** Move/resize agenda item */
189 void performItemAction(QPoint viewportPos); 191 void performItemAction(QPoint viewportPos);
190 192
191 /** End moving/resizing agenda item */ 193 /** End moving/resizing agenda item */
192 void endItemAction(); 194 void endItemAction();
193 195
194 /** Set cursor, when no item action is in progress */ 196 /** Set cursor, when no item action is in progress */
195 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 197 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
196 198
197 /** Place agenda item in agenda and adjust other cells if necessary */ 199 /** Place agenda item in agenda and adjust other cells if necessary */
198 void placeSubCells(KOAgendaItem *placeItem); 200 void placeSubCells(KOAgendaItem *placeItem);
199 201
200 /** Process the keyevent, including the ignored keyevents of eventwidgets. 202 /** Process the keyevent, including the ignored keyevents of eventwidgets.
201 * Implements pgup/pgdn and cursor key navigation in the view. 203 * Implements pgup/pgdn and cursor key navigation in the view.
202 */ 204 */
203 void keyPressEvent( QKeyEvent * ); 205 void keyPressEvent( QKeyEvent * );
204 206
205 void calculateWorkingHours(); 207 void calculateWorkingHours();
206 208
207 virtual void contentsMousePressEvent ( QMouseEvent * ); 209 virtual void contentsMousePressEvent ( QMouseEvent * );
208 210
209 private: 211 private:
212 bool blockNewEvent;
210 void init(); 213 void init();
211 void marcus_bains(); 214 void marcus_bains();
212 bool mAllDayMode; 215 bool mAllDayMode;
213 bool blockResize; 216 bool blockResize;
214 QTimer mResizeTimer; 217 QTimer mResizeTimer;
215 double mContentPosition; 218 double mContentPosition;
216 219
217 // Width and height of agenda cells 220 // Width and height of agenda cells
218 int mGridSpacingX; 221 int mGridSpacingX;
219 int mGridSpacingY; 222 int mGridSpacingY;
220 223
221 // size of border, where mouse action will resize the KOAgendaItem 224 // size of border, where mouse action will resize the KOAgendaItem
222 int mResizeBorderWidth; 225 int mResizeBorderWidth;
223 226
224 // size of border, where mouse mve will cause a scroll of the agenda 227 // size of border, where mouse mve will cause a scroll of the agenda
225 int mScrollBorderWidth; 228 int mScrollBorderWidth;
226 int mScrollDelay; 229 int mScrollDelay;
227 int mScrollOffset; 230 int mScrollOffset;
228 231
229 QTimer mScrollUpTimer; 232 QTimer mScrollUpTimer;
230 QTimer mScrollDownTimer; 233 QTimer mScrollDownTimer;
231 234
232 // Number of Columns/Rows of agenda grid 235 // Number of Columns/Rows of agenda grid
233 int mColumns; 236 int mColumns;
234 int mRows; 237 int mRows;
235 238
236 // Cells to store Move and Resize coordiantes 239 // Cells to store Move and Resize coordiantes
237 int mStartCellX; 240 int mStartCellX;
238 int mStartCellY; 241 int mStartCellY;
239 int mCurrentCellX; 242 int mCurrentCellX;
240 int mCurrentCellY; 243 int mCurrentCellY;
241 244
242 // Working Hour coordiantes 245 // Working Hour coordiantes
243 bool mWorkingHoursEnable; 246 bool mWorkingHoursEnable;
244 int mWorkingHoursYTop; 247 int mWorkingHoursYTop;
245 int mWorkingHoursYBottom; 248 int mWorkingHoursYBottom;
246 249
247 // Selection 250 // Selection
248 int mSelectionCellX; 251 int mSelectionCellX;
249 int mSelectionYTop; 252 int mSelectionYTop;
250 int mSelectionHeight; 253 int mSelectionHeight;
251 254
252 // List of dates to be displayed 255 // List of dates to be displayed
253 DateList mSelectedDates; 256 DateList mSelectedDates;
254 257
255 // The KOAgendaItem, which has been right-clicked last 258 // The KOAgendaItem, which has been right-clicked last
256 KOAgendaItem *mClickedItem; 259 KOAgendaItem *mClickedItem;
257 260
258 // The KOAgendaItem, which is being moved/resized 261 // The KOAgendaItem, which is being moved/resized
259 QGuardedPtr<KOAgendaItem> mActionItem; 262 QGuardedPtr<KOAgendaItem> mActionItem;
260 263
261 // Currently selected item 264 // Currently selected item
262 QGuardedPtr<KOAgendaItem> mSelectedItem; 265 QGuardedPtr<KOAgendaItem> mSelectedItem;
263 266
264 // The Marcus Bains Line widget. 267 // The Marcus Bains Line widget.
265 MarcusBains *mMarcusBains; 268 MarcusBains *mMarcusBains;
266 void computeSizes(); 269 void computeSizes();
267 270
268 MouseActionType mActionType; 271 MouseActionType mActionType;
269 272
270 bool mItemMoved; 273 bool mItemMoved;
271 274
272 // List of all Items contained in agenda 275 // List of all Items contained in agenda
273 QPtrList<KOAgendaItem> mItems; 276 QPtrList<KOAgendaItem> mItems;
274 QPtrList<KOAgendaItem> mUnusedItems; 277 QPtrList<KOAgendaItem> mUnusedItems;
275 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 278 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
276 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 279 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
280 QPopupMenu *mNewItemPopup;
277 281
278 int mOldLowerScrollValue; 282 int mOldLowerScrollValue;
279 int mOldUpperScrollValue; 283 int mOldUpperScrollValue;
280 KOAgendaItem * getItemForTodo ( Todo * todo ); 284 KOAgendaItem * getItemForTodo ( Todo * todo );
281 QMemArray<bool> *mHolidayMask; 285 QMemArray<bool> *mHolidayMask;
282 int mCurPixWid; 286 int mCurPixWid;
283 int mCurPixHei; 287 int mCurPixHei;
284}; 288};
285 289
286#endif // KOAGENDA_H 290#endif // KOAGENDA_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index f54f7bc..60ae41f 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -443,100 +443,104 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
443 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 443 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
444 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 444 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
445 agendaLayout->addWidget(dummyAgendaRight,0,2); 445 agendaLayout->addWidget(dummyAgendaRight,0,2);
446 446
447 // Create time labels 447 // Create time labels
448 mTimeLabels = new TimeLabels(24,agendaFrame); 448 mTimeLabels = new TimeLabels(24,agendaFrame);
449 agendaLayout->addWidget(mTimeLabels,1,0); 449 agendaLayout->addWidget(mTimeLabels,1,0);
450 connect(mTimeLabels,SIGNAL( scaleChanged()), 450 connect(mTimeLabels,SIGNAL( scaleChanged()),
451 this,SLOT(updateConfig())); 451 this,SLOT(updateConfig()));
452 452
453 // Create agenda 453 // Create agenda
454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
456 agendaLayout->setColStretch(1,1); 456 agendaLayout->setColStretch(1,1);
457 mAgenda->setFocusPolicy(NoFocus); 457 mAgenda->setFocusPolicy(NoFocus);
458 // Create event context menu for agenda 458 // Create event context menu for agenda
459 mAgendaPopup = eventPopup(); 459 mAgendaPopup = eventPopup();
460 460
461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
462 i18n("Toggle Alarm"),mAgenda, 462 i18n("Toggle Alarm"),mAgenda,
463 SLOT(popupAlarm()),true); 463 SLOT(popupAlarm()),true);
464 464
465 465
466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
468 468
469 // make connections between dependent widgets 469 // make connections between dependent widgets
470 mTimeLabels->setAgenda(mAgenda); 470 mTimeLabels->setAgenda(mAgenda);
471 471
472 // Update widgets to reflect user preferences 472 // Update widgets to reflect user preferences
473 // updateConfig(); 473 // updateConfig();
474 474
475 // createDayLabels(); 475 // createDayLabels();
476 476
477 // these blank widgets make the All Day Event box line up with the agenda 477 // these blank widgets make the All Day Event box line up with the agenda
478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
481 481
482 // Scrolling 482 // Scrolling
483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
484 mTimeLabels, SLOT(positionChanged())); 484 mTimeLabels, SLOT(positionChanged()));
485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
486 SLOT(setContentsPos(int))); 486 SLOT(setContentsPos(int)));
487 487
488 // Create/Show/Edit/Delete Event 488 // Create/Show/Edit/Delete Event
489 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 489 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
490 SLOT(newEvent(int,int))); 490 SLOT(newEvent(int,int)));
491 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
492 SLOT(newTodo(int,int)));
491 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 493 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
492 SLOT(newEvent(int,int,int,int))); 494 SLOT(newEvent(int,int,int,int)));
493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 495 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
494 SLOT(newEventAllDay(int,int))); 496 SLOT(newEventAllDay(int,int)));
497 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
498 SLOT(newTodoAllDay(int,int)));
495 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 499 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
496 SLOT(newEventAllDay(int,int))); 500 SLOT(newEventAllDay(int,int)));
497 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 501 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
498 SLOT(newTimeSpanSelected(int,int,int,int))); 502 SLOT(newTimeSpanSelected(int,int,int,int)));
499 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 503 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
500 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 504 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
501 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 505 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
502 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 506 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
503 507
504 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 508 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
505 SIGNAL(editIncidenceSignal(Incidence *))); 509 SIGNAL(editIncidenceSignal(Incidence *)));
506 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 510 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
507 SIGNAL(editIncidenceSignal(Incidence *))); 511 SIGNAL(editIncidenceSignal(Incidence *)));
508 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 512 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
509 SIGNAL(showIncidenceSignal(Incidence *))); 513 SIGNAL(showIncidenceSignal(Incidence *)));
510 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 514 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
511 SIGNAL(showIncidenceSignal(Incidence *))); 515 SIGNAL(showIncidenceSignal(Incidence *)));
512 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 516 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
513 SIGNAL(deleteIncidenceSignal(Incidence *))); 517 SIGNAL(deleteIncidenceSignal(Incidence *)));
514 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 518 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
515 SIGNAL(deleteIncidenceSignal(Incidence *))); 519 SIGNAL(deleteIncidenceSignal(Incidence *)));
516 520
517 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 521 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
518 SLOT(updateEventDates(KOAgendaItem *, int ))); 522 SLOT(updateEventDates(KOAgendaItem *, int )));
519 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 523 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
520 SLOT(updateEventDates(KOAgendaItem *, int))); 524 SLOT(updateEventDates(KOAgendaItem *, int)));
521 525
522 // event indicator update 526 // event indicator update
523 connect(mAgenda,SIGNAL(lowerYChanged(int)), 527 connect(mAgenda,SIGNAL(lowerYChanged(int)),
524 SLOT(updateEventIndicatorTop(int))); 528 SLOT(updateEventIndicatorTop(int)));
525 connect(mAgenda,SIGNAL(upperYChanged(int)), 529 connect(mAgenda,SIGNAL(upperYChanged(int)),
526 SLOT(updateEventIndicatorBottom(int))); 530 SLOT(updateEventIndicatorBottom(int)));
527 // drag signals 531 // drag signals
528 /* 532 /*
529 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 533 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
530 SLOT(startDrag(Event *))); 534 SLOT(startDrag(Event *)));
531 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 535 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
532 SLOT(startDrag(Event *))); 536 SLOT(startDrag(Event *)));
533 */ 537 */
534 // synchronize selections 538 // synchronize selections
535 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 539 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
536 mAllDayAgenda, SLOT( deselectItem() ) ); 540 mAllDayAgenda, SLOT( deselectItem() ) );
537 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 541 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
538 mAgenda, SLOT( deselectItem() ) ); 542 mAgenda, SLOT( deselectItem() ) );
539 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 543 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
540 SIGNAL( incidenceSelected( Incidence * ) ) ); 544 SIGNAL( incidenceSelected( Incidence * ) ) );
541 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 545 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
542 SIGNAL( incidenceSelected( Incidence * ) ) ); 546 SIGNAL( incidenceSelected( Incidence * ) ) );
@@ -1238,96 +1242,111 @@ void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1238 else 1242 else
1239 calPrinter->preview(CalPrinter::Week, fd, td); 1243 calPrinter->preview(CalPrinter::Week, fd, td);
1240#endif 1244#endif
1241} 1245}
1242 1246
1243// void KOAgendaView::updateMovedTodo() 1247// void KOAgendaView::updateMovedTodo()
1244// { 1248// {
1245// // updateConfig(); 1249// // updateConfig();
1246// // emit updateTodoViews(); 1250// // emit updateTodoViews();
1247// } 1251// }
1248 1252
1249void KOAgendaView::newEvent(int gx, int gy) 1253void KOAgendaView::newEvent(int gx, int gy)
1250{ 1254{
1251 if (!mSelectedDates.count()) return; 1255 if (!mSelectedDates.count()) return;
1252 1256
1253 QDate day = mSelectedDates[gx]; 1257 QDate day = mSelectedDates[gx];
1254 1258
1255 QTime time = mAgenda->gyToTime(gy); 1259 QTime time = mAgenda->gyToTime(gy);
1256 QDateTime dt(day,time); 1260 QDateTime dt(day,time);
1257 // if ( dt < QDateTime::currentDateTime () ) 1261 // if ( dt < QDateTime::currentDateTime () )
1258 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1262 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1259 emit newEventSignal(dt); 1263 emit newEventSignal(dt);
1260} 1264}
1261 1265
1262void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1266void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1263{ 1267{
1264 if (!mSelectedDates.count()) return; 1268 if (!mSelectedDates.count()) return;
1265 1269
1266 QDate dayStart = mSelectedDates[gxStart]; 1270 QDate dayStart = mSelectedDates[gxStart];
1267 QDate dayEnd = mSelectedDates[gxEnd]; 1271 QDate dayEnd = mSelectedDates[gxEnd];
1268 1272
1269 QTime timeStart = mAgenda->gyToTime(gyStart); 1273 QTime timeStart = mAgenda->gyToTime(gyStart);
1270 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1274 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1271 1275
1272 QDateTime dtStart(dayStart,timeStart); 1276 QDateTime dtStart(dayStart,timeStart);
1273 QDateTime dtEnd(dayEnd,timeEnd); 1277 QDateTime dtEnd(dayEnd,timeEnd);
1274 1278
1275 emit newEventSignal(dtStart,dtEnd); 1279 emit newEventSignal(dtStart,dtEnd);
1276} 1280}
1277 1281
1278void KOAgendaView::newEventAllDay(int gx, int ) 1282void KOAgendaView::newEventAllDay(int gx, int )
1279{ 1283{
1280 if (!mSelectedDates.count()) return; 1284 if (!mSelectedDates.count()) return;
1281 1285
1282 QDate day = mSelectedDates[gx]; 1286 QDate day = mSelectedDates[gx];
1283 1287
1284 emit newEventSignal(day); 1288 emit newEventSignal(day);
1285} 1289}
1290void KOAgendaView::newTodoAllDay(int gx, int )
1291{
1292 if (!mSelectedDates.count()) return;
1293
1294 QDateTime day (mSelectedDates[gx] );
1295 emit newTodoSignal(day, true);
1296}
1297void KOAgendaView::newTodo(int gx, int gy )
1298{
1299 if (!mSelectedDates.count()) return;
1300 QDate dayStart = mSelectedDates[gx];
1301 QTime timeStart = mAgenda->gyToTime(gy);
1302 QDateTime dt (dayStart,timeStart);
1303 emit newTodoSignal( dt, false );
1304}
1286 1305
1287void KOAgendaView::updateEventIndicatorTop(int newY) 1306void KOAgendaView::updateEventIndicatorTop(int newY)
1288{ 1307{
1289 uint i; 1308 uint i;
1290 for(i=0;i<mMinY.size();++i) { 1309 for(i=0;i<mMinY.size();++i) {
1291 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1310 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1292 else mEventIndicatorTop->enableColumn(i,false); 1311 else mEventIndicatorTop->enableColumn(i,false);
1293 } 1312 }
1294 1313
1295 mEventIndicatorTop->update(); 1314 mEventIndicatorTop->update();
1296} 1315}
1297 1316
1298void KOAgendaView::updateEventIndicatorBottom(int newY) 1317void KOAgendaView::updateEventIndicatorBottom(int newY)
1299{ 1318{
1300 uint i; 1319 uint i;
1301 for(i=0;i<mMaxY.size();++i) { 1320 for(i=0;i<mMaxY.size();++i) {
1302 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1321 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1303 else mEventIndicatorBottom->enableColumn(i,false); 1322 else mEventIndicatorBottom->enableColumn(i,false);
1304 } 1323 }
1305 1324
1306 mEventIndicatorBottom->update(); 1325 mEventIndicatorBottom->update();
1307} 1326}
1308 1327
1309void KOAgendaView::startDrag(Event *event) 1328void KOAgendaView::startDrag(Event *event)
1310{ 1329{
1311#ifndef KORG_NODND 1330#ifndef KORG_NODND
1312 DndFactory factory( calendar() ); 1331 DndFactory factory( calendar() );
1313 ICalDrag *vd = factory.createDrag(event,this); 1332 ICalDrag *vd = factory.createDrag(event,this);
1314 if (vd->drag()) { 1333 if (vd->drag()) {
1315 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1334 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1316 } 1335 }
1317#endif 1336#endif
1318} 1337}
1319 1338
1320void KOAgendaView::readSettings() 1339void KOAgendaView::readSettings()
1321{ 1340{
1322 readSettings(KOGlobals::config()); 1341 readSettings(KOGlobals::config());
1323} 1342}
1324 1343
1325void KOAgendaView::readSettings(KConfig *config) 1344void KOAgendaView::readSettings(KConfig *config)
1326{ 1345{
1327 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1346 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1328 1347
1329 config->setGroup("Views"); 1348 config->setGroup("Views");
1330 1349
1331 //#ifndef KORG_NOSPLITTER 1350 //#ifndef KORG_NOSPLITTER
1332 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1351 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1333 if (sizes.count() == 2) { 1352 if (sizes.count() == 2) {
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 3cf938f..01d74a1 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -117,114 +117,117 @@ class EventIndicator : public QFrame {
117*/ 117*/
118class KOAgendaView : public KOEventView { 118class KOAgendaView : public KOEventView {
119 Q_OBJECT 119 Q_OBJECT
120 public: 120 public:
121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
122 virtual ~KOAgendaView(); 122 virtual ~KOAgendaView();
123 void setStartHour( int ); 123 void setStartHour( int );
124 void toggleAllDay(); 124 void toggleAllDay();
125 125
126 126
127 /** Returns maximum number of days supported by the koagendaview */ 127 /** Returns maximum number of days supported by the koagendaview */
128 virtual int maxDatesHint(); 128 virtual int maxDatesHint();
129 129
130 /** Returns number of currently shown dates. */ 130 /** Returns number of currently shown dates. */
131 virtual int currentDateCount(); 131 virtual int currentDateCount();
132 132
133 /** returns the currently selected events */ 133 /** returns the currently selected events */
134 virtual QPtrList<Incidence> selectedIncidences(); 134 virtual QPtrList<Incidence> selectedIncidences();
135 135
136 /** returns the currently selected events */ 136 /** returns the currently selected events */
137 virtual DateList selectedDates(); 137 virtual DateList selectedDates();
138 138
139 /** Remove all events from view */ 139 /** Remove all events from view */
140 void clearView(); 140 void clearView();
141 KOAgenda *agenda() { return mAgenda;} 141 KOAgenda *agenda() { return mAgenda;}
142 virtual void printPreview(CalPrinter *calPrinter, 142 virtual void printPreview(CalPrinter *calPrinter,
143 const QDate &, const QDate &); 143 const QDate &, const QDate &);
144 144
145 /** start-datetime of selection */ 145 /** start-datetime of selection */
146 QDateTime selectionStart() {return mTimeSpanBegin;} 146 QDateTime selectionStart() {return mTimeSpanBegin;}
147 /** end-datetime of selection */ 147 /** end-datetime of selection */
148 QDateTime selectionEnd() {return mTimeSpanEnd;} 148 QDateTime selectionEnd() {return mTimeSpanEnd;}
149 /** returns true if selection is for whole day */ 149 /** returns true if selection is for whole day */
150 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 150 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
151 /** make selected start/end invalid */ 151 /** make selected start/end invalid */
152 void deleteSelectedDateTime(); 152 void deleteSelectedDateTime();
153 void repaintAgenda(); 153 void repaintAgenda();
154 public slots: 154 public slots:
155 virtual void updateView(); 155 virtual void updateView();
156 virtual void updateConfig(); 156 virtual void updateConfig();
157 virtual void showDates(const QDate &start, const QDate &end); 157 virtual void showDates(const QDate &start, const QDate &end);
158 virtual void showEvents(QPtrList<Event> eventList); 158 virtual void showEvents(QPtrList<Event> eventList);
159 159
160 void updateTodo( Todo *, int ); 160 void updateTodo( Todo *, int );
161 void changeEventDisplay(Event *, int); 161 void changeEventDisplay(Event *, int);
162 162
163 void clearSelection(); 163 void clearSelection();
164 164
165 void newTodo(int gx,int gy);
165 void newEvent(int gx,int gy); 166 void newEvent(int gx,int gy);
166 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 167 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
167 void newEventAllDay(int gx, int gy); 168 void newEventAllDay(int gx, int gy);
169 void newTodoAllDay(int gx, int gy);
168 170
169 void startDrag(Event *); 171 void startDrag(Event *);
170 172
171 void readSettings(); 173 void readSettings();
172 void readSettings(KConfig *); 174 void readSettings(KConfig *);
173 void writeSettings(KConfig *); 175 void writeSettings(KConfig *);
174 176
175 void setContentsPos(int y); 177 void setContentsPos(int y);
176 178
177 void setExpandedButton( bool expanded ); 179 void setExpandedButton( bool expanded );
178 void scrollOneHourUp(); 180 void scrollOneHourUp();
179 void scrollOneHourDown(); 181 void scrollOneHourDown();
180 void addToCalSlot(Incidence *, Incidence *); 182 void addToCalSlot(Incidence *, Incidence *);
181 183
182 signals: 184 signals:
185 void newTodoSignal( QDateTime ,bool );
183 void toggleExpand(); 186 void toggleExpand();
184 void todoMoved( Todo *, int ); 187 void todoMoved( Todo *, int );
185 void incidenceChanged(Incidence * , int ); 188 void incidenceChanged(Incidence * , int );
186 // void cloneIncidenceSignal(Incidence *); 189 // void cloneIncidenceSignal(Incidence *);
187 190
188 protected: 191 protected:
189 bool mBlockUpdating; 192 bool mBlockUpdating;
190 int mUpcomingWidth; 193 int mUpcomingWidth;
191 /** Fill agenda beginning with date startDate */ 194 /** Fill agenda beginning with date startDate */
192 void fillAgenda(const QDate &startDate); 195 void fillAgenda(const QDate &startDate);
193 void resizeEvent( QResizeEvent* e ); 196 void resizeEvent( QResizeEvent* e );
194 /** Fill agenda using the current set value for the start date */ 197 /** Fill agenda using the current set value for the start date */
195 void fillAgenda(); 198 void fillAgenda();
196 199
197 /** Create labels for the selected dates. */ 200 /** Create labels for the selected dates. */
198 void createDayLabels(); 201 void createDayLabels();
199 202
200 /** 203 /**
201 Set the masks on the agenda widgets indicating, which days are holidays. 204 Set the masks on the agenda widgets indicating, which days are holidays.
202 */ 205 */
203 void setHolidayMasks(); 206 void setHolidayMasks();
204 207
205 protected slots: 208 protected slots:
206 /** Update event belonging to agenda item */ 209 /** Update event belonging to agenda item */
207 void updateEventDates(KOAgendaItem *item, int mode = -1); 210 void updateEventDates(KOAgendaItem *item, int mode = -1);
208 //void updateMovedTodo(); 211 //void updateMovedTodo();
209 212
210 void updateEventIndicatorTop(int newY); 213 void updateEventIndicatorTop(int newY);
211 void updateEventIndicatorBottom(int newY); 214 void updateEventIndicatorBottom(int newY);
212 215
213 /** Updates data for selected timespan */ 216 /** Updates data for selected timespan */
214 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 217 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
215 /** Updates data for selected timespan for all day event*/ 218 /** Updates data for selected timespan for all day event*/
216 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 219 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
217 220
218 private: 221 private:
219 // view widgets 222 // view widgets
220 QFrame *mDayLabels; 223 QFrame *mDayLabels;
221 QHBox *mDayLabelsFrame; 224 QHBox *mDayLabelsFrame;
222 QBoxLayout *mLayoutDayLabels; 225 QBoxLayout *mLayoutDayLabels;
223 QFrame *mAllDayFrame; 226 QFrame *mAllDayFrame;
224 KOAgenda *mAllDayAgenda; 227 KOAgenda *mAllDayAgenda;
225 KOAgenda *mAgenda; 228 KOAgenda *mAgenda;
226 TimeLabels *mTimeLabels; 229 TimeLabels *mTimeLabels;
227 QWidget *mDummyAllDayLeft; 230 QWidget *mDummyAllDayLeft;
228 231
229 KDGanttMinimizeSplitter* mSplitterAgenda; 232 KDGanttMinimizeSplitter* mSplitterAgenda;
230 QPushButton *mExpandButton; 233 QPushButton *mExpandButton;
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index 158a7d3..b9a028b 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -150,110 +150,115 @@ void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout)
150 mCompletedLabel = new QLabel(i18n("completed"),parent); 150 mCompletedLabel = new QLabel(i18n("completed"),parent);
151 topLayout->addWidget(mCompletedLabel); 151 topLayout->addWidget(mCompletedLabel);
152} 152}
153 153
154void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) 154void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout)
155{ 155{
156 156
157 QHBox* h = new QHBox ( parent ); 157 QHBox* h = new QHBox ( parent );
158 topLayout->addWidget( h ); 158 topLayout->addWidget( h );
159 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); 159 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h);
160 // topLayout->addWidget(priorityLabel); 160 // topLayout->addWidget(priorityLabel);
161 161
162 mPriorityCombo = new QComboBox( h ); 162 mPriorityCombo = new QComboBox( h );
163 mPriorityCombo->insertItem(i18n("1 (high)")); 163 mPriorityCombo->insertItem(i18n("1 (high)"));
164 mPriorityCombo->insertItem(i18n("2")); 164 mPriorityCombo->insertItem(i18n("2"));
165 mPriorityCombo->insertItem(i18n("3")); 165 mPriorityCombo->insertItem(i18n("3"));
166 mPriorityCombo->insertItem(i18n("4")); 166 mPriorityCombo->insertItem(i18n("4"));
167 mPriorityCombo->insertItem(i18n("5 (low)")); 167 mPriorityCombo->insertItem(i18n("5 (low)"));
168 //topLayout->addWidget(mPriorityCombo); 168 //topLayout->addWidget(mPriorityCombo);
169} 169}
170 170
171void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) 171void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout)
172{ 172{
173 QBoxLayout *statusLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *statusLayout = new QHBoxLayout(topLayout);
174 174
175 initCompletion( parent, statusLayout ); 175 initCompletion( parent, statusLayout );
176 176
177 statusLayout->addStretch( 1 ); 177 statusLayout->addStretch( 1 );
178 178
179 initPriority( parent, statusLayout ); 179 initPriority( parent, statusLayout );
180} 180}
181 181
182void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) 182void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
183{ 183{
184 184
185 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 185 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
186 mLocationEdit->load(KOLocationBox::LOCATION); 186 mLocationEdit->load(KOLocationBox::LOCATION);
187 KOEditorGeneral::setDefaults(allDay); 187 KOEditorGeneral::setDefaults(allDay);
188 188
189 mTimeButton->setChecked( !allDay ); 189 mTimeButton->setChecked( !allDay );
190 if(mTimeButton->isChecked()) { 190 if(mTimeButton->isChecked()) {
191 mTimeButton->setEnabled(true); 191 mTimeButton->setEnabled(true);
192 } 192 }
193 else { 193 else {
194 mTimeButton->setEnabled(false); 194 mTimeButton->setEnabled(false);
195 } 195 }
196 196
197 enableTimeEdits( !allDay ); 197 enableTimeEdits( !allDay );
198 198 if ( due.isValid() ) {
199 mDueCheck->setChecked(false); 199 mDueCheck->setChecked(true);
200 enableDueEdit(false); 200 enableDueEdit(true);
201 } else {
202 mDueCheck->setChecked(false);
203 enableDueEdit(false);
204 due = QDateTime::currentDateTime().addDays(7);
205 }
201 206
202 alarmDisable(true); 207 alarmDisable(true);
203 208
204 mStartCheck->setChecked(false); 209 mStartCheck->setChecked(false);
205 enableStartEdit(false); 210 enableStartEdit(false);
206 211
207 mDueDateEdit->setDate(due.date()); 212 mDueDateEdit->setDate(due.date());
208 mDueTimeEdit->setTime(due.time()); 213 mDueTimeEdit->setTime(due.time());
209 214 due = due.addDays(-7);
210 mStartDateEdit->setDate(QDate::currentDate()); 215 mStartDateEdit->setDate(due.date());
211 mStartTimeEdit->setTime(QTime::currentTime()); 216 mStartTimeEdit->setTime(due.time());
212 217
213 mPriorityCombo->setCurrentItem(2); 218 mPriorityCombo->setCurrentItem(2);
214 mCompletedLabel->setText(i18n("completed"));; 219 mCompletedLabel->setText(i18n("completed"));;
215 mCompletedCombo->setCurrentItem(0); 220 mCompletedCombo->setCurrentItem(0);
216} 221}
217 222
218void KOEditorGeneralTodo::readTodo(Todo *todo) 223void KOEditorGeneralTodo::readTodo(Todo *todo)
219{ 224{
220 225
221 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 226 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
222 mLocationEdit->load(KOLocationBox::LOCATION); 227 mLocationEdit->load(KOLocationBox::LOCATION);
223 KOEditorGeneral::readIncidence(todo); 228 KOEditorGeneral::readIncidence(todo);
224 229
225 QDateTime dueDT; 230 QDateTime dueDT;
226 231
227 if (todo->hasDueDate()) { 232 if (todo->hasDueDate()) {
228 enableAlarmEdit(true); 233 enableAlarmEdit(true);
229 dueDT = todo->dtDue(); 234 dueDT = todo->dtDue();
230 mDueDateEdit->setDate(todo->dtDue().date()); 235 mDueDateEdit->setDate(todo->dtDue().date());
231 mDueTimeEdit->setTime(todo->dtDue().time()); 236 mDueTimeEdit->setTime(todo->dtDue().time());
232 mDueCheck->setChecked(true); 237 mDueCheck->setChecked(true);
233 } else { 238 } else {
234 alarmDisable(true); 239 alarmDisable(true);
235 mDueDateEdit->setEnabled(false); 240 mDueDateEdit->setEnabled(false);
236 mDueTimeEdit->setEnabled(false); 241 mDueTimeEdit->setEnabled(false);
237 mDueDateEdit->setDate(QDate::currentDate()); 242 mDueDateEdit->setDate(QDate::currentDate());
238 mDueTimeEdit->setTime(QTime::currentTime()); 243 mDueTimeEdit->setTime(QTime::currentTime());
239 mDueCheck->setChecked(false); 244 mDueCheck->setChecked(false);
240 } 245 }
241 246
242 if (todo->hasStartDate()) { 247 if (todo->hasStartDate()) {
243 mStartDateEdit->setDate(todo->dtStart().date()); 248 mStartDateEdit->setDate(todo->dtStart().date());
244 mStartTimeEdit->setTime(todo->dtStart().time()); 249 mStartTimeEdit->setTime(todo->dtStart().time());
245 mStartCheck->setChecked(true); 250 mStartCheck->setChecked(true);
246 } else { 251 } else {
247 mStartDateEdit->setEnabled(false); 252 mStartDateEdit->setEnabled(false);
248 mStartTimeEdit->setEnabled(false); 253 mStartTimeEdit->setEnabled(false);
249 mStartDateEdit->setDate(QDate::currentDate()); 254 mStartDateEdit->setDate(QDate::currentDate());
250 mStartTimeEdit->setTime(QTime::currentTime()); 255 mStartTimeEdit->setTime(QTime::currentTime());
251 mStartCheck->setChecked(false); 256 mStartCheck->setChecked(false);
252 } 257 }
253 258
254 mTimeButton->setChecked( !todo->doesFloat() ); 259 mTimeButton->setChecked( !todo->doesFloat() );
255 260
256 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); 261 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
257 if (todo->isCompleted() && todo->hasCompletedDate()) { 262 if (todo->isCompleted() && todo->hasCompletedDate()) {
258 mCompleted = todo->completed(); 263 mCompleted = todo->completed();
259 } 264 }
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index e8d5ab1..a88276e 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -262,100 +262,105 @@ void KOViewManager::showListView()
262 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 262 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
263 mMainView, SLOT(editIncidence(Incidence *))); 263 mMainView, SLOT(editIncidence(Incidence *)));
264 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 264 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
265 mMainView, SLOT(deleteIncidence(Incidence *))); 265 mMainView, SLOT(deleteIncidence(Incidence *)));
266 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 266 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
267 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 267 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
268 connect( mListView, SIGNAL( signalNewEvent() ), 268 connect( mListView, SIGNAL( signalNewEvent() ),
269 mMainView, SLOT( newEvent() ) ); 269 mMainView, SLOT( newEvent() ) );
270 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 270 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
271 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 271 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
272 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 272 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
273 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 273 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
274 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 274 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
275 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 275 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
276 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 276 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
277 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 277 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
278 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 278 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
279 } 279 }
280 // bool temp = mFlagShowNextxDays; 280 // bool temp = mFlagShowNextxDays;
281 //globalFlagBlockPainting = true; 281 //globalFlagBlockPainting = true;
282 globalFlagBlockAgenda = 1; 282 globalFlagBlockAgenda = 1;
283 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 283 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
284 mMainView->setBlockShowDates( true ); 284 mMainView->setBlockShowDates( true );
285 mMainView->dateNavigator()->selectMonth(); 285 mMainView->dateNavigator()->selectMonth();
286 mMainView->setBlockShowDates( false ); 286 mMainView->setBlockShowDates( false );
287 } 287 }
288 showView(mListView, KOPrefs::instance()->mFullViewTodo); 288 showView(mListView, KOPrefs::instance()->mFullViewTodo);
289 //mFlagShowNextxDays = temp; 289 //mFlagShowNextxDays = temp;
290} 290}
291 291
292void KOViewManager::showAgendaView( bool fullScreen ) 292void KOViewManager::showAgendaView( bool fullScreen )
293{ 293{
294 294
295 mMainView->dialogManager()->hideSearchDialog(); 295 mMainView->dialogManager()->hideSearchDialog();
296 // qDebug("KOViewManager::showAgendaView "); 296 // qDebug("KOViewManager::showAgendaView ");
297 bool full; 297 bool full;
298 full = fullScreen; 298 full = fullScreen;
299 if (!mAgendaView) { 299 if (!mAgendaView) {
300 full = false; 300 full = false;
301 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 301 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
302 addView(mAgendaView); 302 addView(mAgendaView);
303#ifndef DESKTOP_VERSION 303#ifndef DESKTOP_VERSION
304 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 304 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
305#endif 305#endif
306 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 306 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
307 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 307 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
308 308
309 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 309 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
310
311
312
313 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
314 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
310 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 315 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
311 mMainView, SLOT(newEvent(QDateTime))); 316 mMainView, SLOT(newEvent(QDateTime)));
312 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 317 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
313 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 318 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
314 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 319 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
315 mMainView, SLOT(newEvent(QDate))); 320 mMainView, SLOT(newEvent(QDate)));
316 321
317 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 322 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
318 mMainView, SLOT(editIncidence(Incidence *))); 323 mMainView, SLOT(editIncidence(Incidence *)));
319 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 324 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
320 mMainView, SLOT(showIncidence(Incidence *))); 325 mMainView, SLOT(showIncidence(Incidence *)));
321 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 326 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
322 mMainView, SLOT(deleteIncidence(Incidence *))); 327 mMainView, SLOT(deleteIncidence(Incidence *)));
323 328
324 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 329 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
325 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 330 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
326 331
327 connect(mAgendaView, SIGNAL( toggleExpand() ), 332 connect(mAgendaView, SIGNAL( toggleExpand() ),
328 mMainView, SLOT( toggleExpand() ) ); 333 mMainView, SLOT( toggleExpand() ) );
329 334
330 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 335 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
331 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 336 mAgendaView, SLOT( setExpandedButton( bool ) ) );
332 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 337 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
333 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 338 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
334 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 339 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
335 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 340 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
336 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 341 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
337 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 342 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
338 SLOT( updateTodo( Todo *, int ) ) ); 343 SLOT( updateTodo( Todo *, int ) ) );
339 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 344 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
340 mMainView, SIGNAL( todoModified( Todo *, int ))); 345 mMainView, SIGNAL( todoModified( Todo *, int )));
341 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 346 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
342 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 347 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
343 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 348 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
344 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 349 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
345 mAgendaView->readSettings(); 350 mAgendaView->readSettings();
346 mAgendaView->updateConfig(); 351 mAgendaView->updateConfig();
347 } 352 }
348 353
349 showView( mAgendaView, full); 354 showView( mAgendaView, full);
350 355
351} 356}
352 357
353void KOViewManager::showDayView() 358void KOViewManager::showDayView()
354{ 359{
355 mFlagShowNextxDays = false; 360 mFlagShowNextxDays = false;
356 globalFlagBlockLabel = 1; 361 globalFlagBlockLabel = 1;
357 globalFlagBlockAgenda = 1; 362 globalFlagBlockAgenda = 1;
358 if ( mCurrentAgendaView != 1 ) 363 if ( mCurrentAgendaView != 1 )
359 mCurrentAgendaView = -1; 364 mCurrentAgendaView = -1;
360 showAgendaView(); 365 showAgendaView();
361 qApp->processEvents(); 366 qApp->processEvents();