kconfig: Add search option for xconfig

Implement a simple search request for xconfig.  Currently the capabilities are
rather simple (the same as menuconfig).

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
This commit is contained in:
Roman Zippel 2006-06-08 22:12:45 -07:00 committed by Sam Ravnborg
parent face4374e2
commit 43bf612af2
2 changed files with 333 additions and 172 deletions

View file

@ -6,16 +6,20 @@
#include <qapplication.h>
#include <qmainwindow.h>
#include <qtoolbar.h>
#include <qlayout.h>
#include <qvbox.h>
#include <qsplitter.h>
#include <qlistview.h>
#include <qtextview.h>
#include <qtextbrowser.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qmenubar.h>
#include <qmessagebox.h>
#include <qaction.h>
#include <qheader.h>
#include <qfiledialog.h>
#include <qdragobject.h>
#include <qregexp.h>
#include <stdlib.h>
@ -355,6 +359,12 @@ ConfigItem::~ConfigItem(void)
}
}
ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
: Parent(parent)
{
connect(this, SIGNAL(lostFocus()), SLOT(hide()));
}
void ConfigLineEdit::show(ConfigItem* i)
{
item = i;
@ -385,8 +395,8 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
hide();
}
ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv, ConfigSettings* configSettings)
: Parent(p), cview(cv),
ConfigList::ConfigList(ConfigView* p, ConfigSettings* configSettings)
: Parent(p),
updateAll(false),
symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
@ -450,9 +460,8 @@ void ConfigList::updateSelection(void)
if (!item)
return;
cview->setHelp(item);
menu = item->menu;
emit menuChanged(menu);
if (!menu)
return;
type = menu->prompt ? menu->prompt->type : P_UNKNOWN;
@ -464,8 +473,20 @@ void ConfigList::updateList(ConfigItem* item)
{
ConfigItem* last = 0;
if (!rootEntry)
if (!rootEntry) {
if (mode != listMode)
goto update;
QListViewItemIterator it(this);
ConfigItem* item;
for (; it.current(); ++it) {
item = (ConfigItem*)it.current();
if (!item->menu)
continue;
item->testUpdateMenu(menu_is_visible(item->menu));
}
return;
}
if (rootEntry != &rootmenu && (mode == singleMode ||
(mode == symbolMode && rootEntry->parent != &rootmenu))) {
@ -610,7 +631,7 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
struct menu *menu;
enum prop_type type;
if (ev->key() == Key_Escape && mode != fullMode) {
if (ev->key() == Key_Escape && mode != fullMode && mode != listMode) {
emit parentSelected();
ev->accept();
return;
@ -767,11 +788,10 @@ void ConfigList::focusInEvent(QFocusEvent *e)
ConfigView* ConfigView::viewList;
ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview,
ConfigSettings *configSettings)
ConfigView::ConfigView(QWidget* parent, ConfigSettings *configSettings)
: Parent(parent)
{
list = new ConfigList(this, cview, configSettings);
list = new ConfigList(this, configSettings);
lineEdit = new ConfigLineEdit(this);
lineEdit->hide();
@ -807,230 +827,49 @@ void ConfigView::updateListAll(void)
v->list->updateListAll();
}
/*
* Construct the complete config widget
*/
ConfigMainWindow::ConfigMainWindow(void)
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
: Parent(parent, name), menu(0)
{
QMenuBar* menu;
bool ok;
int x, y, width, height;
QWidget *d = configApp->desktop();
ConfigSettings* configSettings = new ConfigSettings();
#if QT_VERSION >= 300
width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64);
height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64);
resize(width, height);
x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok);
if (ok)
y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok);
if (ok)
move(x, y);
showDebug = configSettings->readBoolEntry("/kconfig/qconf/showDebug", false);
// read list settings into configSettings, will be used later for ConfigList setup
configSettings->readListSettings();
#else
width = d->width() - 64;
height = d->height() - 64;
resize(width, height);
showDebug = false;
#endif
split1 = new QSplitter(this);
split1->setOrientation(QSplitter::Horizontal);
setCentralWidget(split1);
menuView = new ConfigView(split1, this, configSettings);
menuList = menuView->list;
split2 = new QSplitter(split1);
split2->setOrientation(QSplitter::Vertical);
// create config tree
configView = new ConfigView(split2, this, configSettings);
configList = configView->list;
helpText = new QTextView(split2);
helpText->setTextFormat(Qt::RichText);
setTabOrder(configList, helpText);
configList->setFocus();
menu = menuBar();
toolBar = new QToolBar("Tools", this);
backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
connect(backAction, SIGNAL(activated()), SLOT(goBack()));
backAction->setEnabled(FALSE);
QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
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);
connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
showNameAction->setToggleAction(TRUE);
showNameAction->setOn(configList->showName);
connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool)));
QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
showRangeAction->setToggleAction(TRUE);
showRangeAction->setOn(configList->showRange);
connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool)));
QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
showDataAction->setToggleAction(TRUE);
showDataAction->setOn(configList->showData);
connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool)));
QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
showAllAction->setToggleAction(TRUE);
showAllAction->setOn(configList->showAll);
connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));
QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
showDebugAction->setToggleAction(TRUE);
showDebugAction->setOn(showDebug);
connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
QAction *showAboutAction = new QAction(NULL, "About", 0, this);
connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
// init tool bar
backAction->addTo(toolBar);
toolBar->addSeparator();
loadAction->addTo(toolBar);
saveAction->addTo(toolBar);
toolBar->addSeparator();
singleViewAction->addTo(toolBar);
splitViewAction->addTo(toolBar);
fullViewAction->addTo(toolBar);
// create config menu
QPopupMenu* config = new QPopupMenu(this);
menu->insertItem("&File", config);
loadAction->addTo(config);
saveAction->addTo(config);
saveAsAction->addTo(config);
config->insertSeparator();
quitAction->addTo(config);
// create options menu
QPopupMenu* optionMenu = new QPopupMenu(this);
menu->insertItem("&Option", optionMenu);
showNameAction->addTo(optionMenu);
showRangeAction->addTo(optionMenu);
showDataAction->addTo(optionMenu);
optionMenu->insertSeparator();
showAllAction->addTo(optionMenu);
showDebugAction->addTo(optionMenu);
// create help menu
QPopupMenu* helpMenu = new QPopupMenu(this);
menu->insertSeparator();
menu->insertItem("&Help", helpMenu);
showIntroAction->addTo(helpMenu);
showAboutAction->addTo(helpMenu);
connect(configList, SIGNAL(menuSelected(struct menu *)),
SLOT(changeMenu(struct menu *)));
connect(configList, SIGNAL(parentSelected()),
SLOT(goBack()));
connect(menuList, SIGNAL(menuSelected(struct menu *)),
SLOT(changeMenu(struct menu *)));
connect(configList, SIGNAL(gotFocus(void)),
SLOT(listFocusChanged(void)));
connect(menuList, SIGNAL(gotFocus(void)),
SLOT(listFocusChanged(void)));
#if QT_VERSION >= 300
QString listMode = configSettings->readEntry("/kconfig/qconf/listMode", "symbol");
if (listMode == "single")
showSingleView();
else if (listMode == "full")
showFullView();
else /*if (listMode == "split")*/
showSplitView();
// UI setup done, restore splitter positions
QValueList<int> sizes = configSettings->readSizes("/kconfig/qconf/split1", &ok);
if (ok)
split1->setSizes(sizes);
sizes = configSettings->readSizes("/kconfig/qconf/split2", &ok);
if (ok)
split2->setSizes(sizes);
#else
showSplitView();
#endif
delete configSettings;
}
static QString print_filter(const QString &str)
void ConfigInfoView::setShowDebug(bool b)
{
QRegExp re("[<>&\"\\n]");
QString res = str;
for (int i = 0; (i = res.find(re, i)) >= 0;) {
switch (res[i].latin1()) {
case '<':
res.replace(i, 1, "&lt;");
i += 4;
break;
case '>':
res.replace(i, 1, "&gt;");
i += 4;
break;
case '&':
res.replace(i, 1, "&amp;");
i += 5;
break;
case '"':
res.replace(i, 1, "&quot;");
i += 6;
break;
case '\n':
res.replace(i, 1, "<br>");
i += 4;
if (_showDebug != b) {
_showDebug = b;
if (menu)
menuInfo();
emit showDebugChanged(b);
}
}
void ConfigInfoView::setInfo(struct menu *m)
{
menu = m;
if (!menu)
clear();
else
menuInfo();
}
void ConfigInfoView::setSource(const QString& name)
{
const char *p = name.latin1();
menu = NULL;
switch (p[0]) {
case 'm':
if (sscanf(p, "m%p", &menu) == 1)
menuInfo();
break;
}
}
return res;
}
static void expr_print_help(void *data, const char *str)
{
reinterpret_cast<QString*>(data)->append(print_filter(str));
}
/*
* display a new help entry as soon as a new menu entry is selected
*/
void ConfigMainWindow::setHelp(QListViewItem* item)
void ConfigInfoView::menuInfo(void)
{
struct symbol* sym;
struct menu* menu = 0;
configList->parent()->lineEdit->hide();
if (item)
menu = ((ConfigItem*)item)->menu;
if (!menu) {
helpText->setText(QString::null);
return;
}
QString head, debug, help;
menu = ((ConfigItem*)item)->menu;
sym = menu->sym;
if (sym) {
if (menu->prompt) {
@ -1039,17 +878,42 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
head += "</b></big>";
if (sym->name) {
head += " (";
head += print_filter(_(sym->name));
head += print_filter(sym->name);
head += ")";
}
} else if (sym->name) {
head += "<big><b>";
head += print_filter(_(sym->name));
head += print_filter(sym->name);
head += "</b></big>";
}
head += "<br><br>";
if (showDebug) {
if (showDebug())
debug = debug_info(sym);
help = print_filter(_(sym->help));
} else if (menu->prompt) {
head += "<big><b>";
head += print_filter(_(menu->prompt->text));
head += "</b></big><br><br>";
if (showDebug()) {
if (menu->prompt->visible.expr) {
debug += "&nbsp;&nbsp;dep: ";
expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br><br>";
}
}
}
if (showDebug())
debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
setText(head + debug + help);
}
QString ConfigInfoView::debug_info(struct symbol *sym)
{
QString debug;
debug += "type: ";
debug += print_filter(sym_type_name(sym->type));
if (sym_is_choice(sym))
@ -1102,24 +966,283 @@ void ConfigMainWindow::setHelp(QListViewItem* item)
}
}
debug += "<br>";
}
help = print_filter(_(sym->help));
} else if (menu->prompt) {
head += "<big><b>";
head += print_filter(_(menu->prompt->text));
head += "</b></big><br><br>";
if (showDebug) {
if (menu->prompt->visible.expr) {
debug += "&nbsp;&nbsp;dep: ";
expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br><br>";
return debug;
}
QString ConfigInfoView::print_filter(const QString &str)
{
QRegExp re("[<>&\"\\n]");
QString res = str;
for (int i = 0; (i = res.find(re, i)) >= 0;) {
switch (res[i].latin1()) {
case '<':
res.replace(i, 1, "&lt;");
i += 4;
break;
case '>':
res.replace(i, 1, "&gt;");
i += 4;
break;
case '&':
res.replace(i, 1, "&amp;");
i += 5;
break;
case '"':
res.replace(i, 1, "&quot;");
i += 6;
break;
case '\n':
res.replace(i, 1, "<br>");
i += 4;
break;
}
}
return res;
}
void ConfigInfoView::expr_print_help(void *data, const char *str)
{
reinterpret_cast<QString*>(data)->append(print_filter(str));
}
ConfigSearchWindow::ConfigSearchWindow(QWidget* parent)
: Parent(parent), result(NULL)
{
setCaption("Search Config");
QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6);
QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6);
layout2->addWidget(new QLabel("Find:", this));
editField = new QLineEdit(this);
connect(editField, SIGNAL(returnPressed()), SLOT(search()));
layout2->addWidget(editField);
searchButton = new QPushButton("Search", this);
searchButton->setAutoDefault(FALSE);
connect(searchButton, SIGNAL(clicked()), SLOT(search()));
layout2->addWidget(searchButton);
layout1->addLayout(layout2);
QSplitter* split = new QSplitter(this);
split->setOrientation(QSplitter::Vertical);
list = new ConfigView(split, NULL);
list->list->mode = listMode;
info = new ConfigInfoView(split);
connect(list->list, SIGNAL(menuChanged(struct menu *)),
info, SLOT(setInfo(struct menu *)));
layout1->addWidget(split);
}
void ConfigSearchWindow::search(void)
{
struct symbol **p;
struct property *prop;
ConfigItem *lastItem = NULL;
free(result);
list->list->clear();
result = sym_re_search(editField->text().latin1());
if (!result)
return;
for (p = result; *p; p++) {
for_all_prompts((*p), prop)
lastItem = new ConfigItem(list->list, lastItem, prop->menu,
menu_is_visible(prop->menu));
}
if (showDebug)
debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
helpText->setText(head + debug + help);
}
/*
* Construct the complete config widget
*/
ConfigMainWindow::ConfigMainWindow(void)
{
QMenuBar* menu;
bool ok, showDebug;
int x, y, width, height;
QWidget *d = configApp->desktop();
ConfigSettings* configSettings = new ConfigSettings();
#if QT_VERSION >= 300
width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64);
height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64);
resize(width, height);
x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok);
if (ok)
y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok);
if (ok)
move(x, y);
showDebug = configSettings->readBoolEntry("/kconfig/qconf/showDebug", false);
// read list settings into configSettings, will be used later for ConfigList setup
configSettings->readListSettings();
#else
width = d->width() - 64;
height = d->height() - 64;
resize(width, height);
showDebug = false;
#endif
split1 = new QSplitter(this);
split1->setOrientation(QSplitter::Horizontal);
setCentralWidget(split1);
menuView = new ConfigView(split1, configSettings);
menuList = menuView->list;
split2 = new QSplitter(split1);
split2->setOrientation(QSplitter::Vertical);
// create config tree
configView = new ConfigView(split2, configSettings);
configList = configView->list;
helpText = new ConfigInfoView(split2);
helpText->setTextFormat(Qt::RichText);
helpText->setShowDebug(showDebug);
setTabOrder(configList, helpText);
configList->setFocus();
menu = menuBar();
toolBar = new QToolBar("Tools", this);
backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
connect(backAction, SIGNAL(activated()), SLOT(goBack()));
backAction->setEnabled(FALSE);
QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
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);
connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
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);
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()));
QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
showNameAction->setToggleAction(TRUE);
showNameAction->setOn(configList->showName);
connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool)));
QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
showRangeAction->setToggleAction(TRUE);
showRangeAction->setOn(configList->showRange);
connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool)));
QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
showDataAction->setToggleAction(TRUE);
showDataAction->setOn(configList->showData);
connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool)));
QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
showAllAction->setToggleAction(TRUE);
showAllAction->setOn(configList->showAll);
connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));
QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
showDebugAction->setToggleAction(TRUE);
showDebugAction->setOn(showDebug);
connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
QAction *showAboutAction = new QAction(NULL, "About", 0, this);
connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
// init tool bar
backAction->addTo(toolBar);
toolBar->addSeparator();
loadAction->addTo(toolBar);
saveAction->addTo(toolBar);
toolBar->addSeparator();
singleViewAction->addTo(toolBar);
splitViewAction->addTo(toolBar);
fullViewAction->addTo(toolBar);
// create config menu
QPopupMenu* config = new QPopupMenu(this);
menu->insertItem("&File", config);
loadAction->addTo(config);
saveAction->addTo(config);
saveAsAction->addTo(config);
config->insertSeparator();
searchAction->addTo(config);
config->insertSeparator();
quitAction->addTo(config);
// create options menu
QPopupMenu* optionMenu = new QPopupMenu(this);
menu->insertItem("&Option", optionMenu);
showNameAction->addTo(optionMenu);
showRangeAction->addTo(optionMenu);
showDataAction->addTo(optionMenu);
optionMenu->insertSeparator();
showAllAction->addTo(optionMenu);
showDebugAction->addTo(optionMenu);
// create help menu
QPopupMenu* helpMenu = new QPopupMenu(this);
menu->insertSeparator();
menu->insertItem("&Help", helpMenu);
showIntroAction->addTo(helpMenu);
showAboutAction->addTo(helpMenu);
connect(configList, SIGNAL(menuChanged(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(configList, SIGNAL(menuSelected(struct menu *)),
SLOT(changeMenu(struct menu *)));
connect(configList, SIGNAL(parentSelected()),
SLOT(goBack()));
connect(menuList, SIGNAL(menuChanged(struct menu *)),
helpText, SLOT(setInfo(struct menu *)));
connect(menuList, SIGNAL(menuSelected(struct menu *)),
SLOT(changeMenu(struct menu *)));
connect(configList, SIGNAL(gotFocus(void)),
SLOT(listFocusChanged(void)));
connect(menuList, SIGNAL(gotFocus(void)),
SLOT(listFocusChanged(void)));
#if QT_VERSION >= 300
QString listMode = configSettings->readEntry("/kconfig/qconf/listMode", "symbol");
if (listMode == "single")
showSingleView();
else if (listMode == "full")
showFullView();
else /*if (listMode == "split")*/
showSplitView();
// UI setup done, restore splitter positions
QValueList<int> sizes = configSettings->readSizes("/kconfig/qconf/split1", &ok);
if (ok)
split1->setSizes(sizes);
sizes = configSettings->readSizes("/kconfig/qconf/split2", &ok);
if (ok)
split2->setSizes(sizes);
#else
showSplitView();
#endif
delete configSettings;
}
/*
* display a new help entry as soon as a new menu entry is selected
*/
void ConfigMainWindow::setHelp(QListViewItem* item)
{
struct symbol* sym;
struct menu* menu = 0;
if (item)
menu = ((ConfigItem*)item)->menu;
helpText->setInfo(menu);
}
void ConfigMainWindow::loadConfig(void)
@ -1147,6 +1270,13 @@ void ConfigMainWindow::saveConfigAs(void)
QMessageBox::information(this, "qconf", "Unable to save configuration!");
}
void ConfigMainWindow::searchConfig(void)
{
if (!searchWindow)
searchWindow = new ConfigSearchWindow(this);
searchWindow->show();
}
void ConfigMainWindow::changeMenu(struct menu *menu)
{
configList->setRootMenu(menu);
@ -1233,13 +1363,6 @@ void ConfigMainWindow::setShowAll(bool b)
menuList->updateListAll();
}
void ConfigMainWindow::setShowDebug(bool b)
{
if (showDebug == b)
return;
showDebug = b;
}
void ConfigMainWindow::setShowName(bool b)
{
if (configList->showName == b)
@ -1334,7 +1457,7 @@ void ConfigMainWindow::saveSettings(void)
configSettings->writeEntry("/kconfig/qconf/showRange", configList->showRange);
configSettings->writeEntry("/kconfig/qconf/showData", configList->showData);
configSettings->writeEntry("/kconfig/qconf/showAll", configList->showAll);
configSettings->writeEntry("/kconfig/qconf/showDebug", showDebug);
configSettings->writeEntry("/kconfig/qconf/showDebug", helpText->showDebug());
QString entry;
switch(configList->mode) {
@ -1417,9 +1540,10 @@ int main(int ac, char** av)
v = new ConfigMainWindow();
//zconfdump(stdout);
v->show();
configApp->setMainWidget(v);
configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
v->show();
configApp->exec();
return 0;

View file

@ -36,7 +36,7 @@ class ConfigView : public QVBox {
Q_OBJECT
typedef class QVBox Parent;
public:
ConfigView(QWidget* parent, ConfigMainWindow* cview, ConfigSettings* configSettings);
ConfigView(QWidget* parent, ConfigSettings* configSettings);
~ConfigView(void);
static void updateList(ConfigItem* item);
static void updateListAll(void);
@ -53,14 +53,14 @@ enum colIdx {
promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
};
enum listMode {
singleMode, menuMode, symbolMode, fullMode
singleMode, menuMode, symbolMode, fullMode, listMode
};
class ConfigList : public QListView {
Q_OBJECT
typedef class QListView Parent;
public:
ConfigList(ConfigView* p, ConfigMainWindow* cview, ConfigSettings *configSettings);
ConfigList(ConfigView* p, ConfigSettings *configSettings);
void reinit(void);
ConfigView* parent(void) const
{
@ -68,8 +68,6 @@ public:
}
protected:
ConfigMainWindow* cview;
void keyPressEvent(QKeyEvent *e);
void contentsMousePressEvent(QMouseEvent *e);
void contentsMouseReleaseEvent(QMouseEvent *e);
@ -84,6 +82,7 @@ public slots:
void changeValue(ConfigItem* item);
void updateSelection(void);
signals:
void menuChanged(struct menu *menu);
void menuSelected(struct menu *menu);
void parentSelected(void);
void gotFocus(void);
@ -208,9 +207,7 @@ class ConfigLineEdit : public QLineEdit {
Q_OBJECT
typedef class QLineEdit Parent;
public:
ConfigLineEdit(ConfigView* parent)
: Parent(parent)
{ }
ConfigLineEdit(ConfigView* parent);
ConfigView* parent(void) const
{
return (ConfigView*)Parent::parent();
@ -222,6 +219,47 @@ public:
ConfigItem *item;
};
class ConfigInfoView : public QTextBrowser {
Q_OBJECT
typedef class QTextBrowser Parent;
public:
ConfigInfoView(QWidget* parent, const char *name = 0);
bool showDebug(void) const { return _showDebug; }
public slots:
void setInfo(struct menu *menu);
void setSource(const QString& name);
void setShowDebug(bool);
signals:
void showDebugChanged(bool);
protected:
void menuInfo(void);
QString debug_info(struct symbol *sym);
static QString print_filter(const QString &str);
static void expr_print_help(void *data, const char *str);
struct menu *menu;
bool _showDebug;
};
class ConfigSearchWindow : public QDialog {
Q_OBJECT
typedef class QDialog Parent;
public:
ConfigSearchWindow(QWidget* parent);
public slots:
void search(void);
protected:
QLineEdit* editField;
QPushButton* searchButton;
ConfigView* list;
ConfigInfoView* info;
struct symbol **result;
};
class ConfigMainWindow : public QMainWindow {
Q_OBJECT
public:
@ -234,11 +272,11 @@ public slots:
void loadConfig(void);
void saveConfig(void);
void saveConfigAs(void);
void searchConfig(void);
void showSingleView(void);
void showSplitView(void);
void showFullView(void);
void setShowAll(bool);
void setShowDebug(bool);
void setShowRange(bool);
void setShowName(bool);
void setShowData(bool);
@ -249,15 +287,14 @@ public slots:
protected:
void closeEvent(QCloseEvent *e);
ConfigSearchWindow *searchWindow;
ConfigView *menuView;
ConfigList *menuList;
ConfigView *configView;
ConfigList *configList;
QTextView *helpText;
ConfigInfoView *helpText;
QToolBar *toolBar;
QAction *backAction;
QSplitter* split1;
QSplitter* split2;
bool showDebug;
};