korganizer

komonthview.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
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, KNoScrollListBox* lv );
00040 
00041   protected:
00042     void maybeTip( const QPoint & pos);
00043 
00044   private:
00045     Calendar *mCalendar;
00046     KNoScrollListBox* eventlist;
00047 };
00048 
00049 
00050 class KNoScrollListBox: public QListBox
00051 {
00052     Q_OBJECT
00053   public:
00054     KNoScrollListBox(QWidget *parent=0, const char *name=0);
00055     ~KNoScrollListBox() {}
00056 
00057     void setBackground( bool primary, bool workday );
00058 
00059   signals:
00060     void shiftDown();
00061     void shiftUp();
00062     void rightClick();
00063 
00064   protected slots:
00065     void keyPressEvent(QKeyEvent *);
00066     void keyReleaseEvent(QKeyEvent *);
00067     void mousePressEvent(QMouseEvent *);
00068     void resizeEvent(QResizeEvent *);
00069     void contentsMouseDoubleClickEvent( QMouseEvent * e );
00070 
00071   private:
00072     bool mSqueezing;
00073 };
00074 
00075 
00076 class MonthViewItem: public QListBoxItem
00077 {
00078   public:
00079     MonthViewItem( Incidence *, const QDateTime &qd, const QString & title );
00080 
00081     void setEvent(bool on) { mEvent = on; }
00082     void setTodo(bool on)  { mTodo  = on; }
00083     void setTodoDone(bool on) { mTodoDone = on; }
00084     void setRecur(bool on) { mRecur = on; }
00085     void setAlarm(bool on) { mAlarm = on; }
00086     void setReply(bool on) { mReply = on; }
00087 
00088     void setPalette(const QPalette &p) { mPalette = p; }
00089     QPalette palette() const { return mPalette; }
00090 
00091     Incidence *incidence() const { return mIncidence; }
00092     QDateTime incidenceDateTime() { return mDateTime; }
00093 
00094     void setResourceColor( QColor& color ) { mResourceColor = color; }
00095     QColor &resourceColor() { return mResourceColor; }
00096   protected:
00097     virtual void paint(QPainter *);
00098     virtual int height(const QListBox *) const;
00099     virtual int width(const QListBox *) const;
00100     //Color of the resource
00101     QColor mResourceColor;
00102   private:
00103     bool mEvent;
00104     bool mTodo;
00105     bool mTodoDone;
00106     bool mRecur;
00107     bool mAlarm;
00108     bool mReply;
00109 
00110     QPixmap mEventPixmap;
00111     QPixmap mBirthdayPixmap;
00112     QPixmap mAnniversaryPixmap;
00113     QPixmap mTodoPixmap;
00114     QPixmap mTodoDonePixmap;
00115     QPixmap mAlarmPixmap;
00116     QPixmap mRecurPixmap;
00117     QPixmap mReplyPixmap;
00118 
00119     QPalette mPalette;
00120     QDateTime mDateTime;
00121 
00122     Incidence *mIncidence;
00123     QColor catColor() const;
00124 };
00125 
00126 
00127 class KOMonthView;
00128 
00133 class MonthViewCell : public QWidget
00134 {
00135     Q_OBJECT
00136   public:
00137     class CreateItemVisitor;
00138     MonthViewCell( KOMonthView * );
00139 
00141     void setDate( const QDate & );
00143     QDate date() const;
00144 
00146     KOMonthView *monthView() { return mMonthView; }
00147 
00155     void setPrimary( bool primary );
00159     bool isPrimary() const;
00160 
00162     void setHoliday( bool );
00168     void setHolidayString( const QString &name );
00169 
00170     void updateCell();
00178     void addIncidence( Incidence *incidence, MonthViewCell::CreateItemVisitor&v, int multiDay = 0 );
00183     void removeIncidence( Incidence * );
00184 
00185     void updateConfig();
00186 
00187     void enableScrollBars( bool );
00188 
00189     Incidence *selectedIncidence();
00190     QDate selectedIncidenceDate();
00191 
00192     void deselect();
00193 
00194   signals:
00195     void defaultAction( Incidence * );
00201     void newEventSignal( const QDate &date );
00202 
00203   public slots:
00204     void select();
00205 
00206   protected:
00207     void setFrameWidth();
00208     void resizeEvent( QResizeEvent * );
00209 
00210   protected slots:
00211     void defaultAction( QListBoxItem * );
00212     void contextMenu( QListBoxItem * );
00213 
00214   private:
00215     KOMonthView *mMonthView;
00216 
00217     QDate mDate;
00218     bool mPrimary;
00219     bool mHoliday;
00220     QString mHolidayString;
00221 
00222     QLabel *mLabel;
00223     KNoScrollListBox *mItemList;
00224 
00225     QSize mLabelSize;
00226 //    QPalette mOriginalPalette;
00227     QPalette mHolidayPalette;
00228     QPalette mStandardPalette;
00229     QPalette mTodayPalette;
00230 };
00231 
00239 class KOMonthView: public KOEventView
00240 {
00241     Q_OBJECT
00242   public:
00243     KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00244     ~KOMonthView();
00245 
00247     virtual int maxDatesHint();
00248 
00250     virtual int currentDateCount();
00251 
00253     virtual Incidence::List selectedIncidences();
00254 
00256     virtual DateList selectedDates();
00257 
00258     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00259 
00260   public slots:
00261     virtual void updateView();
00262     virtual void updateConfig();
00263     virtual void showDates(const QDate &start, const QDate &end);
00264     virtual void showIncidences( const Incidence::List &incidenceList );
00265 
00266     void changeIncidenceDisplay(Incidence *, int);
00267     void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00268 
00269     void clearSelection();
00270 
00271     void showEventContextMenu( Incidence *, const QDate & );
00272     void showGeneralContextMenu();
00273 
00274     void setSelectedCell( MonthViewCell * );
00275 
00276   protected slots:
00277     void processSelectionChange();
00278 
00279   protected:
00280     void resizeEvent(QResizeEvent *);
00281 
00282     void viewChanged();
00283     void updateDayLabels();
00284 
00285   private:
00286     class GetDateVisitor;
00287     int mDaysPerWeek;
00288     int mNumWeeks;
00289     int mNumCells;
00290     int mWeekStartDay;
00291 
00292     QPtrVector<MonthViewCell> mCells;
00293     QMap<QDate,MonthViewCell *> mDateToCell;
00294     QPtrVector<QLabel> mDayLabels;
00295 
00296     bool mShortDayLabels;
00297     int mWidthLongDayLabel;
00298 
00299     QDate mStartDate;
00300     QDate mSelectedDate;
00301 
00302     MonthViewCell *mSelectedCell;
00303 
00304     KOEventPopupMenu *mEventContextMenu;
00305     QLabel *mLabel;
00306 };
00307 
00308 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys