mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 07:53:08 +02:00
Case 21118 - descending sorts don't work in new (qml) marketplace
This commit is contained in:
parent
7204a0c5c8
commit
a82221d2a5
4 changed files with 72 additions and 59 deletions
|
@ -31,8 +31,9 @@ Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string activeView: "initialize"
|
property string activeView: "initialize"
|
||||||
property int currentSortIndex: 0
|
property int currentSortIndex: 1
|
||||||
property string sortString: "recent"
|
property string sortString: "recent"
|
||||||
|
property bool isAscending: false
|
||||||
property string categoryString: ""
|
property string categoryString: ""
|
||||||
property string searchString: ""
|
property string searchString: ""
|
||||||
property bool keyboardEnabled: HMD.active
|
property bool keyboardEnabled: HMD.active
|
||||||
|
@ -503,6 +504,7 @@ Rectangle {
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
root.sortString,
|
root.sortString,
|
||||||
|
root.isAscending,
|
||||||
WalletScriptingInterface.limitedCommerce,
|
WalletScriptingInterface.limitedCommerce,
|
||||||
marketBrowseModel.currentPageToRetrieve,
|
marketBrowseModel.currentPageToRetrieve,
|
||||||
marketBrowseModel.itemsPerPage
|
marketBrowseModel.itemsPerPage
|
||||||
|
@ -731,7 +733,7 @@ Rectangle {
|
||||||
top: parent.top
|
top: parent.top
|
||||||
leftMargin: 20
|
leftMargin: 20
|
||||||
}
|
}
|
||||||
width: root.isLoggedIn ? 322 : 242
|
width: root.isLoggedIn ? 342 : 262
|
||||||
height: 36
|
height: 36
|
||||||
|
|
||||||
radius: 4
|
radius: 4
|
||||||
|
@ -742,27 +744,27 @@ Rectangle {
|
||||||
id: sortModel
|
id: sortModel
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
name: "Name";
|
name: "Name"
|
||||||
glyph: ";"
|
|
||||||
sortString: "alpha"
|
sortString: "alpha"
|
||||||
|
ascending: true
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
name: "Date";
|
name: "Date"
|
||||||
glyph: ";";
|
sortString: "recent"
|
||||||
sortString: "recent";
|
ascending: false
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
name: "Popular";
|
name: "Popular"
|
||||||
glyph: ";";
|
sortString: "likes"
|
||||||
sortString: "likes";
|
ascending: false
|
||||||
}
|
}
|
||||||
|
|
||||||
ListElement {
|
ListElement {
|
||||||
name: "My Likes";
|
name: "My Likes"
|
||||||
glyph: ";";
|
sortString: "my_likes"
|
||||||
sortString: "my_likes";
|
ascending: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,10 +790,10 @@ Rectangle {
|
||||||
currentIndex: 1;
|
currentIndex: 1;
|
||||||
|
|
||||||
delegate: SortButton {
|
delegate: SortButton {
|
||||||
width: 80
|
width: 85
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
glyph: model.glyph
|
ascending: model.ascending
|
||||||
text: model.name
|
text: model.name
|
||||||
|
|
||||||
visible: root.isLoggedIn || model.sortString != "my_likes"
|
visible: root.isLoggedIn || model.sortString != "my_likes"
|
||||||
|
@ -799,6 +801,12 @@ Rectangle {
|
||||||
checked: ListView.isCurrentItem
|
checked: ListView.isCurrentItem
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if(root.currentSortIndex == index) {
|
||||||
|
ascending = !ascending;
|
||||||
|
} else {
|
||||||
|
ascending = model.ascending;
|
||||||
|
}
|
||||||
|
root.isAscending = ascending;
|
||||||
root.currentSortIndex = index;
|
root.currentSortIndex = index;
|
||||||
sortListView.positionViewAtIndex(index, ListView.Beginning);
|
sortListView.positionViewAtIndex(index, ListView.Beginning);
|
||||||
sortListView.currentIndex = index;
|
sortListView.currentIndex = index;
|
||||||
|
@ -807,7 +815,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
highlight: Rectangle {
|
highlight: Rectangle {
|
||||||
width: 80
|
width: 85
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
color: hifi.colors.faintGray
|
color: hifi.colors.faintGray
|
||||||
|
|
|
@ -28,58 +28,60 @@ Item {
|
||||||
|
|
||||||
id: root;
|
id: root;
|
||||||
|
|
||||||
|
property string ascGlyph: "\u2191"
|
||||||
|
property string descGlyph: "\u2193"
|
||||||
|
property string text: ""
|
||||||
|
property bool ascending: false
|
||||||
|
property bool checked: false
|
||||||
|
signal clicked()
|
||||||
|
|
||||||
property string glyph: "";
|
width: childrenRect.width
|
||||||
property string text: "";
|
height: parent.height
|
||||||
property bool checked: false;
|
|
||||||
signal clicked();
|
|
||||||
|
|
||||||
width: childrenRect.width;
|
|
||||||
height: parent.height;
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left
|
||||||
height: parent.height;
|
height: parent.height
|
||||||
width: 2;
|
width: 2
|
||||||
color: hifi.colors.faintGray;
|
color: hifi.colors.faintGray
|
||||||
visible: index > 0;
|
visible: index > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiGlyphs {
|
RalewayRegular {
|
||||||
id: buttonGlyph;
|
id: buttonGlyph
|
||||||
text: root.glyph;
|
text: root.ascending ? root.ascGlyph : root.descGlyph
|
||||||
// Size
|
// Size
|
||||||
size: 14;
|
size: 14
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 0;
|
anchors.leftMargin: 10
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top
|
||||||
anchors.verticalCenter: parent.verticalCenter;
|
anchors.topMargin: 6
|
||||||
height: parent.height;
|
anchors.bottom: parent.bottom
|
||||||
horizontalAlignment: Text.AlignHCenter;
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignTop
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.lightGray;
|
color: hifi.colors.lightGray
|
||||||
}
|
}
|
||||||
RalewayRegular {
|
RalewayRegular {
|
||||||
id: buttonText;
|
id: buttonText
|
||||||
text: root.text;
|
text: root.text
|
||||||
// Text size
|
// Text size
|
||||||
size: 14;
|
size: 14
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.lightGray;
|
color: hifi.colors.lightGray
|
||||||
elide: Text.ElideRight;
|
elide: Text.ElideRight
|
||||||
horizontalAlignment: Text.AlignHCenter;
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.left: parent.left;
|
anchors.left: buttonGlyph.right
|
||||||
anchors.leftMargin: 20;
|
anchors.leftMargin: 5
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top
|
||||||
height: parent.height;
|
height: parent.height
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent
|
||||||
hoverEnabled: enabled;
|
hoverEnabled: enabled
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.clicked();
|
root.clicked();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,10 @@ void QmlMarketplace::getMarketplaceItems(
|
||||||
const QString& adminFilter,
|
const QString& adminFilter,
|
||||||
const QString& adminFilterCost,
|
const QString& adminFilterCost,
|
||||||
const QString& sort,
|
const QString& sort,
|
||||||
const bool isFree,
|
bool isAscending,
|
||||||
const int& page,
|
bool isFree,
|
||||||
const int& perPage) {
|
int page,
|
||||||
|
int perPage) {
|
||||||
|
|
||||||
QString endpoint = "items";
|
QString endpoint = "items";
|
||||||
QUrlQuery request;
|
QUrlQuery request;
|
||||||
|
@ -62,6 +63,7 @@ void QmlMarketplace::getMarketplaceItems(
|
||||||
request.addQueryItem("adminFilter", adminFilter);
|
request.addQueryItem("adminFilter", adminFilter);
|
||||||
request.addQueryItem("adminFilterCost", adminFilterCost);
|
request.addQueryItem("adminFilterCost", adminFilterCost);
|
||||||
request.addQueryItem("sort", sort);
|
request.addQueryItem("sort", sort);
|
||||||
|
request.addQueryItem("sort_dir", isAscending ? "asc" : "desc");
|
||||||
if (isFree) {
|
if (isFree) {
|
||||||
request.addQueryItem("isFree", "true");
|
request.addQueryItem("isFree", "true");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,10 @@ protected:
|
||||||
const QString& adminFilter = QString("published"),
|
const QString& adminFilter = QString("published"),
|
||||||
const QString& adminFilterCost = QString(),
|
const QString& adminFilterCost = QString(),
|
||||||
const QString& sort = QString(),
|
const QString& sort = QString(),
|
||||||
const bool isFree = false,
|
bool isAscending = false,
|
||||||
const int& page = 1,
|
bool isFree = false,
|
||||||
const int& perPage = 20);
|
int page = 1,
|
||||||
|
int perPage = 20);
|
||||||
Q_INVOKABLE void getMarketplaceItem(const QString& marketplaceItemId);
|
Q_INVOKABLE void getMarketplaceItem(const QString& marketplaceItemId);
|
||||||
Q_INVOKABLE void marketplaceItemLike(const QString& marketplaceItemId, const bool like = true);
|
Q_INVOKABLE void marketplaceItemLike(const QString& marketplaceItemId, const bool like = true);
|
||||||
Q_INVOKABLE void getMarketplaceCategories();
|
Q_INVOKABLE void getMarketplaceCategories();
|
||||||
|
|
Loading…
Reference in a new issue