Choice model settings was added
This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
BeerService::BeerService()
|
||||
: QObject{nullptr}
|
||||
{
|
||||
m_actions = {
|
||||
{ ActionGet, "get" },
|
||||
{ ActionAdd, "add" },
|
||||
{ ActionDelete, "del" },
|
||||
{ ActionModify, "mod" }
|
||||
};
|
||||
|
||||
restoreStash();
|
||||
|
||||
connect(&m_socket, &QWebSocket::textMessageReceived, this, [this](QString message) {
|
||||
@@ -31,7 +38,7 @@ BeerService::BeerService()
|
||||
}
|
||||
});
|
||||
|
||||
connect(&m_socket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), this, [this](QAbstractSocket::SocketError error) {
|
||||
connect(&m_socket, &QWebSocket::errorOccurred, this, [this](QAbstractSocket::SocketError error) {
|
||||
qInfo() << error << m_socket.errorString();
|
||||
});
|
||||
|
||||
@@ -60,11 +67,13 @@ SettingsService *BeerService::settings() const
|
||||
return SettingsService::instance();
|
||||
}
|
||||
|
||||
void BeerService::sendCommand(const QString &entity, const QString &action, const QVariantMap &data)
|
||||
void BeerService::sendCommand(const QString &entity, Action action, const QVariantMap &data)
|
||||
{
|
||||
Q_ASSERT(action != ActionUndefined);
|
||||
|
||||
sendCommand(QVariantMap {
|
||||
{ "entity", entity },
|
||||
{ "action", action },
|
||||
{ "action", m_actions[action] },
|
||||
{ "data", data }
|
||||
});
|
||||
}
|
||||
@@ -75,6 +84,12 @@ void BeerService::connectListener(QObject *listener)
|
||||
m_listeners.insert(entity, listener);
|
||||
}
|
||||
|
||||
void BeerService::removeListener(QObject *listener)
|
||||
{
|
||||
QString entity = listener->property("entity").toString();
|
||||
m_listeners.remove(entity, listener);
|
||||
}
|
||||
|
||||
QString BeerService::stashFileName() const
|
||||
{
|
||||
return QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/command.stash";
|
||||
@@ -102,6 +117,7 @@ void BeerService::restoreStash()
|
||||
QJsonDocument doc = QJsonDocument::fromJson(stash.readAll());
|
||||
m_commandStash = doc.array().toVariantList();
|
||||
stash.close();
|
||||
stash.remove();
|
||||
} else {
|
||||
qWarning() << stash.errorString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user