mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-28 22:53:09 +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) {
|
||||
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[ApplicationStorageIdRole] = "ApplicationStorageIdRole";
|
||||
roleNames[ApplicationEntryPathRole] = "ApplicationEntryPathRole";
|
||||
roleNames[ApplicationOrderRole] = "ApplicationOrderRole";
|
||||
roleNames[ApplicationOriginalRowRole] = "ApplicationOriginalRowRole";
|
||||
|
||||
return roleNames;
|
||||
|
|
@ -89,7 +88,6 @@ void ApplicationListModel::loadApplications()
|
|||
data.icon = plugin.icon();
|
||||
data.storageId = service->storageId();
|
||||
data.entryPath = plugin.entryPath();
|
||||
data.order = 99;
|
||||
m_applicationList << data;
|
||||
}
|
||||
}
|
||||
|
|
@ -118,8 +116,6 @@ QVariant ApplicationListModel::data(const QModelIndex &index, int role) const
|
|||
return m_applicationList.at(index.row()).storageId;
|
||||
case ApplicationEntryPathRole:
|
||||
return m_applicationList.at(index.row()).entryPath;
|
||||
case ApplicationOrderRole:
|
||||
return m_applicationList.at(index.row()).order;
|
||||
case ApplicationOriginalRowRole:
|
||||
return index.row();
|
||||
|
||||
|
|
@ -137,7 +133,7 @@ int ApplicationListModel::rowCount(const QModelIndex &parent) const
|
|||
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() ||
|
||||
destination >= m_applicationList.length() || row == destination) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ struct ApplicationData {
|
|||
QString icon;
|
||||
QString storageId;
|
||||
QString entryPath;
|
||||
int order;
|
||||
};
|
||||
|
||||
class ApplicationListModel : public QAbstractListModel {
|
||||
|
|
@ -57,11 +56,10 @@ public:
|
|||
ApplicationIconRole = Qt::UserRole + 2,
|
||||
ApplicationStorageIdRole = Qt::UserRole + 3,
|
||||
ApplicationEntryPathRole = Qt::UserRole + 4,
|
||||
ApplicationOrderRole = Qt::UserRole + 5,
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue