00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GLUONPLAYER_COMMENTSMODEL_H
00021 #define GLUONPLAYER_COMMENTSMODEL_H
00022
00023 #include "gluon_player_export.h"
00024
00025 #include <attica/providermanager.h>
00026 #include <attica/provider.h>
00027
00028 #include <QAbstractItemModel>
00029 #include <QStringList>
00030
00031
00032 namespace Attica
00033 {
00034 class BaseJob;
00035 }
00036
00037 namespace GluonCore
00038 {
00039 class GluonObject;
00040 };
00041
00042 namespace GluonPlayer
00043 {
00044
00055 class GLUON_PLAYER_EXPORT CommentsModel : public QAbstractItemModel
00056 {
00057 Q_OBJECT
00058
00059 public:
00060 enum Column
00061 {
00062 AuthorColumn,
00063 TitleColumn,
00064 BodyColumn,
00065 DateTimeColumn,
00066 RatingColumn
00067 };
00068
00073 CommentsModel( QString gameId, QObject* parent = 0 );
00074 virtual ~CommentsModel();
00075 virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
00076 virtual int columnCount( const QModelIndex& parent = QModelIndex() ) const;
00077 virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
00078 virtual QModelIndex parent( const QModelIndex& child ) const;
00079 virtual QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
00080 virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
00081 virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
00082 virtual bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );
00083 virtual bool insertRows( int row, int count, const QModelIndex& parent = QModelIndex() );
00084
00090 QString columnName( const Column col ) const;
00091
00097 bool isOnline();
00098
00107 void uploadComment( const QModelIndex& parentIndex, const QString& subject, const QString& message );
00108
00109 private:
00110 GluonCore::GluonObject* rootNode;
00111 QStringList m_columnNames;
00112 bool m_isOnline;
00113 QString m_gameId;
00114
00115 void updateData();
00116 void loadData();
00117 void saveData();
00118
00119 GluonCore::GluonObject* addComment( Attica::Comment comment, GluonCore::GluonObject* parent );
00120
00121 private slots:
00122 void providersUpdated();
00123 void processFetchedComments( Attica::BaseJob* );
00124 void addCommentFinished( Attica::BaseJob* job );
00125
00126 signals:
00129 void addCommentFailed();
00130 };
00131 }
00132
00133 #endif // GLUONPLAYER_COMMENTSMODEL_H