DD-58 : Implement associate listing UI and primitive

master
Merov Linden 2014-04-18 14:41:32 -07:00
parent c52b4e27f2
commit a99e247544
7 changed files with 184 additions and 2 deletions

View File

@ -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<LLButton>("OK")->setCommitCallback(boost::bind(&LLFloaterAssociateListing::apply, this));
getChild<LLButton>("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<LLFloaterAssociateListing>("associate_listing");
floater->mUUID = folder_id;
return floater;
}
void LLFloaterAssociateListing::apply()
{
if (mUUID.notNull())
{
const std::string& id = getChild<LLUICtrl>("listing_id")->getValue().asString();
LLMarketplaceData::instance().associateListing(mUUID,id);
}
closeFloater();
}
void LLFloaterAssociateListing::cancel()
{
closeFloater();
}

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -178,6 +178,7 @@ void LLViewerFloaterReg::registerFloaters()
LLFloaterReg::add("fast_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>);
LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>);
LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAssociateListing>);
LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>);
LLFloaterReg::add("avatar", "floater_avatar.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatar>);
LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarPicker>);

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
legacy_header_height="18"
can_minimize="false"
height="110"
layout="topleft"
name="associate listing"
help_topic="associate_listing"
title="ASSOCIATE LISTING"
width="375">
<text
type="string"
length="1"
follows="top|left"
font="SansSerifLarge"
height="16"
layout="topleft"
left="10"
top="25"
name="message">
Listing ID:
</text>
<line_editor
type="string"
length="1"
follows="top|right"
font="SansSerif"
height="20"
layout="topleft"
left_delta="0"
name="listing_id"
top_pad="5"
width="350">
Type ID here
</line_editor>
<button
follows="bottom|left"
height="23"
label="OK"
layout="topleft"
left="155"
name="OK"
top_pad="10"
width="100" />
<button
follows="bottom|right"
height="23"
label="Cancel"
layout="topleft"
left_pad="5"
name="Cancel"
width="100" />
</floater>