From 9294cdc644d97f9773ba07314907108b132036be Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 4 Jul 2013 01:51:02 +0200 Subject: [PATCH] We don't want duplicate passes. --HG-- branch : gsoc2013-dfighter --- .../plugins/material_editor/render_passes.cpp | 38 +++++++++++++------ .../plugins/material_editor/render_passes.h | 1 + 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp index a77161c34..51dc25a51 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.cpp @@ -84,6 +84,19 @@ namespace MaterialEditor connect( downButton, SIGNAL( clicked( bool ) ), this, SLOT( onDownClicked() ) ); } + bool RenderPassesWidget::passExists( const QString &label ) + { + int c = listWidget->count(); + + for( int i = 0; i < c; i++ ) + { + if( label == listWidget->item( i )->text() ) + return true; + } + + return false; + } + void RenderPassesWidget::onOKClicked() { close(); @@ -101,17 +114,7 @@ namespace MaterialEditor if( label.isEmpty() ) return; - int i = 0; - while( i < listWidget->count() ) - { - QListWidgetItem *item = listWidget->item( i ); - QString text = item->text(); - if( text == label ) - break; - i++; - } - - if( i < listWidget->count() ) + if( passExists( label ) ) { QMessageBox::warning( NULL, @@ -168,6 +171,19 @@ namespace MaterialEditor if( to.isEmpty() ) return; + if( from == to ) + return; + + if( passExists( to ) ) + { + QMessageBox::warning( + NULL, + tr( "Pass label" ), + tr( "Pass label already exists!" ) + ); + return; + } + item->setText( to ); CNelMaterialProxy material = nl3dIface->getMaterial(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h index 4388b2cd5..e4d4666f3 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/material_editor/render_passes.h @@ -40,6 +40,7 @@ namespace MaterialEditor private: void setupConnections(); + bool passExists( const QString &label ); CNel3DInterface *nl3dIface; CMaterialObserver *observer;