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 setTodo(bool on) { mTodo = on; }
00081 void setTodoDone(bool on) { mTodoDone = on; }
00082 void setRecur(bool on) { mRecur = on; }
00083 void setAlarm(bool on) { mAlarm = on; }
00084 void setReply(bool on) { mReply = on; }
00085
00086 void setPalette(const QPalette &p) { mPalette = p; }
00087 QPalette palette() const { return mPalette; }
00088
00089 Incidence *incidence() const { return mIncidence; }
00090 QDateTime incidenceDateTime() { return mDateTime; }
00091
00092 void setResourceColor( QColor& color ) { mResourceColor = color; }
00093 QColor &resourceColor() { return mResourceColor; }
00094 protected:
00095 virtual void paint(QPainter *);
00096 virtual int height(const QListBox *) const;
00097 virtual int width(const QListBox *) const;
00098
00099 QColor mResourceColor;
00100 private:
00101 bool mTodo;
00102 bool mTodoDone;
00103 bool mRecur;
00104 bool mAlarm;
00105 bool mReply;
00106
00107 QPixmap mTodoPixmap;
00108 QPixmap mTodoDonePixmap;
00109 QPixmap mAlarmPixmap;
00110 QPixmap mRecurPixmap;
00111 QPixmap mReplyPixmap;
00112
00113 QPalette mPalette;
00114 QDateTime mDateTime;
00115
00116 Incidence *mIncidence;
00117 };
00118
00119
00120 class KOMonthView;
00121
00126 class MonthViewCell : public QWidget
00127 {
00128 Q_OBJECT
00129 public:
00130 class CreateItemVisitor;
00131 MonthViewCell( KOMonthView * );
00132
00134 void setDate( const QDate & );
00136 QDate date() const;
00137
00145 void setPrimary( bool primary );
00149 bool isPrimary() const;
00150
00152 void setHoliday( bool );
00158 void setHolidayString( const QString &name );
00159
00160 void updateCell();
00168 void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
00173 void removeIncidence( Incidence * );
00174
00175 void updateConfig();
00176
00177 void enableScrollBars( bool );
00178
00179 Incidence *selectedIncidence();
00180 QDate selectedIncidenceDate();
00181
00182 void deselect();
00183
00184 void setCalendar( Calendar*cal ) { mCalendar = cal; }
00185 signals:
00186 void defaultAction( Incidence * );
00192 void newEventSignal( const QDate &date );
00193
00194 public slots:
00195 void select();
00196
00197 protected:
00198 void setFrameWidth();
00199 void resizeEvent( QResizeEvent * );
00200
00201 protected slots:
00202 void defaultAction( QListBoxItem * );
00203 void contextMenu( QListBoxItem * );
00204
00205 private:
00206 KOMonthView *mMonthView;
00207
00208 Calendar *mCalendar;
00209
00210 QDate mDate;
00211 bool mPrimary;
00212 bool mHoliday;
00213 QString mHolidayString;
00214
00215 QLabel *mLabel;
00216 KNoScrollListBox *mItemList;
00217
00218 QSize mLabelSize;
00219
00220 QPalette mHolidayPalette;
00221 QPalette mStandardPalette;
00222 QPalette mTodayPalette;
00223 };
00224
00232 class KOMonthView: public KOEventView
00233 {
00234 Q_OBJECT
00235 public:
00236 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00237 ~KOMonthView();
00238
00240 virtual int maxDatesHint();
00241
00243 virtual int currentDateCount();
00244
00246 virtual Incidence::List selectedIncidences();
00247
00249 virtual DateList selectedDates();
00250
00251 virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00252
00253 public slots:
00254 virtual void updateView();
00255 virtual void updateConfig();
00256 virtual void showDates(const QDate &start, const QDate &end);
00257 virtual void showIncidences( const Incidence::List &incidenceList );
00258
00259 void changeIncidenceDisplay(Incidence *, int);
00260 void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00261
00262 void clearSelection();
00263
00264 void showEventContextMenu( Incidence *, const QDate & );
00265 void showGeneralContextMenu();
00266
00267 void setSelectedCell( MonthViewCell * );
00268
00269 protected slots:
00270 void processSelectionChange();
00271
00272 protected:
00273 void resizeEvent(QResizeEvent *);
00274
00275 void viewChanged();
00276 void updateDayLabels();
00277
00278 private:
00279 class GetDateVisitor;
00280 int mDaysPerWeek;
00281 int mNumWeeks;
00282 int mNumCells;
00283 int mWeekStartDay;
00284
00285 QPtrVector<MonthViewCell> mCells;
00286 QMap<QDate,MonthViewCell *> mDateToCell;
00287 QPtrVector<QLabel> mDayLabels;
00288
00289 bool mShortDayLabels;
00290 int mWidthLongDayLabel;
00291
00292 QDate mStartDate;
00293 QDate mSelectedDate;
00294
00295 MonthViewCell *mSelectedCell;
00296
00297 KOEventPopupMenu *mEventContextMenu;
00298 QLabel *mLabel;
00299 };
00300
00301 #endif
|