mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:06:08 +00:00
UI: Programs: Improve sorting
This commit is contained in:
parent
118b431245
commit
51cd76d561
@ -428,15 +428,20 @@ QString AppListModel::sqlWhere() const
|
|||||||
QString AppListModel::sqlOrderColumn() const
|
QString AppListModel::sqlOrderColumn() const
|
||||||
{
|
{
|
||||||
QString columnsStr;
|
QString columnsStr;
|
||||||
|
bool orderApplied = false;
|
||||||
|
|
||||||
switch (sortColumn()) {
|
switch (sortColumn()) {
|
||||||
case 0: // Name
|
case 0: // Name
|
||||||
columnsStr = "t.name " + sqlOrderAsc() + ", t.path";
|
columnsStr = "t.name" + sqlOrderAsc() + ", t.path";
|
||||||
|
orderApplied = true;
|
||||||
break;
|
break;
|
||||||
case 1: // Action
|
case 1: // Action
|
||||||
columnsStr = "alerted DESC, t.kill_process, t.blocked " + sqlOrderAsc() + ", t.app_id";
|
columnsStr = "alerted DESC, t.kill_process, t.blocked" + sqlOrderAsc() + ", t.name";
|
||||||
|
orderApplied = true;
|
||||||
break;
|
break;
|
||||||
case 2: // Group
|
case 2: // Group
|
||||||
columnsStr = "group_index";
|
columnsStr = "group_index" + sqlOrderAsc() + ", t.name";
|
||||||
|
orderApplied = true;
|
||||||
break;
|
break;
|
||||||
case 3: // File Path
|
case 3: // File Path
|
||||||
columnsStr = "t.path";
|
columnsStr = "t.path";
|
||||||
@ -446,5 +451,9 @@ QString AppListModel::sqlOrderColumn() const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!orderApplied) {
|
||||||
|
columnsStr += sqlOrderAsc();
|
||||||
|
}
|
||||||
|
|
||||||
return columnsStr;
|
return columnsStr;
|
||||||
}
|
}
|
||||||
|
@ -68,17 +68,17 @@ QString TableSqlModel::sqlOrder() const
|
|||||||
if (sortColumn() == -1)
|
if (sortColumn() == -1)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
return QString(" ORDER BY %1 %2").arg(sqlOrderColumn(), sqlOrderAsc());
|
return " ORDER BY " + sqlOrderColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TableSqlModel::sqlOrderAsc() const
|
QString TableSqlModel::sqlOrderAsc() const
|
||||||
{
|
{
|
||||||
return (sortOrder() == Qt::AscendingOrder) ? "ASC" : "DESC";
|
return (sortOrder() == Qt::AscendingOrder) ? " ASC" : " DESC";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TableSqlModel::sqlOrderColumn() const
|
QString TableSqlModel::sqlOrderColumn() const
|
||||||
{
|
{
|
||||||
return QString::number(sortColumn());
|
return QString::number(sortColumn()) + sqlOrderAsc();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TableSqlModel::sqlLimitOffset() const
|
QString TableSqlModel::sqlLimitOffset() const
|
||||||
|
Loading…
Reference in New Issue
Block a user