mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Implemented tileset removal.
--HG-- branch : gsoc2014-dfighter
This commit is contained in:
parent
5301b00e58
commit
71fc4a098b
5 changed files with 32 additions and 1 deletions
|
@ -88,6 +88,7 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent)
|
|||
m_ui->tileSetLV->setModel(m_model);
|
||||
//m_ui->tileSetLV->setRootIndex(m_model->index(0,0));
|
||||
connect(m_ui->tileSetAddTB, SIGNAL(clicked()), this, SLOT(onTileSetAdd()));
|
||||
connect(m_ui->tileSetDeleteTB, SIGNAL(clicked()), this, SLOT(onTileSetDelete()));
|
||||
connect(m_ui->tileSetLV->selectionModel(),
|
||||
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
|
||||
this, SLOT(changeActiveTileSet(const QModelIndex &, const QModelIndex &)));
|
||||
|
@ -261,6 +262,18 @@ void TileEditorMainWindow::onTileSetAdd()
|
|||
}
|
||||
}
|
||||
|
||||
void TileEditorMainWindow::onTileSetDelete()
|
||||
{
|
||||
QModelIndex idx = m_ui->tileSetLV->currentIndex();
|
||||
if( !idx.isValid() )
|
||||
return;
|
||||
|
||||
TileModel *model = static_cast<TileModel*>(m_ui->tileSetLV->model());
|
||||
bool ok = model->removeRow( idx.row() );
|
||||
|
||||
//m_ui->tileSetLV->reset();
|
||||
}
|
||||
|
||||
void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||
{
|
||||
QFileDialog::Options options;
|
||||
|
|
|
@ -48,6 +48,7 @@ public Q_SLOTS:
|
|||
void onActionReplaceImage(bool triggered);
|
||||
void onActionDeleteImage(bool triggered);
|
||||
void onTileSetAdd();
|
||||
void onTileSetDelete();
|
||||
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
|
||||
void onZoomFactor(int level);
|
||||
|
||||
|
|
|
@ -505,7 +505,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_7">
|
||||
<widget class="QToolButton" name="tileSetDeleteTB">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
|
|
|
@ -140,6 +140,21 @@ void TileModel::appendRow(Node *item)
|
|||
rootItem->appendRow(item);
|
||||
}
|
||||
|
||||
bool TileModel::removeRows( int row, int count, const QModelIndex &parent )
|
||||
{
|
||||
int c = rootItem->childCount();
|
||||
if( row + count > c )
|
||||
return false;
|
||||
|
||||
beginRemoveRows( QModelIndex(), row, row + count - 1 );
|
||||
|
||||
bool ok = rootItem->removeChildren( row, count );
|
||||
|
||||
endRemoveRows();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
TileSetNode *TileModel::createTileSetNode(QString tileSetName)
|
||||
{
|
||||
// Create the new tile set.
|
||||
|
|
|
@ -80,6 +80,8 @@ public:
|
|||
void appendRow(const QList<Node*> &items);
|
||||
void appendRow(Node *item);
|
||||
|
||||
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
|
||||
|
||||
TileSetNode *createTileSetNode(QString tileSetName);
|
||||
|
||||
static const char *getTileTypeName(TNodeTileType type);
|
||||
|
|
Loading…
Reference in a new issue