UI: ConnBlockListModel: Simplify headerData()

This commit is contained in:
Nodir Temirkhodjaev 2023-04-03 12:32:21 +03:00
parent 42f5776ef3
commit 40d5a85985
2 changed files with 25 additions and 16 deletions

View File

@ -71,22 +71,7 @@ int ConnBlockListModel::columnCount(const QModelIndex &parent) const
QVariant ConnBlockListModel::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("Program");
case 1:
return (role == Qt::DisplayRole) ? tr("Proc. ID") : tr("Process ID");
case 2:
return tr("Protocol");
case 3:
return tr("Local IP and Port");
case 4:
return tr("Remote IP and Port");
case 5:
return (role == Qt::DisplayRole) ? tr("Dir.") : tr("Direction");
case 6:
return tr("Time");
}
return headerDataDisplay(section, role);
}
return QVariant();
}
@ -110,6 +95,28 @@ QVariant ConnBlockListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
QVariant ConnBlockListModel::headerDataDisplay(int section, int role) const
{
switch (section) {
case 0:
return tr("Program");
case 1:
return (role == Qt::DisplayRole) ? tr("Proc. ID") : tr("Process ID");
case 2:
return tr("Protocol");
case 3:
return tr("Local IP and Port");
case 4:
return tr("Remote IP and Port");
case 5:
return (role == Qt::DisplayRole) ? tr("Dir.") : tr("Direction");
case 6:
return tr("Time");
}
return QVariant();
}
QVariant ConnBlockListModel::dataDisplay(const QModelIndex &index, int role) const
{
const int row = index.row();

View File

@ -79,6 +79,8 @@ protected:
QString sqlLimitOffset() const override;
private:
QVariant headerDataDisplay(int section, int role) const;
QVariant dataDisplay(const QModelIndex &index, int role) const;
QVariant dataDisplayDirection(const ConnRow &connRow, int role) const;
QVariant dataDecoration(const QModelIndex &index) const;