summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelpicks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelpicks.cpp')
-rw-r--r--indra/newview/llpanelpicks.cpp110
1 files changed, 91 insertions, 19 deletions
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index f0860e7027..0a7c39db46 100644
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -192,7 +192,6 @@ LLPanelPicks::LLPanelPicks()
mPicksAccTab(NULL),
mClassifiedsAccTab(NULL),
mPanelClassifiedInfo(NULL),
- mPanelClassifiedEdit(NULL),
mNoClassifieds(false),
mNoPicks(false)
{
@@ -385,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;
@@ -421,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())
@@ -657,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)
@@ -693,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()
@@ -780,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());
@@ -800,6 +824,11 @@ void LLPanelPicks::onPanelClassifiedSave(LLPanelClassifiedEdit* panel)
mClassifiedsAccTab->changeOpenClose(false);
showAccordion("tab_classifieds", true);
}
+ else if(panel->isNewWithErrors())
+ {
+ LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
+ c_item->fillIn(panel);
+ }
else
{
onPanelClassifiedClose(panel);
@@ -860,15 +889,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;
}
}
@@ -941,16 +971,26 @@ void LLPanelPicks::onPanelClassifiedEdit()
LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
- createClassifiedEditPanel();
-
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()
@@ -965,6 +1005,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);
@@ -1153,6 +1207,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);