File indexing completed on 2024-05-12 15:28:15

0001 /***************************************************************************
0002     File                 : WelcomeScreenHelper.h
0003     Project              : LabPlot
0004     --------------------------------------------------------------------
0005     Copyright            : (C) 2019 Ferencz Kovacs (kferike98@gmail.com)
0006     Description          : Helper class for the welcome screen
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *  This program is free software; you can redistribute it and/or modify   *
0012  *  it under the terms of the GNU General Public License as published by   *
0013  *  the Free Software Foundation; either version 2 of the License, or      *
0014  *  (at your option) any later version.                                    *
0015  *                                                                         *
0016  *  This program is distributed in the hope that it will be useful,        *
0017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0019  *  GNU General Public License for more details.                           *
0020  *                                                                         *
0021  *   You should have received a copy of the GNU General Public License     *
0022  *   along with this program; if not, write to the Free Software           *
0023  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0024  *   Boston, MA  02110-1301  USA                                           *
0025  *                                                                         *
0026  ***************************************************************************/
0027 #ifndef WELCOMESCREENHELPER_H
0028 #define WELCOMESCREENHELPER_H
0029 
0030 #include <QObject>
0031 #include <QMap>
0032 #include <QVariant>
0033 #include <memory>
0034 #include <QPixmap>
0035 
0036 class ImportDatasetWidget;
0037 class DatasetHandler;
0038 class Spreadsheet;
0039 class DatasetModel;
0040 
0041 class WelcomeScreenHelper : public QObject {
0042     Q_OBJECT
0043 
0044 public:
0045     WelcomeScreenHelper();
0046     ~WelcomeScreenHelper();
0047 
0048     Q_INVOKABLE QVariant datasetName();
0049     Q_INVOKABLE QVariant datasetDescription();
0050     Q_INVOKABLE QVariant datasetColumns();
0051     Q_INVOKABLE QVariant datasetRows();
0052     Q_INVOKABLE QVariant getProjectThumbnail(const QUrl&);
0053     Q_INVOKABLE QVariant getExampleProjectThumbnail(const QString&);
0054     Q_INVOKABLE QVariant getExampleProjects();
0055     Q_INVOKABLE QVariant searchExampleProjects(const QString& searchtext);
0056     Q_INVOKABLE QVariant getExampleProjectTags(const QString&);
0057     Q_INVOKABLE void setWidthScale(const QString& sectionID, double scale);
0058     Q_INVOKABLE void setHeightScale(const QString& sectionID, double scale);
0059     Q_INVOKABLE QVariant getWidthScale(const QString& sectionID);
0060     Q_INVOKABLE QVariant getHeightScale(const QString& sectionID);
0061     Q_INVOKABLE QVariant getMaxIcon();
0062     Q_INVOKABLE QVariant getMinIcon();
0063     Q_INVOKABLE QVariant getBackIcon();
0064     Q_INVOKABLE QVariant getForwardIcon();
0065 
0066     Spreadsheet* releaseConfiguredSpreadsheet();
0067     DatasetModel* getDatasetModel();
0068 
0069 public slots:
0070     void datasetClicked(const QString& category, const QString& subcategory, const QString& datasetName);
0071     void exampleProjectClicked(const QString&);
0072 
0073 private:
0074     DatasetModel* m_datasetModel{nullptr};
0075     ImportDatasetWidget* m_datasetWidget{nullptr};
0076     DatasetHandler* m_datasetHandler{nullptr};
0077     mutable std::unique_ptr<Spreadsheet> m_spreadsheet{nullptr};
0078     QStringList m_projectNameList;
0079     QMap<QString,QStringList> m_tagMap;
0080     QMap<QString,QStringList> m_datasetTag;
0081     QMap<QString, QString> m_pathMap;
0082     QMap<QString, double> m_widthScale;
0083     QMap<QString, double> m_heightScale;
0084     QPixmap m_maxIcon;
0085     QPixmap m_minIcon;
0086 
0087     void processExampleProjects();
0088     void loadConfig();
0089 
0090 signals:
0091     void datasetFound();
0092     void datasetNotFound();
0093     void showFirstDataset();
0094     void openExampleProject(QString);
0095 };
0096 #endif //WELCOMESCREENHELPER_H