|
3 | 3 | #include <QtCore/QAbstractItemModel> |
4 | 4 | #include <QtCore/QHash> |
5 | 5 | #include <QtCore/QItemSelection> |
| 6 | +#include <QtCore/QMimeData> |
6 | 7 | #include <QtCore/QModelIndex> |
| 8 | +#include <QtCore/QPoint> |
7 | 9 | #include <QtCore/QPointer> |
8 | 10 | #include <QtCore/QRegularExpression> |
9 | 11 | #include <QtCore/QSet> |
|
12 | 14 | #include <QtCore/QStringList> |
13 | 15 | #include <QtCore/QTimer> |
14 | 16 | #include <QtCore/QVariant> |
| 17 | +#include <QtGui/QDrag> |
| 18 | +#include <QtGui/QDragEnterEvent> |
| 19 | +#include <QtGui/QDragLeaveEvent> |
| 20 | +#include <QtGui/QDragMoveEvent> |
| 21 | +#include <QtGui/QDropEvent> |
15 | 22 | #include <QtGui/QMouseEvent> |
16 | 23 | #include <QtWidgets/QCheckBox> |
17 | 24 | #include <QtWidgets/QComboBox> |
|
22 | 29 | #include <QtWidgets/QSpinBox> |
23 | 30 | #include <QtWidgets/QStyledItemDelegate> |
24 | 31 | #include <QtWidgets/QTableWidget> |
| 32 | +#include <QtWidgets/QToolButton> |
25 | 33 | #include <QtWidgets/QTreeView> |
26 | 34 | #include <QtWidgets/QVBoxLayout> |
27 | 35 |
|
@@ -166,33 +174,45 @@ class BINARYNINJAUIAPI ArrayStringSettingEditor : public QWidget |
166 | 174 | QStringList m_enumValues; |
167 | 175 | QSet<QString> m_defaultValueSet; |
168 | 176 | bool m_readOnly = false; |
| 177 | + bool m_reorderable = false; |
169 | 178 | QVBoxLayout* m_rowLayout = nullptr; |
170 | 179 | QWidget* m_addRowWidget = nullptr; |
171 | 180 | QLineEdit* m_addLineEdit = nullptr; |
172 | 181 | QComboBox* m_addComboBox = nullptr; |
173 | 182 | CustomStyleFlatToolButton* m_addButton = nullptr; |
174 | 183 | std::vector<QWidget*> m_rows; |
175 | 184 |
|
| 185 | + int m_dropIndicatorY = -1; |
| 186 | + QPoint m_dragStartPos; |
| 187 | + int m_dragSourceIndex = -1; |
| 188 | + |
176 | 189 | QLineEdit* addRowInputField() const; |
177 | 190 | void clearRows(); |
178 | 191 | QString currentAddText() const; |
179 | 192 | void appendRow(const QString& text); |
180 | 193 | void updateTabOrder(); |
| 194 | + int rowIndexAtY(int y) const; |
| 195 | + QToolButton* findRowGrip(QWidget* row) const; |
181 | 196 |
|
182 | 197 | private Q_SLOTS: |
183 | 198 | void onAddClicked(); |
184 | 199 | void onRowEditingFinished(); |
185 | 200 | void onRowRemoveClicked(); |
186 | 201 |
|
187 | 202 | public: |
188 | | - ArrayStringSettingEditor(QWidget* parent, const QStringList& enumValues, const QStringList& defaultValues, bool readOnly); |
| 203 | + ArrayStringSettingEditor(QWidget* parent, const QStringList& enumValues, const QStringList& defaultValues, bool readOnly, bool reorderable); |
189 | 204 |
|
190 | 205 | void setValues(const QStringList& values); |
191 | 206 | QStringList values() const; |
192 | 207 | void clearAddText(); |
193 | 208 |
|
194 | 209 | protected: |
195 | 210 | void paintEvent(QPaintEvent* event) override; |
| 211 | + bool eventFilter(QObject* watched, QEvent* event) override; |
| 212 | + void dragEnterEvent(QDragEnterEvent* event) override; |
| 213 | + void dragMoveEvent(QDragMoveEvent* event) override; |
| 214 | + void dragLeaveEvent(QDragLeaveEvent* event) override; |
| 215 | + void dropEvent(QDropEvent* event) override; |
196 | 216 |
|
197 | 217 | Q_SIGNALS: |
198 | 218 | void changed(); |
|
0 commit comments