diff options
author | Arno <am@disconnect.de> | 2012-03-02 20:08:40 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2012-03-02 20:08:40 +0100 |
commit | ee29bb41dc9c4d4dd6fc9bfd3fb9ad5cc3bd1569 (patch) | |
tree | 4801c4b23215259cec9620a32593c656fdfd8ede /mappingtreemodel.h | |
parent | 11bf52b6cf1c27a75715a8379e7893b8d1e16bf0 (diff) | |
download | SheMov-ee29bb41dc9c4d4dd6fc9bfd3fb9ad5cc3bd1569.tar.gz SheMov-ee29bb41dc9c4d4dd6fc9bfd3fb9ad5cc3bd1569.tar.bz2 SheMov-ee29bb41dc9c4d4dd6fc9bfd3fb9ad5cc3bd1569.zip |
Make it possible to move mappings
Move mappings by context menu. Select new parent by QComboBox with
available paths, items separated by "/". Note that hell will break loose
if a mapping name contains "/". Will be fixed later.
Since mapping views don't have setSortingEnabled(), make
SmTreeModel::addRow() sort items.
This fixes a long standing bug in SmTreeModel::reparent(): Since it
alters the model, newParent has to be a QPersistentModelIndex to stay
consistent.
Diffstat (limited to 'mappingtreemodel.h')
-rw-r--r-- | mappingtreemodel.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mappingtreemodel.h b/mappingtreemodel.h index 60c7bd4..c8ee8ee 100644 --- a/mappingtreemodel.h +++ b/mappingtreemodel.h @@ -34,7 +34,9 @@ class MappingTreeModel : public SmTreeModel { //data QVariant data(const QModelIndex &index, int role) const; + QModelIndex indexFromPath(QString &path, int column = 0) const; bool setData(const QModelIndex &index, const QVariant &value, int role); + void move(const QModelIndex &source, const QModelIndex &dest); bool addMappingType(const QString &type); bool deleteMappingType(int typeId); bool addChild(const QVariant &name, const QModelIndex &parent); @@ -42,6 +44,7 @@ class MappingTreeModel : public SmTreeModel { int childCount(const QModelIndex &idx) const; MappingData mappingDataFromId(int mappingId) const; void setSelectedMappings(const QList<int> &mappingData); + QStringList paths() const; public slots: void populate(); @@ -58,6 +61,8 @@ class MappingTreeModel : public SmTreeModel { }; void getMappingTypes(); void getChildrenRecursive(SmTreeItem *item); + QStringList getPathsRecursive(SmTreeItem *parent) const; + QString basePath(SmTreeItem *item) const; int lowerBound(SmTreeItem *item, const QVariant &value, int column = 0) const; QList<MappingData> mappingData(SmTreeItem *item); QSqlDatabase mDb; @@ -71,6 +76,8 @@ class MappingTreeModel : public SmTreeModel { QSqlQuery *mSelectChildQ; QSqlQuery *mAddParentQ; QSqlQuery *mDeleteChildQ; + QSqlQuery *mUpdateParentQ; + QSqlQuery *mDeleteMappingParentQ; QList<mappingType> mMappingTypes; QList<MappingData> mValidMappings; QList<int> mSelectedMappings; |