• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

backgroundlistmodel.h

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
00003 
00004   This program is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008 */
00009 
00010 #ifndef BACKGROUNDLISTMODEL_H
00011 #define BACKGROUNDLISTMODEL_H
00012 
00013 #include <QAbstractListModel>
00014 #include <QPixmap>
00015 
00016 #include <KDirWatch>
00017 #include <KFileItem>
00018 
00019 #include <Plasma/Wallpaper>
00020 
00021 class QEventLoop;
00022 class KProgressDialog;
00023 
00024 namespace Plasma
00025 {
00026     class Package;
00027 } // namespace Plasma
00028 
00029 class BackgroundListModel : public QAbstractListModel
00030 {
00031     Q_OBJECT
00032 
00033 public:
00034     BackgroundListModel(float ratio, Plasma::Wallpaper *listener, QObject *parent);
00035     virtual ~BackgroundListModel();
00036 
00037     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00038     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00039     Plasma::Package *package(int index) const;
00040 
00041     void reload();
00042     void reload(const QStringList &selected);
00043     void addBackground(const QString &path);
00044     QModelIndex indexOf(const QString &path) const;
00045     virtual bool contains(const QString &bg) const;
00046 
00047     static QStringList findAllBackgrounds(Plasma::Wallpaper *structureParent,
00048                                                        const BackgroundListModel *container,
00049                                                        const QStringList &path);
00050     static void initProgressDialog(KProgressDialog *dialog);
00051 
00052     void setWallpaperSize(QSize size);
00053     void setResizeMethod(Plasma::Wallpaper::ResizeMethod resizeMethod);
00054 
00055 protected Q_SLOTS:
00056     void removeBackground(const QString &path);
00057     void showPreview(const KFileItem &item, const QPixmap &preview);
00058     void previewFailed(const KFileItem &item);
00059 
00060 private:
00061     QSize bestSize(Plasma::Package *package) const;
00062 
00063     Plasma::Wallpaper *m_listener;
00064     Plasma::Wallpaper *m_structureParent;
00065     QList<Plasma::Package *> m_packages;
00066     QHash<Plasma::Package *, QSize> m_sizeCache;
00067     QHash<Plasma::Package *, QPixmap> m_previews;
00068     QHash<KUrl, QPersistentModelIndex> m_previewJobs;
00069     float m_ratio;
00070     KDirWatch m_dirwatch;
00071 
00072     QSize m_size;
00073     Plasma::Wallpaper::ResizeMethod m_resizeMethod;
00074 };
00075 
00076 class BackgroundFinder : public QObject
00077 {
00078     Q_OBJECT
00079 
00080 public:
00081     BackgroundFinder(Plasma::Wallpaper *structureParent,
00082                      const BackgroundListModel *container,
00083                      const QStringList &p,
00084                      QEventLoop *eventLoop);
00085 
00086     QStringList papersFound() const;
00087 
00088 public slots:
00089     void start();
00090 
00091 signals:
00092     void finished();
00093 
00094 private:
00095     Plasma::Wallpaper *m_structureParent;
00096     const BackgroundListModel *m_container;
00097     QStringList m_paths;
00098     QStringList m_papersFound;
00099     QEventLoop *m_eventLoop;
00100 };
00101 
00102 #endif // BACKGROUNDLISTMODEL_H

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •     Animators
  •     Applets
  •     Engines
  • Solid Modules
  • System Settings
  •   SystemSettingsView
Generated for API Reference by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal