From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp (limited to 'SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp') diff --git a/SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp b/SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp new file mode 100644 index 0000000..201dc8b --- /dev/null +++ b/SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp @@ -0,0 +1,42 @@ +#include "sqlhistorymodel.h" +#include "common/global.h" +#include "db/db.h" + +SqlHistoryModel::SqlHistoryModel(Db* db, QObject *parent) : + QueryModel(db, parent) +{ + static_char* query = "SELECT dbname, datetime(date, 'unixepoch'), (time_spent / 1000.0)||'s', rows, sql " + "FROM sqleditor_history ORDER BY date DESC"; + + setQuery(query); +} + +QVariant SqlHistoryModel::data(const QModelIndex& index, int role) const +{ + if (role == Qt::TextAlignmentRole && (index.column() == 2 || index.column() == 3)) + return (int)(Qt::AlignRight|Qt::AlignVCenter); + + return QueryModel::data(index, role); +} + +QVariant SqlHistoryModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation != Qt::Horizontal || role != Qt::DisplayRole) + return QueryModel::headerData(section, orientation, role); + + switch (section) + { + case 0: + return tr("Database", "sql history header"); + case 1: + return tr("Execution date", "sql history header"); + case 2: + return tr("Time spent", "sql history header"); + case 3: + return tr("Rows affected", "sql history header"); + case 4: + return tr("SQL", "sql history header"); + } + + return QueryModel::headerData(section, orientation, role); +} -- cgit v1.2.3