mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-25 02:00:54 +00:00
Implemented tileset rename.
This commit is contained in:
parent
acf3f656b2
commit
764b80b751
4 changed files with 39 additions and 1 deletions
|
@ -89,6 +89,7 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent)
|
|||
//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->tileSetEditTB, SIGNAL(clicked()), this, SLOT(onTileSetEdit()));
|
||||
connect(m_ui->tileSetLV->selectionModel(),
|
||||
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
|
||||
this, SLOT(changeActiveTileSet(const QModelIndex &, const QModelIndex &)));
|
||||
|
@ -274,6 +275,40 @@ void TileEditorMainWindow::onTileSetDelete()
|
|||
//m_ui->tileSetLV->reset();
|
||||
}
|
||||
|
||||
void TileEditorMainWindow::onTileSetEdit()
|
||||
{
|
||||
QModelIndex idx = m_ui->tileSetLV->currentIndex();
|
||||
if( !idx.isValid() )
|
||||
return;
|
||||
|
||||
TileSetNode *node = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
|
||||
QString name = node->getTileSetName();
|
||||
|
||||
bool ok = false;
|
||||
|
||||
QString newName = QInputDialog::getText( this,
|
||||
tr( "Edit tileset" ),
|
||||
tr( "Enter tileset name" ),
|
||||
QLineEdit::Normal,
|
||||
name,
|
||||
&ok );
|
||||
|
||||
if( !ok )
|
||||
return;
|
||||
|
||||
TileModel *model = static_cast<TileModel*>(m_ui->tileSetLV->model());
|
||||
if( model->hasTileSet( newName ) )
|
||||
{
|
||||
QMessageBox::information( this,
|
||||
tr("Tileset already exists"),
|
||||
tr("A tileset with that name already exists!") );
|
||||
return;
|
||||
}
|
||||
|
||||
node->setTileSetName( newName );
|
||||
m_ui->tileSetLV->reset();
|
||||
}
|
||||
|
||||
void TileEditorMainWindow::onActionAddTile(int tabId)
|
||||
{
|
||||
QFileDialog::Options options;
|
||||
|
|
|
@ -49,6 +49,7 @@ public Q_SLOTS:
|
|||
void onActionDeleteImage(bool triggered);
|
||||
void onTileSetAdd();
|
||||
void onTileSetDelete();
|
||||
void onTileSetEdit();
|
||||
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
|
||||
void onZoomFactor(int level);
|
||||
|
||||
|
|
|
@ -516,7 +516,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_6">
|
||||
<widget class="QToolButton" name="tileSetEditTB">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
int columnCount() const;
|
||||
|
||||
const QString &getTileSetName(){ return m_tileSetName; }
|
||||
void setTileSetName( const QString &name ){ m_tileSetName = name; }
|
||||
|
||||
private:
|
||||
QString m_tileSetName;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue