@@ -22,32 +22,19 @@ import "Components" as FFComps
2222
2323Item {
2424 id: root
25- implicitWidth: childrenRect . width + 12
26- property bool showPlaceHolderMateria: true
25+ implicitWidth: mSelector . implicitWidth + ( 24 * 4 )
26+ property alias showPlaceHolderMateria: mSelector . showPlaceHolderMateria
2727 property bool editable: true
2828 property bool fixedHeightSkills: true
2929 property int starHeight: 24
30- property int currentId: FF7Materia . EmptyId
30+ property alias currentId: mSelector . currentId
3131 property int currentAp: FF7Materia .maxMateriaAp
3232 readonly property bool isEmpty: ((currentId === FF7Materia .EmptyId ))
3333 readonly property int level: FF7Materia .materiaLevel (currentId, currentAp)
3434 signal copyActionTriggered (int currentId, int currentAp)
3535 signal cutActionTriggered (int currentId, int currentAp)
3636 signal pasteActionTriggered ()
3737
38- ListModel {
39- id: typeModel
40- ListElement { text: qsTr (" All Materia" ); icon: " qrc:/materia/all" }
41- ListElement { text: qsTr (" Magic" ); icon: " qrc:/materia/magic" }
42- ListElement { text: qsTr (" Summon" ); icon: " qrc:/materia/summon" }
43- ListElement { text: qsTr (" Independent" ); icon: " qrc:/materia/independent" }
44- ListElement { text: qsTr (" Support" ); icon: " qrc:/materia/support" }
45- ListElement { text: qsTr (" Command" ); icon: " qrc:/materia/command" }
46- }
47-
48- ListModel { id: materiaModel }
49- Component .onCompleted : { setupMateriaModel (0 ); materiaCombo .modelChanged () }
50-
5138 Rectangle {
5239 anchors .fill : parent
5340 color: palette .base
@@ -57,27 +44,19 @@ Item {
5744 anchors .right : parent .right
5845 anchors .top : parent .top
5946 height: 24
60- anchors .margins : 6
47+ anchors .leftMargin : 6
48+ anchors .rightMargin : 6
6149 spacing: 6
62- FFComps .ComboBox {
63- id: typeCombo
64- visible: root .editable
65- Layout .fillHeight : true
66- Layout .preferredWidth : implicitWidth
67- model: typeModel
68- onCurrentIndexChanged: setupMateriaModel (currentIndex)
69- }
70- FFComps .ComboBox {
71- id: materiaCombo
50+ MateriaSelector {
51+ id: mSelector
7252 visible: root .editable
7353 Layout .fillHeight : true
7454 Layout .fillWidth : true
75- Layout .minimumWidth : implicitWidth
76- model: materiaModel
77- onCurrentIndexChanged: currentId = currentIndex !== - 1 ? model .get (currentIndex).data : currentId
55+ Layout .preferredWidth : mSelector .implicitWidth + 12
7856 }
7957 Image {
8058 visible: ! root .editable && currentId !== FF7Materia .EmptyId
59+ Layout .margins : 4
8160 Layout .fillHeight : true
8261 Layout .preferredWidth : height
8362 source: FF7Materia .iconResource (currentId)
@@ -361,21 +340,4 @@ Item {
361340 }
362341 }
363342 }
364-
365- onShowPlaceHolderMateriaChanged: {
366- var cI = materiaCombo .currentIndex
367- typeCombo .currentIndex === 0 ? setupMateriaModel (typeCombo .currentIndex ) : null
368- materiaCombo .currentIndex = cI
369- }
370-
371- function setupMateriaModel (type ) {
372- materiaModel .clear ()
373- for (let i = 0 ; i <= 90 ; i++ ) {
374- if ( (type === 0 || FF7Materia .type (i) === type) && FF7Materia .name (i) !== " " ) {
375- if (String (FF7Materia .name (i)).includes (" :" ) && ! root .showPlaceHolderMateria )
376- continue ;
377- materiaModel .append ({ text: FF7Materia .name (i), icon: FF7Materia .iconResource (i), data: i})
378- }
379- }
380- }
381343}
0 commit comments