Skip to content

Commit b06c3ec

Browse files
mchehabmasahir0y
authored andcommitted
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 <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent c4f7398 commit b06c3ec

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

scripts/kconfig/qconf.cc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ void ConfigList::setRootMenu(struct menu *menu)
537537
rootEntry = menu;
538538
updateListAll();
539539
if (currentItem()) {
540-
currentItem()->setSelected(hasFocus());
540+
setSelected(currentItem(), hasFocus());
541541
scrollToItem(currentItem());
542542
}
543543
}
@@ -865,7 +865,7 @@ void ConfigList::focusInEvent(QFocusEvent *e)
865865

866866
ConfigItem* item = (ConfigItem *)currentItem();
867867
if (item) {
868-
item->setSelected(true);
868+
setSelected(item, true);
869869
menu = item->menu;
870870
}
871871
emit gotFocus(menu);
@@ -1711,17 +1711,10 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
17111711
if (!parent)
17121712
return;
17131713

1714-
/* Clear an already-selected item */
1715-
if (!configList->selectedItems().isEmpty()) {
1716-
item = (ConfigItem*)configList->selectedItems().first();
1717-
if (item)
1718-
item->setSelected(false);
1719-
}
1720-
17211714
/* Select the config view */
17221715
item = configList->findConfigItem(parent);
17231716
if (item) {
1724-
item->setSelected(true);
1717+
configList->setSelected(item, true);
17251718
configList->scrollToItem(item);
17261719
}
17271720

@@ -1740,7 +1733,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
17401733
if (list) {
17411734
item = list->findConfigItem(menu);
17421735
if (item) {
1743-
item->setSelected(true);
1736+
list->setSelected(item, true);
17441737
list->scrollToItem(item);
17451738
list->setFocus();
17461739
}

scripts/kconfig/qconf.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,17 @@ class ConfigList : public QTreeWidget {
4545
public:
4646
ConfigList(ConfigView* p, const char *name = 0);
4747
void reinit(void);
48+
ConfigItem* findConfigItem(struct menu *);
4849
ConfigView* parent(void) const
4950
{
5051
return (ConfigView*)Parent::parent();
5152
}
52-
ConfigItem* findConfigItem(struct menu *);
53+
void setSelected(QTreeWidgetItem *item, bool enable) {
54+
for (int i = 0; i < selectedItems().size(); i++)
55+
selectedItems().at(i)->setSelected(false);
56+
57+
item->setSelected(enable);
58+
}
5359

5460
protected:
5561
void keyPressEvent(QKeyEvent *e);

0 commit comments

Comments
 (0)