Reindex tile item nodes after deleting a node.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-07-26 02:05:21 +02:00
parent f0a67d0c2e
commit e06858f2df
2 changed files with 32 additions and 0 deletions

View file

@ -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++;
}
}
/////////////////////////////////////////////////// ///////////////////////////////////////////////////

View file

@ -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;