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 <KDirWatch> 00015 00016 class Background; 00017 00018 class BackgroundContainer 00019 { 00020 public: 00021 virtual ~BackgroundContainer() {}; 00022 virtual bool contains(const QString &path) const = 0; 00023 }; 00024 00025 class BackgroundListModel : public QAbstractListModel, public BackgroundContainer 00026 { 00027 public: 00028 BackgroundListModel(float ratio, QObject *listener); 00029 virtual ~BackgroundListModel(); 00030 00031 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; 00032 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 00033 Background* package(int index) const; 00034 00035 void reload(); 00036 void reload(const QStringList &selected); 00037 void addBackground(const QString &path); 00038 int indexOf(const QString &path) const; 00039 void removeBackground(const QString &path); 00040 virtual bool contains(const QString &bg) const; 00041 00042 static QList<Background *> findAllBackgrounds(const BackgroundContainer *container, 00043 const QString &path, float ratio); 00044 00045 private: 00046 QObject *m_listener; 00047 QList<Background*> m_packages; 00048 float m_ratio; 00049 KDirWatch m_dirwatch; 00050 }; 00051 00052 #endif // BACKGROUNDLISTMODEL_H