Reindex tile item nodes after deleting a node.

This commit is contained in:
dfighter1985 2014-07-26 02:05:21 +02:00
parent fc4856f28c
commit fe044b8592
2 changed files with 32 additions and 0 deletions

View file

@ -224,7 +224,33 @@ TileModel::TNodeTileType TileTypeNode::getTileType()
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++;
}
}
///////////////////////////////////////////////////

View file

@ -90,7 +90,11 @@ public:
int columnCount() const;
TileModel::TNodeTileType getTileType();
bool removeChildren( int position, int count );
private:
void reindex();
TileModel::TNodeTileType m_nodeTileType;
};
@ -102,6 +106,8 @@ public:
QVariant data(int column, int role) const;
int columnCount() const;
void setTileFilename(TileModel::TTileChannel channel, QString filename);
void setId( int id ){ m_tileId = id; }
int id() const{ return m_tileId; }
private:
int m_tileId;
QMap<TileModel::TTileChannel, QString> m_tileFilename;