HYDROGUI_ImportImageOp.h
HYDROGUI_InputPanel.h
HYDROGUI_Module.h
+ HYDROGUI_NameValidator.h
HYDROGUI_ObjSelector.h
HYDROGUI_ObserveImageOp.h
HYDROGUI_OCCDisplayer.h
HYDROGUI_ImportImageOp.cxx
HYDROGUI_InputPanel.cxx
HYDROGUI_Module.cxx
+ HYDROGUI_NameValidator.cxx
HYDROGUI_ObjSelector.cxx
HYDROGUI_ObserveImageOp.cxx
HYDROGUI_OCCDisplayer.cxx
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_DataObject.h"
+#include "HYDROGUI_NameValidator.h"
#include <HYDROData_Document.h>
#include <HYDROData_Entity.h>
#include <SUIT_Session.h>
#include <SUIT_Study.h>
+#include <LightApp_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+
#include <QGroupBox>
#include <QLabel>
#include <QLayout>
// myObjectName = new QLineEdit( myObjectNameGroup );
myObjectName = new QLineEdit( aPage );
+ myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
+ myObjectName->setValidator( myValidator );
+
+ connect( myValidator, SIGNAL( emptyName() ), this, SLOT( onEmptyName() ) );
+ connect( myValidator, SIGNAL( alreadyExists( QString ) ), this, SLOT( onAlreadyExists( QString ) ) );
//QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
//aNameLayout->setMargin( 5 );
return aPage;
}
+void HYDROGUI_CalculationDlg::onEmptyName()
+{
+ QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
+ QString aMessage = QObject::tr( "INCORRECT_OBJECT_NAME" );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
+}
+
+void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
+{
+ QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
+ QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
+}
+
QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
QWizardPage* aPage = new QWizardPage( wizard() );
QFrame* aFrame = new QFrame( aPage );
void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
{
myEditedObject = theCase;
+ myValidator->setEditedObject( theCase );
HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" );
myBrowser->setRoot(anobj);
LightApp_DataObject* aCaseItem = module()->getDataModel()->createObject( anobj,
myEditedObject, "", true );
-
myBrowser->updateTree();
myBrowser->openLevels();
}
class QListWidget;
class QComboBox;
class HYDROGUI_DataBrowser;
+class HYDROGUI_NameValidator;
class HYDROGUI_CalculationDlg : public HYDROGUI_Wizard
{
void setSelectedGeomObjects( const QStringList& theObjects );
QStringList getSelectedGeomObjects() const;
+ public slots:
+ void onEmptyName();
+ void onAlreadyExists( QString theName );
private:
QWizardPage* createObjectsPage();
QGroupBox* myObjectNameGroup;
QLineEdit* myObjectName;
+ HYDROGUI_NameValidator* myValidator;
QListWidget* myGeomObjects;
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_NameValidator.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Module.h"
+
+HYDROGUI_NameValidator::HYDROGUI_NameValidator( HYDROGUI_Module* theModule, QObject* parent )
+: QValidator( parent ), myModule( theModule )
+{
+}
+
+HYDROGUI_NameValidator::~HYDROGUI_NameValidator()
+{
+}
+
+QValidator::State HYDROGUI_NameValidator::validate( QString & theName, int & thePos ) const
+{
+ State aRes = Acceptable;
+ QString aName = theName.simplified();
+
+ if ( aName.isEmpty() )
+ {
+ aRes = Intermediate;
+ }
+ else if( !myEditedObject.IsNull() && myEditedObject->GetName() != theName )
+ {
+ // check that there are no other objects with the same name in the document
+ Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( myModule, aName );
+ if ( !anObject.IsNull() )
+ {
+ aRes = Intermediate;
+ }
+ }
+
+ return aRes;
+}
+
+void HYDROGUI_NameValidator::fixup( QString & theName ) const
+{
+ theName = theName.simplified();
+ if ( theName.isEmpty() )
+ {
+ emit emptyName();
+ }
+ else
+ {
+ emit alreadyExists( theName );
+ }
+
+ theName = myEditedObject->GetName();
+}
+
+void HYDROGUI_NameValidator::setEditedObject( const Handle(HYDROData_Entity) theObj )
+{
+ myEditedObject = theObj;
+}
--- /dev/null
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_NAMEVALIDATOR_H
+#define HYDROGUI_NAMEVALIDATOR_H
+
+#include <HYDROData_Entity.h>
+#include <QValidator>
+
+class HYDROGUI_Module;
+
+class HYDROGUI_NameValidator : public QValidator
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_NameValidator( HYDROGUI_Module* theModule, QObject* parent = 0 );
+ virtual ~HYDROGUI_NameValidator();
+
+ State validate ( QString & theName, int & thePos ) const override;
+ void fixup ( QString & input ) const override;
+
+ void setEditedObject( const Handle(HYDROData_Entity) theObj );
+
+signals:
+ void emptyName() const;
+ void alreadyExists( QString theName ) const;
+
+private:
+ HYDROGUI_Module* myModule;
+ Handle(HYDROData_Entity) myEditedObject;
+};
+
+#endif