Commit e968db24 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Nate Graham
Browse files

updates: Move the extended delegate state into the model

This way when a delegate is reused, it will be properly initialised as
the user expected.

BUG: 452129
parent 6c1c0b52
Pipeline #193882 passed with stage
in 1 minute and 35 seconds
......@@ -285,7 +285,7 @@ DiscoverPage
highlighted: ListView.isCurrentItem
hoverEnabled: !page.isBusy
onEnabledChanged: if (!enabled) {
layout.extended = false;
model.extended = false;
}
visible: resourceState < 3 //3=AbstractBackendUpdater.Done
......@@ -293,12 +293,12 @@ DiscoverPage
Keys.onReturnPressed: {
itemChecked.clicked()
}
Keys.onPressed: if (event.key===Qt.Key_Alt) layout.extended = true
Keys.onReleased: if (event.key===Qt.Key_Alt) layout.extended = false
Keys.onPressed: if (event.key===Qt.Key_Alt) model.extended = true
Keys.onReleased: if (event.key===Qt.Key_Alt) model.extended = false
ColumnLayout {
id: layout
property bool extended: false
property bool extended: model.extended
onExtendedChanged: if (extended) {
updateModel.fetchUpdateDetails(index)
}
......@@ -409,7 +409,7 @@ DiscoverPage
}
onClicked: {
layout.extended = !layout.extended
model.extended = !model.extended
}
}
}
......
......@@ -44,6 +44,10 @@ public:
qint64 size() const;
Qt::CheckState checked() const;
void setExtended(bool extended)
{
m_isExtended = extended;
}
AbstractResource *resource() const
{
return m_app;
......@@ -52,6 +56,10 @@ public:
{
return m_visible;
}
bool isExtended() const
{
return m_isExtended;
}
void setVisible(bool visible)
{
m_visible = visible;
......@@ -66,6 +74,7 @@ private:
bool m_visible = true;
AbstractBackendUpdater::State m_state = AbstractBackendUpdater::None;
QString m_changelog;
bool m_isExtended = false;
};
#endif // UPDATEITEM_H
......@@ -53,6 +53,7 @@ QHash<int, QByteArray> UpdateModel::roleNames() const
ret.insert(SectionRole, "section");
ret.insert(ChangelogRole, "changelog");
ret.insert(UpgradeTextRole, "upgradeText");
ret.insert(ExtendedRole, "extended");
return ret;
}
......@@ -122,6 +123,8 @@ QVariant UpdateModel::data(const QModelIndex &index, int role) const
return item->state();
case ChangelogRole:
return item->changelog();
case ExtendedRole:
return item->isExtended();
case SectionRole: {
static const QString appUpdatesSection = i18nc("@item:inlistbox", "Applications");
static const QString systemUpdateSection = i18nc("@item:inlistbox", "System Software");
......@@ -182,6 +185,12 @@ bool UpdateModel::setData(const QModelIndex &idx, const QVariant &value, int rol
Q_EMIT toUpdateChanged();
return true;
} else if (role == ExtendedRole) {
UpdateItem *item = itemFromIndex(idx);
if (item->isExtended() != value.toBool()) {
item->setExtended(value.toBool());
Q_EMIT dataChanged(idx, idx, {ExtendedRole});
}
}
return false;
......
......@@ -34,6 +34,7 @@ public:
ChangelogRole,
SectionRole,
UpgradeTextRole,
ExtendedRole,
};
Q_ENUM(Roles)
......
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