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);
276 // called when user moves from page to page
277 void pageChanged( const QString & mytitle);
278 // called when user selected either installation type or installation platform
279 void onButtonGroup( int index );
280 // invokes Help window
282 // invokes directory selection dialog box
283 void browseDirectory();
284 // called when directory path (target or temp) is changed
285 void directoryChanged( const QString& text );
286 // <Start> button's slot - runs installation
288 // called when users tries to pass parameters for the script
289 void onReturnPressed();
290 // callback function - as response for the script finishing
291 void productInstalled();
292 // called when <Cancel> button is clicked during installation script running
294 // kills installation process and quits application
296 // called when selection is changed in the products list view
297 void onSelectionChanged();
298 // called when user checks/unchecks any product item
299 void onItemToggled( QCheckListItem* );
300 // <Installation with GUI> check-box slot
301 void onInstallGuiBtn();
302 // <More...> button slot
304 // Slot to update 'Available disk space' field
305 void updateAvailableSpace();
307 // <Finish> page buttons slot
308 void onFinishButton();
310 // <About> button slot
314 // -->something was written to stdin
316 // -->something was written to stout
317 void readFromStdout();
318 // -->something was written to stderr
319 void readFromStderr();
322 QString myIWName; // Installation Wizard's name
323 QString myVersion; // version info
324 QString myCaption; // application name
325 QString myCopyright; // copyright info
326 QString myLicense; // license info
327 QString myTargetPath; // target directory path
328 QString myTmpPath; // temporary directory path
330 HelpWindow* helpWindow; // help window
331 QProcess* shellProcess; // shell process (install script)
332 QProcess* diskSpaceProc; // 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"
351 // --> introduction page
352 QWidget* introPage; // page itself
353 QLabel* logoLab; // logo pixmap
354 QLabel* versionLab; // version info
355 QLabel* copyrightLab; // copyright info
356 QLabel* licenseLab; // license info
357 QLabel* info; // program info
358 // --> installation types page
359 QWidget* typePage; // page itself
360 QButtonGroup* buttonGrp; // group of the available installation types radio-buttons
361 QRadioButton* binBtn; // install binaries button
362 QRadioButton* srcBtn; // install sources button
363 QRadioButton* srcCompileBtn; // install sources and compile button
364 QMyCheckBox* removeSrcBtn; // <Remove sources & tmp files> checkbox
365 // --> installation platform page
366 QWidget* platformsPage; // page itself
367 QButtonGroup* platBtnGrp; // group of platforms for selection
368 QString warnMsg; // warning message
369 QLabel* warnLab; // warning label
370 // --> installation directories page
371 QWidget* dirPage; // page itself
372 QLineEdit* targetFolder; // target directory for installing of products
373 QPushButton* targetBtn; // browse target directory button
374 QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
375 QPushButton* tempBtn; // browse temp directory button
377 QWidget* productsPage; // page itself
378 ProductsView* modulesView; // modules list view
379 QMyCheckBox* installGuiBtn; // <Installation with GUI> checkbox
380 ProductsView* prereqsView; // prerequisites list view
381 QPushButton* moreBtn; // <More...> button
382 QTextBrowser* productInfo; // products info box
383 QLabel* requiredSize; // <Total disk space required> label
384 QLabel* requiredTemp; // <Space required for temporary files> label
385 QLabel* availableSize; // <Available disk space> label
387 QWidget* prestartPage; // page itself
388 QTextEdit* choices; // choice text view
390 QWidget* progressPage; // page itself
391 QSplitter* splitter; // splitter window
392 InstallInfo* installInfo; // information about running installation scripts
393 QLabel* parametersLab; // answer field's label
394 QLineEdit* passedParams; // user can pass data to running script
395 QTextEdit* installProgress;// contains information about progress of installing selected products
396 ProgressView* progressView; // displays information about progress of installing selected products
397 QLabel* statusLab; // displays currently performed action
399 QWidget* readmePage; // page itself
400 QTextEdit* readme; // Readme information window
401 ButtonList buttons; // operation buttons
403 ProcessThread* myThread; // validation thread
404 bool hasErrors; // flag: if there were any errors or warnings during the installation