Commit f9b918fa authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: qconf: move ConfigView::updateList(All) to ConfigList class

ConfigView::updateList() iterates over all views, and then calls
updateList() against for its ConfigList instance.

This means there is no point to implement it in the ConfigView class.

Move and rename as follows:

  ConfigView::updateList()     -> ConfigList::updateListForAll()
  ConfigView::updateListAll()  -> ConfigList::updateListAllForAll()

I used QList to contain all ConfigList instances.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 6a143041
...@@ -274,7 +274,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) ...@@ -274,7 +274,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
case Qt::Key_Return: case Qt::Key_Return:
case Qt::Key_Enter: case Qt::Key_Enter:
sym_set_string_value(item->menu->sym, text().toLatin1()); sym_set_string_value(item->menu->sym, text().toLatin1());
parent()->updateList(); ConfigList::updateListForAll();
break; break;
default: default:
Parent::keyPressEvent(e); Parent::keyPressEvent(e);
...@@ -315,9 +315,16 @@ ConfigList::ConfigList(ConfigView* p, const char *name) ...@@ -315,9 +315,16 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
showColumn(promptColIdx); showColumn(promptColIdx);
allLists.append(this);
reinit(); reinit();
} }
ConfigList::~ConfigList()
{
allLists.removeOne(this);
}
bool ConfigList::menuSkip(struct menu *menu) bool ConfigList::menuSkip(struct menu *menu)
{ {
if (optMode == normalOpt && menu_is_visible(menu)) if (optMode == normalOpt && menu_is_visible(menu))
...@@ -454,6 +461,28 @@ update: ...@@ -454,6 +461,28 @@ update:
resizeColumnToContents(0); resizeColumnToContents(0);
} }
void ConfigList::updateListForAll()
{
QListIterator<ConfigList *> it(allLists);
while (it.hasNext()) {
ConfigList *list = it.next();
list->updateList();
}
}
void ConfigList::updateListAllForAll()
{
QListIterator<ConfigList *> it(allLists);
while (it.hasNext()) {
ConfigList *list = it.next();
list->updateList();
}
}
void ConfigList::setValue(ConfigItem* item, tristate val) void ConfigList::setValue(ConfigItem* item, tristate val)
{ {
struct symbol* sym; struct symbol* sym;
...@@ -474,7 +503,7 @@ void ConfigList::setValue(ConfigItem* item, tristate val) ...@@ -474,7 +503,7 @@ void ConfigList::setValue(ConfigItem* item, tristate val)
return; return;
if (oldval == no && item->menu->list) if (oldval == no && item->menu->list)
item->setExpanded(true); item->setExpanded(true);
parent()->updateList(); ConfigList::updateListForAll();
break; break;
} }
} }
...@@ -508,7 +537,7 @@ void ConfigList::changeValue(ConfigItem* item) ...@@ -508,7 +537,7 @@ void ConfigList::changeValue(ConfigItem* item)
item->setExpanded(true); item->setExpanded(true);
} }
if (oldexpr != newexpr) if (oldexpr != newexpr)
parent()->updateList(); ConfigList::updateListForAll();
break; break;
case S_INT: case S_INT:
case S_HEX: case S_HEX:
...@@ -904,7 +933,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) ...@@ -904,7 +933,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
e->accept(); e->accept();
} }
ConfigView*ConfigView::viewList; QList<ConfigList *> ConfigList::allLists;
QAction *ConfigList::showNormalAction; QAction *ConfigList::showNormalAction;
QAction *ConfigList::showAllAction; QAction *ConfigList::showAllAction;
QAction *ConfigList::showPromptAction; QAction *ConfigList::showPromptAction;
...@@ -921,21 +950,6 @@ ConfigView::ConfigView(QWidget* parent, const char *name) ...@@ -921,21 +950,6 @@ ConfigView::ConfigView(QWidget* parent, const char *name)
lineEdit = new ConfigLineEdit(this); lineEdit = new ConfigLineEdit(this);
lineEdit->hide(); lineEdit->hide();
verticalLayout->addWidget(lineEdit); verticalLayout->addWidget(lineEdit);
this->nextView = viewList;
viewList = this;
}
ConfigView::~ConfigView(void)
{
ConfigView** vp;
for (vp = &viewList; *vp; vp = &(*vp)->nextView) {
if (*vp == this) {
*vp = nextView;
break;
}
}
} }
void ConfigView::setShowName(bool b) void ConfigView::setShowName(bool b)
...@@ -976,22 +990,6 @@ void ConfigList::setAllOpen(bool open) ...@@ -976,22 +990,6 @@ void ConfigList::setAllOpen(bool open)
} }
} }
void ConfigView::updateList()
{
ConfigView* v;
for (v = viewList; v; v = v->nextView)
v->list->updateList();
}
void ConfigView::updateListAll(void)
{
ConfigView* v;
for (v = viewList; v; v = v->nextView)
v->list->updateListAll();
}
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
: Parent(parent), sym(0), _menu(0) : Parent(parent), sym(0), _menu(0)
{ {
...@@ -1605,7 +1603,7 @@ void ConfigMainWindow::loadConfig(void) ...@@ -1605,7 +1603,7 @@ void ConfigMainWindow::loadConfig(void)
free(configname); free(configname);
configname = xstrdup(name); configname = xstrdup(name);
ConfigView::updateListAll(); ConfigList::updateListAllForAll();
} }
bool ConfigMainWindow::saveConfig(void) bool ConfigMainWindow::saveConfig(void)
......
...@@ -44,6 +44,7 @@ class ConfigList : public QTreeWidget { ...@@ -44,6 +44,7 @@ class ConfigList : public QTreeWidget {
typedef class QTreeWidget Parent; typedef class QTreeWidget Parent;
public: public:
ConfigList(ConfigView* p, const char *name = 0); ConfigList(ConfigView* p, const char *name = 0);
~ConfigList();
void reinit(void); void reinit(void);
ConfigItem* findConfigItem(struct menu *); ConfigItem* findConfigItem(struct menu *);
ConfigView* parent(void) const ConfigView* parent(void) const
...@@ -108,6 +109,10 @@ public slots: ...@@ -108,6 +109,10 @@ public slots:
QPalette inactivedColorGroup; QPalette inactivedColorGroup;
QMenu* headerPopup; QMenu* headerPopup;
static QList<ConfigList *> allLists;
static void updateListForAll();
static void updateListAllForAll();
static QAction *showNormalAction, *showAllAction, *showPromptAction; static QAction *showNormalAction, *showAllAction, *showPromptAction;
}; };
...@@ -188,9 +193,6 @@ class ConfigView : public QWidget { ...@@ -188,9 +193,6 @@ class ConfigView : public QWidget {
typedef class QWidget Parent; typedef class QWidget Parent;
public: public:
ConfigView(QWidget* parent, const char *name = 0); ConfigView(QWidget* parent, const char *name = 0);
~ConfigView(void);
static void updateList();
static void updateListAll(void);
bool showName(void) const { return list->showName; } bool showName(void) const { return list->showName; }
bool showRange(void) const { return list->showRange; } bool showRange(void) const { return list->showRange; }
...@@ -206,9 +208,6 @@ public slots: ...@@ -206,9 +208,6 @@ public slots:
public: public:
ConfigList* list; ConfigList* list;
ConfigLineEdit* lineEdit; ConfigLineEdit* lineEdit;
static ConfigView* viewList;
ConfigView* nextView;
}; };
class ConfigInfoView : public QTextBrowser { class ConfigInfoView : public QTextBrowser {
......
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