1 // File : SALOME_XmlHandler.cxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER
5 // Module : Installation Wizard
6 // Copyright : 2004-2005 CEA
10 #include "SALOME_XmlHandler.hxx"
11 #include "SALOME_ProductsView.hxx"
12 #include "SALOME_InstallWizard.hxx"
14 #include <qlineedit.h>
16 bool isBoolAttributeSet( const QString& attr ) {
17 return ( attr == "true" || attr == "yes" || attr == "ok" || ( !attr.stripWhiteSpace().isEmpty() && attr.toInt() != 0 ) );
20 // ================================================================
22 * StructureParser::StructureParser
25 // ================================================================
26 StructureParser::StructureParser( SALOME_InstallWizard* wizard )
27 : QXmlDefaultHandler(),
34 // ================================================================
36 * StructureParser::setProductsList
37 * Sets products list view
39 // ================================================================
40 void StructureParser::setProductsList( ProductsView* tree )
44 // ================================================================
46 * StructureParser::setTargetDir
47 * Sets target directory widget
49 // ================================================================
50 void StructureParser::setTargetDir( QLineEdit* dir )
54 // ================================================================
56 * StructureParser::setTempDir
57 * Sets temp directory widget
59 // ================================================================
60 void StructureParser::setTempDir( QLineEdit* dir )
64 // ================================================================
66 * StructureParser::startElement
67 * Begins parsing of the xml dom-element
69 // ================================================================
70 bool StructureParser::startElement( const QString& /*namespaceURI*/,
71 const QString& /*localName*/,
73 const QXmlAttributes& attributes)
75 ___MESSAGE___( qName );
76 ___MESSAGE___( attributes.length() );
77 QCheckListItem* element;
78 if (( qName == "config" ) && ( attributes.length() > 0 ) ) {
79 QString myVersion, myCaption, myCopyright, myLicense, myOS;
80 if ( attributes.value( "version" ) ) {
81 myVersion = attributes.value( "version" ).stripWhiteSpace();
82 if ( myWizard && !myVersion.isEmpty() )
83 myWizard->setVersion( myVersion );
85 if ( attributes.value( "caption" ) ) {
86 myCaption = attributes.value( "caption" ).arg( myVersion ).stripWhiteSpace();
87 if ( myWizard && !myCaption.isEmpty() )
88 myWizard->setCaption( myCaption );
90 if ( attributes.value( "copyright" ) ) {
91 myCopyright = attributes.value( "copyright" ).stripWhiteSpace();
92 if ( myWizard && !myCopyright.isEmpty() )
93 myWizard->setCopyright( myCopyright );
95 if ( attributes.value( "license" ) ) {
96 myLicense = attributes.value( "license" ).stripWhiteSpace();
97 if ( myWizard && !myLicense.isEmpty() )
98 myWizard->setLicense( myLicense );
100 if ( attributes.value( "os" ) ) {
101 myOS = attributes.value( "os" ).stripWhiteSpace();
102 if ( myWizard && !myOS.isEmpty() )
103 myWizard->setOS( myOS );
106 else if (( qName == "product" ) && ( attributes.length() > 0 ) && myTree && myWizard ) {
107 if ( isBoolAttributeSet( attributes.value( "disable" ) ) )
110 QString install = attributes.value( "install" );
111 QStringList supported = QStringList::split( ",", attributes.value( "supported" ) );
112 QString script = attributes.value( "script" );
113 QStringList deps = QStringList();
114 if ( attributes.value( "dependancies" ) != "" )
115 deps = QStringList::split( ",", attributes.value( "dependancies" ), false );
116 element = myTree->addItem( attributes.value( "name" ), attributes.value( "version" ), install, supported, script );
117 QStringList diskspace = QStringList::split(",",attributes.value( "installdiskspace" ) );
118 QString descr = QString::null;
119 if ( attributes.value( "description" ) != "" )
120 descr = attributes.value( "description" ).stripWhiteSpace();
121 QString ctx = QString::null;
122 if ( attributes.value( "context" ) != "" )
123 ctx = attributes.value( "context" ).stripWhiteSpace().lower();
124 bool pickUp = isBoolAttributeSet( attributes.value( "pickupenv" ) );
125 myWizard->setDependancies( element,
126 Dependancies( attributes.value( "name" ),
128 ( diskspace.count() > 0 ? diskspace[ 0 ].toInt() : 0 ),
129 ( diskspace.count() > 1 ? diskspace[1].toInt() : ( diskspace.count() > 0 ? diskspace[0].toInt() : 0 ) ),
130 attributes.value( "temporarydiskspace" ).toInt(),
136 else if (( qName == "path" ) && ( attributes.length() > 0 ) && myWizard ) {
138 myTargetDir->setText( attributes.value( "targetdir" ) );
141 if ( attributes.value( "tempdir" ) == "" )
142 myTempDir->setText( "/tmp" );
144 myTempDir->setText( attributes.value( "tempdir" ) );
149 // ================================================================
151 * StructureParser::endElement
152 * Finishes parsing of the xml dom-element
154 // ================================================================
155 bool StructureParser::endElement( const QString&,