53 // We mean it. |
53 // We mean it. |
54 // |
54 // |
55 |
55 |
56 #include "private/qabstractitemview_p.h" |
56 #include "private/qabstractitemview_p.h" |
57 #include <QtCore/qvariantanimation.h> |
57 #include <QtCore/qvariantanimation.h> |
|
58 #include <QtCore/qabstractitemmodel.h> |
58 |
59 |
59 #ifndef QT_NO_TREEVIEW |
60 #ifndef QT_NO_TREEVIEW |
60 |
61 |
61 QT_BEGIN_NAMESPACE |
62 QT_BEGIN_NAMESPACE |
62 |
63 |
63 struct QTreeViewItem |
64 struct QTreeViewItem |
64 { |
65 { |
65 QTreeViewItem() : expanded(false), spanning(false), hasChildren(false), |
66 QTreeViewItem() : parentItem(-1), expanded(false), spanning(false), hasChildren(false), |
66 hasMoreSiblings(false), total(0), level(0), height(0) {} |
67 hasMoreSiblings(false), total(0), level(0), height(0) {} |
67 QModelIndex index; // we remove items whenever the indexes are invalidated |
68 QModelIndex index; // we remove items whenever the indexes are invalidated |
|
69 int parentItem; // parent item index in viewItems |
68 uint expanded : 1; |
70 uint expanded : 1; |
69 uint spanning : 1; |
71 uint spanning : 1; |
70 uint hasChildren : 1; // if the item has visible children (even if collapsed) |
72 uint hasChildren : 1; // if the item has visible children (even if collapsed) |
71 uint hasMoreSiblings : 1; |
73 uint hasMoreSiblings : 1; |
72 uint total : 28; // total number of children visible |
74 uint total : 28; // total number of children visible |
73 uint level : 16; // indentation |
75 uint level : 16; // indentation |
74 int height : 16; // row height |
76 int height : 16; // row height |
75 }; |
77 }; |
76 |
78 |
|
79 Q_DECLARE_TYPEINFO(QTreeViewItem, Q_MOVABLE_TYPE); |
|
80 |
77 class QTreeViewPrivate : public QAbstractItemViewPrivate |
81 class QTreeViewPrivate : public QAbstractItemViewPrivate |
78 { |
82 { |
79 Q_DECLARE_PUBLIC(QTreeView) |
83 Q_DECLARE_PUBLIC(QTreeView) |
80 public: |
84 public: |
81 |
85 |
85 uniformRowHeights(false), rootDecoration(true), |
89 uniformRowHeights(false), rootDecoration(true), |
86 itemsExpandable(true), sortingEnabled(false), |
90 itemsExpandable(true), sortingEnabled(false), |
87 expandsOnDoubleClick(true), |
91 expandsOnDoubleClick(true), |
88 allColumnsShowFocus(false), current(0), spanning(false), |
92 allColumnsShowFocus(false), current(0), spanning(false), |
89 animationsEnabled(false), columnResizeTimerID(0), |
93 animationsEnabled(false), columnResizeTimerID(0), |
90 autoExpandDelay(-1), hoverBranch(-1), geometryRecursionBlock(false) {} |
94 autoExpandDelay(-1), hoverBranch(-1), geometryRecursionBlock(false), hasRemovedItems(false) {} |
91 |
95 |
92 ~QTreeViewPrivate() {} |
96 ~QTreeViewPrivate() {} |
93 void initialize(); |
97 void initialize(); |
94 |
98 |
95 QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; |
99 QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const; |
121 void _q_columnsRemoved(const QModelIndex &, int, int); |
125 void _q_columnsRemoved(const QModelIndex &, int, int); |
122 void _q_modelAboutToBeReset(); |
126 void _q_modelAboutToBeReset(); |
123 void _q_sortIndicatorChanged(int column, Qt::SortOrder order); |
127 void _q_sortIndicatorChanged(int column, Qt::SortOrder order); |
124 void _q_modelDestroyed(); |
128 void _q_modelDestroyed(); |
125 |
129 |
126 void layout(int item); |
130 void layout(int item, bool recusiveExpanding = false, bool afterIsUninitialized = false); |
127 |
131 |
128 int pageUp(int item) const; |
132 int pageUp(int item) const; |
129 int pageDown(int item) const; |
133 int pageDown(int item) const; |
130 |
134 |
131 int itemHeight(int item) const; |
135 int itemHeight(int item) const; |
134 int itemAtCoordinate(int coordinate) const; |
138 int itemAtCoordinate(int coordinate) const; |
135 |
139 |
136 int viewIndex(const QModelIndex &index) const; |
140 int viewIndex(const QModelIndex &index) const; |
137 QModelIndex modelIndex(int i, int column = 0) const; |
141 QModelIndex modelIndex(int i, int column = 0) const; |
138 |
142 |
|
143 void insertViewItems(int pos, int count, const QTreeViewItem &viewItem); |
|
144 void removeViewItems(int pos, int count); |
|
145 #if 0 |
|
146 bool checkViewItems() const; |
|
147 #endif |
|
148 |
139 int firstVisibleItem(int *offset = 0) const; |
149 int firstVisibleItem(int *offset = 0) const; |
140 int columnAt(int x) const; |
150 int columnAt(int x) const; |
141 bool hasVisibleChildren( const QModelIndex& parent) const; |
151 bool hasVisibleChildren( const QModelIndex& parent) const; |
142 |
152 |
143 void relayout(const QModelIndex &parent); |
|
144 bool expandOrCollapseItemAtPos(const QPoint &pos); |
153 bool expandOrCollapseItemAtPos(const QPoint &pos); |
145 |
154 |
146 void updateScrollBars(); |
155 void updateScrollBars(); |
147 |
156 |
148 int itemDecorationAt(const QPoint &pos) const; |
157 int itemDecorationAt(const QPoint &pos) const; |
153 void select(const QModelIndex &start, const QModelIndex &stop, QItemSelectionModel::SelectionFlags command); |
162 void select(const QModelIndex &start, const QModelIndex &stop, QItemSelectionModel::SelectionFlags command); |
154 |
163 |
155 QPair<int,int> startAndEndColumns(const QRect &rect) const; |
164 QPair<int,int> startAndEndColumns(const QRect &rect) const; |
156 |
165 |
157 void updateChildCount(const int parentItem, const int delta); |
166 void updateChildCount(const int parentItem, const int delta); |
158 void rowsRemoved(const QModelIndex &parent, |
|
159 int start, int end, bool before); |
|
160 |
167 |
161 void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const; |
168 void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const; |
162 |
169 |
163 QHeaderView *header; |
170 QHeaderView *header; |
164 int indent; |
171 int indent; |
230 // used for drawing hilighted expand/collapse indicators |
237 // used for drawing hilighted expand/collapse indicators |
231 int hoverBranch; |
238 int hoverBranch; |
232 |
239 |
233 // used for blocking recursion when calling setViewportMargins from updateGeometries |
240 // used for blocking recursion when calling setViewportMargins from updateGeometries |
234 bool geometryRecursionBlock; |
241 bool geometryRecursionBlock; |
|
242 |
|
243 // If we should clean the set |
|
244 bool hasRemovedItems; |
235 }; |
245 }; |
236 |
246 |
237 QT_END_NAMESPACE |
247 QT_END_NAMESPACE |
238 |
248 |
239 #endif // QT_NO_TREEVIEW |
249 #endif // QT_NO_TREEVIEW |