mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 23:56:15 +00:00
Don't allow 2 tilesets to have the same name.
This commit is contained in:
parent
d6524e27ff
commit
147c5604e0
4 changed files with 27 additions and 9 deletions
|
@ -226,16 +226,14 @@ 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())
|
||||||
//{
|
//{
|
||||||
// if(!model->insertRow(index.row()+1, index.parent()))
|
// if(!model->insertRow(index.row()+1, index.parent()))
|
||||||
|
|
|
@ -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