softlockup: s/99/MAX_RT_PRIO/
[safe/jmp/linux-2.6] / scripts / kconfig / qconf.cc
index f3f86e7..f2a23a9 100644 (file)
@@ -38,6 +38,8 @@
 static QApplication *configApp;
 static ConfigSettings *configSettings;
 
+QAction *ConfigMainWindow::saveAction;
+
 static inline QString qgettext(const char* str)
 {
        return QString::fromLocal8Bit(gettext(str));
@@ -87,6 +89,7 @@ void ConfigItem::okRename(int col)
 {
        Parent::okRename(col);
        sym_set_string_value(menu->sym, text(dataColIdx).latin1());
+       listView()->updateList(this);
 }
 #endif
 
@@ -381,6 +384,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)
 {
        struct menu *menu;
@@ -524,6 +539,7 @@ void ConfigList::setRootMenu(struct menu *menu)
        rootEntry = menu;
        updateListAll();
        setSelected(currentItem(), hasFocus());
+       ensureItemVisible(currentItem());
 }
 
 void ConfigList::setParentMenu(void)
@@ -590,6 +606,8 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
 
                visible = menu_is_visible(child);
                if (showAll || visible) {
+                       if (!child->sym && !child->list && !child->prompt)
+                               continue;
                        if (!item || item->menu != child)
                                item = new ConfigItem(parent, last, child, visible);
                        else
@@ -766,14 +784,16 @@ skip:
 
 void ConfigList::focusInEvent(QFocusEvent *e)
 {
-       Parent::focusInEvent(e);
+       struct menu *menu = NULL;
 
-       QListViewItem* item = currentItem();
-       if (!item)
-               return;
+       Parent::focusInEvent(e);
 
-       setSelected(item, TRUE);
-       emit gotFocus();
+       ConfigItem* item = (ConfigItem *)currentItem();
+       if (item) {
+               setSelected(item, TRUE);
+               menu = item->menu;
+       }
+       emit gotFocus(menu);
 }
 
 void ConfigList::contextMenuEvent(QContextMenuEvent *e)
@@ -783,7 +803,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                        QAction *action;
 
                        headerPopup = new QPopupMenu(this);
-                       action = new QAction("Show Name", 0, this);
+                       action = new QAction(NULL, "Show Name", 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowName(bool)));
@@ -791,7 +811,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                                  action, SLOT(setOn(bool)));
                          action->setOn(showName);
                          action->addTo(headerPopup);
-                       action = new QAction("Show Range", 0, this);
+                       action = new QAction(NULL, "Show Range", 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowRange(bool)));
@@ -799,7 +819,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                                  action, SLOT(setOn(bool)));
                          action->setOn(showRange);
                          action->addTo(headerPopup);
-                       action = new QAction("Show Data", 0, this);
+                       action = new QAction(NULL, "Show Data", 0, this);
                          action->setToggleAction(TRUE);
                          connect(action, SIGNAL(toggled(bool)),
                                  parent(), SLOT(setShowData(bool)));
@@ -900,7 +920,7 @@ void ConfigView::updateListAll(void)
 }
 
 ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
-       : Parent(parent, name), menu(0)
+       : Parent(parent, name), menu(0), sym(0)
 {
        if (name) {
                configSettings->beginGroup(name);
@@ -925,13 +945,18 @@ void ConfigInfoView::setShowDebug(bool b)
                _showDebug = b;
                if (menu)
                        menuInfo();
+               else if (sym)
+                       symbolInfo();
                emit showDebugChanged(b);
        }
 }
 
 void ConfigInfoView::setInfo(struct menu *m)
 {
+       if (menu == m)
+               return;
        menu = m;
+       sym = NULL;
        if (!menu)
                clear();
        else
@@ -943,15 +968,45 @@ void ConfigInfoView::setSource(const QString& name)
        const char *p = name.latin1();
 
        menu = NULL;
+       sym = NULL;
 
        switch (p[0]) {
        case 'm':
-               if (sscanf(p, "m%p", &menu) == 1)
+               struct menu *m;
+
+               if (sscanf(p, "m%p", &m) == 1 && menu != m) {
+                       menu = m;
                        menuInfo();
+                       emit menuSelected(menu);
+               }
+               break;
+       case 's':
+               struct symbol *s;
+
+               if (sscanf(p, "s%p", &s) == 1 && sym != s) {
+                       sym = s;
+                       symbolInfo();
+               }
                break;
        }
 }
 
+void ConfigInfoView::symbolInfo(void)
+{
+       QString str;
+
+       str += "<big>Symbol: <b>";
+       str += print_filter(sym->name);
+       str += "</b></big><br><br>value: ";
+       str += print_filter(sym_get_string_value(sym));
+       str += "<br>visibility: ";
+       str += sym->visible == yes ? "y" : sym->visible == mod ? "m" : "n";
+       str += "<br>";
+       str += debug_info(sym);
+
+       setText(str);
+}
+
 void ConfigInfoView::menuInfo(void)
 {
        struct symbol* sym;
@@ -965,12 +1020,20 @@ void ConfigInfoView::menuInfo(void)
                        head += "</b></big>";
                        if (sym->name) {
                                head += " (";
+                               if (showDebug())
+                                       head += QString().sprintf("<a href=\"s%p\">", sym);
                                head += print_filter(sym->name);
+                               if (showDebug())
+                                       head += "</a>";
                                head += ")";
                        }
                } else if (sym->name) {
                        head += "<big><b>";
+                       if (showDebug())
+                               head += QString().sprintf("<a href=\"s%p\">", sym);
                        head += print_filter(sym->name);
+                       if (showDebug())
+                               head += "</a>";
                        head += "</b></big>";
                }
                head += "<br><br>";
@@ -1015,9 +1078,9 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
                switch (prop->type) {
                case P_PROMPT:
                case P_MENU:
-                       debug += "prompt: ";
+                       debug += QString().sprintf("prompt: <a href=\"m%p\">", prop->menu);
                        debug += print_filter(_(prop->text));
-                       debug += "<br>";
+                       debug += "</a><br>";
                        break;
                case P_DEFAULT:
                        debug += "default: ";
@@ -1088,15 +1151,23 @@ QString ConfigInfoView::print_filter(const QString &str)
        return res;
 }
 
-void ConfigInfoView::expr_print_help(void *data, const char *str)
+void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
 {
-       reinterpret_cast<QString*>(data)->append(print_filter(str));
+       QString* text = reinterpret_cast<QString*>(data);
+       QString str2 = print_filter(str);
+
+       if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
+               *text += QString().sprintf("<a href=\"s%p\">", sym);
+               *text += str2;
+               *text += "</a>";
+       } else
+               *text += str2;
 }
 
 QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
 {
        QPopupMenu* popup = Parent::createPopupMenu(pos);
-       QAction* action = new QAction("Show Debug Info", 0, popup);
+       QAction* action = new QAction(NULL,"Show Debug Info", 0, popup);
          action->setToggleAction(TRUE);
          connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
          connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
@@ -1111,7 +1182,7 @@ void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e)
        Parent::contentsContextMenuEvent(e);
 }
 
-ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name)
+ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name)
        : Parent(parent, name), result(NULL)
 {
        setCaption("Search Config");
@@ -1135,6 +1206,9 @@ ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name)
        info = new ConfigInfoView(split, name);
        connect(list->list, SIGNAL(menuChanged(struct menu *)),
                info, SLOT(setInfo(struct menu *)));
+       connect(list->list, SIGNAL(menuChanged(struct menu *)),
+               parent, SLOT(setMenuLink(struct menu *)));
+
        layout1->addWidget(split);
 
        if (name) {
@@ -1179,6 +1253,7 @@ void ConfigSearchWindow::search(void)
 
        free(result);
        list->list->clear();
+       info->clear();
 
        result = sym_re_search(editField->text().latin1());
        if (!result)
@@ -1194,6 +1269,7 @@ void ConfigSearchWindow::search(void)
  * Construct the complete config widget
  */
 ConfigMainWindow::ConfigMainWindow(void)
+       : searchWindow(0)
 {
        QMenuBar* menu;
        bool ok;
@@ -1240,11 +1316,14 @@ ConfigMainWindow::ConfigMainWindow(void)
          connect(quitAction, SIGNAL(activated()), SLOT(close()));
        QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
          connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
-       QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
+       saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
          connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
+       conf_set_changed_callback(conf_changed);
+       // Set saveAction's initial state
+       conf_changed();
        QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
          connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
-       QAction *searchAction = new QAction("Search", "&Search", CTRL+Key_F, this);
+       QAction *searchAction = new QAction("Find", "&Find", CTRL+Key_F, this);
          connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
        QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
          connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
@@ -1301,10 +1380,13 @@ ConfigMainWindow::ConfigMainWindow(void)
        saveAction->addTo(config);
        saveAsAction->addTo(config);
        config->insertSeparator();
-       searchAction->addTo(config);
-       config->insertSeparator();
        quitAction->addTo(config);
 
+       // create edit menu
+       QPopupMenu* editMenu = new QPopupMenu(this);
+       menu->insertItem("&Edit", editMenu);
+       searchAction->addTo(editMenu);
+
        // create options menu
        QPopupMenu* optionMenu = new QPopupMenu(this);
        menu->insertItem("&Option", optionMenu);
@@ -1333,10 +1415,14 @@ ConfigMainWindow::ConfigMainWindow(void)
        connect(menuList, SIGNAL(menuSelected(struct menu *)),
                SLOT(changeMenu(struct menu *)));
 
-       connect(configList, SIGNAL(gotFocus(void)),
-               SLOT(listFocusChanged(void)));
-       connect(menuList, SIGNAL(gotFocus(void)),
+       connect(configList, SIGNAL(gotFocus(struct menu *)),
+               helpText, SLOT(setInfo(struct menu *)));
+       connect(menuList, SIGNAL(gotFocus(struct menu *)),
+               helpText, SLOT(setInfo(struct menu *)));
+       connect(menuList, SIGNAL(gotFocus(struct menu *)),
                SLOT(listFocusChanged(void)));
+       connect(helpText, SIGNAL(menuSelected(struct menu *)),
+               SLOT(setMenuLink(struct menu *)));
 
        QString listMode = configSettings->readEntry("/listMode", "symbol");
        if (listMode == "single")
@@ -1356,18 +1442,6 @@ ConfigMainWindow::ConfigMainWindow(void)
                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)
 {
        QString s = QFileDialog::getOpenFileName(".config", NULL, this);
@@ -1403,20 +1477,68 @@ void ConfigMainWindow::searchConfig(void)
 void ConfigMainWindow::changeMenu(struct menu *menu)
 {
        configList->setRootMenu(menu);
-       backAction->setEnabled(TRUE);
+       if (configList->rootEntry->parent == &rootmenu)
+               backAction->setEnabled(FALSE);
+       else
+               backAction->setEnabled(TRUE);
 }
 
-void ConfigMainWindow::listFocusChanged(void)
+void ConfigMainWindow::setMenuLink(struct menu *menu)
 {
-       if (menuList->hasFocus()) {
-               if (menuList->mode == menuMode)
+       struct menu *parent;
+       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();
-               setHelp(menuList->selectedItem());
-       } else if (configList->hasFocus()) {
-               setHelp(configList->selectedItem());
+                       list = menuList;
+               } else {
+                       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)
 {
        ConfigItem* item;
@@ -1482,7 +1604,7 @@ void ConfigMainWindow::showFullView(void)
  */
 void ConfigMainWindow::closeEvent(QCloseEvent* e)
 {
-       if (!sym_change_count) {
+       if (!conf_get_changed()) {
                e->accept();
                return;
        }
@@ -1555,6 +1677,12 @@ void ConfigMainWindow::saveSettings(void)
        configSettings->writeSizes("/split2", split2->sizes());
 }
 
+void ConfigMainWindow::conf_changed(void)
+{
+       if (saveAction)
+               saveAction->setEnabled(conf_get_changed());
+}
+
 void fixup_rootmenu(struct menu *menu)
 {
        struct menu *child;