Hi all!

The actual search feature in qconf does not allow to identify the found
options in the main display tree(s): it merely displays the option items
in the search dialog.

This drives me mad every time I try to change the configuration of my
kernel because:

- Simply finding a symbol is usually not enough for me (user) to decide
  if I have to activate the option or not: i need to understand the context
  the option belongs to (but the name and the help text usually does not
  contain enough information for this to happen).

- The dialog also finds hidden options that can't be enabled, possibly
  because the parent is not enabled. This forces me to search the parent by
  browsing manually the whole tree... actually making the search feature
  useless.

The following patch adds a "Go To" button to the search dialog that allows
to find and highlight the selected option in the main tree view effectively
showing its context and parents.

-- 

Szymon Stefanek


diff -ruN linux-2.6.21-rc3.orig/scripts/kconfig/qconf.cc 
linux-2.6.21-rc3/scripts/kconfig/qconf.cc
--- linux-2.6.21-rc3.orig/scripts/kconfig/qconf.cc      2007-03-10 
16:24:20.000000000 +0100
+++ linux-2.6.21-rc3/scripts/kconfig/qconf.cc   2007-03-12 01:07:02.000000000 
+0100
@@ -1197,6 +1197,11 @@
        searchButton->setAutoDefault(FALSE);
        connect(searchButton, SIGNAL(clicked()), SLOT(search()));
        layout2->addWidget(searchButton);
+       gotoButton = new QPushButton("Go To", this);
+       gotoButton->setAutoDefault(FALSE);
+       gotoButton->setEnabled(FALSE);
+       connect(gotoButton, SIGNAL(clicked()), SLOT(gotoOption()));
+       layout2->addWidget(gotoButton);
        layout1->addLayout(layout2);
 
        split = new QSplitter(this);
@@ -1205,7 +1210,7 @@
        list->list->mode = listMode;
        info = new ConfigInfoView(split, name);
        connect(list->list, SIGNAL(menuChanged(struct menu *)),
-               info, SLOT(setInfo(struct menu *)));
+               this,SLOT(menuChanged(struct menu *)));
        layout1->addWidget(split);
 
        if (name) {
@@ -1242,6 +1247,23 @@
        }
 }
 
+void ConfigSearchWindow::menuChanged(struct menu *m)
+{
+       info->setInfo(m);
+       gotoButton->setEnabled(m != NULL);
+}
+
+/**
+ * Handler for the "Go To" button.
+ * The signal is handled by our main window.
+ */
+void ConfigSearchWindow::gotoOption(void)
+{
+       ConfigItem * it = (ConfigItem *)(list->list->selectedItem());
+       if(!it)return;
+       emit gotoMenu(it->menu);
+}
+
 void ConfigSearchWindow::search(void)
 {
        struct symbol **p;
@@ -1260,6 +1282,8 @@
                        lastItem = new ConfigItem(list->list, lastItem, 
prop->menu,
                                                  menu_is_visible(prop->menu));
        }
+       
+       gotoButton->setEnabled(FALSE);
 }
 
 /*
@@ -1467,7 +1491,11 @@
 void ConfigMainWindow::searchConfig(void)
 {
        if (!searchWindow)
+       {
                searchWindow = new ConfigSearchWindow(this, "search");
+               connect(searchWindow,SIGNAL(gotoMenu(struct menu *)),
+                       this,SLOT(gotoMenu(struct menu *)));
+       }
        searchWindow->show();
 }
 
@@ -1622,6 +1650,119 @@
        }
 }
 
+/**
+ * Select an item in its view, open all the parents
+ * and make sure that it is visible.
+ */
+void ConfigMainWindow::selectItem(ConfigItem *it)
+{
+       if(!it)return;
+       ConfigItem * save = it;
+       while(it)
+       {
+               it->listView()->setOpen(it,TRUE);
+               it = (ConfigItem *)(it->parent());
+       }
+       save->listView()->setSelected(save,TRUE);
+       save->listView()->ensureItemVisible(save);
+}
+
+/**
+ * Attempt to find and select the item that contains the menu m
+ * in the subtree originating from "it".
+ */
+bool ConfigMainWindow::selectItemInSubtree(ConfigItem * it,struct menu *m)
+{
+       if(it->menu == m)
+       {
+               selectItem(it);
+               return TRUE;
+       }
+
+       it = it->firstChild();
+       while(it)
+       {
+               if(selectItemInSubtree(it,m))return TRUE;
+               it = it->nextSibling();
+       }
+       return FALSE;
+}
+
+/**
+ * Attempt to find and select the item that contains the menu m
+ */
+void ConfigMainWindow::gotoMenu(struct menu *m)
+{
+       ConfigItem *it;
+       ConfigList *list;
+       struct menu *par;
+
+       if(!m)return;
+
+       if(!menu_is_visible(m))
+       {
+               /**
+                * The user _wants_ to go to a hidden option.
+                * Make sure that the "Show All Options" is activated.
+                */
+               if(!configView->showAll())
+                       configView->setShowAll(TRUE);
+       }
+
+       switch (configList->mode)
+       {
+               case singleMode:
+                       /* single list that changes root */
+                       list = configList;
+                       par = menu_get_parent_menu(m);
+                       if(!par)return;
+                       list->setRootMenu(par);
+               break;
+               case symbolMode:
+                       if(m->flags & MENU_ROOT)
+                       {
+                               list = configList;
+                               list->setRootMenu(m);
+                       } else {
+                               /* find the root parent to be selected in the 
left view */
+                               par = m;
+                               while(par && !(par->flags & MENU_ROOT))
+                                       par = par->parent;
+
+                               if(par)
+                               {
+                                       it = menuList->firstChild();
+                                       while(it)
+                                       {
+                                               
if(selectItemInSubtree(it,par))break;
+                                               it = it->nextSibling();
+                                       }
+                               }
+
+                               /* 
+                                * Now set the right part of the subtree in the 
right view and select our item
+                                * This has to be done _after_ selecting the 
root parent in the left view
+                                */
+                               list = configList;
+                               par = menu_get_parent_menu(m);
+                               if(!par)return;
+                               list->setRootMenu(par);
+                       }
+               break;
+               case fullMode:
+                       /* huge single list with everything inside */
+                       list = configList;
+               break;
+       }
+
+       it = list->firstChild();
+       while(it)
+       {
+               if(selectItemInSubtree(it,m))return;
+               it = it->nextSibling();
+       }
+}
+
 void ConfigMainWindow::showIntro(void)
 {
        static char str[] = "Welcome to the qconf graphical kernel 
configuration tool for Linux.\n\n"
diff -ruN linux-2.6.21-rc3.orig/scripts/kconfig/qconf.h 
linux-2.6.21-rc3/scripts/kconfig/qconf.h
--- linux-2.6.21-rc3.orig/scripts/kconfig/qconf.h       2007-03-10 
16:24:20.000000000 +0100
+++ linux-2.6.21-rc3/scripts/kconfig/qconf.h    2007-03-12 01:07:02.000000000 
+0100
@@ -284,10 +284,15 @@
 public slots:
        void saveSettings(void);
        void search(void);
-
+       void gotoOption(void);
+signals:
+       void gotoMenu(struct menu *m);
+protected slots:
+       void menuChanged(struct menu *m);
 protected:
        QLineEdit* editField;
        QPushButton* searchButton;
+       QPushButton* gotoButton;
        QSplitter* split;
        ConfigView* list;
        ConfigInfoView* info;
@@ -317,9 +322,11 @@
        void showIntro(void);
        void showAbout(void);
        void saveSettings(void);
-
+       void gotoMenu(struct menu *m);
 protected:
        void closeEvent(QCloseEvent *e);
+       void selectItem(ConfigItem *it);
+       bool selectItemInSubtree(ConfigItem * it,struct menu *m);
 
        ConfigSearchWindow *searchWindow;
        ConfigView *menuView;


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel

Reply via email to