[education/rkward] /: Some tweaks to object tool tips

Thomas Friedrichsmeier null at kde.org
Sat Jun 18 22:13:50 BST 2022


Git commit 40179ed1ca99d17f460d19b7e24b6c24694e9c5d by Thomas Friedrichsmeier.
Committed on 18/06/2022 at 21:13.
Pushed by tfry into branch 'master'.

Some tweaks to object tool tips

M  +1    -0    ChangeLog
M  +2    -1    rkward/core/rkmodificationtracker.cpp
M  +3    -6    rkward/core/robject.cpp
M  +1    -1    rkward/robjectviewer.cpp
M  +2    -2    rkward/windows/rktexthints.cpp

https://invent.kde.org/education/rkward/commit/40179ed1ca99d17f460d19b7e24b6c24694e9c5d

diff --git a/ChangeLog b/ChangeLog
index 511b20b8..aa5a2d91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 - Provide tooltips on symbols in scripts and R console
+  - TODO: make configurable
 - Fixed: Expresssions spanning several lines would not be shown, correctly, in "R Console"-mode script preview
 - Fix focus problems, and better efficiency for data previews (as used in data import dialogs)
 - Fixed: Excel import plugin failed to accept file name
diff --git a/rkward/core/rkmodificationtracker.cpp b/rkward/core/rkmodificationtracker.cpp
index 869c4c35..e06ef336 100644
--- a/rkward/core/rkmodificationtracker.cpp
+++ b/rkward/core/rkmodificationtracker.cpp
@@ -334,7 +334,8 @@ QVariant RKObjectListModel::data (const QModelIndex& index, int role) const {
 	} else if (role == Qt::DecorationRole) {
 		if (col == NameColumn) return RKStandardIcons::iconForObject (object);
 	} else if (role == Qt::ToolTipRole) {
-		return object->getObjectDescription ();
+		QString ret = QString("<i>") + object->getShortName().replace('<', "<") + "</i><br>" + object->getObjectDescription();
+		return ret;
 	}
 
 	RK_ASSERT (col < columnCount ());
diff --git a/rkward/core/robject.cpp b/rkward/core/robject.cpp
index 2c3b6e61..842fbfad 100644
--- a/rkward/core/robject.cpp
+++ b/rkward/core/robject.cpp
@@ -158,9 +158,7 @@ QString RObject::getObjectDescription () const {
 
 #define ESCS replace ('<', "<")
 
-	QString ret;
-	ret.append ("<i>" + getShortName ().ESCS + "</i>");
-	ret.append ("<br><b>" + i18n ("Full location:") + " </b>" + getFullName ().ESCS);
+	QString ret = "<b>" + i18n("Full location:") + " </b>" + getFullName().ESCS;
 	QString lab = getLabel ();
 	if (!lab.isEmpty ()) ret.append ("<br><b>" + i18n ("Label:") + " </b>" + lab.ESCS);
 	ret.append ("<br><b>" + i18n ("Type:") + " </b>");
@@ -177,8 +175,7 @@ QString RObject::getObjectDescription () const {
 	} else if (isType (List)) {
 		ret.append (i18n ("List"));
 	} else if (isType (Variable)) {
-		ret.append (i18n ("Variable"));
-		ret.append ("<br><b>" + i18n ("Data Type:") + " </b>" + typeToText (getDataType ()));
+		ret.append(i18nc("Noun; in brackets, data type of the var is stated", "Variable (%1)", typeToText(getDataType())));
 	} else if (isType (Environment)) {
 		ret.append (i18n ("Environment"));
 	}
@@ -195,7 +192,7 @@ QString RObject::getObjectDescription () const {
 		}
 	}
 
-	ret.append ("<br><b>" + i18n ("Class(es):") + " </b>" + makeClassString (",").ESCS);
+	if (!isType(Function)) ret.append("<br><b>" + i18n("Class(es):") + " </b>" + makeClassString(",").ESCS);
 
 	return ret;
 }
diff --git a/rkward/robjectviewer.cpp b/rkward/robjectviewer.cpp
index 48c3f489..06e3f6fa 100644
--- a/rkward/robjectviewer.cpp
+++ b/rkward/robjectviewer.cpp
@@ -121,7 +121,7 @@ void RObjectViewer::initDescription (bool notify) {
 
 	setCaption (i18n("Object Viewer: %1", _object->getShortName ()));
 	// make the description use less height. Trying to specify <nobr>s, here, is no good idea (see http://sourceforge.net/p/rkward/bugs/55/)
-	description_label->setText (_object->getObjectDescription ().replace ("<br>", "    "));
+	description_label->setText("<i>" + _object->getShortName().replace('<', "<") + "</i>   " + _object->getObjectDescription ().replace ("<br>", "    "));
 	if (notify) {
 		QString reason = i18n ("The object was changed. You may want to click \"Update\"");
 		summary_widget->invalidate (reason);
diff --git a/rkward/windows/rktexthints.cpp b/rkward/windows/rktexthints.cpp
index aecfbf14..67b81417 100644
--- a/rkward/windows/rktexthints.cpp
+++ b/rkward/windows/rktexthints.cpp
@@ -30,10 +30,10 @@ RKTextHints::~RKTextHints() {
 QString RKTextHints::textHint(KTextEditor::View *view, const KTextEditor::Cursor &position) {
 	RK_TRACE(COMMANDEDITOR);
 	QString line = view->document()->line(position.line()) + ' ';
-	QString symbol = RKCommonFunctions::getCurrentSymbol(line, position.column());
+	QString symbol = RKCommonFunctions::getCurrentSymbol(line, position.column(), false);
 	auto obj = RObjectList::getObjectList()->findObject(symbol);
 	if (obj) {
-		return i18n("Symbol <i>%1</i> might refer to: ", symbol) + obj->getObjectDescription();
+		return i18n("The name <i>%1</i> might refer to:<br>", symbol) + obj->getObjectDescription();
 	}
 	return QString();
 }


More information about the rkward-tracker mailing list