summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llpanelclassified.cpp131
-rw-r--r--indra/newview/llpanelclassified.h23
-rw-r--r--indra/newview/llpanelpicks.cpp91
-rw-r--r--indra/newview/llpanelpicks.h41
-rw-r--r--indra/newview/skins/default/xui/en/menu_picks.xml15
5 files changed, 246 insertions, 55 deletions
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 115c7a1aa5..021e1f5159 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -1410,6 +1410,11 @@ void LLPanelClassifiedInfo::setClassifiedLocation(const std::string& location)
childSetValue("classified_location", location);
}
+std::string LLPanelClassifiedInfo::getClassifiedLocation()
+{
+ return childGetValue("classified_location").asString();
+}
+
void LLPanelClassifiedInfo::setSnapshotId(const LLUUID& id)
{
mSnapshotCtrl->setValue(id);
@@ -1651,6 +1656,7 @@ static const S32 CB_ITEM_PG = 1;
LLPanelClassifiedEdit::LLPanelClassifiedEdit()
: LLPanelClassifiedInfo()
, mIsNew(false)
+ , mIsNewWithErrors(false)
, mCanClose(false)
, mPublishFloater(NULL)
{
@@ -1709,21 +1715,12 @@ BOOL LLPanelClassifiedEdit::postBuild()
return TRUE;
}
-void LLPanelClassifiedEdit::onOpen(const LLSD& key)
+void LLPanelClassifiedEdit::fillIn(const LLSD& key)
{
- LLUUID classified_id = key["classified_id"];
+ setAvatarId(gAgent.getID());
- mIsNew = classified_id.isNull();
-
- scrollToTop();
-
- if(mIsNew)
+ if(key.isUndefined())
{
- setAvatarId(gAgent.getID());
-
- resetData();
- resetControls();
-
setPosGlobal(gAgent.getPositionGlobal());
LLUUID snapshot_id = LLUUID::null;
@@ -1746,25 +1743,55 @@ void LLPanelClassifiedEdit::onOpen(const LLSD& key)
childSetValue("classified_name", makeClassifiedName());
childSetValue("classified_desc", desc);
setSnapshotId(snapshot_id);
-
setClassifiedLocation(createLocationText(getLocationNotice(), region_name, getPosGlobal()));
-
// server will set valid parcel id
setParcelId(LLUUID::null);
+ }
+ else
+ {
+ setClassifiedId(key["classified_id"]);
+ setClassifiedName(key["name"]);
+ setDescription(key["desc"]);
+ setSnapshotId(key["snapshot_id"]);
+ setCategory((U32)key["category"].asInteger());
+ setContentType((U32)key["content_type"].asInteger());
+ setClassifiedLocation(key["location_text"]);
+ childSetValue("auto_renew", key["auto_renew"]);
+ childSetValue("price_for_listing", key["price_for_listing"].asInteger());
+ }
+}
+
+void LLPanelClassifiedEdit::onOpen(const LLSD& key)
+{
+ mIsNew = key.isUndefined();
+
+ scrollToTop();
+
+ // classified is not created yet
+ bool is_new = isNew() || isNewWithErrors();
+
+ if(is_new)
+ {
+ resetData();
+ resetControls();
+
+ fillIn(key);
- enableVerbs(true);
- enableEditing(true);
+ if(isNew())
+ {
+ LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this);
+ }
}
else
{
LLPanelClassifiedInfo::onOpen(key);
- enableVerbs(false);
- enableEditing(false);
}
- std::string save_btn_label = isNew() ? getString("publish_label") : getString("save_label");
+ std::string save_btn_label = is_new ? getString("publish_label") : getString("save_label");
childSetLabelArg("save_changes_btn", "[LABEL]", save_btn_label);
+ enableVerbs(is_new);
+ enableEditing(is_new);
resetDirty();
setInfoLoaded(false);
}
@@ -1776,6 +1803,14 @@ void LLPanelClassifiedEdit::processProperties(void* data, EAvatarProcessorType t
LLAvatarClassifiedInfo* c_info = static_cast<LLAvatarClassifiedInfo*>(data);
if(c_info && getClassifiedId() == c_info->classified_id)
{
+ // see LLPanelClassifiedEdit::sendUpdate() for notes
+ mIsNewWithErrors = false;
+ // for just created classified - panel will probably be closed when we get here.
+ if(!getVisible())
+ {
+ return;
+ }
+
enableEditing(true);
setClassifiedName(c_info->name);
@@ -1785,19 +1820,22 @@ void LLPanelClassifiedEdit::processProperties(void* data, EAvatarProcessorType t
setClassifiedLocation(createLocationText(c_info->parcel_name, c_info->sim_name, c_info->pos_global));
// *HACK see LLPanelClassifiedEdit::sendUpdate()
- getChild<LLComboBox>("category")->setCurrentByIndex(c_info->category - 1);
- getChild<LLComboBox>("category")->resetDirty();
+ setCategory(c_info->category - 1);
bool mature = is_cf_mature(c_info->flags);
bool auto_renew = is_cf_auto_renew(c_info->flags);
- getChild<LLIconsComboBox>("content_type")->setCurrentByIndex(mature ? CB_ITEM_MATURE : CB_ITEM_PG);
+ setContentType(mature ? CB_ITEM_MATURE : CB_ITEM_PG);
childSetValue("auto_renew", auto_renew);
childSetValue("price_for_listing", c_info->price_for_listing);
childSetEnabled("price_for_listing", isNew());
resetDirty();
setInfoLoaded(true);
+ enableVerbs(false);
+
+ // for just created classified - in case user opened edit panel before processProperties() callback
+ childSetLabelArg("save_changes_btn", "[LABEL]", getString("save_label"));
}
}
}
@@ -1828,7 +1866,12 @@ void LLPanelClassifiedEdit::resetDirty()
LLPanelClassifiedInfo::resetDirty();
getChild<LLUICtrl>("classified_snapshot")->resetDirty();
getChild<LLUICtrl>("classified_name")->resetDirty();
- getChild<LLUICtrl>("classified_desc")->resetDirty();
+
+ LLTextEditor* desc = getChild<LLTextEditor>("classified_desc");
+ // call blockUndo() to really reset dirty(and make isDirty work as intended)
+ desc->blockUndo();
+ desc->resetDirty();
+
getChild<LLUICtrl>("category")->resetDirty();
getChild<LLUICtrl>("content_type")->resetDirty();
getChild<LLUICtrl>("auto_renew")->resetDirty();
@@ -1877,15 +1920,31 @@ void LLPanelClassifiedEdit::stretchSnapshot()
getChild<LLUICtrl>("edit_icon")->setShape(mSnapshotCtrl->getRect());
}
+U32 LLPanelClassifiedEdit::getContentType()
+{
+ LLComboBox* ct_cb = getChild<LLComboBox>("content_type");
+ return ct_cb->getCurrentIndex();
+}
+
+void LLPanelClassifiedEdit::setContentType(U32 content_type)
+{
+ LLIconsComboBox* ct_cb = getChild<LLIconsComboBox>("content_type");
+ ct_cb->setCurrentByIndex(content_type);
+ ct_cb->resetDirty();
+}
+
+bool LLPanelClassifiedEdit::getAutoRenew()
+{
+ return childGetValue("auto_renew").asBoolean();
+}
+
void LLPanelClassifiedEdit::sendUpdate()
{
LLAvatarClassifiedInfo c_data;
if(getClassifiedId().isNull())
{
- LLUUID id;
- id.generate();
- setClassifiedId(id);
+ setClassifiedId(LLUUID::generateNewID());
}
c_data.agent_id = gAgent.getID();
@@ -1902,6 +1961,14 @@ void LLPanelClassifiedEdit::sendUpdate()
c_data.price_for_listing = getPriceForListing();
LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoUpdate(&c_data);
+
+ if(isNew())
+ {
+ // Lets assume there will be some error.
+ // Successful sendClassifiedInfoUpdate will trigger processProperties and
+ // let us know there was no error.
+ mIsNewWithErrors = true;
+ }
}
U32 LLPanelClassifiedEdit::getCategory()
@@ -1910,6 +1977,13 @@ U32 LLPanelClassifiedEdit::getCategory()
return cat_cb->getCurrentIndex();
}
+void LLPanelClassifiedEdit::setCategory(U32 category)
+{
+ LLComboBox* cat_cb = getChild<LLComboBox>("category");
+ cat_cb->setCurrentByIndex(category);
+ cat_cb->resetDirty();
+}
+
U8 LLPanelClassifiedEdit::getFlags()
{
bool auto_renew = childGetValue("auto_renew").asBoolean();
@@ -2005,17 +2079,14 @@ void LLPanelClassifiedEdit::onSaveClick()
notifyInvalidName();
return;
}
- if(isNew())
+ if(isNew() || isNewWithErrors())
{
if(gStatusBar->getBalance() < getPriceForListing())
{
LLNotificationsUtil::add("ClassifiedInsufficientFunds");
return;
}
- }
- if(isNew())
- {
mPublishFloater = LLFloaterReg::findTypedInstance<LLPublishClassifiedFloater>(
"publish_classified", LLSD());
diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h
index 58e7c9a4b4..1157649a16 100644
--- a/indra/newview/llpanelclassified.h
+++ b/indra/newview/llpanelclassified.h
@@ -256,6 +256,8 @@ public:
void setClassifiedLocation(const std::string& location);
+ std::string getClassifiedLocation();
+
void setPosGlobal(const LLVector3d& pos) { mPosGlobal = pos; }
LLVector3d& getPosGlobal() { return mPosGlobal; }
@@ -366,6 +368,8 @@ public:
/*virtual*/ BOOL postBuild();
+ void fillIn(const LLSD& key);
+
/*virtual*/ void onOpen(const LLSD& key);
/*virtual*/ void processProperties(void* data, EAvatarProcessorType type);
@@ -382,28 +386,38 @@ public:
bool isNew() { return mIsNew; }
+ bool isNewWithErrors() { return mIsNewWithErrors; }
+
bool canClose();
void draw();
void stretchSnapshot();
+ U32 getCategory();
+
+ void setCategory(U32 category);
+
+ U32 getContentType();
+
+ void setContentType(U32 content_type);
+
+ bool getAutoRenew();
+
+ S32 getPriceForListing();
+
protected:
LLPanelClassifiedEdit();
void sendUpdate();
- U32 getCategory();
-
void enableVerbs(bool enable);
void enableEditing(bool enable);
std::string makeClassifiedName();
- S32 getPriceForListing();
-
void setPriceForListing(S32 price);
U8 getFlags();
@@ -429,6 +443,7 @@ protected:
private:
bool mIsNew;
+ bool mIsNewWithErrors;
bool mCanClose;
LLPublishClassifiedFloater* mPublishFloater;
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index ada770f78b..287896bf65 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;
@@ -693,9 +695,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 +783,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 +802,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 +867,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 +949,26 @@ void LLPanelPicks::onPanelClassifiedEdit()
LLClassifiedItem* c_item = dynamic_cast<LLClassifiedItem*>(mClassifiedsList->getSelectedItem());
- createClassifiedEditPanel();
-
LLSD params;
params["classified_id"] = c_item->getClassifiedId();
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 +983,25 @@ 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)
+ {
+ LLPanelClassifiedEdit* panel = mEditClassifiedPanels[c_item->getClassifiedId()];
+
+ if(panel && "info" == param)
+ {
+ // dont show Info panel if classified was not created
+ return ! panel->isNewWithErrors();
+ }
+ }
+
+ return true;
+}
+
inline LLPanelProfile* LLPanelPicks::getProfilePanel()
{
llassert_always(NULL != mProfilePanel);
@@ -1153,6 +1190,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);
diff --git a/indra/newview/llpanelpicks.h b/indra/newview/llpanelpicks.h
index 11e811275b..6d013035a2 100644
--- a/indra/newview/llpanelpicks.h
+++ b/indra/newview/llpanelpicks.h
@@ -114,6 +114,8 @@ private:
void onPanelClassifiedEdit();
void onClickMenuEdit();
+ bool onEnableMenuItem(const LLSD& user_data);
+
void createNewPick();
void createNewClassified();
@@ -140,7 +142,7 @@ private:
void createPickInfoPanel();
void createPickEditPanel();
void createClassifiedInfoPanel();
- void createClassifiedEditPanel();
+ void createClassifiedEditPanel(LLPanelClassifiedEdit** panel);
LLMenuGL* mPopupMenu;
LLPanelProfile* mProfilePanel;
@@ -149,10 +151,16 @@ private:
LLFlatListView* mClassifiedsList;
LLPanelPickInfo* mPanelPickInfo;
LLPanelClassifiedInfo* mPanelClassifiedInfo;
- LLPanelClassifiedEdit* mPanelClassifiedEdit;
LLPanelPickEdit* mPanelPickEdit;
LLToggleableMenu* mPlusMenu;
+ // <classified_id, edit_panel>
+ typedef std::map<LLUUID, LLPanelClassifiedEdit*> panel_classified_edit_map_t;
+
+ // This map is needed for newly created classifieds. The purpose of panel is to
+ // sit in this map and listen to LLPanelClassifiedEdit::processProperties callback.
+ panel_classified_edit_map_t mEditClassifiedPanels;
+
LLAccordionCtrlTab* mPicksAccTab;
LLAccordionCtrlTab* mClassifiedsAccTab;
@@ -245,6 +253,8 @@ public:
/*virtual*/ void setValue(const LLSD& value);
+ void fillIn(LLPanelClassifiedEdit* panel);
+
LLUUID getAvatarId() {return mAvatarId;}
void setAvatarId(const LLUUID& avatar_id) {mAvatarId = avatar_id;}
@@ -255,7 +265,11 @@ public:
void setPosGlobal(const LLVector3d& pos) { mPosGlobal = pos; }
- const LLVector3d& getPosGlobal() { return mPosGlobal; }
+ const LLVector3d getPosGlobal() { return mPosGlobal; }
+
+ void setLocationText(const std::string location) { mLocationText = location; }
+
+ std::string getLocationText() { return mLocationText; }
void setClassifiedName (const std::string& name);
@@ -269,10 +283,31 @@ public:
LLUUID getSnapshotId();
+ void setCategory(U32 cat) { mCategory = cat; }
+
+ U32 getCategory() { return mCategory; }
+
+ void setContentType(U32 ct) { mContentType = ct; }
+
+ U32 getContentType() { return mContentType; }
+
+ void setAutoRenew(U32 renew) { mAutoRenew = renew; }
+
+ bool getAutoRenew() { return mAutoRenew; }
+
+ void setPriceForListing(S32 price) { mPriceForListing = price; }
+
+ S32 getPriceForListing() { return mPriceForListing; }
+
private:
LLUUID mAvatarId;
LLUUID mClassifiedId;
LLVector3d mPosGlobal;
+ std::string mLocationText;
+ U32 mCategory;
+ U32 mContentType;
+ bool mAutoRenew;
+ S32 mPriceForListing;
};
#endif // LL_LLPANELPICKS_H
diff --git a/indra/newview/skins/default/xui/en/menu_picks.xml b/indra/newview/skins/default/xui/en/menu_picks.xml
index 7e07a97016..ebb49c9004 100644
--- a/indra/newview/skins/default/xui/en/menu_picks.xml
+++ b/indra/newview/skins/default/xui/en/menu_picks.xml
@@ -8,6 +8,9 @@
name="pick_info">
<menu_item_call.on_click
function="Pick.Info" />
+ <menu_item_call.on_enable
+ function="Pick.Enable"
+ parameter="info" />
</menu_item_call>
<menu_item_call
label="Edit"
@@ -16,6 +19,9 @@
visible="false">
<menu_item_call.on_click
function="Pick.Edit" />
+ <menu_item_call.on_enable
+ function="Pick.Enable"
+ parameter="edit" />
</menu_item_call>
<menu_item_call
label="Teleport"
@@ -23,6 +29,9 @@
name="pick_teleport">
<menu_item_call.on_click
function="Pick.Teleport" />
+ <menu_item_call.on_enable
+ function="Pick.Enable"
+ parameter="teleport" />
</menu_item_call>
<menu_item_call
label="Map"
@@ -30,6 +39,9 @@
name="pick_map">
<menu_item_call.on_click
function="Pick.Map" />
+ <menu_item_call.on_enable
+ function="Pick.Enable"
+ parameter="map" />
</menu_item_call>
<menu_item_separator
layout="topleft"
@@ -42,5 +54,8 @@
visible="false">
<menu_item_call.on_click
function="Pick.Delete" />
+ <menu_item_call.on_enable
+ function="Pick.Enable"
+ parameter="delete" />
</menu_item_call>
</context_menu>