Skip to content

Commit

Permalink
Proto Model Header Data Overriding (#175)
Browse files Browse the repository at this point in the history
Make explicit header data with translations override reflected header data of field names.
  • Loading branch information
RobertBColton authored Aug 31, 2020
1 parent 7bc855c commit b2dba24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Models/ProtoModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ static QVariant getHeaderData(const QHash<int,QHash<Qt::ItemDataRole,QVariant>>&

QVariant ProtoModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation == Qt::Horizontal) {
auto data = getHeaderData(_horizontalHeaderData, section, role);
if (data.isValid()) return data;
return getHeaderData(_horizontalHeaderData, section, role);
} else if (orientation == Qt::Vertical) {
auto data = getHeaderData(_verticalHeaderData, section, role);
if (data.isValid()) return data;
return getHeaderData(_verticalHeaderData, section, role);
}
return QAbstractItemModel::headerData(section, orientation, role);
return QVariant();
}
4 changes: 3 additions & 1 deletion Models/RepeatedModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ class RepeatedModel : public ProtoModel {
}

virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override {
auto data = ProtoModel::headerData(section, orientation, role);
if (data.isValid()) return data;
if (section == 0 || role != Qt::DisplayRole || orientation != Qt::Orientation::Horizontal)
return ProtoModel::headerData(section, orientation, role);
return data;
return QString::fromStdString(_field->message_type()->field(section - 1)->name());
}

Expand Down

0 comments on commit b2dba24

Please sign in to comment.