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