diff --git a/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.cpp b/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.cpp index 5acf7536..49195cea 100644 --- a/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.cpp +++ b/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.cpp @@ -13,35 +13,19 @@ #include #include -#include #include - #include #include #include #include #include #include - #include #include #include "backgrounddelegate.h" #include "virus.h" -ImageSizeFinder::ImageSizeFinder(const QString &path, QObject *parent) - : QObject(parent), - m_path(path) -{ -} - -void ImageSizeFinder::run() -{ - QImage image(m_path); - emit sizeFound(m_path, image.size()); -} - - BackgroundListModel::BackgroundListModel(Plasma::Wallpaper *listener, QObject *parent) : QAbstractListModel(parent), m_structureParent(listener), @@ -174,26 +158,16 @@ QSize BackgroundListModel::bestSize(Plasma::Package *package) const QSize size = imagereader.size(); // backup solution if image handler does not provide size option if (size.width() == 0 || size.height() == 0) { - // kDebug() << "fall back to ImageSizeFinder"; - ImageSizeFinder *finder = new ImageSizeFinder(image); - connect(finder, SIGNAL(sizeFound(QString,QSize)), this, - SLOT(sizeFound(QString,QSize))); - QThreadPool::globalInstance()->start(finder); - size = QSize(-1, -1); + size = imagereader.read().size(); } + m_sizeCache.insert(package, size); - const_cast(this)->m_sizeCache.insert(package, size); - return size; -} - -void BackgroundListModel::sizeFound(const QString &path, const QSize &s) -{ - QModelIndex index = indexOf(path); + QModelIndex index = indexOf(image); if (index.isValid()) { - Plasma::Package *package = m_packages.at(index.row()); - m_sizeCache.insert(package, s); static_cast(m_structureParent)->updateScreenshot(index); } + + return size; } QVariant BackgroundListModel::data(const QModelIndex &index, int role) const diff --git a/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.h b/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.h index 8ce29bdb..a147b8ae 100644 --- a/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.h +++ b/kdeplasma-addons/wallpapers/virus/backgroundlistmodel.h @@ -28,20 +28,6 @@ namespace Plasma class Package; } // namespace Plasma -class ImageSizeFinder : public QObject, public QRunnable -{ - Q_OBJECT - public: - ImageSizeFinder(const QString &path, QObject *parent = 0); - void run(); - - Q_SIGNALS: - void sizeFound(const QString &path, const QSize &size); - - private: - QString m_path; -}; - class BackgroundListModel : public QAbstractListModel { Q_OBJECT @@ -66,7 +52,6 @@ protected Q_SLOTS: void reload(); void showPreview(const KFileItem &item, const QPixmap &preview); void previewFailed(const KFileItem &item); - void sizeFound(const QString &path, const QSize &s); void processPaths(const QStringList &paths); private: @@ -74,7 +59,7 @@ private: Plasma::Wallpaper *m_structureParent; QList m_packages; - QHash m_sizeCache; + mutable QHash m_sizeCache; QHash m_previews; QHash m_previewJobs; KDirWatch m_dirwatch;