From a99e2475443bebb6b9c9d2c8998300ce50f254a8 Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Fri, 18 Apr 2014 14:41:32 -0700 Subject: DD-58 : Implement associate listing UI and primitive --- indra/newview/llfloatermarketplacelistings.cpp | 65 ++++++++++++++++++++++ indra/newview/llfloatermarketplacelistings.h | 24 ++++++++ indra/newview/llinventorybridge.cpp | 4 +- indra/newview/llmarketplacefunctions.cpp | 37 ++++++++++++ indra/newview/llmarketplacefunctions.h | 2 + indra/newview/llviewerfloaterreg.cpp | 1 + .../default/xui/en/floater_associate_listing.xml | 53 ++++++++++++++++++ 7 files changed, 184 insertions(+), 2 deletions(-) create mode 100755 indra/newview/skins/default/xui/en/floater_associate_listing.xml (limited to 'indra') diff --git a/indra/newview/llfloatermarketplacelistings.cpp b/indra/newview/llfloatermarketplacelistings.cpp index 7db78ff290..be48005e67 100755 --- a/indra/newview/llfloatermarketplacelistings.cpp +++ b/indra/newview/llfloatermarketplacelistings.cpp @@ -510,4 +510,69 @@ void LLFloaterMarketplaceListings::importReportResults(U32 status, const LLSD& c updateView(); } +//----------------------------------------------------------------------------- +// LLFloaterAssociateListing() +//----------------------------------------------------------------------------- + +LLFloaterAssociateListing::LLFloaterAssociateListing(const LLSD& key) +: LLFloater(key) +, mUUID() +{ +} + +LLFloaterAssociateListing::~LLFloaterAssociateListing() +{ + gFocusMgr.releaseFocusIfNeeded( this ); +} + +BOOL LLFloaterAssociateListing::postBuild() +{ + getChild("OK")->setCommitCallback(boost::bind(&LLFloaterAssociateListing::apply, this)); + getChild("Cancel")->setCommitCallback(boost::bind(&LLFloaterAssociateListing::cancel, this)); + center(); + + return LLFloater::postBuild(); +} + +BOOL LLFloaterAssociateListing::handleKeyHere(KEY key, MASK mask) +{ + if (key == KEY_RETURN && mask == MASK_NONE) + { + apply(); + return TRUE; + } + else if (key == KEY_ESCAPE && mask == MASK_NONE) + { + cancel(); + return TRUE; + } + + return LLFloater::handleKeyHere(key, mask); +} + +// static +LLFloaterAssociateListing* LLFloaterAssociateListing::show(const LLUUID& folder_id) +{ + LLFloaterAssociateListing* floater = LLFloaterReg::showTypedInstance("associate_listing"); + + floater->mUUID = folder_id; + + return floater; +} + +void LLFloaterAssociateListing::apply() +{ + if (mUUID.notNull()) + { + const std::string& id = getChild("listing_id")->getValue().asString(); + LLMarketplaceData::instance().associateListing(mUUID,id); + } + closeFloater(); +} + +void LLFloaterAssociateListing::cancel() +{ + closeFloater(); +} + diff --git a/indra/newview/llfloatermarketplacelistings.h b/indra/newview/llfloatermarketplacelistings.h index 960b6c55e0..f2ff58a712 100755 --- a/indra/newview/llfloatermarketplacelistings.h +++ b/indra/newview/llfloatermarketplacelistings.h @@ -122,4 +122,28 @@ private: LLPanelMarketplaceListings * mPanelListings; }; + +//----------------------------------------------------------------------------- +// LLFloaterAssociateListing() +//----------------------------------------------------------------------------- +class LLFloaterAssociateListing : public LLFloater +{ + friend class LLFloaterReg; +public: + virtual BOOL postBuild(); + virtual BOOL handleKeyHere(KEY key, MASK mask); + + static LLFloaterAssociateListing* show(const LLUUID& folder_id); + +private: + LLFloaterAssociateListing(const LLSD& key); + virtual ~LLFloaterAssociateListing(); + + // UI Callbacks + void apply(); + void cancel(); + + LLUUID mUUID; +}; + #endif // LL_LLFLOATERMARKETPLACELISTINGS_H diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 6dd181501a..1eb647b1b2 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -40,6 +40,7 @@ #include "llfavoritesbar.h" // management of favorites folder #include "llfloateropenobject.h" #include "llfloaterreg.h" +#include "llfloatermarketplacelistings.h" #include "llfloatersidepanelcontainer.h" #include "llfloaterworldmap.h" #include "llfolderview.h" @@ -3209,8 +3210,7 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action) } else if ("marketplace_associate_listing" == action) { - // *TODO : Get a list of listing IDs and let the user choose one, delist the old one and relist the new one - LLMarketplaceData::instance().addListing(mUUID); + LLFloaterAssociateListing::show(mUUID); return; } else if ("marketplace_edit_listing" == action) diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 9465401d88..6ff6ba6714 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -584,6 +584,28 @@ bool LLMarketplaceData::addListing(const LLUUID& folder_id) return true; } +bool LLMarketplaceData::associateListing(const LLUUID& folder_id, std::string listing_id) +{ + if (isListed(folder_id)) + { + // Listing already exists -> exit with error + return false; + } + mMarketplaceItems[folder_id] = LLMarketplaceTuple(folder_id); + + // Check that the listing ID is not already associated to some other record + LLUUID old_listing = getListingFolder(listing_id); + if (old_listing.notNull()) + { + // If it is already used, unlist the old record (we can't have 2 listings with the same listing ID) + deleteListing(old_listing); + } + + setListingID(folder_id,listing_id); + update_marketplace_category(folder_id); + return true; +} + bool LLMarketplaceData::deleteListing(const LLUUID& folder_id) { if (!isListed(folder_id)) @@ -630,6 +652,21 @@ LLUUID LLMarketplaceData::getVersionFolderID(const LLUUID& folder_id) return (it == mMarketplaceItems.end() ? LLUUID::null : (it->second).mVersionFolderId); } +// Reverse lookup : find the listing folder id from the listing id +LLUUID LLMarketplaceData::getListingFolder(std::string listing_id) +{ + marketplace_items_list_t::iterator it = mMarketplaceItems.begin(); + while (it != mMarketplaceItems.end()) + { + if ((it->second).mListingId == listing_id) + { + return (it->second).mListingFolderId; + } + it++; + } + return LLUUID::null; +} + bool LLMarketplaceData::isListed(const LLUUID& folder_id) { marketplace_items_list_t::iterator it = mMarketplaceItems.find(folder_id); diff --git a/indra/newview/llmarketplacefunctions.h b/indra/newview/llmarketplacefunctions.h index 9485311b66..f279c24fb2 100755 --- a/indra/newview/llmarketplacefunctions.h +++ b/indra/newview/llmarketplacefunctions.h @@ -153,6 +153,7 @@ public: // Create/Delete Marketplace data set : each method returns true if the function succeeds, false if error bool addListing(const LLUUID& folder_id); + bool associateListing(const LLUUID& folder_id, std::string listing_id); bool deleteListing(const LLUUID& folder_id); // Access Marketplace data set : each method returns a default value if the folder_id can't be found @@ -160,6 +161,7 @@ public: std::string getListingID(const LLUUID& folder_id); LLUUID getVersionFolderID(const LLUUID& folder_id); std::string getListingURL(const LLUUID& folder_id); + LLUUID getListingFolder(std::string listing_id); // Modify Marketplace data set : each method returns true if the function succeeds, false if error bool setListingID(const LLUUID& folder_id, std::string listing_id); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 9bb6153e56..e5f19d3cce 100755 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -178,6 +178,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("fast_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("avatar", "floater_avatar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/skins/default/xui/en/floater_associate_listing.xml b/indra/newview/skins/default/xui/en/floater_associate_listing.xml new file mode 100755 index 0000000000..e019ed58dd --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_associate_listing.xml @@ -0,0 +1,53 @@ + + + + Listing ID: + + + Type ID here + +