aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/qconf.h
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2020-08-29 17:14:12 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2020-09-25 00:37:13 +0900
commit37162a68bf517b6f870d63bbbcc65a81f99bd968 (patch)
tree82b4a1da75c4cefa243d9436e12c008ab5d81ae0 /scripts/kconfig/qconf.h
parentkconfig: qconf: show data column all the time (diff)
downloadlinux-dev-37162a68bf517b6f870d63bbbcc65a81f99bd968.tar.xz
linux-dev-37162a68bf517b6f870d63bbbcc65a81f99bd968.zip
kconfig: qconf: allow to edit "int", "hex", "string" menus in-place
Previously, when you double-clicked the "int", "hex", or "string" menus, a line-edit gadget showed up to allow you to input the value, which looked clumsy. Also, it was buggy; the editor opened even if the config option was not editable. For example, just try to double-click CC_VERSION_TEXT, which has no prompt. This commit sub-classes QStyleItemDelegate to allow users to edit "int", "hex", "string" menus in-place. Just double-click (or press the F2 key) in the data column. Then, an editor widget is placed on top of the item view. The two methods are overridden: createEditor - process only when the data column is being accessed and the menu is visible. Otherwise, return nullptr to disallow editing. setModelData - take the new data from the editor, and set it to the addressed symbol. If it was successful, update all the list windows. Otherwise, (the reason for the failure is possibly the input data was out of range), set the old value back to the editor. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/kconfig/qconf.h')
-rw-r--r--scripts/kconfig/qconf.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index d01a6c620dbb..b02acf2464ec 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -11,6 +11,7 @@
#include <QPushButton>
#include <QSettings>
#include <QSplitter>
+#include <QStyledItemDelegate>
#include <QTextBrowser>
#include <QTreeWidget>
@@ -172,6 +173,20 @@ public:
static QIcon menuIcon, menubackIcon;
};
+class ConfigItemDelegate : public QStyledItemDelegate
+{
+private:
+ struct menu *menu;
+public:
+ ConfigItemDelegate(QObject *parent = nullptr)
+ : QStyledItemDelegate(parent) {}
+ QWidget *createEditor(QWidget *parent,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override;
+ void setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const override;
+};
+
class ConfigLineEdit : public QLineEdit {
Q_OBJECT
typedef class QLineEdit Parent;