summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-05-08 13:14:09 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-09 13:40:23 +0200
commit4e4403d69c60ea6429b3ad5e7898a84b1dc92be5 (patch)
tree4d8c3f222412438643fe54508036a452c6967152 /src/widgets
parentb316c3ac5e4acac75505bfd77677cecc181599af (diff)
No longer use deprecated methods for plugin loading.
Change-Id: I19c66b1c41ea4dd236726c86d7d071b210ec9244 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qicon.cpp28
-rw-r--r--src/widgets/kernel/qiconloader.cpp2
-rw-r--r--src/widgets/styles/qstylefactory.cpp17
3 files changed, 29 insertions, 18 deletions
diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp
index 62c99a64c8..9c7f8736f0 100644
--- a/src/widgets/kernel/qicon.cpp
+++ b/src/widgets/kernel/qicon.cpp
@@ -816,10 +816,13 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
QString suffix = info.suffix();
if (!suffix.isEmpty()) {
// first try version 2 engines..
- if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(suffix))) {
- if (QIconEngine *engine = factory->create(fileName)) {
- d = new QIconPrivate;
- d->engine = engine;
+ const int index = loader()->indexOf(suffix);
+ if (index != -1) {
+ if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(index))) {
+ if (QIconEngine *engine = factory->create(fileName)) {
+ d = new QIconPrivate;
+ d->engine = engine;
+ }
}
}
}
@@ -1068,12 +1071,17 @@ QDataStream &operator>>(QDataStream &s, QIcon &icon)
icon.d->engine = engine;
engine->read(s);
#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- } else if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(key))) {
- if (QIconEngine *engine= factory->create()) {
- icon.d = new QIconPrivate;
- icon.d->engine = engine;
- engine->read(s);
- }
+ } else {
+ const int index = loader()->indexOf(key);
+ if (index != -1) {
+ if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(index))) {
+ if (QIconEngine *engine= factory->create()) {
+ icon.d = new QIconPrivate;
+ icon.d->engine = engine;
+ engine->read(s);
+ } // factory
+ } // instance
+ } // index
#endif
}
} else if (s.version() == QDataStream::Qt_4_2) {
diff --git a/src/widgets/kernel/qiconloader.cpp b/src/widgets/kernel/qiconloader.cpp
index 38cee3e51f..acbf7c1d07 100644
--- a/src/widgets/kernel/qiconloader.cpp
+++ b/src/widgets/kernel/qiconloader.cpp
@@ -121,7 +121,7 @@ void QIconLoader::ensureInitialized()
QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterface_iid,
QLatin1String("/iconengines"),
Qt::CaseInsensitive);
- if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
+ if (iconFactoryLoader.keyMap().key(QLatin1String("svg"), -1) != -1)
m_supportsSvg = true;
#endif //QT_NO_LIBRARY
}
diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp
index 9ed452b516..ec29ae7b99 100644
--- a/src/widgets/styles/qstylefactory.cpp
+++ b/src/widgets/styles/qstylefactory.cpp
@@ -181,10 +181,8 @@ QStyle *QStyleFactory::create(const QString& key)
#endif
{ } // Keep these here - they make the #ifdefery above work
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- if(!ret) {
- if (QStyleFactoryInterface *factory = qobject_cast<QStyleFactoryInterface*>(loader()->instance(style)))
- ret = factory->create(style);
- }
+ if (!ret)
+ ret = qLoadPlugin<QStyle, QStyleFactoryInterface>(loader(), style);
#endif
if(ret)
ret->setObjectName(style);
@@ -199,10 +197,15 @@ QStyle *QStyleFactory::create(const QString& key)
*/
QStringList QStyleFactory::keys()
{
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- QStringList list = loader()->keys();
-#else
QStringList list;
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ typedef QMultiMap<int, QString> PluginKeyMap;
+ typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
+
+ const PluginKeyMap keyMap = loader()->keyMap();
+ const PluginKeyMap::const_iterator cend = keyMap.constEnd();
+ for (PluginKeyMap::const_iterator it = keyMap.constBegin(); it != cend; ++it)
+ list.append(it.value());
#endif
#ifndef QT_NO_STYLE_WINDOWS
if (!list.contains(QLatin1String("Windows")))