resolve enum naming conflicts

pull/193/head
larteyoh 9 months ago
parent 5e84d4fe3b
commit e7cc60199d

@ -51,22 +51,13 @@ https://user-images.githubusercontent.com/58671384/219222567-f170f728-be31-43d5-
![ProfilePage_ListingsTab](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/ProfilePage_ListingsTab.png)
![ProfilePage_RatingsTab](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/ProfilePage_RatingsTab.png)
![ProfilePage_With_Custom_Avatar](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/ProfilePage_With_Custom_Avatar.png)
![ProfilePage_Identicon](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/identicon.png)
![MessagesPage](https://github.com/larteyoh/testshop/blob/main/assets/images/screenshots/Messages_Page.png)
</details>
<!--
## About
*neroshop* is a decentralized P2P (peer-to-peer) marketplace that uses [**Monero**](https://getmonero.org/) as its default cryptocurrency and
caters not only to darknet market users, but also those who want to partake in a parallel economy free from censorship and government intervention.
Neroshop aims to be simple for a beginner to use and easy for sellers to onboard their shop with just a few clicks.
The name _neroshop_ is a combination of the words _nero_, which is Italian for _black_ and the English word _shop_. And of course, _nero_ is also in the name _Monero_.
-->
## Feature Status
- [x] Distributed P2P network (need help with I2P integration or NAT traversal!!!)
- [x] Distributed P2P network (urgently seeking assistance with I2P integration/NAT traversal!!!)
- [ ] Buy and sell products and services with Monero
- [x] No KYC
- [x] No censorship (censorship-resistant)
@ -101,17 +92,17 @@ The name _neroshop_ is a combination of the words _nero_, which is Italian for _
| [sqlite3](https://sqlite.org/) | 3.38.0 | database management | :heavy_check_mark: |
| [QR Code generator](https://github.com/nayuki/QR-Code-generator) | ? | qr code generation | :heavy_check_mark: |
| [json](https://github.com/nlohmann/json/) | ? | json parsing and msgpack | :heavy_check_mark: |
| [curl](https://github.com/curl/curl) | ? | currency conversion | :o: :white_square_button: |
| [curl](https://github.com/curl/curl) | ? | currency conversion | :heavy_check_mark: :white_square_button: |
| [openssl](https://github.com/openssl/openssl) | 1.1.1 | for curl, sha256 sum and message encryption | :heavy_check_mark: |
| [Qt](https://www.qt.io/) | 5.12.8 | graphical user interface | :heavy_check_mark: |
| [raft](https://github.com/willemt/raft) | ? | consensus mechanism | :grey_question: |
| [stduuid](https://github.com/mariusbancila/stduuid) | ? | unique id generation | :o: |
| [stduuid](https://github.com/mariusbancila/stduuid) | ? | unique id generation | :heavy_check_mark: :white_square_button: |
| [linenoise](https://github.com/antirez/linenoise) | ? | command line interface | :heavy_check_mark: :white_square_button: |
| [lua](https://www.lua.org/) | 5.1.5 | configuration script | :heavy_check_mark: |
| [cxxopts](https://github.com/jarro2783/cxxopts) | ? | command line option parser | :heavy_check_mark: |
| [libzmq](https://github.com/zeromq/libzmq) | ? | networking | :grey_question: |
| [libi2pd](https://github.com/PurpleI2P/i2pd) | latest | network proxy | :grey_question: |
| [libjuice](https://github.com/paullouisageneau/libjuice) | ? | NAT traversal (clearnet) | :o: |
| [libjuice](https://github.com/paullouisageneau/libjuice) | ? | NAT traversal (clearnet) | :grey_question: |
### Compiling neroshop from source
**0. Install prerequisites**

@ -177,7 +177,7 @@ Item {
// This is due to the model changing every time we emit the signal
// Hence the creation of User.delistProducts (notice the s) which solves the issue
}
model: showOutOfStockProductsBox.checked ? User.inventory : User.getInventory(Enum.InventorySorting.SortByAvailability)
model: showOutOfStockProductsBox.checked ? User.inventory : User.getInventory(Enum.Sorting.SortByAvailability)
delegate: Rectangle {
width: listView.width
height: listView.cellHeight

@ -50,7 +50,7 @@ Item {
console.log("Searching for " + searchField.text)
navBar.uncheckAllButtons()
suggestionsPopup.close()
pageStack.pushPageWithProperties("qrc:/qml/pages/CatalogPage.qml", {"model": (searchField.text.length < 1) ? Backend.getListings(Enum.ListingSorting.SortNone, settingsDialog.hideIllegalProducts) : searchBar.model }, StackView.Immediate)//, {"model": [""]})
pageStack.pushPageWithProperties("qrc:/qml/pages/CatalogPage.qml", {"model": (searchField.text.length < 1) ? Backend.getListings(Enum.Sorting.SortNone, settingsDialog.hideIllegalProducts) : searchBar.model }, StackView.Immediate)//, {"model": [""]})
//console.log("page Loader Item (CatalogPage):", pageLoader.item)
//console.log("page Loader Item (CatalogPage.catalog):", pageLoader.catalog)//.item)

@ -86,29 +86,29 @@ Page {
displayText: "Sort: " + currentText
onActivated: {
if(currentIndex == find("None")) {
catalogPage.model = Backend.getListings(Enum.ListingSorting.SortNone, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.ListingSorting.SortNone
catalogPage.model = Backend.getListings(Enum.Sorting.SortNone, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.Sorting.SortNone
}
if(currentIndex == find("Oldest")) {
catalogPage.model = Backend.getListings(Enum.ListingSorting.SortByOldest, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.ListingSorting.SortByOldest
catalogPage.model = Backend.getListings(Enum.Sorting.SortByOldest, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.Sorting.SortByOldest
}
if(currentIndex == find("Latest")) {
console.log("Showing most recent items")
catalogPage.model = Backend.getListings(Enum.ListingSorting.SortByMostRecent, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.ListingSorting.SortByMostRecent
catalogPage.model = Backend.getListings(Enum.Sorting.SortByMostRecent, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.Sorting.SortByMostRecent
}
if(currentIndex == find("Alphabetical order")) {
catalogPage.model = Backend.getListings(Enum.ListingSorting.SortByAlphabeticalOrder, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.ListingSorting.SortByAlphabeticalOrder
catalogPage.model = Backend.getListings(Enum.Sorting.SortByAlphabeticalOrder, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.Sorting.SortByAlphabeticalOrder
}
if(currentIndex == find("Price - Lowest")) {
catalogPage.model = Backend.getListings(Enum.ListingSorting.SortByPriceLowest, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.ListingSorting.SortByPriceLowest
catalogPage.model = Backend.getListings(Enum.Sorting.SortByPriceLowest, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.Sorting.SortByPriceLowest
}
if(currentIndex == find("Price - Highest")) {
catalogPage.model = Backend.getListings(Enum.ListingSorting.SortByPriceHighest, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.ListingSorting.SortByPriceHighest
catalogPage.model = Backend.getListings(Enum.Sorting.SortByPriceHighest, settingsDialog.hideIllegalProducts)
settingsDialog.lastUsedListingSorting = Enum.Sorting.SortByPriceHighest
}
/*if(currentIndex == find("")) {
catalogPage.model = Backend.

@ -1246,13 +1246,13 @@ QVariantList neroshop::Backend::getListings(int sorting, bool hide_illicit_items
sqlite3_finalize(stmt);
switch(sorting) {
case static_cast<int>(EnumWrapper::ListingSorting::SortNone):
case static_cast<int>(EnumWrapper::Sorting::SortNone):
// Code for sorting by none - do nothing
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByCategory):
case static_cast<int>(EnumWrapper::Sorting::SortByCategory):
// Code for sorting by category - unavailable. Use getListingsByCategory() instead
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByMostRecent):
case static_cast<int>(EnumWrapper::Sorting::SortByMostRecent):
// Perform the sorting operation on the catalog based on the "most recent" criteria
std::sort(catalog.begin(), catalog.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
@ -1274,7 +1274,7 @@ QVariantList neroshop::Backend::getListings(int sorting, bool hide_illicit_items
return dateTimeA > dateTimeB;
});
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByOldest):
case static_cast<int>(EnumWrapper::Sorting::SortByOldest):
std::sort(catalog.begin(), catalog.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
QVariantMap listingB = b.toMap();
@ -1295,7 +1295,7 @@ QVariantList neroshop::Backend::getListings(int sorting, bool hide_illicit_items
return dateTimeA < dateTimeB;
});
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByAlphabeticalOrder):
case static_cast<int>(EnumWrapper::Sorting::SortByAlphabeticalOrder):
// Sort the catalog list by product name (alphabetically)
std::sort(catalog.begin(), catalog.end(), [](const QVariant& listing1, const QVariant& listing2) {
QString productName1 = listing1.toMap()["product_name"].toString();
@ -1303,7 +1303,7 @@ QVariantList neroshop::Backend::getListings(int sorting, bool hide_illicit_items
return productName1 < productName2;
});
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByPriceLowest):
case static_cast<int>(EnumWrapper::Sorting::SortByPriceLowest):
// Perform the sorting operation on the catalog based on the "price lowest" criteria
std::sort(catalog.begin(), catalog.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
@ -1311,7 +1311,7 @@ QVariantList neroshop::Backend::getListings(int sorting, bool hide_illicit_items
return listingA["price"].toDouble() < listingB["price"].toDouble();
});
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByPriceHighest):
case static_cast<int>(EnumWrapper::Sorting::SortByPriceHighest):
// Perform the sorting operation on the catalog based on the "price highest" criteria
std::sort(catalog.begin(), catalog.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
@ -1319,10 +1319,10 @@ QVariantList neroshop::Backend::getListings(int sorting, bool hide_illicit_items
return listingA["price"].toDouble() > listingB["price"].toDouble();
});
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByMostFavorited):
case static_cast<int>(EnumWrapper::Sorting::SortByMostFavorited):
// Code for sorting by most favorited
break;
case static_cast<int>(EnumWrapper::ListingSorting::SortByMostSales):
case static_cast<int>(EnumWrapper::Sorting::SortByMostSales):
// Code for sorting by most sales
break;
default:
@ -1464,7 +1464,7 @@ QVariantList neroshop::Backend::getListingsByCategory(int category_id, bool hide
}
//----------------------------------------------------------------
QVariantList neroshop::Backend::getListingsByMostRecentLimit(int limit, bool hide_illicit_items) {
auto catalog = getListings(static_cast<int>(EnumWrapper::ListingSorting::SortByMostRecent), hide_illicit_items);
auto catalog = getListings(static_cast<int>(EnumWrapper::Sorting::SortByMostRecent), hide_illicit_items);
if (catalog.size() > limit) {
catalog = catalog.mid(0, limit);
}

@ -51,35 +51,30 @@ public:
};
Q_ENUM(LoginError)
enum class ListingSorting {
enum class Sorting {
// Listing sorting
SortNone = 0,
SortByCategory,
SortByMostRecent,//SortByLatest = SortByMostRecent,
SortByMostRecent,
SortByLatest = SortByMostRecent,
SortByDateNewest = SortByMostRecent,
SortByOldest,
SortByDateOldest = SortByOldest,
SortByAlphabeticalOrder,
SortByName = SortByAlphabeticalOrder,
SortByPriceLowest,
SortByPriceHighest,
SortByMostFavorited,
SortByMostSales,
};
Q_ENUM(ListingSorting)
enum class InventorySorting {
SortNone = 0,
SortByAvailability, // If item is in stock
SortByDateOldest,
SortByDateNewest,
SortByName,
// Inventory sorting
SortByAvailability, // If item is in stock
SortByQuantitySmallest,
SortByQuantityBiggest,
SortByPriceLowest,
SortByPriceHighest,
SortByProductCode,
SortByCategory,
SortByCondition,
//TODO: productid, currency, location, color, size, weight, imagefilesize, desc
};
Q_ENUM(InventorySorting)
Q_ENUM(Sorting)
};
}
@ -87,6 +82,5 @@ public:
Q_DECLARE_METATYPE(neroshop::EnumWrapper::WalletError)
Q_DECLARE_METATYPE(neroshop::EnumWrapper::CartError)
Q_DECLARE_METATYPE(neroshop::EnumWrapper::LoginError)
Q_DECLARE_METATYPE(neroshop::EnumWrapper::ListingSorting)
Q_DECLARE_METATYPE(neroshop::EnumWrapper::InventorySorting)
Q_DECLARE_METATYPE(neroshop::EnumWrapper::Sorting)
#endif

@ -381,31 +381,31 @@ QVariantList neroshop::UserController::getInventory(int sorting) const {
sqlite3_finalize(stmt);
switch(sorting) {
case static_cast<int>(EnumWrapper::InventorySorting::SortNone):
std::cout << "SortNone (" << static_cast<int>(EnumWrapper::InventorySorting::SortNone) << ") selected\n";
case static_cast<int>(EnumWrapper::Sorting::SortNone):
std::cout << "SortNone (" << static_cast<int>(EnumWrapper::Sorting::SortNone) << ") selected\n";
break;
case static_cast<int>(EnumWrapper::InventorySorting::SortByAvailability): // Filter items with quantity less than 1
std::cout << "SortByAvailability (" << static_cast<int>(EnumWrapper::InventorySorting::SortByAvailability) << ") selected\n";
case static_cast<int>(EnumWrapper::Sorting::SortByAvailability): // Filter items with quantity less than 1
std::cout << "SortByAvailability (" << static_cast<int>(EnumWrapper::Sorting::SortByAvailability) << ") selected\n";
inventory_array.erase(std::remove_if(inventory_array.begin(), inventory_array.end(), [](const QVariant& variant) {
const QVariantMap& inventory_object = variant.toMap();
return inventory_object.value("quantity").toInt() < 1;
}), inventory_array.end());
break;
case static_cast<int>(EnumWrapper::InventorySorting::SortByQuantitySmallest):
case static_cast<int>(EnumWrapper::Sorting::SortByQuantitySmallest):
std::sort(inventory_array.begin(), inventory_array.end(), [](const QVariant& a, const QVariant& b) {
const QVariantMap& itemA = a.toMap();
const QVariantMap& itemB = b.toMap();
return itemA.value("quantity").toInt() < itemB.value("quantity").toInt();
});
break;
case static_cast<int>(EnumWrapper::InventorySorting::SortByQuantityBiggest):
case static_cast<int>(EnumWrapper::Sorting::SortByQuantityBiggest):
std::sort(inventory_array.begin(), inventory_array.end(), [](const QVariant& a, const QVariant& b) {
const QVariantMap& itemA = a.toMap();
const QVariantMap& itemB = b.toMap();
return itemA.value("quantity").toInt() > itemB.value("quantity").toInt();
});
break;
case static_cast<int>(EnumWrapper::InventorySorting::SortByDateOldest):
case static_cast<int>(EnumWrapper::Sorting::SortByDateOldest):
std::sort(inventory_array.begin(), inventory_array.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
QVariantMap listingB = b.toMap();
@ -426,7 +426,7 @@ QVariantList neroshop::UserController::getInventory(int sorting) const {
return dateTimeA < dateTimeB;
});
break;
case static_cast<int>(EnumWrapper::InventorySorting::SortByDateNewest):
case static_cast<int>(EnumWrapper::Sorting::SortByDateNewest):
std::sort(inventory_array.begin(), inventory_array.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
QVariantMap listingB = b.toMap();
@ -447,29 +447,29 @@ QVariantList neroshop::UserController::getInventory(int sorting) const {
return dateTimeA > dateTimeB;
});
break;
case static_cast<int>(EnumWrapper::InventorySorting::SortByPriceLowest):
case static_cast<int>(EnumWrapper::Sorting::SortByPriceLowest):
std::sort(inventory_array.begin(), inventory_array.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
QVariantMap listingB = b.toMap();
return listingA["price"].toDouble() < listingB["price"].toDouble();
});
break;
case static_cast<int>(EnumWrapper::InventorySorting::SortByPriceHighest):
case static_cast<int>(EnumWrapper::Sorting::SortByPriceHighest):
std::sort(inventory_array.begin(), inventory_array.end(), [](const QVariant& a, const QVariant& b) {
QVariantMap listingA = a.toMap();
QVariantMap listingB = b.toMap();
return listingA["price"].toDouble() > listingB["price"].toDouble();
});
break;
/*case static_cast<int>(EnumWrapper::InventorySorting::SortByName):
/*case static_cast<int>(EnumWrapper::Sorting::SortByName):
std::cout << "SortByName (" << SortByName << ") selected\n";
command = "SELECT DISTINCT * FROM listings JOIN products ON products.uuid = listings.product_id JOIN images ON images.product_id = listings.product_id WHERE seller_id = $1 GROUP BY images.product_id;";
break;*/
/*case static_cast<int>(EnumWrapper::InventorySorting::) :
/*case static_cast<int>(EnumWrapper::Sorting::) :
std::cout << "Sort? (" << ? << ") selected\n";
break;*/
default:
std::cout << "default: SortNone (" << static_cast<int>(EnumWrapper::InventorySorting::SortNone) << ") selected\n";
std::cout << "default: SortNone (" << static_cast<int>(EnumWrapper::Sorting::SortNone) << ") selected\n";
break;
}

Loading…
Cancel
Save