[Tux4kids-commits] r1151 - tux4kids-admin/trunk/tux4kids-admin/src
Michał Świtakowski
swistakers-guest at alioth.debian.org
Mon Jul 6 22:03:25 UTC 2009
Author: swistakers-guest
Date: 2009-07-06 22:03:24 +0000 (Mon, 06 Jul 2009)
New Revision: 1151
Modified:
tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp
tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h
tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp
tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h
Log:
dynamic loading/unloading plugins in gui
Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp 2009-07-06 21:43:36 UTC (rev 1150)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.cpp 2009-07-06 22:03:24 UTC (rev 1151)
@@ -28,6 +28,7 @@
} else {
result += " (not loaded)";
}
+ return result;
}
return QVariant();
@@ -51,7 +52,6 @@
plugins.append(pluginLoader);
delete pluginInterface;
pluginLoader->unload();
- delete pluginLoader;
}
}
}
@@ -67,13 +67,17 @@
m_pluginsPath = pluginsPath;
}
-bool PluginManager::load(int index)
+bool PluginManager::load(int pluginIndex)
{
- return plugins.at(index)->load();
+ bool result = plugins.at(pluginIndex)->load();
+ emit dataChanged(index(pluginIndex, 0), index(pluginIndex, 0));
+ return result;
}
-bool PluginManager::unload(int index)
+bool PluginManager::unload(int pluginIndex)
{
- return plugins.at(index)->unload();
+ bool result = plugins.at(pluginIndex)->unload();
+ emit dataChanged(index(pluginIndex, 0), index(pluginIndex, 0));
+ return result;
}
Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h 2009-07-06 21:43:36 UTC (rev 1150)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManager.h 2009-07-06 22:03:24 UTC (rev 1151)
@@ -20,8 +20,8 @@
bool empty() const;
void loadPlugins();
void setPluginsPath(QString pluginsPath);
- bool load(int index);
- bool unload(int index);
+ bool load(int pluginIndex);
+ bool unload(int pluginIndex);
private:
QString m_pluginsPath;
Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp 2009-07-06 21:43:36 UTC (rev 1150)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.cpp 2009-07-06 22:03:24 UTC (rev 1151)
@@ -1,10 +1,16 @@
#include "pluginManagerDialog.h"
#include "ui_pluginManagerDialog.h"
-PluginManagerDialog::PluginManagerDialog(PluginManager *newPluginManager, QWidget *parent) : QDialog(parent), m_ui(new Ui::PluginManagerDialog)
+PluginManagerDialog::PluginManagerDialog(PluginManager *pluginManager, QWidget *parent) : QDialog(parent), m_ui(new Ui::PluginManagerDialog)
{
m_ui->setupUi(this);
- m_ui->pluginsList->setModel(newPluginManager);
+
+ m_pluginManager = pluginManager;
+
+ m_ui->pluginsList->setModel(m_pluginManager);
+
+ connect(m_ui->loadButton, SIGNAL(clicked()), this, SLOT(loadClicked()));
+ connect(m_ui->unloadButton, SIGNAL(clicked()), this, SLOT(unloadClicked()));
}
PluginManagerDialog::~PluginManagerDialog()
@@ -23,3 +29,20 @@
break;
}
}
+
+void PluginManagerDialog::loadClicked()
+{
+ int index = m_ui->pluginsList->selectionModel()->selectedIndexes().first().row();
+ if (!m_pluginManager->load(index)) {
+ //report error
+ }
+}
+
+void PluginManagerDialog::unloadClicked()
+{
+ int index = m_ui->pluginsList->selectionModel()->selectedIndexes().first().row();
+ if (!m_pluginManager->unload(index)) {
+ //report error
+ }
+}
+
Modified: tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h
===================================================================
--- tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h 2009-07-06 21:43:36 UTC (rev 1150)
+++ tux4kids-admin/trunk/tux4kids-admin/src/pluginManagerDialog.h 2009-07-06 22:03:24 UTC (rev 1151)
@@ -22,7 +22,12 @@
private:
Ui::PluginManagerDialog *m_ui;
+ PluginManager *m_pluginManager;
+private slots:
+ void loadClicked();
+ void unloadClicked();
+
};
#endif // PLUGINMANAGERDIALOG_H
More information about the Tux4kids-commits
mailing list