Server settings are read from QSettings and applied if they are changed.
This commit is contained in:
@ -5,7 +5,6 @@
|
||||
|
||||
// TODO add namespace
|
||||
|
||||
static const QString baseUrl = "http://127.0.0.1:4000";
|
||||
static const QString apiPrefix = "/api/";
|
||||
|
||||
static const QString ROUTE_ITEMS = apiPrefix + "items";
|
||||
|
||||
@ -13,7 +13,6 @@ ServerCommunicator::ServerCommunicator(QObject* parent)
|
||||
m_netManager.setAutoDeleteReplies(true);
|
||||
m_restManager = std::make_shared<QRestAccessManager>(&m_netManager);
|
||||
m_serviceApi = std::make_shared<QNetworkRequestFactory>();
|
||||
setUrl(baseUrl);
|
||||
}
|
||||
|
||||
bool ServerCommunicator::sslSupported() {
|
||||
@ -96,3 +95,12 @@ void ServerCommunicator::deleteItem(const QString& id) {
|
||||
reply->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
void ServerCommunicator::setServerConfiguration(const QString url,
|
||||
const QString email,
|
||||
const QString password) {
|
||||
setUrl(url);
|
||||
|
||||
m_email = email;
|
||||
m_password = password;
|
||||
}
|
||||
|
||||
@ -16,6 +16,8 @@ class ServerCommunicator : public QObject {
|
||||
QUrl url() const;
|
||||
void setUrl(const QUrl& url);
|
||||
|
||||
void setServerConfiguration(const QString url, const QString email, const QString password);
|
||||
|
||||
public slots:
|
||||
void fetchItems();
|
||||
void postItems(const QByteArray& jsonData);
|
||||
@ -35,6 +37,10 @@ class ServerCommunicator : public QObject {
|
||||
QNetworkAccessManager m_netManager;
|
||||
std::shared_ptr<QRestAccessManager> m_restManager;
|
||||
std::shared_ptr<QNetworkRequestFactory> m_serviceApi;
|
||||
|
||||
QString m_email;
|
||||
QString m_password;
|
||||
// QString m_authToken;
|
||||
};
|
||||
|
||||
#endif // SERVERCOMMUNICATOR_H
|
||||
|
||||
Reference in New Issue
Block a user