[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7778611fde57d3e221cc1ed077c7b78bedb3cbd7.1593428163.git.mchehab+huawei@kernel.org>
Date: Mon, 29 Jun 2020 12:57:45 +0200
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Masahiro Yamada <masahiroy@...nel.org>,
linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] kconfig: qconf: re-implement setSelected()
The default implementation for setSelected() at QTreeWidgetItem
allows multiple items to be selected.
Well, this should never be possible for the configItem lists.
So, implement a function that will automatically clean any
previous selection. This simplifies the logic somewhat, while
making the selection logic to be applied atomically, avoiding
future issues on that.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
---
This is a followup patch after the series I sent previously.
I noticed that there are still some situations where it might be
possible to have multiple lines selected at the config lists.
This patch addresses it on a different way, ensuring that it shouldn't
be possible anymore to have more than one lines selected.
scripts/kconfig/qconf.cc | 22 ++++------------------
scripts/kconfig/qconf.h | 14 ++++++++++----
2 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index d8870b15a178..0ba373a3cdd4 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -537,7 +537,7 @@ void ConfigList::setRootMenu(struct menu *menu)
rootEntry = menu;
updateListAll();
if (currentItem()) {
- currentItem()->setSelected(hasFocus());
+ setSelected(currentItem(), hasFocus());
scrollToItem(currentItem());
}
}
@@ -865,7 +865,7 @@ void ConfigList::focusInEvent(QFocusEvent *e)
ConfigItem* item = (ConfigItem *)currentItem();
if (item) {
- item->setSelected(true);
+ setSelected(item, true);
menu = item->menu;
}
emit gotFocus(menu);
@@ -1696,17 +1696,10 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
if (!parent)
return;
- /* Clear an already-selected item */
- if (!configList->selectedItems().isEmpty()) {
- item = (ConfigItem*)configList->selectedItems().first();
- if (item)
- item->setSelected(false);
- }
-
/* Select the config view */
item = configList->findConfigItem(parent);
if (item) {
- item->setSelected(true);
+ configList->setSelected(item, true);
configList->scrollToItem(item);
}
@@ -1723,16 +1716,9 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
}
if (list) {
- /* Clear an already-selected item */
- if (!list->selectedItems().isEmpty()) {
- item = (ConfigItem*)list->selectedItems().first();
- if (item)
- item->setSelected(false);
- }
-
item = list->findConfigItem(menu);
if (item) {
- item->setSelected(true);
+ list->setSelected(item, true);
list->scrollToItem(item);
list->setFocus();
helpText->setInfo(menu);
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index a193137f2314..fb9e9729266f 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -45,11 +45,17 @@ class ConfigList : public QTreeWidget {
public:
ConfigList(ConfigView* p, const char *name = 0);
void reinit(void);
- ConfigView* parent(void) const
- {
- return (ConfigView*)Parent::parent();
- }
ConfigItem* findConfigItem(struct menu *);
+ ConfigView* parent(void) const
+ {
+ return (ConfigView*)Parent::parent();
+ }
+ void setSelected(QTreeWidgetItem *item, bool enable) {
+ for (int i = 0; i < selectedItems().size(); i++)
+ selectedItems().at(i)->setSelected(false);
+
+ item->setSelected(enable);
+ }
protected:
void keyPressEvent(QKeyEvent *e);
--
2.26.2
Powered by blists - more mailing lists