00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef KOAGENDAVIEW_H
00026 #define KOAGENDAVIEW_H
00027
00028 #include <qscrollview.h>
00029 #include <qlabel.h>
00030
00031 #include <libkcal/calendar.h>
00032
00033 #include "calprinter.h"
00034 #include "calendarview.h"
00035
00036 #include "agendaview.h"
00037
00038 class QHBox;
00039 class QPushButton;
00040 class QBoxLayout;
00041
00042 class KOAgenda;
00043 class KOAgendaItem;
00044 class TimeLabels;
00045 class KConfig;
00046
00047 namespace KOrg {
00048 class IncidenceChangerBase;
00049 }
00050
00051 class EventIndicator : public QFrame
00052 {
00053 Q_OBJECT
00054 public:
00055 enum Location { Top, Bottom };
00056 EventIndicator( Location loc = Top, QWidget *parent = 0,
00057 const char *name = 0 );
00058 virtual ~EventIndicator();
00059
00060 void changeColumns( int columns );
00061
00062 void enableColumn( int column, bool enable );
00063
00064 protected:
00065 void drawContents( QPainter * );
00066
00067 private:
00068 int mColumns;
00069 Location mLocation;
00070 QPixmap mPixmap;
00071 QMemArray<bool> mEnabled;
00072 };
00073
00074 class KOAlternateLabel : public QLabel
00075 {
00076 Q_OBJECT
00077 public:
00078 KOAlternateLabel( const QString &shortlabel, const QString &longlabel,
00079 const QString &extensivelabel = QString::null,
00080 QWidget *parent = 0, const char *name = 0 );
00081 ~KOAlternateLabel();
00082
00083 virtual QSize minimumSizeHint() const;
00084
00085 enum TextType { Short = 0, Long = 1, Extensive = 2 };
00086 TextType largestFittingTextType() const;
00087 void setFixedType( TextType type );
00088
00089 public slots:
00090 void useShortText();
00091 void useLongText();
00092 void useExtensiveText();
00093 void useDefaultText();
00094
00095 protected:
00096 virtual void resizeEvent( QResizeEvent * );
00097 virtual void squeezeTextToLabel();
00098 bool mTextTypeFixed;
00099 QString mShortText, mLongText, mExtensiveText;
00100 };
00101
00106 class KOAgendaView : public KOrg::AgendaView, public KCal::Calendar::Observer
00107 {
00108 Q_OBJECT
00109 public:
00110 KOAgendaView( Calendar *cal,
00111 CalendarView *calendarView,
00112 QWidget *parent = 0,
00113 const char *name = 0,
00114 bool isSideBySide = false );
00115 virtual ~KOAgendaView();
00116
00118 virtual int maxDatesHint();
00119
00121 virtual int currentDateCount();
00122
00124 virtual Incidence::List selectedIncidences();
00125
00127 virtual DateList selectedIncidenceDates();
00128
00130 virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00131
00133 void clearView();
00134
00135 KOrg::CalPrinterBase::PrintType printType();
00136
00138 QDateTime selectionStart() { return mTimeSpanBegin; }
00140 QDateTime selectionEnd() { return mTimeSpanEnd; }
00142 bool selectedIsAllDay() { return mTimeSpanInAllDay; }
00144 void deleteSelectedDateTime();
00146 bool selectedIsSingleCell();
00147
00148 void setTypeAheadReceiver( QObject * );
00149
00150 KOAgenda* agenda() const { return mAgenda; }
00151 QSplitter* splitter() const { return mSplitterAgenda; }
00152 QFrame *dayLabels() const { return mDayLabels; }
00153
00154
00155 void calendarIncidenceAdded( Incidence *incidence );
00156 void calendarIncidenceChanged( Incidence *incidence );
00157 void calendarIncidenceDeleted( Incidence *incidence );
00158
00160 void updateEventDates( KOAgendaItem *item,
00161 bool useLastGroupwareDialogAnswer,
00162 ResourceCalendar *res,
00163 const QString &subRes,
00164 bool addIncidence );
00165 QMemArray<bool> busyDayMask();
00166 public slots:
00167 virtual void updateView();
00168 virtual void updateConfig();
00169 virtual void showDates( const QDate &start, const QDate &end );
00170 virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
00171
00172 void insertIncidence( Incidence *incidence, const QDate &curDate );
00173 void changeIncidenceDisplayAdded( Incidence *incidence );
00174 void changeIncidenceDisplay( Incidence *incidence, int mode );
00175
00176 void clearSelection();
00177
00178 void startDrag( Incidence * );
00179
00180 void readSettings();
00181 void readSettings( KConfig * );
00182 void writeSettings( KConfig * );
00183
00184 void setContentsPos( int y );
00185
00186 void setExpandedButton( bool expanded );
00187
00188 void finishTypeAhead();
00189
00191 void slotTodoDropped( Todo *, const QPoint &, bool );
00192
00193 void enableAgendaUpdate( bool enable );
00194 void setIncidenceChanger( KOrg::IncidenceChangerBase *changer );
00195
00196 void zoomInHorizontally( const QDate& date=QDate() );
00197 void zoomOutHorizontally( const QDate& date=QDate() );
00198
00199 void zoomInVertically( );
00200 void zoomOutVertically( );
00201
00202 void zoomView( const int delta, const QPoint &pos,
00203 const Qt::Orientation orient=Qt::Horizontal );
00204
00205 void clearTimeSpanSelection();
00206
00207 void resourcesChanged();
00208
00209 signals:
00210 void toggleExpand();
00211 void zoomViewHorizontally(const QDate &, int count );
00212
00213 void timeSpanSelectionChanged();
00214
00215 protected:
00217 void fillAgenda( const QDate &startDate );
00218
00220 void fillAgenda();
00221
00222 void connectAgenda( KOAgenda*agenda, QPopupMenu*popup, KOAgenda* otherAgenda );
00223
00225 void createDayLabels( bool force );
00226
00230 void setHolidayMasks();
00231
00232 void removeIncidence( Incidence * );
00237 void updateEventIndicators();
00238
00239 void updateTimeBarWidth();
00240
00241 virtual void resizeEvent( QResizeEvent *resizeEvent );
00242
00243 protected slots:
00245 void doUpdateItem();
00246
00247 void updateEventIndicatorTop( int newY );
00248 void updateEventIndicatorBottom( int newY );
00249
00251 void newTimeSpanSelected( const QPoint &start, const QPoint &end );
00253 void newTimeSpanSelectedAllDay( const QPoint &start, const QPoint &end );
00254
00255 void updateDayLabelSizes();
00256
00257 private:
00258 bool filterByResource( Incidence *incidence );
00259 void displayIncidence( Incidence *incidence );
00260 bool makesWholeDayBusy( Incidence *incidence ) const;
00261
00262 private:
00263
00264 QFrame *mDayLabels;
00265 QHBox *mDayLabelsFrame;
00266 QBoxLayout *mLayoutDayLabels;
00267 QPtrList<KOAlternateLabel> mDateDayLabels;
00268 QFrame *mAllDayFrame;
00269 KOAgenda *mAllDayAgenda;
00270 KOAgenda *mAgenda;
00271 TimeLabels *mTimeLabels;
00272 QWidget *mDummyAllDayLeft;
00273 QSplitter *mSplitterAgenda;
00274 QPushButton *mExpandButton;
00275
00276 DateList mSelectedDates;
00277 DateList mSaveSelectedDates;
00278 int mViewType;
00279
00280 KOEventPopupMenu *mAgendaPopup;
00281 KOEventPopupMenu *mAllDayAgendaPopup;
00282
00283 EventIndicator *mEventIndicatorTop;
00284 EventIndicator *mEventIndicatorBottom;
00285
00286 QMemArray<int> mMinY;
00287 QMemArray<int> mMaxY;
00288
00289 QMemArray<bool> mHolidayMask;
00290
00291 QPixmap mExpandedPixmap;
00292 QPixmap mNotExpandedPixmap;
00293
00294 QDateTime mTimeSpanBegin;
00295 QDateTime mTimeSpanEnd;
00296 bool mTimeSpanInAllDay;
00297 bool mAllowAgendaUpdate;
00298
00299 Incidence *mUpdateItem;
00300
00301 bool mIsSideBySide;
00302 bool mPendingChanges;
00303
00304
00305
00306
00307
00308
00309
00310 bool mAreDatesInitialized;
00311
00312
00313
00314
00315
00316 QMap<QDate, KCal::Event::List > mBusyDays;
00317 };
00318
00319 #endif