1 // File : SALOME_InstallWizard.hxx
2 // Created : Thu Dec 18 12:01:00 2002
3 // Author : Vadim SANDLER
5 // Module : Installation Wizard
6 // Copyright : 2004-2005 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);
151 virtual ~SALOME_InstallWizard( );
154 bool eventFilter( QObject* object, QEvent* event );
157 void setDependancies( QCheckListItem* item, Dependancies dep);
159 // add button for the <Finish> page
160 void addFinishButton( const QString& label,
161 const QString& tooltip,
162 const QString& script);
165 void setVersion( const QString& version ) { myVersion = version; }
167 void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
169 void setCopyright( const QString& copyright ) { myCopyright = copyright; }
171 void setLicense( const QString& license ) { myLicense = license; }
173 void setOS( const QString& OS ) { myOS = OS; }
176 QString getVersion() { return myVersion; }
178 QString getCaption() { return myCaption; }
180 QString getCopyright() { return myCopyright; }
182 QString getLicense() { return myLicense; }
184 QString getOS() { return myOS; }
185 // get InstallWizard's name
186 QString getIWName() { return myIWName; }
188 // process validation event (<val> is validation code)
189 void processValidateEvent( const int val, void* data );
192 // polishing of the widget
195 // save install log to file
199 // updates caption according to the current page number
200 void updateCaption();
201 // close event handler
202 void closeEvent( QCloseEvent* ce );
203 // creates introduction page
204 void setupIntroPage();
205 // creates products page
206 void setupProductsPage();
207 // creates directories page
209 // creates prestart page
210 void setupCheckPage();
211 // creates progress page
212 void setupProgressPage();
213 // creates readme page
214 void setupReadmePage();
215 // displays choice info
216 void showChoiceInfo();
217 // validates page when <Next> button is clicked
218 bool acceptData( const QString& );
219 // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
220 bool checkSize( long* totSize = 0, long* tempSize = 0 );
221 // checks products page validity (directories and products selection)
222 void checkProductPage();
223 // sets the product and all products this one depends on to be checked ( recursively )
224 void setPrerequisites( QCheckListItem* item );
225 // runs installation script
227 // searches product listview item with given symbolic name
228 QCheckListItem* findItem( const QString& sName );
229 // sets progress state to Aborted
231 // clears and (optionally) removes temporary directory
232 void clean(bool rmDir = false);
241 // called when user moves from page to page
242 void pageChanged( const QString & mytitle);
243 // invokes Help window
245 // invokes directory selection dialog box
246 void browseDirectory();
247 // called when directory path (target or temp) is changed
248 void directoryChanged( const QString& text );
249 // <Start> button's slot - runs installation
251 // called when users tries to pass parameters for the script
252 void onReturnPressed();
253 // callback function - as response for the script finishing
254 void productInstalled();
255 // called when <Cancel> button is clicked during installation script running
257 // kills installation process and quits application
259 // called when selection is changed in the products list view
260 void onSelectionChanged();
261 // called when user checks/unchecks any product item
262 void onItemToggled( QCheckListItem* );
263 // <SALOME sources>, <SALOME binaries>, <Unselect All> buttons slot
265 // <More...> button slot
268 // <Finish> page buttons slot
269 void onFinishButton();
271 // <About> button slot
275 // -->something was written to stdin
277 // -->something was written to stout
278 void readFromStdout();
279 // -->something was written to stderr
280 void readFromStderr();
283 QString myIWName; // Installation Wizard's name
284 QString myVersion; // version info
285 QString myCaption; // application name
286 QString myCopyright; // copyright info
287 QString myLicense; // license info
288 QString myOS; // operation system
290 HelpWindow* helpWindow; // help window
291 QProcess* shellProcess; // shell process (install script)
292 MapProducts productsMap; // products info (name, dependancies, disk space )
293 QStringList toInstall; // list of products being installed
294 QString xmlFileName; // xml file
295 QString targetDirPath; // target directory
296 QString tmpDirPath; // temporary directory
297 bool moreMode; // advanced mode flag
298 QWidget* previousPage; // previous page
299 QString tmpCreated; // created temporary directory
300 bool exitConfirmed; // flag: "Exit confirmed"
302 // --> introduction page
303 QWidget* introPage; // page itself
304 QLabel* logoLab; // logo pixmap
305 QLabel* versionLab; // vesrsion info
306 QLabel* copyrightLab; // copyright info
307 QLabel* licenseLab; // license info
308 QLabel* info; // program info
310 QWidget* productsPage; // page itself
311 QLineEdit* targetFolder; // target directory for installing of products
312 QPushButton* targetBtn; // browse target directory button
313 QLineEdit* tempFolder; // directory for the temporary files: /tmp by default
314 QPushButton* tempBtn; // browse temp directory button
315 QLabel* requiredSize; // <Total disk space required> label
316 QLabel* requiredTemp; // <Space required for temporary files> label
317 QPushButton* moreBtn; // <More...> button
318 QWidget* moreBox; // container for the <More...> mode widgets
319 ProductsView* productsView; // products list view
320 QTextBrowser* productsInfo; // products info box
321 QCheckBox* prerequisites; // <Auto check prerequisites products> checkbox
322 QMyCheckBox* selectSrcBtn; // <SALOME sources> check box
323 QMyCheckBox* selectBinBtn; // <SALOME binaries> check box
324 QPushButton* unselectBtn; // <Unselect All> button
326 QWidget* prestartPage; // page itself
327 QTextEdit* choices; // choice text view
329 QWidget* progressPage; // page itself
330 QSplitter* splitter; // splitter window
331 InstallInfo* installInfo; // information about running installation scripts
332 QLabel* parametersLab; // answer field's label
333 QLineEdit* passedParams; // user can pass data to running script
334 QTextEdit* installProgress;// contains information about progress of installing selected products
335 ProgressView* progressView; // displays information about progress of installing selected products
337 QWidget* readmePage; // page itself
338 QTextEdit* readme; // Readme information window
339 ButtonList buttons; // operation buttons
341 ProcessThread* myThread; // validation thread