]> SALOME platform Git repositories - tools/install.git/blob - src/SALOME_XmlHandler.cxx
Salome HOME
Add description tag support
[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     QStringList deps = QStringList();
111     if ( attributes.value( "dependancies" ) != "" )
112       deps = QStringList::split( ",", attributes.value( "dependancies" ), false );
113     element = myTree->addItem( attributes.value( "name" ), attributes.value( "version" ), install, supported, script );
114     QStringList diskspace = QStringList::split(",",attributes.value( "installdiskspace" ) );
115     QString descr = QString::null;
116     if ( attributes.value( "description" ) != "" )
117       descr = attributes.value( "description" ).stripWhiteSpace();
118     myWizard->setDependancies( element, 
119                                Dependancies( attributes.value( "name" ), 
120                                              deps,
121                                              ( diskspace.count() > 0 ? diskspace[ 0 ].toInt() : 0 ), 
122                                              ( diskspace.count() > 1 ? diskspace[1].toInt() : ( diskspace.count() > 0 ? diskspace[0].toInt() : 0 ) ), 
123                                              attributes.value( "temporarydiskspace" ).toInt(),
124                                              install,
125                                              descr ) );
126   }
127   else if (( qName == "path" ) && ( attributes.length() > 0 ) && myWizard ) {
128     if ( myTargetDir )
129       myTargetDir->setText( attributes.value( "targetdir" ) );
130
131     if ( myTempDir ) {
132       if ( attributes.value( "tempdir" ) == "" )
133         myTempDir->setText( "/tmp" );
134       else
135         myTempDir->setText( attributes.value( "tempdir" ) );
136     }
137   }
138   return true;
139 }
140 // ================================================================
141 /*!
142  *  StructureParser::endElement
143  *  Finishes parsing of the xml dom-element
144  */
145 // ================================================================
146 bool StructureParser::endElement( const QString&, 
147                                   const QString&,
148                                   const QString& )
149 {
150   return true;
151 }
152