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 ? sizeBinaryTotal :
79 instType == Sources ? sizeSourcesTotal :
82 // gets temporary disk space required
83 long getTempSize( InstallationType instType ) const
85 return ( instType == Binaries ? 0 : instType == Sources ? 0 : sizeTemp );
87 // gets product's version
88 QString getVersion() const { return version; }
89 // gets product's description
90 QString getDescription() const { return description; }
91 // gets product's type
92 QString getType() const { return type; }
93 // returns true if this product needs to pick-up environment
94 bool pickUpEnvironment() { return pickupEnv; }
97 QString smbName; // symbolic name
98 QStringList dependsOn; // prerequisites list
99 long sizeBinaryTotal; // disk space for binaries required
100 long sizeSourcesTotal; // disk space for sources required
101 long sizeSrcBuildTotal; // disk space for compiled sources required
102 long sizeTemp; // disk space for temporary files required
103 QString version; // product's version
104 QString description; // product's description
105 QString type; // product's type (salome sources, binaries or prerequisite)
106 bool pickupEnv; // "Pick-up environment" flag
110 Class Button : Operation button info
111 This class stores information about the custom operation buttons which appear on
112 the <Finish> page of the Install Wizard.
117 // default constructor, required for list
118 Button() : myButton( 0 ) {}
120 Button( const QString& label, const QString& tooltip, const QString& script )
121 : myLabel( label ), myTootip( tooltip ), myScript( script ), myButton( 0 ) {}
123 // set operation button
124 void setButton( QButton* btn ) { myButton = btn; }
127 QString label() const { return myLabel; }
129 QString tootip() const { return myTootip; }
131 QString script() const { return myScript; }
132 // get operation button
133 QButton* button() const { return myButton; }
136 QString myLabel; // button label
137 QString myTootip; // button tooltip
138 QString myScript; // operation script
139 QButton* myButton; // operation button
142 typedef QMap<QCheckListItem*, Dependancies> MapProducts;
143 typedef QValueList<Button> ButtonList;
144 typedef QMap<QString, QString> MapXmlFiles;
147 Class SALOME_InstallWizard : Installation Wizard's main window
149 class SALOME_InstallWizard: public InstallWizard
155 SALOME_InstallWizard( const QString& aXmlFileName = QString::null,
156 const QString& aTargetDir = QString::null,
157 const QString& aTmpDir = QString::null );
159 virtual ~SALOME_InstallWizard( );
161 // get current platform
162 QString currentPlatform();
165 QString getBinPath() { return binPath; }
167 QString getSrcPath() { return srcPath; }
169 // get map of supported platforms and corresponding XML files
170 MapXmlFiles getXmlMap( const QString& aXmlFileName = QString::null );
171 // check/get XML file and current platform
172 void getXmlAndPlatform();
175 bool eventFilter( QObject* object, QEvent* event );
178 void setDependancies( QCheckListItem* item, Dependancies dep);
180 // add button for the <Finish> page
181 void addFinishButton( const QString& label,
182 const QString& tooltip,
183 const QString& script,
184 bool toClear = false );
187 void setVersion( const QString& version ) { myVersion = version; }
189 void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
191 void setCopyright( const QString& copyright ) { myCopyright = copyright; }
193 void setLicense( const QString& license ) { myLicense = license; }
196 QString getVersion() { return myVersion; }
198 QString getCaption() { return myCaption; }
200 QString getCopyright() { return myCopyright; }
202 QString getLicense() { return myLicense; }
204 QString getPlatform() { return refPlatform ? refPlatform : curPlatform; }
205 // get InstallWizard's name
206 QString getIWName() { return myIWName; }
208 // process validation event (<val> is validation code)
209 void processValidateEvent( const int val, void* data );
210 // get private installation type
211 InstallationType getInstType() { return installType; };
214 // polishing of the widget
217 // save install log to file
221 // updates caption according to the current page number
222 void updateCaption();
223 // close event handler
224 void closeEvent( QCloseEvent* ce );
225 // creates introduction page
226 void setupIntroPage();
227 // create installation types page
228 void setupTypePage();
229 // create platforms page
230 void setupPlatformPage();
231 // create directories page
233 // creates products page
234 void setupProductsPage();
235 // creates prestart page
236 void setupCheckPage();
237 // creates progress page
238 void setupProgressPage();
239 // creates readme page
240 void setupReadmePage();
241 // displays choice info
242 void showChoiceInfo();
243 // validates page when <Next> button is clicked
244 bool acceptData( const QString& );
245 // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
246 bool checkSize( long* totSize = 0, long* tempSize = 0 );
247 // checks products page validity (directories and products selection)
248 void checkProductPage();
249 // sets the product and all products this one depends on to be checked
250 void setPrerequisites( QCheckListItem* item );
251 // unsets all products which depend of unchecked product ( recursively )
252 void unsetPrerequisites( QCheckListItem* item );
253 // runs installation script
255 // searches product listview item with given symbolic name
256 QCheckListItem* findItem( const QString& sName );
257 // sets progress state to Aborted
259 // clears and (optionally) removes temporary directory
260 void clean(bool rmDir = false);
261 // Update GUI and check installation errors
262 void completeInstallation();
271 // called when user moves from page to page
272 void pageChanged( const QString & mytitle);
273 // called when user selected either installation type or installation platform
274 void onButtonGroup( int index );
275 // invokes Help window
277 // invokes directory selection dialog box
278 void browseDirectory();
279 // called when directory path (target or temp) is changed
280 void directoryChanged( const QString& text );
281 // <Start> button's slot - runs installation
283 // called when users tries to pass parameters for the script
284 void onReturnPressed();
285 // callback function - as response for the script finishing
286 void productInstalled();
287 // called when <Cancel> button is clicked during installation script running
289 // kills installation process and quits application
291 // called when selection is changed in the products list view
292 void onSelectionChanged();
293 // called when user checks/unchecks any product item
294 void onItemToggled( QCheckListItem* );
295 // <Installation with GUI> check-box slot
296 void onInstallGuiBtn();
297 // <More...> button slot
299 // Slot to update 'Available disk space' field
300 void updateAvailableSpace();
301 // Slot to take result of Fortran libraries checking
302 void checkFLibResult();
303 // Slot to update 'Size' column for modules and prerequisites
304 void updateSizeColumn();
306 // <Finish> page buttons slot
307 void onFinishButton();
309 // <About> button slot
313 // -->something was written to stdin
315 // -->something was written to stout
316 void readFromStdout();
317 // -->something was written to stderr
318 void readFromStderr();
321 QString myIWName; // Installation Wizard's name
322 QString myVersion; // version info
323 QString myCaption; // application name
324 QString myCopyright; // copyright info
325 QString myLicense; // license info
326 QString myTargetPath; // target directory path
327 QString myTmpPath; // temporary directory path
329 HelpWindow* helpWindow; // help window
330 QProcess* shellProcess; // shell process (install script)
331 QProcess* diskSpaceProc; // shell process (to get available disk space script)
332 QProcess* checkFLibProc; // shell process (to get available disk space script)
333 MapProducts productsMap; // products info (name, dependancies, disk space )
334 QStringList toInstall; // list of products being installed
335 QStringList notInstall; // list of products being not installed
336 QStringList prodSequence; // specified list of products being installed
337 InstallationType installType; // type of the installation
338 QString curPlatform; // current operating system
339 QString refPlatform; // referenced operating system (selected by user). It is defined,
340 // if current OS is not determined or not supported only
341 MapXmlFiles platformsMap; // supported operating systems and corresponding XML files
342 QString xmlFileName; // xml file
343 QString binPath; // binaries path
344 QString srcPath; // sources path
345 bool moreMode; // advanced mode flag
346 QWidget* previousPage; // previous page
347 QString tmpCreated; // created temporary directory
348 bool stateChanged; // flag: whether installation type or platform was changed
349 bool exitConfirmed; // flag: "Exit confirmed"
350 bool rmSrcPrevState; // flag: status of "Remove SRC & TMP files" is changed ?
352 // --> introduction page
353 QWidget* introPage; // page itself
354 QLabel* logoLab; // logo pixmap
355 QLabel* versionLab; // version info
356 QLabel* copyrightLab; // copyright info
357 QLabel* licenseLab; // license info
358 QLabel* info; // program info
359 // --> installation types page
360 QWidget* typePage; // page itself
361 QButtonGroup* buttonGrp; // group of the available installation types radio-buttons
362 QRadioButton* binBtn; // install binaries button
363 QRadioButton* srcBtn; // install sources button
364 QRadioButton* srcCompileBtn; // install sources and compile button
365 QCheckBox* removeSrcBtn; // <Remove sources & tmp files> checkbox
366 // --> installation platform page
367 QWidget* platformsPage; // page itself
368 QButtonGroup* platBtnGrp; // group of platforms for selection
369 QString warnMsg; // warning message
370 QLabel* warnLab; // warning label
371 // --> installation directories page
372 QWidget* dirPage; // page itself
373 QLineEdit* targetFolder; // target directory for installing of products
374 QPushButton* targetBtn; // browse target directory button
375 QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
376 QPushButton* tempBtn; // browse temp directory button
378 QWidget* productsPage; // page itself
379 ProductsView* modulesView; // modules list view
380 QMyCheckBox* installGuiBtn; // <Installation with GUI> checkbox
381 ProductsView* prereqsView; // prerequisites list view
382 QPushButton* moreBtn; // <More...> button
383 QTextBrowser* productInfo; // products info box
384 QLabel* requiredSize; // <Total disk space required> label
385 QLabel* requiredTemp; // <Space required for temporary files> label
386 QLabel* availableSize; // <Available disk space> label
388 QWidget* prestartPage; // page itself
389 QTextEdit* choices; // choice text view
391 QWidget* progressPage; // page itself
392 QSplitter* splitter; // splitter window
393 InstallInfo* installInfo; // information about running installation scripts
394 QLabel* parametersLab; // answer field's label
395 QLineEdit* passedParams; // user can pass data to running script
396 QTextEdit* installProgress;// contains information about progress of installing selected products
397 ProgressView* progressView; // displays information about progress of installing selected products
398 QLabel* statusLab; // displays currently performed action
400 QWidget* readmePage; // page itself
401 QTextEdit* readme; // Readme information window
402 ButtonList buttons; // operation buttons
404 ProcessThread* myThread; // validation thread
405 bool hasErrors; // flag: if there were any errors or warnings during the installation