Commit af737b4d authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Masahiro Yamada

kconfig: qconf: simplify the goBack() logic

The goBack() logic is used only for the configList, as
it only makes sense on singleMode. So, let's simplify the
code.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent b06c3ec3
...@@ -1455,18 +1455,22 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1455,18 +1455,22 @@ ConfigMainWindow::ConfigMainWindow(void)
addToolBar(toolBar); addToolBar(toolBar);
backAction = new QAction(QPixmap(xpm_back), "Back", this); backAction = new QAction(QPixmap(xpm_back), "Back", this);
connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack())); connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack()));
backAction->setEnabled(false);
QAction *quitAction = new QAction("&Quit", this); QAction *quitAction = new QAction("&Quit", this);
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); connect(quitAction, SIGNAL(triggered(bool)), SLOT(close()));
QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this);
loadAction->setShortcut(Qt::CTRL + Qt::Key_L); loadAction->setShortcut(Qt::CTRL + Qt::Key_L);
connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig()));
saveAction = new QAction(QPixmap(xpm_save), "&Save", this); saveAction = new QAction(QPixmap(xpm_save), "&Save", this);
saveAction->setShortcut(Qt::CTRL + Qt::Key_S); saveAction->setShortcut(Qt::CTRL + Qt::Key_S);
connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig()));
conf_set_changed_callback(conf_changed); conf_set_changed_callback(conf_changed);
// Set saveAction's initial state // Set saveAction's initial state
conf_changed(); conf_changed();
configname = xstrdup(conf_get_configname()); configname = xstrdup(conf_get_configname());
...@@ -1667,21 +1671,11 @@ void ConfigMainWindow::searchConfig(void) ...@@ -1667,21 +1671,11 @@ void ConfigMainWindow::searchConfig(void)
void ConfigMainWindow::changeItens(struct menu *menu) void ConfigMainWindow::changeItens(struct menu *menu)
{ {
configList->setRootMenu(menu); configList->setRootMenu(menu);
if (configList->rootEntry->parent == &rootmenu)
backAction->setEnabled(false);
else
backAction->setEnabled(true);
} }
void ConfigMainWindow::changeMenu(struct menu *menu) void ConfigMainWindow::changeMenu(struct menu *menu)
{ {
menuList->setRootMenu(menu); menuList->setRootMenu(menu);
if (menuList->rootEntry->parent == &rootmenu)
backAction->setEnabled(false);
else
backAction->setEnabled(true);
} }
void ConfigMainWindow::setMenuLink(struct menu *menu) void ConfigMainWindow::setMenuLink(struct menu *menu)
...@@ -1748,25 +1742,11 @@ void ConfigMainWindow::listFocusChanged(void) ...@@ -1748,25 +1742,11 @@ void ConfigMainWindow::listFocusChanged(void)
void ConfigMainWindow::goBack(void) void ConfigMainWindow::goBack(void)
{ {
ConfigItem* item, *oldSelection; qInfo() << __FUNCTION__;
configList->setParentMenu();
if (configList->rootEntry == &rootmenu) if (configList->rootEntry == &rootmenu)
backAction->setEnabled(false);
if (menuList->selectedItems().count() == 0)
return; return;
item = (ConfigItem*)menuList->selectedItems().first(); configList->setParentMenu();
oldSelection = item;
while (item) {
if (item->menu == configList->rootEntry) {
oldSelection->setSelected(false);
item->setSelected(true);
break;
}
item = (ConfigItem*)item->parent();
}
} }
void ConfigMainWindow::showSingleView(void) void ConfigMainWindow::showSingleView(void)
...@@ -1778,6 +1758,8 @@ void ConfigMainWindow::showSingleView(void) ...@@ -1778,6 +1758,8 @@ void ConfigMainWindow::showSingleView(void)
fullViewAction->setEnabled(true); fullViewAction->setEnabled(true);
fullViewAction->setChecked(false); fullViewAction->setChecked(false);
backAction->setEnabled(true);
menuView->hide(); menuView->hide();
menuList->setRootMenu(0); menuList->setRootMenu(0);
configList->mode = singleMode; configList->mode = singleMode;
...@@ -1797,6 +1779,8 @@ void ConfigMainWindow::showSplitView(void) ...@@ -1797,6 +1779,8 @@ void ConfigMainWindow::showSplitView(void)
fullViewAction->setEnabled(true); fullViewAction->setEnabled(true);
fullViewAction->setChecked(false); fullViewAction->setChecked(false);
backAction->setEnabled(false);
configList->mode = menuMode; configList->mode = menuMode;
if (configList->rootEntry == &rootmenu) if (configList->rootEntry == &rootmenu)
configList->updateListAll(); configList->updateListAll();
...@@ -1820,6 +1804,8 @@ void ConfigMainWindow::showFullView(void) ...@@ -1820,6 +1804,8 @@ void ConfigMainWindow::showFullView(void)
fullViewAction->setEnabled(false); fullViewAction->setEnabled(false);
fullViewAction->setChecked(true); fullViewAction->setChecked(true);
backAction->setEnabled(false);
menuView->hide(); menuView->hide();
menuList->setRootMenu(0); menuList->setRootMenu(0);
configList->mode = fullMode; configList->mode = fullMode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment