2
Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
10
#ifndef BACKGROUNDLISTMODEL_H
11
#define BACKGROUNDLISTMODEL_H
13
#include <QAbstractListModel>
21
#include <Plasma/Wallpaper>
24
class KProgressDialog;
31
class ImageSizeFinder : public QObject, public QRunnable
35
ImageSizeFinder(const QString &path, QObject *parent = 0);
39
void sizeFound(const QString &path, const QSize &size);
45
class BackgroundListModel : public QAbstractListModel
50
BackgroundListModel(Plasma::Wallpaper *listener, QObject *parent);
51
virtual ~BackgroundListModel();
53
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
54
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
55
Plasma::Package *package(int index) const;
58
void reload(const QStringList &selected);
59
void addBackground(const QString &path);
60
QModelIndex indexOf(const QString &path) const;
61
virtual bool contains(const QString &bg) const;
63
void setWallpaperSize(const QSize& size);
64
void setResizeMethod(Plasma::Wallpaper::ResizeMethod resizeMethod);
67
void removeBackground(const QString &path);
68
void showPreview(const KFileItem &item, const QPixmap &preview);
69
void previewFailed(const KFileItem &item);
70
void sizeFound(const QString &path, const QSize &s);
71
void backgroundsFound(const QStringList &paths, const QString &token);
72
void processPaths(const QStringList &paths);
75
QSize bestSize(Plasma::Package *package) const;
77
Plasma::Wallpaper *m_structureParent;
78
QList<Plasma::Package *> m_packages;
79
QHash<Plasma::Package *, QSize> m_sizeCache;
80
QHash<Plasma::Package *, QPixmap> m_previews;
81
QHash<KUrl, QPersistentModelIndex> m_previewJobs;
85
Plasma::Wallpaper::ResizeMethod m_resizeMethod;
87
QPixmap m_previewUnavailablePix;
90
class BackgroundFinder : public QThread
95
BackgroundFinder(Plasma::Wallpaper *structureParent, const QStringList &p);
98
QString token() const;
101
void backgroundsFound(const QStringList &paths, const QString &token);
107
Plasma::PackageStructure::Ptr m_structure;
112
#endif // BACKGROUNDLISTMODEL_H