File indexing completed on 2024-05-12 15:27:48
0001 /*************************************************************************** 0002 File : ImportDatasetWidget.h 0003 Project : LabPlot 0004 Description : import online dataset widget 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2019 Kovacs Ferencz (kferike98@gmail.com) 0007 Copyright : (C) 2019 by Alexander Semke (alexander.semke@web.de) 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 * This program is distributed in the hope that it will be useful, * 0018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0020 * GNU General Public License for more details. * 0021 * * 0022 * You should have received a copy of the GNU General Public License * 0023 * along with this program; if not, write to the Free Software * 0024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0025 * Boston, MA 02110-1301 USA * 0026 * * 0027 ***************************************************************************/ 0028 0029 0030 #ifndef IMPORTDATASETWIDGET_H 0031 #define IMPORTDATASETWIDGET_H 0032 0033 #include "ui_importdatasetwidget.h" 0034 #include "QMap" 0035 #include <QJsonArray> 0036 #include <QJsonObject> 0037 0038 class DatasetHandler; 0039 class DatasetModel; 0040 class QCompleter; 0041 class QNetworkAccessManager; 0042 class QNetworkReply; 0043 0044 typedef QMap< QString, QMap<QString, QMap<QString, QVector<QString>>>> DatasetsMap; 0045 0046 class ImportDatasetWidget : public QWidget { 0047 Q_OBJECT 0048 0049 public: 0050 explicit ImportDatasetWidget(QWidget* parent); 0051 ~ImportDatasetWidget() override; 0052 0053 QString getSelectedDataset() const; 0054 void import(DatasetHandler*); 0055 const DatasetsMap& getDatasetsMap(); 0056 void setCollection(const QString&); 0057 void setCategory(const QString&); 0058 void setSubcategory(const QString&); 0059 void setDataset(const QString&); 0060 void processTest(const QString& category, const QString& subcategory, const QString& dataset, DatasetHandler*); 0061 0062 private: 0063 Ui::ImportDatasetWidget ui; 0064 DatasetsMap m_datasetsMap; 0065 bool m_allCollections{false}; 0066 QString m_collection; 0067 QString m_category; 0068 QString m_subcategory; 0069 QString m_prevCollection; 0070 QString m_prevCategory; 0071 QString m_prevSubcategory; 0072 QString m_prevDataset; 0073 QCompleter* m_completer{nullptr}; 0074 QString m_jsonDir; 0075 bool m_initializing{false}; 0076 DatasetModel* m_model{nullptr}; 0077 QNetworkAccessManager* m_networkManager; 0078 QJsonArray m_collections; 0079 QJsonObject m_datasetObject; 0080 0081 void updateDatasetCompleter(); 0082 void updateCategoryCompleter(); 0083 void updateDatasets(QTreeWidgetItem*); 0084 void addDatasetItems(const QString& collection, const QString& category, const QString& subcategory, const QString& filter); 0085 0086 void loadCategories(); 0087 QJsonObject loadDatasetObject(); 0088 0089 private slots: 0090 void datasetChanged(); 0091 void collectionChanged(int); 0092 void downloadFinished(QNetworkReply*); 0093 void updateCategories(); 0094 0095 signals: 0096 void datasetSelected(); 0097 void datasetDoubleClicked(); 0098 }; 0099 0100 #endif // IMPORTDATASETWIDGET_H