llfloaterparcel.cpp

Go to the documentation of this file.
00001 
00033 #include "llviewerprecompiledheaders.h"
00034 
00035 #include "llfloaterparcel.h"
00036 
00037 // viewer project includes
00038 #include "llcommandhandler.h"
00039 #include "llpanelplace.h"
00040 
00041 // linden library includes
00042 #include "lluuid.h"
00043 #include "lluictrlfactory.h"
00044 
00045 //-----------------------------------------------------------------------------
00046 // Globals
00047 //-----------------------------------------------------------------------------
00048 
00049 LLMap< const LLUUID, LLFloaterParcelInfo* > gPlaceInfoInstances;
00050 
00051 class LLParcelHandler : public LLCommandHandler
00052 {
00053 public:
00054         // don't allow from external browsers
00055         LLParcelHandler() : LLCommandHandler("parcel", false) { }
00056         bool handle(const LLSD& params, const LLSD& queryMap)
00057         {
00058                 if (params.size() < 2)
00059                 {
00060                         return false;
00061                 }
00062                 LLUUID parcel_id;
00063                 if (!parcel_id.set(params[0], FALSE))
00064                 {
00065                         return false;
00066                 }
00067                 if (params[1].asString() == "about")
00068                 {
00069                         LLFloaterParcelInfo::show(parcel_id);
00070                         return true;
00071                 }
00072                 return false;
00073         }
00074 };
00075 LLParcelHandler gParcelHandler;
00076 
00077 //-----------------------------------------------------------------------------
00078 // Member functions
00079 //-----------------------------------------------------------------------------
00080 
00081 //----------------------------------------------------------------------------
00082 
00083 void*   LLFloaterParcelInfo::createPanelPlace(void*     data)
00084 {
00085         LLFloaterParcelInfo* self = (LLFloaterParcelInfo*)data;
00086         self->mPanelParcelp = new LLPanelPlace(); // allow edit self
00087         LLUICtrlFactory::getInstance()->buildPanel(self->mPanelParcelp, "panel_place.xml");
00088         return self->mPanelParcelp;
00089 }
00090 
00091 //----------------------------------------------------------------------------
00092 
00093 
00094 LLFloaterParcelInfo::LLFloaterParcelInfo(const std::string& name, const LLUUID &parcel_id)
00095 :       LLFloater(name),
00096         mParcelID( parcel_id )
00097 {
00098         mFactoryMap["place_details_panel"] = LLCallbackMap(LLFloaterParcelInfo::createPanelPlace, this);
00099         LLUICtrlFactory::getInstance()->buildFloater(this, "floater_preview_url.xml", &getFactoryMap());
00100         gPlaceInfoInstances.addData(parcel_id, this);
00101 }
00102 
00103 // virtual
00104 LLFloaterParcelInfo::~LLFloaterParcelInfo()
00105 {
00106         // child views automatically deleted
00107         gPlaceInfoInstances.removeData(mParcelID);
00108 
00109 }
00110 
00111 void LLFloaterParcelInfo::displayParcelInfo(const LLUUID& parcel_id)
00112 {
00113         mPanelParcelp->setParcelID(parcel_id);
00114 }
00115 
00116 // static
00117 LLFloaterParcelInfo* LLFloaterParcelInfo::show(const LLUUID &parcel_id)
00118 {
00119         if (parcel_id.isNull())
00120         {
00121                 return NULL;
00122         }
00123 
00124         LLFloaterParcelInfo *floater;
00125         if (gPlaceInfoInstances.checkData(parcel_id))
00126         {
00127                 // ...bring that window to front
00128                 floater = gPlaceInfoInstances.getData(parcel_id);
00129                 floater->open();        /*Flawfinder: ignore*/
00130                 floater->setFrontmost(true);
00131         }
00132         else
00133         {
00134                 floater =  new LLFloaterParcelInfo("parcelinfo", parcel_id );
00135                 floater->center();
00136                 floater->open();        /*Flawfinder: ignore*/
00137                 floater->displayParcelInfo(parcel_id);
00138                 floater->setFrontmost(true);
00139         }
00140 
00141         return floater;
00142 }
00143 
00144 

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