From 2904bb5e64e69d27c643e66e3dd727c5110ec275 Mon Sep 17 00:00:00 2001 From: mzn Date: Tue, 25 Mar 2014 14:15:46 +0000 Subject: [PATCH] Renaming, add selector for selection synchronization. --- src/HYDROGUI/CMakeLists.txt | 12 +- ...LevelsModel.cxx => HYDROGUI_ListModel.cxx} | 45 +-- ...UI_ZLevelsModel.h => HYDROGUI_ListModel.h} | 15 +- src/HYDROGUI/HYDROGUI_ListSelector.cxx | 95 +++++++ src/HYDROGUI/HYDROGUI_ListSelector.h | 59 ++++ src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx | 256 ++++++++++++++++++ src/HYDROGUI/HYDROGUI_OrderedListWidget.h | 75 +++++ src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx | 146 ++-------- src/HYDROGUI/HYDROGUI_ZLevelsDlg.h | 32 +-- src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx | 19 +- ...sModel.cxx => test_HYDROGUI_ListModel.cxx} | 42 +-- ...evelsModel.h => test_HYDROGUI_ListModel.h} | 12 +- 12 files changed, 603 insertions(+), 205 deletions(-) rename src/HYDROGUI/{HYDROGUI_ZLevelsModel.cxx => HYDROGUI_ListModel.cxx} (86%) rename src/HYDROGUI/{HYDROGUI_ZLevelsModel.h => HYDROGUI_ListModel.h} (89%) create mode 100644 src/HYDROGUI/HYDROGUI_ListSelector.cxx create mode 100644 src/HYDROGUI/HYDROGUI_ListSelector.h create mode 100644 src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx create mode 100644 src/HYDROGUI/HYDROGUI_OrderedListWidget.h rename src/HYDROGUI/{test_HYDROGUI_ZLevelsModel.cxx => test_HYDROGUI_ListModel.cxx} (92%) rename src/HYDROGUI/{test_HYDROGUI_ZLevelsModel.h => test_HYDROGUI_ListModel.h} (50%) diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 95a1d878..f31a04a8 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -86,9 +86,11 @@ set(PROJECT_HEADERS HYDROGUI_BathymetryBoundsOp.h HYDROGUI_TranslateObstacleDlg.h HYDROGUI_TranslateObstacleOp.h - HYDROGUI_ZLevelsModel.h + HYDROGUI_ListModel.h HYDROGUI_ZLevelsDlg.h HYDROGUI_ZLevelsOp.h + HYDROGUI_OrderedListWidget.h + HYDROGUI_ListSelector.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -176,9 +178,11 @@ set(PROJECT_SOURCES HYDROGUI_BathymetryBoundsOp.cxx HYDROGUI_TranslateObstacleDlg.cxx HYDROGUI_TranslateObstacleOp.cxx - HYDROGUI_ZLevelsModel.cxx + HYDROGUI_ListModel.cxx HYDROGUI_ZLevelsDlg.cxx HYDROGUI_ZLevelsOp.cxx + HYDROGUI_OrderedListWidget.cxx + HYDROGUI_ListSelector.cxx ) add_definitions( @@ -238,12 +242,12 @@ INSTALL(FILES ${GUI_DATA} DESTINATION ${SALOME_HYDRO_INSTALL_RES_DATA}) if(SALOME_BUILD_TESTS) set(TEST_HEADERS - test_HYDROGUI_ZLevelsModel.h + test_HYDROGUI_ListModel.h ) set(TEST_SOURCES test_HYDROGUI_Main.cxx - test_HYDROGUI_ZLevelsModel.cxx + test_HYDROGUI_ListModel.cxx ) set(TEST_EXE test_HYDROGUI) diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsModel.cxx b/src/HYDROGUI/HYDROGUI_ListModel.cxx similarity index 86% rename from src/HYDROGUI/HYDROGUI_ZLevelsModel.cxx rename to src/HYDROGUI/HYDROGUI_ListModel.cxx index 326d167d..bfda69d9 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsModel.cxx +++ b/src/HYDROGUI/HYDROGUI_ListModel.cxx @@ -20,7 +20,9 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "HYDROGUI_ZLevelsModel.h" +#include "HYDROGUI_ListModel.h" + +#include "HYDROGUI_DataObject.h" #include #include @@ -34,7 +36,7 @@ const QString OBJ_LIST_MIME_TYPE = "application/hydro.objects.list"; Constructor. @param theParent the parent object */ -HYDROGUI_ZLevelsModel::HYDROGUI_ZLevelsModel( QObject* theParent ) +HYDROGUI_ListModel::HYDROGUI_ListModel( QObject* theParent ) : QAbstractListModel( theParent ) { // Get resource manager @@ -61,13 +63,13 @@ HYDROGUI_ZLevelsModel::HYDROGUI_ZLevelsModel( QObject* theParent ) /** Destructor. */ -HYDROGUI_ZLevelsModel::~HYDROGUI_ZLevelsModel() +HYDROGUI_ListModel::~HYDROGUI_ListModel() { } /** */ -QVariant HYDROGUI_ZLevelsModel::data( const QModelIndex &theIndex, int theRole ) const +QVariant HYDROGUI_ListModel::data( const QModelIndex &theIndex, int theRole ) const { QVariant aVariant; @@ -105,6 +107,13 @@ QVariant HYDROGUI_ZLevelsModel::data( const QModelIndex &theIndex, int theRole ) return QVariant( isVisible ).toString(); } break; + case HYDROGUI_EntryRole: + { + if( aColumn==0 && aRow >=0 && aRow < myObjects.count() ) { + aVariant = HYDROGUI_DataObject::dataObjectEntry( myObjects.at( aRow ).first ); + } + } + break; } return aVariant; @@ -112,7 +121,7 @@ QVariant HYDROGUI_ZLevelsModel::data( const QModelIndex &theIndex, int theRole ) /** */ -int HYDROGUI_ZLevelsModel::rowCount( const QModelIndex &theParent ) const +int HYDROGUI_ListModel::rowCount( const QModelIndex &theParent ) const { return myObjects.count(); } @@ -121,7 +130,7 @@ int HYDROGUI_ZLevelsModel::rowCount( const QModelIndex &theParent ) const Set objects list. @param theObjects the list of pairs (object; object visibility) */ -void HYDROGUI_ZLevelsModel::setObjects( const Object2VisibleList& theObjects ) +void HYDROGUI_ListModel::setObjects( const Object2VisibleList& theObjects ) { myObjects = theObjects; @@ -132,7 +141,7 @@ void HYDROGUI_ZLevelsModel::setObjects( const Object2VisibleList& theObjects ) Get objects list. @return the list of objects ordered according to the model */ -HYDROGUI_ZLevelsModel::ObjectList HYDROGUI_ZLevelsModel::getObjects() const +HYDROGUI_ListModel::ObjectList HYDROGUI_ListModel::getObjects() const { ObjectList anObjects; @@ -148,7 +157,7 @@ HYDROGUI_ZLevelsModel::ObjectList HYDROGUI_ZLevelsModel::getObjects() const @param theIndex the object index @return true if the object is visible, false - otherwise */ -bool HYDROGUI_ZLevelsModel::isObjectVisible( int theIndex ) const +bool HYDROGUI_ListModel::isObjectVisible( int theIndex ) const { bool isVisible = false; @@ -161,7 +170,7 @@ bool HYDROGUI_ZLevelsModel::isObjectVisible( int theIndex ) const /** */ -QVariant HYDROGUI_ZLevelsModel::headerData( int theSection, +QVariant HYDROGUI_ListModel::headerData( int theSection, Qt::Orientation theOrientation, int theRole ) const { @@ -180,7 +189,7 @@ QVariant HYDROGUI_ZLevelsModel::headerData( int theSection, /** */ -Qt::ItemFlags HYDROGUI_ZLevelsModel::flags( const QModelIndex& theIndex ) const +Qt::ItemFlags HYDROGUI_ListModel::flags( const QModelIndex& theIndex ) const { Qt::ItemFlags aDefaultFlags = QAbstractListModel::flags( theIndex ); if( theIndex.isValid() ) @@ -191,7 +200,7 @@ Qt::ItemFlags HYDROGUI_ZLevelsModel::flags( const QModelIndex& theIndex ) const /** */ -QMimeData* HYDROGUI_ZLevelsModel::mimeData( const QModelIndexList& theIndexes ) const +QMimeData* HYDROGUI_ListModel::mimeData( const QModelIndexList& theIndexes ) const { QMimeData* aMimeData = new QMimeData(); QByteArray anEncodedData; @@ -207,7 +216,7 @@ QMimeData* HYDROGUI_ZLevelsModel::mimeData( const QModelIndexList& theIndexes ) /** */ -QStringList HYDROGUI_ZLevelsModel::mimeTypes() const +QStringList HYDROGUI_ListModel::mimeTypes() const { QStringList aTypes; aTypes << OBJ_LIST_MIME_TYPE; @@ -216,7 +225,7 @@ QStringList HYDROGUI_ZLevelsModel::mimeTypes() const /** */ -bool HYDROGUI_ZLevelsModel::dropMimeData( const QMimeData* theData, Qt::DropAction theAction, +bool HYDROGUI_ListModel::dropMimeData( const QMimeData* theData, Qt::DropAction theAction, int theRow, int theColumn, const QModelIndex& theParent ) { if( theAction == Qt::IgnoreAction) @@ -246,7 +255,7 @@ bool HYDROGUI_ZLevelsModel::dropMimeData( const QMimeData* theData, Qt::DropActi /** */ -Qt::DropActions HYDROGUI_ZLevelsModel::supportedDropActions() const +Qt::DropActions HYDROGUI_ListModel::supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } @@ -256,7 +265,7 @@ Qt::DropActions HYDROGUI_ZLevelsModel::supportedDropActions() const @param theIsToSort defines if the list of ids should be sorted in ascending order @return the list of ids */ -QList HYDROGUI_ZLevelsModel::getIds( const QModelIndexList& theIndexes, bool theIsToSort ) const +QList HYDROGUI_ListModel::getIds( const QModelIndexList& theIndexes, bool theIsToSort ) const { QList anIds; foreach( const QModelIndex& anIndex, theIndexes ) { @@ -278,7 +287,7 @@ QList HYDROGUI_ZLevelsModel::getIds( const QModelIndexList& theIndexes, boo @param theDropItem the drop item id ( used for drag and drop obly ) @return true in case of success */ -bool HYDROGUI_ZLevelsModel::move( const int theItem, const OpType theType, +bool HYDROGUI_ListModel::move( const int theItem, const OpType theType, bool theIsVisibleOnly, const int theDropItem ) { bool aRes = false; @@ -352,7 +361,7 @@ bool HYDROGUI_ZLevelsModel::move( const int theItem, const OpType theType, @param theDropItem the drop item id ( used for drag and drop obly ) @return true in case of success */ -bool HYDROGUI_ZLevelsModel::move( const QList& theItems, const OpType theType, +bool HYDROGUI_ListModel::move( const QList& theItems, const OpType theType, bool theIsVisibleOnly, const int theDropItem ) { bool aRes = true; @@ -427,7 +436,7 @@ bool HYDROGUI_ZLevelsModel::move( const QList& theItems, const OpType theTy @param theDropItem the drop item id @return true if drag and drop allowed */ -bool HYDROGUI_ZLevelsModel::isDragAndDropAllowed( const QList& theItems, +bool HYDROGUI_ListModel::isDragAndDropAllowed( const QList& theItems, const int theDropItem ) const { bool isAllowed = false; diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsModel.h b/src/HYDROGUI/HYDROGUI_ListModel.h similarity index 89% rename from src/HYDROGUI/HYDROGUI_ZLevelsModel.h rename to src/HYDROGUI/HYDROGUI_ListModel.h index 356de24b..12ca7f71 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsModel.h +++ b/src/HYDROGUI/HYDROGUI_ListModel.h @@ -20,8 +20,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef HYDROGUI_ZLEVELSMODEL_H -#define HYDROGUI_ZLEVELSMODEL_H +#ifndef HYDROGUI_ListModel_H +#define HYDROGUI_ListModel_H #include #include @@ -29,12 +29,13 @@ #include const int HYDROGUI_VisibleRole = Qt::UserRole + 1; +const int HYDROGUI_EntryRole = Qt::UserRole + 2; /** - * \class HYDROGUI_ZLevelsModel + * \class HYDROGUI_ListModel * \brief The class representing custom list model for the Z levels */ -class HYDRO_EXPORT HYDROGUI_ZLevelsModel : public QAbstractListModel +class HYDRO_EXPORT HYDROGUI_ListModel : public QAbstractListModel { Q_OBJECT @@ -46,8 +47,8 @@ public: typedef QList ObjectList; public: - HYDROGUI_ZLevelsModel( QObject* theParent = 0 ); - virtual ~HYDROGUI_ZLevelsModel(); + HYDROGUI_ListModel( QObject* theParent = 0 ); + virtual ~HYDROGUI_ListModel(); virtual QVariant data( const QModelIndex &theIndex, int theRole = Qt::DisplayRole ) const; @@ -78,7 +79,7 @@ protected: bool isDragAndDropAllowed( const QList& theItems, const int theDropItem ) const; private: - friend class test_HYDROGUI_ZLevelsModel; + friend class test_HYDROGUI_ListModel; Object2VisibleList myObjects; QPixmap myEmpty, myEye; diff --git a/src/HYDROGUI/HYDROGUI_ListSelector.cxx b/src/HYDROGUI/HYDROGUI_ListSelector.cxx new file mode 100644 index 00000000..d060381f --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ListSelector.cxx @@ -0,0 +1,95 @@ +// 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_ListSelector.h" + +#include "HYDROGUI_OrderedListWidget.h" + +#include + + +HYDROGUI_ListSelector::HYDROGUI_ListSelector( HYDROGUI_OrderedListWidget* theListWidget, + SUIT_SelectionMgr* theSelectionMgr ) +: SUIT_Selector( theSelectionMgr, theListWidget ), + myListWidget( theListWidget ) +{ + if ( myListWidget ) { + connect( myListWidget, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); + } +} + +/** + Destructor. +*/ +HYDROGUI_ListSelector::~HYDROGUI_ListSelector() +{ +} + +/*! + Get selector type. + @return the selector type +*/ +QString HYDROGUI_ListSelector::type() const +{ + return "ListSelector"; +} + +/** +*/ +void HYDROGUI_ListSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const +{ + QStringList aSelectedEntries = myListWidget->getSelectedEntries(); + + foreach ( const QString& anEntry, aSelectedEntries ) { + if ( !anEntry.isEmpty() ) { + theList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( anEntry ) ) ); + } + } +} + +/** +*/ +void HYDROGUI_ListSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) +{ + if ( !myListWidget ) { + return; + } + + QStringList aSelectedEntries; + SUIT_DataOwnerPtrList::const_iterator anIt = theList.begin(); + for ( ; anIt != theList.end(); ++anIt ) { + const LightApp_DataOwner* anOwner = dynamic_cast( (*anIt).operator->() ); + if ( anOwner ) { + aSelectedEntries << anOwner->entry(); + } + } + + myListWidget->setSelectedEntries( aSelectedEntries ); +} + +/** + Called when the list selection is changed. +*/ +void HYDROGUI_ListSelector::onSelectionChanged() +{ + selectionChanged(); +} diff --git a/src/HYDROGUI/HYDROGUI_ListSelector.h b/src/HYDROGUI/HYDROGUI_ListSelector.h new file mode 100644 index 00000000..dfe8b920 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ListSelector.h @@ -0,0 +1,59 @@ +// 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_LISTSELECTOR_H +#define HYDROGUI_LISTSELECTOR_H + +#include + +#include + +class HYDROGUI_OrderedListWidget; + + +/** + * \class HYDROGUI_ListSelector + * \brief The special selector for ordered list of objects. + */ +class HYDROGUI_ListSelector : public QObject, public SUIT_Selector +{ + Q_OBJECT + +public: + HYDROGUI_ListSelector( HYDROGUI_OrderedListWidget* theListWidget, + SUIT_SelectionMgr* theSelectionMgr ); + virtual ~HYDROGUI_ListSelector(); + + virtual QString type() const; + +protected: + virtual void getSelection( SUIT_DataOwnerPtrList& ) const; + virtual void setSelection( const SUIT_DataOwnerPtrList& ); + +private slots: + void onSelectionChanged(); + +private: + HYDROGUI_OrderedListWidget* myListWidget; ///< the ordered list widget +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx b/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx new file mode 100644 index 00000000..414186ec --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx @@ -0,0 +1,256 @@ +// 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_OrderedListWidget.h" + +#include "HYDROGUI_ListModel.h" + +#include +#include + +#include +#include +#include +#include +#include + + +/** + Constructor. + @param theParent the parent widget +*/ +HYDROGUI_OrderedListWidget::HYDROGUI_OrderedListWidget( QWidget* theParent ) +: QWidget( theParent ) +{ + // Main layout + QHBoxLayout* aMainLayout = new QHBoxLayout( this ); + aMainLayout->setSpacing( 5 ); + + // List view + myList = new QListView( this ); + myList->setSelectionMode( QAbstractItemView::ExtendedSelection ); + myList->setDragEnabled( true ); + myList->setAcceptDrops( true ); + myList->viewport()->setAcceptDrops( true ); + myList->setDropIndicatorShown( true ); + myList->setDragDropMode( QAbstractItemView::InternalMove ); + + HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel(); + QSortFilterProxyModel* aFilteredModel = new QSortFilterProxyModel(); + aFilteredModel->setSourceModel( aModel ); + aFilteredModel->setFilterKeyColumn( 0 ); + aFilteredModel->setFilterRole( HYDROGUI_VisibleRole ); + + myList->setModel( aFilteredModel ); + + // Buttons top, up, down, bottom + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + myTop = new QToolButton; + myTop->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_TOP_ICO" ) ) ); + myTop->setIconSize( QSize( 32, 32 ) ); + myUp = new QToolButton; + myUp->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_UP_ICO" ) ) ); + myUp->setIconSize( myTop->iconSize() ); + myDown = new QToolButton; + myDown->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_DOWN_ICO" ) ) ); + myDown->setIconSize( myTop->iconSize() ); + myBottom = new QToolButton; + myBottom->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_BOTTOM_ICO" ) ) ); + myBottom->setIconSize( myTop->iconSize() ); + + // Layout + // buttons + QVBoxLayout* aListButtonsLayout = new QVBoxLayout(); + aListButtonsLayout->addWidget( myTop ); + aListButtonsLayout->addWidget( myUp ); + aListButtonsLayout->addWidget( myDown ); + aListButtonsLayout->addWidget( myBottom ); + aListButtonsLayout->addStretch(); + // main + aMainLayout->addWidget( myList ); + aMainLayout->addLayout( aListButtonsLayout ); + + // Connections + QSignalMapper* aSignalMapper = new QSignalMapper( this ); + aSignalMapper->setMapping( myTop, HYDROGUI_ListModel::Top ); + aSignalMapper->setMapping( myUp, HYDROGUI_ListModel::Up ); + aSignalMapper->setMapping( myDown, HYDROGUI_ListModel::Down ); + aSignalMapper->setMapping( myBottom, HYDROGUI_ListModel::Bottom ); + connect( myTop, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); + connect( myUp, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); + connect( myDown, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); + connect( myBottom, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); + connect( aSignalMapper, SIGNAL( mapped( int ) ), this, SLOT( onMove( int ) ) ); + + connect ( myList->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), + this, SIGNAL( selectionChanged() ) ); + + // Initialize + setHiddenObjectsShown( true ); +} + +/** + Destructor. +*/ +HYDROGUI_OrderedListWidget::~HYDROGUI_OrderedListWidget() +{ +} + +/** + Set the list of objects (which supposed to be ordered by the widget). + @param theObjects the list of pairs (object; visibility) +*/ +void HYDROGUI_OrderedListWidget::setObjects( const HYDROGUI_ListModel::Object2VisibleList& theObjects ) +{ + HYDROGUI_ListModel* aModel = getSourceModel(); + if( aModel ) { + aModel->setObjects( theObjects ); + } +} + +/** + Returns the ordered list of objects. + @return the list of objects +*/ +QList HYDROGUI_OrderedListWidget::getObjects() const +{ + QList anObjects; + + HYDROGUI_ListModel* aModel = getSourceModel(); + if( aModel ) { + anObjects = aModel->getObjects(); + } + + return anObjects; +} + +/** + Set whether the hidden objects are presented in the list. + @param theIsToShow if true - the hidden objects will be shown in the list +*/ +void HYDROGUI_OrderedListWidget::setHiddenObjectsShown( const bool theIsToShow ) +{ + myIsHiddenObjectsShown = theIsToShow; + + QSortFilterProxyModel* aFilterModel = dynamic_cast( myList->model() ); + QString anExpr = theIsToShow ? "true|false" : "true"; + aFilterModel->setFilterRegExp( anExpr ); +} + +/** + Get entries of the selected objects. + @return the list of entries +*/ +QStringList HYDROGUI_OrderedListWidget::getSelectedEntries() const +{ + QStringList anEntries; + + QSortFilterProxyModel* aFilterModel = + dynamic_cast( myList->model() ); + if( aFilterModel ) { + HYDROGUI_ListModel* aSourceModel = + dynamic_cast( aFilterModel->sourceModel() ); + if ( aSourceModel ) { + QModelIndexList aSelectedIndexes = myList->selectionModel()->selectedIndexes(); + foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { + QModelIndex aSourceIndex = aFilterModel->mapToSource( anIndex ); + QString anEntry = aSourceModel->data( aSourceIndex, HYDROGUI_EntryRole ).toString(); + anEntries << anEntry; + } + } + } + + return anEntries; +} + +/** + Set objects with the given entries selected (other objects will deselected). + @param theEntries the list of entries +*/ +void HYDROGUI_OrderedListWidget::setSelectedEntries( const QStringList& theEntries ) const +{ + QSortFilterProxyModel* aFilterModel = dynamic_cast( myList->model() ); + if( !aFilterModel ) { + return; + } + HYDROGUI_ListModel* aSourceModel = dynamic_cast( aFilterModel->sourceModel() ); + if ( !aSourceModel ) { + return; + } + QItemSelectionModel* aSelectionModel = myList->selectionModel(); + if ( !aSelectionModel ) { + return; + } + + for ( int aRow = 0 ; aRow < aSourceModel->rowCount() ; aRow++ ) { + QModelIndex anIndex = aSourceModel->index( aRow, 0 ); + if ( !anIndex.isValid() ) { + continue; + } + + QString anEntry = aSourceModel->data( anIndex, HYDROGUI_EntryRole ).toString(); + + bool isToSelect = theEntries.contains( anEntry ); + QModelIndex aProxyModelIndex = aFilterModel->mapFromSource( anIndex ); + QItemSelectionModel::SelectionFlags aSelectionFlags = + isToSelect ? QItemSelectionModel::Select : QItemSelectionModel::Deselect; + aSelectionModel->select( aProxyModelIndex, aSelectionFlags ); + } +} + +/** + Slot called on top, up, down and bottom button click. + @param theType the move operation type +*/ +void HYDROGUI_OrderedListWidget::onMove( int theType ) +{ + QSortFilterProxyModel* aFilterModel = dynamic_cast( myList->model() ); + if( aFilterModel ) { + HYDROGUI_ListModel* aModel = dynamic_cast( aFilterModel->sourceModel() ); + if( aModel ) { + QModelIndexList aSelectedIndexes = myList->selectionModel()->selectedIndexes(); + QModelIndexList aSelectedSourceIndexes; + foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { + aSelectedSourceIndexes << aFilterModel->mapToSource( anIndex ); + } + QList aSelectedIds = aModel->getIds( aSelectedSourceIndexes ); + aModel->move( aSelectedIds, ( HYDROGUI_ListModel::OpType )theType, + !myIsHiddenObjectsShown ); + } + } +} + +/** + Returns the list source model. + @return the source model +*/ +HYDROGUI_ListModel* HYDROGUI_OrderedListWidget::getSourceModel() const +{ + HYDROGUI_ListModel* aSourceModel = 0; + + QSortFilterProxyModel* aFilterModel = dynamic_cast( myList->model() ); + if( aFilterModel ) { + aSourceModel = dynamic_cast( aFilterModel->sourceModel() ); + } + + return aSourceModel; +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_OrderedListWidget.h b/src/HYDROGUI/HYDROGUI_OrderedListWidget.h new file mode 100644 index 00000000..9664e98f --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_OrderedListWidget.h @@ -0,0 +1,75 @@ +// 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_ORDEREDLISTWIDGET_H +#define HYDROGUI_ORDEREDLISTWIDGET_H + +#include "HYDROGUI_ListModel.h" + +#include + +class QListView; +class QToolButton; + +/** + * \class HYDROGUI_OrderedListWidget + * \brief The class representing widget for managing list of objects. + * + * The widget represents a list and a set of buttons (top, up, down and bottom) + * providing the possibility to change the list items order. + */ +class HYDRO_EXPORT HYDROGUI_OrderedListWidget : public QWidget +{ + Q_OBJECT + +public: + HYDROGUI_OrderedListWidget( QWidget* theParent ); + virtual ~HYDROGUI_OrderedListWidget(); + + void setObjects( const HYDROGUI_ListModel::Object2VisibleList& theObjects ); + HYDROGUI_ListModel::ObjectList getObjects() const; + + void setHiddenObjectsShown( const bool theIsToShow ); + + QStringList getSelectedEntries() const; + void setSelectedEntries( const QStringList& theEntries ) const; + +signals: + void selectionChanged(); + +private slots: + void onMove( int theType ); + +private: + HYDROGUI_ListModel* getSourceModel() const; + +private: + QListView* myList; ///< the list view + QToolButton* myTop; ///< the move on top button + QToolButton* myUp; ///< the move up button + QToolButton* myDown; ///< the move down button + QToolButton* myBottom; ///< the move on bottom button + + bool myIsHiddenObjectsShown; ///< the show hidden objects in the list indicator +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx index ed33f6d0..aac2cc2e 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx @@ -21,25 +21,24 @@ // #include "HYDROGUI_ZLevelsDlg.h" -#include "HYDROGUI_ZLevelsModel.h" -#include -#include +#include "HYDROGUI_OrderedListWidget.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_ListSelector.h" + +#include "LightApp_Application.h" +#include "LightApp_SelectionMgr.h" #include #include -#include #include -#include -#include -#include /** Constructor. @param theParent the parent widget */ -HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent ) +HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent, HYDROGUI_Module* theModule ) : QDialog( theParent ) { // Dialog title @@ -50,78 +49,28 @@ HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent ) aMainLayout->setMargin( 5 ); aMainLayout->setSpacing( 5 ); - // List and buttons top, up, down, bottom - QHBoxLayout* aListLayout = new QHBoxLayout(); - - // list - myList = new QListView( this ); - myList->setSelectionMode( QAbstractItemView::ExtendedSelection ); - myList->setDragEnabled( true ); - myList->setAcceptDrops( true ); - myList->viewport()->setAcceptDrops( true ); - myList->setDropIndicatorShown( true ); - myList->setDragDropMode( QAbstractItemView::InternalMove ); - - HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel(); - QSortFilterProxyModel* aFilteredModel = new QSortFilterProxyModel(); - aFilteredModel->setSourceModel( aModel ); - aFilteredModel->setFilterKeyColumn( 0 ); - aFilteredModel->setFilterRole( HYDROGUI_VisibleRole ); - - myList->setModel( aFilteredModel ); - - // buttons top, up, down, bottom - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - myTop = new QToolButton; - myTop->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_TOP_ICO" ) ) ); - myTop->setIconSize( QSize( 32, 32 ) ); - myUp = new QToolButton; - myUp->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_UP_ICO" ) ) ); - myUp->setIconSize( myTop->iconSize() ); - myDown = new QToolButton; - myDown->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_DOWN_ICO" ) ) ); - myDown->setIconSize( myTop->iconSize() ); - myBottom = new QToolButton; - myBottom->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "ARROW_BOTTOM_ICO" ) ) ); - myBottom->setIconSize( myTop->iconSize() ); - - QVBoxLayout* aListButtonsLayout = new QVBoxLayout(); - aListButtonsLayout->addWidget( myTop ); - aListButtonsLayout->addWidget( myUp ); - aListButtonsLayout->addWidget( myDown ); - aListButtonsLayout->addWidget( myBottom ); - aListButtonsLayout->addStretch(); - aListLayout->addWidget( myList ); - - aListLayout->addLayout( aListButtonsLayout ); - aMainLayout->addLayout( aListLayout ); + // Ordered list widget + myListWidget = new HYDROGUI_OrderedListWidget( this ); // "All objects" check box myAllObjects = new QCheckBox( tr( "ALL_OBJECTS" ) ); - aMainLayout->addWidget( myAllObjects ); // Apply and close buttons - QHBoxLayout* aDlgButtonsLayout = new QHBoxLayout(); myApply = new QPushButton( tr("APPLY") ); myClose = new QPushButton( tr("CLOSE") ); + + // Layout + // apply and close buttons + QHBoxLayout* aDlgButtonsLayout = new QHBoxLayout(); aDlgButtonsLayout->addWidget( myApply ); aDlgButtonsLayout->addWidget( myClose ); aDlgButtonsLayout->addStretch(); - + // main + aMainLayout->addWidget( myListWidget ); + aMainLayout->addWidget( myAllObjects ); aMainLayout->addLayout( aDlgButtonsLayout ); // Connections - QSignalMapper* aSignalMapper = new QSignalMapper( this ); - aSignalMapper->setMapping( myTop, HYDROGUI_ZLevelsModel::Top ); - aSignalMapper->setMapping( myUp, HYDROGUI_ZLevelsModel::Up ); - aSignalMapper->setMapping( myDown, HYDROGUI_ZLevelsModel::Down ); - aSignalMapper->setMapping( myBottom, HYDROGUI_ZLevelsModel::Bottom ); - connect( myTop, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); - connect( myUp, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); - connect( myDown, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); - connect( myBottom, SIGNAL( clicked() ), aSignalMapper, SLOT( map() ) ); - connect( aSignalMapper, SIGNAL( mapped( int ) ), this, SLOT( onMove( int ) ) ); - connect( myAllObjects, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChanged() ) ); connect( myApply, SIGNAL( clicked() ), this, SIGNAL( applyOrder() ) ); @@ -129,6 +78,11 @@ HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent ) // Initialize onStateChanged(); + + // Create selector + if ( theModule ) { + new HYDROGUI_ListSelector( myListWidget, theModule->getApp()->selectionMgr() ); + } } /** @@ -142,12 +96,9 @@ HYDROGUI_ZLevelsDlg::~HYDROGUI_ZLevelsDlg() Set the list of objects (which supposed to be ordered by the dialog). @param theObjects the list of objects */ -void HYDROGUI_ZLevelsDlg::setObjects( const HYDROGUI_ZLevelsModel::Object2VisibleList& theObjects ) +void HYDROGUI_ZLevelsDlg::setObjects( const HYDROGUI_ListModel::Object2VisibleList& theObjects ) { - HYDROGUI_ZLevelsModel* aModel = getListSourceModel(); - if( aModel ) { - aModel->setObjects( theObjects ); - } + myListWidget->setObjects( theObjects ); } /** @@ -156,36 +107,7 @@ void HYDROGUI_ZLevelsDlg::setObjects( const HYDROGUI_ZLevelsModel::Object2Visibl */ QList HYDROGUI_ZLevelsDlg::getObjects() const { - QList anObjects; - - HYDROGUI_ZLevelsModel* aModel = getListSourceModel(); - if( aModel ) { - anObjects = aModel->getObjects(); - } - - return anObjects; -} - -/** - Slot called on top, up, down and bottom button click. - @param theType the move operation type -*/ -void HYDROGUI_ZLevelsDlg::onMove( int theType ) -{ - QSortFilterProxyModel* aFilterModel = dynamic_cast( myList->model() ); - if( aFilterModel ) { - HYDROGUI_ZLevelsModel* aModel = dynamic_cast( aFilterModel->sourceModel() ); - if( aModel ) { - QModelIndexList aSelectedIndexes = myList->selectionModel()->selectedIndexes(); - QModelIndexList aSelectedSourceIndexes; - foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { - aSelectedSourceIndexes << aFilterModel->mapToSource( anIndex ); - } - QList aSelectedIds = aModel->getIds( aSelectedSourceIndexes ); - aModel->move( aSelectedIds, ( HYDROGUI_ZLevelsModel::OpType )theType, - !myAllObjects->isChecked() ); - } - } + return myListWidget->getObjects(); } /** @@ -193,24 +115,6 @@ void HYDROGUI_ZLevelsDlg::onMove( int theType ) */ void HYDROGUI_ZLevelsDlg::onStateChanged() { - QSortFilterProxyModel* aFilterModel = dynamic_cast( myList->model() ); bool isAll = myAllObjects->isChecked(); - QString anExpr = isAll ? "true|false" : "true"; - aFilterModel->setFilterRegExp( anExpr ); + myListWidget->setHiddenObjectsShown( isAll ); } - -/** - Returns the list source model. - @return the source model -*/ -HYDROGUI_ZLevelsModel* HYDROGUI_ZLevelsDlg::getListSourceModel() const -{ - HYDROGUI_ZLevelsModel* aSourceModel = 0; - - QSortFilterProxyModel* aFilterModel = dynamic_cast( myList->model() ); - if( aFilterModel ) { - aSourceModel = dynamic_cast( aFilterModel->sourceModel() ); - } - - return aSourceModel; -} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h index be41085a..466b6042 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h +++ b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h @@ -23,49 +23,43 @@ #ifndef HYDROGUI_ZLEVELSPANEL_H #define HYDROGUI_ZLEVELSPANEL_H -#include "HYDROGUI_ZLevelsModel.h" +#include "HYDROGUI_ListModel.h" #include +class HYDROGUI_OrderedListWidget; +class HYDROGUI_Module; + class QCheckBox; -class QListView; class QPushButton; -class QToolButton; + /** * \class HYDROGUI_ZLevelsDlg - * \brief The class representing widget for managing Z levels + * \brief The class representing dialog for managing Z levels */ class HYDRO_EXPORT HYDROGUI_ZLevelsDlg : public QDialog { Q_OBJECT public: - HYDROGUI_ZLevelsDlg( QWidget* theParent ); + HYDROGUI_ZLevelsDlg( QWidget* theParent, HYDROGUI_Module* theModule ); virtual ~HYDROGUI_ZLevelsDlg(); - void setObjects( const HYDROGUI_ZLevelsModel::Object2VisibleList& theObjects ); - HYDROGUI_ZLevelsModel::ObjectList getObjects() const; + void setObjects( const HYDROGUI_ListModel::Object2VisibleList& theObjects ); + HYDROGUI_ListModel::ObjectList getObjects() const; signals: void applyOrder(); private slots: - void onMove( int theType ); void onStateChanged(); private: - HYDROGUI_ZLevelsModel* getListSourceModel() const; - -private: - QListView* myList; - QToolButton* myTop; - QToolButton* myUp; - QToolButton* myDown; - QToolButton* myBottom; - QCheckBox* myAllObjects; - QPushButton* myApply; - QPushButton* myClose; + HYDROGUI_OrderedListWidget* myListWidget; ///< the ordered list widget + QCheckBox* myAllObjects; ///< the show all objects button + QPushButton* myApply; ///< the apply changes button + QPushButton* myClose; ///< the close dialog button }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx index 085b8e98..87dc49ee 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx @@ -27,6 +27,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_ListSelector.h" #include @@ -60,7 +61,7 @@ void HYDROGUI_ZLevelsOp::startOperation() HYDROGUI_Operation::startOperation(); // Prepare the list of objects - HYDROGUI_ZLevelsModel::Object2VisibleList anObject2VisibleList; + HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList; // get the document Handle(HYDROData_Document) aDoc = doc(); @@ -75,20 +76,20 @@ void HYDROGUI_ZLevelsOp::startOperation() Handle(HYDROData_Entity) anObject = anIter.Value(); if ( !anObject.IsNull() ) { bool isVisible = module()->isObjectVisible( anActiveOCCViewId, anObject ); - anObject2VisibleList << HYDROGUI_ZLevelsModel::Object2Visible( anObject, isVisible ); + anObject2VisibleList << HYDROGUI_ListModel::Object2Visible( anObject, isVisible ); } } } // Show the dialog - myZLevelsDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop() ); - myZLevelsDlg->setModal( true ); + if ( !myZLevelsDlg ) { + //TODO: delete dialog each time? + myZLevelsDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop(), module() ); + connect( myZLevelsDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) ); + connect( myZLevelsDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); + } myZLevelsDlg->setObjects( anObject2VisibleList ); - //TODO: check - connect( myZLevelsDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) ); - connect( myZLevelsDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); - myZLevelsDlg->exec(); } @@ -102,7 +103,7 @@ bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags, if ( myZLevelsDlg ) { Handle(HYDROData_Document) aDoc = doc(); if( !aDoc.IsNull() ) { - HYDROGUI_ZLevelsModel::ObjectList anObjects = myZLevelsDlg->getObjects(); + HYDROGUI_ListModel::ObjectList anObjects = myZLevelsDlg->getObjects(); HYDROData_SequenceOfObjects anOrderedObjects; foreach ( const Handle(HYDROData_Entity) anObject, anObjects ) { anOrderedObjects.Append( anObject ); diff --git a/src/HYDROGUI/test_HYDROGUI_ZLevelsModel.cxx b/src/HYDROGUI/test_HYDROGUI_ListModel.cxx similarity index 92% rename from src/HYDROGUI/test_HYDROGUI_ZLevelsModel.cxx rename to src/HYDROGUI/test_HYDROGUI_ListModel.cxx index 0b774229..f3c76ed0 100644 --- a/src/HYDROGUI/test_HYDROGUI_ZLevelsModel.cxx +++ b/src/HYDROGUI/test_HYDROGUI_ListModel.cxx @@ -1,18 +1,18 @@ #undef HYDROGUI_EXPORTS -#include +#include #include -#include +#include Handle_HYDROData_Document GetDocument() { return HYDROData_Document::Document( 0 ); } -HYDROGUI_ZLevelsModel::Object2VisibleList CreateTestObjects( int theObjCount ) +HYDROGUI_ListModel::Object2VisibleList CreateTestObjects( int theObjCount ) { - HYDROGUI_ZLevelsModel::Object2VisibleList anObjects; + HYDROGUI_ListModel::Object2VisibleList anObjects; for( int i=0; imyObjects.size(); isetObjects( CreateTestObjects( 6 ) ); - const HYDROGUI_ZLevelsModel::OpType anUp = HYDROGUI_ZLevelsModel::Up; + const HYDROGUI_ListModel::OpType anUp = HYDROGUI_ListModel::Up; // 0. Check the initial state CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) ); @@ -128,11 +128,11 @@ void test_HYDROGUI_ZLevelsModel::testMoveUp() /** Test move on top algorithm. */ -void test_HYDROGUI_ZLevelsModel::testMoveOnTop() +void test_HYDROGUI_ListModel::testMoveOnTop() { - HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel(); + HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel(); aModel->setObjects( CreateTestObjects( 6 ) ); - const HYDROGUI_ZLevelsModel::OpType aTop = HYDROGUI_ZLevelsModel::Top; + const HYDROGUI_ListModel::OpType aTop = HYDROGUI_ListModel::Top; // 0. Check the initial state CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) ); @@ -183,11 +183,11 @@ void test_HYDROGUI_ZLevelsModel::testMoveOnTop() /** Test move down algorithm. */ -void test_HYDROGUI_ZLevelsModel::testMoveDown() +void test_HYDROGUI_ListModel::testMoveDown() { - HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel(); + HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel(); aModel->setObjects( CreateTestObjects( 6 ) ); - const HYDROGUI_ZLevelsModel::OpType aDown = HYDROGUI_ZLevelsModel::Down; + const HYDROGUI_ListModel::OpType aDown = HYDROGUI_ListModel::Down; // 0. Check the initial state CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) ); @@ -264,11 +264,11 @@ void test_HYDROGUI_ZLevelsModel::testMoveDown() /** Test move on bottom algorithm. */ -void test_HYDROGUI_ZLevelsModel::testMoveOnBottom() +void test_HYDROGUI_ListModel::testMoveOnBottom() { - HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel(); + HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel(); aModel->setObjects( CreateTestObjects( 6 ) ); - const HYDROGUI_ZLevelsModel::OpType aBottom = HYDROGUI_ZLevelsModel::Bottom; + const HYDROGUI_ListModel::OpType aBottom = HYDROGUI_ListModel::Bottom; // 0. Check the initial state CPPUNIT_ASSERT_EQUAL( std::string( "*A, B, *C, D, *E, F" ), GetObjects( aModel ) ); @@ -319,11 +319,11 @@ void test_HYDROGUI_ZLevelsModel::testMoveOnBottom() /** Test drag and drop algorithm. */ -void test_HYDROGUI_ZLevelsModel::testDragAndDrop() +void test_HYDROGUI_ListModel::testDragAndDrop() { - HYDROGUI_ZLevelsModel* aModel = new HYDROGUI_ZLevelsModel(); + HYDROGUI_ListModel* aModel = new HYDROGUI_ListModel(); aModel->setObjects( CreateTestObjects( 8 ) ); - const HYDROGUI_ZLevelsModel::OpType aDnD = HYDROGUI_ZLevelsModel::DragAndDrop; + const HYDROGUI_ListModel::OpType aDnD = HYDROGUI_ListModel::DragAndDrop; // 0. Check the initial state std::string anInitialState = std::string( "*A, B, *C, D, *E, F, *G, H" ); diff --git a/src/HYDROGUI/test_HYDROGUI_ZLevelsModel.h b/src/HYDROGUI/test_HYDROGUI_ListModel.h similarity index 50% rename from src/HYDROGUI/test_HYDROGUI_ZLevelsModel.h rename to src/HYDROGUI/test_HYDROGUI_ListModel.h index c8f0eeab..0b168ba9 100644 --- a/src/HYDROGUI/test_HYDROGUI_ZLevelsModel.h +++ b/src/HYDROGUI/test_HYDROGUI_ListModel.h @@ -1,9 +1,9 @@ #include -class HYDROGUI_ZLevelsModel; +class HYDROGUI_ListModel; -class test_HYDROGUI_ZLevelsModel : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(test_HYDROGUI_ZLevelsModel); +class test_HYDROGUI_ListModel : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(test_HYDROGUI_ListModel); CPPUNIT_TEST(testMoveUp); CPPUNIT_TEST(testMoveOnTop); CPPUNIT_TEST(testMoveDown); @@ -12,7 +12,7 @@ class test_HYDROGUI_ZLevelsModel : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE_END(); private: - std::string GetObjects( HYDROGUI_ZLevelsModel* theModel ) const; + std::string GetObjects( HYDROGUI_ListModel* theModel ) const; public: void testMoveUp(); @@ -22,5 +22,5 @@ public: void testDragAndDrop(); }; -CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROGUI_ZLevelsModel); -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROGUI_ZLevelsModel, "HYDROGUI_ZLevelsModel"); +CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROGUI_ListModel); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROGUI_ListModel, "HYDROGUI_ListModel"); -- 2.39.2