Salome HOME
5a488aa5f4397737cc454262c5b592d025adaddb
[modules/geom.git] / src / GEOMGUI / GEOMGUI_CreationInfoWdg.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File      : GEOMGUI_CreationInfoWdg.cxx
20 // Created   : Fri Jun  7 13:07:59 2013
21 // Author    : Edward AGAPOV (eap)
22
23 #include "GEOMGUI_CreationInfoWdg.h"
24
25 #include <SalomeApp_Application.h>
26 #include <SUIT_Desktop.h>
27
28 #include <QString>
29 #include <QLabel>
30 #include <QLineEdit>
31 #include <QTreeWidget>
32 #include <QHeaderView>
33 #include <QGroupBox>
34 #include <QVBoxLayout>
35 #include <QHBoxLayout>
36
37 GEOMGUI_CreationInfoWdg::GEOMGUI_CreationInfoWdg( SalomeApp_Application* app )
38 //:QWidget( app->desktop() )
39 {
40   setWindowTitle(tr("CREATION_INFO_TITLE"));
41
42   QFrame* frame = new QFrame( this );
43
44   QVBoxLayout* myLayout = new QVBoxLayout( this );
45   myLayout->addWidget( frame );
46   myLayout->setMargin(0);
47
48   QGroupBox* operationGB = new QGroupBox( tr( "OPERATION" ), frame );
49
50   myIconLbl      = new QLabel( operationGB );
51   myOperaionLnEd = new QLineEdit( operationGB );
52   myParamsTreeWd = new QTreeWidget( frame );
53   myParamsTreeWd->setColumnCount( 2 );
54   myParamsTreeWd->setHeaderLabels( QStringList() << tr( "PARAMETER" ) << tr( "VALUE" ) );
55   myParamsTreeWd->header()->setStretchLastSection( true );
56   myParamsTreeWd->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
57
58   QHBoxLayout* operationLay = new QHBoxLayout( operationGB );
59   operationLay->addWidget( myIconLbl );
60   operationLay->addWidget( myOperaionLnEd );
61   operationLay->setMargin(5);
62
63   QVBoxLayout* aLayout = new QVBoxLayout( frame );
64   aLayout->addWidget( operationGB );
65   aLayout->addWidget( myParamsTreeWd );
66
67   // get a free dockable window id
68   myWindowID = 1;
69   while( app->dockWindow( myWindowID ))
70     ++myWindowID;
71 }
72
73 void GEOMGUI_CreationInfoWdg::setOperation(const QPixmap& icon, const QString& name)
74 {
75   myIconLbl->setPixmap( icon );
76   myOperaionLnEd->setText( name );
77   myParamsTreeWd->clear();
78
79   if ( name.isEmpty() )
80     myOperaionLnEd->setText( tr("NO_INFO"));
81 }
82
83 void GEOMGUI_CreationInfoWdg::addParam (const QString& name, const QString& value)
84 {
85   QTreeWidgetItem* item = new QTreeWidgetItem( myParamsTreeWd );
86
87   //item->setFlags( Qt::NoItemFlags );
88   item->setExpanded( true );
89
90   item->setText( 0, name );
91   item->setText( 1, value );
92 }
93
94 void GEOMGUI_CreationInfoWdg::clear()
95 {
96   myIconLbl->setPixmap( QPixmap() );
97   myOperaionLnEd->setText( "" );
98   myParamsTreeWd->clear();
99 }
100
101 GEOMGUI_CreationInfoWdg::~GEOMGUI_CreationInfoWdg()
102 {
103   //std::cout<<"~GEOMGUI_CreationInfoWdg"<<std::endl;
104 }