~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to korganizer/views/agendaview/koagendaview.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#ifndef KOAGENDAVIEW_H
26
26
#define KOAGENDAVIEW_H
27
27
 
28
 
#include "agendaview.h"
29
 
#ifndef KORG_NOPRINTER
30
 
#include "calprinter.h"
31
 
#endif
32
 
 
33
 
#include <KCal/Calendar>
34
 
 
35
 
#include <QFrame>
36
 
#include <QPixmap>
37
 
#include <QVector>
38
 
 
39
 
class TimeLabels;
40
 
class TimeLabelsZone;
41
 
 
42
 
class KOAgenda;
43
 
class KOAgendaItem;
44
 
class KOAgendaView;
45
 
 
46
 
class KConfig;
47
 
class KHBox;
48
 
 
49
 
class QBoxLayout;
50
 
class QGridLayout;
51
 
class QMenu;
52
 
class QPaintEvent;
 
28
#include "../../koeventview.h"
 
29
#include "../../printing/calprinter.h"
 
30
 
 
31
#include <KCalCore/Todo>
 
32
 
53
33
class QSplitter;
54
34
 
55
 
namespace KCal {
56
 
  class ResourceCalendar;
57
 
}
58
 
using namespace KCal;
59
 
 
60
 
namespace KOrg {
61
 
#ifndef KORG_NODECOS
62
 
  namespace CalendarDecoration {
63
 
    class Decoration;
64
 
  }
65
 
#endif
66
 
  class IncidenceChangerBase;
67
 
}
68
 
using namespace KOrg;
69
 
 
70
 
class EventIndicator : public QFrame
71
 
{
72
 
  Q_OBJECT
73
 
  public:
74
 
    enum Location {
75
 
      Top,
76
 
      Bottom
77
 
    };
78
 
    explicit EventIndicator( Location loc = Top, QWidget *parent = 0 );
79
 
    virtual ~EventIndicator();
80
 
 
81
 
    void changeColumns( int columns );
82
 
 
83
 
    void enableColumn( int column, bool enable );
84
 
 
85
 
  protected:
86
 
    void paintEvent( QPaintEvent *event );
87
 
 
88
 
  private:
89
 
    int mColumns;
90
 
    Location mLocation;
91
 
    QPixmap mPixmap;
92
 
    QVector<bool> mEnabled;
93
 
};
 
35
namespace EventViews {
 
36
  class AgendaView;
 
37
}
94
38
 
95
39
/**
96
40
  KOAgendaView is the agenda-like view that displays events in a single
97
41
  or multi-day view.
98
42
*/
99
 
class KOAgendaView : public KOrg::AgendaView, public KCal::Calendar::CalendarObserver
 
43
class KOAgendaView : public KOEventView
100
44
{
101
45
  Q_OBJECT
102
46
  public:
103
 
    explicit KOAgendaView( Calendar *cal, QWidget *parent = 0, bool isSideBySide = false );
 
47
    explicit KOAgendaView( QWidget *parent = 0, bool isSideBySide = false );
104
48
    virtual ~KOAgendaView();
105
49
 
106
50
    /** Returns maximum number of days supported by the koagendaview */
107
 
    virtual int maxDatesHint();
 
51
    virtual int maxDatesHint() const;
108
52
 
109
53
    /** Returns number of currently shown dates. */
110
 
    virtual int currentDateCount();
 
54
    virtual int currentDateCount() const;
111
55
 
112
56
    /** returns the currently selected events */
113
 
    virtual Incidence::List selectedIncidences();
 
57
    virtual Akonadi::Item::List selectedIncidences();
114
58
 
115
59
    /** returns the currently selected incidence's dates */
116
 
    virtual DateList selectedIncidenceDates();
 
60
    virtual KCalCore::DateList selectedIncidenceDates();
117
61
 
118
62
    /** return the default start/end date/time for new events   */
119
63
    virtual bool eventDurationHint( QDateTime &startDt, QDateTime &endDt, bool &allDay );
120
64
 
121
 
    /** Remove all events from view */
122
 
    void clearView();
123
 
 
124
 
#ifndef KORG_NOPRINTER
125
 
    CalPrinter::PrintType printType();
126
 
#endif
 
65
    CalPrinter::PrintType printType() const;
127
66
 
128
67
    /** start-datetime of selection */
129
 
    virtual QDateTime selectionStart() { return mTimeSpanBegin; }
 
68
    virtual QDateTime selectionStart();
130
69
 
131
70
    /** end-datetime of selection */
132
 
    virtual QDateTime selectionEnd() { return mTimeSpanEnd; }
 
71
    virtual QDateTime selectionEnd();
133
72
 
134
73
    /** returns true if selection is for whole day */
135
 
    bool selectedIsAllDay() { return mTimeSpanInAllDay; }
 
74
    bool selectedIsAllDay();
136
75
    /** make selected start/end invalid */
137
76
    void deleteSelectedDateTime();
138
77
    /** returns if only a single cell is selected, or a range of cells */
139
78
    bool selectedIsSingleCell();
140
79
 
141
 
    /** Show only incidences from the given resource. */
142
 
    void setResource( KCal::ResourceCalendar *res, const QString &subResource = QString() );
143
 
 
144
 
    KOAgenda *agenda() const { return mAgenda; }
145
 
    QSplitter *splitter() const { return mSplitterAgenda; }
146
 
 
147
 
    /* reimplemented from KCal::Calendar::CalendarObserver */
148
 
    void calendarIncidenceAdded( Incidence *incidence );
149
 
    void calendarIncidenceChanged( Incidence *incidence );
150
 
    void calendarIncidenceDeleted( Incidence *incidence );
 
80
    /* reimp from BaseView */
 
81
    virtual void setCalendar( CalendarSupport::Calendar *cal );
 
82
 
 
83
    /** reimpl */
 
84
    virtual void setTypeAheadReceiver( QObject *o );
 
85
 
 
86
    void setChanges( EventViews::EventView::Changes changes );
 
87
 
 
88
    /** reimpl */
 
89
    void setDateRange( const KDateTime &start, const KDateTime &end, const QDate &preferredMonth = QDate() );
151
90
 
152
91
  public slots:
153
92
    virtual void updateView();
154
93
    virtual void updateConfig();
155
 
    virtual void showDates( const QDate &start, const QDate &end );
156
 
    virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
 
94
    virtual void showDates( const QDate &start, const QDate &end, const QDate &preferredMonth = QDate() );
 
95
    virtual void showIncidences( const Akonadi::Item::List &incidenceList, const QDate &date );
157
96
 
158
 
    void insertIncidence( Incidence *incidence, const QDate &curDate );
159
 
    void changeIncidenceDisplayAdded( Incidence *incidence );
160
 
    void changeIncidenceDisplay( Incidence *incidence, int mode );
 
97
    void changeIncidenceDisplayAdded( const Akonadi::Item &incidence );
 
98
    void changeIncidenceDisplay( const Akonadi::Item &incidence, int mode );
161
99
 
162
100
    void clearSelection();
163
101
 
164
 
    void startDrag( Incidence * );
165
 
 
166
102
    void readSettings();
167
103
    void readSettings( KConfig * );
168
104
    void writeSettings( KConfig * );
169
105
 
170
 
    void setContentsPos( int y );
171
 
 
172
106
    /** reschedule the todo  to the given x- and y- coordinates.
173
107
        Third parameter determines all-day (no time specified) */
174
 
    void slotTodoDropped( Todo *, const QPoint &, bool );
 
108
    void slotTodosDropped( const Todo::List  &todos, const QPoint &, bool );
 
109
    void slotTodosDropped( const QList<KUrl> &todos, const QPoint &, bool );
175
110
 
176
111
    void enableAgendaUpdate( bool enable );
177
 
    void setIncidenceChanger( IncidenceChangerBase *changer );
 
112
    void setIncidenceChanger( CalendarSupport::IncidenceChanger *changer );
178
113
 
179
114
    void zoomInHorizontally( const QDate &date=QDate() );
180
115
    void zoomOutHorizontally( const QDate &date=QDate() );
182
117
    void zoomInVertically( );
183
118
    void zoomOutVertically( );
184
119
 
185
 
    void zoomView( const int delta, const QPoint &pos,
186
 
      const Qt::Orientation orient=Qt::Horizontal );
187
 
 
188
 
    void clearTimeSpanSelection();
189
 
 
190
 
    /** Notifies agenda that there are pending changes */
191
 
    void setUpdateNeeded();
192
 
 
193
 
    // Used by the timelabelszone
194
 
    void updateTimeBarWidth();
195
 
    /** Create labels for the selected dates. */
196
 
    void createDayLabels();
197
 
 
198
 
    void createTimeBarHeaders();
 
120
    void zoomView( const int delta, const QPoint &pos, const Qt::Orientation orient=Qt::Horizontal );
199
121
 
200
122
  signals:
201
123
    void zoomViewHorizontally( const QDate &, int count );
202
 
 
203
124
    void timeSpanSelectionChanged();
204
125
 
205
 
  protected:
206
 
    /** Fill agenda beginning with date startDate */
207
 
    void fillAgenda( const QDate &startDate );
208
 
 
209
 
    /** Fill agenda using the current set value for the start date */
210
 
    void fillAgenda();
211
 
 
212
 
    void connectAgenda( KOAgenda *agenda, QMenu *popup, KOAgenda *otherAgenda );
213
 
 
214
 
    /**
215
 
      Set the masks on the agenda widgets indicating, which days are holidays.
216
 
    */
217
 
    void setHolidayMasks();
218
 
 
219
 
    void removeIncidence( Incidence * );
220
 
    /**
221
 
      Updates the event indicators after a certain incidence was modified or
222
 
      removed.
223
 
    */
224
 
    void updateEventIndicators();
225
 
 
226
 
  protected slots:
227
 
    /** Update event belonging to agenda item */
228
 
    void updateEventDates( KOAgendaItem *item );
229
 
    /** update just the display of the given incidence, called by a single-shot timer */
230
 
    void doUpdateItem();
231
 
 
232
 
    void updateEventIndicatorTop( int newY );
233
 
    void updateEventIndicatorBottom( int newY );
234
 
 
235
 
    /** Updates data for selected timespan */
236
 
    void newTimeSpanSelected( const QPoint &start, const QPoint &end );
237
 
    /** Updates data for selected timespan for all day event*/
238
 
    void newTimeSpanSelectedAllDay( const QPoint &start, const QPoint &end );
239
 
 
240
 
  private:
241
 
 
242
 
    bool filterByResource( Incidence *incidence );
243
 
    void setupTimeLabel( TimeLabels *timeLabel );
244
 
    int timeLabelsWidth();
245
 
    void displayIncidence( Incidence *incidence );
246
 
#ifndef KORG_NODECOS
247
 
    typedef QList<KOrg::CalendarDecoration::Decoration *> DecorationList;
248
 
    bool loadDecorations( const QStringList &decorations, DecorationList &decoList );
249
 
    void placeDecorationsFrame( KHBox *frame, bool decorationsFound, bool isTop );
250
 
    void placeDecorations( DecorationList &decoList, const QDate &date,
251
 
                           KHBox *labelBox, bool forWeek );
252
 
#endif
253
 
 
254
 
  private:
255
 
    // view widgets
256
 
    QGridLayout *mGridLayout;
257
 
    QFrame *mTopDayLabels;
258
 
    KHBox *mTopDayLabelsFrame;
259
 
    QBoxLayout *mLayoutTopDayLabels;
260
 
    QFrame *mBottomDayLabels;
261
 
    KHBox *mBottomDayLabelsFrame;
262
 
    QBoxLayout *mLayoutBottomDayLabels;
263
 
    KHBox *mAllDayFrame;
264
 
    QWidget *mTimeBarHeaderFrame;
265
 
    QGridLayout *mAgendaLayout;
266
 
    QSplitter *mSplitterAgenda;
267
 
    QList<QWidget *> mTimeBarHeaders;
268
 
 
269
 
    KOAgenda *mAllDayAgenda;
270
 
    KOAgenda *mAgenda;
271
 
 
272
 
    TimeLabelsZone *mTimeLabelsZone;
273
 
 
274
 
    DateList mSelectedDates;  // List of dates to be displayed
275
 
    int mViewType;
276
 
 
277
 
    KOEventPopupMenu *mAgendaPopup;
278
 
    KOEventPopupMenu *mAllDayAgendaPopup;
279
 
 
280
 
    EventIndicator *mEventIndicatorTop;
281
 
    EventIndicator *mEventIndicatorBottom;
282
 
 
283
 
    QVector<int> mMinY;
284
 
    QVector<int> mMaxY;
285
 
 
286
 
    QVector<bool> mHolidayMask;
287
 
 
288
 
    QDateTime mTimeSpanBegin;
289
 
    QDateTime mTimeSpanEnd;
290
 
    bool mTimeSpanInAllDay;
291
 
    bool mAllowAgendaUpdate;
292
 
 
293
 
    Incidence *mUpdateItem;
294
 
 
295
 
    KCal::ResourceCalendar *mResource;
296
 
    QString mSubResource;
297
 
 
298
 
    bool mIsSideBySide;
299
 
    bool mPendingChanges;
300
 
 
301
 
    // the current date is inserted into mSelectedDates in the constructor
302
 
    // however whe should only show events when setDates is called, otherwise
303
 
    // we see day view with current date for a few milisecs, then we see something else
304
 
    // because someone called setDates with the real dates that should be displayed.
305
 
    // Other solution would be not initializing mSelectedDates in the ctor, but that requires
306
 
    // lots of changes in koagenda.cpp and koagendaview.cpp
307
 
    bool mAreDatesInitialized;
 
126
  private:
 
127
    class Private;
 
128
    Private *const d;
308
129
};
309
130
 
310
131
#endif