1 /* 2 Copyright (C) 2014 Aseman 3 http://aseman.co 4 5 This project is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This project is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef TELEGRAMWALLPAPERSMODEL_H 20 #define TELEGRAMWALLPAPERSMODEL_H 21 22 #include "telegramqml_global.h" 23 #include "tgabstractlistmodel.h" 24 25 class TelegramQml; 26 class TelegramWallpapersModelPrivate; 27 class TELEGRAMQMLSHARED_EXPORT TelegramWallpapersModel : public TgAbstractListModel 28 { 29 Q_OBJECT 30 Q_ENUMS(WallpapersRoles) 31 32 Q_PROPERTY(TelegramQml* telegram READ telegram WRITE setTelegram NOTIFY telegramChanged) 33 Q_PROPERTY(int count READ count NOTIFY countChanged) 34 Q_PROPERTY(bool initializing READ initializing NOTIFY initializingChanged) 35 36 public: 37 enum WallpapersRoles { 38 ItemRole = Qt::UserRole 39 }; 40 41 TelegramWallpapersModel(QObject *parent = 0); 42 ~TelegramWallpapersModel(); 43 44 TelegramQml *telegram() const; 45 void setTelegram(TelegramQml *tg ); 46 47 qint64 id( const QModelIndex &index ) const; 48 int rowCount(const QModelIndex & parent = QModelIndex()) const; 49 50 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 51 52 QHash<qint32,QByteArray> roleNames() const; 53 54 int count() const; 55 bool initializing() const; 56 57 Q_SIGNALS: 58 void telegramChanged(); 59 void countChanged(); 60 void initializingChanged(); 61 62 private Q_SLOTS: 63 void recheck(); 64 void wallpapersChanged(); 65 66 protected: 67 TelegramWallpapersModelPrivate *p; 68 }; 69 70 #endif // TELEGRAMWALLPAPERSMODEL_H 71