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
9 #include "SALOME_XmlHandler.hxx"
10 #include "SALOME_ProductsView.hxx"
11 #include "SALOME_InstallWizard.hxx"
13 #include <qlineedit.h>
15 // ================================================================
17 * StructureParser::StructureParser
20 // ================================================================
21 StructureParser::StructureParser( SALOME_InstallWizard* wizard )
22 : QXmlDefaultHandler(),
29 // ================================================================
31 * StructureParser::setProductsList
32 * Sets products list view
34 // ================================================================
35 void StructureParser::setProductsList( ProductsView* tree )
39 // ================================================================
41 * StructureParser::setTargetDir
42 * Sets target directory widget
44 // ================================================================
45 void StructureParser::setTargetDir( QLineEdit* dir )
49 // ================================================================
51 * StructureParser::setTempDir
52 * Sets temp directory widget
54 // ================================================================
55 void StructureParser::setTempDir( QLineEdit* dir )
59 // ================================================================
61 * StructureParser::startElement
62 * Begins parsing of the xml dom-element
64 // ================================================================
65 bool StructureParser::startElement( const QString& /*namespaceURI*/,
66 const QString& /*localName*/,
68 const QXmlAttributes& attributes)
71 cout << qName << endl;
72 cout << attributes.length() << endl;
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 );
82 if ( attributes.value( "caption" ) ) {
83 myCaption = attributes.value( "caption" ).arg( myVersion ).stripWhiteSpace();
84 if ( myWizard && !myCaption.isEmpty() )
85 myWizard->setCaption( myCaption );
87 if ( attributes.value( "copyright" ) ) {
88 myCopyright = attributes.value( "copyright" ).stripWhiteSpace();
89 if ( myWizard && !myCopyright.isEmpty() )
90 myWizard->setCopyright( myCopyright );
92 if ( attributes.value( "license" ) ) {
93 myLicense = attributes.value( "license" ).stripWhiteSpace();
94 if ( myWizard && !myLicense.isEmpty() )
95 myWizard->setLicense( myLicense );
97 if ( attributes.value( "os" ) ) {
98 myOS = attributes.value( "os" ).stripWhiteSpace();
99 if ( myWizard && !myOS.isEmpty() )
100 myWizard->setOS( myOS );
103 else if (( qName == "product" ) && ( attributes.length() > 0 ) && myTree && myWizard ) {
104 if (attributes.value( "disable" ) == "true" )
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() ) );
120 myWizard->setDependancies( element,
121 Dependancies( attributes.value( "name" ), QStringList(),
122 diskspace[0].toInt(),
123 diskspace[0].toInt(),
124 attributes.value( "temporarydiskspace" ).toInt() ) );
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() ) );
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() ) );
145 else if (( qName == "path" ) && ( attributes.length() > 0 ) && myWizard ) {
147 myTargetDir->setText( attributes.value( "targetdir" ) );
150 if ( attributes.value( "tempdir" ) == "" )
151 myTempDir->setText( "/tmp" );
153 myTempDir->setText( attributes.value( "tempdir" ) );
158 // ================================================================
160 * StructureParser::endElement
161 * Finishes parsing of the xml dom-element
163 // ================================================================
164 bool StructureParser::endElement( const QString&,