Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef QXTSCHEDULEVIEW_P_INCLUDED
00027 #define QXTSCHEDULEVIEW_P_INCLUDED
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <QList>
00042 #include <QLinkedList>
00043 #include <QVector>
00044 #include <QAbstractItemModel>
00045 #include <QHeaderView>
00046 #include <QPainterPath>
00047 #include <QTimer>
00048 #include "qxtnamespace.h"
00049 #include "qxtpimpl.h"
00050 #include "qxtscheduleitemdelegate.h"
00051
00052 class QxtScheduleView;
00053 class QxtScheduleHeaderWidget;
00054
00055 class QxtScheduleInternalItem : public QObject
00056 {
00057 Q_OBJECT
00058 friend class QxtScheduleView;
00059
00060 public:
00061
00062 QxtScheduleInternalItem(QxtScheduleView *parent , QModelIndex index , QVector<QRect> geometries = QVector<QRect>());
00063
00064 bool setData(QVariant data , int role);
00065 QVariant data(int role) const;
00066
00067 int visualStartTableOffset() const;
00068 int visualEndTableOffset() const;
00069
00070 int startTableOffset() const;
00071 int endTableOffset() const;
00072 void setStartTableOffset(int iOffset);
00073
00074 int rows() const;
00075 void setRowsUsed(int rows);
00076 QxtScheduleView* parentView() const;
00077
00078 void startMove();
00079 void resetMove();
00080 void stopMove();
00081
00082 bool contains(const QPoint &pt);
00083 void setGeometry(const QVector<QRect> geo);
00084 QModelIndex modelIndex() const;
00085 void setDirty(bool state = true)
00086 {
00087 isDirty = state;
00088 }
00089
00090 QVector<QRect> geometry() const;
00091
00092 Q_SIGNALS:
00093 void geometryChanged(QxtScheduleInternalItem * item , QVector<QRect> oldGeometry);
00094
00095 public:
00096 bool m_moving;
00097 bool isDirty;
00098 int m_iModelRow;
00099 QVector<QRect> m_geometries;
00100 QVector<QRect> m_SavedGeometries;
00101 QVector<QPixmap> m_cachedParts;
00102 };
00103
00104 class QxtScheduleViewPrivate : public QObject, public QxtPrivate<QxtScheduleView>
00105 {
00106 Q_OBJECT
00107 public:
00108
00109 QXT_DECLARE_PUBLIC(QxtScheduleView);
00110 QxtScheduleViewPrivate();
00111
00112
00113 int offsetToVisualColumn(const int iOffset) const;
00114 int offsetToVisualRow(const int iOffset) const;
00115 int visualIndexToOffset(const int iRow, const int iCol) const;
00116 int unixTimeToOffset(const uint constUnixTime, bool indexEndTime = false) const;
00117 int offsetToUnixTime(const int offset, bool indexEndTime = false) const;
00118 QVector< QRect > calculateRangeGeometries(const int iStartOffset, const int iEndOffset) const;
00119 int pointToOffset(const QPoint & point);
00120 void handleItemConcurrency(const int from, const int to);
00121 QList< QLinkedList<QxtScheduleInternalItem *> >findConcurrentItems(const int from, const int to) const;
00122
00123
00124 QxtScheduleInternalItem *internalItemAt(const QPoint &pt);
00125 QxtScheduleInternalItem *internalItemAtModelIndex(const QModelIndex &index);
00126
00127
00128 void init();
00129 void reloadItemsFromModel();
00130
00131 QxtScheduleInternalItem * itemForModelIndex(const QModelIndex &index)const
00132 {
00133 for (int iLoop = 0; iLoop < m_Items.size(); iLoop++)
00134 {
00135 if (m_Items.at(iLoop)->modelIndex() == index)
00136 return m_Items.at(iLoop);
00137 }
00138 return 0;
00139 }
00140
00141 void handleItemConcurrency(QxtScheduleInternalItem *item)
00142 {
00143 if (item)
00144 {
00145 int startOffset = item->startTableOffset();
00146 int endOffset = startOffset + item->rows() - 1 ;
00147 handleItemConcurrency(startOffset, endOffset);
00148 }
00149 }
00150
00151 QxtScheduleInternalItem *m_currentItem;
00152 QxtScheduleInternalItem *m_selectedItem;
00153
00154 int m_lastMousePosOffset;
00155 int m_currentZoomDepth;
00156 int m_zoomStepWidth;
00157 int m_currentViewMode;
00158 uint m_startUnixTime;
00159 uint m_endUnixTime;
00160
00161 QList<QxtScheduleInternalItem* > m_Items ;
00162 QList<QxtScheduleInternalItem* > m_InactiveItems;
00163
00164 QTimer scrollTimer;
00165
00166 QxtScheduleHeaderWidget *m_vHeader;
00167 QxtScheduleHeaderWidget *m_hHeader;
00168
00169 int m_Cols;
00170
00171 QAbstractItemModel *m_Model;
00172 bool handlesConcurrency;
00173 QxtScheduleItemDelegate *delegate;
00174 QxtScheduleItemDelegate *defaultDelegate;
00175
00176 public Q_SLOTS:
00177 void itemGeometryChanged(QxtScheduleInternalItem * item, QVector<QRect> oldGeometry);
00178 void scrollTimerTimeout();
00179
00180 };
00181
00182 bool qxtScheduleItemLessThan(const QxtScheduleInternalItem * item1, const QxtScheduleInternalItem * item2);
00183
00184 #endif