Salome HOME
PAL10853
[tools/install.git] / src / SALOME_InstallWizard.hxx
1 //  File      : SALOME_InstallWizard.hxx
2 //  Created   : Thu Dec 18 12:01:00 2002
3 //  Author    : Vadim SANDLER
4 //  Project   : SALOME
5 //  Module    : Installation Wizard
6 //  Copyright : 2004-2005 CEA
7
8 #ifndef __SALOME_InstallWizard
9 #define __SALOME_InstallWizard
10
11 #include "InstallWizard.h"
12
13 #include <qmap.h>
14 #include <qstringlist.h> 
15
16 /*! 
17   Class Dependancies : Products info
18   This class stores all product dependancies for correct work of installation procedure
19      smbName   - parameter for launching install shell script (e.g. cas for CASCADE4.0).
20      dependsOn - list of products needed for correct installation of product
21                  (e.g tcl is checked during installation of CASCADE 4).
22      sizeTotal - amount of disk space in Kbytes required for installation 
23                  of this product
24      sizeTemp  - amount of disk space in Kbytes required for the temporary files
25 */
26 class Dependancies
27 {
28  public:
29   // default constructor, necessary for map
30   Dependancies() {}
31   // constructor
32   Dependancies( const QString&     name, 
33                 const QStringList& depend, 
34                 const long         Binsize,  
35                 const long         Sourcessize, 
36                 const long         tempsize, 
37                 const QString&     def = QString::null,
38                 const QString&     descr = QString::null,
39                 const QString&     ctx = QString::null,
40                 bool               pickup = false )
41     : smbName( name ), 
42       dependsOn( depend ), 
43       sizeSourcesTotal( Sourcessize ), 
44       sizeBinaryTotal( Binsize ), 
45       sizeTemp( tempsize ),
46       defaultMode( def ),
47       description( descr ),
48       context( ctx ),
49       pickupEnv( pickup ) {}
50
51   // gets symbolic name
52   QString     getName() const         { return smbName;   }
53   // gets dependancies
54   QStringList getDependancies() const { return dependsOn; }
55   // gets disk space required
56   long        getSize(bool sources = false) const 
57   { 
58     return ( sources ? sizeSourcesTotal : sizeBinaryTotal ); 
59   }
60   // gets temporary disk space required
61   long        getTempSize() const     { return sizeTemp;   }
62   // gets product's description
63   QString     getDescription() const  { return description; }
64   // gets product's context
65   QString     getContext() const      { return context; }
66   // returns true if product supports given context
67   bool        hasContext( const QString& ctx ) const
68   {
69     QStringList cl = QStringList::split(",",context);
70     return cl.find( ctx ) != cl.end();
71   }
72   // gets default mode
73   QString     getDefault() const      { return defaultMode; }
74   // returns true if this product needs to pick-up environment
75   bool        pickUpEnvironment()     { return pickupEnv; }
76
77  private:
78   QString     smbName;          // symbolic name
79   QStringList dependsOn;        // prerequisites list
80   long        sizeSourcesTotal; // disk space required
81   long        sizeBinaryTotal;  // disk space required
82   long        sizeTemp;         // disk space for temporary files required
83   QString     defaultMode;      // default installation mode
84   QString     description;      // product's description
85   QString     context;          // product's context (salome sources, binaries or prerequisite)
86   bool        pickupEnv;        // "Pick-up environment" flag
87 };
88
89 class QLineEdit;
90 class QPushButton;
91 class QListViewItem;
92 class QCheckListItem;
93 class QLabel;
94 class QTextEdit;
95 class QTextBrowser;
96 class QProcess;
97 class QCheckBox;
98 class QSplitter;
99 class QMyCheckBox;
100 class QProcessThread;
101 class ProductsView;
102 class ProgressView;
103 class HelpWindow;
104
105 typedef QMap<QCheckListItem*, Dependancies> MapProducts;
106
107 /*!
108   Class SALOME_InstallWizard : Installation Wizard's main window
109 */
110 class SALOME_InstallWizard: public InstallWizard
111 {
112   Q_OBJECT
113     
114  public:
115   // constructor
116   SALOME_InstallWizard(QString aXmlFileName);
117   // destructor
118   virtual ~SALOME_InstallWizard( );
119
120   // event filter
121   bool eventFilter( QObject* object, QEvent* event );
122
123   // set dependancies
124   void setDependancies( QCheckListItem* item, Dependancies dep);
125
126   // process validation event (<val> is validation code)
127   void processValidateEvent( const int val, void* data );
128
129  public slots:
130   // polishing of the widget
131   void polish();
132   
133   // set version
134   void setVersion( const QString& version ) { myVersion = version; }
135   // set caption
136   void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
137   // set copyright
138   void setCopyright( const QString& copyright ) { myCopyright = copyright; }
139   // set license
140   void setLicense( const QString& license ) { myLicense = license; }
141   // set OS
142   void setOS( const QString& OS ) { myOS = OS; }
143
144   // get version
145   QString getVersion() { return myVersion; }
146   // get caption
147   QString getCaption() { return myCaption; }
148   // get copyright
149   QString getCopyright() { return myCopyright; }
150   // get license
151   QString getLicense() { return myLicense; }
152   // get OS
153   QString getOS() { return myOS; }
154   // get InstallWizard's name
155   QString getIWName() { return myIWName; }
156
157  protected:
158   // updates caption according to the current page number
159   void updateCaption();
160   // close event handler
161   void closeEvent( QCloseEvent* ce );
162   // creates introduction page
163   void setupIntroPage();   
164   // creates products page
165   void setupProductsPage();
166   // creates directories page
167   void setupDirPage();
168   // creates prestart page
169   void setupCheckPage();
170   // creates progress page
171   void setupProgressPage();
172   // creates readme page
173   void setupReadmePage();
174   // displays choice info
175   void showChoiceInfo();
176   // validates page when <Next> button is clicked
177   bool acceptData( const QString& ); 
178   // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
179   bool checkSize( long* totSize = 0, long* tempSize = 0 );
180   // checks products page validity (directories and products selection)
181   void checkProductPage();
182   // sets the product and all products this one depends on to be checked ( recursively )
183   void setPrerequisites( QCheckListItem* item );
184   // runs installation script
185   void launchScript(); 
186   // searches product listview item with given symbolic name 
187   QCheckListItem* findItem( const QString& sName );
188   // sets progress state to Aborted
189   void abort();
190   // clears and (optionally) removes temporary directory
191   void clean(bool rmDir = false);
192
193  protected slots:
194   // reject slot
195   void reject();
196   // accept slot
197   void accept();
198   
199  private slots:
200   // called when user moves from page to page
201   void pageChanged( const QString & mytitle);
202   // invokes Help window
203   void helpClicked();
204   // invokes directory selection dialog box
205   void browseDirectory();
206   // called when directory path (target or temp) is changed
207   void directoryChanged( const QString& text );
208   // <Start> button's slot - runs installation
209   void onStart();
210   // called when users tries to pass parameters for the script
211   void onReturnPressed();
212   // callback function - as response for the script finishing
213   void productInstalled();
214   // called when <Cancel> button is clicked during installation script running
215   void tryTerminate();
216   // kills installation process and quits application
217   void onCancel();
218   // called when selection is changed in the products list view
219   void onSelectionChanged();
220   // called when user checks/unchecks any product item
221   void onItemToggled( QCheckListItem* );
222   // <SALOME sources>, <SALOME binaries>, <Unselect All> buttons slot
223   void onProdBtn();
224   // <More...> button slot
225   void onMoreBtn();
226   // <Launch Salome> button slot
227   void onLaunchSalome();
228
229   // QProcess slots:
230   // -->something was written to stdin
231   void wroteToStdin();
232   // -->something was written to stout
233   void readFromStdout();
234   // -->something was written to stderr
235   void readFromStderr();
236
237  private:
238   QString       myIWName;       // Installation Wizard's name
239   QString       myVersion;      // version info
240   QString       myCaption;      // application name
241   QString       myCopyright;    // copyright info 
242   QString       myLicense;      // license info
243   QString       myOS;           // operation system
244   
245   HelpWindow*   helpWindow;     // help window
246   QProcess*     shellProcess;   // shell process (install script)
247   MapProducts   productsMap;    // products info (name, dependancies, disk space )
248   QStringList   toInstall;      // list of products being installed
249   QString       xmlFileName;    // xml file
250   bool          moreMode;       // advanced mode flag
251   QWidget*      previousPage;   // previous page
252   QString       tmpCreated;     // created temporary directory
253   bool          exitConfirmed;  // flag: "Exit confirmed"
254   // Widgets
255   // --> introduction page
256   QWidget*      introPage;      // page itself
257   QLabel*       logoLab;        // logo pixmap
258   QLabel*       versionLab;     // vesrsion info
259   QLabel*       copyrightLab;   // copyright info
260   QLabel*       licenseLab;     // license info
261   QLabel*       info;           // program info
262   // --> products page
263   QWidget*      productsPage;   // page itself
264   QLineEdit*    targetFolder;   // target directory for installing of products
265   QPushButton*  targetBtn;      // browse target directory button
266   QLineEdit*    tempFolder;     // directory for the temporary files: /tmp by default
267   QPushButton*  tempBtn;        // browse temp directory button
268   QLabel*       requiredSize;   // <Total disk space required> label
269   QLabel*       requiredTemp;   // <Space required for temporary files> label
270   QPushButton*  moreBtn;        // <More...> button
271   QWidget*      moreBox;        // container for the <More...> mode widgets
272   ProductsView* productsView;   // products list view
273   QTextBrowser* productsInfo;   // products info box
274   QCheckBox*    prerequisites;  // <Auto check prerequisites products> checkbox
275   QMyCheckBox*  selectSrcBtn;   // <SALOME sources> check box 
276   QMyCheckBox*  selectBinBtn;   // <SALOME binaries> check box 
277   QPushButton*  unselectBtn;    // <Unselect All> button
278   // --> prestart page
279   QWidget*      prestartPage;   // page itself
280   QTextEdit*    choices;        // choice text view
281   // --> progress page
282   QWidget*      progressPage;   // page itself
283   QSplitter*    splitter;       // splitter window
284   QTextEdit*    installInfo;    // information about running installation scripts
285   QLabel*       parametersLab;  // answer field's label
286   QLineEdit*    passedParams;   // user can pass data to running script
287   QTextEdit*    installProgress;// contains information about progress of installing selected products
288   ProgressView* progressView;   // displays information about progress of installing selected products
289   // --> readme page
290   QWidget*      readmePage;     // page itself
291   QTextEdit*    readme;         // Readme information window
292   QPushButton*  runSalomeBtn;   // <Launch Salome> buttnon
293
294   QProcessThread* myThread;     // validation thread
295 };
296
297 #endif