mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:55:54 +00:00
UI: ProgramsWindow: Tweak state.
This commit is contained in:
parent
48fe652d69
commit
98288d80a7
@ -1,5 +1,6 @@
|
||||
#include "applistmodel.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QIcon>
|
||||
|
||||
#include <sqlite/sqlitedb.h>
|
||||
@ -155,8 +156,14 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const
|
||||
QString iconPath;
|
||||
switch (appRow.state) {
|
||||
case AppAlert: return QIcon(":/images/error.png");
|
||||
case AppAllow: {
|
||||
if (!appRow.useGroupPerm
|
||||
|| appGroupAt(appRow.groupIndex)->enabled()) {
|
||||
return QIcon(":/images/arrow_switch.png");
|
||||
}
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
case AppBlock: return QIcon(":/images/stop.png");
|
||||
case AppAllow: return QIcon(":/images/arrow_switch.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -164,6 +171,38 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const
|
||||
break;
|
||||
}
|
||||
|
||||
// Font
|
||||
case Qt::FontRole: {
|
||||
if (index.column() == 2) {
|
||||
QFont font;
|
||||
font.setWeight(QFont::DemiBold);
|
||||
return font;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Foreground
|
||||
case Qt::ForegroundRole: {
|
||||
if (index.column() == 2) {
|
||||
const auto appRow = appRowAt(index.row());
|
||||
|
||||
switch (appRow.state) {
|
||||
case AppAlert: return QColorConstants::Svg::orange;
|
||||
case AppAllow: {
|
||||
if (!appRow.useGroupPerm
|
||||
|| appGroupAt(appRow.groupIndex)->enabled()) {
|
||||
return QColorConstants::Svg::green;
|
||||
}
|
||||
Q_FALLTHROUGH();
|
||||
}
|
||||
case AppBlock: return QColorConstants::Svg::red;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Text Alignment
|
||||
case Qt::TextAlignmentRole: {
|
||||
const int column = index.column();
|
||||
@ -179,22 +218,6 @@ QVariant AppListModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags AppListModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
auto flags = TableItemModel::flags(index);
|
||||
|
||||
if ((flags & Qt::ItemIsEnabled)
|
||||
&& index.column() == 2) {
|
||||
const auto appRow = appRowAt(index.row());
|
||||
if (appRow.useGroupPerm
|
||||
&& !appGroupAt(appRow.groupIndex)->enabled()) {
|
||||
flags ^= Qt::ItemIsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void AppListModel::sort(int column, Qt::SortOrder order)
|
||||
{
|
||||
if (m_sortColumn != column || m_sortOrder != order) {
|
||||
|
@ -66,8 +66,6 @@ public:
|
||||
int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
||||
|
||||
const AppRow &appRowAt(int row) const;
|
||||
|
Loading…
Reference in New Issue
Block a user