All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MarketClientAssistant.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  \file MarketClientAssistant.hpp
35  \brief Header of ...
36 
37  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38  */
39 
40 
41 #ifndef __MARKETCLIENTASSISTANT_HPP__
42 #define __MARKETCLIENTASSISTANT_HPP__
43 
44 #include <QWizard>
45 #include <QBoxLayout>
46 #include <QLabel>
47 #include <QComboBox>
48 #include <QTabWidget>
49 #include <QPushButton>
50 #include <QScrollArea>
51 #include <QTreeWidget>
52 #include <QRadioButton>
53 #include <QTextEdit>
54 #include <QTableWidget>
55 #include <QProgressBar>
56 #include <QSplitter>
57 #include <QStandardItemModel>
58 
59 #include <openfluid/dllexport.hpp>
62 
63 
64 namespace openfluid { namespace ui { namespace market {
65 
66 class MarketPackWidget;
67 
68 // TODO review parenting of all widgets
69 class DLLEXPORT MarketClientAssistant : public QWizard
70 {
71  Q_OBJECT
72 
73  private:
74 
75  // ===== Package selection =====//
76  MarketWizardPage m_SelectionPage;
77  QVBoxLayout m_SelectionPageBox;
78 
79  QHBoxLayout m_URLBox;
80  QLabel m_URLLabel;
81  QComboBox m_URLCombo;
82  QStandardItemModel m_RefURLComboBoxModel;
83 
84  class URLComboColumns : public QList<QStandardItem*>
85  {
86  public:
87 
88  enum { NAME, URL};
89 
90  QStandardItem *mp_Name;
91  QStandardItem *mp_URL;
92 
93  URLComboColumns() {}
94 
95  void appendItems() { clear(); append(mp_Name); append(mp_URL); }
96  };
97 
98  URLComboColumns m_URLColumns;
99 
100 
101  // Tabs
102  QTabWidget m_TypesTabs;
103 
104  // Pages and main box of tab
105  std::map<openfluid::market::PackageInfo::PackageType,QWidget*> mp_TabPage;
106  std::map<openfluid::market::PackageInfo::PackageType,QVBoxLayout*> mp_TabBox;
107 
108  // Box and ScrolledWindow for packages list
109  std::map<openfluid::market::PackageInfo::PackageType,QVBoxLayout*> mp_AvailTypesPacksBox;
110  std::map<openfluid::market::PackageInfo::PackageType,QScrollArea*> mp_AvailTypesPacksSWindow;
111 
112  // Buttons of tab
113  std::map<openfluid::market::PackageInfo::PackageType,QHBoxLayout*> mp_ActionButtonsBox;
114  std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_SelectAllButton;
115  std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_SelectNoneButton;
116  std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_CommonBuildConfigButton;
117 
118  // List of MarketPackWidget
119  std::map<openfluid::market::PackageInfo::PackageType,std::list<MarketPackWidget*> > mp_AvailPacksWidgets;
120 
121 
122  /**
123  @return Type of current tab
124  */
126 
127 
128  /**
129  @return MarketPackWidget of ID package
130  @param ID of package
131  */
132  MarketPackWidget* getAvailPackWidget(const openfluid::ware::WareID_t& ID) const;
133 
134  /**
135  @return true if ID package passed as parameter has datasets selected which need it
136  @param ID of dependence
137  @param Type Type of dependence
138  */
139  bool hasParentSelected(const openfluid::ware::WareID_t& ID,
141 
142  /**
143  @return choice of user to apply action of selected dataset to this dependencies
144  @param ID of package selected
145  @param Select action applied on the package
146  @param List of dependencies to select
147  */
148  bool getUserChoice(const openfluid::ware::WareID_t& ID, const bool Select,
149  const std::map<openfluid::market::PackageInfo::PackageType,std::list<MarketPackWidget*> >& PacksToSelect);
150 
151 
152  // ===== Licenses =====//
153  MarketWizardPage m_LicensesPage;
154  QVBoxLayout m_LicensesPageBox;
155 
156  QLabel m_LicensesLabel;
157 
158  // Adjustable container for packages treeview and license text view
159  QSplitter m_LicensesReviewPaned;
160 
161  QTreeWidget *mp_LicensesTreeView;
162 
163  QTextEdit *mp_LicensesTextView;
164 
165 
166  QScrollArea m_LicensesListSWindow;
167  QScrollArea m_LicensesReviewSWindow;
168 
169  QRadioButton m_LicensesAcceptRadio;
170  QRadioButton m_LicensesDoNotRadio;
171 
172 
173 
174 
175  // ===== Download and install =====//
176  MarketWizardPage m_InstallPage;
177 
178  QVBoxLayout m_InstallPageBox;
179 
180  QTableWidget *mp_InstallTable;
181 
182 
183  class InstallTableColumns
184  {
185  public:
186 
187  enum { ID, TYPE, FORMAT, STATUS};
188 
189  QTableWidgetItem *mp_ID;
190  QTableWidgetItem *mp_Type;
191  QTableWidgetItem *mp_Format;
192  QTableWidgetItem *mp_Status;
193 
194  InstallTableColumns() {}
195 
196  void setFlags()
197  {
198  mp_ID->setFlags(mp_ID->flags() ^ Qt::ItemIsEditable);
199  mp_Type->setFlags(mp_Type->flags() ^ Qt::ItemIsEditable);
200  mp_Format->setFlags(mp_Format->flags() ^ Qt::ItemIsEditable);
201  mp_Status->setFlags(mp_Status->flags() ^ Qt::ItemIsEditable);
202  }
203  };
204 
205  InstallTableColumns m_InstallColumns;
206 
207 
208  QScrollArea m_InstallSWindow;
209 
210  QProgressBar m_InstallProgressBar;
211  QPushButton m_ViewLogButton;
212 
213 
214  void setupSelectionPage();
215  void setupLicensesPage();
216  void setupDownloadPage();
217 
218 
219  /**
220  * Removes tabs, destroys content and clear screen
221  */
222  void clearAvailPacksTreeview();
223 
224  /**
225  * Creates tabs and display all available packages in Market-place selected
226  */
227  void updateAvailPacksTreeview();
228 
229  /**
230  * Indicates that no marketplace reached and unselects repository
231  */
232  void displayMarketplaceError();
233 
234 
235  void initializeLicencesTreeView();
236 
237  void updateInstallTreeview();
238 
239  openfluid::market::MarketClient m_MarketClient;
240 
241  int m_InstallationTimeout;
242 
243 
244  private slots:
245 
246  void onApply();
247  void onCancel();
248  void onClose();
249  void onPrepare(int Id);
250 
251  void onURLComboChanged(int RowNumber);
252 
253  /**
254  * Selects all packages of current tab
255  */
256  void onSelectAllClicked();
257 
258  /**
259  * Unselects all packages of current tab
260  */
261  void onSelectNoneClicked();
262 
263  /**
264  * Edit common options of packages of the current tab
265  */
266  void onCommonBuildConfigClicked();
267 
268 
269  /**
270  Selects dependencies of ID package
271  @param ID of package selected
272  */
273  void selectDependencies(const openfluid::ware::WareID_t& ID);
274 
275 
276  void onPackageInstallModified();
277 
278 
279  void onLicenseRadioClicked(bool Checked);
280 
281 
282  void onLicensesTreeviewChanged(QTreeWidgetItem *CurrentItem);
283 
284 
285  void onInstallTimeoutOnce();
286 
287  void onViewLogClicked();
288 
289 
290  public:
291 
292  MarketClientAssistant(QWidget* Parent);
293 
294  virtual ~MarketClientAssistant();
295 
296  /**
297  @return string name of type passed as parameter
298  @param Type Type of package
299  @param Maj First letter in maj
300  @param Plural Return plural name
301  */
302  static QString getGraphicTypeName(const openfluid::market::PackageInfo::PackageType& Type, const bool Maj, const bool Plural);
303 };
304 
305 } } } // namespaces
306 
307 
308 #endif /* __MARKETCLIENTASSISTANT_HPP__ */
Definition: MarketWizardPage.hpp:50
PackageType
Definition: MarketInfos.hpp:94
Definition: MarketClient.hpp:68
Definition: MarketPackWidget.hpp:59
std::string WareID_t
Definition: WareSignature.hpp:86
Definition: MarketClientAssistant.hpp:69
#define DLLEXPORT
Definition: dllexport.hpp:51