Implemented tileset rename.

This commit is contained in:
dfighter1985 2014-07-23 21:53:09 +02:00
parent 2f6e34ce17
commit df1cf32d0f
4 changed files with 39 additions and 1 deletions

View file

@ -89,6 +89,7 @@ TileEditorMainWindow::TileEditorMainWindow(QWidget *parent)
//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->tileSetDeleteTB, SIGNAL(clicked()), this, SLOT(onTileSetDelete()));
connect(m_ui->tileSetEditTB, SIGNAL(clicked()), this, SLOT(onTileSetEdit()));
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 &)));
@ -274,6 +275,40 @@ void TileEditorMainWindow::onTileSetDelete()
//m_ui->tileSetLV->reset(); //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) void TileEditorMainWindow::onActionAddTile(int tabId)
{ {
QFileDialog::Options options; QFileDialog::Options options;

View file

@ -49,6 +49,7 @@ public Q_SLOTS:
void onActionDeleteImage(bool triggered); void onActionDeleteImage(bool triggered);
void onTileSetAdd(); void onTileSetAdd();
void onTileSetDelete(); void onTileSetDelete();
void onTileSetEdit();
void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex); void changeActiveTileSet(const QModelIndex &newIndex, const QModelIndex &oldIndex);
void onZoomFactor(int level); void onZoomFactor(int level);

View file

@ -516,7 +516,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_6"> <widget class="QToolButton" name="tileSetEditTB">
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>

View file

@ -68,6 +68,8 @@ public:
int columnCount() const; int columnCount() const;
const QString &getTileSetName(){ return m_tileSetName; } const QString &getTileSetName(){ return m_tileSetName; }
void setTileSetName( const QString &name ){ m_tileSetName = name; }
private: private:
QString m_tileSetName; QString m_tileSetName;
}; };