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 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_UIMARKET_MARKETCLIENTASSISTANT_HPP__
41 #define __OPENFLUID_UIMARKET_MARKETCLIENTASSISTANT_HPP__
42 
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 OPENFLUID_API 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  mp_Name(nullptr), mp_URL(nullptr)
95  { }
96 
97  void appendItems()
98  {
99  clear();
100  append(mp_Name);
101  append(mp_URL);
102  }
103  };
104 
105  URLComboColumns m_URLColumns;
106 
107 
108  // Tabs
109  QTabWidget m_TypesTabs;
110 
111  // Pages and main box of tab
112  std::map<openfluid::market::PackageInfo::PackageType,QWidget*> mp_TabPage;
113  std::map<openfluid::market::PackageInfo::PackageType,QVBoxLayout*> mp_TabBox;
114 
115  // Box and ScrolledWindow for packages list
116  std::map<openfluid::market::PackageInfo::PackageType,QVBoxLayout*> mp_AvailTypesPacksBox;
117  std::map<openfluid::market::PackageInfo::PackageType,QScrollArea*> mp_AvailTypesPacksSWindow;
118 
119  // Buttons of tab
120  std::map<openfluid::market::PackageInfo::PackageType,QHBoxLayout*> mp_ActionButtonsBox;
121  std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_SelectAllButton;
122  std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_SelectNoneButton;
123  std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_CommonBuildConfigButton;
124 
125  // List of MarketPackWidget
126  std::map<openfluid::market::PackageInfo::PackageType,std::list<MarketPackWidget*> > mp_AvailPacksWidgets;
127 
128 
129  /**
130  @return Type of current tab
131  */
133 
134 
135  /**
136  @return MarketPackWidget of ID package
137  @param ID of package
138  */
139  MarketPackWidget* availablePackWidget(const openfluid::ware::WareID_t& ID) const;
140 
141  /**
142  @return true if ID package passed as parameter has datasets selected which need it
143  @param ID of dependence
144  @param Type Type of dependence
145  */
146  bool hasParentSelected(const openfluid::ware::WareID_t& ID,
148 
149  /**
150  @return choice of user to apply action of selected dataset to this dependencies
151  @param ID of package selected
152  @param Select action applied on the package
153  @param List of dependencies to select
154  */
155  bool getUserChoice(const openfluid::ware::WareID_t& ID, const bool Select,
156  const std::map<openfluid::market::PackageInfo::PackageType,std::list<MarketPackWidget*> >& PacksToSelect);
157 
158 
159  // ===== Licenses =====//
160  MarketWizardPage m_LicensesPage;
161  QVBoxLayout m_LicensesPageBox;
162 
163  QLabel m_LicensesLabel;
164 
165  // Adjustable container for packages treeview and license text view
166  QSplitter m_LicensesReviewPaned;
167 
168  QTreeWidget *mp_LicensesTreeView;
169 
170  QTextEdit *mp_LicensesTextView;
171 
172 
173  QScrollArea m_LicensesListSWindow;
174  QScrollArea m_LicensesReviewSWindow;
175 
176  QRadioButton m_LicensesAcceptRadio;
177  QRadioButton m_LicensesDoNotRadio;
178 
179 
180  // ===== Download and install =====//
181  MarketWizardPage m_InstallPage;
182 
183  QVBoxLayout m_InstallPageBox;
184 
185  QTableWidget *mp_InstallTable;
186 
187 
188  class InstallTableColumns
189  {
190  public:
191 
192  enum { ID, TYPE, FORMAT, STATUS};
193 
194  QTableWidgetItem* mp_ID;
195  QTableWidgetItem* mp_Type;
196  QTableWidgetItem* mp_Format;
197  QTableWidgetItem* mp_Status;
198 
199  InstallTableColumns() :
200  mp_ID(nullptr), mp_Type(nullptr), mp_Format(nullptr), mp_Status(nullptr)
201  {
202 
203  }
204 
205  void setFlags()
206  {
207  mp_ID->setFlags(mp_ID->flags() ^ Qt::ItemIsEditable);
208  mp_Type->setFlags(mp_Type->flags() ^ Qt::ItemIsEditable);
209  mp_Format->setFlags(mp_Format->flags() ^ Qt::ItemIsEditable);
210  mp_Status->setFlags(mp_Status->flags() ^ Qt::ItemIsEditable);
211  }
212  };
213 
214  InstallTableColumns m_InstallColumns;
215 
216 
217  QScrollArea m_InstallSWindow;
218 
219  QProgressBar m_InstallProgressBar;
220  QPushButton m_ViewLogButton;
221 
222 
223  void setupSelectionPage();
224  void setupLicensesPage();
225  void setupDownloadPage();
226 
227 
228  /**
229  * Removes tabs, destroys content and clear screen
230  */
231  void clearAvailPacksTreeview();
232 
233  /**
234  * Creates tabs and display all available packages in Market-place selected
235  */
236  void updateAvailPacksTreeview();
237 
238  /**
239  * Indicates that no marketplace reached and unselects repository
240  */
241  void displayMarketplaceError();
242 
243 
244  void initializeLicencesTreeView();
245 
246  void updateInstallTreeview();
247 
248  openfluid::market::MarketClient m_MarketClient;
249 
250  int m_InstallationTimeout;
251 
252 
253  private slots:
254 
255  void onApply();
256  void onCancel();
257  void onClose();
258  void onPrepare(int Id);
259 
260  void onURLComboChanged(int RowNumber);
261 
262  /**
263  * Selects all packages of current tab
264  */
265  void onSelectAllClicked();
266 
267  /**
268  * Unselects all packages of current tab
269  */
270  void onSelectNoneClicked();
271 
272  /**
273  * Edit common options of packages of the current tab
274  */
275  void onCommonBuildConfigClicked();
276 
277 
278  /**
279  Selects dependencies of ID package
280  @param ID of package selected
281  */
282  void selectDependencies(const openfluid::ware::WareID_t& ID);
283 
284 
285  void onPackageInstallModified();
286 
287 
288  void onLicenseRadioClicked(bool Checked);
289 
290 
291  void onLicensesTreeviewChanged(QTreeWidgetItem *CurrentItem);
292 
293 
294  void onInstallTimeoutOnce();
295 
296  void onViewLogClicked();
297 
298 
299  public:
300 
301  MarketClientAssistant(QWidget* Parent);
302 
303  virtual ~MarketClientAssistant();
304 
305  /**
306  @return string name of type passed as parameter
307  @param Type Type of package
308  @param Maj First letter in maj
309  @param Plural Return plural name
310  */
311  static QString getGraphicTypeName(const openfluid::market::PackageInfo::PackageType& Type,
312  const bool Maj, const bool Plural);
313 };
314 
315 } } } // namespaces
316 
317 
318 #endif /* __OPENFLUID_UIMARKET_MARKETCLIENTASSISTANT_HPP__ */
Definition: MarketClient.hpp:69
std::string WareID_t
Definition: TypeDefs.hpp:49
Definition: MarketWizardPage.hpp:51
Definition: MarketPackWidget.hpp:56
PackageType
Definition: MarketInfos.hpp:91
Definition: ApplicationException.hpp:47
Definition: MarketClientAssistant.hpp:69
#define OPENFLUID_API
Definition: dllexport.hpp:86