mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-24 07:46:20 +00:00
Implemented tile deletion.
This commit is contained in:
parent
9deb101894
commit
fc76db29d0
4 changed files with 42 additions and 4 deletions
|
@ -215,6 +215,7 @@ void TileEditorMainWindow::onActionAddTile(bool triggered)
|
||||||
|
|
||||||
void TileEditorMainWindow::onActionDeleteTile(bool triggered)
|
void TileEditorMainWindow::onActionDeleteTile(bool triggered)
|
||||||
{
|
{
|
||||||
|
onActionDeleteTile(m_ui->tileViewTabWidget->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileEditorMainWindow::onActionReplaceImage(bool triggered)
|
void TileEditorMainWindow::onActionReplaceImage(bool triggered)
|
||||||
|
@ -585,6 +586,32 @@ void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
lv->setCurrentIndex( lv->model()->index( 0, 0, rootIdx ) );
|
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()
|
TileModel* TileEditorMainWindow::createTileModel()
|
||||||
{
|
{
|
||||||
QStringList headers;
|
QStringList headers;
|
||||||
|
|
|
@ -69,6 +69,7 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onActionAddTile(int tabId);
|
void onActionAddTile(int tabId);
|
||||||
|
void onActionDeleteTile(int tabId);
|
||||||
TileModel* createTileModel();
|
TileModel* createTileModel();
|
||||||
|
|
||||||
Ui::TileEditorMainWindow *m_ui;
|
Ui::TileEditorMainWindow *m_ui;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
virtual QVariant data(int column, int role) const;
|
virtual QVariant data(int column, int role) const;
|
||||||
|
|
||||||
bool insertChildren(int position, int count, int columns);
|
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);
|
bool insertColumns(int position, int columns);
|
||||||
|
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|
|
@ -142,13 +142,23 @@ void TileModel::appendRow(Node *item)
|
||||||
|
|
||||||
bool TileModel::removeRows( int row, int count, const QModelIndex &parent )
|
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 )
|
if( row + count > c )
|
||||||
return false;
|
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();
|
endRemoveRows();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue