diff --git a/containments/homescreen2/applicationlistmodel.cpp b/containments/homescreen2/applicationlistmodel.cpp index b3e06c71..20670807 100644 --- a/containments/homescreen2/applicationlistmodel.cpp +++ b/containments/homescreen2/applicationlistmodel.cpp @@ -205,7 +205,37 @@ void ApplicationListModel::moveRow(const QModelIndex& /* sourceParent */, int so moveItem(sourceRow, destinationChild); } -Q_INVOKABLE void ApplicationListModel::moveItem(int row, int destination) +void ApplicationListModel::setFavoriteItem(int row, bool favorite) +{ + if (row < 0 || row >= m_applicationList.length()) { + return; + } + + ApplicationData &data = m_applicationList[row]; + if (data.favorite == favorite) { + return; + } + + data.favorite = favorite; + emit dataChanged(index(row, 0), index(row, 0)); +} + +void ApplicationListModel::setDesktopItem(int row, bool desktop) +{ + if (row < 0 || row >= m_applicationList.length()) { + return; + } + + ApplicationData &data = m_applicationList[row]; + if (data.desktop == desktop) { + return; + } + + data.desktop = desktop; + emit dataChanged(index(row, 0), index(row, 0)); +} + +void ApplicationListModel::moveItem(int row, int destination) { if (row < 0 || destination < 0 || row >= m_applicationList.length() || destination >= m_applicationList.length() || row == destination) { diff --git a/containments/homescreen2/applicationlistmodel.h b/containments/homescreen2/applicationlistmodel.h index ddf65bf5..e2396ea8 100644 --- a/containments/homescreen2/applicationlistmodel.h +++ b/containments/homescreen2/applicationlistmodel.h @@ -32,6 +32,8 @@ struct ApplicationData { QString icon; QString storageId; QString entryPath; + bool favorite = false; + bool desktop = false; }; class ApplicationListModel : public QAbstractListModel { @@ -67,6 +69,9 @@ public: QStringList appOrder() const; void setAppOrder(const QStringList &order); + Q_INVOKABLE void setFavoriteItem(int row, bool favorite); + Q_INVOKABLE void setDesktopItem(int row, bool desktop); + Q_INVOKABLE void moveItem(int row, int order); Q_INVOKABLE void runApplication(const QString &storageId);