Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
profile_tree_view.h
Go to the documentation of this file.
1
9
10#ifndef PROFILE_TREEVIEW_H
11#define PROFILE_TREEVIEW_H
12
14
15#include <QTreeView>
16#include <QItemDelegate>
17#include <QPersistentModelIndex>
18#include <QPixmap>
19#include <QPoint>
20
25class ProfileTreeEditDelegate : public QItemDelegate
26{
27 Q_OBJECT
28public:
33 ProfileTreeEditDelegate(QWidget *parent = Q_NULLPTR);
34
42 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
43
49 virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override;
50
51private:
52 QWidget *editor_;
53 QModelIndex index_;
54};
55
56
61class ProfileTreeView : public QTreeView
62{
63 Q_OBJECT
64public:
69 ProfileTreeView(QWidget *parent = nullptr);
70
75
80 void selectIndex(const QModelIndex &idx);
81
86 bool activeEdit();
87
88signals:
93
94protected:
98 virtual void showEvent(QShowEvent *) override;
99
105 virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
106
111 virtual void startDrag(Qt::DropActions supportedActions) override;
112
117 virtual void dragMoveEvent(QDragMoveEvent *event) override;
118 virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
119 virtual void dropEvent(QDropEvent *event) override;
120 virtual void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
121 virtual void paintEvent(QPaintEvent *event) override;
122
123protected slots:
130 virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
131
132private:
133 ProfileTreeEditDelegate *delegate_;
134 QList<QPersistentModelIndex> drop_path_;
135 QPixmap drag_pixmap_;
136 QPoint drag_offset_;
137 QPoint drag_pos_ = QPoint(-1, -1);
138 bool drop_top_level_ = false;
139
145 void setDropPath(const QModelIndex &target, bool topLevel = false);
146};
147
148#endif
Item delegate that provides inline editing for profile name cells in the profile tree view.
Definition profile_tree_view.h:26
ProfileTreeEditDelegate(QWidget *parent=Q_NULLPTR)
Constructs a ProfileTreeEditDelegate.
Definition profile_tree_view.cpp:28
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Creates and returns an editor widget for the cell at index.
Definition profile_tree_view.cpp:30
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override
Populates the editor widget with the current value from the model.
Definition profile_tree_view.cpp:39
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override
Responds to selection changes, updating UI state and emitting itemUpdated() when appropriate.
Definition profile_tree_view.cpp:63
~ProfileTreeView()
Destroys the view and releases the associated delegate.
Definition profile_tree_view.cpp:58
virtual void dragMoveEvent(QDragMoveEvent *event) override
Highlights the profile where a dragged profile will be moved to, and all its parents.
Definition profile_tree_view.cpp:181
virtual void showEvent(QShowEvent *) override
Restores the previously selected row when the view becomes visible.
Definition profile_tree_view.cpp:260
virtual void startDrag(Qt::DropActions supportedActions) override
Starts dragging the selected profile names, with the same drag image on all platforms.
Definition profile_tree_view.cpp:118
void itemUpdated()
Emitted when a profile item has been modified through the inline editor.
void selectIndex(const QModelIndex &idx)
Selects the row of idx in the view.
Definition profile_tree_view.cpp:87
bool activeEdit()
Returns whether an inline edit is currently active in the view.
Definition profile_tree_view.cpp:253
ProfileTreeView(QWidget *parent=nullptr)
Constructs a ProfileTreeView.
Definition profile_tree_view.cpp:48
virtual void mouseDoubleClickEvent(QMouseEvent *event) override
Opens an inline editor for the double-clicked cell when the profile is editable; otherwise propagates...
Definition profile_tree_view.cpp:100