| 111 | } |
| 112 | |
| 113 | QVariant BanTableModel::data(const QModelIndex &index, int role) const |
| 114 | { |
| 115 | if(!index.isValid()) |
| 116 | return QVariant(); |
| 117 | |
| 118 | CCombinedBan *rec = static_cast<CCombinedBan*>(index.internalPointer()); |
| 119 | |
| 120 | const auto column = static_cast<ColumnIndex>(index.column()); |
| 121 | if (role == Qt::DisplayRole) { |
| 122 | switch (column) { |
| 123 | case Address: |
| 124 | return QString::fromStdString(rec->subnet.ToString()); |
| 125 | case Bantime: |
| 126 | QDateTime date = QDateTime::fromMSecsSinceEpoch(0); |
| 127 | date = date.addSecs(rec->banEntry.nBanUntil); |
| 128 | return QLocale::system().toString(date, QLocale::LongFormat); |
| 129 | } // no default case, so the compiler can warn about missing cases |
| 130 | assert(false); |
| 131 | } |
| 132 | |
| 133 | return QVariant(); |
| 134 | } |
| 135 | |
| 136 | QVariant BanTableModel::headerData(int section, Qt::Orientation orientation, int role) const |
| 137 | { |