23 QAbstractTableModel(parent),
43 int channelIndex = index.row();
48 case Qt::DisplayRole: {
49 if (index.column() == 2) {
50 return channels.at(channelIndex)->name();
54 case Qt::DecorationRole: {
55 if (index.column() == 1 &&
63 case Qt::CheckStateRole: {
67 if (index.column() == 0) {
69 return (
flags.isEmpty() ||
flags.testBit(channelIndex)) ? Qt::Checked : Qt::Unchecked;
81 Q_UNUSED(section); Q_UNUSED(orientation); Q_UNUSED(role);
110 int channelIndex = index.row();
112 if (role == Qt::CheckStateRole) {
115 Q_ASSERT(!
flags.isEmpty());
117 flags.setBit(channelIndex,
value.toInt() == Qt::Checked);
139 Q_ASSERT(index.row() <= channels.count());
141 int channelIndex = index.row();
143 QBitArray
flags = rootLayer->channelFlags();
145 Q_ASSERT(!
flags.isEmpty());
147 for (
int i = 0; i < channels.count(); ++i) {
149 flags.setBit(i, (i == channelIndex));
153 rootLayer->setChannelFlags(
flags);
162 Qt::ItemFlags
flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
185 if (!cs || *rootLayer->colorSpace() == *cs) {
186 const int newChannelCount = cs ? cs->
channelCount() : 0;
219 if (bottomRow >= 0 && rightColumn >= 0) {
222 if (rows > 0 && cols > 0) {
223 Q_EMIT dataChanged(this->index(0, 0), this->index(qMin(bottomRow, rows - 1), qMin(rightColumn, cols - 1)));
228#include "moc_channelmodel.cpp"
float value(const T *src, size_t ch)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void setCanvas(KisCanvas2 *canvas)
void rowActivated(const QModelIndex &index)
void slotColorSpaceChanged(const KoColorSpace *colorSpace)
QPointer< KisCanvas2 > m_canvas
QVector< QImage > m_thumbnails
void channelFlagsChanged()
void setChannelThumbnails(const QVector< QImage > &channels, const KoColorSpace *cs)
QSize m_thumbnailSizeLimit
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setThumbnailSizeLimit(QSize size)
ChannelModel(QObject *parent=0)
KisSignalAutoConnectionsStore m_canvasConnections
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QSize thumbnailSizeLimit() const
void emitAllDataChanged(int bottomRow, int rightColumn)
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
@ ALPHA
The channel represents the opacity of a pixel.
QBitArray channelFlags(bool color=true, bool alpha=false) const
QList< KoChannelInfo * > channels
virtual quint32 channelCount() const =0
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
const KoColorSpace * colorSpace() const override
virtual void setChannelFlags(const QBitArray &channelFlags)