added methods to simplify some common actions
Dieser Commit ist enthalten in:
Ursprung
6f0c6d3dcf
Commit
39f5a518c3
@ -44,12 +44,12 @@ void Board::getTileData()
|
||||
|
||||
int Board::addTile(int16_t x, int16_t y, TileRotate rotate, const QString& id, bool replace, std::function<void(const bool&, Message::ErrorCode)> callback)
|
||||
{
|
||||
return callMethod(*m_connection, *getMethod("add_tile"), std::move(callback), x, y, rotate, id, replace);
|
||||
return ::callMethod(*m_connection, *getMethod("add_tile"), std::move(callback), x, y, rotate, id, replace);
|
||||
}
|
||||
|
||||
int Board::deleteTile(int16_t x, int16_t y, std::function<void(const bool&, Message::ErrorCode)> callback)
|
||||
{
|
||||
return callMethod(*m_connection, *getMethod("delete_tile"), std::move(callback), x, y);
|
||||
return ::callMethod(*m_connection, *getMethod("delete_tile"), std::move(callback), x, y);
|
||||
}
|
||||
|
||||
void Board::getTileDataResponse(const Message& response)
|
||||
|
||||
@ -59,6 +59,14 @@ AbstractProperty* Object::getProperty(const QString& name)
|
||||
return dynamic_cast<AbstractProperty*>(m_interfaceItems.find(name));
|
||||
}
|
||||
|
||||
void Object::setPropertyValue(const QString& name, bool value)
|
||||
{
|
||||
if(AbstractProperty* property = getProperty(name))
|
||||
property->setValueBool(value);
|
||||
else
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
const Method* Object::getMethod(const QString& name) const
|
||||
{
|
||||
return dynamic_cast<const Method*>(m_interfaceItems.find(name));
|
||||
@ -68,3 +76,11 @@ Method* Object::getMethod(const QString& name)
|
||||
{
|
||||
return dynamic_cast<Method*>(m_interfaceItems.find(name));
|
||||
}
|
||||
|
||||
void Object::callMethod(const QString& name)
|
||||
{
|
||||
if(Method* method = getMethod(name))
|
||||
method->call();
|
||||
else
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
@ -63,8 +63,12 @@ class Object : public QObject
|
||||
const AbstractProperty* getProperty(const QString& name) const;
|
||||
AbstractProperty* getProperty(const QString& name);
|
||||
|
||||
void setPropertyValue(const QString& name, bool value);
|
||||
|
||||
const Method* getMethod(const QString& name) const;
|
||||
Method* getMethod(const QString& name);
|
||||
|
||||
void callMethod(const QString& name);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren