Salome HOME
Update of CheckDone
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FileInfoDlg.cxx
1 // Copyright (C) 2007-2020  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, or (at your option) any later version.
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
20 // SMESH SMESHGUI : GUI for SMESH component
21 // File   : SMESHGUI_FileInfoDlg.cxx
22 // Author : Alexandre SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
23 //
24 #include "SMESHGUI_FileInfoDlg.h"
25
26 #include <QGridLayout>
27 #include <QLabel>
28 #include <QLineEdit>
29
30 SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SMESH::MedFileInfo* inf )
31   : QtxDialog( parent, true, true, QtxDialog::OK )
32 {
33   setWindowTitle( tr( "CAPTION" ) );
34   setSizeGripEnabled( true );
35
36   QLineEdit* fname = new QLineEdit( mainFrame() );
37   fname->setReadOnly( true );
38   QLineEdit* fsize = new QLineEdit( mainFrame() );
39   fsize->setReadOnly( true );
40   QLineEdit* medversion = new QLineEdit( mainFrame() );
41   medversion->setReadOnly( true );
42   QLabel* medversionlabel = new QLabel( tr( "MED_VERSION" ), mainFrame() );
43   fname->setMinimumWidth( 300 );
44
45   QGridLayout* lay = new QGridLayout( mainFrame() );
46   lay->setMargin( 5 ); lay->setSpacing( 5 );
47   lay->addWidget( new QLabel( tr( "FILE_NAME" ), mainFrame() ), 0, 0 );
48   lay->addWidget( fname, 0, 1 );
49   lay->addWidget( new QLabel( tr( "FILE_SIZE" ), mainFrame() ), 1, 0 );
50   lay->addWidget( fsize, 1, 1 );
51   lay->addWidget( medversionlabel, 2, 0 );
52   lay->addWidget( medversion, 2, 1 );
53
54   fname->setText( (char*)inf->fileName );
55   fname->home( false );
56   fsize->setText( QString::number( inf->fileSize ) );
57
58   if ( fname->text().endsWith("med"))
59   {
60     QString version;
61     if( inf->major>=0 )
62     {
63       version = QString::number( inf->major );
64       if( inf->minor>=0 )
65       {
66         version += "." + QString::number( inf->minor );
67         if( inf->release>=0 )
68           version += "." + QString::number( inf->release );
69       }
70     }
71     medversion->setText( version );
72   }
73   else
74   {
75     medversionlabel->hide();
76     medversion->hide();
77   }
78 }
79
80 SMESHGUI_FileInfoDlg::~SMESHGUI_FileInfoDlg()
81 {
82 }