bool NetworkProxyProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { NetworkProxy leftNetworkProxy = left.data(NetworkProxyRole).value<NetworkProxy>(); NetworkProxy rightNetworkProxy = right.data(NetworkProxyRole).value<NetworkProxy>(); if (leftNetworkProxy.isNull()) return false; if (rightNetworkProxy.isNull()) return true; int displayCompare = compareNames(leftNetworkProxy.address(), rightNetworkProxy.address()); return displayCompare < 0; }
QVariant NetworkProxyModel::data(const QModelIndex &index, int role) const { NetworkProxy proxy = networkProxy(index); if (proxy.isNull()) return QVariant(); switch (role) { case Qt::DisplayRole: return proxy.displayName(); case NetworkProxyRole: return QVariant::fromValue<NetworkProxy>(proxy); case ItemTypeRole: return NetworkProxyRole; default: return QVariant(); } }