Commit 8691f363 authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Start moving pluginmap management to R package dialog

parent b6cd142e
......@@ -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"
......@@ -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
......@@ -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;
......
<!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"/>
......
<!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 -->
......
......@@ -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 ();
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment