-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHousesInfoDialog.qml
More file actions
1989 lines (1655 loc) · 81.8 KB
/
HousesInfoDialog.qml
File metadata and controls
1989 lines (1655 loc) · 81.8 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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qmlcomponents
Item {
id: root
property var controller: null
property bool needsTabNavigation: false
readonly property var currentModel: housesListView.currentItem != null && housesListView.currentItem.modelData != null ? housesListView.currentItem.modelData : null
property var activeActionType: TibiaEnums.HouseActionNone
property alias currentLayer: mapLayersSlider.currentLayer
property int minimumHouseLayer : controller != null ? controller.minimumHouseLayer : 0
property int maximumHouseLayer : controller != null ? controller.maximumHouseLayer : 0
readonly property var _currentHouseId: controller != null ? controller.currentHouseId : 0
readonly property var _houseValid: _currentHouseId != 0;
readonly property var lastServerSave: controller != null ? controller.lastServerSave : new Date()
readonly property var in30DaysDate: {
if (controller != null) {
return controller.in30DaysServerSave;
} else {
var date = new Date();
date.setDate(date.getDate() + 30);
return date;
}
} //readonly property var in30DaysDate
property var initialFocusItem: housesListView
KeyNavigation.tab: housesListView
KeyNavigation.backtab: housesListView
onControllerChanged: {
if (controller != null) {
controller.setHouseWorldMapQuickItem(houseView);
controller.setHouseCameraViewport(cameraViewport);
}
} //onControllerChanged
Connections {
target: root.controller
function onHouseActionConfirmed() {
root.activeActionType = TibiaEnums.HouseActionNone;
} //function onHouseActionConfirmed()
} // Connections
onActiveActionTypeChanged: {
root.needsTabNavigation = false;
if (root.activeActionType == TibiaEnums.HouseActionNone) {
housesListView.forceActiveFocus();
}
} //onActiveActionTypeChanged
onCurrentModelChanged: {
root.activeActionType = TibiaEnums.HouseActionNone;
} //onCurrentModelChanged
onCurrentLayerChanged: {
if (controller) {
cameraViewport.translateToLayer(currentLayer);
}
} //onCurrentLayerChanged
function getHouseActionName(HouseAction)
{
if (HouseAction == TibiaEnums.HouseActionBid) {
return qsTrId("houses_action_name_bid");
} else if (HouseAction == TibiaEnums.HouseActionMoveOut) {
return qsTrId("houses_action_name_move_out");
} else if (HouseAction == TibiaEnums.HouseActionCancelMoveOut) {
return qsTrId("houses_action_name_cancel_move_out");
} else if (HouseAction == TibiaEnums.HouseActionTransfer) {
return qsTrId("houses_action_name_transfer");
} else if (HouseAction == TibiaEnums.HouseActionCancelTransfer) {
return qsTrId("houses_action_name_cancel_transfer");
} else if (HouseAction == TibiaEnums.HouseActionAcceptTransfer) {
return qsTrId("houses_action_name_accept_transfer");
} else if (HouseAction == TibiaEnums.HouseActionRejectTransfer) {
return qsTrId("houses_action_name_reject_transfer");
}
return qsTrId("dummy_unknown");
} //function getHouseActionName()
ColumnLayout {
anchors.fill: parent
anchors.bottomMargin: TibiaStyle.marginRelated;
spacing: TibiaStyle.marginRelated
TibiaFrame2PixelUpFilled {
Layout.fillWidth: true
Layout.preferredHeight: filterLayout.height + 2 * marginsToContent
ColumnLayout {
id: filterLayout
anchors { left: parent.left; top: parent.top; right: parent.right }
anchors.margins: parent.marginsToContent
spacing: TibiaStyle.marginRelated
RowLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginRelated
TibiaComboBox {
id: townFilterComboBox
Layout.fillWidth: true
model: controller != null ? controller.townFilterModel : null
shouldBeCurrentIndex: controller != null ? controller.townFilterCurrentIndex : 0
onCurrentTextChanged: {
if (controller != null && model != null && !controller.disableQmlSelect) {
controller.setTownFilter(currentText);
}
} //onCurrentTextChanged
} //TibiaComboBox
TibiaComboBox {
id: stateFitlerComboBox
Layout.fillWidth: true
model: controller != null ? controller.statesFitlerModel : null
textRole: "text"
shouldBeCurrentIndex: controller != null ? controller.stateFilterCurrentIndex : 0
onCurrentTextChanged:{
if (controller != null && model != null && !controller.disableQmlSelect) {
controller.setStateFilter(model[stateFitlerComboBox.currentIndex].state);
}
} //onCurrentTextChanged
} //TibiaComboBox
TibiaComboBox {
id: sortOrderComboBox
Layout.fillWidth: true
model: controller != null ? controller.sortOrderModel : null
textRole: "text"
shouldBeCurrentIndex: controller != null ? controller.sortOrderCurrentIndex : 0
onCurrentTextChanged: {
if (controller != null && model != null && !controller.disableQmlSelect) {
controller.setSortOrder(model[sortOrderComboBox.currentIndex].sortOrder);
}
} //onCurrentTextChanged
} //TibiaComboBox
} //RowLayout
RowLayout {
spacing: TibiaStyle.marginRelated
Layout.alignment: Qt.AlignHCenter
ButtonGroup {
id: houseTypeGroup
property var houseType: TibiaEnums.HouseTypeHouseOrFlat
checkedButton: {
if (controller != null) {
if (controller.houseType == TibiaEnums.HouseTypeHouseOrFlat) {
return houseOrFlatRadioButton;
} else if (controller.houseType == TibiaEnums.HouseTypeGuildHall) {
return guildHallRadioButton;
}
}
return houseOrFlatRadioButton;
} //current
onCheckedButtonChanged: {
if (controller != null) {
if (checkedButton == houseOrFlatRadioButton) {
controller.setHouseTypeFilter(TibiaEnums.HouseTypeHouseOrFlat);
} else if (checkedButton == guildHallRadioButton) {
controller.setHouseTypeFilter(TibiaEnums.HouseTypeGuildHall);
} else {
controller.setHouseTypeFilter(TibiaEnums.HouseTypeHouseOrFlat);
}
}
} //onCurrentChanged
} //ButtonGroup
TibiaRadioButton {
id: houseOrFlatRadioButton
text: qsTrId("houses_filter_houses_flats")
ButtonGroup.group: houseTypeGroup
} //TibiaRadioButton
TibiaRadioButton {
id: guildHallRadioButton
text: qsTrId("houses_filter_guildhalls")
ButtonGroup.group: houseTypeGroup
} //TibiaRadioButton
} //RowLayout
} //ColumnLayout
} //TibiaFrame2PixelUpFilled
RowLayout {
spacing: TibiaStyle.marginRelated
Layout.fillHeight: true
TibiaFrame2PixelUpFilled {
Layout.fillHeight: true
Layout.preferredWidth: 250
Layout.maximumWidth: Layout.preferredWidth
ColumnLayout {
id: columnWrapper
anchors.fill: parent
anchors.margins: parent.marginsToContent
spacing: TibiaStyle.marginRelated
RowLayout {
Layout.fillWidth: true
Layout.preferredHeight: 212
Layout.minimumHeight: Layout.preferredHeight
Layout.maximumHeight: Layout.preferredHeight
spacing: TibiaStyle.marginRelated
TibiaFrame1PixelDown {
Layout.fillWidth: true
Layout.fillHeight: true
Rectangle {
anchors.fill: parent
color: "black"
anchors.margins: parent.borderWidth
Item {
anchors.fill: parent
clip: true
MinimapRenderer {
id: minimapRenderer
anchors.fill: parent
opacity: 0.8
showAreaCaptions: false
visible: _houseValid
}
WorldMap {
id: houseView
anchors.fill: parent
smoothTextureFiltering: true
onWidthChanged: cameraViewport.setSize();
onHeightChanged: cameraViewport.setSize();
visible: _houseValid
WorldMapCameraViewport {
id: cameraViewport
function setSize() {
size = Qt.size(houseView.width, houseView.height);
}
onVolumeChanged: {
}
Component.onCompleted: {
cameraViewport.scaleFactor = cameraViewportMouseArea.targetScaleFactor;
}
onViewportChanged: {
var coordinate = cameraViewport.centerSubfieldCoordinate;
if (root.currentLayer != coordinate.z) {
root.currentLayer = coordinate.z;
}
if (scaleFactorPropertyAnimation.running == false) {
scaleFactorAnimation.enabled = false;
cameraViewportMouseArea.targetScaleFactor = cameraViewport.scaleFactor;
scaleFactorAnimation.enabled = true;
}
var currentCoordinate = cameraViewport.centerLayerTopLeftSubfieldCoordinate;
minimapRenderer.camera.topLeftSubfieldCoordinate = currentCoordinate;
minimapRenderer.camera.scaleFactor = cameraViewport.scaleFactor;
if (currentCoordinate.z > 7) {
minimapRenderer.tileType = MinimapRenderer.LocalMinimap;
} else {
minimapRenderer.tileType = MinimapRenderer.Satellite;
}
minimapRenderer.update();
}
}
MouseArea {
id: cameraViewportMouseArea
property var zoomCoordinate: null
property var zoomSubfieldCoordinate: null
property var clickCoordinate: null
property var clickSubfieldCoordinate: null
property bool mapMoved: false
property double targetScaleFactor: 0.5
property double tempScaleFactor: targetScaleFactor
anchors.fill: parent
Behavior on tempScaleFactor {
id: scaleFactorAnimation
enabled: true
PropertyAnimation {
id: scaleFactorPropertyAnimation
duration: 250
}
}
onTempScaleFactorChanged: {
cameraViewport.scaleFactor = tempScaleFactor;
if (zoomCoordinate != null && zoomSubfieldCoordinate != null) {
cameraViewport.moveWorldMapSubfieldCoordinateToStretchedPixelCoordinate(zoomSubfieldCoordinate, zoomCoordinate);
}
}
function changeLayer(direction, x, y) {
var addValue = direction;
if (direction > 0) {
addValue = -1;
} else if (direction < 0) {
addValue = 1;
}
root.currentLayer = Math.min(15, Math.max(0, root.currentLayer + addValue));
}
function changeZoom(direction, x, y) {
zoomCoordinate = Qt.point(x,y);
zoomSubfieldCoordinate = cameraViewport.convertToWorldMapSubfieldCoordinate(zoomCoordinate);
var multiplyValue = 0;
if (direction > 0) {
multiplyValue = 2.0;
} else if (direction < 0) {
multiplyValue = 0.5;
}
targetScaleFactor = Math.max(Math.min(targetScaleFactor * multiplyValue, 1.0), 1.0 / 16.0);
}
onPressed: (mouse) => {
clickCoordinate = Qt.point(mouse.x, mouse.y);
clickSubfieldCoordinate = cameraViewport.convertToWorldMapSubfieldCoordinate(clickCoordinate);
mapMoved = false;
} //onPressed
onReleased: {
clickCoordinate = null;
} //onReleased
onPositionChanged: (mouse) => {
if (clickCoordinate !== null) {
var mouseDistance = Qt.point((clickCoordinate.x - mouse.x), (clickCoordinate.y - mouse.y));
if (mapMoved == true || Math.abs(mouseDistance.x) > 3 || Math.abs(mouseDistance.y) > 3) {
mouseDistance = Qt.point(mouseDistance.x, mouseDistance.y)
cameraViewport.moveWorldMapSubfieldCoordinateToStretchedPixelCoordinate(clickSubfieldCoordinate, Qt.point(mouse.x, mouse.y));
mapMoved = true;
}
}
mouse.accepted = false;
} //onPositionChanged
onWheel: (wheel) => {
if (wheel.modifiers & Qt.ShiftModifier) {
changeLayer(wheel.angleDelta.y, wheel.x, wheel.y);
} else {
changeZoom(wheel.angleDelta.y, wheel.x, wheel.y);
}
} //onWheel
}
}
}
Loader {
anchors.centerIn: parent
z: 100
sourceComponent: root.currentModel != null ? undefined : noHouseSelectedComponent
Component {
id: noHouseSelectedComponent
TibiaText {
text: qsTrId("houses_no_house_selected")
} //TibiaText
} //Component
} //Loader
} //Rectangle
} //TibiaFrame1PixelDown
ColumnLayout {
id: mapControlsWrapper
Layout.alignment: Qt.AlignVCenter
spacing: TibiaStyle.marginRelated
ColumnLayout {
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
spacing: TibiaStyle.marginRelated
TibiaMinimapRose {
id: minimapRose
timeOfDayNormalized: controller != null ? controller.timeOfDayNormalized : 0.0
onMouseButtonClicked: (offsetX, offsetY) => {
if (offsetX == 0 && offsetY == 0) {
if (controller != null) {
controller.centerHouse();
}
} else {
var offset = Qt.point(-offsetX * 10, -offsetY * 10);
var clickSubfieldCoordinate = cameraViewport.convertToWorldMapSubfieldCoordinate(Qt.point(0,0));
cameraViewport.moveWorldMapSubfieldCoordinateToStretchedPixelCoordinate(clickSubfieldCoordinate, offset);
}
} //onMouseButtonClicked
} //TibiaMinimapRose
RowLayout {
Layout.maximumWidth: minimapRose.width
Layout.topMargin: -4
ColumnLayout {
id: buttonsWrapper
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
spacing: 0
TibiaIconButton {
id: automap_button_zoomout
sourceUp: "/images/automap-button-zoomout-up.png"
sourceDown: "/images/automap-button-zoomout-down.png"
tooltipText: qsTrId("cyclopedia_map_zoom_out_tooltip")
onClicked: {
cameraViewportMouseArea.changeZoom(-1, cameraViewportMouseArea.width / 2, cameraViewportMouseArea.height / 2);
} //onClicked
} // TibiaIconButton
Item { Layout.fillWidth: true }
TibiaIconButton {
id: automap_button_zoomin
sourceUp: "/images/automap-button-zoomin-up.png"
sourceDown: "/images/automap-button-zoomin-down.png"
tooltipText: qsTrId("cyclopedia_map_zoom_in_tooltip")
onClicked: {
cameraViewportMouseArea.changeZoom(1, cameraViewportMouseArea.width / 2, cameraViewportMouseArea.height / 2);
} //onClicked
} // TibiaIconButton
TibiaIconButton {
id: goToCyclopediaMapButton
sourceUp: "/images/automap-button-cyclopediamap-up.png"
sourceDown: "/images/automap-button-cyclopediamap-down.png"
tooltipText: qsTrId("houses_details_show_on_map")
onClicked: {
if (controller != null) {
controller.showOnCyclopediaMap();
}
}//onClicked
} //TibiaIconButton
} // ColumnLayout
TibiaMapLayersSlider {
id: mapLayersSlider
minimumLayer: root.minimumHouseLayer
maximumLayer: root.maximumHouseLayer
noLayers: root.currentModel == null
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
tooltip: qsTrId("cyclopedia_map_change_layer_tooltip")
} //TibiaMapLayersSlider
} // RowLayout
} // ColumnLayout
} // RowLayout
}
RowLayout {
spacing: 0
Layout.bottomMargin: -(parent.spacing - TibiaStyle.marginNarrow)
TibiaText {
Layout.fillWidth: true
styleType: "WhiteCaption"
text: {
if (root.currentModel != null) {
if (root.currentModel.state == TibiaEnums.HouseStateAuctioned) {
return qsTrId("houses_state_auction_caption");
} else if (root.currentModel.state == TibiaEnums.HouseStateUnoccupied) {
return qsTrId("houses_state_empty_caption");
} else if (root.currentModel.state == TibiaEnums.HouseStateRented) {
return qsTrId("houses_state_rented_caption");
} else if (root.currentModel.state == TibiaEnums.HouseStateTransferPending) {
return qsTrId("houses_state_rented_caption");
} else if (root.currentModel.state == TibiaEnums.HouseStateMoveOutPending) {
return qsTrId("houses_state_rented_caption");
} else if (root.currentModel.state == TibiaEnums.HouseStateUnknown) {
return qsTrId("houses_state_updating_caption");
}
}
return "";
} //text
} //TibiaText
Image {
visible: root.currentModel != null && root.currentModel.isOwnHouse
source: "image://store-description-icons/5"
Tooltip {
anchors.fill: parent
text: qsTrId("houses_your_house_tooltip")
} //Tooltip
} //Image
Image {
visible: root.currentModel != null && root.currentModel.state == TibiaEnums.HouseStateTransferPending && root.currentModel.isOwnHouse
source: "image://store-description-icons/16"
Tooltip {
anchors.fill: parent
text: qsTrId("houses_outgoing_transfer_tooltip")
} //Tooltip
} //Image
Image {
visible: root.currentModel != null && root.currentModel.state == TibiaEnums.HouseStateTransferPending && root.currentModel.isHouseOfferedToMe
source: "image://store-description-icons/17"
Tooltip {
anchors.fill: parent
text: qsTrId("houses_incoming_transfer_tooltip")
} //Tooltip
} //Image
Image {
visible: root.currentModel != null && root.currentModel.isShop
source: "image://store-description-icons/15"
Tooltip {
anchors.fill: parent
text: qsTrId("houses_house_is_shop_tooltip")
} //Tooltip
} //Image
Image {
visible: root.currentModel != null && !root.currentModel.isRentable
source: "image://store-description-icons/18"
Tooltip {
anchors.fill: parent
text: qsTrId("houses_scheduled_for_renovation_toolitp")
} //Tooltip
} //Image
TibiaGuiHelp {
color: "orange"
visible: text.length > 0
text: root.currentModel != null ? root.currentModel.description : ""
} //TibiaGuiHelp
} //RowLayout
Loader {
id: detailsLoader
Layout.fillWidth: true
Layout.fillHeight: true
sourceComponent: {
if (root.currentModel != null) {
if (root.currentModel.state == TibiaEnums.HouseStateAuctioned) {
return auctionComponent;
} else if (root.currentModel.state == TibiaEnums.HouseStateUnoccupied) {
return unoccupiedComponent;
} else if (root.currentModel.state == TibiaEnums.HouseStateRented) {
return rentedComponent;
} else if (root.currentModel.state == TibiaEnums.HouseStateTransferPending) {
return transferPendingComponent;
} else if (root.currentModel.state == TibiaEnums.HouseStateMoveOutPending) {
return moveOutPendingComponent;
} else if (root.currentModel.state == TibiaEnums.HouseStateUnknown) {
return unknownComponent;
}
}
return undefined;
} //sourceComponent
Component {
id: auctionComponent
ColumnLayout {
id: auctionLayout
Layout.fillWidth: true
spacing: TibiaStyle.marginNarrow
TibiaText {
visible: root.currentModel != null && !root.currentModel.hasBids
Layout.fillWidth: true
wrapMode: Text.Wrap
text: qsTrId("houses_details_auction_no_bids")
} //TibiaText
TibiaKeyValueRowLayout {
visible: root.currentModel != null && root.currentModel.hasBids
key: qsTrId("houses_label_highest_bidder")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
value: root.currentModel != null ? root.currentModel.highestBidderName : ""
} //TibiaKeyValueRowLayout
TibiaKeyValueRowLayout {
visible: root.currentModel != null && root.currentModel.hasBids
key: qsTrId("houses_label_end_time")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
value: root.currentModel != null ? root.currentModel.auctionEndStringMulti : ""
} //TibiaKeyValueRowLayout
TibiaKeyValueRowLayout {
visible: root.currentModel != null && root.currentModel.hasBids
key: qsTrId("houses_label_highest_bid")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
readonly property var bid: root.currentModel != null ? root.currentModel.highestBid : 0
value: TextHelper.formatNumberWithThousandSeparatorsAndThousandShortcutsAsMultiString(bid)
valueAlignment: Text.AlignRight
Image {
source: "/images/icon-goldcoin.png"
} //Image
} //TibiaKeyValueRowLayout
TibiaKeyValueRowLayout {
visible: root.currentModel != null && root.currentModel.ownLimitSet
key: qsTrId("houses_label_your_limit")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
readonly property var limit: root.currentModel != null ? root.currentModel.ownBidLimit : 0
value: TextHelper.formatNumberWithThousandSeparatorsAndThousandShortcutsAsMultiString(limit)
valueAlignment: Text.AlignRight
Image {
source: "/images/icon-goldcoin.png"
} //Image
} //TibiaKeyValueRowLayout
Item {
Layout.topMargin: -parent.spacing
Layout.fillHeight: true
} //Item
RowLayout {
Layout.alignment: Qt.AlignRight
spacing: TibiaStyle.marginRelated
TibiaHouseActionButton {
text: root.getHouseActionName(TibiaEnums.HouseActionBid)
disabledReason: root.currentModel != null ? root.currentModel.disableBidReasonString : qsTrId("dummy_unknown")
onClicked: { root.activeActionType = TibiaEnums.HouseActionBid; }
} //TibiaHouseActionButton
} //RowLayout
} //ColumnLayout
} //Component
Component {
id: unoccupiedComponent
ColumnLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginNarrow
TibiaText {
Layout.fillWidth: true
wrapMode: Text.Wrap
text: qsTrId("houses_details_unoccupied")
} //TibiaText
Item {
Layout.topMargin: -parent.spacing
Layout.fillHeight: true
} //Item
} //ColumnLayout
} //Component
Component {
id: rentedComponent
ColumnLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginNarrow
TibiaKeyValueRowLayout {
key: qsTrId("houses_label_rentee")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
value: root.currentModel != null ? root.currentModel.renterName : ""
} //TibiaKeyValueRowLayout
TibiaKeyValueRowLayout {
key: qsTrId("houses_label_paid_until")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
value: root.currentModel != null ? root.currentModel.paidUntilStringMulti : ""
} //TibiaKeyValueRowLayout
Item {
visible: root.currentModel != null && root.currentModel.state == TibiaEnums.HouseStateRented
Layout.topMargin: -parent.spacing
Layout.fillHeight: true
} //Item
RowLayout {
Layout.alignment: Qt.AlignRight
visible: root.currentModel != null && root.currentModel.isOwnHouse && root.currentModel.state == TibiaEnums.HouseStateRented
spacing: TibiaStyle.marginRelated
TibiaHouseActionButton {
text: root.getHouseActionName(TibiaEnums.HouseActionMoveOut)
disabledReason: root.currentModel != null ? root.currentModel.disableMoveOutReasonString : qsTrId("dummy_unknown")
onClicked: { root.activeActionType = TibiaEnums.HouseActionMoveOut; }
} //TibiaHouseActionButton
TibiaHouseActionButton {
text: root.getHouseActionName(TibiaEnums.HouseActionTransfer)
disabledReason: root.currentModel != null ? root.currentModel.disableTransferReasonString : qsTrId("dummy_unknown")
onClicked: { root.activeActionType = TibiaEnums.HouseActionTransfer; }
} //TibiaHouseActionButton
} //RowLayout
} //ColumnLayout
} //Component
Component {
id: transferPendingComponent
ColumnLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginNarrow
Loader {
Layout.fillWidth: true
sourceComponent: rentedComponent
} //Loader
TibiaText {
Layout.fillWidth: true
Layout.topMargin: -(parent.spacing - TibiaStyle.marginRelated)
styleType: "WhiteCaption"
text: qsTrId("houses_state_transfer_pending_caption")
} //TibiaText
TibiaKeyValueRowLayout {
key: qsTrId("houses_label_new_owner")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
value: root.currentModel != null ? root.currentModel.newOwnerName : ""
} //TibiaKeyValueRowLayout
TibiaKeyValueRowLayout {
key: qsTrId("houses_label_date")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
value: root.currentModel != null ? root.currentModel.transferTimestampStringMulti : ""
} //TibiaKeyValueRowLayout
TibiaKeyValueRowLayout {
key: qsTrId("houses_label_price")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
readonly property var price: root.currentModel != null ? root.currentModel.transferPrice : 0
value: TextHelper.formatNumberWithThousandSeparatorsAndThousandShortcutsAsMultiString(price)
valueFillWidth: false
Image {
source: "/images/icon-goldcoin.png"
} //Image
} //TibiaKeyValueRowLayout
Item {
Layout.topMargin: -parent.spacing
Layout.fillHeight: true
} //Item
RowLayout {
Layout.alignment: Qt.AlignRight
visible: root.currentModel != null && (root.currentModel.isOwnHouse || root.currentModel.isHouseOfferedToMe)
spacing: TibiaStyle.marginRelated
TibiaHouseActionButton {
Layout.preferredWidth: TibiaStyle.buttonWidthWide
text: root.getHouseActionName(TibiaEnums.HouseActionCancelTransfer)
visible: root.currentModel != null && root.currentModel.isOwnHouse
disabledReason: root.currentModel != null ? root.currentModel.disableCancelTransferReasonString : qsTrId("dummy_unknown")
onClicked: { root.activeActionType = TibiaEnums.HouseActionCancelTransfer; }
} //TibiaHouseActionButton
TibiaHouseActionButton {
Layout.preferredWidth: TibiaStyle.buttonWidthWide
text: root.getHouseActionName(TibiaEnums.HouseActionAcceptTransfer)
visible: root.currentModel != null && root.currentModel.isHouseOfferedToMe
disabledReason: root.currentModel != null ? root.currentModel.disableAcceptTransferReasonString : qsTrId("dummy_unknown")
onClicked: { root.activeActionType = TibiaEnums.HouseActionAcceptTransfer; }
} //TibiaHouseActionButton
TibiaHouseActionButton {
Layout.preferredWidth: TibiaStyle.buttonWidthWide
text: root.getHouseActionName(TibiaEnums.HouseActionRejectTransfer)
visible: root.currentModel != null && root.currentModel.isHouseOfferedToMe
disabledReason: root.currentModel != null ? root.currentModel.disableRejectTransferReasonString : qsTrId("dummy_unknown")
onClicked: { root.activeActionType = TibiaEnums.HouseActionRejectTransfer; }
} //TibiaHouseActionButton
} //RowLayout
} //ColumnLayout
} //Component
Component {
id: moveOutPendingComponent
ColumnLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginNarrow
Loader {
Layout.fillWidth: true
sourceComponent: rentedComponent
} //Loader
TibiaText {
Layout.fillWidth: true
Layout.topMargin: -(parent.spacing - TibiaStyle.marginRelated)
styleType: "WhiteCaption"
text: qsTrId("houses_state_move_out_pending_caption")
} //TibiaText
TibiaKeyValueRowLayout {
key: qsTrId("houses_label_date")
keyTextWidth: TibiaStyle.propertyInformationKeyWidth
value: root.currentModel != null ? root.currentModel.moveOutTimestampStringMulti : ""
} //TibiaKeyValueRowLayout
Item {
Layout.topMargin: -parent.spacing
Layout.fillHeight: true
} //Item
RowLayout {
Layout.alignment: Qt.AlignRight
visible: root.currentModel != null && root.currentModel.isOwnHouse
spacing: TibiaStyle.marginRelated
TibiaHouseActionButton {
Layout.preferredWidth: TibiaStyle.buttonWidthWide
text: root.getHouseActionName(TibiaEnums.HouseActionCancelMoveOut)
disabledReason: root.currentModel != null ? root.currentModel.disableCancelMoveOutReasonString : qsTrId("dummy_unknown")
onClicked: { root.activeActionType = TibiaEnums.HouseActionCancelMoveOut; }
} //TibiaHouseActionButton
} //RowLayout
} //ColumnLayout
} //Component
Component {
id: unknownComponent
ColumnLayout {
Layout.fillWidth: true
spacing: TibiaStyle.marginNarrow
TibiaText {
Layout.fillWidth: true
wrapMode: Text.Wrap
text: qsTrId("houses_details_updating").arg(qsTrId("refresh"))
} //TibiaText
Item {
Layout.topMargin: -parent.spacing
Layout.fillHeight: true
} //Item
} //ColumnLayout
} //Component
} //Loader
} // ColumnLayout
} //TibiaFrame2PixelUpFilled
TibiaFrame1PixelDown {
Layout.fillHeight: true
Layout.fillWidth: true
visible: !actionDetailsView.visible
Loader {
anchors.centerIn: parent
sourceComponent: housesListView.visible ? undefined : noResultsComponent
Component {
id: noResultsComponent
TibiaText {
text: qsTrId("noresults")
} //TibiaText
} //Component
} //Loader
TibiaScrollView {
anchors.fill: parent
anchors.margins: parent.borderWidth
visible: housesListView.count > 0
contentWidth: housesListView.width - TibiaStyle.marginNarrow * 2
ListView {
id: housesListView
leftMargin: TibiaStyle.marginNarrow
rightMargin: TibiaStyle.marginNarrow
topMargin: TibiaStyle.marginNarrow
bottomMargin: 0
model: controller != null ? controller.housesModel : null
boundsBehavior: Flickable.StopAtBounds
interactive: false //prevent flick behavior on touch screens
highlightMoveDuration: 0
Keys.onUpPressed: (event) => {
var oldIndex = housesListView.currentIndex;
housesListView.decrementCurrentIndex();
if (oldIndex === housesListView.currentIndex) {
event.accepted = false;
}
} //Keys.onUpPressed
Keys.onDownPressed: (event) => {
var oldIndex = housesListView.currentIndex;
housesListView.incrementCurrentIndex();
if (oldIndex === housesListView.currentIndex) {
event.accepted = false;
}
} //Keys.onDownPressed
onCurrentIndexChanged: {
if (controller != null) {
if (currentItem != null ) {
controller.selectHouse(housesListView.currentItem.modelData.houseId);
} else if (housesListView.currentIndex == -1 && housesListView.count > 0 && !controller.disableQmlSelect) {
selectFirstDelayed.restart();
} else if(_currentHouseId != 0 && !controller.disableQmlSelect) {
controller.selectHouse(0);
selectFirstDelayed.stop()
}
}
} //onCurrentIndexChanged
Timer {
id: selectFirstDelayed
property bool enabled: controller != null && !controller.disableQmlSelect
onEnabledChanged: {
if (!enabled) {
stop();
}
} //onEnabledChanged
repeat: false
interval: 1
onTriggered: {
if (enabled) {
housesListView.currentIndex = 0;
}
} //onTriggered
} //Timer
//type var is important, otherwise not all changes signals are forwarded, using int and changing to the same value would not trigger onChanged
readonly property var _currentHouseId: controller != null ? controller.currentHouseId : 0
on_CurrentHouseIdChanged: {
if (housesListView.model != null) {
for (var i=0; i < housesListView.count; i++) {
var idx = housesListView.model.index(i, 0);
var value = housesListView.model.data(idx, housesListView.model.houseIdEnumValue);
if (value == housesListView._currentHouseId) {
housesListView.currentIndex = i;
return;
}
}
}
housesListView.currentIndex = -1;
currentIndexChanged(); //make sure that onCurrentIndexChanged is triggered to select the first entry if needed
} //on_CurrentHouseIdChanged
Component {
id: headerFooterComponent
Item {
anchors.left: parent != null ? parent.left : undefined
anchors.right: parent != null ? parent.right : undefined
height: TibiaStyle.marginNarrow
} //header: Item
} //Component
//header: count > 0 ? headerFooterComponent : null //does break the scroll bar if there are not enough entries to scroll
footer: count > 0 ? headerFooterComponent : null
spacing: 1 //with the borders of the adjacent etnries this is TibiaStyle.marginRelated
delegate: Rectangle {
id: delegateRoot
property int houseID: model.houseId
anchors { left: parent ? parent.left : undefined; right: parent ? parent.right : undefined }
readonly property int frameBorderWidth: TibiaStyle.marginNarrow
height: contentFrame.height + 2 * frameBorderWidth
color: "transparent"
border.width: housesListView.currentIndex == index ? frameBorderWidth : 0
border.color: "white"
readonly property var modelData: model
TibiaDialogFrameWithCaption {
id: contentFrame
anchors { left: parent.left; top: parent.top; right: parent.right }
anchors.margins: delegateRoot.frameBorderWidth
borderToContentMargin: delegateRoot.frameBorderWidth
height: contentLayout.height + topMarginToContent + marginsToContent
caption: model.name
ColumnLayout {
id: contentLayout