Implemented tile image replace.

--HG--
branch : gsoc2014-dfighter
This commit is contained in:
dfighter1985 2014-07-26 02:24:32 +02:00
parent 5866a61cff
commit 4326ca1df8
2 changed files with 26 additions and 0 deletions

View file

@ -220,6 +220,7 @@ void TileEditorMainWindow::onActionDeleteTile(bool triggered)
void TileEditorMainWindow::onActionReplaceImage(bool triggered)
{
onActionReplaceImage(m_ui->tileViewTabWidget->currentIndex());
}
void TileEditorMainWindow::onActionDeleteImage(bool triggered)
@ -619,6 +620,30 @@ void TileEditorMainWindow::onActionDeleteImage( int tabId )
n->setTileFilename( TileModel::TileDiffuse, "" );
}
void TileEditorMainWindow::onActionReplaceImage( int tabId )
{
QListView *lv = getListViewByTab( tabId );
QModelIndex idx = lv->currentIndex();
if( !idx.isValid() )
{
QMessageBox::information( this,
tr( "Replacing tile image" ),
tr( "No tile selected!" ) );
return;
}
QString fileName = QFileDialog::getOpenFileName( this,
tr( "Select tile image" ),
"",
tr( "PNG files (*.png)" ) );
if( fileName.isEmpty() )
return;
TileItemNode *n = reinterpret_cast< TileItemNode* >( idx.internalPointer() );
n->setTileFilename( TileModel::TileDiffuse, fileName );
}
TileModel* TileEditorMainWindow::createTileModel()
{
QStringList headers;

View file

@ -71,6 +71,7 @@ private:
void onActionAddTile(int tabId);
void onActionDeleteTile(int tabId);
void onActionDeleteImage(int tabId);
void onActionReplaceImage(int tabId);
TileModel* createTileModel();