summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp10
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/koviewmanager.cpp7
3 files changed, 18 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 0d36946..13d8398 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1408,172 +1408,182 @@ void KOAgendaView::writeSettings(KConfig *config)
1408{ 1408{
1409 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1409 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1410 1410
1411 config->setGroup("Views"); 1411 config->setGroup("Views");
1412 1412
1413 //#ifndef KORG_NOSPLITTER 1413 //#ifndef KORG_NOSPLITTER
1414 QValueList<int> list = mSplitterAgenda->sizes(); 1414 QValueList<int> list = mSplitterAgenda->sizes();
1415 config->writeEntry("Separator AgendaView",list); 1415 config->writeEntry("Separator AgendaView",list);
1416 //qDebug("write %d %d ", list[0],list[1] ); 1416 //qDebug("write %d %d ", list[0],list[1] );
1417 //#endif 1417 //#endif
1418} 1418}
1419 1419
1420void KOAgendaView::setHolidayMasks() 1420void KOAgendaView::setHolidayMasks()
1421{ 1421{
1422 mHolidayMask.resize(mSelectedDates.count()); 1422 mHolidayMask.resize(mSelectedDates.count());
1423 1423
1424 uint i; 1424 uint i;
1425 for(i=0;i<mSelectedDates.count();++i) { 1425 for(i=0;i<mSelectedDates.count();++i) {
1426 QDate date = mSelectedDates[i]; 1426 QDate date = mSelectedDates[i];
1427 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1427 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1428 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1428 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1429 bool showHoliday = false; 1429 bool showHoliday = false;
1430 if ( KOPrefs::instance()->mExcludeHolidays ) { 1430 if ( KOPrefs::instance()->mExcludeHolidays ) {
1431 QPtrList<Event> events = calendar()->events( date, true ); 1431 QPtrList<Event> events = calendar()->events( date, true );
1432 Event *event; 1432 Event *event;
1433 for( event = events.first(); event; event = events.next() ) { 1433 for( event = events.first(); event; event = events.next() ) {
1434 if ( event->categories().contains("Holiday") || 1434 if ( event->categories().contains("Holiday") ||
1435 event->categories().contains(i18n("Holiday"))) { 1435 event->categories().contains(i18n("Holiday"))) {
1436 showHoliday = true; 1436 showHoliday = true;
1437 break; 1437 break;
1438 } 1438 }
1439 } 1439 }
1440 1440
1441 } 1441 }
1442 1442
1443#ifndef KORG_NOPLUGINS 1443#ifndef KORG_NOPLUGINS
1444 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1444 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1445 !KOCore::self()->holiday(date).isEmpty(); 1445 !KOCore::self()->holiday(date).isEmpty();
1446#endif 1446#endif
1447 bool showDay = showSaturday || showSunday || showHoliday; 1447 bool showDay = showSaturday || showSunday || showHoliday;
1448 1448
1449 if (showDay) { 1449 if (showDay) {
1450 mHolidayMask.at(i) = true; 1450 mHolidayMask.at(i) = true;
1451 } else { 1451 } else {
1452 mHolidayMask.at(i) = false; 1452 mHolidayMask.at(i) = false;
1453 } 1453 }
1454 } 1454 }
1455 1455
1456 mAgenda->setHolidayMask(&mHolidayMask); 1456 mAgenda->setHolidayMask(&mHolidayMask);
1457 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1457 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1458} 1458}
1459 1459
1460void KOAgendaView::setContentsPos(int y) 1460void KOAgendaView::setContentsPos(int y)
1461{ 1461{
1462 mAgenda->setContentsPos(0,y); 1462 mAgenda->setContentsPos(0,y);
1463} 1463}
1464 1464
1465void KOAgendaView::setExpandedButton( bool expanded ) 1465void KOAgendaView::setExpandedButton( bool expanded )
1466{ 1466{
1467 if ( expanded ) { 1467 if ( expanded ) {
1468 mExpandButton->setPixmap( mExpandedPixmap ); 1468 mExpandButton->setPixmap( mExpandedPixmap );
1469 } else { 1469 } else {
1470 mExpandButton->setPixmap( mNotExpandedPixmap ); 1470 mExpandButton->setPixmap( mNotExpandedPixmap );
1471 } 1471 }
1472} 1472}
1473 1473
1474void KOAgendaView::clearSelection() 1474void KOAgendaView::clearSelection()
1475{ 1475{
1476 mAgenda->deselectItem(); 1476 mAgenda->deselectItem();
1477 mAllDayAgenda->deselectItem(); 1477 mAllDayAgenda->deselectItem();
1478} 1478}
1479 1479
1480void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1480void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1481 int gxEnd, int gyEnd) 1481 int gxEnd, int gyEnd)
1482{ 1482{
1483 mTimeSpanInAllDay = true; 1483 mTimeSpanInAllDay = true;
1484 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1484 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1485} 1485}
1486 1486
1487 1487
1488 1488
1489 1489
1490void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1490void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1491 int gxEnd, int gyEnd) 1491 int gxEnd, int gyEnd)
1492{ 1492{
1493 if (!mSelectedDates.count()) return; 1493 if (!mSelectedDates.count()) return;
1494 1494
1495 QDate dayStart = mSelectedDates[gxStart]; 1495 QDate dayStart = mSelectedDates[gxStart];
1496 QDate dayEnd = mSelectedDates[gxEnd]; 1496 QDate dayEnd = mSelectedDates[gxEnd];
1497 1497
1498 QTime timeStart = mAgenda->gyToTime(gyStart); 1498 QTime timeStart = mAgenda->gyToTime(gyStart);
1499 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1499 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1500 1500
1501 QDateTime dtStart(dayStart,timeStart); 1501 QDateTime dtStart(dayStart,timeStart);
1502 QDateTime dtEnd(dayEnd,timeEnd); 1502 QDateTime dtEnd(dayEnd,timeEnd);
1503 1503
1504 mTimeSpanBegin = dtStart; 1504 mTimeSpanBegin = dtStart;
1505 mTimeSpanEnd = dtEnd; 1505 mTimeSpanEnd = dtEnd;
1506 1506
1507} 1507}
1508 1508
1509void KOAgendaView::deleteSelectedDateTime() 1509void KOAgendaView::deleteSelectedDateTime()
1510{ 1510{
1511 mTimeSpanBegin.setDate(QDate()); 1511 mTimeSpanBegin.setDate(QDate());
1512 mTimeSpanEnd.setDate(QDate()); 1512 mTimeSpanEnd.setDate(QDate());
1513 mTimeSpanInAllDay = false; 1513 mTimeSpanInAllDay = false;
1514} 1514}
1515 1515
1516void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1516void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1517{ 1517{
1518 e->ignore(); 1518 e->ignore();
1519} 1519}
1520 1520
1521void KOAgendaView::scrollOneHourUp() 1521void KOAgendaView::scrollOneHourUp()
1522{ 1522{
1523 1523
1524 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1524 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1525} 1525}
1526void KOAgendaView::scrollOneHourDown() 1526void KOAgendaView::scrollOneHourDown()
1527{ 1527{
1528 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1528 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1529} 1529}
1530 1530
1531void KOAgendaView::setStartHour( int h ) 1531void KOAgendaView::setStartHour( int h )
1532{ 1532{
1533 mAgenda->setStartHour( h ); 1533 mAgenda->setStartHour( h );
1534 1534
1535} 1535}
1536void KOAgendaView::setInitStartHour()
1537{
1538
1539 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1540 setStartHour( QTime::currentTime ().hour() );
1541 else
1542 setStartHour( KOPrefs::instance()->mDayBegins );
1543
1544}
1545
1536 1546
1537void KOAgendaView::updateTodo( Todo * t, int ) 1547void KOAgendaView::updateTodo( Todo * t, int )
1538{ 1548{
1539 if ( !isVisible() ) 1549 if ( !isVisible() )
1540 return; 1550 return;
1541 bool remove = false; 1551 bool remove = false;
1542 bool removeAD = false; 1552 bool removeAD = false;
1543 QDate da; 1553 QDate da;
1544 if ( t->hasCompletedDate() ) 1554 if ( t->hasCompletedDate() )
1545 da = t->completed().date(); 1555 da = t->completed().date();
1546 else 1556 else
1547 da = t->dtDue().date(); 1557 da = t->dtDue().date();
1548 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1558 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1549 remove = true; 1559 remove = true;
1550 removeAD = true; 1560 removeAD = true;
1551 } 1561 }
1552 else { 1562 else {
1553 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1563 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1554 if ( overdue && 1564 if ( overdue &&
1555 QDate::currentDate() >= mSelectedDates.first() && 1565 QDate::currentDate() >= mSelectedDates.first() &&
1556 QDate::currentDate() <= mSelectedDates.last()) { 1566 QDate::currentDate() <= mSelectedDates.last()) {
1557 removeAD = false; 1567 removeAD = false;
1558 remove = true; 1568 remove = true;
1559 } 1569 }
1560 else { 1570 else {
1561 1571
1562 if ( da < mSelectedDates.first() || 1572 if ( da < mSelectedDates.first() ||
1563 da > mSelectedDates.last() ) { 1573 da > mSelectedDates.last() ) {
1564 remove = true; 1574 remove = true;
1565 removeAD = true; 1575 removeAD = true;
1566 } else { 1576 } else {
1567 remove = t->doesFloat() && !t->hasCompletedDate(); 1577 remove = t->doesFloat() && !t->hasCompletedDate();
1568 removeAD = !remove; 1578 removeAD = !remove;
1569 } 1579 }
1570 } 1580 }
1571 } 1581 }
1572 int days = mSelectedDates.first().daysTo( da ); 1582 int days = mSelectedDates.first().daysTo( da );
1573 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1583 //qDebug("daysto %d %d %d", days, remove,removeAD );
1574 mAgenda->updateTodo( t , days, remove); 1584 mAgenda->updateTodo( t , days, remove);
1575 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1585 if ( KOPrefs::instance()->mShowTodoInAgenda )
1576 mAllDayAgenda->updateTodo( t , days, removeAD); 1586 mAllDayAgenda->updateTodo( t , days, removeAD);
1577 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1587 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1578 1588
1579} 1589}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 4a058ce..8b8bac0 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -52,239 +52,240 @@ class KOAgendaButton : public QPushButton
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 int mMouseDownY; 104 int mMouseDownY;
105 QString mOrgCap; 105 QString mOrgCap;
106 int mRows; 106 int mRows;
107 int mCellHeight; 107 int mCellHeight;
108 108
109 /** */ 109 /** */
110 KOAgenda* mAgenda; 110 KOAgenda* mAgenda;
111}; 111};
112 112
113class EventIndicator : public QFrame { 113class EventIndicator : public QFrame {
114 Q_OBJECT 114 Q_OBJECT
115 public: 115 public:
116 enum Location { Top, Bottom }; 116 enum Location { Top, Bottom };
117 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 117 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
118 virtual ~EventIndicator(); 118 virtual ~EventIndicator();
119 119
120 void changeColumns(int columns); 120 void changeColumns(int columns);
121 void setPaintWidget( KDGanttMinimizeSplitter* ); 121 void setPaintWidget( KDGanttMinimizeSplitter* );
122 void setXOffset( int ); 122 void setXOffset( int );
123 void enableColumn(int column, bool enable); 123 void enableColumn(int column, bool enable);
124 124
125 protected: 125 protected:
126 void drawContents(QPainter *); 126 void drawContents(QPainter *);
127 127
128 private: 128 private:
129 int mXOffset; 129 int mXOffset;
130 KDGanttMinimizeSplitter* mPaintWidget; 130 KDGanttMinimizeSplitter* mPaintWidget;
131 int mColumns; 131 int mColumns;
132 QHBox *mTopBox; 132 QHBox *mTopBox;
133 QBoxLayout *mTopLayout; 133 QBoxLayout *mTopLayout;
134 Location mLocation; 134 Location mLocation;
135 QPixmap mPixmap; 135 QPixmap mPixmap;
136 QMemArray<bool> mEnabled; 136 QMemArray<bool> mEnabled;
137}; 137};
138 138
139/** 139/**
140 KOAgendaView is the agenda-like view used to display events in an one or 140 KOAgendaView is the agenda-like view used to display events in an one or
141 multi-day view. 141 multi-day view.
142*/ 142*/
143class KOAgendaView : public KOEventView { 143class KOAgendaView : public KOEventView {
144 Q_OBJECT 144 Q_OBJECT
145 public: 145 public:
146 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 146 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
147 virtual ~KOAgendaView(); 147 virtual ~KOAgendaView();
148 void setStartHour( int ); 148 void setStartHour( int );
149 void toggleAllDay(); 149 void toggleAllDay();
150 150
151 151
152 /** Returns maximum number of days supported by the koagendaview */ 152 /** Returns maximum number of days supported by the koagendaview */
153 virtual int maxDatesHint(); 153 virtual int maxDatesHint();
154 154
155 /** Returns number of currently shown dates. */ 155 /** Returns number of currently shown dates. */
156 virtual int currentDateCount(); 156 virtual int currentDateCount();
157 157
158 /** returns the currently selected events */ 158 /** returns the currently selected events */
159 virtual QPtrList<Incidence> selectedIncidences(); 159 virtual QPtrList<Incidence> selectedIncidences();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual DateList selectedDates(); 162 virtual DateList selectedDates();
163 163
164 /** Remove all events from view */ 164 /** Remove all events from view */
165 void clearView(); 165 void clearView();
166 KOAgenda *agenda() { return mAgenda;} 166 KOAgenda *agenda() { return mAgenda;}
167 virtual void printPreview(CalPrinter *calPrinter, 167 virtual void printPreview(CalPrinter *calPrinter,
168 const QDate &, const QDate &); 168 const QDate &, const QDate &);
169 169
170 /** start-datetime of selection */ 170 /** start-datetime of selection */
171 QDateTime selectionStart() {return mTimeSpanBegin;} 171 QDateTime selectionStart() {return mTimeSpanBegin;}
172 /** end-datetime of selection */ 172 /** end-datetime of selection */
173 QDateTime selectionEnd() {return mTimeSpanEnd;} 173 QDateTime selectionEnd() {return mTimeSpanEnd;}
174 /** returns true if selection is for whole day */ 174 /** returns true if selection is for whole day */
175 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 175 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
176 /** make selected start/end invalid */ 176 /** make selected start/end invalid */
177 void deleteSelectedDateTime(); 177 void deleteSelectedDateTime();
178 void repaintAgenda(); 178 void repaintAgenda();
179 public slots: 179 public slots:
180 void setInitStartHour();
180 virtual void updateView(); 181 virtual void updateView();
181 virtual void updateConfig(); 182 virtual void updateConfig();
182 virtual void showDates(const QDate &start, const QDate &end); 183 virtual void showDates(const QDate &start, const QDate &end);
183 virtual void showEvents(QPtrList<Event> eventList); 184 virtual void showEvents(QPtrList<Event> eventList);
184 185
185 void updateTodo( Todo *, int ); 186 void updateTodo( Todo *, int );
186 void changeEventDisplay(Event *, int); 187 void changeEventDisplay(Event *, int);
187 188
188 void clearSelection(); 189 void clearSelection();
189 190
190 void newTodo(int gx,int gy); 191 void newTodo(int gx,int gy);
191 void newEvent(int gx,int gy); 192 void newEvent(int gx,int gy);
192 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 193 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
193 void newEventAllDay(int gx, int gy); 194 void newEventAllDay(int gx, int gy);
194 void newTodoAllDay(int gx, int gy); 195 void newTodoAllDay(int gx, int gy);
195 196
196 void startDrag(Event *); 197 void startDrag(Event *);
197 198
198 void readSettings(); 199 void readSettings();
199 void readSettings(KConfig *); 200 void readSettings(KConfig *);
200 void writeSettings(KConfig *); 201 void writeSettings(KConfig *);
201 202
202 void setContentsPos(int y); 203 void setContentsPos(int y);
203 204
204 void setExpandedButton( bool expanded ); 205 void setExpandedButton( bool expanded );
205 void scrollOneHourUp(); 206 void scrollOneHourUp();
206 void scrollOneHourDown(); 207 void scrollOneHourDown();
207 void addToCalSlot(Incidence *, Incidence *); 208 void addToCalSlot(Incidence *, Incidence *);
208 209
209 signals: 210 signals:
210 void showDateView( int, QDate ); 211 void showDateView( int, QDate );
211 void newTodoSignal( QDateTime ,bool ); 212 void newTodoSignal( QDateTime ,bool );
212 void toggleExpand(); 213 void toggleExpand();
213 void selectWeekNum( int ); 214 void selectWeekNum( int );
214 void todoMoved( Todo *, int ); 215 void todoMoved( Todo *, int );
215 void incidenceChanged(Incidence * , int ); 216 void incidenceChanged(Incidence * , int );
216 // void cloneIncidenceSignal(Incidence *); 217 // void cloneIncidenceSignal(Incidence *);
217 218
218 protected: 219 protected:
219 KOAgendaButton* getNewDaylabel(); 220 KOAgendaButton* getNewDaylabel();
220 bool mBlockUpdating; 221 bool mBlockUpdating;
221 int mUpcomingWidth; 222 int mUpcomingWidth;
222 /** Fill agenda beginning with date startDate */ 223 /** Fill agenda beginning with date startDate */
223 void fillAgenda(const QDate &startDate); 224 void fillAgenda(const QDate &startDate);
224 void resizeEvent( QResizeEvent* e ); 225 void resizeEvent( QResizeEvent* e );
225 /** Fill agenda using the current set value for the start date */ 226 /** Fill agenda using the current set value for the start date */
226 void fillAgenda(); 227 void fillAgenda();
227 228
228 /** Create labels for the selected dates. */ 229 /** Create labels for the selected dates. */
229 void createDayLabels(); 230 void createDayLabels();
230 231
231 /** 232 /**
232 Set the masks on the agenda widgets indicating, which days are holidays. 233 Set the masks on the agenda widgets indicating, which days are holidays.
233 */ 234 */
234 void setHolidayMasks(); 235 void setHolidayMasks();
235 236
236 protected slots: 237 protected slots:
237 void slotDaylabelClicked( int ); 238 void slotDaylabelClicked( int );
238 /** Update event belonging to agenda item */ 239 /** Update event belonging to agenda item */
239 void updateEventDates(KOAgendaItem *item, int mode = -1); 240 void updateEventDates(KOAgendaItem *item, int mode = -1);
240 //void updateMovedTodo(); 241 //void updateMovedTodo();
241 242
242 void updateEventIndicatorTop(int newY); 243 void updateEventIndicatorTop(int newY);
243 void updateEventIndicatorBottom(int newY); 244 void updateEventIndicatorBottom(int newY);
244 245
245 /** Updates data for selected timespan */ 246 /** Updates data for selected timespan */
246 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 247 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
247 /** Updates data for selected timespan for all day event*/ 248 /** Updates data for selected timespan for all day event*/
248 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 249 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
249 250
250 private: 251 private:
251 // view widgets 252 // view widgets
252 QFrame *mDayLabels; 253 QFrame *mDayLabels;
253 QHBox *mDayLabelsFrame; 254 QHBox *mDayLabelsFrame;
254 QBoxLayout *mLayoutDayLabels; 255 QBoxLayout *mLayoutDayLabels;
255 QFrame *mAllDayFrame; 256 QFrame *mAllDayFrame;
256 KOAgenda *mAllDayAgenda; 257 KOAgenda *mAllDayAgenda;
257 KOAgenda *mAgenda; 258 KOAgenda *mAgenda;
258 TimeLabels *mTimeLabels; 259 TimeLabels *mTimeLabels;
259 QWidget *mDummyAllDayLeft; 260 QWidget *mDummyAllDayLeft;
260 261
261 KDGanttMinimizeSplitter* mSplitterAgenda; 262 KDGanttMinimizeSplitter* mSplitterAgenda;
262 QPushButton *mExpandButton; 263 QPushButton *mExpandButton;
263 264
264 DateList mSelectedDates; // List of dates to be displayed 265 DateList mSelectedDates; // List of dates to be displayed
265 int mViewType; 266 int mViewType;
266 267
267 bool mWeekStartsMonday; 268 bool mWeekStartsMonday;
268 int mStartHour; 269 int mStartHour;
269 270
270 KOEventPopupMenu *mAgendaPopup; 271 KOEventPopupMenu *mAgendaPopup;
271 KOEventPopupMenu *mAllDayAgendaPopup; 272 KOEventPopupMenu *mAllDayAgendaPopup;
272 273
273 EventIndicator *mEventIndicatorTop; 274 EventIndicator *mEventIndicatorTop;
274 EventIndicator *mEventIndicatorBottom; 275 EventIndicator *mEventIndicatorBottom;
275 276
276 QMemArray<int> mMinY; 277 QMemArray<int> mMinY;
277 QMemArray<int> mMaxY; 278 QMemArray<int> mMaxY;
278 279
279 QMemArray<bool> mHolidayMask; 280 QMemArray<bool> mHolidayMask;
280 281
281 QPixmap mExpandedPixmap; 282 QPixmap mExpandedPixmap;
282 QPixmap mNotExpandedPixmap; 283 QPixmap mNotExpandedPixmap;
283 QPtrList<KOAgendaButton> mDayLabelsList; 284 QPtrList<KOAgendaButton> mDayLabelsList;
284 QDateTime mTimeSpanBegin; 285 QDateTime mTimeSpanBegin;
285 QDateTime mTimeSpanEnd; 286 QDateTime mTimeSpanEnd;
286 bool mTimeSpanInAllDay; 287 bool mTimeSpanInAllDay;
287 void keyPressEvent ( QKeyEvent * e ); 288 void keyPressEvent ( QKeyEvent * e );
288}; 289};
289 290
290#endif // KOAGENDAVIEW_H 291#endif // KOAGENDAVIEW_H
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index b0f26d1..f8f6c1d 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,225 +1,232 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
92 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
96 else { 96 else {
97 config->setGroup( "Views" );
98 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
99 mCurrentAgendaView = dateCount;
97 showAgendaView(); 100 showAgendaView();
101 mCurrentAgendaView = dateCount;
102#ifdef DESKTOP_VERSION
103 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
104#endif
98 } 105 }
99} 106}
100 107
101void KOViewManager::showDateView( int view, QDate date) 108void KOViewManager::showDateView( int view, QDate date)
102{ 109{
103 static int lastMode = 0; 110 static int lastMode = 0;
104 static int lastCount = 0; 111 static int lastCount = 0;
105 static bool lastNDMode = false; 112 static bool lastNDMode = false;
106 static QDate lastDate; 113 static QDate lastDate;
107 //qDebug("date %d %s", view, date.toString().latin1()); 114 //qDebug("date %d %s", view, date.toString().latin1());
108 115
109 if (view != 9) 116 if (view != 9)
110 lastMode = 0; 117 lastMode = 0;
111 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 118 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
112 bool savemFlagShowNextxDays = mFlagShowNextxDays; 119 bool savemFlagShowNextxDays = mFlagShowNextxDays;
113 mFlagShowNextxDays = false; 120 mFlagShowNextxDays = false;
114 if ( view == 3 ) { 121 if ( view == 3 ) {
115 //mCurrentAgendaView = 1 ; 122 //mCurrentAgendaView = 1 ;
116 lastDate = mMainView->dateNavigator()->selectedDates().first(); 123 lastDate = mMainView->dateNavigator()->selectedDates().first();
117 lastCount = mMainView->dateNavigator()->selectedDates().count(); 124 lastCount = mMainView->dateNavigator()->selectedDates().count();
118 lastNDMode = savemFlagShowNextxDays; 125 lastNDMode = savemFlagShowNextxDays;
119 mMainView->showDay( date ); 126 mMainView->showDay( date );
120 lastMode = 1; 127 lastMode = 1;
121 } else if (view == 4 ) { 128 } else if (view == 4 ) {
122 mCurrentAgendaView = 7 ; 129 mCurrentAgendaView = 7 ;
123 mMainView->dateNavigator()->selectDates( date, 7 ); 130 mMainView->dateNavigator()->selectDates( date, 7 );
124 } else if (view == 5 ) { 131 } else if (view == 5 ) {
125 mCurrentAgendaView = 14 ; 132 mCurrentAgendaView = 14 ;
126 mMainView->dateNavigator()->selectDates( date, 14); 133 mMainView->dateNavigator()->selectDates( date, 14);
127 } else if (view == 6 ) { 134 } else if (view == 6 ) {
128 //mMainView->dateNavigator()->selectDates( date, 7 ); 135 //mMainView->dateNavigator()->selectDates( date, 7 );
129 showMonthView(); 136 showMonthView();
130 } else if (view == 7 ) { 137 } else if (view == 7 ) {
131 mMainView->dateNavigator()->selectDate( date ); 138 mMainView->dateNavigator()->selectDate( date );
132 showJournalView(); 139 showJournalView();
133 } else if (view == 8 ) { 140 } else if (view == 8 ) {
134 globalFlagBlockAgenda = 1; 141 globalFlagBlockAgenda = 1;
135 if ( mCurrentAgendaView != 3 ) 142 if ( mCurrentAgendaView != 3 )
136 mCurrentAgendaView = -1; 143 mCurrentAgendaView = -1;
137 showAgendaView(KOPrefs::instance()->mFullViewMonth); 144 showAgendaView(KOPrefs::instance()->mFullViewMonth);
138 globalFlagBlockAgenda = 2; 145 globalFlagBlockAgenda = 2;
139 mMainView->dateNavigator()->selectDates( date , 146 mMainView->dateNavigator()->selectDates( date ,
140 KOPrefs::instance()->mNextXDays ); 147 KOPrefs::instance()->mNextXDays );
141 mFlagShowNextxDays = true; 148 mFlagShowNextxDays = true;
142 mCurrentAgendaView = 3 ; 149 mCurrentAgendaView = 3 ;
143 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 150 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
144 if ( lastMode ) { 151 if ( lastMode ) {
145 mCurrentAgendaView = lastCount ; 152 mCurrentAgendaView = lastCount ;
146 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 153 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
147 mFlagShowNextxDays = lastNDMode; 154 mFlagShowNextxDays = lastNDMode;
148 if ( mFlagShowNextxDays ) { 155 if ( mFlagShowNextxDays ) {
149 mCurrentAgendaView = 3 ; 156 mCurrentAgendaView = 3 ;
150 } 157 }
151 } else 158 } else
152 showWeekView(); 159 showWeekView();
153 } else if (view == 10) { 160 } else if (view == 10) {
154 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 161 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
155 } 162 }
156} 163}
157 164
158 165
159 166
160void KOViewManager::writeSettings(KConfig *config) 167void KOViewManager::writeSettings(KConfig *config)
161{ 168{
162 config->setGroup("General"); 169 config->setGroup("General");
163 170
164 QString view; 171 QString view;
165 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 172 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
166 else if (mCurrentView == mMonthView) view = "Month"; 173 else if (mCurrentView == mMonthView) view = "Month";
167 else if (mCurrentView == mListView) view = "List"; 174 else if (mCurrentView == mListView) view = "List";
168 else if (mCurrentView == mJournalView) view = "Journal"; 175 else if (mCurrentView == mJournalView) view = "Journal";
169 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 176 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
170 else if (mCurrentView == mTodoView) view = "Todo"; 177 else if (mCurrentView == mTodoView) view = "Todo";
171 else view = "Agenda"; 178 else view = "Agenda";
172 179
173 config->writeEntry("Current View",view); 180 config->writeEntry("Current View",view);
174 181
175 if (mAgendaView) { 182 if (mAgendaView) {
176 mAgendaView->writeSettings(config); 183 mAgendaView->writeSettings(config);
177 } 184 }
178 if (mTimeSpanView) { 185 if (mTimeSpanView) {
179 mTimeSpanView->writeSettings(config); 186 mTimeSpanView->writeSettings(config);
180 } 187 }
181 if (mListView) { 188 if (mListView) {
182 mListView->writeSettings(config); 189 mListView->writeSettings(config);
183 } 190 }
184 if (mTodoView) { 191 if (mTodoView) {
185 mTodoView->saveLayout(config,"Todo View"); 192 mTodoView->saveLayout(config,"Todo View");
186 } 193 }
187} 194}
188 195
189void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 196void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
190{ 197{
191 198
192 //mFlagShowNextxDays = false; 199 //mFlagShowNextxDays = false;
193 //if(view == mCurrentView) return; 200 //if(view == mCurrentView) return;
194 if ( view == 0 ) { 201 if ( view == 0 ) {
195 view = mCurrentView; 202 view = mCurrentView;
196 if ( view == 0 ) 203 if ( view == 0 )
197 return; 204 return;
198 } 205 }
199 bool full = fullScreen; 206 bool full = fullScreen;
200 if(view == mCurrentView && view != mWhatsNextView ) { 207 if(view == mCurrentView && view != mWhatsNextView ) {
201 if ( mCurrentAgendaView < 0 ) 208 if ( mCurrentAgendaView < 0 )
202 return; 209 return;
203 full = mMainView->leftFrame()->isVisible(); 210 full = mMainView->leftFrame()->isVisible();
204 } else { 211 } else {
205 if ( view == mMonthView && mMonthView) 212 if ( view == mMonthView && mMonthView)
206 ;//mMonthView->skipResize = true ; 213 ;//mMonthView->skipResize = true ;
207 mCurrentView = view; 214 mCurrentView = view;
208 // bool full = fullScreen; 215 // bool full = fullScreen;
209 bool isFull = !mMainView->leftFrame()->isVisible(); 216 bool isFull = !mMainView->leftFrame()->isVisible();
210 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 217 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
211 full = true; 218 full = true;
212 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 219 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
213 full = false; 220 full = false;
214 } 221 }
215 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 222 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
216 //raiseCurrentView( full ); 223 //raiseCurrentView( full );
217 mMainView->processIncidenceSelection( 0 ); 224 mMainView->processIncidenceSelection( 0 );
218 //mMainView->updateView(); 225 //mMainView->updateView();
219 raiseCurrentView( full, true ); 226 raiseCurrentView( full, true );
220 mMainView->adaptNavigationUnits(); 227 mMainView->adaptNavigationUnits();
221} 228}
222 229
223void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 230void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
224{ 231{
225 mCurrentAgendaView = 0; 232 mCurrentAgendaView = 0;