File indexing completed on 2025-01-19 03:55:37
0001 #ifndef TWEETMODEL_H 0002 #define TWEETMODEL_H 0003 0004 #include <QAbstractListModel> 0005 #include <QList> 0006 #include <QVariantMap> 0007 0008 /// List of tweets, suitable as a ListView model 0009 class TweetModel : public QAbstractListModel { 0010 Q_OBJECT 0011 0012 public: 0013 enum Roles { 0014 RoleText = Qt::UserRole + 1, 0015 }; 0016 0017 TweetModel(QObject *parent = 0); 0018 0019 /// Clear all tweets 0020 void clearTweets(); 0021 0022 /// Add a tweet 0023 void addTweet(QVariantMap tweet); 0024 0025 /// Get number of tweets 0026 int rowCount(const QModelIndex &parent = QModelIndex()) const; 0027 0028 /// Access a tweet 0029 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; 0030 0031 /// Get role names 0032 QHash<int, QByteArray>roleNames() const; 0033 0034 protected: 0035 QList<QVariantMap> tweets; 0036 }; 0037 0038 #endif // TWEETMODEL_H