UI: Programs: Group's name reflects its enabled flag

This commit is contained in:
Nodir Temirkhodjaev 2023-03-16 19:25:22 +03:00
parent d492592ac4
commit 0fc0537de8
2 changed files with 23 additions and 12 deletions

View File

@ -138,7 +138,7 @@ QVariant AppListModel::dataDisplay(const QModelIndex &index) const
case 1:
return dataDisplayState(appRow);
case 2:
return conf()->appGroupAt(appRow.groupIndex)->name();
return appGroupName(appRow);
case 3:
return appRow.appPath;
case 4:
@ -210,6 +210,25 @@ QVariant AppListModel::dataTextAlignment(const QModelIndex &index) const
return QVariant();
}
QVariant AppListModel::appGroupName(const AppRow &appRow) const
{
const AppGroup *appGroup = conf()->appGroupAt(appRow.groupIndex);
return appGroup->name();
}
QVariant AppListModel::appGroupColor(const AppRow &appRow) const
{
if (!appRow.useGroupPerm)
return inactiveColor;
const AppGroup *appGroup = conf()->appGroupAt(appRow.groupIndex);
if (!appGroup->enabled())
return blockColor;
return {};
}
QString AppListModel::appStateText(const AppRow &appRow)
{
if (appRow.blocked)
@ -218,14 +237,6 @@ QString AppListModel::appStateText(const AppRow &appRow)
return tr("Allow");
}
QVariant AppListModel::appGroupColor(const AppRow &appRow)
{
if (!appRow.useGroupPerm)
return inactiveColor;
return {};
}
QColor AppListModel::appStateColor(const AppRow &appRow)
{
if (appRow.blocked)

View File

@ -57,11 +57,11 @@ private:
QVariant dataForeground(const QModelIndex &index) const;
QVariant dataTextAlignment(const QModelIndex &index) const;
QVariant appGroupName(const AppRow &appRow) const;
QVariant appGroupColor(const AppRow &appRow) const;
static QString appStateText(const AppRow &appRow);
static QVariant appGroupColor(const AppRow &appRow);
static QColor appStateColor(const AppRow &appRow);
static QIcon appStateIcon(const AppRow &appRow);
bool updateAppRow(const QString &sql, const QVariantList &vars, AppRow &appRow) const;