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 QColor catColor() const;
00121 };
00122
00123
00124 class KOMonthView;
00125
00130 class MonthViewCell : public QWidget
00131 {
00132 Q_OBJECT
00133 public:
00134 class CreateItemVisitor;
00135 MonthViewCell( KOMonthView * );
00136
00138 void setDate( const QDate & );
00140 QDate date() const;
00141
00149 void setPrimary( bool primary );
00153 bool isPrimary() const;
00154
00156 void setHoliday( bool );
00162 void setHolidayString( const QString &name );
00163
00164 void updateCell();
00172 void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
00177 void removeIncidence( Incidence * );
00178
00179 void updateConfig();
00180
00181 void enableScrollBars( bool );
00182
00183 Incidence *selectedIncidence();
00184 QDate selectedIncidenceDate();
00185
00186 void deselect();
00187
00188 void setCalendar( Calendar*cal ) { mCalendar = cal; }
00189 signals:
00190 void defaultAction( Incidence * );
00196 void newEventSignal( const QDate &date );
00197
00198 public slots:
00199 void select();
00200
00201 protected:
00202 void setFrameWidth();
00203 void resizeEvent( QResizeEvent * );
00204
00205 protected slots:
00206 void defaultAction( QListBoxItem * );
00207 void contextMenu( QListBoxItem * );
00208
00209 private:
00210 KOMonthView *mMonthView;
00211
00212 Calendar *mCalendar;
00213
00214 QDate mDate;
00215 bool mPrimary;
00216 bool mHoliday;
00217 QString mHolidayString;
00218
00219 QLabel *mLabel;
00220 KNoScrollListBox *mItemList;
00221
00222 QSize mLabelSize;
00223
00224 QPalette mHolidayPalette;
00225 QPalette mStandardPalette;
00226 QPalette mTodayPalette;
00227 };
00228
00236 class KOMonthView: public KOEventView
00237 {
00238 Q_OBJECT
00239 public:
00240 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00241 ~KOMonthView();
00242
00244 virtual int maxDatesHint();
00245
00247 virtual int currentDateCount();
00248
00250 virtual Incidence::List selectedIncidences();
00251
00253 virtual DateList selectedDates();
00254
00255 virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00256
00257 public slots:
00258 virtual void updateView();
00259 virtual void updateConfig();
00260 virtual void showDates(const QDate &start, const QDate &end);
00261 virtual void showIncidences( const Incidence::List &incidenceList );
00262
00263 void changeIncidenceDisplay(Incidence *, int);
00264 void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00265
00266 void clearSelection();
00267
00268 void showEventContextMenu( Incidence *, const QDate & );
00269 void showGeneralContextMenu();
00270
00271 void setSelectedCell( MonthViewCell * );
00272
00273 protected slots:
00274 void processSelectionChange();
00275
00276 protected:
00277 void resizeEvent(QResizeEvent *);
00278
00279 void viewChanged();
00280 void updateDayLabels();
00281
00282 private:
00283 class GetDateVisitor;
00284 int mDaysPerWeek;
00285 int mNumWeeks;
00286 int mNumCells;
00287 int mWeekStartDay;
00288
00289 QPtrVector<MonthViewCell> mCells;
00290 QMap<QDate,MonthViewCell *> mDateToCell;
00291 QPtrVector<QLabel> mDayLabels;
00292
00293 bool mShortDayLabels;
00294 int mWidthLongDayLabel;
00295
00296 QDate mStartDate;
00297 QDate mSelectedDate;
00298
00299 MonthViewCell *mSelectedCell;
00300
00301 KOEventPopupMenu *mEventContextMenu;
00302 QLabel *mLabel;
00303 };
00304
00305 #endif
|