1
/****************************************************************************
3
** Copyright (C) Qxt Foundation. Some rights reserved.
5
** This file is part of the QxtGui module of the Qxt library.
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.
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.
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.
22
** <http://libqxt.org> <foundation@libqxt.org>
24
****************************************************************************/
26
#ifndef QXTSCHEDULEVIEW_P_INCLUDED
27
#define QXTSCHEDULEVIEW_P_INCLUDED
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.
42
#include <QLinkedList>
44
#include <QAbstractItemModel>
45
#include <QHeaderView>
46
#include <QPainterPath>
48
#include "qxtnamespace.h"
49
#include "qxtscheduleitemdelegate.h"
51
class QxtScheduleView;
52
class QxtScheduleHeaderWidget;
54
class QxtScheduleInternalItem : public QObject
57
friend class QxtScheduleView;
61
QxtScheduleInternalItem(QxtScheduleView *parent , QModelIndex index , QVector<QRect> geometries = QVector<QRect>());
63
bool setData(QVariant data , int role);
64
QVariant data(int role) const;
66
int visualStartTableOffset() const;
67
int visualEndTableOffset() const;
69
int startTableOffset() const;
70
int endTableOffset() const;
71
void setStartTableOffset(int iOffset);
74
void setRowsUsed(int rows);
75
QxtScheduleView* parentView() const;
81
bool contains(const QPoint &pt);
82
void setGeometry(const QVector<QRect> geo);
83
QModelIndex modelIndex() const;
84
void setDirty(bool state = true)
89
QVector<QRect> geometry() const;
92
void geometryChanged(QxtScheduleInternalItem * item , QVector<QRect> oldGeometry);
98
QVector<QRect> m_geometries;
99
QVector<QRect> m_SavedGeometries;
100
QVector<QPixmap> m_cachedParts;
103
class QxtScheduleViewPrivate : public QObject, public QxtPrivate<QxtScheduleView>
108
QXT_DECLARE_PUBLIC(QxtScheduleView)
109
QxtScheduleViewPrivate();
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;
123
QxtScheduleInternalItem *internalItemAt(const QPoint &pt);
124
QxtScheduleInternalItem *internalItemAtModelIndex(const QModelIndex &index);
128
void reloadItemsFromModel();
130
QxtScheduleInternalItem * itemForModelIndex(const QModelIndex &index)const
132
for (int iLoop = 0; iLoop < m_Items.size(); iLoop++)
134
if (m_Items.at(iLoop)->modelIndex() == index)
135
return m_Items.at(iLoop);
140
void handleItemConcurrency(QxtScheduleInternalItem *item)
144
int startOffset = item->startTableOffset();
145
int endOffset = startOffset + item->rows() - 1 ;
146
handleItemConcurrency(startOffset, endOffset);
150
QxtScheduleInternalItem *m_currentItem;
151
QxtScheduleInternalItem *m_selectedItem;
153
int m_lastMousePosOffset;
154
int m_currentZoomDepth;
156
int m_currentViewMode;
157
uint m_startUnixTime;
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*/
165
QxtScheduleHeaderWidget *m_vHeader;
166
QxtScheduleHeaderWidget *m_hHeader;
170
QAbstractItemModel *m_Model;
171
bool handlesConcurrency;
172
QxtScheduleItemDelegate *delegate;
173
QxtScheduleItemDelegate *defaultDelegate;
176
void itemGeometryChanged(QxtScheduleInternalItem * item, QVector<QRect> oldGeometry);
177
void scrollTimerTimeout();
181
bool qxtScheduleItemLessThan(const QxtScheduleInternalItem * item1, const QxtScheduleInternalItem * item2);