mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 07:36:16 +00:00
Implemented tile deletion.
This commit is contained in:
parent
4d0002a6f4
commit
fc4856f28c
4 changed files with 42 additions and 4 deletions
|
@ -215,6 +215,7 @@ void TileEditorMainWindow::onActionAddTile(bool triggered)
|
|||
|
||||
void TileEditorMainWindow::onActionDeleteTile(bool triggered)
|
||||
{
|
||||
onActionDeleteTile(m_ui->tileViewTabWidget->currentIndex());
|
||||
}
|
||||
|
||||
void TileEditorMainWindow::onActionReplaceImage(bool triggered)
|
||||
|
@ -585,6 +586,32 @@ void TileEditorMainWindow::onActionAddTile(int tabId)
|
|||
lv->setCurrentIndex( lv->model()->index( 0, 0, rootIdx ) );
|
||||
}
|
||||
|
||||
void TileEditorMainWindow::onActionDeleteTile( int tabId )
|
||||
{
|
||||
QListView *lv = NULL;
|
||||
switch( tabId )
|
||||
{
|
||||
case TAB_128: lv = m_ui->listView128; break;
|
||||
case TAB_256: lv = m_ui->listView256; break;
|
||||
}
|
||||
|
||||
QModelIndex idx = lv->currentIndex();
|
||||
if( !idx.isValid() )
|
||||
{
|
||||
QMessageBox::information( this,
|
||||
tr( "Deleting a tile" ),
|
||||
tr( "You need to select a tile to delete is!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
int row = idx.row();
|
||||
|
||||
QModelIndex parent = idx.parent();
|
||||
lv->model()->removeRow( row, parent );
|
||||
|
||||
//lv->reset();
|
||||
}
|
||||
|
||||
TileModel* TileEditorMainWindow::createTileModel()
|
||||
{
|
||||
QStringList headers;
|
||||
|
|
|
@ -69,6 +69,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
void onActionAddTile(int tabId);
|
||||
void onActionDeleteTile(int tabId);
|
||||
TileModel* createTileModel();
|
||||
|
||||
Ui::TileEditorMainWindow *m_ui;
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
virtual QVariant data(int column, int role) const;
|
||||
|
||||
bool insertChildren(int position, int count, int columns);
|
||||
bool removeChildren(int position, int count);
|
||||
virtual bool removeChildren(int position, int count);
|
||||
bool insertColumns(int position, int columns);
|
||||
|
||||
int row() const;
|
||||
|
|
|
@ -142,13 +142,23 @@ void TileModel::appendRow(Node *item)
|
|||
|
||||
bool TileModel::removeRows( int row, int count, const QModelIndex &parent )
|
||||
{
|
||||
int c = rootItem->childCount();
|
||||
Node *parentNode = NULL;
|
||||
|
||||
if( !parent.isValid() )
|
||||
parentNode = rootItem;
|
||||
else
|
||||
parentNode = getItem( parent );
|
||||
|
||||
if( parentNode == NULL )
|
||||
return false;
|
||||
|
||||
int c = parentNode->childCount();
|
||||
if( row + count > c )
|
||||
return false;
|
||||
|
||||
beginRemoveRows( QModelIndex(), row, row + count - 1 );
|
||||
beginRemoveRows( parent, row, row + count - 1 );
|
||||
|
||||
bool ok = rootItem->removeChildren( row, count );
|
||||
bool ok = parentNode->removeChildren( row, count );
|
||||
|
||||
endRemoveRows();
|
||||
|
||||
|
|
Loading…
Reference in a new issue