@@ -35,7 +35,8 @@ P(sym_lookup,struct symbol *,(const char *name, int flags));
P(sym_find,struct symbol *,(const char *name));
P(sym_expand_string_value,const char *,(const char *in));
P(sym_escape_string_value, const char *,(const char *in));
-P(sym_re_search,struct symbol **,(const char *pattern));
+P(sym_re_search, struct symbol **, (const char *pattern,
+ const bool in_description));
P(sym_type_name,const char *,(enum symbol_type type));
P(sym_calc_value,void,(struct symbol *sym));
P(sym_get_type,enum symbol_type,(struct symbol *sym));
@@ -430,7 +430,7 @@ again:
stpart.text = str_get(&sttext);
list_add_tail(&stpart.entries, &trail);
- sym_arr = sym_re_search(dialog_input);
+ sym_arr = sym_re_search(dialog_input, false);
do {
LIST_HEAD(head);
struct menu *targets[JUMP_NB];
@@ -720,7 +720,7 @@ again:
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
dialog_input += strlen(CONFIG_);
- sym_arr = sym_re_search(dialog_input);
+ sym_arr = sym_re_search(dialog_input, false);
res = get_relations_str(sym_arr, NULL);
free(sym_arr);
show_scroll_win(main_window,
@@ -1197,6 +1197,9 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
layout2->addWidget(searchButton);
layout1->addLayout(layout2);
+ searchInDescription = new QCheckBox(_("Search in all texts."), this);
+ layout1->addWidget(searchInDescription);
+
split = new QSplitter(this);
split->setOrientation(Qt::Vertical);
list = new ConfigView(split, name);
@@ -1253,7 +1256,15 @@ void ConfigSearchWindow::search(void)
list->list->clear();
info->clear();
- result = sym_re_search(editField->text().latin1());
+ bool in_description = false;
+#if QT_VERSION >= 0x040000
+ if (searchInDescription->checkState() == Qt::Checked) {
+#else
+ if (searchInDescription->isChecked() == TRUE) {
+#endif
+ in_description = true;
+ }
+ result = sym_re_search(editField->text().latin1(), in_description);
if (!result)
return;
for (p = result; *p; p++) {
@@ -5,8 +5,10 @@
#if QT_VERSION < 0x040000
#include <qlistview.h>
+#include <qcheckbox.h>
#else
#include <q3listview.h>
+#include <QCheckBox>
#endif
#include <qsettings.h>
@@ -294,6 +296,7 @@ protected:
QSplitter* split;
ConfigView* list;
ConfigInfoView* info;
+ QCheckBox *searchInDescription;
struct symbol **result;
};
@@ -990,7 +990,7 @@ static int sym_rel_comp(const void *sym1, const void *sym2)
return strcmp(s1->sym->name, s2->sym->name);
}
-struct symbol **sym_re_search(const char *pattern)
+struct symbol **sym_re_search(const char *pattern, const bool in_description)
{
struct symbol *sym, **sym_arr = NULL;
struct sym_match *sym_match_arr = NULL;
@@ -1008,8 +1008,43 @@ struct symbol **sym_re_search(const char *pattern)
for_all_symbols(i, sym) {
if (sym->flags & SYMBOL_CONST || !sym->name)
continue;
- if (regexec(&re, sym->name, 1, match, 0))
- continue;
+ if (in_description) {
+ struct property *prop;
+ size_t length = 1;
+ if (sym->name)
+ length += strlen(sym->name);
+ for_all_prompts(sym, prop) {
+ if (prop->text)
+ length += strlen(prop->text) + 1;
+ if (prop->menu && prop->menu->help)
+ length += strlen(prop->menu->help) + 1;
+ }
+ char *all_text = 0;
+ all_text = malloc(length);
+ if (!all_text)
+ goto sym_re_search_free;
+ *all_text = 0;
+ if (sym->name)
+ strcat(all_text, sym->name);
+ for_all_prompts(sym, prop) {
+ if (prop->text) {
+ strcat(all_text, "\n");
+ strcat(all_text, prop->text);
+ }
+ if (prop->menu && prop->menu->help) {
+ strcat(all_text, "\n");
+ strcat(all_text, prop->menu->help);
+ }
+ }
+ if (regexec(&re, all_text, 1, match, 0)) {
+ free(all_text);
+ continue;
+ }
+ free(all_text);
+ } else {
+ if (regexec(&re, sym->name, 1, match, 0))
+ continue;
+ }
if (cnt >= size) {
void *tmp;
size += 16;