summaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/sqlhistorymodel.cpp42
1 files changed, 42 insertions, 0 deletions
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);
+}