2024-04-01 18:45:00 +07:00
|
|
|
#include "appSplitTunnelingModel.h"
|
|
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
AppSplitTunnelingModel::AppSplitTunnelingModel(QObject *parent)
|
|
|
|
|
: QAbstractListModel(parent)
|
2024-04-01 18:45:00 +07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AppSplitTunnelingModel::rowCount(const QModelIndex &parent) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(parent)
|
|
|
|
|
return m_apps.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant AppSplitTunnelingModel::data(const QModelIndex &index, int role) const
|
|
|
|
|
{
|
|
|
|
|
if (!index.isValid() || index.row() < 0 || index.row() >= static_cast<int>(rowCount()))
|
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
|
|
switch (role) {
|
2025-08-01 07:54:58 +04:00
|
|
|
case AppPathRole: {
|
|
|
|
|
return m_apps.at(index.row()).appName;
|
|
|
|
|
}
|
|
|
|
|
default: {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-04-01 18:45:00 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QVariant();
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-30 14:53:03 +08:00
|
|
|
void AppSplitTunnelingModel::updateModel(const QVector<amnezia::InstalledAppInfo> &apps)
|
2024-04-01 18:45:00 +07:00
|
|
|
{
|
|
|
|
|
beginResetModel();
|
2026-04-30 14:53:03 +08:00
|
|
|
m_apps = apps;
|
2024-04-01 18:45:00 +07:00
|
|
|
endResetModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QHash<int, QByteArray> AppSplitTunnelingModel::roleNames() const
|
|
|
|
|
{
|
|
|
|
|
QHash<int, QByteArray> roles;
|
|
|
|
|
roles[AppPathRole] = "appPath";
|
|
|
|
|
return roles;
|
|
|
|
|
}
|