Basic JSON RESTful client fetching items from a local server at application start and adding them to the model.
This commit is contained in:
33
network/servercommunicator.h
Normal file
33
network/servercommunicator.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef SERVERCOMMUNICATOR_H
|
||||
#define SERVERCOMMUNICATOR_H
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequestFactory>
|
||||
#include <QObject>
|
||||
#include <QRestAccessManager>
|
||||
|
||||
class ServerCommunicator : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ServerCommunicator(QObject* parent = nullptr);
|
||||
|
||||
bool sslSupported();
|
||||
|
||||
QUrl url() const;
|
||||
void setUrl(const QUrl& url);
|
||||
|
||||
void fetchItems();
|
||||
|
||||
signals:
|
||||
void urlChanged();
|
||||
|
||||
void itemsFetched(const QByteArray jsonDoc);
|
||||
void itemsFetchFailure(const QString errorString);
|
||||
|
||||
private:
|
||||
QNetworkAccessManager m_netManager;
|
||||
std::shared_ptr<QRestAccessManager> m_restManager;
|
||||
std::shared_ptr<QNetworkRequestFactory> m_serviceApi;
|
||||
};
|
||||
|
||||
#endif // SERVERCOMMUNICATOR_H
|
||||
Reference in New Issue
Block a user