From c996d1c416a6777571faf95c5a67205f104188ca Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 18 Jun 2015 15:21:07 +0300 Subject: [PATCH] sinusX p.6 // Export // GUI Part // moving to new listbox --- src/HYDROGUI/HYDROGUI_ExportSinusXDlg.cxx | 62 +++++------------------ src/HYDROGUI/HYDROGUI_ExportSinusXDlg.h | 19 +++---- src/HYDROGUI/HYDROGUI_ExportSinusXOp.cxx | 35 ++----------- src/HYDROGUI/HYDROGUI_ExportSinusXOp.h | 3 +- 4 files changed, 26 insertions(+), 93 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.cxx b/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.cxx index 49f6711d..e0da77a5 100644 --- a/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.cxx @@ -27,6 +27,7 @@ #include #include #include +#include HYDROGUI_ExportSinusXDlg::HYDROGUI_ExportSinusXDlg( HYDROGUI_Module* theModule, const QString& theTitle ) @@ -39,30 +40,23 @@ HYDROGUI_ExportSinusXDlg::HYDROGUI_ExportSinusXDlg( HYDROGUI_Module* theModule, aLayout->setMargin( 5 ); aLayout->setSpacing( 5 ); - myQListW = new QListWidget(mainFrame()); + QList anAllowedTypesToSave; + anAllowedTypesToSave.append(KIND_BATHYMETRY); + anAllowedTypesToSave.append(KIND_POLYLINEXY); + anAllowedTypesToSave.append(KIND_PROFILE); - myQListW->setSelectionMode(QAbstractItemView::ExtendedSelection); - aLayout->addWidget(myQListW, 0, 0, 1, 2); + myList = new HYDROGUI_ObjListBox( theModule, tr( "OBJECT_TO_EXPORT" ), anAllowedTypesToSave, mainFrame() ); + aLayout->addWidget( myList, 0, 0 ); - myIncludeBtn = new QPushButton( tr( "INCLUDE" ) ); - myExcludeBtn = new QPushButton( tr( "EXCLUDE" ) ); - aLayout->addWidget(myIncludeBtn, 1, 0 ); - aLayout->addWidget(myExcludeBtn, 1, 1 ); - - myExport = new QPushButton( tr( "EXPORT" ) ); + myExportBtn = new QPushButton( tr( "EXPORT" ) ); QHBoxLayout* aBtnsLayout = qobject_cast(buttonFrame()->layout()); - aBtnsLayout->addWidget( myExport, 0 ); + aBtnsLayout->addWidget( myExportBtn, 0 ); aBtnsLayout->addWidget( myCancel, 0 ); aBtnsLayout->addStretch( 1 ); aBtnsLayout->addWidget( myHelp, 0 ); - - //TODO connect - //connect( myExport, SIGNAL( clicked() ), SLOT( onExport() ) ); - connect( myIncludeBtn, SIGNAL( clicked() ), SIGNAL( IncludeItems() ) ); - connect( myExcludeBtn, SIGNAL( clicked() ), SIGNAL( ExcludeItems() ) ); - myEnt2WIMap.clear(); + connect( myExportBtn, SIGNAL( clicked() ), SIGNAL( ExportItems() ) ); } @@ -70,38 +64,8 @@ HYDROGUI_ExportSinusXDlg::~HYDROGUI_ExportSinusXDlg() { } -void HYDROGUI_ExportSinusXDlg::addItems(const HYDROData_SequenceOfObjects& theSelectedItems) -{ - for (int i = 1; i <= theSelectedItems.Size(); i++) - { - QString anEntName = theSelectedItems.Value(i)->GetName(); - if (!myEnt2WIMap.contains(anEntName)) - { - QListWidgetItem* aWI = new QListWidgetItem(); - aWI->setText(anEntName); - myEnt2WIMap[anEntName] = aWI; ///TODO free this map - myQListW->addItem(aWI); - } - } - myQListW->update(); -} -void HYDROGUI_ExportSinusXDlg::RemoveItems() +HYDROData_SequenceOfObjects HYDROGUI_ExportSinusXDlg::GetSelectedEntities() { - for (int i = 0; i < myQListW->selectedItems().size(); i++) - { - QListWidgetItem* anItem = myQListW->selectedItems()[i]; - QMap::iterator aMapIt; - for (aMapIt = myEnt2WIMap.begin(); aMapIt != myEnt2WIMap.end(); ++aMapIt) - if (aMapIt.value() == anItem) - { - aMapIt = myEnt2WIMap.erase(aMapIt); - delete anItem; - //myQListW->takeItem(anItem); - } - else - ++aMapIt; - } - myQListW->update(); -} - + return myList->selectedObjects(); +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.h b/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.h index 648c0c08..72e294a5 100644 --- a/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.h +++ b/src/HYDROGUI/HYDROGUI_ExportSinusXDlg.h @@ -16,8 +16,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef HYDROGUI_ExportSinusXDlg_H -#define HYDROGUI_ExportSinusXDlg_H +#ifndef HYDROGUI_EXPORTSINUSXDLG_H +#define HYDROGUI_EXPORTSINUSXDLG_H #include "HYDROGUI_InputPanel.h" #include @@ -28,6 +28,7 @@ class QStackedWidget; class QPushButton; class QListWidget; class QListWidgetItem; +class HYDROGUI_ObjListBox; class HYDROGUI_ExportSinusXDlg : public HYDROGUI_InputPanel @@ -37,20 +38,14 @@ class HYDROGUI_ExportSinusXDlg : public HYDROGUI_InputPanel public: HYDROGUI_ExportSinusXDlg( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_ExportSinusXDlg(); - void addItems(const HYDROData_SequenceOfObjects& theSelectedItems); - void RemoveItems(); + HYDROData_SequenceOfObjects GetSelectedEntities(); signals: - void IncludeItems(); - void ExcludeItems(); - + void ExportItems(); private: - QPushButton* myExport; - QPushButton* myIncludeBtn; - QPushButton* myExcludeBtn; - QListWidget* myQListW; - QMap myEnt2WIMap; + HYDROGUI_ObjListBox* myList; + QPushButton* myExportBtn; }; diff --git a/src/HYDROGUI/HYDROGUI_ExportSinusXOp.cxx b/src/HYDROGUI/HYDROGUI_ExportSinusXOp.cxx index ea53a0c6..ef17ecdb 100644 --- a/src/HYDROGUI/HYDROGUI_ExportSinusXOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportSinusXOp.cxx @@ -25,6 +25,8 @@ #include #include #include +#include +#include HYDROGUI_ExportSinusXOp::HYDROGUI_ExportSinusXOp( HYDROGUI_Module* theModule ) @@ -49,41 +51,14 @@ void HYDROGUI_ExportSinusXOp::startOperation() HYDROGUI_InputPanel* HYDROGUI_ExportSinusXOp::createInputPanel() const { HYDROGUI_ExportSinusXDlg* aPanel = new HYDROGUI_ExportSinusXDlg( module(), getName() ); - connect( aPanel, SIGNAL( IncludeItems() ), SLOT( onIncludeItems() ) ); - connect( aPanel, SIGNAL( ExcludeItems() ), SLOT( onExcludeItems() ) ); + connect( aPanel, SIGNAL( ExportItems() ), SLOT( onExportItems() ) ); return aPanel; } -void HYDROGUI_ExportSinusXOp::onIncludeItems() +void HYDROGUI_ExportSinusXOp::onExportItems() { HYDROGUI_ExportSinusXDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return; - - HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); - HYDROData_SequenceOfObjects aSelectedItems; - - if ( aSeq.IsEmpty()) - return; - - for( int i = 1; i <= aSeq.Length(); i++ ) - { - Handle_HYDROData_Entity anEnt = aSeq.Value( i ); - if (anEnt->IsKind( STANDARD_TYPE( HYDROData_Bathymetry)) || - anEnt->IsKind( STANDARD_TYPE( HYDROData_PolylineXY)) || - anEnt->IsKind( STANDARD_TYPE( HYDROData_Profile)) ) - aSelectedItems.Append(anEnt); - } - - aPanel->addItems( aSelectedItems ); - -} - -void HYDROGUI_ExportSinusXOp::onExcludeItems() -{ - HYDROGUI_ExportSinusXDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - aPanel->RemoveItems( ); - + int T = aPanel->GetSelectedEntities().Size(); } diff --git a/src/HYDROGUI/HYDROGUI_ExportSinusXOp.h b/src/HYDROGUI/HYDROGUI_ExportSinusXOp.h index 3d1a6bf8..b5e5bf61 100644 --- a/src/HYDROGUI/HYDROGUI_ExportSinusXOp.h +++ b/src/HYDROGUI/HYDROGUI_ExportSinusXOp.h @@ -35,8 +35,7 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; protected slots: - void onIncludeItems(); - void onExcludeItems(); + void onExportItems(); }; -- 2.39.2