38 #ifndef _pqFlatTreeView_h 39 #define _pqFlatTreeView_h 42 #include <QAbstractScrollArea> 43 #include <QModelIndex> 44 #include <QStyleOptionViewItem> 46 class pqFlatTreeViewItem;
47 class pqFlatTreeViewItemRows;
48 class pqFlatTreeViewInternal;
50 class QAbstractItemModel;
55 class QItemSelectionModel;
112 bool eventFilter(QObject*
object, QEvent* e)
override;
118 QAbstractItemModel*
getModel()
const {
return this->Model; }
119 void setModel(QAbstractItemModel* model);
121 QModelIndex getRootIndex()
const;
122 void setRootIndex(
const QModelIndex&
index);
130 void setSelectionModel(QItemSelectionModel* selectionModel);
143 QHeaderView*
getHeader()
const {
return this->HeaderView; }
144 void setHeader(QHeaderView* headerView);
166 void setColumnSizeManaged(
bool managed);
173 int getIconSize()
const;
174 void setIconSize(
int iconSize);
181 bool isIndexHidden(
const QModelIndex& index)
const;
182 void getVisibleRect(
const QModelIndex& index, QRect& area)
const;
183 QModelIndex getIndexVisibleAt(
const QPoint&
point)
const;
184 QModelIndex getIndexCellAt(
const QPoint& point)
const;
185 void getSelectionIn(
const QRect& rect, QItemSelection& items)
const;
192 bool isIndexExpanded(
const QModelIndex& index)
const;
193 QModelIndex getNextVisibleIndex(
194 const QModelIndex& index,
const QModelIndex& root = QModelIndex())
const;
195 QModelIndex getRelativeIndex(
const QString&
id,
const QModelIndex& root = QModelIndex())
const;
196 void getRelativeIndexId(
197 const QModelIndex& index, QString&
id,
const QModelIndex& root = QModelIndex())
const;
204 bool startEditing(
const QModelIndex& index);
205 void finishEditing();
206 void cancelEditing();
210 void activated(
const QModelIndex& index);
211 void clicked(
const QModelIndex& index);
216 void setCurrentIndex(
const QModelIndex& index);
218 void expand(
const QModelIndex& index);
219 void collapse(
const QModelIndex& index);
220 void scrollTo(
const QModelIndex& index);
227 void insertRows(
const QModelIndex& parent,
int start,
int end);
228 void startRowRemoval(
const QModelIndex& parent,
int start,
int end);
229 void finishRowRemoval(
const QModelIndex& parent,
int start,
int end);
230 void insertColumns(
const QModelIndex& parent,
int start,
int end);
231 void startColumnRemoval(
const QModelIndex& parent,
int start,
int end);
232 void finishColumnRemoval(
const QModelIndex& parent,
int start,
int end);
233 void updateData(
const QModelIndex& topLeft,
const QModelIndex& bottomRight);
241 void keyPressEvent(QKeyEvent* e)
override;
242 void keyboardSearch(
const QString& search);
249 void mousePressEvent(QMouseEvent* e)
override;
250 void mouseMoveEvent(QMouseEvent* e)
override;
251 void mouseReleaseEvent(QMouseEvent* e)
override;
252 void mouseDoubleClickEvent(QMouseEvent* e)
override;
259 bool event(QEvent* e)
override;
262 int horizontalOffset()
const;
263 int verticalOffset()
const;
265 void resizeEvent(QResizeEvent* e)
override;
266 bool viewportEvent(QEvent* e)
override;
267 void paintEvent(QPaintEvent* e)
override;
268 QStyleOptionViewItem getViewOptions()
const;
275 void handleSectionResized(
int index,
int oldSize,
int newSize);
276 void handleSectionMoved(
int index,
int oldVisual,
int newVisual);
283 void changeCurrent(
const QModelIndex& current,
const QModelIndex&
previous);
284 void changeCurrentRow(
const QModelIndex& current,
const QModelIndex& previous);
285 void changeCurrentColumn(
const QModelIndex& current,
const QModelIndex& previous);
286 void changeSelection(
const QItemSelection& selected,
const QItemSelection& deselected);
291 void resetPreferredSizes();
299 void layoutItem(pqFlatTreeViewItem* item,
int& point,
const QFontMetrics& fm);
300 int getDataWidth(
const QModelIndex& index,
const QFontMetrics& fm)
const;
301 int getWidthSum(pqFlatTreeViewItem* item,
int column)
const;
302 bool updateContentsWidth();
303 void updateScrollBars();
304 void addChildItems(pqFlatTreeViewItem* item,
int parentChildCount);
311 bool getIndexRowList(
const QModelIndex& index, pqFlatTreeViewItemRows& rowList)
const;
312 pqFlatTreeViewItem* getItem(
const pqFlatTreeViewItemRows& rowList)
const;
313 pqFlatTreeViewItem* getItem(
const QModelIndex& index)
const;
314 pqFlatTreeViewItem* getItemAt(
int contentsY)
const;
315 pqFlatTreeViewItem* getNextItem(pqFlatTreeViewItem* item)
const;
316 pqFlatTreeViewItem* getNextVisibleItem(pqFlatTreeViewItem* item)
const;
317 pqFlatTreeViewItem* getPreviousVisibleItem(pqFlatTreeViewItem* item)
const;
318 pqFlatTreeViewItem* getLastVisibleItem()
const;
321 void expandItem(pqFlatTreeViewItem* item);
324 const QModelIndex& topLeft,
const QModelIndex& bottomRight, QItemSelection& items)
const;
326 void drawBranches(QPainter& painter, pqFlatTreeViewItem* item,
int halfIndent,
327 const QColor& branchColor,
const QColor& expandColor,
const QStyleOptionViewItem& options);
328 bool drawDecoration(QPainter& painter,
int px,
int py,
const QModelIndex& index,
329 const QStyleOptionViewItem& options,
int itemHeight);
330 void drawData(QPainter& painter,
int px,
int py,
const QModelIndex& index,
331 const QStyleOptionViewItem& options,
int itemHeight,
int itemWidth,
int columnWidth,
334 QPainter& painter,
const QRect& cell,
const QStyleOptionViewItem& options,
bool selected);
337 QAbstractItemModel* Model;
338 QItemSelectionModel* Selection;
341 QHeaderView* HeaderView;
342 pqFlatTreeViewItem* Root;
343 pqFlatTreeViewInternal* Internal;
349 int DoubleTextMargin;
356 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.