summaryrefslogtreecommitdiffstats
path: root/mappingtreemodel.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2012-03-17 11:48:24 +0100
committerArno <am@disconnect.de>2012-03-17 11:48:24 +0100
commit6b8c2cf35525c62b1e7a0279a7ebaa175848d268 (patch)
tree762291d670475cf7dcd95d8a2f2fc67ac63ea73b /mappingtreemodel.cpp
parent77645a5dcfcb968cf5a3e4d43b4e93c12710f79e (diff)
downloadSheMov-6b8c2cf35525c62b1e7a0279a7ebaa175848d268.tar.gz
SheMov-6b8c2cf35525c62b1e7a0279a7ebaa175848d268.tar.bz2
SheMov-6b8c2cf35525c62b1e7a0279a7ebaa175848d268.zip
Make nodes with children selectable in picture widget
This was a tough one. Lost in recursion. When selecting nodes with children in the picture widget, all files having this node as mapping parent are shown. Had to make some changes to SmTreeModel::findRecursive for this. I hope I didn't break anything. If I did, I'll fix it :) Also disposed of some comments and unused member variables.
Diffstat (limited to 'mappingtreemodel.cpp')
-rw-r--r--mappingtreemodel.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/mappingtreemodel.cpp b/mappingtreemodel.cpp
index b2ca982..5ab6068 100644
--- a/mappingtreemodel.cpp
+++ b/mappingtreemodel.cpp
@@ -109,6 +109,15 @@ QVariant MappingTreeModel::data(const QModelIndex &index, int role) const{
return SmTreeModel::data(index, role);
}
+QList<QVariant> MappingTreeModel::childList(const QVariant &value, int column) const{
+ QModelIndex itemIdx = findRecursive(value, column, createIndex(0, 0, root()));
+ SmTreeItem *item = static_cast<SmTreeItem*>(itemIdx.internalPointer());
+ if(item->childCount()){
+ return getChildListRecursive(item, column);
+ }
+ return QList<QVariant>() << value;
+}
+
QModelIndex MappingTreeModel::indexFromPath(QString &path, int column) const{
QStringList items = path.split("/");
if(items.isEmpty() || column >= NumFields){
@@ -318,7 +327,8 @@ void MappingTreeModel::populate(){
SmTreeItem *rootItem = new SmTreeItem(NumFields);
SmTreeItem *firstChild = new SmTreeItem(NumFields, rootItem);
firstChild->setData(Name, mappingTypeNameFromId(mType));
- firstChild->setData(Id, mType);
+ //no real id needed... conflicts with mapping ids!
+ firstChild->setData(Id, 0);
rootItem->appendChild(firstChild);
//collect children recursive
while(mTypeParentsQ->next()){
@@ -379,6 +389,21 @@ QStringList MappingTreeModel::getPathsRecursive(SmTreeItem *parent) const{
return retval;
}
+QList<QVariant> MappingTreeModel::getChildListRecursive(SmTreeItem *item, int column) const{
+ QList<QVariant> retval;
+ if(!item){
+ return retval;
+ }
+ for(int i = 0; i < item->childCount(); ++i){
+ if(item->child(i)->childCount()){
+ retval << getChildListRecursive(item->child(i), column);
+ }else{
+ retval << item->child(i)->data(column);
+ }
+ }
+ return retval;
+}
+
QString MappingTreeModel::basePath(SmTreeItem *item) const{
QStringList pItems;
SmTreeItem *cur = item;