Don't allow 2 tilesets to have the same name.
--HG-- branch : gsoc2014-dfighter
This commit is contained in:
parent
dcc072ba18
commit
4d6de3f737
4 changed files with 27 additions and 9 deletions
code/studio/src/plugins/tile_editor
|
@ -226,15 +226,13 @@ void TileEditorMainWindow::onTileSetAdd()
|
|||
QString text = QInputDialog::getText(this, tr("Add Tile Set"), tr("Enter Tile Set name:"), QLineEdit::Normal, "", &ok);
|
||||
if (ok && !text.isEmpty())
|
||||
{
|
||||
//if (ui.tileSetListWidget->findItems(text, Qt::MatchExactly).count() > 0)
|
||||
//{
|
||||
// QMessageBox::information( this, tr("Error Adding Tile Set"), tr("This name already exists") );
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
||||
//QModelIndex index = m_ui->tileSetLV->selectionModel()->currentIndex();
|
||||
TileModel *model = static_cast<TileModel*>(m_ui->tileSetLV->model());
|
||||
|
||||
if( model->hasTileSet( text ) )
|
||||
{
|
||||
QMessageBox::information( this, tr("Error Adding Tile Set"), tr("This name already exists") );
|
||||
return;
|
||||
}
|
||||
|
||||
//if(index.isValid())
|
||||
//{
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
QVariant data(int column, int role) const;
|
||||
int columnCount() const;
|
||||
|
||||
const QString &getTileSetName();
|
||||
const QString &getTileSetName(){ return m_tileSetName; }
|
||||
private:
|
||||
QString m_tileSetName;
|
||||
};
|
||||
|
|
|
@ -219,6 +219,24 @@ uint32 TileModel::getTileTypeSize(TileModel::TNodeTileType type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool TileModel::hasTileSet( const QString &name )
|
||||
{
|
||||
for( int i = 0; i < rowCount(); i++ )
|
||||
{
|
||||
QModelIndex idx = index( i, 0 );
|
||||
if( !idx.isValid() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TileSetNode *n = reinterpret_cast< TileSetNode* >( idx.internalPointer() );
|
||||
if( n->getTileSetName() == name )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TileModel::selectFilenameDisplay(bool selected)
|
||||
{
|
||||
m_fileDisplay = selected;
|
||||
|
|
|
@ -87,6 +87,8 @@ public:
|
|||
|
||||
static TTileZoomFactor CurrentZoomFactor;
|
||||
|
||||
bool hasTileSet( const QString &name );
|
||||
|
||||
public Q_SLOTS:
|
||||
void selectFilenameDisplay(bool selected);
|
||||
void selectIndexDisplay(bool selected);
|
||||
|
|
Loading…
Reference in a new issue