ZoneListModel: Simplify headerData()

This commit is contained in:
Nodir Temirkhodjaev 2021-12-11 10:58:56 +03:00
parent 77fb73cd4b
commit fe16207a2f
2 changed files with 19 additions and 12 deletions

View File

@ -44,18 +44,7 @@ int ZoneListModel::columnCount(const QModelIndex &parent) const
QVariant ZoneListModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) {
switch (section) {
case 0:
return tr("Zone");
case 1:
return tr("Source");
case 2:
return tr("Addresses");
case 3:
return tr("Last Run");
case 4:
return tr("Last Success");
}
return headerDataDisplay(section);
}
return QVariant();
}
@ -79,6 +68,23 @@ QVariant ZoneListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
QVariant ZoneListModel::headerDataDisplay(int section) const
{
switch (section) {
case 0:
return tr("Zone");
case 1:
return tr("Source");
case 2:
return tr("Addresses");
case 3:
return tr("Last Run");
case 4:
return tr("Last Success");
}
return QVariant();
}
QVariant ZoneListModel::dataDisplay(const QModelIndex &index) const
{
const int row = index.row();

View File

@ -70,6 +70,7 @@ protected:
QString sqlBase() const override;
private:
QVariant headerDataDisplay(int section) const;
QVariant dataDisplay(const QModelIndex &index) const;
QVariant dataCheckState(const QModelIndex &index) const;