From 152b8427e20261bccf9eb61592d66115749cfb51 Mon Sep 17 00:00:00 2001 From: Robert Colton Date: Wed, 2 Sep 2020 12:04:30 -0400 Subject: [PATCH] Repeated Submodel Flags (#183) Ask the submodel for flags at the index allowing more specialization. --- Models/RepeatedMessageModel.cpp | 7 +++++++ Models/RepeatedMessageModel.h | 1 + 2 files changed, 8 insertions(+) diff --git a/Models/RepeatedMessageModel.cpp b/Models/RepeatedMessageModel.cpp index d2bfe380f..8f9d892ab 100644 --- a/Models/RepeatedMessageModel.cpp +++ b/Models/RepeatedMessageModel.cpp @@ -59,3 +59,10 @@ QVariant RepeatedMessageModel::data(const QModelIndex &index, int role) const { return _subModels[index.row()]->data(_subModels[index.row()]->index(index.column()), role); } + +Qt::ItemFlags RepeatedMessageModel::flags(const QModelIndex &index) const { + R_EXPECT(index.row() >= 0 && index.row() < _subModels.size(), RepeatedModel::flags(index)) << + "Supplied row was out of bounds:" << index.row(); + + return _subModels[index.row()]->flags(_subModels[index.row()]->index(index.column())); +} diff --git a/Models/RepeatedMessageModel.h b/Models/RepeatedMessageModel.h index 09fe13c14..f2fac1788 100644 --- a/Models/RepeatedMessageModel.h +++ b/Models/RepeatedMessageModel.h @@ -30,6 +30,7 @@ class RepeatedMessageModel : public RepeatedModel { virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole) override; virtual QVariant data(const QModelIndex &index, int role) const override; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; + virtual Qt::ItemFlags flags(const QModelIndex &index) const override; // TODO: implement dropping a message //virtual QMimeData *mimeData(const QModelIndexList &indexes) const override;