diff options
Diffstat (limited to 'mappingtreemodel.cpp')
-rw-r--r-- | mappingtreemodel.cpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/mappingtreemodel.cpp b/mappingtreemodel.cpp index eed686b..48a4c67 100644 --- a/mappingtreemodel.cpp +++ b/mappingtreemodel.cpp @@ -11,8 +11,6 @@ #include <algorithm> -#include <QDebug> - #include "mappingtreemodel.h" #include "smtreeitem.h" @@ -39,14 +37,10 @@ MappingTreeModel::MappingTreeModel(QStringList &headers, QObject *parent) : SmTr mSelectChildQ->prepare("SELECT imapping_id, tmapping_name, tscreated FROM mappings WHERE tmapping_name = :name AND imapping_type = :type"); mAddParentQ = new QSqlQuery(mDb); mAddParentQ->prepare("INSERT INTO mappings_parents2 (imapping_id, iparent_id) VALUES(:id, :parentid)"); - mDeleteChildQ = new QSqlQuery(mDb); - mDeleteChildQ->prepare("DELETE FROM mappings WHERE imapping_id = :id"); mUpdateParentQ = new QSqlQuery(mDb); mUpdateParentQ->prepare("UPDATE mappings_parents SET iparent_id = :pid WHERE imapping_id = :id"); mDeleteMappingParentQ = new QSqlQuery(mDb); mDeleteMappingParentQ->prepare("DELETE FROM mappings_parents2 WHERE imappings_parents_id = :id"); - mMappingsForFileIdQ = new QSqlQuery(mDb); - mMappingsForFileIdQ->prepare("SELECT DISTINCT(imapping_id) FROM pics_mappings WHERE ipics_id = :pid"); mMappingsQ = new QSqlQuery(mDb); mMappingsQ->prepare("SELECT tmapping_name, imapping_id FROM mappings WHERE imapping_type = :type"); } @@ -60,9 +54,7 @@ MappingTreeModel::~MappingTreeModel(){ delete mAddChildQ; delete mSelectChildQ; delete mAddParentQ; - delete mDeleteChildQ; delete mUpdateParentQ; - delete mMappingsForFileIdQ; delete mMappingsQ; mDb = QSqlDatabase(); } @@ -85,15 +77,6 @@ int MappingTreeModel::mappingTypeIdFromName(const QVariant &name) const{ return -1; } -QString MappingTreeModel::mappingTypeNameFromId(int id) const{ - foreach(const mappingType t, mMappingTypes){ - if(t.id == id){ - return t.name.toString(); - } - } - return QString(); -} - //caller has ownership of this item! SmTreeItem *MappingTreeModel::treeFromPaths(const QStringList &paths){ if(paths.isEmpty()){ @@ -156,17 +139,6 @@ QList<QVariant> MappingTreeModel::childList(const QVariant &value, int column) c return QList<QVariant>() << value; } -QList<QVariant> MappingTreeModel::mappingsForFile(const QVariant &fileId) const{ - QList<QVariant> retval; - mMappingsForFileIdQ->addBindValue(fileId); - if(mMappingsForFileIdQ->exec()){ - while(mMappingsForFileIdQ->next()){ - retval << mMappingsForFileIdQ->value(0); - } - } - return retval; -} - QStringList MappingTreeModel::path(QModelIndex &idx) const{ if(!idx.isValid()){ return QStringList(); @@ -347,14 +319,6 @@ bool MappingTreeModel::deleteChild(const QModelIndex &idx){ return false; } -int MappingTreeModel::childCount(const QModelIndex &idx) const{ - if(!idx.isValid()){ - return 0; - } - SmTreeItem *item = itemAt(idx); - return item->childCount(); -} - MappingData MappingTreeModel::mappingDataFromIndex(QModelIndex &idx) const{ MappingData retval = { -1, QString(), QList<QStringList>() }; if(!idx.isValid()){ @@ -446,8 +410,6 @@ void MappingTreeModel::getChildrenRecursive(SmTreeItem *item){ cq.prepare(mSParentsQ); cq.bindValue(":type", mType); cq.bindValue(":pid", item->data(Id)); - //cq.prepare("SELECT mappings.imapping_id, mappings.tmapping_name, mappings.tscreated FROM mappings, mappings_parents WHERE mappings_parents.iparent_id = :id AND mappings.imapping_id = mappings_parents.imapping_id ORDER BY mappings.tmapping_name"); - //cq.bindValue(":id", item->data(Id)); if(cq.exec()){ while(cq.next()){ QList<QVariant> childData; @@ -513,26 +475,6 @@ int MappingTreeModel::lowerBound(SmTreeItem *item, const QVariant &value, int co return item->childCount(); } -QList<MappingData> MappingTreeModel::mappingData(SmTreeItem *item){ - QList<MappingData> retval; - if(item->childCount() > 0){ - for(int i = 0; i < item->childCount(); ++i){ - retval << mappingData(item->child(i)); - } - } - MappingData mapItem = { item->data(Id).toInt(), item->data(Name).toString(), QList<QStringList>() }; - QStringList path; - SmTreeItem *p = item; - while(p->parent()){ - path << p->data(Name).toString(); - p = p->parent(); - } - std::reverse(path.begin(), path.end()); - mapItem.path << path; - retval << mapItem; - return retval; -} - MappingTreeResultModel::MappingTreeResultModel(const QStringList &headers, QObject *parent) : SmTreeModel(headers, parent) { } Qt::ItemFlags MappingTreeResultModel::flags(const QModelIndex &index) const { |