mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-04 02:34:45 +00:00
setOrcer->moveItem
This commit is contained in:
parent
d09c3beafb
commit
a3667cb3ba
3 changed files with 3 additions and 9 deletions
|
|
@ -70,7 +70,7 @@ Item {
|
||||||
if (delegateItem.drag.target) {
|
if (delegateItem.drag.target) {
|
||||||
var pos = mapToItem(delegateRoot.parent, 0, 0);
|
var pos = mapToItem(delegateRoot.parent, 0, 0);
|
||||||
|
|
||||||
appListModel.setOrder(model.ApplicationOriginalRowRole, (Math.round(delegateRoot.GridView.view.width / delegateRoot.GridView.view.cellWidth) * Math.round(pos.y / delegateRoot.GridView.view.cellHeight) + Math.round(pos.x / delegateRoot.GridView.view.cellWidth)));
|
appListModel.moveItem(model.ApplicationOriginalRowRole, (Math.round(delegateRoot.GridView.view.width / delegateRoot.GridView.view.cellWidth) * Math.round(pos.y / delegateRoot.GridView.view.cellHeight) + Math.round(pos.x / delegateRoot.GridView.view.cellWidth)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ QHash<int, QByteArray> ApplicationListModel::roleNames() const
|
||||||
roleNames[ApplicationIconRole] = "ApplicationIconRole";
|
roleNames[ApplicationIconRole] = "ApplicationIconRole";
|
||||||
roleNames[ApplicationStorageIdRole] = "ApplicationStorageIdRole";
|
roleNames[ApplicationStorageIdRole] = "ApplicationStorageIdRole";
|
||||||
roleNames[ApplicationEntryPathRole] = "ApplicationEntryPathRole";
|
roleNames[ApplicationEntryPathRole] = "ApplicationEntryPathRole";
|
||||||
roleNames[ApplicationOrderRole] = "ApplicationOrderRole";
|
|
||||||
roleNames[ApplicationOriginalRowRole] = "ApplicationOriginalRowRole";
|
roleNames[ApplicationOriginalRowRole] = "ApplicationOriginalRowRole";
|
||||||
|
|
||||||
return roleNames;
|
return roleNames;
|
||||||
|
|
@ -89,7 +88,6 @@ void ApplicationListModel::loadApplications()
|
||||||
data.icon = plugin.icon();
|
data.icon = plugin.icon();
|
||||||
data.storageId = service->storageId();
|
data.storageId = service->storageId();
|
||||||
data.entryPath = plugin.entryPath();
|
data.entryPath = plugin.entryPath();
|
||||||
data.order = 99;
|
|
||||||
m_applicationList << data;
|
m_applicationList << data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -118,8 +116,6 @@ QVariant ApplicationListModel::data(const QModelIndex &index, int role) const
|
||||||
return m_applicationList.at(index.row()).storageId;
|
return m_applicationList.at(index.row()).storageId;
|
||||||
case ApplicationEntryPathRole:
|
case ApplicationEntryPathRole:
|
||||||
return m_applicationList.at(index.row()).entryPath;
|
return m_applicationList.at(index.row()).entryPath;
|
||||||
case ApplicationOrderRole:
|
|
||||||
return m_applicationList.at(index.row()).order;
|
|
||||||
case ApplicationOriginalRowRole:
|
case ApplicationOriginalRowRole:
|
||||||
return index.row();
|
return index.row();
|
||||||
|
|
||||||
|
|
@ -137,7 +133,7 @@ int ApplicationListModel::rowCount(const QModelIndex &parent) const
|
||||||
return m_applicationList.count();
|
return m_applicationList.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_INVOKABLE void ApplicationListModel::setOrder(int row, int destination)
|
Q_INVOKABLE 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,7 +32,6 @@ struct ApplicationData {
|
||||||
QString icon;
|
QString icon;
|
||||||
QString storageId;
|
QString storageId;
|
||||||
QString entryPath;
|
QString entryPath;
|
||||||
int order;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ApplicationListModel : public QAbstractListModel {
|
class ApplicationListModel : public QAbstractListModel {
|
||||||
|
|
@ -57,11 +56,10 @@ public:
|
||||||
ApplicationIconRole = Qt::UserRole + 2,
|
ApplicationIconRole = Qt::UserRole + 2,
|
||||||
ApplicationStorageIdRole = Qt::UserRole + 3,
|
ApplicationStorageIdRole = Qt::UserRole + 3,
|
||||||
ApplicationEntryPathRole = Qt::UserRole + 4,
|
ApplicationEntryPathRole = Qt::UserRole + 4,
|
||||||
ApplicationOrderRole = Qt::UserRole + 5,
|
|
||||||
ApplicationOriginalRowRole = Qt::UserRole + 6
|
ApplicationOriginalRowRole = Qt::UserRole + 6
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_INVOKABLE void setOrder(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