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
|
@ -226,15 +226,13 @@ void TileEditorMainWindow::onTileSetAdd()
|
||||||
QString text = QInputDialog::getText(this, tr("Add Tile Set"), tr("Enter Tile Set name:"), QLineEdit::Normal, "", &ok);
|
QString text = QInputDialog::getText(this, tr("Add Tile Set"), tr("Enter Tile Set name:"), QLineEdit::Normal, "", &ok);
|
||||||
if (ok && !text.isEmpty())
|
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());
|
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())
|
//if(index.isValid())
|
||||||
//{
|
//{
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
int columnCount() const;
|
int columnCount() const;
|
||||||
|
|
||||||
const QString &getTileSetName();
|
const QString &getTileSetName(){ return m_tileSetName; }
|
||||||
private:
|
private:
|
||||||
QString m_tileSetName;
|
QString m_tileSetName;
|
||||||
};
|
};
|
||||||
|
|
|
@ -219,6 +219,24 @@ uint32 TileModel::getTileTypeSize(TileModel::TNodeTileType type)
|
||||||
return 0;
|
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)
|
void TileModel::selectFilenameDisplay(bool selected)
|
||||||
{
|
{
|
||||||
m_fileDisplay = selected;
|
m_fileDisplay = selected;
|
||||||
|
|
|
@ -87,6 +87,8 @@ public:
|
||||||
|
|
||||||
static TTileZoomFactor CurrentZoomFactor;
|
static TTileZoomFactor CurrentZoomFactor;
|
||||||
|
|
||||||
|
bool hasTileSet( const QString &name );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void selectFilenameDisplay(bool selected);
|
void selectFilenameDisplay(bool selected);
|
||||||
void selectIndexDisplay(bool selected);
|
void selectIndexDisplay(bool selected);
|
||||||
|
|
Loading…
Reference in a new issue