| 62 | } |
| 63 | |
| 64 | QVariant NetworkInterfaceModel::data(const QModelIndex &index, int role) const |
| 65 | { |
| 66 | if (!index.isValid()) |
| 67 | return QVariant(); |
| 68 | |
| 69 | if (role == Qt::DisplayRole) { |
| 70 | if (index.internalId() == IFACE_ID) { |
| 71 | const auto &iface = m_interfaces.at(index.row()); |
| 72 | switch (index.column()) { |
| 73 | case 0: |
| 74 | if (iface.name() == iface.humanReadableName()) |
| 75 | return iface.name(); |
| 76 | return QStringLiteral("%1 (%2)").arg(iface.name(), iface.humanReadableName()); |
| 77 | case 1: |
| 78 | return iface.hardwareAddress(); |
| 79 | case 2: |
| 80 | return MetaEnum::flagsToString(iface.flags(), interface_flag_table); |
| 81 | } |
| 82 | } else if (index.column() == 0) { |
| 83 | const auto iface = m_interfaces.at(index.internalId()); |
| 84 | const auto addr = iface.addressEntries().at(index.row()); |
| 85 | return QString(addr.ip().toString() + QLatin1Char('/') + addr.netmask().toString()); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return QVariant(); |
| 90 | } |
| 91 | |
| 92 | QVariant NetworkInterfaceModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 93 | { |