Commit 6c8ae250 authored by Marco Martin's avatar Marco Martin

api for favorites and desktop

parent 85035dda
......@@ -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) {
......
......@@ -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);
......
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