1 // File : SALOME_InstallWizard.hxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
5 // Module : Installation Wizard
6 // Copyright : 2002-2009 CEA
8 #ifndef __SALOME_InstallWizard
9 #define __SALOME_InstallWizard
11 #include "InstallWizard.h"
14 #include <qvaluelist.h>
15 #include <qstringlist.h>
37 // This enum describes the possible types of the SALOME installation
38 enum InstallationType { Binaries, Sources, Compile };
39 // This enum describes the possible states of a tristate parameter
40 enum BoolTristate { False, True, NotDefined };
43 Class Dependancies : Products info
44 This class stores all product dependancies for correct work of installation procedure
49 // default constructor, necessary for map
52 Dependancies( const QString& name,
53 const QStringList& depend,
55 const long Sourcessize,
56 const long SrcBuildsize,
58 const QString& vers = QString::null,
59 const QString& descr = QString::null,
60 const QString& tp = QString::null,
62 BoolTristate woGui = NotDefined )
65 sizeBinaryTotal( Binsize ),
66 sizeSourcesTotal( Sourcessize ),
67 sizeSrcBuildTotal( SrcBuildsize ),
76 QString getName() const { return smbName; }
78 QStringList getDependancies() const { return dependsOn; }
79 // gets disk space required
80 long getSize( InstallationType instType ) const
82 return instType == Binaries ? sizeBinaryTotal :
83 instType == Sources ? sizeSourcesTotal :
86 // gets temporary disk space required
87 long getTempSize( InstallationType instType ) const
89 return ( instType == Binaries ? 0 : instType == Sources ? 0 : sizeTemp );
91 // gets product's version
92 QString getVersion() const { return version; }
93 // gets product's description
94 QString getDescription() const { return description; }
95 // gets product's type
96 QString getType() const { return type; }
97 // returns true if this product needs to pick-up environment
98 bool pickUpEnvironment() { return pickupEnv; }
99 // returns true if this product supports installation without GUI mode
100 BoolTristate supportWoGuiMode() { return woGuiMode; }
103 QString smbName; // symbolic name
104 QStringList dependsOn; // prerequisites list
105 long sizeBinaryTotal; // disk space for binaries required
106 long sizeSourcesTotal; // disk space for sources required
107 long sizeSrcBuildTotal; // disk space for compiled sources required
108 long sizeTemp; // disk space for temporary files required
109 QString version; // product's version
110 QString description; // product's description
111 QString type; // product's type (salome sources, binaries or prerequisite)
112 bool pickupEnv; // "Pick-up environment" flag
113 BoolTristate woGuiMode; // support of installation without GUI flag
117 Class Button : Operation button info
118 This class stores information about the custom operation buttons which appear on
119 the <Finish> page of the Install Wizard.
124 // default constructor, required for list
125 Button() : myButton( 0 ) {}
127 Button( const QString& label, const QString& tooltip, const QString& script )
128 : myLabel( label ), myTootip( tooltip ), myScript( script ), myButton( 0 ) {}
130 // set operation button
131 void setButton( QButton* btn ) { myButton = btn; }
134 QString label() const { return myLabel; }
136 QString tootip() const { return myTootip; }
138 QString script() const { return myScript; }
139 // get operation button
140 QButton* button() const { return myButton; }
143 QString myLabel; // button label
144 QString myTootip; // button tooltip
145 QString myScript; // operation script
146 QButton* myButton; // operation button
149 typedef QMap<QCheckListItem*, Dependancies> MapProducts;
150 typedef QValueList<Button> ButtonList;
151 typedef QMap<QString, QString> MapXmlFiles;
152 typedef QMap<QString, BoolTristate> MapAttrStates;
155 Class SALOME_InstallWizard : Installation Wizard's main window
157 class SALOME_InstallWizard: public InstallWizard
163 SALOME_InstallWizard( const QString& aXmlFileName = QString::null,
164 const QString& aTargetDir = QString::null,
165 const QString& aTmpDir = QString::null,
166 const bool aForceSrc = false,
167 const bool aSingleDir = false );
169 virtual ~SALOME_InstallWizard( );
171 // get base platform to install binaries package
172 QString getBasePlatform();
173 // get current platform
174 static QStringList currentPlatform();
175 // get application root dir
176 static QString rootDirPath();
179 QString getBinPath() const { return binPath; }
181 QString getSrcPath() const { return srcPath; }
182 // get platform binaries path
183 QString getPlatformBinPath( const QString& ) const;
185 // get map of supported platforms and corresponding XML files
186 MapXmlFiles getXmlMap( const QString& aXmlFileName = QString::null );
187 // check/get XML file and current platform
188 void getXmlAndPlatform();
191 bool eventFilter( QObject* object, QEvent* event );
194 void setDependancies( QCheckListItem* item, Dependancies dep);
196 // add button for the <Finish> page
197 void addFinishButton( const QString& label,
198 const QString& tooltip,
199 const QString& script,
200 bool toClear = false );
203 void setVersion( const QString& version ) { myVersion = version; }
205 void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
207 void setCopyright( const QString& copyright ) { myCopyright = copyright; }
209 void setLicense( const QString& license ) { myLicense = license; }
210 // set list of optional libraries
211 void setOptionalLibs( const QString& optlibs ) { myOptLibs = QStringList::split( ",", optlibs ); }
214 QString getVersion() { return myVersion; }
216 QString getCaption() { return myCaption; }
218 QString getCopyright() { return myCopyright; }
220 QString getLicense() { return myLicense; }
221 // get list of optional libraries
222 QStringList getOptionalLibs() { return myOptLibs; }
224 QString getPlatform() { return !refPlatform.isEmpty() ? refPlatform : curPlatform; }
225 // get corresponding XML file
226 QString getXmlFile( const QString& platform ) {
227 return (platformsMap.find( platform ) != platformsMap.end() ) ?
228 platformsMap[ platform ] :
231 // get InstallWizard's name
232 QString getIWName() { return myIWName; }
234 // process validation event (<val> is validation code)
235 void processValidateEvent( const int val, void* data );
236 // get private installation type
237 InstallationType getInstType() { return installType; };
240 // polishing of the widget
243 // save install log to file
247 // updates caption according to the current page number
248 void updateCaption();
249 // close event handler
250 void closeEvent( QCloseEvent* ce );
251 // creates introduction page
252 void setupIntroPage();
253 // create installation types page
254 void setupTypePage();
255 // create platforms page
256 void setupPlatformPage();
257 // create directories page
259 // creates products page
260 void setupProductsPage();
261 // creates prestart page
262 void setupCheckPage();
263 // creates progress page
264 void setupProgressPage();
265 // creates readme page
266 void setupReadmePage();
267 // displays choice info
268 void showChoiceInfo();
269 // validates page when <Next> button is clicked
270 bool acceptData( const QString& );
271 // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
272 bool checkSize( long* totSize = 0, long* tempSize = 0 );
273 // checks products page validity (directories and products selection)
274 void checkProductPage();
275 // sets the product and all products this one depends on to be checked
276 void setPrerequisites( QCheckListItem* item );
277 // unsets all products which depend of unchecked product ( recursively )
278 void unsetPrerequisites( QCheckListItem* item );
279 // runs installation script
281 // searches product listview item with given symbolic name
282 QCheckListItem* findItem( const QString& sName );
283 // sets progress state to Aborted
285 // clears and (optionally) removes temporary directory
286 void clean(bool rmDir = false);
287 // Update GUI and check installation errors
288 void completeInstallation();
289 // Run the modification of SALOME *.la files
290 void runModifyLaFiles();
291 // Run the Fortran libraries checking
301 // called when user moves from page to page
302 void pageChanged( const QString & mytitle);
303 // called when user selected either installation type or installation platform
304 void onButtonGroup( int index );
305 // invokes Help window
307 // invokes directory selection dialog box
308 void browseDirectory();
309 // called when directory path (target or temp) is changed
310 void directoryChanged( const QString& text );
311 // <Start> button's slot - runs installation
313 // called when users tries to pass parameters for the script
314 void onReturnPressed();
315 // callback function - as response for the script finishing
316 void productInstalled();
317 // called when <Cancel> button is clicked during installation script running
319 // kills installation process and quits application
321 // called when selection is changed in the products list view
322 void onSelectionChanged();
323 // called when user checks/unchecks any product item
324 void onItemToggled( QCheckListItem* );
325 // <Installation with GUI> check-box slot
326 void onInstallGuiBtn();
327 // <More...> button slot
329 // Slot to update 'Available disk space' field
330 void updateAvailableSpace();
331 // Slot to take result of modification SALOME *.la files
332 void checkModifyLaResult();
333 // Slot to take result of Fortran libraries checking
334 void checkFLibResult();
335 // Slot to update 'Size' column for modules and prerequisites
336 void updateSizeColumn();
338 // <Finish> page buttons slot
339 void onFinishButton();
341 // <About> button slot
345 // -->something was written to stdin
347 // -->something was written to stout
348 void readFromStdout();
349 // -->something was written to stderr
350 void readFromStderr();
353 QString myIWName; // Installation Wizard's name
354 QString myVersion; // version info
355 QString myCaption; // application name
356 QString myCopyright; // copyright info
357 QString myLicense; // license info
358 QString myTargetPath; // target directory path
359 QString myTmpPath; // temporary directory path
360 QStringList myOptLibs; // list of optional libraries
362 HelpWindow* helpWindow; // help window
363 QProcess* shellProcess; // shell process (install script)
364 QProcess* diskSpaceProc; // shell process (to get available disk space script)
365 QProcess* modifyLaProc; // shell process (to modify SALOME *.la files script)
366 QProcess* checkFLibProc; // shell process (to check Fortran libraries script)
367 MapProducts productsMap; // products info (name, dependancies, disk space )
368 MapXmlFiles extraProducts; // additional products to be installed
369 QStringList toInstall; // list of products being installed
370 QStringList notInstall; // list of products being not installed
371 QStringList prodSequence; // specified list of products being installed
372 MapAttrStates woGuiModules; // map of SALOME modules names, that can support installation without GUI mode
373 InstallationType installType; // type of the installation
374 QString curPlatform; // current operating system
375 QString refPlatform; // referenced operating system (selected by user). It is defined,
376 // if current OS is not determined or not supported only
377 MapXmlFiles platformsMap; // supported operating systems and corresponding XML files
378 QString xmlFileName; // xml file
379 QString binPath; // binaries path
380 QString srcPath; // sources path
381 QString oneProdDirName; // name of the single directory for binaries of prerequisites
382 QString commonPlatform; // platform with universal binaries
383 bool moreMode; // advanced mode flag
384 QWidget* previousPage; // previous page
385 QString tmpCreated; // created temporary directory
386 bool stateChanged; // flag: whether installation type or platform was changed
387 bool exitConfirmed; // flag: "Exit confirmed"
388 bool rmSrcPrevState; // flag: status of "Remove SRC & TMP files" is changed ?
390 // --> introduction page
391 QWidget* introPage; // page itself
392 QLabel* logoLab; // logo pixmap
393 QLabel* versionLab; // version info
394 QLabel* copyrightLab; // copyright info
395 QLabel* licenseLab; // license info
396 QLabel* info; // program info
397 // --> installation types page
398 QWidget* typePage; // page itself
399 QButtonGroup* buttonGrp; // group of the available installation types radio-buttons
400 QRadioButton* binBtn; // install binaries button
401 QRadioButton* srcBtn; // install sources button
402 QRadioButton* srcCompileBtn; // install sources and compile button
403 QCheckBox* removeSrcBtn; // <Remove sources & tmp files> checkbox
404 bool forceSrc; // Force all products to be compiled from sources
405 // --> installation platform page
406 QWidget* platformsPage; // page itself
407 QButtonGroup* platBtnGrp; // group of platforms for selection
408 QString warnMsg; // warning message
409 QLabel* warnLab; // warning label
410 QLabel* warnLab3; // additional warning label
411 // --> installation directories page
412 QWidget* dirPage; // page itself
413 QLineEdit* targetFolder; // target directory for installing of products
414 QPushButton* targetBtn; // browse target directory button
415 QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
416 QPushButton* tempBtn; // browse temp directory button
418 QWidget* productsPage; // page itself
419 ProductsView* modulesView; // modules list view
420 QMyCheckBox* installGuiBtn; // <Installation with GUI> checkbox
421 ProductsView* prereqsView; // prerequisites list view
422 QMyCheckBox* oneModDirBtn; // <Install SALOME modules to a single directory> checkbox
423 QMyCheckBox* oneProdDirBtn; // <Install prerequisites to a single directory> checkbox
424 QPushButton* moreBtn; // <Show/Hide prerequisites> button
425 QTextBrowser* productInfo; // products info box
426 QLabel* requiredSize; // <Total disk space required> label
427 QLabel* requiredTemp; // <Space required for temporary files> label
428 QLabel* availableSize; // <Available disk space> label
429 bool singleDir; // Force all SALOME modules to be installed into single directory
431 QWidget* prestartPage; // page itself
432 QTextEdit* choices; // choice text view
434 QWidget* progressPage; // page itself
435 QSplitter* splitter; // splitter window
436 InstallInfo* installInfo; // information about running installation scripts
437 QLabel* parametersLab; // answer field's label
438 QLineEdit* passedParams; // user can pass data to running script
439 QTextEdit* installProgress;// contains information about progress of installing selected products
440 ProgressView* progressView; // displays information about progress of installing selected products
441 QLabel* statusLab; // displays currently performed action
443 QWidget* readmePage; // page itself
444 QTextEdit* readme; // Readme information window
445 ButtonList buttons; // operation buttons
447 ProcessThread* myThread; // validation thread
448 bool hasErrors; // flag: if there were any errors or warnings during the installation