korganizer
komonthview.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _KOMONTHVIEW_H
00027 #define _KOMONTHVIEW_H
00028
00029 #include <qlistbox.h>
00030 #include <qptrvector.h>
00031 #include <qtooltip.h>
00032 #include "koeventview.h"
00033
00034 class KNoScrollListBox;
00035
00036 class KOMonthCellToolTip : public QToolTip
00037 {
00038 public:
00039 KOMonthCellToolTip (QWidget* parent, Calendar *calendar, const QDate &date, KNoScrollListBox* lv );
00040
00041 protected:
00042 void maybeTip( const QPoint & pos);
00043
00044 private:
00045 Calendar *mCalendar;
00046 QDate mDate;
00047 KNoScrollListBox* eventlist;
00048 };
00049
00050
00051 class KNoScrollListBox: public QListBox
00052 {
00053 Q_OBJECT
00054 public:
00055 KNoScrollListBox(QWidget *parent=0, const char *name=0);
00056 ~KNoScrollListBox() {}
00057
00058 void setBackground( bool primary, bool workday, bool busyDay );
00059
00060 signals:
00061 void shiftDown();
00062 void shiftUp();
00063 void rightClick();
00064
00065 protected slots:
00066 void keyPressEvent(QKeyEvent *);
00067 void keyReleaseEvent(QKeyEvent *);
00068 void mousePressEvent(QMouseEvent *);
00069 void resizeEvent(QResizeEvent *);
00070 void contentsMouseDoubleClickEvent( QMouseEvent * e );
00071
00072 private:
00073 bool mSqueezing;
00074 };
00075
00076
00077 class MonthViewItem: public QListBoxItem
00078 {
00079 public:
00080 MonthViewItem( Incidence *, const QDateTime &qd, const QString & title );
00081
00082 void setEvent(bool on) { mEvent = on; }
00083 void setTodo(bool on) { mTodo = on; }
00084 void setTodoDone(bool on) { mTodoDone = on; }
00085 void setRecur(bool on) { mRecur = on; }
00086 void setAlarm(bool on) { mAlarm = on; }
00087 void setReply(bool on) { mReply = on; }
00088
00089 void setPalette(const QPalette &p) { mPalette = p; }
00090 QPalette palette() const { return mPalette; }
00091
00092 Incidence *incidence() const { return mIncidence; }
00093 QDateTime incidenceDateTime() { return mDateTime; }
00094
00095 void setResourceColor( QColor& color ) { mResourceColor = color; }
00096 QColor &resourceColor() { return mResourceColor; }
00097 protected:
00098 virtual void paint(QPainter *);
00099 virtual int height(const QListBox *) const;
00100 virtual int width(const QListBox *) const;
00101
00102 QColor mResourceColor;
00103 private:
00104 bool mEvent;
00105 bool mTodo;
00106 bool mTodoDone;
00107 bool mRecur;
00108 bool mAlarm;
00109 bool mReply;
00110
00111 QPixmap mEventPixmap;
00112 QPixmap mBirthdayPixmap;
00113 QPixmap mAnniversaryPixmap;
00114 QPixmap mTodoPixmap;
00115 QPixmap mTodoDonePixmap;
00116 QPixmap mAlarmPixmap;
00117 QPixmap mRecurPixmap;
00118 QPixmap mReplyPixmap;
00119
00120 QPalette mPalette;
00121 QDateTime mDateTime;
00122
00123 Incidence *mIncidence;
00124 QColor catColor() const;
00125 };
00126
00127
00128 class KOMonthView;
00129
00134 class MonthViewCell : public QWidget
00135 {
00136 Q_OBJECT
00137 public:
00138 class CreateItemVisitor;
00139 MonthViewCell( KOMonthView * );
00140
00142 void setDate( const QDate & );
00144 QDate date() const;
00145
00147 KOMonthView *monthView() { return mMonthView; }
00148
00156 void setPrimary( bool primary );
00160 bool isPrimary() const;
00161
00163 void setHoliday( bool );
00164
00170 void setHolidayString( const QString &name );
00171
00172 void updateCell();
00180 void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
00185 void removeIncidence( Incidence * );
00186
00187 void updateConfig();
00188
00189 void enableScrollBars( bool );
00190
00191 Incidence *selectedIncidence();
00192 QDate selectedIncidenceDate();
00193
00194 void deselect();
00195
00196 signals:
00197 void defaultAction( Incidence * );
00203 void newEventSignal( ResourceCalendar *res,const QString &subResource,
00204 const QDate &date );
00205
00206 public slots:
00207 void select();
00208
00209 protected:
00210 void setFrameWidth();
00211 void resizeEvent( QResizeEvent * );
00212
00213 protected slots:
00214 void defaultAction( QListBoxItem * );
00215 void contextMenu( QListBoxItem * );
00216
00217 private:
00218 KOMonthView *mMonthView;
00219
00220 QDate mDate;
00221 bool mPrimary;
00222 bool mHoliday;
00223 QString mHolidayString;
00224
00225 QLabel *mLabel;
00226 KNoScrollListBox *mItemList;
00227
00228 bool isSelected;
00229
00230 QSize mLabelSize;
00231
00232 QPalette mHolidayPalette;
00233 QPalette mStandardPalette;
00234 QPalette mTodayPalette;
00235 };
00236
00244 class KOMonthView: public KOEventView
00245 {
00246 Q_OBJECT
00247 public:
00248 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00249 ~KOMonthView();
00250
00252 virtual int maxDatesHint();
00253
00255 virtual int currentDateCount();
00256
00258 virtual Incidence::List selectedIncidences();
00259
00261 virtual DateList selectedIncidenceDates();
00262
00263 virtual QDateTime selectionStart();
00264
00265 virtual QDateTime selectionEnd();
00266
00267 virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00268
00269 public slots:
00270 virtual void updateView();
00271 virtual void updateConfig();
00272 virtual void showDates(const QDate &start, const QDate &end);
00273 virtual void showIncidences( const Incidence::List &incidenceList, const QDate &date );
00274
00275 void changeIncidenceDisplay(Incidence *, int);
00276 void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00277
00278 void clearSelection();
00279
00280 void showEventContextMenu( Calendar *, Incidence *, const QDate & );
00281 void showGeneralContextMenu();
00282
00283 void setSelectedCell( MonthViewCell * );
00284
00285 protected slots:
00286 void processSelectionChange();
00287
00288 protected:
00289 void resizeEvent(QResizeEvent *);
00290
00291 void viewChanged();
00292 void updateDayLabels();
00293
00294 private:
00295 void showLabel( bool show );
00296
00297 class GetDateVisitor;
00298 int mDaysPerWeek;
00299 int mNumWeeks;
00300 int mNumCells;
00301 int mWeekStartDay;
00302
00303 QPtrVector<MonthViewCell> mCells;
00304 QMap<QDate,MonthViewCell *> mDateToCell;
00305 QPtrVector<QLabel> mDayLabels;
00306
00307 bool mShortDayLabels;
00308 int mWidthLongDayLabel;
00309
00310 QDate mStartDate;
00311 QDate mSelectedDate;
00312
00313 MonthViewCell *mSelectedCell;
00314
00315 KOEventPopupMenu *mEventContextMenu;
00316 QLabel *mLabel;
00317 };
00318
00319 #endif
|