From c1c9dfb43ad18e54de9a3a130d181211cf0d03c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mikko=20Kein=C3=A4nen?= Date: Thu, 9 Dec 2010 00:38:08 +0200 Subject: [PATCH] Added sql select script and table column enums. --- src/models/filepathmodel.cpp | 15 +++++++++++++-- src/models/filepathmodel.h | 7 +++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/models/filepathmodel.cpp b/src/models/filepathmodel.cpp index 4bbb3e1..5e3fae0 100644 --- a/src/models/filepathmodel.cpp +++ b/src/models/filepathmodel.cpp @@ -34,8 +34,19 @@ void FilePathModel::refresh() QString FilePathModel::constructSelect(QString where) const { - // TODO - return QString(); + return QString("SELECT " + "filepath.id AS FilePathId, " + "filepath.name AS Name, " + "datetime(filepath.lastscanned, 'unixepoch') AS LastScanned, " + "setup.id AS SetupId, " + "platform.name || ' ' || mediatype.name AS SetupName, " + "filepath.filetypeid " + "FROM filepath " + "INNER JOIN setup ON filepath.setupid=setup.id " + "INNER JOIN platform ON setup.platformid=platform.id " + "INNER JOIN mediatype ON setup.mediatypeid=mediatype.id " + "%1 " + "ORDER BY SetupName").arg(where); } Qt::ItemFlags FilePathModel::flags(const QModelIndex &index) const diff --git a/src/models/filepathmodel.h b/src/models/filepathmodel.h index 510bae0..76bad4f 100644 --- a/src/models/filepathmodel.h +++ b/src/models/filepathmodel.h @@ -31,6 +31,13 @@ public: virtual bool setData(const QModelIndex &index, const QVariant &value, int role); virtual bool insertRows(int row, int count, const QModelIndex &parent); virtual bool removeRows(int row, int count, const QModelIndex &parent); + enum { FilePath_Id = 0, + FilePath_Name, + FilePath_LastScanned, + FilePath_SetupId, + FilePath_SetupName, + FilePath_FileTypeId + }; protected: virtual void refresh(); -- 1.7.9.5