diff --git a/src/ui/model/applistmodel.cpp b/src/ui/model/applistmodel.cpp index f4c50771..7765c8df 100644 --- a/src/ui/model/applistmodel.cpp +++ b/src/ui/model/applistmodel.cpp @@ -428,15 +428,20 @@ QString AppListModel::sqlWhere() const QString AppListModel::sqlOrderColumn() const { QString columnsStr; + bool orderApplied = false; + switch (sortColumn()) { case 0: // Name - columnsStr = "t.name " + sqlOrderAsc() + ", t.path"; + columnsStr = "t.name" + sqlOrderAsc() + ", t.path"; + orderApplied = true; break; 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; case 2: // Group - columnsStr = "group_index"; + columnsStr = "group_index" + sqlOrderAsc() + ", t.name"; + orderApplied = true; break; case 3: // File Path columnsStr = "t.path"; @@ -446,5 +451,9 @@ QString AppListModel::sqlOrderColumn() const break; } + if (!orderApplied) { + columnsStr += sqlOrderAsc(); + } + return columnsStr; } diff --git a/src/ui/util/model/tablesqlmodel.cpp b/src/ui/util/model/tablesqlmodel.cpp index fd90d1ff..a336e1a5 100644 --- a/src/ui/util/model/tablesqlmodel.cpp +++ b/src/ui/util/model/tablesqlmodel.cpp @@ -68,17 +68,17 @@ QString TableSqlModel::sqlOrder() const if (sortColumn() == -1) return QString(); - return QString(" ORDER BY %1 %2").arg(sqlOrderColumn(), sqlOrderAsc()); + return " ORDER BY " + sqlOrderColumn(); } QString TableSqlModel::sqlOrderAsc() const { - return (sortOrder() == Qt::AscendingOrder) ? "ASC" : "DESC"; + return (sortOrder() == Qt::AscendingOrder) ? " ASC" : " DESC"; } QString TableSqlModel::sqlOrderColumn() const { - return QString::number(sortColumn()); + return QString::number(sortColumn()) + sqlOrderAsc(); } QString TableSqlModel::sqlLimitOffset() const