mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Randy Dunlap <rdunlap@infradead.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 04/11] kconfig: qconf: move ConfigView::updateList(All) to ConfigList class
Date: Sat, 29 Aug 2020 17:14:10 +0900	[thread overview]
Message-ID: <20200829081417.725978-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20200829081417.725978-1-masahiroy@kernel.org>

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: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/qconf.cc | 70 +++++++++++++++++++---------------------
 scripts/kconfig/qconf.h  | 11 +++----
 2 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 278c04de11ec..035101984bd3 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -274,7 +274,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
 	case Qt::Key_Return:
 	case Qt::Key_Enter:
 		sym_set_string_value(item->menu->sym, text().toLatin1());
-		parent()->updateList();
+		ConfigList::updateListForAll();
 		break;
 	default:
 		Parent::keyPressEvent(e);
@@ -315,9 +315,16 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
 
 	showColumn(promptColIdx);
 
+	allLists.append(this);
+
 	reinit();
 }
 
+ConfigList::~ConfigList()
+{
+	allLists.removeOne(this);
+}
+
 bool ConfigList::menuSkip(struct menu *menu)
 {
 	if (optMode == normalOpt && menu_is_visible(menu))
@@ -454,6 +461,28 @@ update:
 	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)
 {
 	struct symbol* sym;
@@ -474,7 +503,7 @@ void ConfigList::setValue(ConfigItem* item, tristate val)
 			return;
 		if (oldval == no && item->menu->list)
 			item->setExpanded(true);
-		parent()->updateList();
+		ConfigList::updateListForAll();
 		break;
 	}
 }
@@ -508,7 +537,7 @@ void ConfigList::changeValue(ConfigItem* item)
 				item->setExpanded(true);
 		}
 		if (oldexpr != newexpr)
-			parent()->updateList();
+			ConfigList::updateListForAll();
 		break;
 	case S_INT:
 	case S_HEX:
@@ -904,7 +933,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
 	e->accept();
 }
 
-ConfigView*ConfigView::viewList;
+QList<ConfigList *> ConfigList::allLists;
 QAction *ConfigList::showNormalAction;
 QAction *ConfigList::showAllAction;
 QAction *ConfigList::showPromptAction;
@@ -921,21 +950,6 @@ ConfigView::ConfigView(QWidget* parent, const char *name)
 	lineEdit = new ConfigLineEdit(this);
 	lineEdit->hide();
 	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)
@@ -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)
 	: Parent(parent), sym(0), _menu(0)
 {
@@ -1600,7 +1598,7 @@ void ConfigMainWindow::loadConfig(void)
 	free(configname);
 	configname = xstrdup(name);
 
-	ConfigView::updateListAll();
+	ConfigList::updateListAllForAll();
 }
 
 bool ConfigMainWindow::saveConfig(void)
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index d41670f322b3..818e00617ae3 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -44,6 +44,7 @@ class ConfigList : public QTreeWidget {
 	typedef class QTreeWidget Parent;
 public:
 	ConfigList(ConfigView* p, const char *name = 0);
+	~ConfigList();
 	void reinit(void);
 	ConfigItem* findConfigItem(struct menu *);
 	ConfigView* parent(void) const
@@ -108,6 +109,10 @@ public slots:
 	QPalette inactivedColorGroup;
 	QMenu* headerPopup;
 
+	static QList<ConfigList *> allLists;
+	static void updateListForAll();
+	static void updateListAllForAll();
+
 	static QAction *showNormalAction, *showAllAction, *showPromptAction;
 };
 
@@ -188,9 +193,6 @@ class ConfigView : public QWidget {
 	typedef class QWidget Parent;
 public:
 	ConfigView(QWidget* parent, const char *name = 0);
-	~ConfigView(void);
-	static void updateList();
-	static void updateListAll(void);
 
 	bool showName(void) const { return list->showName; }
 	bool showRange(void) const { return list->showRange; }
@@ -206,9 +208,6 @@ public slots:
 public:
 	ConfigList* list;
 	ConfigLineEdit* lineEdit;
-
-	static ConfigView* viewList;
-	ConfigView* nextView;
 };
 
 class ConfigInfoView : public QTextBrowser {
-- 
2.25.1


  parent reply	other threads:[~2020-08-29  8:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-29  8:14 [PATCH 01/11] kconfig: qconf: reformat the intro message Masahiro Yamada
2020-08-29  8:14 ` [PATCH 02/11] kconfig: qconf: update the intro message to match to the current code Masahiro Yamada
2020-08-30  4:58   ` Randy Dunlap
2020-08-29  8:14 ` [PATCH 03/11] kconfig: qconf: remove unused ConfigItem::okRename() Masahiro Yamada
2020-08-29  8:14 ` Masahiro Yamada [this message]
2020-08-29  8:14 ` [PATCH 05/11] kconfig: qconf: show data column all the time Masahiro Yamada
2020-08-30  4:54   ` Randy Dunlap
2020-08-30  9:59     ` Masahiro Yamada
2020-08-29  8:14 ` [PATCH 06/11] kconfig: qconf: allow to edit "int", "hex", "string" menus in-place Masahiro Yamada
2020-08-30  4:54   ` Randy Dunlap
2020-08-30 10:01     ` Masahiro Yamada
2020-08-29  8:14 ` [PATCH 07/11] kconfig: qconf: remove ConfigLineEdit class Masahiro Yamada
2020-08-29  8:14 ` [PATCH 08/11] kconfig: qconf: move setShowName/Range() to ConfigList from ConfigView Masahiro Yamada
2020-08-29  8:14 ` [PATCH 09/11] kconfig: qconf: remove ConfigView class Masahiro Yamada
2020-08-29  8:14 ` [PATCH 10/11] kconfig: qconf: remove Y, M, N columns Masahiro Yamada
2020-08-29  8:14 ` [PATCH 11/11] kconfig: qconf: create QApplication after option checks Masahiro Yamada
2020-08-30  4:58   ` Randy Dunlap
2020-08-30  4:59 ` [PATCH 01/11] kconfig: qconf: reformat the intro message Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200829081417.725978-4-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®