[rkward-cvs] [rkward/development/plugin_management_to_loadlibs] rkward: Start moving pluginmap management to R package dialog
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Dec 29 21:56:26 UTC 2014
Git commit 8691f363bd8810aed4bd07032633b3894c31165d by Thomas Friedrichsmeier.
Committed on 29/12/2014 at 21:51.
Pushed by tfry into branch 'development/plugin_management_to_loadlibs'.
Start moving pluginmap management to R package dialog
M +42 -1 rkward/dialogs/rkloadlibsdialog.cpp
M +18 -0 rkward/dialogs/rkloadlibsdialog.h
M +1 -1 rkward/plugin/rkcomponentmap.h
M +1 -1 rkward/plugins/embedded.pluginmap
M +1 -1 rkward/plugins/menu.pluginmap
M +30 -11 rkward/settings/rksettingsmoduleplugins.cpp
M +3 -1 rkward/settings/rksettingsmoduleplugins.h
http://commits.kde.org/rkward/8691f363bd8810aed4bd07032633b3894c31165d
diff --git a/rkward/dialogs/rkloadlibsdialog.cpp b/rkward/dialogs/rkloadlibsdialog.cpp
index 73d8c16..14c39af 100644
--- a/rkward/dialogs/rkloadlibsdialog.cpp
+++ b/rkward/dialogs/rkloadlibsdialog.cpp
@@ -72,9 +72,11 @@ RKLoadLibsDialog::RKLoadLibsDialog (QWidget *parent, RCommandChain *chain, bool
setButtonText (KDialog::User1, i18n ("Configure Repositories"));
+ addPage (new RKPluginMapSelectionWidget (this), i18n ("Manage Plugins"));
+
connect (this, SIGNAL (currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)), this, SLOT (slotPageChanged()));
QTimer::singleShot (0, this, SLOT (slotPageChanged()));
- num_child_widgets = 3;
+ num_child_widgets = 4;
accepted = false;
RKGlobals::rInterface ()->issueCommand (".libPaths ()", RCommand::App | RCommand::GetStringVector, QString (), this, GET_CURRENT_LIBLOCS_COMMAND, chain);
@@ -1195,6 +1197,45 @@ void RKRPackageInstallationStatusSortFilterModel::setRKWardOnly (bool only) {
if (rkward_only != old_only) invalidate ();
}
+/////////////////////////
+#include "../misc/multistringselector.h"
+RKPluginMapSelectionWidget::RKPluginMapSelectionWidget (RKLoadLibsDialog* dialog) : QWidget (dialog) {
+ RK_TRACE (DIALOGS);
+ model = 0;
+
+ QVBoxLayout *vbox = new QVBoxLayout (this);
+ vbox->setContentsMargins (0, 0, 0, 0);
+ vbox->addWidget (new QLabel (i18n ("Installed plugin groups (.pluginmap files)"), this));
+ selector = new RKMultiStringSelectorV2 (QString (), this);
+ vbox->addWidget (selector);
+}
+
+RKPluginMapSelectionWidget::~RKPluginMapSelectionWidget () {
+ RK_TRACE (DIALOGS);
+}
+
+void RKPluginMapSelectionWidget::activated () {
+ RK_TRACE (DIALOGS);
+
+ if (!model) {
+ model = new RKSettingsModulePluginsModel (this);
+ model->init (RKSettingsModulePlugins::knownPluginmaps ());
+ selector->setModel (model, 1);
+ }
+}
+
+void RKPluginMapSelectionWidget::apply () {
+
+}
+
+void RKPluginMapSelectionWidget::cancel () {
+
+}
+
+void RKPluginMapSelectionWidget::ok () {
+
+}
+
#include "rkloadlibsdialog.moc"
diff --git a/rkward/dialogs/rkloadlibsdialog.h b/rkward/dialogs/rkloadlibsdialog.h
index c5b79d4..55af834 100644
--- a/rkward/dialogs/rkloadlibsdialog.h
+++ b/rkward/dialogs/rkloadlibsdialog.h
@@ -283,4 +283,22 @@ private:
QCheckBox *suggested_packages;
};
+
+#include "../settings/rksettingsmoduleplugins.h"
+
+class RKPluginMapSelectionWidget : public QWidget {
+Q_OBJECT
+public:
+ RKPluginMapSelectionWidget (RKLoadLibsDialog *dialog);
+ virtual ~RKPluginMapSelectionWidget ();
+public slots:
+ void ok ();
+ void apply ();
+ void cancel ();
+ void activated ();
+private:
+ RKMultiStringSelectorV2* selector;
+ RKSettingsModulePluginsModel* model;
+};
+
#endif
diff --git a/rkward/plugin/rkcomponentmap.h b/rkward/plugin/rkcomponentmap.h
index 98e02c2..1c3f0d1 100644
--- a/rkward/plugin/rkcomponentmap.h
+++ b/rkward/plugin/rkcomponentmap.h
@@ -37,7 +37,7 @@ public:
QList<RKComponentDependency> getDependencies () const { return dependencies; };
static QString parseId (const QDomElement &e, XMLHelper &xml);
const RKMessageCatalog *messageCatalog () const { return catalog; };
- // Get the about data for this pluginmap.
+ /** Get the about data for this pluginmap. */
RKComponentAboutData getAboutData ();
private:
friend class RKComponentMap;
diff --git a/rkward/plugins/embedded.pluginmap b/rkward/plugins/embedded.pluginmap
index f0d0cdb..9956dc3 100644
--- a/rkward/plugins/embedded.pluginmap
+++ b/rkward/plugins/embedded.pluginmap
@@ -1,6 +1,6 @@
<!DOCTYPE rkpluginmap>
-<document base_prefix="" namespace="rkward" id="embedded">
+<document base_prefix="" namespace="rkward" id="embedded" priority="hidden">
<include file="pluginmap_meta.inc"/>
<require file="menu.pluginmap"/>
diff --git a/rkward/plugins/menu.pluginmap b/rkward/plugins/menu.pluginmap
index ff33602..555d17f 100644
--- a/rkward/plugins/menu.pluginmap
+++ b/rkward/plugins/menu.pluginmap
@@ -1,6 +1,6 @@
<!DOCTYPE rkpluginmap>
<!-- The point of this pluginmap is to pre-define the layout (and labels) of some menus -->
-<document base_prefix="" namespace="rkward" id="rkward_menu_hierarchy">
+<document base_prefix="" namespace="rkward" id="rkward_menu_hierarchy" priority="hidden">
<include file="pluginmap_meta.inc"/>
<hierarchy>
<!-- Define a group before and after each top-level menu to allow inserting top-level menus at defined positions -->
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index f0b48ee..97e729a 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -352,10 +352,7 @@ void RKSettingsModulePlugins::fixPluginMapLists () {
}
if (inf.id.isEmpty ()) {
- XMLHelper xml (inf.filename);
- QDomElement de = xml.openXMLFile (DL_WARNING);
- inf.id = RKPluginMapFile::parseId (de, xml);
- inf.priority = xml.getMultiChoiceAttribute (de, "priority", "hidden;low;medium;high", (int) PriorityMedium, DL_WARNING);
+ parsePluginMapBasics (inf.filename, &inf.id, &inf.priority);
}
}
@@ -372,6 +369,17 @@ void RKSettingsModulePlugins::fixPluginMapLists () {
}
}
+void RKSettingsModulePlugins::parsePluginMapBasics (const QString &filename, QString *id, int *priority) {
+ RK_TRACE (SETTINGS);
+ RK_ASSERT (id);
+ RK_ASSERT (priority);
+
+ XMLHelper xml (filename);
+ QDomElement de = xml.openXMLFile (DL_WARNING);
+ *id = RKPluginMapFile::parseId (de, xml);
+ *priority = xml.getMultiChoiceAttribute (de, "priority", "hidden;low;medium;high", (int) PriorityMedium, DL_WARNING);
+}
+
QStringList RKSettingsModulePlugins::findPluginMapsRecursive (const QString &basedir) {
RK_TRACE (SETTINGS);
@@ -393,7 +401,7 @@ QStringList RKSettingsModulePlugins::findPluginMapsRecursive (const QString &bas
return ret;
}
-RKSettingsModulePluginsModel::RKSettingsModulePluginsModel (RKSettingsModulePlugins* parent) : QAbstractTableModel (parent) {
+RKSettingsModulePluginsModel::RKSettingsModulePluginsModel (QObject* parent) : QAbstractTableModel (parent) {
RK_TRACE (SETTINGS);
}
@@ -417,9 +425,10 @@ int RKSettingsModulePluginsModel::rowCount (const QModelIndex& parent) const {
}
#define COLUMN_CHECKED 0
-#define COLUMN_FILENAME 1
-#define COLUMN_STATUS 2
-#define COLUMN_COUNT 3
+#define COLUMN_TITLE 1
+#define COLUMN_ID 2
+#define COLUMN_STATUS 3
+#define COLUMN_COUNT 4
int RKSettingsModulePluginsModel::columnCount (const QModelIndex& parent) const {
// RK_TRACE (SETTINGS);
@@ -444,6 +453,7 @@ QVariant RKSettingsModulePluginsModel::data (const QModelIndex& index, int role)
if (!meta.dependencies.isEmpty ()) {
desc.append ("<b>" + i18n ("Dependencies") + "</b>");
desc.append (RKComponentDependency::depsToHtml (meta.dependencies));
+ desc.append ("<p>" + inf.filename + "</p>");
}
return desc;
}
@@ -452,8 +462,15 @@ QVariant RKSettingsModulePluginsModel::data (const QModelIndex& index, int role)
if (role == Qt::CheckStateRole) {
return (inf.active ? Qt::Checked : Qt::Unchecked);
}
- } else if (col == COLUMN_FILENAME) {
- if (role == Qt::DisplayRole) return inf.filename;
+ } else if (col == COLUMN_ID) {
+ if (role == Qt::DisplayRole) {
+ return inf.id;
+ }
+ } else if (col == COLUMN_TITLE) {
+ if (role == Qt::DisplayRole) {
+ const PluginMapMetaInfo &meta = const_cast<RKSettingsModulePluginsModel*> (this)->getPluginMapMetaInfo (inf.filename);
+ return meta.about->name;
+ }
} else if (col == COLUMN_STATUS) {
if (role == Qt::DisplayRole) {
if (inf.broken_in_this_version) return i18n ("Broken");
@@ -481,7 +498,8 @@ QVariant RKSettingsModulePluginsModel::headerData (int section, Qt::Orientation
// RK_TRACE (SETTINGS);
if ((role == Qt::DisplayRole) && (orientation == Qt::Horizontal)) {
if (section == COLUMN_CHECKED) return i18n ("Active");
- if (section == COLUMN_FILENAME) return i18n ("Filename");
+ if (section == COLUMN_ID) return i18n ("ID");
+ if (section == COLUMN_TITLE) return i18n ("Title");
if (section == COLUMN_STATUS) return i18n ("Status");
RK_ASSERT (false);
}
@@ -523,6 +541,7 @@ void RKSettingsModulePluginsModel::insertNewStrings (int above_row) {
for (int i = files.size () - 1; i >= 0; --i) {
RKSettingsModulePlugins::PluginMapStoredInfo inf (files[i]);
inf.active = true;
+ RKSettingsModulePlugins::parsePluginMapBasics (files[i], &(inf.id), &(inf.priority));
plugin_maps.insert (above_row, inf);
}
endInsertRows ();
diff --git a/rkward/settings/rksettingsmoduleplugins.h b/rkward/settings/rksettingsmoduleplugins.h
index a22d23e..b37078a 100644
--- a/rkward/settings/rksettingsmoduleplugins.h
+++ b/rkward/settings/rksettingsmoduleplugins.h
@@ -80,6 +80,8 @@ public:
QDateTime last_modified;
};
typedef QList<PluginMapStoredInfo> PluginMapList;
+ static PluginMapList knownPluginmaps () { return known_plugin_maps; };
+ static void parsePluginMapBasics (const QString &filename, QString *id, int *priority);
public slots:
void settingChanged ();
private:
@@ -106,7 +108,7 @@ private:
class RKSettingsModulePluginsModel : public QAbstractTableModel {
Q_OBJECT
public:
- RKSettingsModulePluginsModel (RKSettingsModulePlugins* parent);
+ RKSettingsModulePluginsModel (QObject* parent);
virtual ~RKSettingsModulePluginsModel ();
/** (re-)initialize the model */
void init (const RKSettingsModulePlugins::PluginMapList &known_plugin_maps);
More information about the rkward-tracker
mailing list