channelmodel.h 2.27 KB
Newer Older
Sven Langkamp's avatar
Sven Langkamp committed
1 2 3
/*
 *  Copyright (c) 2011 Sven Langkamp <sven.langkamp@gmail.com>
 *
4
 *  This library is free software; you can redistribute it and/or modify
Sven Langkamp's avatar
Sven Langkamp committed
5
 *  it under the terms of the GNU Lesser General Public License as published by
6 7
 *  the Free Software Foundation; version 2 of the License, or
 *  (at your option) any later version.
Sven Langkamp's avatar
Sven Langkamp committed
8
 *
9
 *  This library is distributed in the hope that it will be useful,
Sven Langkamp's avatar
Sven Langkamp committed
10 11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU Lesser General Public License for more details.
Sven Langkamp's avatar
Sven Langkamp committed
13 14 15 16 17 18 19 20 21 22
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef CHANNELMODEL_H
#define CHANNELMODEL_H

#include <QModelIndex>
23
#include <QSize>
24 25 26
#include <QPointer>

#include <kis_canvas2.h>
27
#include <kis_types.h>
Sven Langkamp's avatar
Sven Langkamp committed
28

29
class KoColorSpace;
30

Sven Langkamp's avatar
Sven Langkamp committed
31

32
class ChannelModel : public QAbstractTableModel
Sven Langkamp's avatar
Sven Langkamp committed
33 34 35 36
{
    Q_OBJECT
public:
    ChannelModel(QObject* parent = 0);
37
    ~ChannelModel() override;
38

39 40 41 42 43 44
    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
    int rowCount(const QModelIndex& parent = QModelIndex()) const override;
    int columnCount(const QModelIndex& parent = QModelIndex()) const override;
    bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
    Qt::ItemFlags flags(const QModelIndex& index) const override;
45 46 47 48
    void unsetCanvas( void );

    //set maximum size of the thumbnail image. This should be set based on screen resolution, etc.
    void setThumbnailSizeLimit(QSize size);
Sven Langkamp's avatar
Sven Langkamp committed
49

50
public Q_SLOTS:
51
    void slotSetCanvas(KisCanvas2* canvas);
52
    void slotColorSpaceChanged(const KoColorSpace *colorSpace);
53 54 55
    void updateData(KisCanvas2 *canvas);
    void rowActivated(const QModelIndex &index);

56
Q_SIGNALS:
57
    void channelFlagsChanged();
58

Sven Langkamp's avatar
Sven Langkamp committed
59
private:
60 61 62
    void updateThumbnails();

private:
63
    QPointer<KisCanvas2> m_canvas;
64 65 66 67
    QVector<QImage> m_thumbnails;
    QSize m_thumbnailSizeLimit;
    int m_oversampleRatio;
    int m_channelCount;
Sven Langkamp's avatar
Sven Langkamp committed
68 69
};

70

Sven Langkamp's avatar
Sven Langkamp committed
71
#endif // CHANNELMODEL_H