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 bool isBoolAttributeSet( const QString& attr ) {
16 return ( attr == "true" || attr == "yes" || attr == "ok" || ( !attr.stripWhiteSpace().isEmpty() && attr.toInt() != 0 ) );
19 // ================================================================
21 * StructureParser::StructureParser
24 // ================================================================
25 StructureParser::StructureParser( SALOME_InstallWizard* wizard )
26 : QXmlDefaultHandler(),
33 // ================================================================
35 * StructureParser::setProductsList
36 * Sets products list view
38 // ================================================================
39 void StructureParser::setProductsList( ProductsView* tree )
43 // ================================================================
45 * StructureParser::setTargetDir
46 * Sets target directory widget
48 // ================================================================
49 void StructureParser::setTargetDir( QLineEdit* dir )
53 // ================================================================
55 * StructureParser::setTempDir
56 * Sets temp directory widget
58 // ================================================================
59 void StructureParser::setTempDir( QLineEdit* dir )
63 // ================================================================
65 * StructureParser::startElement
66 * Begins parsing of the xml dom-element
68 // ================================================================
69 bool StructureParser::startElement( const QString& /*namespaceURI*/,
70 const QString& /*localName*/,
72 const QXmlAttributes& attributes)
75 cout << qName << endl;
76 cout << attributes.length() << endl;
78 QCheckListItem* element;
79 if (( qName == "config" ) && ( attributes.length() > 0 ) ) {
80 QString myVersion, myCaption, myCopyright, myLicense, myOS;
81 if ( attributes.value( "version" ) ) {
82 myVersion = attributes.value( "version" ).stripWhiteSpace();
83 if ( myWizard && !myVersion.isEmpty() )
84 myWizard->setVersion( myVersion );
86 if ( attributes.value( "caption" ) ) {
87 myCaption = attributes.value( "caption" ).arg( myVersion ).stripWhiteSpace();
88 if ( myWizard && !myCaption.isEmpty() )
89 myWizard->setCaption( myCaption );
91 if ( attributes.value( "copyright" ) ) {
92 myCopyright = attributes.value( "copyright" ).stripWhiteSpace();
93 if ( myWizard && !myCopyright.isEmpty() )
94 myWizard->setCopyright( myCopyright );
96 if ( attributes.value( "license" ) ) {
97 myLicense = attributes.value( "license" ).stripWhiteSpace();
98 if ( myWizard && !myLicense.isEmpty() )
99 myWizard->setLicense( myLicense );
101 if ( attributes.value( "os" ) ) {
102 myOS = attributes.value( "os" ).stripWhiteSpace();
103 if ( myWizard && !myOS.isEmpty() )
104 myWizard->setOS( myOS );
107 else if (( qName == "product" ) && ( attributes.length() > 0 ) && myTree && myWizard ) {
108 if ( isBoolAttributeSet( attributes.value( "disable" ) ) )
111 QString install = attributes.value( "install" );
112 QStringList supported = QStringList::split( ",", attributes.value( "supported" ) );
113 QString script = attributes.value( "script" );
114 QStringList deps = QStringList();
115 if ( attributes.value( "dependancies" ) != "" )
116 deps = QStringList::split( ",", attributes.value( "dependancies" ), false );
117 element = myTree->addItem( attributes.value( "name" ), attributes.value( "version" ), install, supported, script );
118 QStringList diskspace = QStringList::split(",",attributes.value( "installdiskspace" ) );
119 QString descr = QString::null;
120 if ( attributes.value( "description" ) != "" )
121 descr = attributes.value( "description" ).stripWhiteSpace();
122 bool pickUp = isBoolAttributeSet( attributes.value( "pickupenv" ) );
123 myWizard->setDependancies( element,
124 Dependancies( attributes.value( "name" ),
126 ( diskspace.count() > 0 ? diskspace[ 0 ].toInt() : 0 ),
127 ( diskspace.count() > 1 ? diskspace[1].toInt() : ( diskspace.count() > 0 ? diskspace[0].toInt() : 0 ) ),
128 attributes.value( "temporarydiskspace" ).toInt(),
133 else if (( qName == "path" ) && ( attributes.length() > 0 ) && myWizard ) {
135 myTargetDir->setText( attributes.value( "targetdir" ) );
138 if ( attributes.value( "tempdir" ) == "" )
139 myTempDir->setText( "/tmp" );
141 myTempDir->setText( attributes.value( "tempdir" ) );
146 // ================================================================
148 * StructureParser::endElement
149 * Finishes parsing of the xml dom-element
151 // ================================================================
152 bool StructureParser::endElement( const QString&,