File indexing completed on 2024-05-05 17:09:08

0001 /*
0002  * This file is part of the KDE project
0003  * Copyright (C) 2013 Arjen Hiemstra <ahiemstra@heimr.nl>
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This program is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef CQPRESENTATIONMODEL_H
0021 #define CQPRESENTATIONMODEL_H
0022 
0023 #include <QAbstractListModel>
0024 #include <QPixmap>
0025 
0026 class QDeclarativeItem;
0027 class CQPresentationModel : public QAbstractListModel
0028 {
0029     Q_OBJECT
0030     Q_PROPERTY(QDeclarativeItem* canvas READ canvas WRITE setCanvas NOTIFY canvasChanged)
0031     Q_PROPERTY(QSizeF thumbnailSize READ thumbnailSize WRITE setThumbnailSize NOTIFY thumbnailSizeChanged)
0032 
0033 public:
0034     enum Roles {
0035         ThumbnailRole = Qt::UserRole,
0036     };
0037 
0038     explicit CQPresentationModel(QObject* parent = 0);
0039     ~CQPresentationModel();
0040 
0041     virtual QVariant data(const QModelIndex& index, int role) const;
0042     virtual int rowCount(const QModelIndex& parent) const;
0043 
0044     Q_INVOKABLE QPixmap thumbnail(int index) const;
0045 
0046     QDeclarativeItem* canvas() const;
0047 
0048     QSizeF thumbnailSize() const;
0049 
0050 public Q_SLOTS:
0051     void setCanvas(QDeclarativeItem* canvas);
0052     void setThumbnailSize(const QSizeF& size);
0053     void canvasSourceChanged();
0054 
0055 Q_SIGNALS:
0056     void canvasChanged();
0057     void thumbnailSizeChanged();
0058 
0059 private:
0060     class Private;
0061     Private * const d;
0062 };
0063 
0064 #endif // CQPRESENTATIONMODEL_H