korganizer Library API Documentation

koagendaitem.h

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2000,2001,2003 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 #ifndef KOAGENDAITEM_H
00025 #define KOAGENDAITEM_H
00026 
00027 #include "cellitem.h"
00028 
00029 #include <libkcal/incidence.h>
00030 
00031 #include <qframe.h>
00032 #include <qdatetime.h>
00033 
00034 class QToolTipGroup;
00035 class QDragEnterEvent;
00036 class QDropEvent;
00037 
00038 using namespace KCal;
00039 class KOAgendaItem;
00040 
00041 struct MultiItemInfo
00042 {
00043   int mStartCellXLeft, mStartCellXRight;
00044   int mStartCellYTop, mStartCellYBottom;
00045   KOAgendaItem *mFirstMultiItem;
00046   KOAgendaItem *mPrevMultiItem;
00047   KOAgendaItem *mNextMultiItem;
00048   KOAgendaItem *mLastMultiItem;
00049 };
00050 
00051 /*
00052   The KOAgendaItem has to make sure that it receives all mouse events, which are
00053   to be used for dragging and resizing. That means it has to be installed as
00054   eventfiler for its children, if it has children, and it has to pass mouse
00055   events from the cildren to itself. See eventFilter().
00056   
00057   
00058   Some comments on the movement of multi-day items:
00059   Basically, the agenda items are arranged in two implicit double-linked lists.
00060   The mMultiItemInfo works like before to describe the currently viewed
00061   multi-item.
00062   When moving, new events might need to be added to the beginning or the end of
00063   the multi-item sequence, or events might need to be hidden. I cannot just
00064   delete this items, since I have to restore/show them if the move is reset
00065   (i.e. if a drag started). So internally, I keep another doubly-linked list
00066   which is longer than the one defined by mMultiItemInfo, but includes the
00067   multi-item sequence, too.
00068 
00069   The mStartMoveInfo stores the first and last item of the multi-item sequence
00070   when the move started. The prev and next members of mStartMoveInfo are used
00071   for that longer sequence including all (shown and hidden) items.
00072 */
00073 class KOAgendaItem : public QWidget, public KOrg::CellItem
00074 {
00075     Q_OBJECT
00076   public:
00077     KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, const char *name=0,
00078                  WFlags f=0 );
00079 
00080     int cellXLeft() const { return mCellXLeft; }
00081     int cellXRight() const { return mCellXRight; }
00082     int cellYTop() const { return mCellYTop; }
00083     int cellYBottom() const { return mCellYBottom; }
00084     int cellHeight() const;
00085     int cellWidth() const;
00086 
00087     void setCellXY(int X, int YTop, int YBottom);
00088     void setCellY(int YTop, int YBottom);
00089     void setCellX(int XLeft, int XRight);
00090     void setCellXRight(int xright);
00091 
00093     void startMove();
00095     void resetMove();
00097     void endMove();
00098 
00099     void moveRelative(int dx,int dy);
00100     void expandTop(int dy);
00101     void expandBottom(int dy);
00102     void expandLeft(int dx);
00103     void expandRight(int dx);
00104 
00105     bool isMultiItem();
00106     KOAgendaItem *prevMoveItem() const { return (mStartMoveInfo)?(mStartMoveInfo->mPrevMultiItem):0; }
00107     KOAgendaItem *nextMoveItem() const { return (mStartMoveInfo)?(mStartMoveInfo->mNextMultiItem):0; }
00108     MultiItemInfo *moveInfo() const { return mStartMoveInfo; }
00109     void setMultiItem(KOAgendaItem *first,KOAgendaItem *prev,
00110                       KOAgendaItem *next, KOAgendaItem *last);
00111     KOAgendaItem *prependMoveItem(KOAgendaItem*);
00112     KOAgendaItem *appendMoveItem(KOAgendaItem*);
00113     KOAgendaItem *removeMoveItem(KOAgendaItem*);
00114     KOAgendaItem *firstMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mFirstMultiItem):0; }
00115     KOAgendaItem *prevMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mPrevMultiItem):0; }
00116     KOAgendaItem *nextMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mNextMultiItem):0; }
00117     KOAgendaItem *lastMultiItem() const { return (mMultiItemInfo)?(mMultiItemInfo->mLastMultiItem):0; }
00118 
00119     Incidence *incidence() const { return mIncidence; }
00120     QDate itemDate() { return mDate; }
00121 
00123     void setItemDate(QDate qd);
00124 
00125     void setText ( const QString & text ) { mLabelText = text; }
00126     QString text () { return mLabelText; }
00127 
00128     static QToolTipGroup *toolTipGroup();
00129 
00130     QPtrList<KOAgendaItem> conflictItems();
00131     void setConflictItems(QPtrList<KOAgendaItem>);
00132     void addConflictItem(KOAgendaItem *ci);
00133     
00134     QString label() const;
00135 
00136     bool overlaps( KOrg::CellItem * ) const;
00137 
00138   signals:
00139     void removeAgendaItem( KOAgendaItem* );
00140     void showAgendaItem( KOAgendaItem* );
00141 
00142   public slots:
00143     void updateIcons();
00144     void select(bool=true);
00145     void addAttendee(QString);
00146 
00147   protected:
00148     void dragEnterEvent(QDragEnterEvent *e);
00149     void dropEvent(QDropEvent *e);
00150     void paintEvent(QPaintEvent *e);
00151     void paintFrame(QPainter *p, const QColor &color);
00152     void paintTodoIcon(QPainter *p, int &x, int ft);
00156     void startMovePrivate();
00157     void resetMovePrivate();
00158     void endMovePrivate();
00159 
00160 
00161   private:
00162     int mCellXLeft, mCellXRight;
00163     int mCellYTop, mCellYBottom;
00164     int mSubCell;  // subcell number of this item
00165     int mSubCells;  // Total number of subcells in cell of this item
00166 
00167     Incidence *mIncidence; // corresponding event or todo
00168     QDate mDate; //date this events occurs (for recurrence)
00169     QString mLabelText;
00170     bool mIconAlarm, mIconRecur, mIconReadonly;
00171     bool mIconReply, mIconGroup, mIconOrganizer;
00172 
00173     // Multi item pointers
00174     MultiItemInfo* mMultiItemInfo;
00175   protected:
00176     // Variables to remember start position
00177     MultiItemInfo* mStartMoveInfo;
00178 
00179   private:
00180     static QToolTipGroup *mToolTipGroup;
00181 
00182     bool mSelected;
00183     QPtrList<KOAgendaItem> mConflictItems;
00184 };
00185 
00186 #endif
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:28 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003