Commit 943c9615 authored by David Jarvie's avatar David Jarvie
Browse files

Fix resource ID numbers not working in command line & DBUS commands

Resource ID numbers were erroneously interpreted as internal resource
IDs instead of the IDs used in the config and known to the user.
parent a6d022dc
Pipeline #111218 passed with stage
in 1 minute and 30 seconds
......@@ -53,6 +53,22 @@ Resource Resources::resource(ResourceId id)
return mResources.value(id, Resource::null());
}
Resource Resources::resourceFromDisplayId(ResourceId id)
{
Resource result = Resource::null();
for (auto it = mResources.constBegin(); it != mResources.constEnd(); ++it)
{
const Resource& res = it.value();
if (res.displayId() == id)
{
if (result != Resource::null())
return Resource::null();
result = res;
}
}
return result;
}
/******************************************************************************
* Return the resources which are enabled for a specified alarm type.
* If 'writable' is true, only writable resources are included.
......
......@@ -38,6 +38,12 @@ public:
*/
static Resource resource(ResourceId);
/** Return a copy of the resource with a given display ID.
* @return The resource, or invalid if the ID doesn't already exist or is invalid
* or if more than one resource has the same display ID.
*/
static Resource resourceFromDisplayId(ResourceId);
/** Remove a resource. The calendar file is not removed.
* @return true if the resource has been removed or a removal job has been scheduled.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment