File indexing completed on 2025-02-02 05:02:39

0001 /*
0002     SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef WEATHERFORECASTMODEL_H
0008 #define WEATHERFORECASTMODEL_H
0009 
0010 #include "weatherforecast.h"
0011 
0012 #include <QAbstractListModel>
0013 
0014 class WeatherForecastManager;
0015 
0016 /** Weather forecast details page model. */
0017 class WeatherForecastModel : public QAbstractListModel
0018 {
0019     Q_OBJECT
0020     Q_PROPERTY(QObject* weatherForecastManager READ weatherForecastManager WRITE setWeatherForecastManager)
0021     Q_PROPERTY(QVariant weatherForecast READ weatherForecast WRITE setWeatherForecast)
0022 public:
0023     enum Roles {
0024         WeatherForecastRole = Qt::UserRole,
0025         LocalizedTimeRole
0026     };
0027 
0028     explicit WeatherForecastModel(QObject *parent = nullptr);
0029     ~WeatherForecastModel() override;
0030 
0031     int rowCount(const QModelIndex &parent) const override;
0032     QVariant data(const QModelIndex &index, int role) const override;
0033     QHash<int, QByteArray> roleNames() const override;
0034 
0035     QObject* weatherForecastManager() const;
0036     void setWeatherForecastManager(QObject *mgr);
0037     QVariant weatherForecast() const;
0038     void setWeatherForecast(const QVariant &fc);
0039 
0040 private:
0041     WeatherForecastManager *m_mgr = nullptr;
0042     WeatherForecast m_fc;
0043 };
0044 
0045 #endif // WEATHERFORECASTMODEL_H