Reindex tile item nodes after deleting a node.
This commit is contained in:
parent
fc4856f28c
commit
fe044b8592
2 changed files with 32 additions and 0 deletions
|
@ -224,7 +224,33 @@ TileModel::TNodeTileType TileTypeNode::getTileType()
|
||||||
return m_nodeTileType;
|
return m_nodeTileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TileTypeNode::removeChildren( int position, int count )
|
||||||
|
{
|
||||||
|
bool ok = Node::removeChildren( position, count );
|
||||||
|
if( !ok )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
reindex();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileTypeNode::reindex()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
QListIterator< Node* > itr( m_childItems );
|
||||||
|
while( itr.hasNext() )
|
||||||
|
{
|
||||||
|
TileItemNode *n = dynamic_cast< TileItemNode* >( itr.next() );
|
||||||
|
if( n == NULL )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
n->setId( i );
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
|
|
|
@ -90,7 +90,11 @@ public:
|
||||||
int columnCount() const;
|
int columnCount() const;
|
||||||
|
|
||||||
TileModel::TNodeTileType getTileType();
|
TileModel::TNodeTileType getTileType();
|
||||||
|
|
||||||
|
bool removeChildren( int position, int count );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void reindex();
|
||||||
TileModel::TNodeTileType m_nodeTileType;
|
TileModel::TNodeTileType m_nodeTileType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -102,6 +106,8 @@ public:
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
int columnCount() const;
|
int columnCount() const;
|
||||||
void setTileFilename(TileModel::TTileChannel channel, QString filename);
|
void setTileFilename(TileModel::TTileChannel channel, QString filename);
|
||||||
|
void setId( int id ){ m_tileId = id; }
|
||||||
|
int id() const{ return m_tileId; }
|
||||||
private:
|
private:
|
||||||
int m_tileId;
|
int m_tileId;
|
||||||
QMap<TileModel::TTileChannel, QString> m_tileFilename;
|
QMap<TileModel::TTileChannel, QString> m_tileFilename;
|
||||||
|
|
Loading…
Reference in a new issue