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, KNoScrollListBox* lv );
00040
00041 protected:
00042 void maybeTip( const QPoint & pos);
00043
00044 private:
00045 KNoScrollListBox* eventlist;
00046 };
00047
00048
00049 class KNoScrollListBox: public QListBox
00050 {
00051 Q_OBJECT
00052 public:
00053 KNoScrollListBox(QWidget *parent=0, const char *name=0);
00054 ~KNoScrollListBox() {}
00055
00056 void setBackground( bool primary, bool workday );
00057
00058 signals:
00059 void shiftDown();
00060 void shiftUp();
00061 void rightClick();
00062
00063 protected slots:
00064 void keyPressEvent(QKeyEvent *);
00065 void keyReleaseEvent(QKeyEvent *);
00066 void mousePressEvent(QMouseEvent *);
00067 void resizeEvent(QResizeEvent *);
00068 void contentsMouseDoubleClickEvent( QMouseEvent * e );
00069
00070 private:
00071 bool mSqueezing;
00072 };
00073
00074
00075 class MonthViewItem: public QListBoxItem
00076 {
00077 public:
00078 MonthViewItem( Incidence *, const QDateTime &qd, const QString & title );
00079
00080 void setEvent(bool on) { mEvent = on; }
00081 void setTodo(bool on) { mTodo = on; }
00082 void setTodoDone(bool on) { mTodoDone = on; }
00083 void setRecur(bool on) { mRecur = on; }
00084 void setAlarm(bool on) { mAlarm = on; }
00085 void setReply(bool on) { mReply = on; }
00086
00087 void setPalette(const QPalette &p) { mPalette = p; }
00088 QPalette palette() const { return mPalette; }
00089
00090 Incidence *incidence() const { return mIncidence; }
00091 QDateTime incidenceDateTime() { return mDateTime; }
00092
00093 void setResourceColor( QColor& color ) { mResourceColor = color; }
00094 QColor &resourceColor() { return mResourceColor; }
00095 protected:
00096 virtual void paint(QPainter *);
00097 virtual int height(const QListBox *) const;
00098 virtual int width(const QListBox *) const;
00099
00100 QColor mResourceColor;
00101 private:
00102 bool mEvent;
00103 bool mTodo;
00104 bool mTodoDone;
00105 bool mRecur;
00106 bool mAlarm;
00107 bool mReply;
00108
00109 QPixmap mEventPixmap;
00110 QPixmap mTodoPixmap;
00111 QPixmap mTodoDonePixmap;
00112 QPixmap mAlarmPixmap;
00113 QPixmap mRecurPixmap;
00114 QPixmap mReplyPixmap;
00115
00116 QPalette mPalette;
00117 QDateTime mDateTime;
00118
00119 Incidence *mIncidence;
00120 };
00121
00122
00123 class KOMonthView;
00124
00129 class MonthViewCell : public QWidget
00130 {
00131 Q_OBJECT
00132 public:
00133 class CreateItemVisitor;
00134 MonthViewCell( KOMonthView * );
00135
00137 void setDate( const QDate & );
00139 QDate date() const;
00140
00148 void setPrimary( bool primary );
00152 bool isPrimary() const;
00153
00155 void setHoliday( bool );
00161 void setHolidayString( const QString &name );
00162
00163 void updateCell();
00171 void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
00176 void removeIncidence( Incidence * );
00177
00178 void updateConfig();
00179
00180 void enableScrollBars( bool );
00181
00182 Incidence *selectedIncidence();
00183 QDate selectedIncidenceDate();
00184
00185 void deselect();
00186
00187 void setCalendar( Calendar*cal ) { mCalendar = cal; }
00188 signals:
00189 void defaultAction( Incidence * );
00195 void newEventSignal( const QDate &date );
00196
00197 public slots:
00198 void select();
00199
00200 protected:
00201 void setFrameWidth();
00202 void resizeEvent( QResizeEvent * );
00203
00204 protected slots:
00205 void defaultAction( QListBoxItem * );
00206 void contextMenu( QListBoxItem * );
00207
00208 private:
00209 KOMonthView *mMonthView;
00210
00211 Calendar *mCalendar;
00212
00213 QDate mDate;
00214 bool mPrimary;
00215 bool mHoliday;
00216 QString mHolidayString;
00217
00218 QLabel *mLabel;
00219 KNoScrollListBox *mItemList;
00220
00221 QSize mLabelSize;
00222
00223 QPalette mHolidayPalette;
00224 QPalette mStandardPalette;
00225 QPalette mTodayPalette;
00226 };
00227
00235 class KOMonthView: public KOEventView
00236 {
00237 Q_OBJECT
00238 public:
00239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00240 ~KOMonthView();
00241
00243 virtual int maxDatesHint();
00244
00246 virtual int currentDateCount();
00247
00249 virtual Incidence::List selectedIncidences();
00250
00252 virtual DateList selectedDates();
00253
00254 virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00255
00256 public slots:
00257 virtual void updateView();
00258 virtual void updateConfig();
00259 virtual void showDates(const QDate &start, const QDate &end);
00260 virtual void showIncidences( const Incidence::List &incidenceList );
00261
00262 void changeIncidenceDisplay(Incidence *, int);
00263 void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00264
00265 void clearSelection();
00266
00267 void showEventContextMenu( Incidence *, const QDate & );
00268 void showGeneralContextMenu();
00269
00270 void setSelectedCell( MonthViewCell * );
00271
00272 protected slots:
00273 void processSelectionChange();
00274
00275 protected:
00276 void resizeEvent(QResizeEvent *);
00277
00278 void viewChanged();
00279 void updateDayLabels();
00280
00281 private:
00282 class GetDateVisitor;
00283 int mDaysPerWeek;
00284 int mNumWeeks;
00285 int mNumCells;
00286 int mWeekStartDay;
00287
00288 QPtrVector<MonthViewCell> mCells;
00289 QMap<QDate,MonthViewCell *> mDateToCell;
00290 QPtrVector<QLabel> mDayLabels;
00291
00292 bool mShortDayLabels;
00293 int mWidthLongDayLabel;
00294
00295 QDate mStartDate;
00296 QDate mSelectedDate;
00297
00298 MonthViewCell *mSelectedCell;
00299
00300 KOEventPopupMenu *mEventContextMenu;
00301 QLabel *mLabel;
00302 };
00303
00304 #endif
|