Skip to content

Commit

Permalink
Repeated Submodel Flags (#183)
Browse files Browse the repository at this point in the history
Ask the submodel for flags at the index allowing more specialization.
  • Loading branch information
RobertBColton committed Sep 2, 2020
1 parent 4e2e498 commit 152b842
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Models/RepeatedMessageModel.cpp
Expand Up @@ -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()));
}
1 change: 1 addition & 0 deletions Models/RepeatedMessageModel.h
Expand Up @@ -30,6 +30,7 @@ class RepeatedMessageModel : public RepeatedModel<Message> {
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;
Expand Down

0 comments on commit 152b842

Please sign in to comment.