summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelpicks.cpp
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2010-03-29 16:55:22 -0700
committerJames Cook <james@lindenlab.com>2010-03-29 16:55:22 -0700
commitecc2c726502448076295254714c0bfa8c0074f25 (patch)
tree6a9434c540f7b5ea7bca326df1a420e4a0a99cc4 /indra/newview/llpanelpicks.cpp
parentd2f9e34598621f1dabad15025417efd6b81dddf0 (diff)
parentac103403160e87bb6b40ac3e032d077a3381da8e (diff)
Merge latest viewer-hotfix, approximately equal to Viewer 2.0 final
Diffstat (limited to 'indra/newview/llpanelpicks.cpp')
-rw-r--r--indra/newview/llpanelpicks.cpp192
1 files changed, 123 insertions, 69 deletions
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index 6b45cd82fd..2239db96de 100644
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -140,10 +140,11 @@ public:
params["open_tab_name"] = "panel_picks";
params["show_tab_panel"] = "classified_details";
params["classified_id"] = c_info->classified_id;
- params["classified_avatar_id"] = c_info->creator_id;
+ params["classified_creator_id"] = c_info->creator_id;
params["classified_snapshot_id"] = c_info->snapshot_id;
params["classified_name"] = c_info->name;
params["classified_desc"] = c_info->description;
+ params["from_search"] = true;
LLSideTray::getInstance()->showPanel("panel_profile_view", params);
}
@@ -174,31 +175,6 @@ LLClassifiedHandler gClassifiedHandler;
//////////////////////////////////////////////////////////////////////////
-/**
- * Copy&Pasted from old LLPanelClassified. This class does nothing at the moment.
- * Subscribing to "classifiedclickthrough" removes a few warnings.
- */
-class LLClassifiedClickThrough : public LLDispatchHandler
-{
-public:
-
- // "classifiedclickthrough"
- // strings[0] = classified_id
- // strings[1] = teleport_clicks
- // strings[2] = map_clicks
- // strings[3] = profile_clicks
- virtual bool operator()(
- const LLDispatcher* dispatcher,
- const std::string& key,
- const LLUUID& invoice,
- const sparam_t& strings)
- {
- if (strings.size() != 4)
- return false;
-
- return true;
- }
-};
//-----------------------------------------------------------------------------
// LLPanelPicks
@@ -216,13 +192,9 @@ LLPanelPicks::LLPanelPicks()
mPicksAccTab(NULL),
mClassifiedsAccTab(NULL),
mPanelClassifiedInfo(NULL),
- mPanelClassifiedEdit(NULL),
- mClickThroughDisp(NULL),
mNoClassifieds(false),
mNoPicks(false)
{
- mClickThroughDisp = new LLClassifiedClickThrough();
- gGenericDispatcher.addHandler("classifiedclickthrough", mClickThroughDisp);
}
LLPanelPicks::~LLPanelPicks()
@@ -231,8 +203,6 @@ LLPanelPicks::~LLPanelPicks()
{
LLAvatarPropertiesProcessor::getInstance()->removeObserver(getAvatarId(),this);
}
-
- delete mClickThroughDisp;
}
void* LLPanelPicks::create(void* data /* = NULL */)
@@ -414,6 +384,9 @@ BOOL LLPanelPicks::postBuild()
registar.add("Pick.Teleport", boost::bind(&LLPanelPicks::onClickTeleport, this));
registar.add("Pick.Map", boost::bind(&LLPanelPicks::onClickMap, this));
registar.add("Pick.Delete", boost::bind(&LLPanelPicks::onClickDelete, this));
+ LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registar;
+ enable_registar.add("Pick.Enable", boost::bind(&LLPanelPicks::onEnableMenuItem, this, _2));
+
mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>("menu_picks.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar plus_registar;
@@ -450,6 +423,22 @@ bool LLPanelPicks::isActionEnabled(const LLSD& userdata) const
return true;
}
+bool LLPanelPicks::isClassifiedPublished(LLClassifiedItem* c_item)
+{
+ if(c_item)
+ {
+ LLPanelClassifiedEdit* panel = mEditClassifiedPanels[c_item->getClassifiedId()];
+ if(panel)
+ {
+ return !panel->isNewWithErrors();
+ }
+
+ // we've got this classified from server - it's published
+ return true;
+ }
+ return false;
+}
+
void LLPanelPicks::onAccordionStateChanged(const LLAccordionCtrlTab* acc_tab)
{
if(!mPicksAccTab->getDisplayChildren())
@@ -607,7 +596,11 @@ void LLPanelPicks::onClickTeleport()
if(pick_item)
pos = pick_item->getPosGlobal();
else if(c_item)
+ {
pos = c_item->getPosGlobal();
+ LLPanelClassifiedInfo::sendClickMessage("teleport", false,
+ c_item->getClassifiedId(), LLUUID::null, pos, LLStringUtil::null);
+ }
if (!pos.isExactlyZero())
{
@@ -626,7 +619,11 @@ void LLPanelPicks::onClickMap()
if (pick_item)
pos = pick_item->getPosGlobal();
else if(c_item)
+ {
+ LLPanelClassifiedInfo::sendClickMessage("map", false,
+ c_item->getClassifiedId(), LLUUID::null, pos, LLStringUtil::null);
pos = c_item->getPosGlobal();
+ }
LLFloaterWorldMap::getInstance()->trackLocation(pos);
LLFloaterReg::showInstance("world_map", "center");
@@ -678,6 +675,12 @@ void LLPanelPicks::updateButtons()
childSetEnabled(XML_BTN_INFO, has_selected);
childSetEnabled(XML_BTN_TELEPORT, has_selected);
childSetEnabled(XML_BTN_SHOW_ON_MAP, has_selected);
+
+ LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
+ if(c_item)
+ {
+ childSetEnabled(XML_BTN_INFO, isClassifiedPublished(c_item));
+ }
}
void LLPanelPicks::setProfilePanel(LLPanelProfile* profile_panel)
@@ -714,9 +717,10 @@ void LLPanelPicks::createNewPick()
void LLPanelPicks::createNewClassified()
{
- createClassifiedEditPanel();
+ LLPanelClassifiedEdit* panel = NULL;
+ createClassifiedEditPanel(&panel);
- getProfilePanel()->openPanel(mPanelClassifiedEdit, LLSD());
+ getProfilePanel()->openPanel(panel, LLSD());
}
void LLPanelPicks::onClickInfo()
@@ -756,26 +760,20 @@ void LLPanelPicks::openClassifiedInfo()
if (selected_value.isUndefined()) return;
LLClassifiedItem* c_item = getSelectedClassifiedItem();
+ LLSD params;
+ params["classified_id"] = c_item->getClassifiedId();
+ params["classified_creator_id"] = c_item->getAvatarId();
+ params["classified_snapshot_id"] = c_item->getSnapshotId();
+ params["classified_name"] = c_item->getClassifiedName();
+ params["classified_desc"] = c_item->getDescription();
+ params["from_search"] = false;
- openClassifiedInfo(c_item->getClassifiedId(), c_item->getAvatarId(),
- c_item->getSnapshotId(), c_item->getClassifiedName(),
- c_item->getDescription());
+ openClassifiedInfo(params);
}
-void LLPanelPicks::openClassifiedInfo(const LLUUID &classified_id,
- const LLUUID &avatar_id,
- const LLUUID &snapshot_id,
- const std::string &name, const std::string &desc)
+void LLPanelPicks::openClassifiedInfo(const LLSD &params)
{
createClassifiedInfoPanel();
-
- LLSD params;
- params["classified_id"] = classified_id;
- params["avatar_id"] = avatar_id;
- params["snapshot_id"] = snapshot_id;
- params["name"] = name;
- params["desc"] = desc;
-
getProfilePanel()->openPanel(mPanelClassifiedInfo, params);
}
@@ -807,11 +805,10 @@ void LLPanelPicks::onPanelClassifiedSave(LLPanelClassifiedEdit* panel)
if(panel->isNew())
{
+ mEditClassifiedPanels[panel->getClassifiedId()] = panel;
+
LLClassifiedItem* c_item = new LLClassifiedItem(getAvatarId(), panel->getClassifiedId());
-
- c_item->setClassifiedName(panel->getClassifiedName());
- c_item->setDescription(panel->getDescription());
- c_item->setSnapshotId(panel->getSnapshotId());
+ c_item->fillIn(panel);
LLSD c_value;
c_value.insert(CLASSIFIED_ID, c_item->getClassifiedId());
@@ -827,6 +824,15 @@ void LLPanelPicks::onPanelClassifiedSave(LLPanelClassifiedEdit* panel)
mClassifiedsAccTab->changeOpenClose(false);
showAccordion("tab_classifieds", true);
}
+ else if(panel->isNewWithErrors())
+ {
+ LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
+ llassert(c_item);
+ if (c_item)
+ {
+ c_item->fillIn(panel);
+ }
+ }
else
{
onPanelClassifiedClose(panel);
@@ -853,13 +859,13 @@ void LLPanelPicks::onPanelClassifiedClose(LLPanelClassifiedInfo* panel)
llassert(c_item);
if (c_item)
{
- c_item->setClassifiedName(panel->getClassifiedName());
- c_item->setDescription(panel->getDescription());
- c_item->setSnapshotId(panel->getSnapshotId());
+ c_item->setClassifiedName(panel->getClassifiedName());
+ c_item->setDescription(panel->getDescription());
+ c_item->setSnapshotId(panel->getSnapshotId());
+ }
}
}
}
- }
onPanelPickClose(panel);
updateButtons();
@@ -887,15 +893,16 @@ void LLPanelPicks::createClassifiedInfoPanel()
}
}
-void LLPanelPicks::createClassifiedEditPanel()
+void LLPanelPicks::createClassifiedEditPanel(LLPanelClassifiedEdit** panel)
{
- if(!mPanelClassifiedEdit)
+ if(panel)
{
- mPanelClassifiedEdit = LLPanelClassifiedEdit::create();
- mPanelClassifiedEdit->setExitCallback(boost::bind(&LLPanelPicks::onPanelClassifiedClose, this, mPanelClassifiedEdit));
- mPanelClassifiedEdit->setSaveCallback(boost::bind(&LLPanelPicks::onPanelClassifiedSave, this, mPanelClassifiedEdit));
- mPanelClassifiedEdit->setCancelCallback(boost::bind(&LLPanelPicks::onPanelClassifiedClose, this, mPanelClassifiedEdit));
- mPanelClassifiedEdit->setVisible(FALSE);
+ LLPanelClassifiedEdit* new_panel = LLPanelClassifiedEdit::create();
+ new_panel->setExitCallback(boost::bind(&LLPanelPicks::onPanelClassifiedClose, this, new_panel));
+ new_panel->setSaveCallback(boost::bind(&LLPanelPicks::onPanelClassifiedSave, this, new_panel));
+ new_panel->setCancelCallback(boost::bind(&LLPanelPicks::onPanelClassifiedClose, this, new_panel));
+ new_panel->setVisible(FALSE);
+ *panel = new_panel;
}
}
@@ -967,17 +974,32 @@ void LLPanelPicks::onPanelClassifiedEdit()
}
LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
-
- createClassifiedEditPanel();
+ llassert(c_item);
+ if (!c_item)
+ {
+ return;
+ }
LLSD params;
params["classified_id"] = c_item->getClassifiedId();
- params["avatar_id"] = c_item->getAvatarId();
+ params["classified_creator_id"] = c_item->getAvatarId();
params["snapshot_id"] = c_item->getSnapshotId();
params["name"] = c_item->getClassifiedName();
params["desc"] = c_item->getDescription();
-
- getProfilePanel()->openPanel(mPanelClassifiedEdit, params);
+ params["category"] = (S32)c_item->getCategory();
+ params["content_type"] = (S32)c_item->getContentType();
+ params["auto_renew"] = c_item->getAutoRenew();
+ params["price_for_listing"] = c_item->getPriceForListing();
+ params["location_text"] = c_item->getLocationText();
+
+ LLPanelClassifiedEdit* panel = mEditClassifiedPanels[c_item->getClassifiedId()];
+ if(!panel)
+ {
+ createClassifiedEditPanel(&panel);
+ mEditClassifiedPanels[c_item->getClassifiedId()] = panel;
+ }
+ getProfilePanel()->openPanel(panel, params);
+ panel->setPosGlobal(c_item->getPosGlobal());
}
void LLPanelPicks::onClickMenuEdit()
@@ -992,6 +1014,20 @@ void LLPanelPicks::onClickMenuEdit()
}
}
+bool LLPanelPicks::onEnableMenuItem(const LLSD& user_data)
+{
+ std::string param = user_data.asString();
+
+ LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
+ if(c_item && "info" == param)
+ {
+ // dont show Info panel if classified was not created
+ return isClassifiedPublished(c_item);
+ }
+
+ return true;
+}
+
inline LLPanelProfile* LLPanelPicks::getProfilePanel()
{
llassert_always(NULL != mProfilePanel);
@@ -1180,6 +1216,24 @@ void LLClassifiedItem::setValue(const LLSD& value)
childSetVisible("selected_icon", value["selected"]);
}
+void LLClassifiedItem::fillIn(LLPanelClassifiedEdit* panel)
+{
+ if(!panel)
+ {
+ return;
+ }
+
+ setClassifiedName(panel->getClassifiedName());
+ setDescription(panel->getDescription());
+ setSnapshotId(panel->getSnapshotId());
+ setCategory(panel->getCategory());
+ setContentType(panel->getContentType());
+ setAutoRenew(panel->getAutoRenew());
+ setPriceForListing(panel->getPriceForListing());
+ setPosGlobal(panel->getPosGlobal());
+ setLocationText(panel->getClassifiedLocation());
+}
+
void LLClassifiedItem::setClassifiedName(const std::string& name)
{
childSetValue("name", name);