[rkward] rkward: Allow to complete slots as slot(object, member).
Thomas Friedrichsmeier
null at kde.org
Fri Feb 1 09:52:33 GMT 2019
Git commit 489f73a662d6730ab649e3f103f52a43e9543044 by Thomas Friedrichsmeier.
Committed on 01/02/2019 at 09:52.
Pushed by tfry into branch 'master'.
Allow to complete slots as slot(object, member).
Change list-operator default back to the safer [[. See https://mail.kde.org/pipermail/rkward-devel/2019-January/005277.html .
M +3 -0 rkward/core/rkpseudoobjects.cpp
M +1 -0 rkward/core/robject.h
M +12 -1 rkward/settings/rksettingsmodulecommandeditor.cpp
M +1 -0 rkward/settings/rksettingsmodulecommandeditor.h
https://commits.kde.org/rkward/489f73a662d6730ab649e3f103f52a43e9543044
diff --git a/rkward/core/rkpseudoobjects.cpp b/rkward/core/rkpseudoobjects.cpp
index 4e9281fb..cd787b25 100644
--- a/rkward/core/rkpseudoobjects.cpp
+++ b/rkward/core/rkpseudoobjects.cpp
@@ -41,6 +41,9 @@ QString RSlotsPseudoObject::getFullName (int options) const {
QString RSlotsPseudoObject::makeChildName (const QString &short_child_name, bool, int options) const {
RK_TRACE (OBJECTS);
+ if (options & ExplicitSlotsExpansion) {
+ return (QStringLiteral("slot(") + parent->getFullName (options) + QStringLiteral(", ") + rQuote(short_child_name) + ')');
+ }
QString safe_name = short_child_name;
if (irregularShortName (safe_name)) safe_name = rQuote (short_child_name);
return (parent->getFullName (options) + '@' + safe_name);
diff --git a/rkward/core/robject.h b/rkward/core/robject.h
index 91d1fe46..0bb7481a 100644
--- a/rkward/core/robject.h
+++ b/rkward/core/robject.h
@@ -119,6 +119,7 @@ public:
IncludeEnvirIfNotGlobalEnv = 2, /**< Include package name for objects on the search path */
IncludeEnvirForGlobalEnv = 4, /**< Include ".GlobalEnv" for objects inside globalenv */
IncludeEnvirIfMasked = 8, /**< Include package name for objects that are masked (only applicable for object lists, i.e. getFullNames()) */
+ ExplicitSlotsExpansion = 16, /**< Return slots as slot(object, member), intead of object\@member */
NoIncludeEnvir = 0, /**< Label for missing include-envirs */
DefaultObjectNameOptions = IncludeEnvirIfNotGlobalEnv
};
diff --git a/rkward/settings/rksettingsmodulecommandeditor.cpp b/rkward/settings/rksettingsmodulecommandeditor.cpp
index 8f6d5c82..49988939 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.cpp
+++ b/rkward/settings/rksettingsmodulecommandeditor.cpp
@@ -95,6 +95,16 @@ RKSettingsModuleCommandEditor::RKSettingsModuleCommandEditor (RKSettings *gui, Q
box_layout->addWidget (label);
box_layout->addWidget (completion_list_member_operator_box);
+ label = new QLabel (i18nc ("Note: S4-slot() is a programming term in R, and should not be translated, here", "Operator for access to S4-slot()s"));
+ label->setWordWrap (true);
+ completion_slot_operator_box = new QComboBox (group);
+ completion_slot_operator_box->addItem (i18n ("'@'-operator (object at smember)"));
+ completion_slot_operator_box->addItem (i18n ("'slot()'-function (slot(object, member))"));
+ completion_slot_operator_box->setCurrentIndex ((completion_options & RObject::ExplicitSlotsExpansion) ? 1 : 0);
+ connect (completion_slot_operator_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &RKSettingsModuleCommandEditor::settingChanged);
+ box_layout->addWidget (label);
+ box_layout->addWidget (completion_slot_operator_box);
+
label = new QLabel (i18n ("Include environment for objects on the search path:"));
label->setWordWrap (true);
completion_object_qualification_box = new QComboBox (group);
@@ -192,6 +202,7 @@ void RKSettingsModuleCommandEditor::applyChanges () {
arghinting_enabled = arghinting_enabled_box->isChecked ();
completion_options = 0;
if (completion_list_member_operator_box->currentIndex () == 0) completion_options += RObject::DollarExpansion;
+ if (completion_slot_operator_box->currentIndex () == 1) completion_options += RObject::ExplicitSlotsExpansion;
if (completion_object_qualification_box->currentIndex () == 2) completion_options += RObject::IncludeEnvirForGlobalEnv | RObject::IncludeEnvirIfNotGlobalEnv;
else if (completion_object_qualification_box->currentIndex () == 1) completion_options += RObject::IncludeEnvirIfNotGlobalEnv;
else completion_options += RObject::IncludeEnvirIfMasked;
@@ -234,7 +245,7 @@ void RKSettingsModuleCommandEditor::loadSettings (KConfig *config) {
completion_enabled = cg.readEntry ("Completion enabled", true);
completion_min_chars = cg.readEntry ("Completion min chars", 2);
completion_timeout = cg.readEntry ("Completion timeout", 500);
- completion_options = cg.readEntry ("Completion option flags", RObject::DollarExpansion | RObject::IncludeEnvirIfMasked);
+ completion_options = cg.readEntry ("Completion option flags", (int) RObject::IncludeEnvirIfMasked);
arghinting_enabled = cg.readEntry ("Argument hinting enabled", true);
autosave_enabled = cg.readEntry ("Autosave enabled", true);
diff --git a/rkward/settings/rksettingsmodulecommandeditor.h b/rkward/settings/rksettingsmodulecommandeditor.h
index 9cdbfa33..0fbae0c4 100644
--- a/rkward/settings/rksettingsmodulecommandeditor.h
+++ b/rkward/settings/rksettingsmodulecommandeditor.h
@@ -74,6 +74,7 @@ private:
QCheckBox* completion_enabled_box;
QCheckBox* arghinting_enabled_box;
QComboBox* completion_list_member_operator_box;
+ QComboBox* completion_slot_operator_box;
QComboBox* completion_object_qualification_box;
static bool autosave_enabled;
More information about the rkward-tracker
mailing list