guicommon/MarketClientAssistant.hpp
Go to the documentation of this file.
00001 /*
00002 
00003   This file is part of OpenFLUID software
00004   Copyright(c) 2007, INRA - Montpellier SupAgro
00005 
00006 
00007  == GNU General Public License Usage ==
00008 
00009   OpenFLUID is free software: you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation, either version 3 of the License, or
00012   (at your option) any later version.
00013 
00014   OpenFLUID is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
00021 
00022 
00023  == Other Usage ==
00024 
00025   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00026   license, and requires a written agreement between You and INRA.
00027   Licensees for Other Usage of OpenFLUID may use this file in accordance
00028   with the terms contained in the written agreement between You and INRA.
00029   
00030 */
00031 
00032 
00033 /**
00034   \file MarketClientAssistant.hpp
00035   \brief Header of ...
00036 
00037   \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
00038  */
00039 
00040 
00041 #ifndef __MARKETCLIENTASSISTANT_HPP__
00042 #define __MARKETCLIENTASSISTANT_HPP__
00043 
00044 #include <QWizard>
00045 #include <QBoxLayout>
00046 #include <QLabel>
00047 #include <QComboBox>
00048 #include <QTabWidget>
00049 #include <QPushButton>
00050 #include <QScrollArea>
00051 #include <QTreeWidget>
00052 #include <QRadioButton>
00053 #include <QTextEdit>
00054 #include <QTableWidget>
00055 #include <QProgressBar>
00056 #include <QSplitter>
00057 #include <QStandardItemModel>
00058 
00059 #include <openfluid/dllexport.hpp>
00060 #include <openfluid/market/MarketClient.hpp>
00061 #include <openfluid/guicommon/MarketWizardPage.hpp>
00062 
00063 
00064 namespace openfluid { namespace guicommon {
00065 
00066 class MarketPackWidget;
00067 
00068 // TODO review parenting of all widgets
00069 class DLLEXPORT MarketClientAssistant : public QWizard
00070 {
00071   Q_OBJECT
00072 
00073   private:
00074 
00075     // ===== Package selection =====//
00076     MarketWizardPage m_SelectionPage;
00077     QVBoxLayout m_SelectionPageBox;
00078 
00079     QHBoxLayout m_URLBox;
00080     QLabel m_URLLabel;
00081     QComboBox m_URLCombo;
00082     QStandardItemModel m_RefURLComboBoxModel;
00083 
00084     class URLComboColumns : public QList<QStandardItem*>
00085     {
00086       public:
00087 
00088         enum { NAME, URL};
00089 
00090         QStandardItem *mp_Name;
00091         QStandardItem *mp_URL;
00092 
00093         URLComboColumns() {}
00094 
00095         void appendItems() { clear(); append(mp_Name); append(mp_URL); }
00096     };
00097 
00098     URLComboColumns m_URLColumns;
00099 
00100 
00101     // Tabs
00102     QTabWidget m_TypesTabs;
00103 
00104     // Pages and main box of tab
00105     std::map<openfluid::market::PackageInfo::PackageType,QWidget*> mp_TabPage;
00106     std::map<openfluid::market::PackageInfo::PackageType,QVBoxLayout*> mp_TabBox;
00107 
00108     // Box and ScrolledWindow for packages list
00109     std::map<openfluid::market::PackageInfo::PackageType,QVBoxLayout*> mp_AvailTypesPacksBox;
00110     std::map<openfluid::market::PackageInfo::PackageType,QScrollArea*> mp_AvailTypesPacksSWindow;
00111 
00112     // Buttons of tab
00113     std::map<openfluid::market::PackageInfo::PackageType,QHBoxLayout*> mp_ActionButtonsBox;
00114     std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_SelectAllButton;
00115     std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_SelectNoneButton;
00116     std::map<openfluid::market::PackageInfo::PackageType,QPushButton*> mp_CommonBuildConfigButton;
00117 
00118     // List of MarketPackWidget
00119     std::map<openfluid::market::PackageInfo::PackageType,std::list<MarketPackWidget*> > mp_AvailPacksWidgets;
00120 
00121 
00122     /**
00123      @return Type of current tab
00124     */
00125     openfluid::market::PackageInfo::PackageType getCurrentTypeTab();
00126 
00127 
00128     /**
00129      @return MarketPackWidget of ID package
00130      @param ID of package
00131     */
00132     MarketPackWidget* getAvailPackWidget(const openfluid::ware::WareID_t& ID) const;
00133 
00134     /**
00135      @return true if ID package passed as parameter has datasets selected which need it
00136      @param ID of dependence
00137      @param Type Type of dependence
00138     */
00139     bool hasParentSelected(const openfluid::ware::WareID_t& ID,
00140         const openfluid::market::PackageInfo::PackageType& Type);
00141 
00142     /**
00143      @return choice of user to apply action of selected dataset to this dependencies
00144      @param ID of package selected
00145      @param Select action applied on the package
00146      @param List of dependencies to select
00147     */
00148     bool getUserChoice(const openfluid::ware::WareID_t& ID, const bool Select,
00149         const std::map<openfluid::market::PackageInfo::PackageType,std::list<MarketPackWidget*> >& PacksToSelect);
00150 
00151 
00152     // ===== Licenses =====//
00153     MarketWizardPage m_LicensesPage;
00154     QVBoxLayout m_LicensesPageBox;
00155 
00156     QLabel m_LicensesLabel;
00157 
00158     // Adjustable container for packages treeview and license text view
00159     QSplitter m_LicensesReviewPaned;
00160 
00161     QTreeWidget *mp_LicensesTreeView;
00162 
00163     QTextEdit *mp_LicensesTextView;
00164 
00165 
00166     QScrollArea m_LicensesListSWindow;
00167     QScrollArea m_LicensesReviewSWindow;
00168 
00169     QRadioButton m_LicensesAcceptRadio;
00170     QRadioButton m_LicensesDoNotRadio;
00171 
00172 
00173 
00174 
00175     // ===== Download and install =====//
00176     MarketWizardPage m_InstallPage;
00177 
00178     QVBoxLayout m_InstallPageBox;
00179 
00180     QTableWidget *mp_InstallTable;
00181 
00182 
00183     class InstallTableColumns
00184     {
00185       public:
00186 
00187         enum { ID, TYPE, FORMAT, STATUS};
00188 
00189         QTableWidgetItem *mp_ID;
00190         QTableWidgetItem *mp_Type;
00191         QTableWidgetItem *mp_Format;
00192         QTableWidgetItem *mp_Status;
00193 
00194         InstallTableColumns() {}
00195 
00196         void setFlags()
00197         {
00198           mp_ID->setFlags(mp_ID->flags() ^ Qt::ItemIsEditable);
00199           mp_Type->setFlags(mp_Type->flags() ^ Qt::ItemIsEditable);
00200           mp_Format->setFlags(mp_Format->flags() ^ Qt::ItemIsEditable);
00201           mp_Status->setFlags(mp_Status->flags() ^ Qt::ItemIsEditable);
00202         }
00203     };
00204 
00205     InstallTableColumns m_InstallColumns;
00206 
00207 
00208     QScrollArea m_InstallSWindow;
00209 
00210     QProgressBar m_InstallProgressBar;
00211     QPushButton m_ViewLogButton;
00212 
00213 
00214     void setupSelectionPage();
00215     void setupLicensesPage();
00216     void setupDownloadPage();
00217 
00218 
00219     /**
00220      * Removes tabs, destroys content and clear screen
00221     */
00222     void clearAvailPacksTreeview();
00223 
00224     /**
00225      * Creates tabs and display all available packages in Market-place selected
00226     */
00227     void updateAvailPacksTreeview();
00228 
00229     /**
00230      * Indicates that no marketplace reached and unselects repository
00231     */
00232     void displayMarketplaceError();
00233 
00234 
00235     void initializeLicencesTreeView();
00236 
00237     void updateInstallTreeview();
00238 
00239     openfluid::market::MarketClient m_MarketClient;
00240 
00241     int m_InstallationTimeout;
00242 
00243 
00244   private slots:
00245 
00246     void onApply();
00247     void onCancel();
00248     void onClose();
00249     void onPrepare(int Id);
00250 
00251     void onURLComboChanged(int RowNumber);
00252 
00253     /**
00254      * Selects all packages of current tab
00255     */
00256     void onSelectAllClicked();
00257 
00258     /**
00259      * Unselects all packages of current tab
00260     */
00261     void onSelectNoneClicked();
00262 
00263     /**
00264      * Edit common options of packages of the current tab
00265     */
00266     void onCommonBuildConfigClicked();
00267 
00268 
00269     /**
00270      Selects dependencies of ID package
00271      @param ID of package selected
00272     */
00273     void selectDependencies(const openfluid::ware::WareID_t& ID);
00274 
00275 
00276     void onPackageInstallModified();
00277 
00278 
00279     void onLicenseRadioClicked(bool Checked);
00280 
00281 
00282     void onLicensesTreeviewChanged(QTreeWidgetItem *CurrentItem);
00283 
00284 
00285     void onInstallTimeoutOnce();
00286 
00287     void onViewLogClicked();
00288 
00289 
00290   public:
00291 
00292     MarketClientAssistant(QWidget* Parent);
00293 
00294     virtual ~MarketClientAssistant();
00295 
00296     /**
00297      @return string name of type passed as parameter
00298      @param Type Type of package
00299      @param Maj First letter in maj
00300      @param Plural Return plural name
00301     */
00302     static QString getGraphicTypeName(const openfluid::market::PackageInfo::PackageType& Type, const bool Maj, const bool Plural);
00303 };
00304 
00305 } } //namespaces
00306 
00307 
00308 #endif /* __MARKETCLIENTASSISTANT_HPP__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines