-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepotSearchWidget.qml
More file actions
532 lines (450 loc) · 22.5 KB
/
DepotSearchWidget.qml
File metadata and controls
532 lines (450 loc) · 22.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qmlcomponents
TibiaSidebarWidget {
id: root
caption: qsTrId("depot_search_caption")
picSource: "/images/icon-widget-search.png"
initialContentHeight: 350
minContentHeight: Math.max(searchResultLayout.Layout.minimumHeight, detailListLayout.Layout.minimumHeight)
maxContentHeight: 392 //enough to show a full 32 slot detail list
levelUpButtonVisible: root.showDetailList
highlightFocus: widgetController != null && widgetController.hasFocus
readonly property bool showDetailList: widgetController != null && widgetController.showDetailList
readonly property int totalCountDepot: widgetController != null ? widgetController.totalCountDepot : 0
readonly property int totalCountStash: widgetController != null ? widgetController.totalCountStash : 0
readonly property int totalCountInbox: widgetController != null ? widgetController.totalCountInbox : 0
function categoryListSelectionRequest(Index) {
if (widgetController != null) {
if (Index > -1) {
itemSelection.selectCategoryIndex(Index);
}
}
} //function categoryListSelectionRequest(Index)
onWidgetControllerChanged: {
if (widgetController != null) {
widgetController.requestWidgetControlToTakeFocus.connect(itemSelection.setFocusToSearchTextField);
widgetController.categoryListSelectionRequest.connect(root.categoryListSelectionRequest);
}
} //onWidgetControllerChanged
ColumnLayout {
id: searchResultLayout
anchors.fill: parent
spacing: TibiaStyle.marginRelated
visible: !root.showDetailList
MarketCategorySelection {
id: itemSelection
Layout.fillWidth: true
Layout.fillHeight: true
widgetLayout: true
useObjectCount: true
categoryViewHeight: TibiaStyle.cyclopediaObjectCategoryViewHeight
focusOnComboboxes: false
categoryModel: widgetController != null ? widgetController.categories : null
categoryItemModel: widgetController != null ? widgetController.appearanceTypeListModel : null
showLockerOnlyShouldBeChecked: widgetController != null && widgetController.showLockerOnly
enableTierAndClassificationSelection : widgetController != null ? widgetController.enableTierAndClassificationSelection : false
enableTierSelection : widgetController != null ? widgetController.enableTierSelection : false
availableTiers: widgetController != null ? widgetController.availableTiers : null
indexOfSelectedTier: widgetController != null ? widgetController.indexOfSelectedTier : -1
availableClassifications: widgetController != null ? widgetController.availableClassifications : null
indexOfSelectedClassification: widgetController != null ? widgetController.indexOfSelectedClassification : -1
npcFilterVisible: true
availableNPCs: widgetController != null ? widgetController.availableNPCs : null
indexOfSelectedNPC: widgetController != null ? widgetController.indexOfSelectedNPC : -1
Connections {
function onCategorySelected(CategoryIdentifier, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) {
widgetController != null ? widgetController.requestCategorySelect(CategoryIdentifier, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) : null
}
function onFilterSelected(NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) {
widgetController != null ? widgetController.requestNameSelect(NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) : null
}
function onItemSelected(AppearanceId, UpgradeTier) {
widgetController != null ? widgetController.requestItemSelect(AppearanceId, UpgradeTier) : null
}
function onItemChosen(AppearanceId, UpgradeTier) {
widgetController != null ? widgetController.requestItemChosen(AppearanceId, UpgradeTier) : null
}
function onItemClicked(AppearanceId, UpgradeTier, MouseButton, KeyboardModifiers) {
widgetController != null ? widgetController.onSearchedItemClicked(AppearanceId, UpgradeTier, MouseButton, KeyboardModifiers) : null
}
function onFocusEnteredTextInput() {
widgetController != null ? widgetController.takeFocus() : null
}
function onClassificationFilterWasSelected(CurrentIndex, NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) {
widgetController != null ? widgetController.onClassificationFilterWasSelected(CurrentIndex, NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) : null
}
function onTierFilterWasSelected(CurrentIndex, NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) {
widgetController != null ? widgetController.onTierFilterWasSelected(CurrentIndex, NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) : null
}
function onNpcFilterWasSelected(CurrentIndex, NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) {
widgetController != null ? widgetController.onNpcFilterWasSelected(CurrentIndex, NameFilter, FilterByLevel, FilterByVocation, OnlyOneHandWeapons, OnlyTwoHandWeapons, ShowLockerOnly) : null
}
function onAcceptedTextInput() {
if(widgetController != null && itemSelection.hasSelectedItem) {
widgetController.requestSearch();
}
} //onAcceptedTextInput
function onEscPressedInSearchTextField() {
widgetController != null ? widgetController.releaseFocus() : null
}
} //Connections
} // MarketCategorySelection
RowLayout {
Layout.fillWidth: true
Layout.bottomMargin: TibiaStyle.marginNarrow
Layout.leftMargin: TibiaStyle.marginNarrow
Layout.rightMargin: TibiaStyle.marginNarrow
spacing: TibiaStyle.marginRelated
Item { Layout.fillWidth: true }
TibiaButton {
Layout.preferredHeight: TibiaStyle.buttonHeightDefault
Layout.preferredWidth: Layout.preferredHeight
imageSource: "/images/icon-refresh.png"
tooltipText: qsTrId("depot_search_refresh_tooltip")
onClicked: widgetController != null ? widgetController.requestRefresh() : undefined
} //TibiaButton
TibiaButton {
Layout.preferredHeight: TibiaStyle.buttonHeightDefault
Layout.preferredWidth: Layout.preferredHeight
imageSource: "/images/icon-displayresults.png"
tooltipText: qsTrId("depot_search_search_tooltip")
enabled: itemSelection.hasSelectedItem
onClicked: widgetController != null ? widgetController.requestSearch() : undefined
TibiaDisabledOverlay {
anchors.fill: parent
anchors.margins: 1
visible: !parent.enabled
} //TibiaDisabledOverlay
} //TibiaButton
} //RowLayout
} //ColumnLayout
ColumnLayout {
id: detailListLayout
anchors.fill: parent
spacing: TibiaStyle.marginNarrow
visible: root.showDetailList
ColumnLayout {
spacing: TibiaStyle.marginRelated
Layout.leftMargin: TibiaStyle.marginNarrow
Layout.rightMargin: TibiaStyle.marginNarrow
TibiaText {
Layout.fillWidth: true
text: widgetController != null ? widgetController.detailListObjectName : qsTrId("unknown")
} //TibiaText
GridLayout {
Layout.fillWidth: true
columns: 3
rowSpacing: TibiaStyle.marginNarrow
columnSpacing: TibiaStyle.marginRelated
ButtonGroup {
id: storageLocationExlusiveGroup
//property int useObjectTypeEnumId: 0
checkedButton: {
if (root.totalCountDepot > 0) {
return depotButton;
} else if (root.totalCountStash > 0) {
return stashButton;
} else if (root.totalCountInbox > 0) {
return inboxButton;
}
return depotButton;
} //checkedButton
property int selectedButtonIndex: {
if (storageLocationExlusiveGroup.checkedButton == depotButton) {
return 0;
} else if (storageLocationExlusiveGroup.checkedButton == stashButton) {
return 1;
} else if (storageLocationExlusiveGroup.checkedButton == inboxButton) {
return 2;
}
return 0;
}
} //ButtonGroup
TibiaButton {
id: depotButton
Layout.fillWidth: true
Layout.preferredHeight: TibiaStyle.buttonHeightAppearance
imageSource: "/images/icon-depot.png"
tooltipText: qsTrId("depot_search_storage_location_tooltip").arg(qsTrId("depot"))
ButtonGroup.group: storageLocationExlusiveGroup
checkable: true
enabled: root.totalCountDepot > 0
TibiaDisabledOverlay {
anchors.fill: parent
anchors.margins: 1
visible: !parent.enabled
} //TibiaDisabledOverlay
} //TibiaButton
TibiaButton {
id: stashButton
Layout.fillWidth: true
Layout.preferredHeight: TibiaStyle.buttonHeightAppearance
imageSource: "/images/icon-supplystash.png"
tooltipText: qsTrId("depot_search_storage_location_tooltip").arg(qsTrId("stash"))
ButtonGroup.group: storageLocationExlusiveGroup
checkable: true
enabled: root.totalCountStash > 0
TibiaDisabledOverlay {
anchors.fill: parent
anchors.margins: 1
visible: !parent.enabled
} //TibiaDisabledOverlay
} //TibiaButton
TibiaButton {
id: inboxButton
Layout.fillWidth: true
Layout.preferredHeight: TibiaStyle.buttonHeightAppearance
imageSource: "/images/icon-inbox.png"
tooltipText: qsTrId("depot_search_storage_location_tooltip").arg(qsTrId("inbox"))
ButtonGroup.group: storageLocationExlusiveGroup
checkable: true
enabled: root.totalCountInbox > 0
TibiaDisabledOverlay {
anchors.fill: parent
anchors.margins: 1
visible: !parent.enabled
} //TibiaDisabledOverlay
} //TibiaButton
TibiaText {
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
text: widgetController != null ? widgetController.totalCountDepotString : "0"
tooltipText: (root.totalCountDepot == 1 ? qsTrId("depot_search_storage_location_count_tooltip_singular")
: qsTrId("depot_search_storage_location_count_tooltip").arg(TextHelper.formatNumberWithThousandSeparators(root.totalCountDepot)))
.arg(qsTrId("depot"))
} //TibiaText
TibiaText {
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
text: widgetController != null ? widgetController.totalCountStashString : "0"
tooltipText: (root.totalCountStash == 1 ? qsTrId("depot_search_storage_location_count_tooltip_singular")
: qsTrId("depot_search_storage_location_count_tooltip").arg(TextHelper.formatNumberWithThousandSeparators(root.totalCountStash)))
.arg(qsTrId("stash"))
} //TibiaText
TibiaText {
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
text: widgetController != null ? widgetController.totalCountInboxString : "0"
tooltipText: (root.totalCountInbox == 1 ? qsTrId("depot_search_storage_location_count_tooltip_singular")
: qsTrId("depot_search_storage_location_count_tooltip").arg(TextHelper.formatNumberWithThousandSeparators(root.totalCountInbox)))
.arg(qsTrId("inbox"))
} //TibiaText
} //Grid
} //ColumnLayout
MouseArea {
id: detailListView
Layout.fillHeight: true
Layout.fillWidth: true
//for some reason the preferredHeight of depotInboxView is used as minimumHeight which is not correct
//Layout.minimumHeight: containerContent.Layout.minimumHeight
Layout.minimumHeight: TibiaStyle.widgetWithScrollBarMinContentHeight
acceptedButtons: Qt.LeftButton
property bool slotContainsDrag: false
Rectangle {
id: highlightBorder
anchors.fill: parent
color: "transparent"
border.color: "red"
border.width: 1
z: 999
visible: dropArea.containsDrag || detailListView.slotContainsDrag
} //Rectangle
TibiaObjectDropArea {
id: dropArea
anchors.fill: parent
onEntered: {
if (widgetController != null) {
widgetController.emptySlotAreaEntered();
}
} //onEntered
onExited: {
if (widgetController != null) {
widgetController.emptySlotAreaExited();
}
} //onExited
TibiaScrollView {
id: containerScrollView
anchors.fill: parent
Flickable {
id: flickContent
interactive: false //prevent flick behavior on touch screens
boundsBehavior: Flickable.StopAtBounds
contentHeight: containerContent.height
contentWidth: parent.width
ColumnLayout {
id: containerContent
spacing: 0
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: TibiaStyle.containerContentLeftMargin
ListView {
id: stashView
Layout.fillWidth: true
Layout.minimumHeight: TibiaStyle.containerSlotSize
spacing: TibiaStyle.containerSlotsMargin
visible: storageLocationExlusiveGroup.checkedButton == stashButton
boundsBehavior: Flickable.StopAtBounds
interactive: false //prevent flick behavior on touch screens
highlightFollowsCurrentItem: false
model: widgetController != null ? widgetController.stashAppearanceTypeListModel : null
delegate: RowLayout {
spacing: TibiaStyle.marginRelated
ContainerSlot {
slotID: model.typeID
slotText: model.countString
slotTooltip: model.countAndNameTooltip
objectAppearanceInstanceTypeId: model.displayTypeID
objectAppearanceInstanceCumulativeCount: model.cumulativeCount
objectAppearanceInstanceUpgradeTier: model.upgradeTier
lootvalueImageSourceUnderItem: model.lootvalueImageSourceUnderItem
lootvalueImageSourceOverItem: model.lootvalueImageSourceOverItem
acceptsDrop: true
isUpdatable: false
mouseAreaEnabled: true
onDragDropped: { }
onContainsDragChanged: {
detailListView.slotContainsDrag = containsDrag;
} //onContainsDragChanged
Component.onCompleted: {
clicked.connect(stashSlotClicked);
} //Component.onCompleted
function stashSlotClicked(SlotID, MouseButton, KeyboardModifier) {
if (widgetController != null) {
widgetController.slotClicked(1, SlotID, MouseButton, KeyboardModifier);
}
} //function stashSlotClicked
} //ContainerSlot
TibiaButton {
Layout.preferredWidth: TibiaStyle.buttonWidthWide
text: qsTrId("selectamount_retrieve_caption")
onClicked: {
if (widgetController != null) {
widgetController.requestRetrieveFromStash(model.typeID);
}
} //onClicked
} //TibiaButton
} //delegate: RowLayout
} //ListView
GridView {
id: depotInboxView
Layout.fillWidth: true
Layout.minimumHeight: TibiaStyle.containerSlotSize
Layout.preferredHeight: contentHeight
visible: storageLocationExlusiveGroup.checkedButton == depotButton
|| storageLocationExlusiveGroup.checkedButton == inboxButton
cellWidth: TibiaStyle.containerSlotSize + TibiaStyle.containerSlotsMargin
cellHeight: cellWidth
interactive: false //prevent flick behavior on touch screens
boundsBehavior: Flickable.StopAtBounds
model: {
if (widgetController != null) {
if(storageLocationExlusiveGroup.checkedButton == depotButton) {
return widgetController.depotAppearanceTypeListModel;
} else if (storageLocationExlusiveGroup.checkedButton == inboxButton) {
return widgetController.inboxAppearanceTypeListModel;
}
}
return null;
} //model
delegate: ContainerSlot {
slotID: index
slotText: model.cumulativeCount > 1 ? model.cumulativeCount : ""
objectAppearanceInstanceTypeId: model.typeID
objectAppearanceInstanceCumulativeCount: model.cumulativeCount
objectAppearanceInstanceUpgradeTier: model.upgradeTier
lootvalueImageSourceUnderItem: model.lootvalueImageSourceUnderItem
lootvalueImageSourceOverItem: model.lootvalueImageSourceOverItem
objectAppearanceInstanceLiquidType: model.liquideType
objectAppearanceInstanceHookDirection: model.hookDirection
managedContainerTooltipText: model.managedContainerTooltip
acceptsDrop: objectAppearanceInstanceTypeId != 0
isUpdatable: false
mouseAreaEnabled: true
onDragDropped: { }
onContainsDragChanged: {
detailListView.slotContainsDrag = containsDrag;
} //onContainsDragChanged
Component.onCompleted: {
clicked.connect(slotClicked);
entered.connect(slotEntered);
exited.connect(slotExited);
startDrag.connect(slotStartDrag);
//dragDropped.connect(slotDragDropped);
targetSelected.connect(slotTargetSelected);
} //Component.onCompleted
function slotClicked(SlotID, MouseButton, KeyboardModifier) {
if (widgetController != null) {
widgetController.slotClicked(storageLocationExlusiveGroup.selectedButtonIndex,
SlotID,
MouseButton,
KeyboardModifier);
}
} //function slotClicked
function slotEntered(SlotID) {
if (widgetController != null) {
widgetController.slotEntered(storageLocationExlusiveGroup.selectedButtonIndex,
SlotID);
}
} //function slotEntered
function slotExited(SlotID) {
if (widgetController != null) {
widgetController.slotExited(storageLocationExlusiveGroup.selectedButtonIndex,
SlotID);
}
} //function slotExited
function slotStartDrag(SlotID, Source) {
if (widgetController != null) {
widgetController.slotStartDrag(storageLocationExlusiveGroup.selectedButtonIndex,
SlotID,
Source);
}
} //function slotStartDrag
function slotTargetSelected(SlotID) {
if (widgetController != null) {
widgetController.slotTargetSelected(storageLocationExlusiveGroup.selectedButtonIndex,
SlotID);
}
} //function slotTargetSelected
} //delegate: ContainerSlot
} //GridView
} //ColumnLayout
} //Flickable
} //TibiaScrollView
} //TibiaObjectDropArea
} //MouseArea
Item {
Layout.preferredWidth: retrieveFromDepotInboxButton.width
Layout.preferredHeight: retrieveFromDepotInboxButton.height
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: TibiaStyle.marginNarrow
TibiaButton {
id: retrieveFromDepotInboxButton
width: TibiaStyle.buttonWidthWidest
text: qsTrId("depot_search_retrieve_displayed")
visible: storageLocationExlusiveGroup.checkedButton == depotButton
|| storageLocationExlusiveGroup.checkedButton == inboxButton
enabled: widgetController != null && widgetController.isAppearanceAllowedToRetrieve
&& ( storageLocationExlusiveGroup.checkedButton == depotButton && root.totalCountDepot > 0
|| storageLocationExlusiveGroup.checkedButton == inboxButton && root.totalCountInbox > 0)
onClicked: {
if (widgetController != null) {
widgetController.requestRetrieveFromDepotInbox(storageLocationExlusiveGroup.selectedButtonIndex);
}
} //onClicked
} //TibiaButton
Tooltip {
anchors.fill: parent
enabled: !retrieveFromDepotInboxButton.enabled && widgetController != null && !widgetController.isAppearanceAllowedToRetrieve
text: qsTrId("depot_search_no_containers_tooltip")
} //Tooltip
} //Item
} //ColumnLayout
Lenshelp {
anchors.fill: parent
triggerRect: mapFromItem(widgetRoot, 0, 0, widgetRoot.width, widgetRoot.height)
caption: qsTrId("depot_search_lenshelp_caption")
content: qsTrId("depot_search_lenshelp")
} //Lenshelp
} //TibiaSidebarWidget