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