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, 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     //Color of the resource
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();
00164     void addIncidence( Incidence *, MonthViewCell::CreateItemVisitor& );
00169     bool removeIncidence( Incidence * );
00170 
00171     void updateConfig();
00172 
00173     void enableScrollBars( bool );
00174 
00175     Incidence *selectedIncidence();
00176     QDate selectedIncidenceDate();
00177 
00178     void deselect();
00179 
00180     void setCalendar( Calendar*cal ) { mCalendar = cal; }
00181   signals:
00182     void defaultAction( Incidence * );
00188     void newEventSignal( const QDate &date );
00189 
00190   public slots:
00191     void select();
00192 
00193   protected:
00194     void setFrameWidth();
00195     void resizeEvent( QResizeEvent * );
00196 
00197   protected slots:
00198     void defaultAction( QListBoxItem * );
00199     void contextMenu( QListBoxItem * );
00200 
00201   private:
00202     KOMonthView *mMonthView;
00203   // We need the calendar for paint the ResourceColor
00204     Calendar *mCalendar;
00205 
00206     QDate mDate;
00207     bool mPrimary;
00208     bool mHoliday;
00209     QString mHolidayString;
00210 
00211     QLabel *mLabel;
00212     KNoScrollListBox *mItemList;
00213 
00214     QSize mLabelSize;
00215 //    QPalette mOriginalPalette;
00216     QPalette mHolidayPalette;
00217     QPalette mStandardPalette;
00218     QPalette mTodayPalette;
00219 };
00220 
00228 class KOMonthView: public KOEventView
00229 {
00230     Q_OBJECT
00231   public:
00232     KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
00233     ~KOMonthView();
00234 
00236     virtual int maxDatesHint();
00237 
00239     virtual int currentDateCount();
00240 
00242     virtual Incidence::List selectedIncidences();
00243 
00245     virtual DateList selectedDates();
00246 
00247     virtual bool eventDurationHint(QDateTime &startDt, QDateTime &endDt, bool &allDay);
00248 
00249   public slots:
00250     virtual void updateView();
00251     virtual void updateConfig();
00252     virtual void showDates(const QDate &start, const QDate &end);
00253     virtual void showIncidences( const Incidence::List &incidenceList );
00254 
00255     void changeIncidenceDisplay(Incidence *, int);
00256     void changeIncidenceDisplayAdded(Incidence *, MonthViewCell::CreateItemVisitor&);
00257 
00258     void clearSelection();
00259 
00260     void showEventContextMenu( Incidence *, const QDate & );
00261     void showGeneralContextMenu();
00262 
00263     void setSelectedCell( MonthViewCell * );
00264 
00265   protected slots:
00266     void processSelectionChange();
00267 
00268   protected:
00269     void resizeEvent(QResizeEvent *);
00270 
00271     void viewChanged();
00272     void updateDayLabels();
00273 
00276     MonthViewCell *lookupCellByDate( const QDate &date );
00277 
00278   private:
00279     class GetDateVisitor;
00280     int mDaysPerWeek;
00281     int mNumWeeks;
00282     int mNumCells;
00283     int mWeekStartDay;
00284 
00285     QPtrVector<MonthViewCell> mCells;
00286     QPtrVector<QLabel> mDayLabels;
00287 
00288     bool mShortDayLabels;
00289     int mWidthLongDayLabel;
00290 
00291     QDate mStartDate;
00292     QDate mSelectedDate;
00293 
00294     MonthViewCell *mSelectedCell;
00295 
00296     KOEventPopupMenu *mEventContextMenu;
00297     QLabel *mLabel;
00298 };
00299 
00300 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys