From ee29bb41dc9c4d4dd6fc9bfd3fb9ad5cc3bd1569 Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 2 Mar 2012 20:08:40 +0100 Subject: 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. --- smtreemodel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'smtreemodel.h') diff --git a/smtreemodel.h b/smtreemodel.h index e097d60..515f7b3 100644 --- a/smtreemodel.h +++ b/smtreemodel.h @@ -43,12 +43,12 @@ class SmTreeModel : public QAbstractItemModel { bool setRoot(SmTreeItem *rootItem); SmTreeItem *root() const { return mRootItem; } SmTreeItem *parentItem(const QModelIndex &child) const; - void reparent(const QModelIndex &idx, const QModelIndex &newParent); + void reparent(const QModelIndex &idx, const QModelIndex &newParent, bool sorted = false); // row manipulation - virtual bool insertRows(int row, int count, const QModelIndex &parent); + virtual bool insertRows(int row, int count, const QModelIndex &parent); virtual bool removeRows(int row, int count, const QModelIndex &parent); - bool addRow(const QList &data, const QModelIndex &parent); + bool addRow(const QList &data, const QModelIndex &parent, bool sorted = false); //misc void setDecorationIcon(const QIcon &icon) { mDecorationIcon = icon; } -- cgit v1.2.3-70-g09d2