[Kst] branches/work/kst/portto4/kst/src
Peter Kümmel
syntheticpp at gmx.net
Mon Jan 10 14:46:13 CET 2011
SVN commit 1213473 by kuemmel:
fix broken debug dialog: show datasource plugin path
M +38 -12 libkst/datasourcepluginmanager.cpp
M +2 -1 libkst/datasourcepluginmanager.h
M +7 -15 libkstapp/debugdialog.cpp
--- branches/work/kst/portto4/kst/src/libkst/datasourcepluginmanager.cpp #1213472:1213473
@@ -60,7 +60,23 @@
+
+struct FoundPlugin
+{
+ FoundPlugin(const SharedPtr<PluginInterface>& plug, const QString& path) :
+ plugin(plug),
+ filePath(path)
+ {}
+
+ SharedPtr<PluginInterface> plugin;
+ // TODO add filepath to PluginInterface
+ QString filePath;
+};
+
+typedef QList<FoundPlugin> PluginList;
static PluginList _pluginList;
+
+
void DataSourcePluginManager::cleanupForExit() {
_pluginList.clear();
qDebug() << "cleaning up for exit in datasource";
@@ -116,7 +132,7 @@
foreach (QObject *plugin, QPluginLoader::staticInstances()) {
//try a cast
if (DataSourcePluginInterface *ds = dynamic_cast<DataSourcePluginInterface*>(plugin)) {
- tmpList.append(ds);
+ tmpList.append(FoundPlugin(ds, ""));
}
}
@@ -138,7 +154,7 @@
pluginPath += QLatin1String("PlugIns");
pluginPaths << pluginPath;
- foreach (QString pluginPath, pluginPaths) {
+ foreach (const QString& pluginPath, pluginPaths) {
QDir d(pluginPath);
foreach (QString fileName, d.entryList(QDir::Files)) {
#ifdef Q_OS_WIN
@@ -149,7 +165,8 @@
QObject *plugin = loader.instance();
if (plugin) {
if (DataSourcePluginInterface *ds = dynamic_cast<DataSourcePluginInterface*>(plugin)) {
- tmpList.append(ds);
+
+ tmpList.append(FoundPlugin(ds, d.absoluteFilePath(fileName)));
Debug::self()->log(QString("Plugin loaded: %1").arg(fileName));
}
} else {
@@ -172,20 +189,29 @@
QStringList DataSourcePluginManager::pluginList() {
- QStringList plugins;
-
// Ensure state. When using kstapp MainWindow calls init.
init();
+ QStringList plugins;
for (PluginList::ConstIterator it = _pluginList.begin(); it != _pluginList.end(); ++it) {
- plugins += (*it)->pluginName();
+ plugins += (*it).plugin->pluginName();
}
return plugins;
}
+QString DataSourcePluginManager::pluginFileName(const QString& pluginName)
+{
+ for (PluginList::ConstIterator it = _pluginList.begin(); it != _pluginList.end(); ++it) {
+ if (it->plugin->pluginName() == pluginName) {
+ return it->filePath;
+ }
+ }
+ return "not avaolable";
+}
+
int DataSourcePluginManager::PluginSortContainer::operator<(const PluginSortContainer& x) const {
return match > x.match; // yes, this is by design. biggest go first
}
@@ -204,7 +230,7 @@
if (!type.isEmpty()) {
for (PluginList::Iterator it = info.begin(); it != info.end(); ++it) {
- if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).data())) {
+ if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).plugin.data())) {
if (p->provides(type)) {
PluginSortContainer psc;
psc.match = 100;
@@ -218,7 +244,7 @@
for (PluginList::Iterator it = info.begin(); it != info.end(); ++it) {
PluginSortContainer psc;
- if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).data())) {
+ if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).plugin.data())) {
if ((psc.match = p->understands(&settingsObject, filename)) > 0) {
psc.plugin = p;
bestPlugins.append(psc);
@@ -299,7 +325,7 @@
PluginList info = _pluginList;
for (PluginList::Iterator it = info.begin(); it != info.end(); ++it) {
- if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).data())) {
+ if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).plugin.data())) {
if ((p->understands(&settingsObject, filename)) > 0) {
return true;
}
@@ -317,8 +343,8 @@
PluginList info = _pluginList;
for (PluginList::ConstIterator it = info.begin(); it != info.end(); ++it) {
- if ((*it)->pluginName() == plugin) {
- return (*it)->hasConfigWidget();
+ if ((*it).plugin->pluginName() == plugin) {
+ return (*it).plugin->hasConfigWidget();
}
}
@@ -332,7 +358,7 @@
PluginList info = _pluginList;
for (PluginList::Iterator it = info.begin(); it != info.end(); ++it) {
- if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).data())) {
+ if (DataSourcePluginInterface *p = dynamic_cast<DataSourcePluginInterface*>((*it).plugin.data())) {
if (p->pluginName() == plugin) {
return p->configWidget(&settingsObject, QString());
}
--- branches/work/kst/portto4/kst/src/libkst/datasourcepluginmanager.h #1213472:1213473
@@ -26,7 +26,6 @@
class ObjectStore;
-typedef ObjectList<PluginInterface> PluginList;
class KSTCORE_EXPORT DataSourcePluginManager
@@ -42,6 +41,8 @@
/** Returns a list of plugins found on the system. */
static QStringList pluginList();
+ static QString pluginFileName(const QString& pluginName);
+
static SharedPtr<DataSource> loadSource(ObjectStore *store, const QString& filename, const QString& type = QString());
static SharedPtr<DataSource> loadSource(ObjectStore *store, QDomElement& e);
static SharedPtr<DataSource> findOrLoadSource(ObjectStore *store, const QString& filename);
--- branches/work/kst/portto4/kst/src/libkstapp/debugdialog.cpp #1213472:1213473
@@ -80,23 +80,15 @@
void DebugDialog::show() {
Q_ASSERT(_store);
_dataSources->clear();
-
- const QStringList& pl = DataSourcePluginManager::pluginList();
- foreach (QString pluginName, pl) {
- new QTreeWidgetItem(_dataSources, QStringList(pluginName));
+ _dataSources->setColumnCount(2);
+ const QStringList pl = DataSourcePluginManager::pluginList();
+ foreach (const QString& pluginName, pl) {
+ QTreeWidgetItem* name = new QTreeWidgetItem(QStringList() << pluginName);
+ name->setData(1, Qt::DisplayRole, DataSourcePluginManager::pluginFileName(pluginName));
+ _dataSources->insertTopLevelItem (0, name);
}
- QTreeWidgetItemIterator it(_dataSources);
- while (*it) {
- foreach (DataSourcePtr dataSource, _store->dataSourceList()) {
- if (dataSource->sourceName() == (*it)->text(0)) {
- QStringList list(QString::null);
- list += dataSource->fileName();
- new QTreeWidgetItem(*it, list);
- }
- }
- ++it;
- }
+ _dataSources->header()->resizeSections(QHeaderView::ResizeToContents);
QDialog::show();
}
More information about the Kst
mailing list