fixed checkbox selection on installedAppsDrawer (#759)

* fixed checkbox selection on installedAppsDrawer
* added sorting by name for split tunneling by application
This commit is contained in:
Nethius 2024-04-18 19:01:26 +07:00 committed by GitHub
parent 79edbe52a3
commit 5c19b08e5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 6 deletions

View file

@ -37,6 +37,9 @@ QVariant InstalledAppsModel::data(const QModelIndex &index, int role) const
case PackageNameRole: { case PackageNameRole: {
return m_installedApps.at(index.row()).toObject().value("package"); return m_installedApps.at(index.row()).toObject().value("package");
} }
case IsAppSelectedRole: {
return m_selectedAppIndexes.contains(index.row());
}
} }
return QVariant(); return QVariant();
@ -93,5 +96,6 @@ QHash<int, QByteArray> InstalledAppsModel::roleNames() const
roles[AppNameRole] = "appName"; roles[AppNameRole] = "appName";
roles[AppIconRole] = "appIcon"; roles[AppIconRole] = "appIcon";
roles[PackageNameRole] = "packageName"; roles[PackageNameRole] = "packageName";
roles[IsAppSelectedRole] = "isAppSelected";
return roles; return roles;
} }

View file

@ -1,8 +1,8 @@
#ifndef INSTALLEDAPPSMODEL_H #ifndef INSTALLEDAPPSMODEL_H
#define INSTALLEDAPPSMODEL_H #define INSTALLEDAPPSMODEL_H
#include <QJsonArray>
#include <QAbstractListModel> #include <QAbstractListModel>
#include <QJsonArray>
class InstalledAppsModel : public QAbstractListModel class InstalledAppsModel : public QAbstractListModel
{ {
@ -12,7 +12,8 @@ public:
enum Roles { enum Roles {
AppNameRole = Qt::UserRole + 1, AppNameRole = Qt::UserRole + 1,
PackageNameRole, PackageNameRole,
AppIconRole AppIconRole,
IsAppSelectedRole
}; };
explicit InstalledAppsModel(QObject *parent = nullptr); explicit InstalledAppsModel(QObject *parent = nullptr);

View file

@ -101,7 +101,7 @@ DrawerType2 {
Layout.fillWidth: true Layout.fillWidth: true
text: appName text: appName
checked: isAppSelected
onCheckedChanged: { onCheckedChanged: {
installedAppsModel.selectedStateChanged(proxyInstalledAppsModel.mapToSource(index), checked) installedAppsModel.selectedStateChanged(proxyInstalledAppsModel.mapToSource(index), checked)
} }

View file

@ -175,6 +175,9 @@ PageType {
pattern: ".*" + searchField.textField.text + ".*" pattern: ".*" + searchField.textField.text + ".*"
caseSensitivity: Qt.CaseInsensitive caseSensitivity: Qt.CaseInsensitive
} }
sorters: [
RoleSorter { roleName: "appPath"; sortOrder: Qt.AscendingOrder }
]
} }
clip: true clip: true