Unverified Commit ba737f47 authored by Andreas Krutzler's avatar Andreas Krutzler Committed by David Rosca
Browse files

Fix wrong availability of profiles and ports.

Summary: Fixed bug where available ports are displayed as unavailable/unplugged and vice versa. It seems that this bug was introduced with D9671.

Reviewers: nicolasfella, broulik, drosca

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D13694
parent 8c79da69
......@@ -40,7 +40,18 @@ public:
template<typename PAInfo>
void setInfo(const PAInfo *info)
{
Profile::setInfo(info);
Availability newAvailability;
switch (info->available) {
case PA_PORT_AVAILABLE_NO:
newAvailability = Unavailable;
break;
case PA_PORT_AVAILABLE_YES:
newAvailability = Available;
break;
default:
newAvailability = Unknown;
}
setCommonInfo(info, newAvailability);
}
};
......
......@@ -48,6 +48,24 @@ public:
template<typename PAInfo>
void setInfo(const PAInfo *info)
{
setCommonInfo(info, info->available ? Available : Unavailable);
}
QString name() const;
QString description() const;
quint32 priority() const;
Availability availability() const;
signals:
void nameChanged();
void descriptionChanged();
void priorityChanged();
void availabilityChanged();
protected:
template<typename PAInfo>
void setCommonInfo(const PAInfo *info, Availability newAvailability)
{
// Description is optional. Name not so much as we need some ID.
Q_ASSERT(info->name);
......@@ -68,24 +86,12 @@ public:
emit priorityChanged();
}
Availability newAvailability = info->available ? Available : Unavailable;
if (m_availability != newAvailability) {
m_availability = newAvailability;
emit availabilityChanged();
}
}
QString name() const;
QString description() const;
quint32 priority() const;
Availability availability() const;
signals:
void nameChanged();
void descriptionChanged();
void priorityChanged();
void availabilityChanged();
private:
QString m_name;
QString m_description;
......
Supports Markdown
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