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@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
c4f7398bee
commit
b06c3ec3bd
@ -537,7 +537,7 @@ void ConfigList::setRootMenu(struct menu *menu)
|
|||||||
rootEntry = menu;
|
rootEntry = menu;
|
||||||
updateListAll();
|
updateListAll();
|
||||||
if (currentItem()) {
|
if (currentItem()) {
|
||||||
currentItem()->setSelected(hasFocus());
|
setSelected(currentItem(), hasFocus());
|
||||||
scrollToItem(currentItem());
|
scrollToItem(currentItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -865,7 +865,7 @@ void ConfigList::focusInEvent(QFocusEvent *e)
|
|||||||
|
|
||||||
ConfigItem* item = (ConfigItem *)currentItem();
|
ConfigItem* item = (ConfigItem *)currentItem();
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setSelected(true);
|
setSelected(item, true);
|
||||||
menu = item->menu;
|
menu = item->menu;
|
||||||
}
|
}
|
||||||
emit gotFocus(menu);
|
emit gotFocus(menu);
|
||||||
@ -1711,17 +1711,10 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
|
|||||||
if (!parent)
|
if (!parent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Clear an already-selected item */
|
|
||||||
if (!configList->selectedItems().isEmpty()) {
|
|
||||||
item = (ConfigItem*)configList->selectedItems().first();
|
|
||||||
if (item)
|
|
||||||
item->setSelected(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Select the config view */
|
/* Select the config view */
|
||||||
item = configList->findConfigItem(parent);
|
item = configList->findConfigItem(parent);
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setSelected(true);
|
configList->setSelected(item, true);
|
||||||
configList->scrollToItem(item);
|
configList->scrollToItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1740,7 +1733,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
|
|||||||
if (list) {
|
if (list) {
|
||||||
item = list->findConfigItem(menu);
|
item = list->findConfigItem(menu);
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setSelected(true);
|
list->setSelected(item, true);
|
||||||
list->scrollToItem(item);
|
list->scrollToItem(item);
|
||||||
list->setFocus();
|
list->setFocus();
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,17 @@ class ConfigList : public QTreeWidget {
|
|||||||
public:
|
public:
|
||||||
ConfigList(ConfigView* p, const char *name = 0);
|
ConfigList(ConfigView* p, const char *name = 0);
|
||||||
void reinit(void);
|
void reinit(void);
|
||||||
|
ConfigItem* findConfigItem(struct menu *);
|
||||||
ConfigView* parent(void) const
|
ConfigView* parent(void) const
|
||||||
{
|
{
|
||||||
return (ConfigView*)Parent::parent();
|
return (ConfigView*)Parent::parent();
|
||||||
}
|
}
|
||||||
ConfigItem* findConfigItem(struct menu *);
|
void setSelected(QTreeWidgetItem *item, bool enable) {
|
||||||
|
for (int i = 0; i < selectedItems().size(); i++)
|
||||||
|
selectedItems().at(i)->setSelected(false);
|
||||||
|
|
||||||
|
item->setSelected(enable);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *e);
|
void keyPressEvent(QKeyEvent *e);
|
||||||
|
Loading…
Reference in New Issue
Block a user