Salome HOME
SHP Poly 1
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportLandCoverDlg.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_ImportLandCoverDlg.h"
20
21 #include <SUIT_MessageBox.h>
22
23 #include <QTextEdit>
24 #include <QListWidget>
25 #include <QVBoxLayout>
26 #include <QLabel>
27 #include <QPushButton>
28
29 HYDROGUI_ImportLandCoverDlg::HYDROGUI_ImportLandCoverDlg( std::vector<SHPObject*> theSHPObjects, std::map<QListWidgetItem*, SHPObject*>& theWItemToSObjectMap, QWidget* theParent )
30 : QtxDialog( theParent, false, true, QtxDialog::YesNo )
31 {
32   setWindowTitle( tr( "IMPORT_LANDCOVER_OBJECTS" ) );
33   setButtonPosition( Left, Yes );
34   setButtonPosition( Right, No );
35
36   QLabel* anIconLabelLabel = new QLabel( mainFrame() );
37   anIconLabelLabel->setPixmap( SUIT_MessageBox::standardIcon( QMessageBox::Question ) );
38   anIconLabelLabel->setScaledContents( false );
39   anIconLabelLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
40
41   myObjectsLabel = new QLabel( tr( "CONFIRM_SELECTION" ), mainFrame() );
42
43   myListW = new QListWidget(mainFrame());
44   for (int i = 1 ; i <= theSHPObjects.size(); i++)
45   {
46     myListW->addItem("Polygon_" + QString::number(i));
47   }
48   myListW->setSelectionMode(QAbstractItemView::ExtendedSelection);
49   
50   QGridLayout* aLayout = new QGridLayout( mainFrame() );
51   aLayout->setMargin( 5 );
52   aLayout->setSpacing( 5 );
53   aLayout->addWidget( anIconLabelLabel, 0, 0 );
54   aLayout->addWidget( myObjectsLabel, 0, 1 );
55
56   aLayout->addWidget( myListW, 1, 0, 1, 2 );
57
58   if ( QPushButton* aYesBtn = ::qobject_cast<QPushButton*>( button( Yes ) ) )
59   {
60     setFocusProxy( aYesBtn );
61     aYesBtn->setAutoDefault( true );
62     aYesBtn->setDefault( true );
63   }
64   if ( QPushButton* aNoBtn = ::qobject_cast<QPushButton*>( button( No ) ) )
65   {
66     aNoBtn->setAutoDefault( true );
67   }
68
69   setMinimumSize( 350, 450 );
70 }
71
72 HYDROGUI_ImportLandCoverDlg::~HYDROGUI_ImportLandCoverDlg()
73 {
74 }
75
76 QList<QListWidgetItem*> HYDROGUI_ImportLandCoverDlg::GetSelectedItems()
77 {
78   return myListW->selectedItems();
79 }