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