mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-24 07:46:20 +00:00
Reindex tile item nodes after deleting a node.
This commit is contained in:
parent
fc76db29d0
commit
dd193e3d51
2 changed files with 32 additions and 0 deletions
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue