llfloaterclassified.cpp

Go to the documentation of this file.
00001 
00033 #include "llviewerprecompiledheaders.h"
00034 
00035 #include "llfloaterclassified.h"
00036 
00037 // viewer project includes
00038 #include "llcommandhandler.h"
00039 #include "llpanelclassified.h"
00040 
00041 // linden library includes
00042 #include "lluuid.h"
00043 #include "lluictrlfactory.h"
00044 
00045 //-----------------------------------------------------------------------------
00046 // Globals
00047 //-----------------------------------------------------------------------------
00048 
00049 LLMap< const LLUUID, LLFloaterClassifiedInfo* > gClassifiedInfoInstances;
00051 // LLFloaterEventDisplay
00052 
00053 class LLClassifiedHandler : public LLCommandHandler
00054 {
00055 public:
00056         // don't allow from external browsers
00057         LLClassifiedHandler() : LLCommandHandler("classified", false) { }
00058         bool handle(const LLSD& tokens, const LLSD& queryMap)
00059         {
00060                 if (tokens.size() < 2)
00061                 {
00062                         return false;
00063                 }
00064                 LLUUID classified_id;
00065                 if (!classified_id.set(tokens[0], FALSE))
00066                 {
00067                         return false;
00068                 }
00069 
00070                 if (tokens[1].asString() == "about")
00071                 {
00072                         LLFloaterClassifiedInfo::show(classified_id);
00073                         return true;
00074                 }
00075                 return false;
00076         }
00077 };
00078 LLClassifiedHandler gClassifiedHandler;
00079 
00080 LLFloaterClassifiedInfo::LLFloaterClassifiedInfo(const std::string& name, const LLUUID &id)
00081 :       LLFloater(name),
00082 mClassifiedID( id )
00083 {
00084         mFactoryMap["classified_details_panel"] = LLCallbackMap(LLFloaterClassifiedInfo::createClassifiedDetail, this);
00085         LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preview_classified.xml", &getFactoryMap());
00086         gClassifiedInfoInstances.addData(id, this);
00087 }
00088 
00089 LLFloaterClassifiedInfo::~LLFloaterClassifiedInfo()
00090 {
00091         // child views automatically deleted
00092         gClassifiedInfoInstances.removeData(mClassifiedID);
00093 
00094 }
00095 
00096 void LLFloaterClassifiedInfo::displayClassifiedInfo(const LLUUID& classified_id)
00097 {
00098         mClassifiedPanel->setClassifiedID(classified_id);
00099         mClassifiedPanel->sendClassifiedInfoRequest();
00100         this->setFrontmost(true);
00101 }
00102 
00103 // static
00104 void* LLFloaterClassifiedInfo::createClassifiedDetail(void* userdata)
00105 {
00106         LLFloaterClassifiedInfo *self = (LLFloaterClassifiedInfo*)userdata;
00107         self->mClassifiedPanel = new LLPanelClassified(true, true);
00108         self->mClassifiedPanel->childSetValue("classified_url", self->mClassifiedID);
00109         return self->mClassifiedPanel;
00110 }
00111 
00112 // static
00113 LLFloaterClassifiedInfo* LLFloaterClassifiedInfo::show(const LLUUID &classified_id)
00114 {
00115         if (classified_id.isNull())
00116         {
00117                 return NULL;
00118         }
00119 
00120         LLFloaterClassifiedInfo *floater;
00121         if (gClassifiedInfoInstances.checkData(classified_id))
00122         {
00123                 // ...bring that window to front
00124                 floater = gClassifiedInfoInstances.getData(classified_id);
00125                 floater->open();        /*Flawfinder: ignore*/
00126                 floater->setFrontmost(true);
00127         }
00128         else
00129         {
00130                 floater =  new LLFloaterClassifiedInfo("calssifiedinfo", classified_id );
00131                 floater->center();
00132                 floater->open();        /*Flawfinder: ignore*/
00133                 floater->displayClassifiedInfo(classified_id);
00134                 floater->setFrontmost(true);
00135         }
00136 
00137         return floater;
00138 }
00139 
00140 

Generated on Fri May 16 08:33:23 2008 for SecondLife by  doxygen 1.5.5