Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Fix channel docker model dataChanged indexes
Carsten Hartenfels4448a2a435d9
diff --git a/plugins/dockers/channeldocker/channelmodel.cpp b/plugins/dockers/channeldocker/channelmodel.cppindex 40cb167be0..49bedf8a78 100644--- a/plugins/dockers/channeldocker/channelmodel.cpp+++ b/plugins/dockers/channeldocker/channelmodel.cpp@@ -119,7 +119,7 @@ bool ChannelModel::setData(const QModelIndex& index, const QVariant& value, introotLayer->setChannelFlags(flags);Q_EMIT channelFlagsChanged();- Q_EMIT dataChanged(this->index(0, 0), this->index(channels.count(), 0));+ emitAllDataChanged(channels.count() - 1, 0);return true;}}@@ -154,7 +154,7 @@ void ChannelModel::rowActivated(const QModelIndex &index)rootLayer->setChannelFlags(flags);Q_EMIT channelFlagsChanged();- Q_EMIT dataChanged(this->index(0, 0), this->index(channels.count(), 0));+ emitAllDataChanged(channels.count() - 1, 0);}}@@ -194,7 +194,7 @@ void ChannelModel::setChannelThumbnails(const QVector<QImage> &channels, const KendResetModel();} else {m_thumbnails = channels;- Q_EMIT dataChanged(this->index(0, 0), this->index(channels.count(), this->columnCount()));+ emitAllDataChanged(channels.count() - 1, columnCount() - 1);}}}@@ -215,4 +215,15 @@ QSize ChannelModel::thumbnailSizeLimit() constreturn m_thumbnailSizeLimit;}+void ChannelModel::emitAllDataChanged(int bottomRow, int rightColumn)+{+ if (bottomRow >= 0 && rightColumn >= 0) {+ int rows = rowCount();+ int cols = columnCount();+ if (rows > 0 && cols > 0) {+ Q_EMIT dataChanged(this->index(0, 0), this->index(qMin(bottomRow, rows - 1), qMin(rightColumn, cols - 1)));+ }+ }+}+#include "moc_channelmodel.cpp"diff --git a/plugins/dockers/channeldocker/channelmodel.h b/plugins/dockers/channeldocker/channelmodel.hindex 0ec63d7f4b..3b84bc62d1 100644--- a/plugins/dockers/channeldocker/channelmodel.h+++ b/plugins/dockers/channeldocker/channelmodel.h@@ -47,6 +47,8 @@ Q_SIGNALS:void channelFlagsChanged();private:+ void emitAllDataChanged(int bottomRow, int rightColumn);+QPointer<KisCanvas2> m_canvas;QVector<QImage> m_thumbnails;