mirror of
https://github.com/tnodir/fort
synced 2024-11-15 03:26:01 +00:00
UI: Programs: Sort "Name" column case-insentively
This commit is contained in:
parent
12022c5333
commit
f98765a18a
2
src/ui/3rdparty/sqlite/sqlite.pri
vendored
2
src/ui/3rdparty/sqlite/sqlite.pri
vendored
@ -16,6 +16,7 @@ SOURCES += \
|
||||
$$PWD/dbutil.cpp \
|
||||
$$PWD/dbvar.cpp \
|
||||
$$PWD/sqlitedb.cpp \
|
||||
$$PWD/sqlitedbext.cpp \
|
||||
$$PWD/sqlitestmt.cpp
|
||||
|
||||
HEADERS += \
|
||||
@ -27,4 +28,5 @@ HEADERS += \
|
||||
$$PWD/dbvar.h \
|
||||
$$PWD/sqlite_types.h \
|
||||
$$PWD/sqlitedb.h \
|
||||
$$PWD/sqlitedbext.h \
|
||||
$$PWD/sqlitestmt.h
|
||||
|
9
src/ui/3rdparty/sqlite/sqlitedb.cpp
vendored
9
src/ui/3rdparty/sqlite/sqlitedb.cpp
vendored
@ -9,6 +9,7 @@
|
||||
#include <sqlite.h>
|
||||
|
||||
#include "dbquery.h"
|
||||
#include "sqlitedbext.h"
|
||||
#include "sqlitestmt.h"
|
||||
|
||||
namespace {
|
||||
@ -84,7 +85,13 @@ bool SqliteDb::open()
|
||||
{
|
||||
const auto filePathUtf8 = m_filePath.toUtf8();
|
||||
|
||||
return sqlite3_open_v2(filePathUtf8.data(), &m_db, m_openFlags, nullptr) == SQLITE_OK;
|
||||
const bool ok = sqlite3_open_v2(filePathUtf8.data(), &m_db, m_openFlags, nullptr) == SQLITE_OK;
|
||||
|
||||
if (ok) {
|
||||
SqliteDbExt::registerExtensions(this);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void SqliteDb::close()
|
||||
|
44
src/ui/3rdparty/sqlite/sqlitedbext.cpp
vendored
Normal file
44
src/ui/3rdparty/sqlite/sqlitedbext.cpp
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
#include "sqlitedbext.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#include <sqlite.h>
|
||||
|
||||
#include "sqlitedb.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const QLoggingCategory LC("dbExt");
|
||||
|
||||
void extLower(sqlite3_context *ctx, int argc, sqlite3_value **argv)
|
||||
{
|
||||
Q_ASSERT(argc == 1);
|
||||
|
||||
const unsigned char *textUtf8 = sqlite3_value_text(argv[0]);
|
||||
const auto text = QString::fromUtf8(textUtf8);
|
||||
const auto textLower = text.toLower();
|
||||
const auto result = textLower.toUtf8();
|
||||
|
||||
sqlite3_result_text(ctx, result.data(), result.size(), SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
bool createExtLower(struct sqlite3 *db)
|
||||
{
|
||||
return sqlite3_create_function(db, "EXT_LOWER",
|
||||
/*nArg=*/1,
|
||||
/*eTextRep=*/(SQLITE_DETERMINISTIC | SQLITE_UTF8),
|
||||
/*pApp=*/nullptr,
|
||||
/*xFunc=*/&extLower,
|
||||
/*xStep=*/nullptr,
|
||||
/*xFinal=*/nullptr)
|
||||
== SQLITE_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SqliteDbExt::registerExtensions(SqliteDb *sqliteDb)
|
||||
{
|
||||
struct sqlite3 *db = sqliteDb->db();
|
||||
|
||||
createExtLower(db);
|
||||
}
|
14
src/ui/3rdparty/sqlite/sqlitedbext.h
vendored
Normal file
14
src/ui/3rdparty/sqlite/sqlitedbext.h
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef SQLITEDBEXT_H
|
||||
#define SQLITEDBEXT_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class SqliteDb;
|
||||
|
||||
class SqliteDbExt
|
||||
{
|
||||
public:
|
||||
static void registerExtensions(SqliteDb *sqliteDb);
|
||||
};
|
||||
|
||||
#endif // SQLITEDBEXT_H
|
@ -34,7 +34,7 @@ namespace {
|
||||
|
||||
const QLoggingCategory LC("conf");
|
||||
|
||||
constexpr int DATABASE_USER_VERSION = 43;
|
||||
constexpr int DATABASE_USER_VERSION = 44;
|
||||
|
||||
const char *const sqlSelectAddressGroups = "SELECT addr_group_id, include_all, exclude_all,"
|
||||
" include_zones, exclude_zones,"
|
||||
|
@ -80,7 +80,7 @@ CREATE TABLE app(
|
||||
|
||||
CREATE INDEX app_app_group_id_idx ON app(app_group_id);
|
||||
CREATE UNIQUE INDEX app_path_uk ON app(path);
|
||||
CREATE INDEX app_name_idx ON app(name);
|
||||
CREATE INDEX app_name_idx ON app(EXT_LOWER(name));
|
||||
CREATE INDEX app_rule_idx ON app(rule_id);
|
||||
CREATE INDEX app_end_time_idx ON app(end_time);
|
||||
|
||||
|
@ -320,7 +320,7 @@ QString AppListModel::sqlWhereFts() const
|
||||
|
||||
QString AppListModel::sqlOrderColumn() const
|
||||
{
|
||||
static const QString nameColumn = "t.name";
|
||||
static const QString nameColumn = "EXT_LOWER(t.name)";
|
||||
static const QString pathColumn = "t.path";
|
||||
|
||||
static const QStringList orderColumns = {
|
||||
|
Loading…
Reference in New Issue
Block a user