Salome HOME
Copyright update 2022
[modules/gui.git] / src / SalomeApp / SalomeApp_ListView.cxx
index b86831fa17bc7f33f48d6b993d3ed6e171292416..a2f0984c50218b79b794582ddfe1d21bb653b0a7 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  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
+// 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 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, 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File   : SalomeApp_ListView.cxx
 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 //
@@ -28,6 +29,8 @@
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Session.h"
 
+#include "utilities.h"
+
 #include <QValidator>
 #include <QToolButton>
 #include <QPixmap>
@@ -81,7 +84,7 @@ SalomeApp_ListView::SalomeApp_ListView( QWidget* parent )
   setRootIsDecorated(false);
   setAllColumnsShowFocus(false);
 //  header()->setClickEnabled(false);
-  header()->setMovable(false);
+  header()->setSectionsMovable(false);
 
   myEditedItem = 0;
   myEdit = 0;
@@ -89,9 +92,9 @@ SalomeApp_ListView::SalomeApp_ListView( QWidget* parent )
   viewport()->installEventFilter(this);
 
   connect(this, SIGNAL(itemSelectionChanged()),
-         this, SLOT(onSelectionChanged()));
+          this, SLOT(onSelectionChanged()));
   connect(header(), SIGNAL(sizeChange(int, int, int)),
-         this,     SLOT(onHeaderSizeChange(int, int, int)));
+          this,     SLOT(onHeaderSizeChange(int, int, int)));
 }
 
 /*!
@@ -330,10 +333,10 @@ UpdateType SalomeApp_ListView::finishEditing(bool ok)
     if (ok) {
       aNeedsUpdate = myEditedItem->finishEditing(myEdit);
       if (aNeedsUpdate == utCancel) {
-       // something to do here on Cancel...
+        // something to do here on Cancel...
       }
       else {
-       // something to do here on OK...
+        // something to do here on OK...
       }
       // updating contents
       switch (aNeedsUpdate) {
@@ -385,9 +388,9 @@ UpdateType SalomeApp_ListView::finishEditing(bool ok)
   \retval valid rect in success
 */
 QRect SalomeApp_ListView::tip(QPoint aPos,
-                             QString& aText,
-                             QRect& dspRect,
-                             QFont& dspFnt) const
+                              QString& aText,
+                              QRect& dspRect,
+                              QFont& dspFnt) const
 {
   QRect result( -1, -1, -1, -1 );
   SalomeApp_ListViewItem* aItem = (SalomeApp_ListViewItem*)itemAt( aPos );
@@ -396,15 +399,15 @@ QRect SalomeApp_ListView::tip(QPoint aPos,
       QRect aItemRect = aItem->itemRect(i);
       QRect aTextRect = aItem->textRect(i);
       if ( !aItem->text(i).isEmpty() &&
-          ( aItemRect.width()  > header()->sectionSize(i) ||
-            aTextRect.left()   < 0 ||
+           ( aItemRect.width()  > header()->sectionSize(i) ||
+             aTextRect.left()   < 0 ||
              aTextRect.top()    < 0 ||
              aTextRect.right()  > viewport()->width() ||
              aTextRect.bottom() > viewport()->height() ) ) {
         // calculating tip data
         aText   = aItem->tipText();
-       dspRect = aItem->tipRect();
-       dspFnt  = font();
+        dspRect = aItem->tipRect();
+        dspFnt  = font();
         if (dspRect.isValid()) {
           result  = QRect(QPoint(0, aItemRect.top()),
                           QSize(viewport()->width(), aItemRect.height()));
@@ -428,7 +431,7 @@ QTreeWidgetItem( parent )
   Constructor
 */
 SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView*     parent,
-                                              SalomeApp_ListViewItem* after) :
+                                               SalomeApp_ListViewItem* after) :
 QTreeWidgetItem( parent, after )
 {
   init();
@@ -438,8 +441,8 @@ QTreeWidgetItem( parent, after )
   Constructor
 */
 SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView*     parent,
-                                              const QStringList&    theStrings,
-                                              const bool        theEditable) :
+                                               const QStringList&    theStrings,
+                                               const bool        theEditable) :
 QTreeWidgetItem(parent, theStrings)
 {
   init();
@@ -450,8 +453,8 @@ QTreeWidgetItem(parent, theStrings)
   Constructor
 */
 SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListViewItem* parent,
-                                              const QStringList&    theString,
-                                              const bool        theEditable) :
+                                               const QStringList&    theString,
+                                               const bool        theEditable) :
 QTreeWidgetItem(parent, theString)
 {
   init();
@@ -462,9 +465,9 @@ QTreeWidgetItem(parent, theString)
   Constructor
 */
 SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListViewItem* parent,
-                                              SalomeApp_ListViewItem* after,
-                                              const QString&    theName,
-                                              const bool        theEditable) :
+                                               SalomeApp_ListViewItem* after,
+                                               const QString&    theName,
+                                               const bool        theEditable) :
 QTreeWidgetItem(parent, after)
 {
   setData(0,Qt::DisplayRole,QVariant(theName));
@@ -476,9 +479,9 @@ QTreeWidgetItem(parent, after)
   Constructor
 */
 SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView*     parent,
-                                              SalomeApp_ListViewItem* after,
-                                              const QString&    theName,
-                                              const bool        theEditable) :
+                                               SalomeApp_ListViewItem* after,
+                                               const QString&    theName,
+                                               const bool        theEditable) :
 QTreeWidgetItem(parent, after)
 {
   setData(0,Qt::DisplayRole,QVariant(theName));
@@ -490,10 +493,10 @@ QTreeWidgetItem(parent, after)
   Constructor
 */
 SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListViewItem* parent,
-                                              SalomeApp_ListViewItem* after,
-                                              const QString&    theName,
-                                              const QString&    theValue,
-                                              const bool        theEditable) :
+                                               SalomeApp_ListViewItem* after,
+                                               const QString&    theName,
+                                               const QString&    theValue,
+                                               const bool        theEditable) :
 QTreeWidgetItem(parent, after)
 {
   setData(0,Qt::DisplayRole,QVariant(theName));
@@ -506,10 +509,10 @@ QTreeWidgetItem(parent, after)
   Constructor
 */
 SalomeApp_ListViewItem::SalomeApp_ListViewItem(SalomeApp_ListView*     parent,
-                                              SalomeApp_ListViewItem* after,
-                                              const QString&    theName,
-                                              const QString&    theValue,
-                                              const bool        theEditable) :
+                                               SalomeApp_ListViewItem* after,
+                                               const QString&    theName,
+                                               const QString&    theValue,
+                                               const bool        theEditable) :
 QTreeWidgetItem(parent, after)
 {
   setData(0,Qt::DisplayRole,QVariant(theName));
@@ -767,9 +770,9 @@ SalomeApp_EntityEdit* SalomeApp_ListViewItem::startEditing()
       return 0;
     aWidget = new SalomeApp_EntityEdit(aListView->viewport(),
                                  anEditType,
-                                aValueType,
-                                aButtons & SalomeApp_EntityEdit::btApply,
-                                aButtons & SalomeApp_EntityEdit::btCancel);
+                                 aValueType,
+                                 aButtons & SalomeApp_EntityEdit::btApply,
+                                 aButtons & SalomeApp_EntityEdit::btCancel);
     computeEditGeometry(this, aWidget);
 
     fillWidgetWithValues(aWidget);
@@ -966,7 +969,7 @@ int SalomeApp_ComboBox::findItem(const QString& theText)
   Adds item in combo box
 */
 void SalomeApp_ComboBox::insertItem(const QString& theValue,
-                                   int            theIndex)
+                                    int            theIndex)
 {
   if (duplicatesEnabled() || findItem(theValue) < 0)
     QComboBox::insertItem(theIndex, theValue);
@@ -977,7 +980,7 @@ void SalomeApp_ComboBox::insertItem(const QString& theValue,
 */
 void SalomeApp_ComboBox::insertList(const QStringList& theList)
 {
-  for (unsigned i = 0; i < theList.count(); i++)
+  for (int i = 0; i < theList.count(); i++)
     insertItem(theList[i]);
 }
 
@@ -1046,10 +1049,10 @@ void SalomeApp_ComboBox::insertList(const TColStd_ListOfReal& theList)
   Constructor
 */
 SalomeApp_EntityEdit::SalomeApp_EntityEdit(QWidget* parent,
-                              int      controlType,
-                              int      valueType,
-                              bool     butApply,
-                              bool     butCancel) :
+                               int      controlType,
+                               int      valueType,
+                               bool     butApply,
+                               bool     butCancel) :
 QWidget(parent),
 myEdit(0),
 myCombo(0),
@@ -1185,8 +1188,8 @@ void SalomeApp_EntityEdit::setText(const QString& theText)
   Adds item in combo box, sets it current if theSetCurrent is true
 */
 void SalomeApp_EntityEdit::insertItem(const QString& theValue,
-                               bool           theSetCurrent,
-                               int            theOrder)
+                                bool           theSetCurrent,
+                                int            theOrder)
 {
   if (myCombo) {
     int aIndexAt = -1;
@@ -1208,7 +1211,7 @@ void SalomeApp_EntityEdit::insertItem(const QString& theValue,
   Adds items in combo box, sets item theCurrent as current
 */
 void SalomeApp_EntityEdit::insertList(const QStringList& theList,
-                               const int          theCurrent)
+                                const int          theCurrent)
 {
   if (myCombo)
     myCombo->insertList(theList);
@@ -1220,7 +1223,7 @@ void SalomeApp_EntityEdit::insertList(const QStringList& theList,
   Adds item in combo box, sets it current if theSetCurrent is true
 */
 void SalomeApp_EntityEdit::insertItem(const int theValue,
-                               bool      theSetCurrent)
+                                bool      theSetCurrent)
 {
   if (myCombo) {
     myCombo->insertItem(theValue);
@@ -1233,14 +1236,14 @@ void SalomeApp_EntityEdit::insertItem(const int theValue,
   Adds items in combo box, sets item theCurrent as current
 */
 void SalomeApp_EntityEdit::insertList(const TColStd_ListOfInteger& theList,
-                               const int                    theCurrent)
+                                const int                    theCurrent)
 {
   if (myCombo)
     myCombo->insertList(theList);
 
   TColStd_ListIteratorOfListOfInteger aIter(theList);
   for (unsigned i = 0; aIter.More(); aIter.Next(), i++) {
-    if (theCurrent == i) {
+    if (theCurrent == (int)i) { //!< TODO: mismatch signed/unsigned
       setText(QString::number(aIter.Value()));
       break;
     }
@@ -1251,7 +1254,7 @@ void SalomeApp_EntityEdit::insertList(const TColStd_ListOfInteger& theList,
   Adds item in combo box, sets it current if theSetCurrent is true
 */
 void SalomeApp_EntityEdit::insertItem(const double theValue,
-                               bool         theSetCurrent)
+                                bool         theSetCurrent)
 {
   if (myCombo) {
     myCombo->insertItem(theValue);
@@ -1264,14 +1267,14 @@ void SalomeApp_EntityEdit::insertItem(const double theValue,
   Adds items in combo box, sets item theCurrent as current
 */
 void SalomeApp_EntityEdit::insertList(const TColStd_ListOfReal& theList,
-                               const int                 theCurrent)
+                                const int                 theCurrent)
 {
   if (myCombo)
     myCombo->insertList(theList);
 
   TColStd_ListIteratorOfListOfReal aIter(theList);
   for (unsigned i = 0; aIter.More(); aIter.Next(), i++) {
-    if (theCurrent == i) {
+    if (theCurrent == (int)i) { //!< TODO: mismatch signed/unsigned
       setText(QString::number(aIter.Value()));
       break;
     }