Implemented tileset removal.
This commit is contained in:
parent
068a10ea6d
commit
acf3f656b2
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->setModel(m_model);
|
||||||
//m_ui->tileSetLV->setRootIndex(m_model->index(0,0));
|
//m_ui->tileSetLV->setRootIndex(m_model->index(0,0));
|
||||||
connect(m_ui->tileSetAddTB, SIGNAL(clicked()), this, SLOT(onTileSetAdd()));
|
connect(m_ui->tileSetAddTB, SIGNAL(clicked()), this, SLOT(onTileSetAdd()));
|
||||||
|
connect(m_ui->tileSetDeleteTB, SIGNAL(clicked()), this, SLOT(onTileSetDelete()));
|
||||||
connect(m_ui->tileSetLV->selectionModel(),
|
connect(m_ui->tileSetLV->selectionModel(),
|
||||||
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
|
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
|
||||||
this, SLOT(changeActiveTileSet(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)
|
void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||||
{
|
{
|
||||||
QFileDialog::Options options;
|
QFileDialog::Options options;
|
||||||
|
|
|
@ -48,6 +48,7 @@ public Q_SLOTS:
|
||||||
void onActionReplaceImage(bool triggered);
|
void onActionReplaceImage(bool triggered);
|
||||||
void onActionDeleteImage(bool triggered);
|
void onActionDeleteImage(bool triggered);
|
||||||
void onTileSetAdd();
|
void onTileSetAdd();
|
||||||
|
void onTileSetDelete();
|
||||||
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
|
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
|
||||||
void onZoomFactor(int level);
|
void onZoomFactor(int level);
|
||||||
|
|
||||||
|
|
|
@ -505,7 +505,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="toolButton_7">
|
<widget class="QToolButton" name="tileSetDeleteTB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -140,6 +140,21 @@ void TileModel::appendRow(Node *item)
|
||||||
rootItem->appendRow(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)
|
TileSetNode *TileModel::createTileSetNode(QString tileSetName)
|
||||||
{
|
{
|
||||||
// Create the new tile set.
|
// Create the new tile set.
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
void appendRow(const QList<Node*> &items);
|
void appendRow(const QList<Node*> &items);
|
||||||
void appendRow(Node *item);
|
void appendRow(Node *item);
|
||||||
|
|
||||||
|
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
|
||||||
|
|
||||||
TileSetNode *createTileSetNode(QString tileSetName);
|
TileSetNode *createTileSetNode(QString tileSetName);
|
||||||
|
|
||||||
static const char *getTileTypeName(TNodeTileType type);
|
static const char *getTileTypeName(TNodeTileType type);
|
||||||
|
|
Loading…
Reference in a new issue