Commit b65a47e1 authored by Roman Zippel's avatar Roman Zippel Committed by Sam Ravnborg

kconfig: jump to linked menu prompt

If clicking on of the links, which leads to a visible prompt, jump to it in
the symbol list.
Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent ab45d190
...@@ -381,6 +381,18 @@ void ConfigList::saveSettings(void) ...@@ -381,6 +381,18 @@ void ConfigList::saveSettings(void)
} }
} }
ConfigItem* ConfigList::findConfigItem(struct menu *menu)
{
ConfigItem* item = (ConfigItem*)menu->data;
for (; item; item = item->nextItem) {
if (this == item->listView())
break;
}
return item;
}
void ConfigList::updateSelection(void) void ConfigList::updateSelection(void)
{ {
struct menu *menu; struct menu *menu;
...@@ -524,6 +536,7 @@ void ConfigList::setRootMenu(struct menu *menu) ...@@ -524,6 +536,7 @@ void ConfigList::setRootMenu(struct menu *menu)
rootEntry = menu; rootEntry = menu;
updateListAll(); updateListAll();
setSelected(currentItem(), hasFocus()); setSelected(currentItem(), hasFocus());
ensureItemVisible(currentItem());
} }
void ConfigList::setParentMenu(void) void ConfigList::setParentMenu(void)
...@@ -766,14 +779,16 @@ skip: ...@@ -766,14 +779,16 @@ skip:
void ConfigList::focusInEvent(QFocusEvent *e) void ConfigList::focusInEvent(QFocusEvent *e)
{ {
Parent::focusInEvent(e); struct menu *menu = NULL;
QListViewItem* item = currentItem(); Parent::focusInEvent(e);
if (!item)
return;
setSelected(item, TRUE); ConfigItem* item = (ConfigItem *)currentItem();
emit gotFocus(); if (item) {
setSelected(item, TRUE);
menu = item->menu;
}
emit gotFocus(menu);
} }
void ConfigList::contextMenuEvent(QContextMenuEvent *e) void ConfigList::contextMenuEvent(QContextMenuEvent *e)
...@@ -933,6 +948,8 @@ void ConfigInfoView::setShowDebug(bool b) ...@@ -933,6 +948,8 @@ void ConfigInfoView::setShowDebug(bool b)
void ConfigInfoView::setInfo(struct menu *m) void ConfigInfoView::setInfo(struct menu *m)
{ {
if (menu == m)
return;
menu = m; menu = m;
if (!menu) if (!menu)
clear(); clear();
...@@ -954,6 +971,7 @@ void ConfigInfoView::setSource(const QString& name) ...@@ -954,6 +971,7 @@ void ConfigInfoView::setSource(const QString& name)
if (sscanf(p, "m%p", &m) == 1 && menu != m) { if (sscanf(p, "m%p", &m) == 1 && menu != m) {
menu = m; menu = m;
menuInfo(); menuInfo();
emit menuSelected(menu);
} }
break; break;
case 's': case 's':
...@@ -1380,10 +1398,14 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1380,10 +1398,14 @@ ConfigMainWindow::ConfigMainWindow(void)
connect(menuList, SIGNAL(menuSelected(struct menu *)), connect(menuList, SIGNAL(menuSelected(struct menu *)),
SLOT(changeMenu(struct menu *))); SLOT(changeMenu(struct menu *)));
connect(configList, SIGNAL(gotFocus(void)), connect(configList, SIGNAL(gotFocus(struct menu *)),
SLOT(listFocusChanged(void))); helpText, SLOT(setInfo(struct menu *)));
connect(menuList, SIGNAL(gotFocus(void)), connect(menuList, SIGNAL(gotFocus(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(menuList, SIGNAL(gotFocus(struct menu *)),
SLOT(listFocusChanged(void))); SLOT(listFocusChanged(void)));
connect(helpText, SIGNAL(menuSelected(struct menu *)),
SLOT(setMenuLink(struct menu *)));
QString listMode = configSettings->readEntry("/listMode", "symbol"); QString listMode = configSettings->readEntry("/listMode", "symbol");
if (listMode == "single") if (listMode == "single")
...@@ -1403,18 +1425,6 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1403,18 +1425,6 @@ ConfigMainWindow::ConfigMainWindow(void)
split2->setSizes(sizes); split2->setSizes(sizes);
} }
/*
* display a new help entry as soon as a new menu entry is selected
*/
void ConfigMainWindow::setHelp(QListViewItem* item)
{
struct menu* menu = 0;
if (item)
menu = ((ConfigItem*)item)->menu;
helpText->setInfo(menu);
}
void ConfigMainWindow::loadConfig(void) void ConfigMainWindow::loadConfig(void)
{ {
QString s = QFileDialog::getOpenFileName(".config", NULL, this); QString s = QFileDialog::getOpenFileName(".config", NULL, this);
...@@ -1453,17 +1463,62 @@ void ConfigMainWindow::changeMenu(struct menu *menu) ...@@ -1453,17 +1463,62 @@ void ConfigMainWindow::changeMenu(struct menu *menu)
backAction->setEnabled(TRUE); backAction->setEnabled(TRUE);
} }
void ConfigMainWindow::listFocusChanged(void) void ConfigMainWindow::setMenuLink(struct menu *menu)
{ {
if (menuList->hasFocus()) { struct menu *parent;
if (menuList->mode == menuMode) ConfigList* list = NULL;
ConfigItem* item;
if (!menu_is_visible(menu) && !configView->showAll())
return;
switch (configList->mode) {
case singleMode:
list = configList;
parent = menu_get_parent_menu(menu);
if (!parent)
return;
list->setRootMenu(parent);
break;
case symbolMode:
if (menu->flags & MENU_ROOT) {
configList->setRootMenu(menu);
configList->clearSelection(); configList->clearSelection();
setHelp(menuList->selectedItem()); list = menuList;
} else if (configList->hasFocus()) { } else {
setHelp(configList->selectedItem()); list = configList;
parent = menu_get_parent_menu(menu->parent);
if (!parent)
return;
item = menuList->findConfigItem(parent);
if (item) {
menuList->setSelected(item, TRUE);
menuList->ensureItemVisible(item);
}
list->setRootMenu(parent);
}
break;
case fullMode:
list = configList;
break;
}
if (list) {
item = list->findConfigItem(menu);
if (item) {
list->setSelected(item, TRUE);
list->ensureItemVisible(item);
list->setFocus();
}
} }
} }
void ConfigMainWindow::listFocusChanged(void)
{
if (menuList->mode == menuMode)
configList->clearSelection();
}
void ConfigMainWindow::goBack(void) void ConfigMainWindow::goBack(void)
{ {
ConfigItem* item; ConfigItem* item;
......
...@@ -55,6 +55,7 @@ class ConfigList : public QListView { ...@@ -55,6 +55,7 @@ class ConfigList : public QListView {
{ {
return (ConfigView*)Parent::parent(); return (ConfigView*)Parent::parent();
} }
ConfigItem* findConfigItem(struct menu *);
protected: protected:
void keyPressEvent(QKeyEvent *e); void keyPressEvent(QKeyEvent *e);
...@@ -77,7 +78,7 @@ public slots: ...@@ -77,7 +78,7 @@ public slots:
void menuChanged(struct menu *menu); void menuChanged(struct menu *menu);
void menuSelected(struct menu *menu); void menuSelected(struct menu *menu);
void parentSelected(void); void parentSelected(void);
void gotFocus(void); void gotFocus(struct menu *);
public: public:
void updateListAll(void) void updateListAll(void)
...@@ -258,6 +259,7 @@ public slots: ...@@ -258,6 +259,7 @@ public slots:
signals: signals:
void showDebugChanged(bool); void showDebugChanged(bool);
void menuSelected(struct menu *);
protected: protected:
void symbolInfo(void); void symbolInfo(void);
...@@ -298,8 +300,8 @@ class ConfigMainWindow : public QMainWindow { ...@@ -298,8 +300,8 @@ class ConfigMainWindow : public QMainWindow {
public: public:
ConfigMainWindow(void); ConfigMainWindow(void);
public slots: public slots:
void setHelp(QListViewItem* item);
void changeMenu(struct menu *); void changeMenu(struct menu *);
void setMenuLink(struct menu *);
void listFocusChanged(void); void listFocusChanged(void);
void goBack(void); void goBack(void);
void loadConfig(void); void loadConfig(void);
......
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