mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-03 18:24:46 +00:00
api for favorites and desktop
This commit is contained in:
parent
85035dda60
commit
6c8ae2501a
2 changed files with 36 additions and 1 deletions
|
|
@ -205,7 +205,37 @@ void ApplicationListModel::moveRow(const QModelIndex& /* sourceParent */, int so
|
||||||
moveItem(sourceRow, destinationChild);
|
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() ||
|
if (row < 0 || destination < 0 || row >= m_applicationList.length() ||
|
||||||
destination >= m_applicationList.length() || row == destination) {
|
destination >= m_applicationList.length() || row == destination) {
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ struct ApplicationData {
|
||||||
QString icon;
|
QString icon;
|
||||||
QString storageId;
|
QString storageId;
|
||||||
QString entryPath;
|
QString entryPath;
|
||||||
|
bool favorite = false;
|
||||||
|
bool desktop = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ApplicationListModel : public QAbstractListModel {
|
class ApplicationListModel : public QAbstractListModel {
|
||||||
|
|
@ -67,6 +69,9 @@ public:
|
||||||
QStringList appOrder() const;
|
QStringList appOrder() const;
|
||||||
void setAppOrder(const QStringList &order);
|
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 moveItem(int row, int order);
|
||||||
|
|
||||||
Q_INVOKABLE void runApplication(const QString &storageId);
|
Q_INVOKABLE void runApplication(const QString &storageId);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue