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-2006 CEA
8 #ifndef __SALOME_InstallWizard
9 #define __SALOME_InstallWizard
11 #include "InstallWizard.h"
14 #include <qvaluelist.h>
15 #include <qstringlist.h>
36 Class Dependancies : Products info
37 This class stores all product dependancies for correct work of installation procedure
42 // default constructor, necessary for map
45 Dependancies( const QString& name,
46 const QStringList& depend,
48 const long Sourcessize,
50 const QString& def = QString::null,
51 const QString& descr = QString::null,
52 const QString& ctx = QString::null,
56 sizeSourcesTotal( Sourcessize ),
57 sizeBinaryTotal( Binsize ),
62 pickupEnv( pickup ) {}
65 QString getName() const { return smbName; }
67 QStringList getDependancies() const { return dependsOn; }
68 // gets disk space required
69 long getSize(bool sources = false) const
71 return ( sources ? sizeSourcesTotal : sizeBinaryTotal );
73 // gets temporary disk space required
74 long getTempSize() const { return sizeTemp; }
75 // gets product's description
76 QString getDescription() const { return description; }
77 // gets product's context
78 QString getContext() const { return context; }
79 // returns true if product supports given context
80 bool hasContext( const QString& ctx ) const
82 QStringList cl = QStringList::split(",",context);
83 return cl.find( ctx ) != cl.end();
86 QString getDefault() const { return defaultMode; }
87 // returns true if this product needs to pick-up environment
88 bool pickUpEnvironment() { return pickupEnv; }
91 QString smbName; // symbolic name
92 QStringList dependsOn; // prerequisites list
93 long sizeSourcesTotal; // disk space required
94 long sizeBinaryTotal; // disk space required
95 long sizeTemp; // disk space for temporary files required
96 QString defaultMode; // default installation mode
97 QString description; // product's description
98 QString context; // product's context (salome sources, binaries or prerequisite)
99 bool pickupEnv; // "Pick-up environment" flag
103 Class Button : Operation button info
104 This class stores information about the custom operation buttons which appear on
105 the <Finish> page of the Install Wizard.
110 // default constructor, required for list
111 Button() : myButton( 0 ) {}
113 Button( const QString& label, const QString& tooltip, const QString& script )
114 : myLabel( label ), myTootip( tooltip ), myScript( script ), myButton( 0 ) {}
116 // set operation button
117 void setButton( QButton* btn ) { myButton = btn; }
120 QString label() const { return myLabel; }
122 QString tootip() const { return myTootip; }
124 QString script() const { return myScript; }
125 // get operation button
126 QButton* button() const { return myButton; }
129 QString myLabel; // button label
130 QString myTootip; // button tooltip
131 QString myScript; // operation script
132 QButton* myButton; // operation button
135 typedef QMap<QCheckListItem*, Dependancies> MapProducts;
136 typedef QValueList<Button> ButtonList;
139 Class SALOME_InstallWizard : Installation Wizard's main window
141 class SALOME_InstallWizard: public InstallWizard
147 SALOME_InstallWizard(const QString& aXmlFileName,
148 const QString& aTargetDir = QString::null,
149 const QString& aTmpDir = QString::null,
150 const bool aForceSrc = false);
152 virtual ~SALOME_InstallWizard( );
155 bool eventFilter( QObject* object, QEvent* event );
158 void setDependancies( QCheckListItem* item, Dependancies dep);
160 // add button for the <Finish> page
161 void addFinishButton( const QString& label,
162 const QString& tooltip,
163 const QString& script);
166 void setVersion( const QString& version ) { myVersion = version; }
168 void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
170 void setCopyright( const QString& copyright ) { myCopyright = copyright; }
172 void setLicense( const QString& license ) { myLicense = license; }
174 void setOS( const QString& OS ) { myOS = OS; }
177 QString getVersion() { return myVersion; }
179 QString getCaption() { return myCaption; }
181 QString getCopyright() { return myCopyright; }
183 QString getLicense() { return myLicense; }
185 QString getOS() { return myOS; }
186 // get InstallWizard's name
187 QString getIWName() { return myIWName; }
189 // process validation event (<val> is validation code)
190 void processValidateEvent( const int val, void* data );
193 // polishing of the widget
196 // save install log to file
200 // updates caption according to the current page number
201 void updateCaption();
202 // close event handler
203 void closeEvent( QCloseEvent* ce );
204 // creates introduction page
205 void setupIntroPage();
206 // creates products page
207 void setupProductsPage(const bool forceSrc = false);
208 // creates directories page
210 // creates prestart page
211 void setupCheckPage();
212 // creates progress page
213 void setupProgressPage();
214 // creates readme page
215 void setupReadmePage();
216 // displays choice info
217 void showChoiceInfo();
218 // validates page when <Next> button is clicked
219 bool acceptData( const QString& );
220 // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
221 bool checkSize( long* totSize = 0, long* tempSize = 0 );
222 // checks products page validity (directories and products selection)
223 void checkProductPage();
224 // sets the product and all products this one depends on to be checked ( recursively )
225 void setPrerequisites( QCheckListItem* item );
226 // runs installation script
228 // searches product listview item with given symbolic name
229 QCheckListItem* findItem( const QString& sName );
230 // sets progress state to Aborted
232 // clears and (optionally) removes temporary directory
233 void clean(bool rmDir = false);
242 // called when user moves from page to page
243 void pageChanged( const QString & mytitle);
244 // invokes Help window
246 // invokes directory selection dialog box
247 void browseDirectory();
248 // called when directory path (target or temp) is changed
249 void directoryChanged( const QString& text );
250 // <Start> button's slot - runs installation
252 // called when users tries to pass parameters for the script
253 void onReturnPressed();
254 // callback function - as response for the script finishing
255 void productInstalled();
256 // called when <Cancel> button is clicked during installation script running
258 // kills installation process and quits application
260 // called when selection is changed in the products list view
261 void onSelectionChanged();
262 // called when user checks/unchecks any product item
263 void onItemToggled( QCheckListItem* );
264 // <SALOME sources>, <SALOME binaries>, <Unselect All> buttons slot
266 // <More...> button slot
268 // <Install all products from sources> check box
271 // <Finish> page buttons slot
272 void onFinishButton();
274 // reset to default state
275 void resetToDefaultState();
277 // <About> button slot
281 // -->something was written to stdin
283 // -->something was written to stout
284 void readFromStdout();
285 // -->something was written to stderr
286 void readFromStderr();
289 QString myIWName; // Installation Wizard's name
290 QString myVersion; // version info
291 QString myCaption; // application name
292 QString myCopyright; // copyright info
293 QString myLicense; // license info
294 QString myOS; // operation system
296 HelpWindow* helpWindow; // help window
297 QProcess* shellProcess; // shell process (install script)
298 MapProducts productsMap; // products info (name, dependancies, disk space )
299 QStringList toInstall; // list of products being installed
300 QString xmlFileName; // xml file
301 QString targetDirPath; // target directory
302 QString tmpDirPath; // temporary directory
303 bool moreMode; // advanced mode flag
304 QWidget* previousPage; // previous page
305 QString tmpCreated; // created temporary directory
306 bool exitConfirmed; // flag: "Exit confirmed"
308 // --> introduction page
309 QWidget* introPage; // page itself
310 QLabel* logoLab; // logo pixmap
311 QLabel* versionLab; // vesrsion info
312 QLabel* copyrightLab; // copyright info
313 QLabel* licenseLab; // license info
314 QLabel* info; // program info
316 QWidget* productsPage; // page itself
317 QLineEdit* targetFolder; // target directory for installing of products
318 QPushButton* targetBtn; // browse target directory button
319 QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
320 QPushButton* tempBtn; // browse temp directory button
321 QLabel* requiredSize; // <Total disk space required> label
322 QLabel* requiredTemp; // <Space required for temporary files> label
323 QPushButton* moreBtn; // <More...> button
324 QWidget* moreBox; // container for the <More...> mode widgets
325 ProductsView* productsView; // products list view
326 QTextBrowser* productsInfo; // products info box
327 QCheckBox* prerequisites; // <Auto check prerequisites products> checkbox
328 QMyCheckBox* selectSrcBtn; // <SALOME sources> check box
329 QMyCheckBox* buildSrcBtn; // <Build SALOME sources> check box
330 QMyCheckBox* selectBinBtn; // <SALOME binaries> check box
331 QPushButton* unselectBtn; // <Unselect All> button
332 QWidget* lessBox; // container for the <Less...> mode widgets
333 QMyCheckBox* allFromSrcBtn; // <Install all products from sources> check box
335 QWidget* prestartPage; // page itself
336 QTextEdit* choices; // choice text view
338 QWidget* progressPage; // page itself
339 QSplitter* splitter; // splitter window
340 InstallInfo* installInfo; // information about running installation scripts
341 QLabel* parametersLab; // answer field's label
342 QLineEdit* passedParams; // user can pass data to running script
343 QTextEdit* installProgress;// contains information about progress of installing selected products
344 ProgressView* progressView; // displays information about progress of installing selected products
346 QWidget* readmePage; // page itself
347 QTextEdit* readme; // Readme information window
348 ButtonList buttons; // operation buttons
350 ProcessThread* myThread; // validation thread