Salome HOME
37800cdc8b7f6d7a2155ee45cd70ebd844b7728d
[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 ProcessThread;
101 class ProductsView;
102 class ProgressView;
103 class HelpWindow;
104 class InstallInfo;
105
106 typedef QMap<QCheckListItem*, Dependancies> MapProducts;
107
108 /*!
109   Class SALOME_InstallWizard : Installation Wizard's main window
110 */
111 class SALOME_InstallWizard: public InstallWizard
112 {
113   Q_OBJECT
114     
115  public:
116   // constructor
117   SALOME_InstallWizard(QString aXmlFileName);
118   // destructor
119   virtual ~SALOME_InstallWizard( );
120
121   // event filter
122   bool eventFilter( QObject* object, QEvent* event );
123
124   // set dependancies
125   void setDependancies( QCheckListItem* item, Dependancies dep);
126
127   // process validation event (<val> is validation code)
128   void processValidateEvent( const int val, void* data );
129
130  public slots:
131   // polishing of the widget
132   void polish();
133   
134   // set version
135   void setVersion( const QString& version ) { myVersion = version; }
136   // set caption
137   void setCaption( const QString& caption ) { myCaption = caption; updateCaption(); }
138   // set copyright
139   void setCopyright( const QString& copyright ) { myCopyright = copyright; }
140   // set license
141   void setLicense( const QString& license ) { myLicense = license; }
142   // set OS
143   void setOS( const QString& OS ) { myOS = OS; }
144
145   // get version
146   QString getVersion() { return myVersion; }
147   // get caption
148   QString getCaption() { return myCaption; }
149   // get copyright
150   QString getCopyright() { return myCopyright; }
151   // get license
152   QString getLicense() { return myLicense; }
153   // get OS
154   QString getOS() { return myOS; }
155   // get InstallWizard's name
156   QString getIWName() { return myIWName; }
157   
158   // save install log to file
159   void saveLog();
160
161  protected:
162   // updates caption according to the current page number
163   void updateCaption();
164   // close event handler
165   void closeEvent( QCloseEvent* ce );
166   // creates introduction page
167   void setupIntroPage();   
168   // creates products page
169   void setupProductsPage();
170   // creates directories page
171   void setupDirPage();
172   // creates prestart page
173   void setupCheckPage();
174   // creates progress page
175   void setupProgressPage();
176   // creates readme page
177   void setupReadmePage();
178   // displays choice info
179   void showChoiceInfo();
180   // validates page when <Next> button is clicked
181   bool acceptData( const QString& ); 
182   // calculates disk space required for the installation, returns true if any product selected to be installed (src, bin or native)
183   bool checkSize( long* totSize = 0, long* tempSize = 0 );
184   // checks products page validity (directories and products selection)
185   void checkProductPage();
186   // sets the product and all products this one depends on to be checked ( recursively )
187   void setPrerequisites( QCheckListItem* item );
188   // runs installation script
189   void launchScript(); 
190   // searches product listview item with given symbolic name 
191   QCheckListItem* findItem( const QString& sName );
192   // sets progress state to Aborted
193   void abort();
194   // clears and (optionally) removes temporary directory
195   void clean(bool rmDir = false);
196
197  protected slots:
198   // reject slot
199   void reject();
200   // accept slot
201   void accept();
202   
203  private slots:
204   // called when user moves from page to page
205   void pageChanged( const QString & mytitle);
206   // invokes Help window
207   void helpClicked();
208   // invokes directory selection dialog box
209   void browseDirectory();
210   // called when directory path (target or temp) is changed
211   void directoryChanged( const QString& text );
212   // <Start> button's slot - runs installation
213   void onStart();
214   // called when users tries to pass parameters for the script
215   void onReturnPressed();
216   // callback function - as response for the script finishing
217   void productInstalled();
218   // called when <Cancel> button is clicked during installation script running
219   void tryTerminate();
220   // kills installation process and quits application
221   void onCancel();
222   // called when selection is changed in the products list view
223   void onSelectionChanged();
224   // called when user checks/unchecks any product item
225   void onItemToggled( QCheckListItem* );
226   // <SALOME sources>, <SALOME binaries>, <Unselect All> buttons slot
227   void onProdBtn();
228   // <More...> button slot
229   void onMoreBtn();
230   // <Launch Salome> button slot
231   void onLaunchSalome();
232
233   // QProcess slots:
234   // -->something was written to stdin
235   void wroteToStdin();
236   // -->something was written to stout
237   void readFromStdout();
238   // -->something was written to stderr
239   void readFromStderr();
240
241  private:
242   QString          myIWName;       // Installation Wizard's name
243   QString          myVersion;      // version info
244   QString          myCaption;      // application name
245   QString          myCopyright;    // copyright info 
246   QString          myLicense;      // license info
247   QString          myOS;           // operation system
248   
249   HelpWindow*      helpWindow;     // help window
250   QProcess*        shellProcess;   // shell process (install script)
251   MapProducts      productsMap;    // products info (name, dependancies, disk space )
252   QStringList      toInstall;      // list of products being installed
253   QString          xmlFileName;    // xml file
254   bool             moreMode;       // advanced mode flag
255   QWidget*         previousPage;   // previous page
256   QString          tmpCreated;     // created temporary directory
257   bool             exitConfirmed;  // flag: "Exit confirmed"
258   // Widgets
259   // --> introduction page
260   QWidget*         introPage;      // page itself
261   QLabel*          logoLab;        // logo pixmap
262   QLabel*          versionLab;     // vesrsion info
263   QLabel*          copyrightLab;   // copyright info
264   QLabel*          licenseLab;     // license info
265   QLabel*          info;           // program info
266   // --> products page
267   QWidget*         productsPage;   // page itself
268   QLineEdit*       targetFolder;   // target directory for installing of products
269   QPushButton*     targetBtn;      // browse target directory button
270   QLineEdit*       tempFolder;     // directory for the temporary files: /tmp by default
271   QPushButton*     tempBtn;        // browse temp directory button
272   QLabel*          requiredSize;   // <Total disk space required> label
273   QLabel*          requiredTemp;   // <Space required for temporary files> label
274   QPushButton*     moreBtn;        // <More...> button
275   QWidget*         moreBox;        // container for the <More...> mode widgets
276   ProductsView*    productsView;   // products list view
277   QTextBrowser*    productsInfo;   // products info box
278   QCheckBox*       prerequisites;  // <Auto check prerequisites products> checkbox
279   QMyCheckBox*     selectSrcBtn;   // <SALOME sources> check box 
280   QMyCheckBox*     selectBinBtn;   // <SALOME binaries> check box 
281   QPushButton*     unselectBtn;    // <Unselect All> button
282   // --> prestart page
283   QWidget*         prestartPage;   // page itself
284   QTextEdit*       choices;        // choice text view
285   // --> progress page
286   QWidget*         progressPage;   // page itself
287   QSplitter*       splitter;       // splitter window
288   InstallInfo*     installInfo;    // information about running installation scripts
289   QLabel*          parametersLab;  // answer field's label
290   QLineEdit*       passedParams;   // user can pass data to running script
291   QTextEdit*       installProgress;// contains information about progress of installing selected products
292   ProgressView*    progressView;   // displays information about progress of installing selected products
293   // --> readme page
294   QWidget*         readmePage;     // page itself
295   QTextEdit*       readme;         // Readme information window
296   QPushButton*     runSalomeBtn;   // <Launch Salome> buttnon
297
298   ProcessThread*   myThread;       // validation thread
299 };
300
301 #endif