2024-02-16 11:31:40 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import StatusQ 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
|
|
|
import Storybook 1.0
|
|
|
|
|
|
|
|
import AppLayouts.Profile.helpers 1.0
|
|
|
|
|
2024-02-20 13:26:56 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2024-02-16 11:31:40 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: communitiesModel
|
|
|
|
|
2024-03-29 11:43:49 +00:00
|
|
|
ListElement { showcaseKey: "1"; name: "Crypto Kitties"; showcaseVisibility: Constants.ShowcaseVisibility.IdVerifiedContacts; showcasePosition: 0 }
|
2024-03-04 22:07:09 +00:00
|
|
|
ListElement { showcaseKey: "2"; name: "Status" }
|
2024-03-29 11:43:49 +00:00
|
|
|
ListElement { showcaseKey: "3"; name: "Fun Stuff"; showcaseVisibility: Constants.ShowcaseVisibility.Contacts; showcasePosition: 9}
|
2024-03-04 22:07:09 +00:00
|
|
|
ListElement { showcaseKey: "4"; name: "Other Stuff" }
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
2024-02-20 13:26:56 +00:00
|
|
|
ListModel {
|
|
|
|
id: comboBoxModel
|
|
|
|
|
|
|
|
ListElement {
|
|
|
|
text: "verified"
|
|
|
|
value: Constants.ShowcaseVisibility.IdVerifiedContacts
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
text: "contacts"
|
|
|
|
value: Constants.ShowcaseVisibility.Contacts
|
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
text: "all"
|
|
|
|
value: Constants.ShowcaseVisibility.Everyone
|
|
|
|
}
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfileShowcaseDirtyState {
|
|
|
|
id: dirtyState
|
|
|
|
|
|
|
|
sourceModel: communitiesModel
|
|
|
|
}
|
|
|
|
|
|
|
|
MovableModel {
|
|
|
|
id: movableModel
|
|
|
|
|
|
|
|
sourceModel: dirtyState.visibleModel
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
Grid {
|
2024-03-04 22:07:09 +00:00
|
|
|
id: grid
|
2024-02-16 11:31:40 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.margins: 10
|
|
|
|
|
2024-03-29 11:43:49 +00:00
|
|
|
rows: 2
|
|
|
|
columns: 2
|
2024-02-16 11:31:40 +00:00
|
|
|
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
flow: Grid.TopToBottom
|
|
|
|
|
|
|
|
GenericListView {
|
2024-03-29 11:43:49 +00:00
|
|
|
width: grid.width / 2 - grid.spacing
|
2024-02-16 11:31:40 +00:00
|
|
|
height: 300
|
|
|
|
|
|
|
|
model: communitiesModel
|
2024-03-29 11:43:49 +00:00
|
|
|
label: "COMMUNITIES MODEL - Backend model"
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericListView {
|
2024-03-29 11:43:49 +00:00
|
|
|
width: grid.width / 2 - grid.spacing
|
2024-02-16 11:31:40 +00:00
|
|
|
height: 300
|
|
|
|
|
|
|
|
model: dirtyState.writable_
|
2024-03-29 11:43:49 +00:00
|
|
|
label: "WRITABLE MODEL - Internal Model"
|
2024-03-04 22:07:09 +00:00
|
|
|
roles: ["showcaseKey", "showcaseVisibility", "showcasePosition", "name"]
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericListView {
|
2024-03-29 11:43:49 +00:00
|
|
|
width: grid.width / 2 - grid.spacing
|
2024-02-16 11:31:40 +00:00
|
|
|
height: 300
|
|
|
|
|
|
|
|
model: movableModel
|
2024-03-29 11:43:49 +00:00
|
|
|
label: "IN SHOWCASE - output"
|
2024-02-16 11:31:40 +00:00
|
|
|
movable: true
|
2024-03-04 22:07:09 +00:00
|
|
|
roles: ["showcaseKey", "showcaseVisibility", "showcasePosition"]
|
2024-02-16 11:31:40 +00:00
|
|
|
|
|
|
|
onMoveRequested: {
|
|
|
|
movableModel.move(from, to)
|
2024-03-04 22:07:09 +00:00
|
|
|
dirtyState.changePosition(from, to);
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
insetComponent: RowLayout {
|
|
|
|
readonly property var topModel: model
|
|
|
|
|
|
|
|
RoundButton {
|
|
|
|
text: "❌"
|
2024-02-20 13:26:56 +00:00
|
|
|
onClicked: dirtyState.setVisibility(
|
2024-03-04 22:07:09 +00:00
|
|
|
model.showcaseKey,
|
2024-02-20 13:26:56 +00:00
|
|
|
Constants.ShowcaseVisibility.NoOne)
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ComboBox {
|
2024-02-20 13:26:56 +00:00
|
|
|
model: comboBoxModel
|
2024-02-16 11:31:40 +00:00
|
|
|
|
|
|
|
onCurrentValueChanged: {
|
|
|
|
if (!completed || topModel.index < 0)
|
|
|
|
return
|
|
|
|
|
2024-03-04 22:07:09 +00:00
|
|
|
dirtyState.setVisibility(topModel.showcaseKey, currentValue)
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
property bool completed: false
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2024-03-04 22:07:09 +00:00
|
|
|
currentIndex = indexOfValue(topModel.showcaseVisibility)
|
2024-02-16 11:31:40 +00:00
|
|
|
completed = true
|
|
|
|
}
|
|
|
|
|
|
|
|
textRole: "text"
|
|
|
|
valueRole: "value"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GenericListView {
|
2024-03-29 11:43:49 +00:00
|
|
|
width: grid.width / 2 - grid.spacing
|
2024-02-16 11:31:40 +00:00
|
|
|
height: 300
|
|
|
|
|
|
|
|
model: dirtyState.hiddenModel
|
2024-03-29 11:43:49 +00:00
|
|
|
label: "HIDDEN - output"
|
2024-02-16 11:31:40 +00:00
|
|
|
|
2024-03-04 22:07:09 +00:00
|
|
|
roles: ["showcaseKey", "showcaseVisibility", "showcasePosition"]
|
2024-02-16 11:31:40 +00:00
|
|
|
|
|
|
|
insetComponent: Button {
|
|
|
|
text: "unhide"
|
|
|
|
|
2024-02-20 13:26:56 +00:00
|
|
|
onClicked: dirtyState.setVisibility(
|
2024-03-04 22:07:09 +00:00
|
|
|
model.showcaseKey,
|
2024-02-20 13:26:56 +00:00
|
|
|
Constants.ShowcaseVisibility.IdVerifiedContacts)
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: "SAVE"
|
|
|
|
onClicked: {
|
|
|
|
const toBeSaved = dirtyState.currentState()
|
|
|
|
|
2024-03-29 11:43:49 +00:00
|
|
|
for (let i = 0; i < communitiesModel.count; i++) {
|
|
|
|
const item = communitiesModel.get(i)
|
|
|
|
const found = toBeSaved.find((x) => x.showcaseKey === item.showcaseKey)
|
|
|
|
|
|
|
|
item.showcaseVisibility = !!found ? found.showcaseVisibility : Constants.ShowcaseVisibility.NoOne
|
|
|
|
item.showcasePosition = !!found ? found.showcasePosition : 0
|
|
|
|
}
|
2024-02-16 11:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.margins: 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// category: Models
|