[education/labplot] src: [scripting] show the doc string in the completion popup.

Alexander Semke <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 74ff2483c9929606da1439fa0dab9e3b59ca26f8 by Alexander Semke.
Committed on 01/08/2026 at 20:22.
Pushed by asemke into branch 'master'.

[scripting] show the doc string in the completion popup.

M  +1    -1    src/backend/script/python/PythonScriptRuntime.cpp
M  +3    -3    src/backend/script/python/PythonScriptingHelper.h
M  +13   -0    src/frontend/script/ScriptCompletionModel.cpp

https://invent.kde.org/education/labplot/-/commit/74ff2483c9929606da1439fa0dab9e3b59ca26f8

diff --git a/src/backend/script/python/PythonScriptRuntime.cpp b/src/backend/script/python/PythonScriptRuntime.cpp
index c4f9f2f1e3..ab14f238c3 100644
--- a/src/backend/script/python/PythonScriptRuntime.cpp
+++ b/src/backend/script/python/PythonScriptRuntime.cpp
@@ -959,7 +959,7 @@ QList<PylabplotMemberInfo> getPylabplotClassMembersHelper(const QString& classNa
 				continue; // Skip private/special methods
 
 			// Filter out Qt/QObject internal methods that shouldn't be part of the public API
-			// shown in the completion box. For now, the user still will be able to call them, 
+			// shown in the completion box. For now, the user still will be able to call them,
 			// but they won't be suggested in the completion box.
 			// TODO: decide if we want to remove them from the public API completely, if possible,
 			// by filtering them out in the shiboken binding generation.
diff --git a/src/backend/script/python/PythonScriptingHelper.h b/src/backend/script/python/PythonScriptingHelper.h
index 0dcb81c80b..83a5ed4254 100644
--- a/src/backend/script/python/PythonScriptingHelper.h
+++ b/src/backend/script/python/PythonScriptingHelper.h
@@ -16,9 +16,9 @@ struct PylabplotMemberInfo {
 	QString name;
 	bool isMethod;
 	bool isProperty;
-	QString signature;    // For methods: "method(arg1, arg2)"
-	QString docstring;    // Brief documentation
-	QString returnType;   // Return type annotation if available
+	QString signature; // For methods: "method(arg1, arg2)"
+	QString docstring; // Brief documentation
+	QString returnType; // Return type annotation if available
 };
 
 // Helper function to get pylabplot symbols without requiring Python.h
diff --git a/src/frontend/script/ScriptCompletionModel.cpp b/src/frontend/script/ScriptCompletionModel.cpp
index 8b6768292b..5352d1514b 100644
--- a/src/frontend/script/ScriptCompletionModel.cpp
+++ b/src/frontend/script/ScriptCompletionModel.cpp
@@ -236,6 +236,13 @@ QVariant ScriptCompletionModel::data(const QModelIndex& index, int role) const {
 	case Qt::DisplayRole:
 		if (index.column() == Name)
 			return item.name;
+		else if (index.column() == Prefix) {
+			// Show signature or type indicator
+			if (!item.signature.isEmpty())
+				return item.signature;
+			else if (item.isFunction)
+				return QStringLiteral("()");
+		}
 		break;
 
 	case Qt::DecorationRole:
@@ -251,6 +258,12 @@ QVariant ScriptCompletionModel::data(const QModelIndex& index, int role) const {
 				return QIcon::fromTheme(QStringLiteral("code-variable"));
 		}
 		break;
+
+	case ItemSelected:
+		// Show docstring in the status bar or completion widget when item is selected
+		if (!item.docstring.isEmpty())
+			return item.docstring;
+		break;
 	}
 
 	return QVariant();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.