aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelclassified.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llpanelclassified.cpp')
-rw-r--r--linden/indra/newview/llpanelclassified.cpp64
1 files changed, 56 insertions, 8 deletions
diff --git a/linden/indra/newview/llpanelclassified.cpp b/linden/indra/newview/llpanelclassified.cpp
index 7a2542d..408f91a 100644
--- a/linden/indra/newview/llpanelclassified.cpp
+++ b/linden/indra/newview/llpanelclassified.cpp
@@ -60,6 +60,7 @@
60#include "llfloaterworldmap.h" 60#include "llfloaterworldmap.h"
61#include "llviewergenericmessage.h" // send_generic_message 61#include "llviewergenericmessage.h" // send_generic_message
62#include "llviewerwindow.h" // for window width, height 62#include "llviewerwindow.h" // for window width, height
63#include "viewer.h" // app_abort_quit()
63 64
64const S32 MINIMUM_PRICE_FOR_LISTING = 50; // L$ 65const S32 MINIMUM_PRICE_FOR_LISTING = 50; // L$
65 66
@@ -97,11 +98,12 @@ std::list<LLPanelClassified*> LLPanelClassified::sAllPanels;
97LLPanelClassified::LLPanelClassified(BOOL in_finder) 98LLPanelClassified::LLPanelClassified(BOOL in_finder)
98: LLPanel("Classified Panel"), 99: LLPanel("Classified Panel"),
99 mInFinder(in_finder), 100 mInFinder(in_finder),
101 mDirty(false),
102 mForceClose(false),
100 mClassifiedID(), 103 mClassifiedID(),
101 mCreatorID(), 104 mCreatorID(),
102 mPriceForListing(0), 105 mPriceForListing(0),
103 mDataRequested(FALSE), 106 mDataRequested(FALSE),
104 mEnableCommit(FALSE),
105 mPaidFor(FALSE), 107 mPaidFor(FALSE),
106 mPosGlobal(), 108 mPosGlobal(),
107 mSnapshotCtrl(NULL), 109 mSnapshotCtrl(NULL),
@@ -152,7 +154,7 @@ void LLPanelClassified::reset()
152 // Don't request data, this isn't valid 154 // Don't request data, this isn't valid
153 mDataRequested = TRUE; 155 mDataRequested = TRUE;
154 156
155 mEnableCommit = FALSE; 157 mDirty = false;
156 mPaidFor = FALSE; 158 mPaidFor = FALSE;
157 159
158 mPosGlobal.clearVec(); 160 mPosGlobal.clearVec();
@@ -235,7 +237,6 @@ BOOL LLPanelClassified::postBuild()
235 mUpdateBtn = LLUICtrlFactory::getButtonByName(this, "classified_update_btn"); 237 mUpdateBtn = LLUICtrlFactory::getButtonByName(this, "classified_update_btn");
236 mUpdateBtn->setClickedCallback(onClickUpdate); 238 mUpdateBtn->setClickedCallback(onClickUpdate);
237 mUpdateBtn->setCallbackUserData(this); 239 mUpdateBtn->setCallbackUserData(this);
238 mEnableCommit = TRUE;
239 240
240 if (!mInFinder) 241 if (!mInFinder)
241 { 242 {
@@ -268,12 +269,58 @@ void LLPanelClassified::apply()
268{ 269{
269 // Apply is used for automatically saving results, so only 270 // Apply is used for automatically saving results, so only
270 // do that if there is a difference, and this is a save not create. 271 // do that if there is a difference, and this is a save not create.
271 if (mEnableCommit && mPaidFor) 272 if (mDirty && mPaidFor)
272 { 273 {
273 sendClassifiedInfoUpdate(); 274 sendClassifiedInfoUpdate();
274 } 275 }
275} 276}
276 277
278
279// static
280void LLPanelClassified::saveCallback(S32 option, void* data)
281{
282 LLPanelClassified* self = (LLPanelClassified*)data;
283 switch(option)
284 {
285 case 0: // Save
286 self->sendClassifiedInfoUpdate();
287 // fall through to close
288
289 case 1: // Don't Save
290 {
291 self->mForceClose = true;
292 // Close containing floater
293 LLView* view = self;
294 while (view)
295 {
296 if (view->getWidgetType() == WIDGET_TYPE_FLOATER)
297 {
298 LLFloater* f = (LLFloater*)view;
299 f->close();
300 break;
301 }
302 view = view->getParent();
303 }
304 }
305 break;
306
307 case 2: // Cancel
308 default:
309 app_abort_quit();
310 break;
311 }
312}
313
314BOOL LLPanelClassified::canClose()
315{
316 if (mForceClose || !mDirty) return TRUE;
317
318 LLString::format_map_t args;
319 args["[NAME]"] = mNameEditor->getText();
320 LLAlertDialog::showXml("ClassifiedSave", args, saveCallback, this);
321 return FALSE;
322}
323
277// Fill in some reasonable defaults for a new classified. 324// Fill in some reasonable defaults for a new classified.
278void LLPanelClassified::initNewClassified() 325void LLPanelClassified::initNewClassified()
279{ 326{
@@ -416,6 +463,8 @@ void LLPanelClassified::sendClassifiedInfoUpdate()
416 msg->addU8Fast(_PREHASH_ClassifiedFlags, flags); 463 msg->addU8Fast(_PREHASH_ClassifiedFlags, flags);
417 msg->addS32("PriceForListing", mPriceForListing); 464 msg->addS32("PriceForListing", mPriceForListing);
418 gAgent.sendReliableMessage(); 465 gAgent.sendReliableMessage();
466
467 mDirty = false;
419} 468}
420 469
421 470
@@ -627,7 +676,7 @@ void LLPanelClassified::refresh()
627 mSetBtn->setVisible(is_self); 676 mSetBtn->setVisible(is_self);
628 mSetBtn->setEnabled(is_self); 677 mSetBtn->setEnabled(is_self);
629 678
630 mUpdateBtn->setEnabled(is_self && mEnableCommit); 679 mUpdateBtn->setEnabled(is_self && mDirty);
631 mUpdateBtn->setVisible(is_self); 680 mUpdateBtn->setVisible(is_self);
632 } 681 }
633} 682}
@@ -710,7 +759,6 @@ void LLPanelClassified::callbackConfirmPublish(S32 option, void* data)
710 LLTabContainerVertical* tab = (LLTabContainerVertical*)self->getParent(); 759 LLTabContainerVertical* tab = (LLTabContainerVertical*)self->getParent();
711 tab->setCurrentTabName(self->mNameEditor->getText()); 760 tab->setCurrentTabName(self->mNameEditor->getText());
712 } 761 }
713 self->mEnableCommit = FALSE;
714} 762}
715 763
716// static 764// static
@@ -789,14 +837,14 @@ void LLPanelClassified::onCommitAny(LLUICtrl* ctrl, void* data)
789 LLPanelClassified* self = (LLPanelClassified*)data; 837 LLPanelClassified* self = (LLPanelClassified*)data;
790 if (self) 838 if (self)
791 { 839 {
792 self->mEnableCommit = TRUE; 840 self->mDirty = true;
793 } 841 }
794} 842}
795 843
796// static 844// static
797void LLPanelClassified::onFocusReceived(LLUICtrl* ctrl, void* data) 845void LLPanelClassified::onFocusReceived(LLUICtrl* ctrl, void* data)
798{ 846{
799 // first, allow the data to be saved 847 // allow the data to be saved
800 onCommitAny(ctrl, data); 848 onCommitAny(ctrl, data);
801} 849}
802 850