Skip to content

Commit

Permalink
code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmm committed Feb 24, 2025
1 parent 5bd074d commit 8141721
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/contents/ui/DelegatePluginsList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.kde.kirigami as Kirigami
Item {
id: delegateItem

required property var listModel
required property int index
required property bool bypass
required property string name
Expand Down Expand Up @@ -70,10 +71,10 @@ Item {
icon.name: "delete"
displayHint: Kirigami.DisplayHint.IconOnly
onTriggered: {
pluginsListModel.remove(index, 1);
const indexStart = pluginsListModel.index(0, 0);
const indexEnd = pluginsListModel.index(pluginsListModel.count - 1, 0);
pluginsListModel.dataChanged(indexStart, indexEnd, []);
listModel.remove(index, 1);
const indexStart = listModel.index(0, 0);
const indexEnd = listModel.index(listModel.count - 1, 0);
listModel.dataChanged(indexStart, indexEnd, []);
}
}
]
Expand All @@ -83,10 +84,10 @@ Item {
listItem: listItemDelegate
listView: pluginsListView
onMoveRequested: (oldIndex, newIndex) => {
const indexStart = pluginsListModel.index(0, 0);
const indexEnd = pluginsListModel.index(pluginsListModel.count - 1, 0);
pluginsListModel.move(oldIndex, newIndex, 1);
pluginsListModel.dataChanged(indexStart, indexEnd, []);
const indexStart = listModel.index(0, 0);
const indexEnd = listModel.index(listModel.count - 1, 0);
listModel.move(oldIndex, newIndex, 1);
listModel.dataChanged(indexStart, indexEnd, []);
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/contents/ui/PageStreamsEffects.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Kirigami.Page {
}
}

ListModel {
id: pluginsListModel
}

MenuAddPlugins {
id: menuAddPlugins

Expand Down Expand Up @@ -315,12 +319,10 @@ Kirigami.Page {
}
}
}

model: ListModel {
id: pluginsListModel
}
model: pluginsListModel

delegate: DelegatePluginsList {
listModel: pluginsListModel
}

moveDisplaced: Transition {
Expand Down

0 comments on commit 8141721

Please sign in to comment.