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