summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaitem.h
blob: 53658c02a138b46372dea2f9775b42f5307cefba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
    This file is part of KOrganizer.
    Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
#ifndef KOAGENDAITEM_H
#define KOAGENDAITEM_H

#include <qframe.h>
#include <qlabel.h>
#include <qpixmap.h>
#include <qdatetime.h>
#include <qpalette.h> 

#include <libkcal/incidence.h>

class KOAgendaItemWhatsThis;
class QToolTipGroup;
class QDragEnterEvent;
class QDropEvent;

using namespace KCal;

/*
  The KOAgendaItem has to make sure that it receives all mouse events, which are
  to be used for dragging and resizing. That means it has to be installed as
  eventfiler for its children, if it has children, and it has to pass mouse
  events from the cildren to itself. See eventFilter().
*/
class KOAgendaItem : public QWidget
{
    Q_OBJECT
  public:
    KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
                 WFlags f=0 );
    ~KOAgendaItem();
    QString getWhatsThisText();
    void init ( Incidence *incidence, QDate qd );
    int cellX() { return mCellX; }
    int cellXWidth() { return mCellXWidth; }
    int cellYTop() { return mCellYTop; }
    int cellYBottom() { return mCellYBottom; }
    int cellHeight();
    int cellWidth();
    int subCell() { return mSubCell; }
    int subCells() { return mSubCells; }

    void setCellXY(int X, int YTop, int YBottom);
    void setCellY(int YTop, int YBottom);
    void setCellX(int XLeft, int XRight);
    void setCellXWidth(int xwidth);
    void setSubCell(int subCell);
    void setSubCells(int subCells);

    /** Start movement */
    void startMove();
    /** Reset to original values */
    void resetMove();

    void moveRelative(int dx,int dy);
    void expandTop(int dy);
    void expandBottom(int dy);
    void expandLeft(int dx);
    void expandRight(int dx);
    int mLastMoveXPos;

    void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
                      KOAgendaItem *last);
    KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
    KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
    KOAgendaItem *lastMultiItem() { return mLastMultiItem; }

    Incidence *incidence() const { return mIncidence; }
    QDate itemDate() { return mDate; }
    
    /** Update the date of this item's occurence (not in the event) */ 
    void setItemDate(QDate qd);
    
    void setText ( const QString & text ) { mDisplayedText = text; }
    QString text () { return mDisplayedText; }

    virtual bool eventFilter ( QObject *, QEvent * );

    static QToolTipGroup *toolTipGroup();
    
    QPtrList<KOAgendaItem> conflictItems();
    void setConflictItems(QPtrList<KOAgendaItem>);
    void addConflictItem(KOAgendaItem *ci);
    void paintMe( bool, QPainter* painter = 0 );
    void repaintMe();
    static void resizePixmap( int, int );
    static QPixmap * paintPix();
    static QPixmap * paintPixSel();
    static QPixmap * paintPixAllday();
    void updateItem();
    void computeText();
    void recreateIncidence();
    bool checkLayout();
  public slots:
    bool updateIcons( QPainter *, bool );
    void select(bool=true);

 protected:
    void dragEnterEvent(QDragEnterEvent *e);
    void dropEvent(QDropEvent *e);
    void paintEvent ( QPaintEvent * );
    void resizeEvent ( QResizeEvent *ev );

  private:
    KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
    bool mAllDay;
    int mCellX;
    int mCellXWidth;
    int mCellYTop,mCellYBottom;
    int mSubCell;  // subcell number of this item
    int mSubCells;  // Total number of subcells in cell of this item
    int xPaintCoord;
    int yPaintCoord;
    int wPaintCoord;
    int hPaintCoord;
    // Variables to remember start position
    int mStartCellX;
    int mStartCellXWidth;
    int mStartCellYTop,mStartCellYBottom;
    int mLastMovePos;

    // Multi item pointers
    KOAgendaItem *mFirstMultiItem;
    KOAgendaItem *mNextMultiItem;
    KOAgendaItem *mLastMultiItem;
    
    int mFontPixelSize;
    Incidence *mIncidence; // corresponding event or todo
    QDate mDate; //date this events occurs (for recurrence)
    //void showIcon( QLabel*, int );
    //QLabel *mTodoIconLabel;
    //QLabel *mItemLabel;
    //QWidget *mIconBox;
    //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
    //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
    //QLabel *mIconMoreInfo;
    static QToolTipGroup *mToolTipGroup;

    QColor mBackgroundColor;
    QColorGroup mColorGroup;
    QString mDisplayedText;
    bool mSelected;
    QPtrList<KOAgendaItem> mConflictItems;
};

#endif // KOAGENDAITEM_H