36 #ifndef _pqFlatTreeView_h 37 #define _pqFlatTreeView_h 40 #include "pqWidgetsModule.h" 41 #include <QAbstractScrollArea> 42 #include <QModelIndex> 43 #include <QStyleOptionViewItem> 45 class pqFlatTreeViewItem;
46 class pqFlatTreeViewItemRows;
47 class pqFlatTreeViewInternal;
49 class QAbstractItemModel;
54 class QItemSelectionModel;
106 virtual bool eventFilter(QObject *
object, QEvent *e);
110 QAbstractItemModel *
getModel()
const {
return this->Model;}
111 void setModel(QAbstractItemModel *model);
113 QModelIndex getRootIndex()
const;
114 void setRootIndex(
const QModelIndex &index);
120 void setSelectionModel(QItemSelectionModel *selectionModel);
131 QHeaderView *
getHeader()
const {
return this->HeaderView;}
132 void setHeader(QHeaderView *headerView);
150 void setColumnSizeManaged(
bool managed);
155 int getIconSize()
const;
156 void setIconSize(
int iconSize);
161 bool isIndexHidden(
const QModelIndex &index)
const;
162 void getVisibleRect(
const QModelIndex &index, QRect &area)
const;
163 QModelIndex getIndexVisibleAt(
const QPoint &point)
const;
164 QModelIndex getIndexCellAt(
const QPoint &point)
const;
165 void getSelectionIn(
const QRect &rect, QItemSelection &items)
const;
170 bool isIndexExpanded(
const QModelIndex &index)
const;
171 QModelIndex getNextVisibleIndex(
const QModelIndex &index,
172 const QModelIndex &root=QModelIndex())
const;
173 QModelIndex getRelativeIndex(
const QString &
id,
174 const QModelIndex &root=QModelIndex())
const;
175 void getRelativeIndexId(
const QModelIndex &index, QString &
id,
176 const QModelIndex &root=QModelIndex())
const;
181 bool startEditing(
const QModelIndex &index);
182 void finishEditing();
183 void cancelEditing();
187 void activated(
const QModelIndex &index);
188 void clicked(
const QModelIndex &index);
193 void setCurrentIndex(
const QModelIndex &index);
195 void expand(
const QModelIndex &index);
196 void collapse(
const QModelIndex &index);
197 void scrollTo(
const QModelIndex &index);
202 void insertRows(
const QModelIndex &parent,
int start,
int end);
203 void startRowRemoval(
const QModelIndex &parent,
int start,
int end);
204 void finishRowRemoval(
const QModelIndex &parent,
int start,
int end);
205 void insertColumns(
const QModelIndex &parent,
int start,
int end);
206 void startColumnRemoval(
const QModelIndex &parent,
int start,
int end);
207 void finishColumnRemoval(
const QModelIndex &parent,
int start,
int end);
208 void updateData(
const QModelIndex &topLeft,
const QModelIndex &bottomRight);
214 virtual void keyPressEvent(QKeyEvent *e);
215 void keyboardSearch(
const QString &search);
220 virtual void mousePressEvent(QMouseEvent *e);
221 virtual void mouseMoveEvent(QMouseEvent *e);
222 virtual void mouseReleaseEvent(QMouseEvent *e);
223 virtual void mouseDoubleClickEvent(QMouseEvent *e);
224 virtual void wheelEvent(QWheelEvent *e);
229 virtual bool event(QEvent *e);
232 int horizontalOffset()
const;
233 int verticalOffset()
const;
235 virtual void resizeEvent(QResizeEvent *e);
236 virtual bool viewportEvent(QEvent *e);
237 virtual void paintEvent(QPaintEvent *e);
238 QStyleOptionViewItem getViewOptions()
const;
243 void handleSectionResized(
int index,
int oldSize,
int newSize);
244 void handleSectionMoved(
int index,
int oldVisual,
int newVisual);
249 void changeCurrent(
const QModelIndex ¤t,
const QModelIndex &previous);
250 void changeCurrentRow(
const QModelIndex ¤t,
251 const QModelIndex &previous);
252 void changeCurrentColumn(
const QModelIndex ¤t,
253 const QModelIndex &previous);
254 void changeSelection(
const QItemSelection &selected,
255 const QItemSelection &deselected);
260 void resetPreferredSizes();
266 void layoutItem(pqFlatTreeViewItem *item,
int &point,
267 const QFontMetrics &fm);
268 int getDataWidth(
const QModelIndex &index,
const QFontMetrics &fm)
const;
269 int getWidthSum(pqFlatTreeViewItem *item,
int column)
const;
270 bool updateContentsWidth();
271 void updateScrollBars();
272 void addChildItems(pqFlatTreeViewItem *item,
int parentChildCount);
277 bool getIndexRowList(
const QModelIndex &index,
278 pqFlatTreeViewItemRows &rowList)
const;
279 pqFlatTreeViewItem *getItem(
const pqFlatTreeViewItemRows &rowList)
const;
280 pqFlatTreeViewItem *getItem(
const QModelIndex &index)
const;
281 pqFlatTreeViewItem *getItemAt(
int contentsY)
const;
282 pqFlatTreeViewItem *getNextItem(pqFlatTreeViewItem *item)
const;
283 pqFlatTreeViewItem *getNextVisibleItem(pqFlatTreeViewItem *item)
const;
284 pqFlatTreeViewItem *getPreviousVisibleItem(pqFlatTreeViewItem *item)
const;
285 pqFlatTreeViewItem *getLastVisibleItem()
const;
288 void expandItem(pqFlatTreeViewItem *item);
290 void getSelectionIn(
const QModelIndex &topLeft,
291 const QModelIndex &bottomRight, QItemSelection &items)
const;
293 void drawBranches(QPainter &painter, pqFlatTreeViewItem *item,
294 int halfIndent,
const QColor &branchColor,
const QColor &expandColor,
295 const QStyleOptionViewItem &options);
296 bool drawDecoration(QPainter &painter,
int px,
int py,
297 const QModelIndex &index,
const QStyleOptionViewItem &options,
299 void drawData(QPainter &painter,
int px,
int py,
300 const QModelIndex &index,
const QStyleOptionViewItem &options,
301 int itemHeight,
int itemWidth,
int columnWidth,
bool selected);
302 void drawFocus(QPainter &painter,
const QRect &cell,
303 const QStyleOptionViewItem &options,
bool selected);
306 QAbstractItemModel *Model;
307 QItemSelectionModel *Selection;
310 QHeaderView *HeaderView;
311 pqFlatTreeViewItem *Root;
312 pqFlatTreeViewInternal *Internal;
318 int DoubleTextMargin;
325 static int PipeLength;
QItemSelectionModel * getSelectionModel() const
QHeaderView * getHeader() const
Gets whether or not the column size is managed by the view.
SelectionMode getSelectionMode() const
QAbstractItemModel * getModel() const
The pqFlatTreeView class is used to display a flattened tree view of a hierarchical model...
SelectionBehavior getSelectionBehavior() const
bool isColumnSizeManaged() const
Gets whether or not the column size is managed by the view.