Salome HOME
updated copyright message
[modules/gui.git] / src / LightApp / LightApp_Dialog.cxx
index 51d7510963991653d1423750dea857abc36e36c5..a6d4850e5ba1eeba5248190fc2d7bf549af1e6c7 100644 (file)
@@ -1,40 +1,47 @@
-// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-// 
+// Copyright (C) 2007-2023  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 
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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 
+// 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/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File:      LightApp_Dialog.cxx
 // Author:    Alexander SOLOVYOV
-
-#include <LightApp_Dialog.h>
+//
+#include "LightApp_Dialog.h"
 #include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
 
-#include <qtoolbutton.h>
-#include <qlineedit.h>
-#include <qlabel.h>
+#include <QAbstractButton>
+#include <QToolButton>
+#include <QLineEdit>
+#include <QLabel>
 
 /*!
   Constructor
 */
 LightApp_Dialog::LightApp_Dialog( QWidget* parent, const char* name, bool modal,
-                                  bool allowResize, const int f, WFlags wf )
-: QtxDialog( parent, name, modal, allowResize, f, wf ),
+                                  bool allowResize, const int f, Qt::WindowFlags wf )
+: QtxDialog( parent, modal, allowResize, f, wf ),
   myIsExclusive( true ),
   myIsBusy( false )
 {
+  setObjectName( name );
   setObjectPixmap( "LightApp", tr( "ICON_SELECT" ) );
 }
 
@@ -76,14 +83,14 @@ void LightApp_Dialog::updateButtons( const int _id )
                             aLast = myObjects.end();
   for( ; anIt!=aLast; anIt++ )
   {
-    QToolButton* but = (QToolButton*)anIt.data().myBtn;
-    if( but && but->isOn() )
+    QToolButton* but = (QToolButton*)anIt.value().myBtn;
+    if( but && but->isChecked() )
     {
       if( id==-1 )
         id = anIt.key();
 
       if( anIt.key()!=id )
-        but->setOn( false );
+        but->setChecked( false );
     }
   }
 }
@@ -126,11 +133,11 @@ void LightApp_Dialog::setObjectShown( const int id, const bool shown )
   if( myObjects.contains( id ) && isObjectShown( id )!=shown )
   {
     Object& obj = myObjects[ id ];
-    obj.myEdit->setShown( shown );
-    obj.myBtn->setShown( shown );
-    obj.myLabel->setShown( shown );
+    obj.myEdit->setVisible( shown );
+    obj.myBtn->setVisible( shown );
+    obj.myLabel->setVisible( shown );
     if( !shown )
-      ( ( QToolButton* )obj.myBtn )->setOn( false );
+      ( ( QToolButton* )obj.myBtn )->setChecked( false );
   }
 }
 
@@ -140,7 +147,9 @@ void LightApp_Dialog::setObjectShown( const int id, const bool shown )
 */
 bool LightApp_Dialog::isObjectShown( const int id ) const
 {
-  return myObjects.contains( id ) && myObjects[ id ].myEdit->isShown();
+  return myObjects.contains( id ) &&
+         ( myObjects[ id ].myEdit->isVisible() ||
+           myObjects[ id ].myEdit->isVisibleTo( myObjects[ id ].myEdit->parentWidget() ) );
 }
 
 /*!
@@ -157,7 +166,7 @@ void LightApp_Dialog::setObjectEnabled( const int id, const bool en )
     obj.myBtn->setEnabled( en );
 //    obj.myLabel->setEnabled( en );
     if( !en )
-      ( ( QToolButton* )obj.myBtn )->setOn( false );
+      ( ( QToolButton* )obj.myBtn )->setChecked( false );
   } 
 }
 
@@ -195,12 +204,12 @@ void LightApp_Dialog::selectObject( const QString& name, const int type, const Q
 void LightApp_Dialog::selectObject( const QStringList& _names,
                                      const TypesList& _types,
                                      const QStringList& _ids,
-                                    const bool update )
+                                     const bool update )
 {
   ObjectMap::iterator anIt = myObjects.begin(),
                       aLast = myObjects.end();
   for( ; anIt!=aLast; anIt++ )
-    if( anIt.data().myBtn->isOn() )
+    if( anIt.value().myBtn->isChecked() )
       selectObject( anIt.key(), _names, _types, _ids, update );
 }
 
@@ -233,7 +242,7 @@ void LightApp_Dialog::clearSelection( const int id )
     myObjects[ id ].myTypes.clear();
     myObjects[ id ].myNames.clear();
     
-    myObjects[ id ].myEdit->setText( QString::null );
+    myObjects[ id ].myEdit->setText( QString() );
     emit selectionChanged( id );
   }
 }
@@ -338,8 +347,8 @@ int LightApp_Dialog::createObject( const QString& label, QWidget* parent, const
     myObjects[ nid ].myLabel = lab;
     
     QToolButton* but = new QToolButton( parent );
-    but->setIconSet( QIconSet( myPixmap ) );
-    but->setToggleButton( true );
+    but->setIcon( QIcon( myPixmap ) );
+    but->setCheckable( true );
     but->setMaximumWidth( but->height() );
     but->setMinimumWidth( but->height() );    
     connect( but, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) );
@@ -542,7 +551,7 @@ void LightApp_Dialog::objectTypes( const int id, TypesList& list ) const
 */
 void LightApp_Dialog::onToggled( bool on )
 {
-  QButton* but = ( QButton* )sender();
+  QAbstractButton* but = ( QAbstractButton* )sender();
   int id = -1;
 
   if( !but )
@@ -551,10 +560,11 @@ void LightApp_Dialog::onToggled( bool on )
   ObjectMap::const_iterator anIt = myObjects.begin(),
                             aLast = myObjects.end();
   for( ; anIt!=aLast && id==-1; anIt++ )
-    if( anIt.data().myBtn==but )
+    if( anIt.value().myBtn==but )
       id = anIt.key();
 
   if( id!=-1 )
+  {
     if( on )
     {
       updateButtons( id );
@@ -562,6 +572,7 @@ void LightApp_Dialog::onToggled( bool on )
     }
     else
       emit objectDeactivated( id );
+  }
 }
 
 /*!
@@ -637,7 +648,7 @@ void LightApp_Dialog::setObjectPixmap( const QPixmap& p )
   ObjectMap::const_iterator anIt = myObjects.begin(),
                             aLast = myObjects.end();
   for( ; anIt!=aLast; anIt++ )
-    ( ( QToolButton* )anIt.data().myBtn )->setIconSet( p );
+    ( ( QToolButton* )anIt.value().myBtn )->setIcon( p );
 }                        
 
 /*!
@@ -687,7 +698,7 @@ void LightApp_Dialog::setNameIndication( const int id, const NameIndication ni )
                         aLast = myObjects.end();
     for( ; anIt!=aLast; anIt++ )
     {
-      anIt.data().myNI = ni;
+      anIt.value().myNI = ni;
       setReadOnly( anIt.key(), isReadOnly( anIt.key() ) );
       aNext = anIt; aNext++;
       updateObject( anIt.key(), aNext==aLast );
@@ -713,7 +724,7 @@ QString LightApp_Dialog::selectionDescription( const QStringList& names, const T
     return "LightApp_Dialog::selectionDescription(): Error!!!";
     
   if( names.isEmpty() )
-    return QString::null;
+    return QString();
     
   switch( ni )
   {
@@ -736,7 +747,7 @@ QString LightApp_Dialog::selectionDescription( const QStringList& names, const T
       return countOfTypes( types );
       break;
   };
-  return QString::null;
+  return QString();
 }
 
 /*!
@@ -759,7 +770,7 @@ QString LightApp_Dialog::countOfTypes( const TypesList& types ) const
   QMap<int,int>::const_iterator aMIt = typesCount.begin(),
                                 aMLast = typesCount.end();
   for( ; aMIt!=aMLast; aMIt++ )
-    typeCount.append( QString( "%1 %2" ).arg( aMIt.data() ).arg( typeName( aMIt.key() ) ) );
+    typeCount.append( QString( "%1 %2" ).arg( aMIt.value() ).arg( typeName( aMIt.key() ) ) );
 
   return typeCount.join( ", " );
 }
@@ -777,7 +788,7 @@ QString& LightApp_Dialog::typeName( const int type )
   \return const reference to type name
   \param type - integer id of type
 */
-const QString& LightApp_Dialog::typeName( const int type ) const
+const QString LightApp_Dialog::typeName( const int type ) const
 {
   return myTypeNames[ type ];
 }
@@ -789,7 +800,7 @@ const QString& LightApp_Dialog::typeName( const int type ) const
 */
 void LightApp_Dialog::activateObject( const int theId )
 {
-  if ( myObjects.contains( theId ) && !myObjects[ theId ].myBtn->isOn() )
+  if ( myObjects.contains( theId ) && !myObjects[ theId ].myBtn->isChecked() )
     myObjects[ theId ].myBtn->toggle();
 }
 
@@ -802,8 +813,8 @@ void LightApp_Dialog::deactivateAll()
                       aLast = myObjects.end();
   for( ; anIt!=aLast; anIt++ )
   {
-    QToolButton* btn = ( QToolButton* )anIt.data().myBtn;
-    btn->setOn( false );
+    QToolButton* btn = ( QToolButton* )anIt.value().myBtn;
+    btn->setChecked( false );
   }
 }
 
@@ -892,12 +903,12 @@ void LightApp_Dialog::onTextChanged( const QString& text )
     ObjectMap::const_iterator anIt = myObjects.begin(),
                               aLast = myObjects.end();
     for( ; anIt!=aLast; anIt++ )
-      if( anIt.data().myEdit == edit )
+      if( anIt.value().myEdit == edit )
         id = anIt.key();
 
     if( id>=0 && !isReadOnly( id ) )
     {
-      QStringList list = QStringList::split( " ", text );
+      QStringList list = text.split( " ", QString::SkipEmptyParts );
       emit objectChanged( id, list );
     }
   }