]> SALOME platform Git repositories - tools/install.git/blob - src/SALOME_XmlHandler.cxx
Salome HOME
d4ec37de4e20a9c2fd47fe30c6b6ebb7693682cc
[tools/install.git] / src / SALOME_XmlHandler.cxx
1 //  File      : SALOME_XmlHandler.cxx
2 //  Created   : Thu Dec 18 12:01:00 2002
3 //  Author    : Vadim SANDLER
4 //  Project   : PAL/SALOME
5 //  Module    : InstallWizard
6 //  Copyright : 2004 CEA
7 //  $Header$ 
8
9 #include "SALOME_XmlHandler.hxx"
10 #include "SALOME_ProductsView.hxx"
11 #include "SALOME_InstallWizard.hxx"
12
13 #include <qlineedit.h>
14
15 // ================================================================
16 /*!
17  *  StructureParser::StructureParser
18  *  Constructor
19  */
20 // ================================================================
21 StructureParser::StructureParser( SALOME_InstallWizard* wizard )
22      : QXmlDefaultHandler(), 
23        myWizard( wizard ), 
24        myTree( 0 ), 
25        myTargetDir( 0 ), 
26        myTempDir( 0 )
27 {
28 }
29 // ================================================================
30 /*!
31  *  StructureParser::setProductsList
32  *  Sets products list view
33  */
34 // ================================================================
35 void StructureParser::setProductsList( ProductsView* tree )
36 {
37   myTree = tree;
38 }
39 // ================================================================
40 /*!
41  *  StructureParser::setTargetDir
42  *  Sets target directory widget
43  */
44 // ================================================================
45 void StructureParser::setTargetDir( QLineEdit* dir )
46 {
47   myTargetDir = dir;
48 }
49 // ================================================================
50 /*!
51  *  StructureParser::setTempDir
52  *  Sets temp directory widget
53  */
54 // ================================================================
55 void StructureParser::setTempDir( QLineEdit* dir )
56 {
57   myTempDir = dir;
58 }
59 // ================================================================
60 /*!
61  *  StructureParser::startElement
62  *  Begins parsing of the xml dom-element
63  */  
64 // ================================================================
65 bool StructureParser::startElement( const QString&        /*namespaceURI*/,
66                                     const QString&        /*localName*/,
67                                     const QString&        qName,
68                                     const QXmlAttributes& attributes)
69 {
70 #ifdef DEBUG
71   cout << qName << endl;
72   cout << attributes.length() << endl;
73 #endif
74   QCheckListItem* element;
75   if (( qName == "config" ) && ( attributes.length() > 0 ) ) {
76     QString myVersion, myCaption, myCopyright, myLicense, myOS;
77     if ( attributes.value( "version" ) ) {
78       myVersion = attributes.value( "version" ).stripWhiteSpace();
79       if ( myWizard && !myVersion.isEmpty() ) 
80         myWizard->setVersion( myVersion );
81     }
82     if ( attributes.value( "caption" ) ) {
83       myCaption = attributes.value( "caption" ).arg( myVersion ).stripWhiteSpace();
84       if ( myWizard && !myCaption.isEmpty() ) 
85         myWizard->setCaption( myCaption );
86     }
87     if ( attributes.value( "copyright" ) ) {
88       myCopyright = attributes.value( "copyright" ).stripWhiteSpace();
89       if ( myWizard && !myCopyright.isEmpty() ) 
90         myWizard->setCopyright( myCopyright );
91     }
92     if ( attributes.value( "license" ) ) {
93       myLicense = attributes.value( "license" ).stripWhiteSpace();
94       if ( myWizard && !myLicense.isEmpty() ) 
95         myWizard->setLicense( myLicense );
96     }
97     if ( attributes.value( "os" ) ) {
98       myOS = attributes.value( "os" ).stripWhiteSpace();
99       if ( myWizard && !myOS.isEmpty() ) 
100         myWizard->setOS( myOS );
101     }
102   } 
103   else if (( qName == "product" ) && ( attributes.length() > 0 ) && myTree && myWizard ) {
104     if (attributes.value( "disable" ) == "true" )
105       return true;
106     
107     QString install = attributes.value( "install" );
108     QStringList supported = QStringList::split( ",", attributes.value( "supported" ) );
109     QString script = attributes.value( "script" );
110     element = myTree->addItem( attributes.value( "name" ), attributes.value( "version" ), install, supported, script );
111     if ( attributes.value( "dependancies" ) == "" ) {
112       QStringList diskspace = QStringList::split( ",",attributes.value( "installdiskspace" ) );
113       if (diskspace.count() == 2)
114         myWizard->setDependancies( element, 
115                                    Dependancies( attributes.value( "name" ), QStringList(), 
116                                                  diskspace[0].toInt(), 
117                                                  diskspace[1].toInt(), 
118                                                  attributes.value( "temporarydiskspace" ).toInt() ) );
119       else
120         myWizard->setDependancies( element, 
121                                    Dependancies( attributes.value( "name" ), QStringList(), 
122                                                  diskspace[0].toInt(), 
123                                                  diskspace[0].toInt(), 
124                                                  attributes.value( "temporarydiskspace" ).toInt() ) );
125
126     } 
127     else {
128       QStringList diskspace = QStringList::split(",",attributes.value( "installdiskspace" ) );
129       if (diskspace.count() == 2)
130         myWizard->setDependancies( element, 
131                                    Dependancies( attributes.value( "name" ), 
132                                                  QStringList::split( ",", attributes.value( "dependancies" ) ), 
133                                                  diskspace[0].toInt(), 
134                                                  diskspace[1].toInt(), 
135                                                  attributes.value( "temporarydiskspace" ).toInt() ) );
136       else
137         myWizard->setDependancies( element, 
138                                    Dependancies( attributes.value( "name" ), 
139                                                  QStringList::split( ",", attributes.value( "dependancies" ) ), 
140                                                  diskspace[0].toInt(), 
141                                                  diskspace[0].toInt(),
142                                                  attributes.value( "temporarydiskspace" ).toInt() ) );
143     }
144   } 
145   else if (( qName == "path" ) && ( attributes.length() > 0 ) && myWizard ) {
146     if ( myTargetDir )
147       myTargetDir->setText( attributes.value( "targetdir" ) );
148
149     if ( myTempDir ) {
150       if ( attributes.value( "tempdir" ) == "" )
151         myTempDir->setText( "/tmp" );
152       else
153         myTempDir->setText( attributes.value( "tempdir" ) );
154     }
155   }
156   return true;
157 }
158 // ================================================================
159 /*!
160  *  StructureParser::endElement
161  *  Finishes parsing of the xml dom-element
162  */
163 // ================================================================
164 bool StructureParser::endElement( const QString&, 
165                                   const QString&,
166                                   const QString& )
167 {
168   return true;
169 }
170