dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
waypointdelegate.h
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, see <http://www.gnu.org/licenses/>
25  */
26 
27 #ifndef WAYPOINTDELEGATE_H
28 #define WAYPOINTDELEGATE_H
29 
30 #include <QStyledItemDelegate>
31 #include <QComboBox>
32 #include <QEvent>
33 
38 class WaypointDelegate : public QStyledItemDelegate
39 {
40  Q_OBJECT
41 
42 public:
43  WaypointDelegate(QObject *parent = nullptr);
44 
46  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
47  const QModelIndex &index) const;
48 
50  bool eventFilter(QObject *object, QEvent *event);
51 
53  void setEditorData(QWidget *editor, const QModelIndex &index) const;
54 
56  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
57 
59  void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
60  const QModelIndex &index) const;
61 
63  QString displayText(const QVariant &value, const QLocale &locale) const;
64 
66  void loadComboBox(QComboBox *combo) const;
67 };
68 
69 #endif // WAYPOINTDELEGATE_H
void loadComboBox(QComboBox *combo) const
Populate the selections in the mode combo box.
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
Update the size of the editor widget.
The WaypointDelegate class is used to handle updating the values in the mode combo box to the data mo...
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Set data in the model when the UI is changed.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Create the QComboxBox for the mode or pass to the default implementation.
WaypointDelegate(QObject *parent=nullptr)
bool eventFilter(QObject *object, QEvent *event)
This filter is required to make combo boxes work.
void setEditorData(QWidget *editor, const QModelIndex &index) const
Set data in the UI when the model is changed.
QString displayText(const QVariant &value, const QLocale &locale) const
Convert the variant to a string value.