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 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" ),
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(),
127 else if (( qName == "path" ) && ( attributes.length() > 0 ) && myWizard ) {
129 myTargetDir->setText( attributes.value( "targetdir" ) );
132 if ( attributes.value( "tempdir" ) == "" )
133 myTempDir->setText( "/tmp" );
135 myTempDir->setText( attributes.value( "tempdir" ) );
140 // ================================================================
142 * StructureParser::endElement
143 * Finishes parsing of the xml dom-element
145 // ================================================================
146 bool StructureParser::endElement( const QString&,