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-2007 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 };
41 Class Dependancies : Products info
42 This class stores all product dependancies for correct work of installation procedure
47 // default constructor, necessary for map
50 Dependancies( const QString& name,
51 const QStringList& depend,
53 const long Sourcessize,
54 const long SrcBuildsize,
56 const QString& vers = QString::null,
57 const QString& descr = QString::null,
58 const QString& tp = QString::null,
62 sizeBinaryTotal( Binsize ),
63 sizeSourcesTotal( Sourcessize ),
64 sizeSrcBuildTotal( SrcBuildsize ),
69 pickupEnv( pickup ) {}
72 QString getName() const { return smbName; }
74 QStringList getDependancies() const { return dependsOn; }
75 // gets disk space required
76 long getSize( InstallationType instType ) const
78 return ( instType == Binaries ? ( type == "component" ? sizeBinaryTotal + sizeSourcesTotal : sizeBinaryTotal ) :
79 ( instType == Sources ? sizeSourcesTotal : sizeSrcBuildTotal ) );
81 // gets temporary disk space required
82 long getTempSize( InstallationType instType ) const
84 return ( instType == Binaries ? 0 : instType == Sources ? 0 : sizeTemp );
86 // gets product's version
87 QString getVersion() const { return version; }
88 // gets product's description
89 QString getDescription() const { return description; }
90 // gets product's type
91 QString getType() const { return type; }
92 // returns true if product supports given type
93 bool hasType( const QString& tp ) const
95 QStringList tl = QStringList::split(",",type);
96 return tl.find( tp ) != tl.end();
99 QString getDefault() const { return ""; }
100 // returns true if this product needs to pick-up environment
101 bool pickUpEnvironment() { return pickupEnv; }
104 QString smbName; // symbolic name
105 QStringList dependsOn; // prerequisites list
106 long sizeBinaryTotal; // disk space for binaries required
107 long sizeSourcesTotal; // disk space for sources required
108 long sizeSrcBuildTotal; // disk space for compiled sources required
109 long sizeTemp; // disk space for temporary files required
110 QString version; // product's version
111 QString description; // product's description
112 QString type; // product's type (salome sources, binaries or prerequisite)
113 bool pickupEnv; // "Pick-up environment" 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;
154 Class SALOME_InstallWizard : Installation Wizard's main window
156 class SALOME_InstallWizard: public InstallWizard
162 SALOME_InstallWizard( const QString& aXmlFileName = QString::null,
163 const QString& aTargetDir = QString::null,
164 const QString& aTmpDir = QString::null );
166 virtual ~SALOME_InstallWizard( );
168 // get current platform
169 QString currentPlatform();
172 QString getBinPath() { return binPath; }
174 QString getSrcPath() { return srcPath; }
176 // get map of supported platforms and corresponding XML files
177 MapXmlFiles getXmlMap( const QString& aXmlFileName = QString::null );
178 // check/get XML file and current platform
179 void getXmlAndPlatform();
182 bool eventFilter( QObject* object, QEvent* event );
185 void setDependancies( QCheckListItem* item, Dependancies dep);
187 // add button for the <Finish> page
188 void addFinishButton( const QString& label,
189 const QString& tooltip,
190 const QString& script,
191 bool toClear = false );
194 void setVersion( const QString& version ) { myVersion = version; }
196 void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
198 void setCopyright( const QString& copyright ) { myCopyright = copyright; }
200 void setLicense( const QString& license ) { myLicense = license; }
203 QString getVersion() { return myVersion; }
205 QString getCaption() { return myCaption; }
207 QString getCopyright() { return myCopyright; }
209 QString getLicense() { return myLicense; }
211 QString getPlatform() { return refPlatform ? refPlatform : curPlatform; }
212 // get InstallWizard's name
213 QString getIWName() { return myIWName; }
215 // process validation event (<val> is validation code)
216 void processValidateEvent( const int val, void* data );
217 // get private installation type
218 InstallationType getInstType() { return installType; };
221 // polishing of the widget
224 // save install log to file
228 // updates caption according to the current page number
229 void updateCaption();
230 // close event handler
231 void closeEvent( QCloseEvent* ce );
232 // creates introduction page
233 void setupIntroPage();
234 // create installation types page
235 void setupTypePage();
236 // create platforms page
237 void setupPlatformPage();
238 // create directories page
240 // creates products page
241 void setupProductsPage();
242 // creates prestart page
243 void setupCheckPage();
244 // creates progress page
245 void setupProgressPage();
246 // creates readme page
247 void setupReadmePage();
248 // displays choice info
249 void showChoiceInfo();
250 // validates page when <Next> button is clicked
251 bool acceptData( const QString& );
252 // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
253 bool checkSize( long* totSize = 0, long* tempSize = 0 );
254 // checks products page validity (directories and products selection)
255 void checkProductPage();
256 // sets the product and all products this one depends on to be checked
257 void setPrerequisites( QCheckListItem* item );
258 // unsets all products which depend of unchecked product ( recursively )
259 void unsetPrerequisites( QCheckListItem* item );
260 // runs installation script
262 // searches product listview item with given symbolic name
263 QCheckListItem* findItem( const QString& sName );
264 // sets progress state to Aborted
266 // clears and (optionally) removes temporary directory
267 void clean(bool rmDir = false);
268 // Update GUI and check installation errors
269 void completeInstallation();
278 // called when user moves from page to page
279 void pageChanged( const QString & mytitle);
280 // called when user selected either installation type or installation platform
281 void onButtonGroup( int index );
282 // invokes Help window
284 // invokes directory selection dialog box
285 void browseDirectory();
286 // called when directory path (target or temp) is changed
287 void directoryChanged( const QString& text );
288 // <Start> button's slot - runs installation
290 // called when users tries to pass parameters for the script
291 void onReturnPressed();
292 // callback function - as response for the script finishing
293 void productInstalled();
294 // called when <Cancel> button is clicked during installation script running
296 // kills installation process and quits application
298 // called when selection is changed in the products list view
299 void onSelectionChanged();
300 // called when user checks/unchecks any product item
301 void onItemToggled( QCheckListItem* );
302 // <Installation with GUI> check-box slot
303 void onInstallGuiBtn();
304 // <More...> button slot
306 // Slot to update 'Available disk space' field
307 void updateAvailableSpace();
308 // Slot to take result of Fortran libraries checking
309 void checkFLibResult();
311 // <Finish> page buttons slot
312 void onFinishButton();
314 // <About> button slot
318 // -->something was written to stdin
320 // -->something was written to stout
321 void readFromStdout();
322 // -->something was written to stderr
323 void readFromStderr();
326 QString myIWName; // Installation Wizard's name
327 QString myVersion; // version info
328 QString myCaption; // application name
329 QString myCopyright; // copyright info
330 QString myLicense; // license info
331 QString myTargetPath; // target directory path
332 QString myTmpPath; // temporary directory path
334 HelpWindow* helpWindow; // help window
335 QProcess* shellProcess; // shell process (install script)
336 QProcess* diskSpaceProc; // shell process (to get available disk space script)
337 QProcess* checkFLibProc; // shell process (to get available disk space script)
338 MapProducts productsMap; // products info (name, dependancies, disk space )
339 QStringList toInstall; // list of products being installed
340 QStringList notInstall; // list of products being not installed
341 QStringList prodSequence; // specified list of products being installed
342 InstallationType installType; // type of the installation
343 QString curPlatform; // current operating system
344 QString refPlatform; // referenced operating system (selected by user). It is defined,
345 // if current OS is not determined or not supported only
346 MapXmlFiles platformsMap; // supported operating systems and corresponding XML files
347 QString xmlFileName; // xml file
348 QString binPath; // binaries path
349 QString srcPath; // sources path
350 bool moreMode; // advanced mode flag
351 QWidget* previousPage; // previous page
352 QString tmpCreated; // created temporary directory
353 bool stateChanged; // flag: whether installation type or platform was changed
354 bool exitConfirmed; // flag: "Exit confirmed"
356 // --> introduction page
357 QWidget* introPage; // page itself
358 QLabel* logoLab; // logo pixmap
359 QLabel* versionLab; // version info
360 QLabel* copyrightLab; // copyright info
361 QLabel* licenseLab; // license info
362 QLabel* info; // program info
363 // --> installation types page
364 QWidget* typePage; // page itself
365 QButtonGroup* buttonGrp; // group of the available installation types radio-buttons
366 QRadioButton* binBtn; // install binaries button
367 QRadioButton* srcBtn; // install sources button
368 QRadioButton* srcCompileBtn; // install sources and compile button
369 QMyCheckBox* removeSrcBtn; // <Remove sources & tmp files> checkbox
370 // --> installation platform page
371 QWidget* platformsPage; // page itself
372 QButtonGroup* platBtnGrp; // group of platforms for selection
373 QString warnMsg; // warning message
374 QLabel* warnLab; // warning label
375 // --> installation directories page
376 QWidget* dirPage; // page itself
377 QLineEdit* targetFolder; // target directory for installing of products
378 QPushButton* targetBtn; // browse target directory button
379 QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
380 QPushButton* tempBtn; // browse temp directory button
382 QWidget* productsPage; // page itself
383 ProductsView* modulesView; // modules list view
384 QMyCheckBox* installGuiBtn; // <Installation with GUI> checkbox
385 ProductsView* prereqsView; // prerequisites list view
386 QPushButton* moreBtn; // <More...> button
387 QTextBrowser* productInfo; // products info box
388 QLabel* requiredSize; // <Total disk space required> label
389 QLabel* requiredTemp; // <Space required for temporary files> label
390 QLabel* availableSize; // <Available disk space> label
392 QWidget* prestartPage; // page itself
393 QTextEdit* choices; // choice text view
395 QWidget* progressPage; // page itself
396 QSplitter* splitter; // splitter window
397 InstallInfo* installInfo; // information about running installation scripts
398 QLabel* parametersLab; // answer field's label
399 QLineEdit* passedParams; // user can pass data to running script
400 QTextEdit* installProgress;// contains information about progress of installing selected products
401 ProgressView* progressView; // displays information about progress of installing selected products
402 QLabel* statusLab; // displays currently performed action
404 QWidget* readmePage; // page itself
405 QTextEdit* readme; // Readme information window
406 ButtonList buttons; // operation buttons
408 ProcessThread* myThread; // validation thread
409 bool hasErrors; // flag: if there were any errors or warnings during the installation