Skip to contentSkip to conversation

kconfig: qconf: remove mouse{Press,Move}Event() functions

PATCH New Masahiro Yamada 1 participant 13 messages Oct 23, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/13 kconfig: qconf: remove mouse{Press,Move}Event() functions

These functions simply passes the event to the parent.

---

 scripts/kconfig/qconf.cc | 14 --------------
 scripts/kconfig/qconf.h  |  2 --
 2 files changed, 16 deletions(-)
scripts/kconfig/qconf.cc +0 -14
index 90f139480eda..18cc5c184f56 100644
@@ -781,13 +781,6 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
 	ev->accept();
 }
 
-void ConfigList::mousePressEvent(QMouseEvent* e)
-{
-	//QPoint p(contentsToViewport(e->pos()));
-	//printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());
-	Parent::mousePressEvent(e);
-}
-
 void ConfigList::mouseReleaseEvent(QMouseEvent* e)
 {
 	QPoint p = e->pos();
@@ -834,13 +827,6 @@ skip:
 	Parent::mouseReleaseEvent(e);
 }
 
-void ConfigList::mouseMoveEvent(QMouseEvent* e)
-{
-	//QPoint p(contentsToViewport(e->pos()));
-	//printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());
-	Parent::mouseMoveEvent(e);
-}
-
 void ConfigList::mouseDoubleClickEvent(QMouseEvent* e)
 {
 	QPoint p = e->pos();
scripts/kconfig/qconf.h +0 -2
index aab25ece95c6..0b62fb26821a 100644
@@ -55,9 +55,7 @@ class ConfigList : public QTreeWidget {
 
 protected:
 	void keyPressEvent(QKeyEvent *e);
-	void mousePressEvent(QMouseEvent *e);
 	void mouseReleaseEvent(QMouseEvent *e);
-	void mouseMoveEvent(QMouseEvent *e);
 	void mouseDoubleClickEvent(QMouseEvent *e);
 	void focusInEvent(QFocusEvent *e);
 	void contextMenuEvent(QContextMenuEvent *e);
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/13 kconfig: qconf: remove redundant type check for choice members

Since commit fde192511bdb ("kconfig: remove tristate choice support"), choice members are always boolean. The type check is redundant.

---

 scripts/kconfig/qconf.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/qconf.cc +1 -1
index 18cc5c184f56..58c57c908149 100644
@@ -159,7 +159,7 @@ void ConfigItem::updateMenu(void)
 			ch = 'M';
 			break;
 		default:
-			if (sym_is_choice_value(sym) && type == S_BOOLEAN)
+			if (sym_is_choice_value(sym))
 				setIcon(promptColIdx, choiceNoIcon);
 			else
 				setIcon(promptColIdx, symbolNoIcon);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/13 kconfig: qconf: remove unnecessary setRootIsDecorated() call

In reply to Masahiro Yamada

The default value of the rootIsDecorated property is true.

---

 scripts/kconfig/qconf.cc | 1 -
 1 file changed, 1 deletion(-)
scripts/kconfig/qconf.cc +0 -1
index 58c57c908149..120090fa4ac9 100644
@@ -307,7 +307,6 @@ ConfigList::ConfigList(QWidget *parent, const char *name)
 {
 	setObjectName(name);
 	setSortingEnabled(false);
-	setRootIsDecorated(true);
 
 	setVerticalScrollMode(ScrollPerPixel);
 	setHorizontalScrollMode(ScrollPerPixel);
Signature · 1 line
2.43.0
#3 lore raw

PATCH 4/13 kconfig: qconf: remove unnecessary lastWindowClosed() signal connection

In reply to Masahiro Yamada

The default value of the quitOnLastWindowClosed property is true.

Hence, the application implicitly quits when the last window is closed.

---

 scripts/kconfig/qconf.cc | 1 -
 1 file changed, 1 deletion(-)
scripts/kconfig/qconf.cc +0 -1
index 120090fa4ac9..49a3d0365c39 100644
@@ -1863,7 +1863,6 @@ int main(int ac, char** av)
 	v = new ConfigMainWindow();
 
 	//zconfdump(stdout);
-	configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit()));
 	configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
 
 	v->show();
Signature · 1 line
2.43.0
#4 lore raw

PATCH 5/13 kconfig: qconf: convert the last old connection syntax to Qt5 style

In reply to Masahiro Yamada

Commit a2574c12df0d ("kconfig: qconf: convert to Qt5 new signal/slot connection syntax") converted most of the old string-based connections, but one more instance still remains. Convert it to the new style.

---

 scripts/kconfig/qconf.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/kconfig/qconf.cc +3 -1
index 49a3d0365c39..c922c34621a4 100644
@@ -1475,6 +1475,9 @@ ConfigMainWindow::ConfigMainWindow(void)
 	connect(helpText, &ConfigInfoView::menuSelected,
 		this, &ConfigMainWindow::setMenuLink);
 
+	connect(configApp, &QApplication::aboutToQuit,
+		this, &ConfigMainWindow::saveSettings);
+
 	conf_read(NULL);
 
 	QString listMode = configSettings->value("/listMode", "symbol").toString();
@@ -1863,7 +1866,6 @@ int main(int ac, char** av)
 	v = new ConfigMainWindow();
 
 	//zconfdump(stdout);
-	configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings()));
 
 	v->show();
 	configApp->exec();
Signature · 1 line
2.43.0
#5 lore raw

PATCH 6/13 kconfig: qconf: do not show goParent button in split view

In reply to Masahiro Yamada

When a menu is selected in the split view, the right pane displays the goParent button, but it is never functional.

This is unnecessary, as you can select a menu from the menu tree in the left pane.

---

 scripts/kconfig/qconf.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/kconfig/qconf.cc +1 -2
index c922c34621a4..7c844c4a119e 100644
@@ -436,8 +436,7 @@ void ConfigList::updateList()
 		return;
 	}
 
-	if (rootEntry != &rootmenu && (mode == singleMode ||
-	    (mode == symbolMode && rootEntry->parent != &rootmenu))) {
+	if (rootEntry != &rootmenu && mode == singleMode) {
 		item = (ConfigItem *)topLevelItem(0);
 		if (!item)
 			item = new ConfigItem(this, 0, true);
Signature · 1 line
2.43.0
#6 lore raw

PATCH 7/13 kconfig: qconf: remove ConfigItem::visible member

In reply to Masahiro Yamada

The " (NEW)" string should be displayed regardless of the visibility of the associated menu.

The ConfigItem::visible member is not used for any other purpose.

---

 scripts/kconfig/qconf.cc | 28 +++++++++++-----------------
 scripts/kconfig/qconf.h  | 15 +++++++--------
 2 files changed, 18 insertions(+), 25 deletions(-)
scripts/kconfig/qconf.cc +11 -17
index 7c844c4a119e..5b1237bf085a 100644
@@ -175,17 +175,16 @@ void ConfigItem::updateMenu(void)
 		setText(dataColIdx, sym_get_string_value(sym));
 		break;
 	}
-	if (!sym_has_value(sym) && visible)
+	if (!sym_has_value(sym))
 		prompt += " (NEW)";
 set_prompt:
 	setText(promptColIdx, prompt);
 }
 
-void ConfigItem::testUpdateMenu(bool v)
+void ConfigItem::testUpdateMenu(void)
 {
 	ConfigItem* i;
 
-	visible = v;
 	if (!menu)
 		return;
 
@@ -429,7 +428,7 @@ void ConfigList::updateList()
 			item = (ConfigItem*)(*it);
 			if (!item->menu)
 				continue;
-			item->testUpdateMenu(menu_is_visible(item->menu));
+			item->testUpdateMenu();
 
 			++it;
 		}
@@ -439,16 +438,16 @@ void ConfigList::updateList()
 	if (rootEntry != &rootmenu && mode == singleMode) {
 		item = (ConfigItem *)topLevelItem(0);
 		if (!item)
-			item = new ConfigItem(this, 0, true);
+			item = new ConfigItem(this, 0);
 		last = item;
 	}
 	if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&
 	    rootEntry->sym && rootEntry->prompt) {
 		item = last ? last->nextSibling() : nullptr;
 		if (!item)
-			item = new ConfigItem(this, last, rootEntry, true);
+			item = new ConfigItem(this, last, rootEntry);
 		else
-			item->testUpdateMenu(true);
+			item->testUpdateMenu();
 
 		updateMenuList(item, rootEntry);
 		update();
@@ -597,7 +596,6 @@ void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu)
 	struct menu* child;
 	ConfigItem* item;
 	ConfigItem* last;
-	bool visible;
 	enum prop_type type;
 
 	if (!menu) {
@@ -629,14 +627,13 @@ void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu)
 			break;
 		}
 
-		visible = menu_is_visible(child);
 		if (!menuSkip(child)) {
 			if (!child->sym && !child->list && !child->prompt)
 				continue;
 			if (!item || item->menu != child)
-				item = new ConfigItem(parent, last, child, visible);
+				item = new ConfigItem(parent, last, child);
 			else
-				item->testUpdateMenu(visible);
+				item->testUpdateMenu();
 
 			if (mode == fullMode || mode == menuMode || type != P_MENU)
 				updateMenuList(item, child);
@@ -662,7 +659,6 @@ void ConfigList::updateMenuList(struct menu *menu)
 	struct menu* child;
 	ConfigItem* item;
 	ConfigItem* last;
-	bool visible;
 	enum prop_type type;
 
 	if (!menu) {
@@ -694,14 +690,13 @@ void ConfigList::updateMenuList(struct menu *menu)
 			break;
 		}
 
-		visible = menu_is_visible(child);
 		if (!menuSkip(child)) {
 			if (!child->sym && !child->list && !child->prompt)
 				continue;
 			if (!item || item->menu != child)
-				item = new ConfigItem(this, last, child, visible);
+				item = new ConfigItem(this, last, child);
 			else
-				item->testUpdateMenu(visible);
+				item->testUpdateMenu();
 
 			if (mode == fullMode || mode == menuMode || type != P_MENU)
 				updateMenuList(item, child);
@@ -1274,8 +1269,7 @@ void ConfigSearchWindow::search(void)
 		return;
 	for (p = result; *p; p++) {
 		for_all_prompts((*p), prop)
-			lastItem = new ConfigItem(list, lastItem, prop->menu,
-						  menu_is_visible(prop->menu));
+			lastItem = new ConfigItem(list, lastItem, prop->menu);
 	}
 }
 
scripts/kconfig/qconf.h +7 -8
index 0b62fb26821a..62ab3286d04f 100644
@@ -114,25 +114,25 @@ public slots:
 class ConfigItem : public QTreeWidgetItem {
 	typedef class QTreeWidgetItem Parent;
 public:
-	ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v)
-	: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
+	ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m)
+	: Parent(parent, after), nextItem(0), menu(m), goParent(false)
 	{
 		init();
 	}
-	ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
-	: Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false)
+	ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m)
+	: Parent(parent, after), nextItem(0), menu(m), goParent(false)
 	{
 		init();
 	}
-	ConfigItem(ConfigList *parent, ConfigItem *after, bool v)
-	: Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true)
+	ConfigItem(ConfigList *parent, ConfigItem *after)
+	: Parent(parent, after), nextItem(0), menu(0), goParent(true)
 	{
 		init();
 	}
 	~ConfigItem(void);
 	void init(void);
 	void updateMenu(void);
-	void testUpdateMenu(bool v);
+	void testUpdateMenu(void);
 	ConfigList* listView() const
 	{
 		return (ConfigList*)Parent::treeWidget();
@@ -159,7 +159,6 @@ class ConfigItem : public QTreeWidgetItem {
 
 	ConfigItem* nextItem;
 	struct menu *menu;
-	bool visible;
 	bool goParent;
 
 	static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon;
Signature · 1 line
2.43.0
#7 lore raw

PATCH 8/13 kconfig: qconf: avoid unnecessary parentSelected() when ESC is pressed

In reply to Masahiro Yamada

When the ESC key is pressed, the parentSelected() signal is currently emitted for singleMode, menuMode, and symbolMode.

However, parentSelected() signal is functional only for singleMode.

In menuMode, the signal is connected to the goBack() slot, but nothing occurs because configList->rootEntry is always &rootmenu.

In symbolMode (in the right pane), the parentSelected() signal is not connected to any slot.

This commit prevents the unnecessary emission of the parentSelected() signal.

---

 scripts/kconfig/qconf.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/qconf.cc +1 -1
index 5b1237bf085a..1948cda048d2 100644
@@ -724,7 +724,7 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
 	struct menu *menu;
 	enum prop_type type;
 
-	if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
+	if (ev->key() == Qt::Key_Escape && mode == singleMode) {
 		emit parentSelected();
 		ev->accept();
 		return;
Signature · 1 line
2.43.0
#8 lore raw

PATCH 9/13 kconfig: qconf: remove redundant check in goBack()

In reply to Masahiro Yamada

The same check is performed in the configList->setParentMenu() call.

---

 scripts/kconfig/qconf.cc | 3 ---
 1 file changed, 3 deletions(-)
scripts/kconfig/qconf.cc +0 -3
index 1948cda048d2..acbc4331ebc5 100644
@@ -1616,9 +1616,6 @@ void ConfigMainWindow::listFocusChanged(void)
 
 void ConfigMainWindow::goBack(void)
 {
-	if (configList->rootEntry == &rootmenu)
-		return;
-
 	configList->setParentMenu();
 }
 
Signature · 1 line
2.43.0
#9 lore raw

PATCH 10/13 kconfig: qconf: remove non-functional href="m..." tag

In reply to Masahiro Yamada

The only functional tag is href="s<symbol_name>".

Commit c4f7398bee9c ("kconfig: qconf: make debug links work again") changed prop->name to sym->name for this reference, but it missed to change the tag "m" to "s".

This tag is not functional at all.

---

 scripts/kconfig/qconf.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/kconfig/qconf.cc +2 -2
index acbc4331ebc5..a208ef33128f 100644
@@ -1065,9 +1065,9 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
 		switch (prop->type) {
 		case P_PROMPT:
 		case P_MENU:
-			stream << "prompt: <a href=\"m" << sym->name << "\">";
+			stream << "prompt: ";
 			stream << print_filter(prop->text);
-			stream << "</a><br>";
+			stream << "<br>";
 			break;
 		case P_DEFAULT:
 		case P_SELECT:
Signature · 1 line
2.43.0
#10 lore raw

PATCH 11/13 kconfig: add sym_get_prompt_menu() helper function

In reply to Masahiro Yamada

Split out the code that retrieves the menu entry with a prompt, so it can be reused in other functions.

---

 scripts/kconfig/lkc_proto.h |  1 +
 scripts/kconfig/symbol.c    | 26 +++++++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)
scripts/kconfig/lkc_proto.h +1 -0
index 63519cd24bc7..8914b4e8f2a8 100644
@@ -34,6 +34,7 @@ bool sym_string_valid(struct symbol *sym, const char *newval);
 bool sym_string_within_range(struct symbol *sym, const char *str);
 bool sym_set_string_value(struct symbol *sym, const char *newval);
 bool sym_is_changeable(const struct symbol *sym);
+struct menu *sym_get_prompt_menu(const struct symbol *sym);
 struct menu *sym_get_choice_menu(const struct symbol *sym);
 const char * sym_get_string_value(struct symbol *sym);
 
scripts/kconfig/symbol.c +19 -7
index a3af93aaaf32..89b84bf8e21f 100644
@@ -70,6 +70,24 @@ const char *sym_type_name(enum symbol_type type)
 	return "???";
 }
 
+/**
+ * sym_get_prompt_menu - get the menu entry with a prompt
+ *
+ * @sym: a symbol pointer
+ *
+ * Return: the menu entry with a prompt.
+ */
+struct menu *sym_get_prompt_menu(const struct symbol *sym)
+{
+	struct menu *m;
+
+	list_for_each_entry(m, &sym->menus, link)
+		if (m->prompt)
+			return m;
+
+	return NULL;
+}
+
 /**
  * sym_get_choice_menu - get the parent choice menu if present
  *
@@ -80,18 +98,12 @@ const char *sym_type_name(enum symbol_type type)
 struct menu *sym_get_choice_menu(const struct symbol *sym)
 {
 	struct menu *menu = NULL;
-	struct menu *m;
 
 	/*
 	 * Choice members must have a prompt. Find a menu entry with a prompt,
 	 * and assume it resides inside a choice block.
 	 */
-	list_for_each_entry(m, &sym->menus, link)
-		if (m->prompt) {
-			menu = m;
-			break;
-		}
-
+	menu = sym_get_prompt_menu(sym);
 	if (!menu)
 		return NULL;
 
Signature · 1 line
2.43.0
#11 lore raw

PATCH 12/13 kconfig: qconf: refactor ConfigInfoView::clicked()

In reply to Masahiro Yamada

Most of the code in ConfigInfoView::clicked() is unnecessary. There is no need to use the regular expression to search for a symbol. Calling sym_find() is simpler and faster.

The hyperlink always begins with the "s" tag, and there is no other tag used. Remove it.

---

 scripts/kconfig/qconf.cc | 43 ++++++----------------------------------
 1 file changed, 6 insertions(+), 37 deletions(-)
scripts/kconfig/qconf.cc +6 -37
index a208ef33128f..f59a9597f09b 100644
@@ -1001,7 +1001,7 @@ void ConfigInfoView::menuInfo(void)
 			if (sym->name) {
 				stream << " (";
 				if (showDebug())
-					stream << "<a href=\"s" << sym->name << "\">";
+					stream << "<a href=\"" << sym->name << "\">";
 				stream << print_filter(sym->name);
 				if (showDebug())
 					stream << "</a>";
@@ -1010,7 +1010,7 @@ void ConfigInfoView::menuInfo(void)
 		} else if (sym->name) {
 			stream << "<big><b>";
 			if (showDebug())
-				stream << "<a href=\"s" << sym->name << "\">";
+				stream << "<a href=\"" << sym->name << "\">";
 			stream << print_filter(sym->name);
 			if (showDebug())
 				stream << "</a>";
@@ -1124,7 +1124,7 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
 	QTextStream *stream = reinterpret_cast<QTextStream *>(data);
 
 	if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
-		*stream << "<a href=\"s" << sym->name << "\">";
+		*stream << "<a href=\"" << sym->name << "\">";
 		*stream << print_filter(str);
 		*stream << "</a>";
 	} else {
@@ -1134,39 +1134,11 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
 
 void ConfigInfoView::clicked(const QUrl &url)
 {
-	QByteArray str = url.toEncoded();
-	const std::size_t count = str.size();
-	char *data = new char[count + 2];  // '$' + '\0'
-	struct symbol **result;
-	struct menu *m = NULL;
+	struct menu *m;
 
-	if (count < 1) {
-		delete[] data;
-		return;
-	}
-
-	memcpy(data, str.constData(), count);
-	data[count] = '\0';
-
-	/* Seek for exact match */
-	data[0] = '^';
-	strcat(data, "$");
-	result = sym_re_search(data);
-	if (!result) {
-		delete[] data;
-		return;
-	}
-
-	sym = *result;
-
-	/* Seek for the menu which holds the symbol */
-	for (struct property *prop = sym->prop; prop; prop = prop->next) {
-		    if (prop->type != P_PROMPT && prop->type != P_MENU)
-			    continue;
-		    m = prop->menu;
-		    break;
-	}
+	sym = sym_find(url.toEncoded().constData());
 
+	m = sym_get_prompt_menu(sym);
 	if (!m) {
 		/* Symbol is not visible as a menu */
 		symbolInfo();
@@ -1174,9 +1146,6 @@ void ConfigInfoView::clicked(const QUrl &url)
 	} else {
 		emit menuSelected(m);
 	}
-
-	free(result);
-	delete[] data;
 }
 
 void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
Signature · 1 line
2.43.0
#12 lore raw

PATCH 13/13 kconfig: qconf: remove unnecessary mode check in ConfigItem::updateMenu()

In reply to Masahiro Yamada

The P_MENU entries ("menu" and "menuconfig") are never displayed in symbolMode.

The condition, list->mode == symbolMode, is never met here.

---

 scripts/kconfig/qconf.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/qconf.cc +1 -1
index f59a9597f09b..6c92ef1e16ef 100644
@@ -110,7 +110,7 @@ void ConfigItem::updateMenu(void)
 
 	if (prop) switch (prop->type) {
 	case P_MENU:
-		if (list->mode == singleMode || list->mode == symbolMode) {
+		if (list->mode == singleMode) {
 			/* a menuconfig entry is displayed differently
 			 * depending whether it's at the view root or a child.
 			 */
Signature · 1 line
2.43.0