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;
111 bool eventFilter(QObject*
object, QEvent* e)
override;
117 QAbstractItemModel*
getModel()
const {
return this->Model; }
118 void setModel(QAbstractItemModel* model);
120 QModelIndex getRootIndex()
const;
121 void setRootIndex(
const QModelIndex&
index);
129 void setSelectionModel(QItemSelectionModel* selectionModel);
142 QHeaderView*
getHeader()
const {
return this->HeaderView; }
143 void setHeader(QHeaderView* headerView);
165 void setColumnSizeManaged(
bool managed);
172 int getIconSize()
const;
173 void setIconSize(
int iconSize);
180 bool isIndexHidden(
const QModelIndex& index)
const;
181 void getVisibleRect(
const QModelIndex& index, QRect& area)
const;
182 QModelIndex getIndexVisibleAt(
const QPoint&
point)
const;
183 QModelIndex getIndexCellAt(
const QPoint& point)
const;
184 void getSelectionIn(
const QRect& rect, QItemSelection& items)
const;
191 bool isIndexExpanded(
const QModelIndex& index)
const;
192 QModelIndex getNextVisibleIndex(
193 const QModelIndex& index,
const QModelIndex& root = QModelIndex())
const;
194 QModelIndex getRelativeIndex(
const QString&
id,
const QModelIndex& root = QModelIndex())
const;
195 void getRelativeIndexId(
196 const QModelIndex& index, QString&
id,
const QModelIndex& root = QModelIndex())
const;
203 bool startEditing(
const QModelIndex& index);
204 void finishEditing();
205 void cancelEditing();
209 void activated(
const QModelIndex& index);
210 void clicked(
const QModelIndex& index);
215 void setCurrentIndex(
const QModelIndex& index);
217 void expand(
const QModelIndex& index);
218 void collapse(
const QModelIndex& index);
219 void scrollTo(
const QModelIndex& index);
226 void insertRows(
const QModelIndex& parent,
int start,
int end);
227 void startRowRemoval(
const QModelIndex& parent,
int start,
int end);
228 void finishRowRemoval(
const QModelIndex& parent,
int start,
int end);
229 void insertColumns(
const QModelIndex& parent,
int start,
int end);
230 void startColumnRemoval(
const QModelIndex& parent,
int start,
int end);
231 void finishColumnRemoval(
const QModelIndex& parent,
int start,
int end);
232 void updateData(
const QModelIndex& topLeft,
const QModelIndex& bottomRight);
240 void keyPressEvent(QKeyEvent* e)
override;
241 void keyboardSearch(
const QString& search);
248 void mousePressEvent(QMouseEvent* e)
override;
249 void mouseMoveEvent(QMouseEvent* e)
override;
250 void mouseReleaseEvent(QMouseEvent* e)
override;
251 void mouseDoubleClickEvent(QMouseEvent* e)
override;
258 bool event(QEvent* e)
override;
261 int horizontalOffset()
const;
262 int verticalOffset()
const;
264 void resizeEvent(QResizeEvent* e)
override;
265 bool viewportEvent(QEvent* e)
override;
266 void paintEvent(QPaintEvent* e)
override;
267 QStyleOptionViewItem getViewOptions()
const;
274 void handleSectionResized(
int index,
int oldSize,
int newSize);
275 void handleSectionMoved(
int index,
int oldVisual,
int newVisual);
282 void changeCurrent(
const QModelIndex& current,
const QModelIndex&
previous);
283 void changeCurrentRow(
const QModelIndex& current,
const QModelIndex& previous);
284 void changeCurrentColumn(
const QModelIndex& current,
const QModelIndex& previous);
285 void changeSelection(
const QItemSelection& selected,
const QItemSelection& deselected);
290 void resetPreferredSizes();
298 void layoutItem(pqFlatTreeViewItem* item,
int& point,
const QFontMetrics& fm);
299 int getDataWidth(
const QModelIndex& index,
const QFontMetrics& fm)
const;
300 int getWidthSum(pqFlatTreeViewItem* item,
int column)
const;
301 bool updateContentsWidth();
302 void updateScrollBars();
303 void addChildItems(pqFlatTreeViewItem* item,
int parentChildCount);
310 bool getIndexRowList(
const QModelIndex& index, pqFlatTreeViewItemRows& rowList)
const;
311 pqFlatTreeViewItem* getItem(
const pqFlatTreeViewItemRows& rowList)
const;
312 pqFlatTreeViewItem* getItem(
const QModelIndex& index)
const;
313 pqFlatTreeViewItem* getItemAt(
int contentsY)
const;
314 pqFlatTreeViewItem* getNextItem(pqFlatTreeViewItem* item)
const;
315 pqFlatTreeViewItem* getNextVisibleItem(pqFlatTreeViewItem* item)
const;
316 pqFlatTreeViewItem* getPreviousVisibleItem(pqFlatTreeViewItem* item)
const;
317 pqFlatTreeViewItem* getLastVisibleItem()
const;
320 void expandItem(pqFlatTreeViewItem* item);
323 const QModelIndex& topLeft,
const QModelIndex& bottomRight, QItemSelection& items)
const;
325 void drawBranches(QPainter& painter, pqFlatTreeViewItem* item,
int halfIndent,
326 const QColor& branchColor,
const QColor& expandColor,
const QStyleOptionViewItem& options);
327 bool drawDecoration(QPainter& painter,
int px,
int py,
const QModelIndex& index,
328 const QStyleOptionViewItem& options,
int itemHeight);
329 void drawData(QPainter& painter,
int px,
int py,
const QModelIndex& index,
330 const QStyleOptionViewItem& options,
int itemHeight,
int itemWidth,
int columnWidth,
333 QPainter& painter,
const QRect& cell,
const QStyleOptionViewItem& options,
bool selected);
335 QAbstractItemModel* Model;
336 QItemSelectionModel* Selection;
339 QHeaderView* HeaderView;
340 pqFlatTreeViewItem* Root;
341 pqFlatTreeViewInternal* Internal;
347 int DoubleTextMargin;
354 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.