From f5a7d411051d3112a90e26f1e382dc1e00fb9a00 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 16 Jun 2010 22:45:24 +0200 Subject: Treemodel Development -Changed the database schema. Attached quality to files -Subclassed SmTreeModel for SeriesTreeModel -Made SmTreeModel virtual for that Well, it seems there is a serious problem with the database schema. Curiously everything inside the model works beside the db update. Seems I have it wrong with the fks :( --- smubermodel.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'smubermodel.cpp') diff --git a/smubermodel.cpp b/smubermodel.cpp index d07b762..205b8d7 100644 --- a/smubermodel.cpp +++ b/smubermodel.cpp @@ -11,6 +11,7 @@ #include "smubermodel.h" #include "smtreemodel.h" +#include "seriestreemodel.h" #include "smtreeitem.h" #include "actormodel.h" @@ -23,19 +24,21 @@ SmUberModel::SmUberModel(QObject *parent) : QObject(parent), mSeriesModel(0), mF mDb.setDatabaseName("shemov2"); mDb.open(); mSeriesPartsQuery = new QSqlQuery(mDb); - mSeriesPartsQuery->prepare("SELECT iseriesparts_id, iseriespart, iseries_id, iquality FROM seriesparts WHERE iseries_id = :id ORDER BY iseriespart"); + //mSeriesPartsQuery->prepare("SELECT iseriesparts_id, iseriespart, iseries_id, iquality FROM seriesparts WHERE iseries_id = :id ORDER BY iseriespart"); //series model - QStringList seriesHeaders = QStringList() << tr("Series") << tr("Quality") << tr("Id"); - mSeriesModel = new SmTreeModel(seriesHeaders, this); - populateSeriesmodel(); + QStringList seriesHeaders = QStringList() << tr("Series") << QString() << QString() << QString() << QString(); + mSeriesModel = new SeriesTreeModel(seriesHeaders, this); + //populateSeriesmodel(); } SmUberModel::~SmUberModel(){ - delete mSeriesPartsQuery; + delete mSeriesModel; + QSqlDatabase::removeDatabase("treedb"); + //delete mSeriesPartsQuery; } -void SmUberModel::populateSeriesmodel(){ +/*void SmUberModel::populateSeriesmodel(){ QSqlQuery seriesQuery("SELECT iseries_id, tseries_name FROM series ORDER BY tseries_name", mDb); SmTreeItem *root = new SmTreeItem(3); while(seriesQuery.next()){ @@ -53,4 +56,4 @@ void SmUberModel::populateSeriesmodel(){ } } mSeriesModel->setRoot(root); -} +}*/ -- cgit v1.2.3-70-g09d2