~ubuntu-branches/ubuntu/saucy/goldencheetah/saucy

« back to all changes in this revision

Viewing changes to qxt/src/qxtscheduleview_p.h

  • Committer: Package Import Robot
  • Author(s): KURASHIKI Satoru
  • Date: 2013-08-18 07:02:45 UTC
  • mfrom: (4.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130818070245-zgdvb47e1k3mtgil
Tags: 3.0-3
debian/control: remove needless dependency. (Closes: #719571)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 **
 
3
 ** Copyright (C) Qxt Foundation. Some rights reserved.
 
4
 **
 
5
 ** This file is part of the QxtGui module of the Qxt library.
 
6
 **
 
7
 ** This library is free software; you can redistribute it and/or modify it
 
8
 ** under the terms of the Common Public License, version 1.0, as published
 
9
 ** by IBM, and/or under the terms of the GNU Lesser General Public License,
 
10
 ** version 2.1, as published by the Free Software Foundation.
 
11
 **
 
12
 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
 
13
 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
 
14
 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
 
15
 ** FITNESS FOR A PARTICULAR PURPOSE.
 
16
 **
 
17
 ** You should have received a copy of the CPL and the LGPL along with this
 
18
 ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
 
19
 ** included with the source distribution for more information.
 
20
 ** If you did not receive a copy of the licenses, contact the Qxt Foundation.
 
21
 **
 
22
 ** <http://libqxt.org>  <foundation@libqxt.org>
 
23
 **
 
24
 ****************************************************************************/
 
25
 
 
26
#ifndef QXTSCHEDULEVIEW_P_INCLUDED
 
27
#define QXTSCHEDULEVIEW_P_INCLUDED
 
28
 
 
29
//
 
30
//  W A R N I N G
 
31
//  -------------
 
32
//
 
33
// This file is not part of the Qxt API.  It exists for the convenience
 
34
// of other Qxt classes.  This header file may change from version to
 
35
// version without notice, or even be removed.
 
36
//
 
37
// We mean it.
 
38
//
 
39
 
 
40
 
 
41
#include <QList>
 
42
#include <QLinkedList>
 
43
#include <QVector>
 
44
#include <QAbstractItemModel>
 
45
#include <QHeaderView>
 
46
#include <QPainterPath>
 
47
#include <QTimer>
 
48
#include "qxtnamespace.h"
 
49
#include "qxtscheduleitemdelegate.h"
 
50
 
 
51
class QxtScheduleView;
 
52
class QxtScheduleHeaderWidget;
 
53
 
 
54
class QxtScheduleInternalItem : public QObject
 
55
{
 
56
    Q_OBJECT
 
57
    friend class QxtScheduleView;
 
58
 
 
59
public:
 
60
 
 
61
    QxtScheduleInternalItem(QxtScheduleView *parent , QModelIndex index , QVector<QRect> geometries = QVector<QRect>());
 
62
 
 
63
    bool                setData(QVariant data , int role);
 
64
    QVariant            data(int role) const;
 
65
 
 
66
    int                 visualStartTableOffset() const;
 
67
    int                 visualEndTableOffset() const;
 
68
 
 
69
    int                 startTableOffset() const;
 
70
    int                 endTableOffset() const;
 
71
    void                setStartTableOffset(int iOffset);
 
72
 
 
73
    int                 rows() const;
 
74
    void                setRowsUsed(int rows);
 
75
    QxtScheduleView*    parentView() const;
 
76
 
 
77
    void                startMove();
 
78
    void                resetMove();
 
79
    void                stopMove();
 
80
 
 
81
    bool                contains(const QPoint &pt);
 
82
    void                setGeometry(const QVector<QRect> geo);
 
83
    QModelIndex         modelIndex() const;
 
84
    void                setDirty(bool state = true)
 
85
    {
 
86
        isDirty = state;
 
87
    }
 
88
 
 
89
    QVector<QRect>      geometry() const;
 
90
 
 
91
Q_SIGNALS:
 
92
    void                geometryChanged(QxtScheduleInternalItem * item , QVector<QRect> oldGeometry);
 
93
 
 
94
public:
 
95
    bool m_moving;
 
96
    bool isDirty;
 
97
    int m_iModelRow;
 
98
    QVector<QRect> m_geometries;
 
99
    QVector<QRect> m_SavedGeometries;
 
100
    QVector<QPixmap> m_cachedParts;
 
101
};
 
102
 
 
103
class QxtScheduleViewPrivate : public QObject, public QxtPrivate<QxtScheduleView>
 
104
{
 
105
    Q_OBJECT
 
106
public:
 
107
 
 
108
    QXT_DECLARE_PUBLIC(QxtScheduleView)
 
109
    QxtScheduleViewPrivate();
 
110
 
 
111
 
 
112
    int offsetToVisualColumn(const int iOffset) const;
 
113
    int offsetToVisualRow(const int iOffset) const;
 
114
    int visualIndexToOffset(const int iRow, const int iCol) const;
 
115
    int unixTimeToOffset(const uint constUnixTime, bool indexEndTime = false) const;
 
116
    int offsetToUnixTime(const int offset, bool indexEndTime = false) const;
 
117
    QVector< QRect > calculateRangeGeometries(const int iStartOffset, const int iEndOffset) const;
 
118
    int pointToOffset(const QPoint & point);
 
119
    void handleItemConcurrency(const int from, const int to);
 
120
    QList< QLinkedList<QxtScheduleInternalItem *> >findConcurrentItems(const int from, const int to) const;
 
121
 
 
122
 
 
123
    QxtScheduleInternalItem *internalItemAt(const QPoint &pt);
 
124
    QxtScheduleInternalItem *internalItemAtModelIndex(const QModelIndex &index);
 
125
 
 
126
 
 
127
    void init();
 
128
    void reloadItemsFromModel();
 
129
 
 
130
    QxtScheduleInternalItem * itemForModelIndex(const QModelIndex &index)const
 
131
    {
 
132
        for (int iLoop = 0; iLoop < m_Items.size(); iLoop++)
 
133
        {
 
134
            if (m_Items.at(iLoop)->modelIndex() == index)
 
135
                return m_Items.at(iLoop);
 
136
        }
 
137
        return 0;
 
138
    }
 
139
 
 
140
    void handleItemConcurrency(QxtScheduleInternalItem *item)
 
141
    {
 
142
        if (item)
 
143
        {
 
144
            int startOffset = item->startTableOffset();
 
145
            int endOffset = startOffset +  item->rows() - 1 ;
 
146
            handleItemConcurrency(startOffset, endOffset);
 
147
        }
 
148
    }
 
149
 
 
150
    QxtScheduleInternalItem *m_currentItem;
 
151
    QxtScheduleInternalItem *m_selectedItem;
 
152
 
 
153
    int m_lastMousePosOffset;
 
154
    int m_currentZoomDepth;
 
155
    int m_zoomStepWidth;
 
156
    int m_currentViewMode;
 
157
    uint m_startUnixTime;
 
158
    uint m_endUnixTime;
 
159
 
 
160
    QList<QxtScheduleInternalItem* > m_Items ;
 
161
    QList<QxtScheduleInternalItem* > m_InactiveItems; /*used for items that are not in the range of our view but we need to look if they get updates*/
 
162
 
 
163
    QTimer scrollTimer;
 
164
 
 
165
    QxtScheduleHeaderWidget *m_vHeader;
 
166
    QxtScheduleHeaderWidget *m_hHeader;
 
167
 
 
168
    int m_Cols;
 
169
 
 
170
    QAbstractItemModel *m_Model;
 
171
    bool handlesConcurrency;
 
172
    QxtScheduleItemDelegate *delegate;
 
173
    QxtScheduleItemDelegate *defaultDelegate;
 
174
 
 
175
public Q_SLOTS:
 
176
    void itemGeometryChanged(QxtScheduleInternalItem * item, QVector<QRect> oldGeometry);
 
177
    void scrollTimerTimeout();
 
178
 
 
179
};
 
180
 
 
181
bool qxtScheduleItemLessThan(const QxtScheduleInternalItem * item1, const QxtScheduleInternalItem * item2);
 
182
 
 
183
#endif