llfloaterdirectory.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llfloaterdirectory.h"
00035 
00036 #include "llpaneldirfind.h"
00037 #include "llpaneldirevents.h"
00038 #include "llpaneldirland.h"
00039 #include "llpaneldirpeople.h"
00040 #include "llpaneldirpopular.h"
00041 #include "llpaneldirgroups.h"
00042 #include "llpaneldirplaces.h"
00043 #include "llpaneldirclassified.h"
00044 #include "llresizehandle.h"
00045 #include "llresmgr.h"
00046 #include "llscrollbar.h"
00047 #include "llbutton.h"
00048 
00049 #include "llkeyboard.h"
00050 #include "llscrollcontainer.h"
00051 #include "llcheckboxctrl.h"
00052 #include "lluiconstants.h"
00053 #include "llviewercontrol.h"
00054 
00055 #include "llagent.h"
00056 #include "llpanelavatar.h"
00057 #include "llpanelevent.h"
00058 #include "llpanelclassified.h"
00059 #include "llpanelgroup.h"
00060 #include "llpanelpick.h"
00061 #include "llpanelplace.h"
00062 #include "llpaneldirland.h"
00063 #include "llfloateravatarinfo.h"
00064 #include "lldir.h"
00065 #include "lluictrlfactory.h"
00066 
00067 LLFloaterDirectory* LLFloaterDirectory::sInstance = NULL;
00068 //static
00069 S32 LLFloaterDirectory::sOldSearchCount = 0; // debug
00070 S32 LLFloaterDirectory::sNewSearchCount = 0; // debug
00071 
00072 
00073 LLFloaterDirectory::LLFloaterDirectory(const std::string& name)
00074 :       LLFloater(name, "FloaterFindRect2", ""),
00075         mMinimizing(false)
00076 {
00077         sInstance = this;
00078 
00079         mFindAllPanel = NULL;
00080         mClassifiedPanel = NULL;
00081         mEventsPanel = NULL;
00082         mLandPanel = NULL;
00083 
00084         mPanelAvatarp = NULL;
00085         mPanelEventp = NULL;
00086         mPanelGroupp = NULL;
00087         mPanelGroupHolderp = NULL;
00088         mPanelPlacep = NULL;
00089         mPanelPlaceSmallp = NULL;
00090         mPanelClassifiedp = NULL;
00091         
00092         // Build the floater with our tab panel classes
00093 
00094         LLCallbackMap::map_t factory_map;
00095         factory_map["find_all_panel"] = LLCallbackMap(createFindAll, this);
00096         factory_map["classified_panel"] = LLCallbackMap(createClassified, this);
00097         factory_map["events_panel"] = LLCallbackMap(createEvents, this);
00098         factory_map["showcase_panel"] = LLCallbackMap(createShowcase, this);
00099         factory_map["places_panel"] = LLCallbackMap(createPlaces, this);
00100         factory_map["land_sales_panel"] = LLCallbackMap(createLand, this);
00101         factory_map["people_panel"] = LLCallbackMap(createPeople, this);
00102         factory_map["groups_panel"] = LLCallbackMap(createGroups, this);
00103 
00104         factory_map["classified_details_panel"] = LLCallbackMap(createClassifiedDetail, this);
00105         factory_map["event_details_panel"] = LLCallbackMap(createEventDetail, this);
00106         factory_map["group_details_panel"] = LLCallbackMap(createGroupDetail, this);
00107         factory_map["group_details_panel_holder"] = LLCallbackMap(createGroupDetailHolder, this);
00108         factory_map["place_details_panel"] = LLCallbackMap(createPlaceDetail, this);
00109         factory_map["place_details_small_panel"] = LLCallbackMap(createPlaceDetailSmall, this);
00110 
00111         factory_map["Panel Avatar"] = LLCallbackMap(createPanelAvatar, this);
00112         
00113         LLUICtrlFactory::getInstance()->buildFloater(this, "floater_directory.xml", &factory_map);
00114         moveResizeHandlesToFront();
00115 
00116         if(mPanelAvatarp)
00117         {
00118                 mPanelAvatarp->selectTab(0);
00119         }
00120         
00121         childSetTabChangeCallback("Directory Tabs", "find_all_panel", onTabChanged, this);
00122         childSetTabChangeCallback("Directory Tabs", "classified_panel", onTabChanged, this);
00123         childSetTabChangeCallback("Directory Tabs", "events_panel", onTabChanged, this);
00124         childSetTabChangeCallback("Directory Tabs", "showcase_panel", onTabChanged, this);
00125         childSetTabChangeCallback("Directory Tabs", "places_panel", onTabChanged, this);
00126         childSetTabChangeCallback("Directory Tabs", "land_sales_panel", onTabChanged, this);
00127         childSetTabChangeCallback("Directory Tabs", "people_panel", onTabChanged, this);
00128         childSetTabChangeCallback("Directory Tabs", "groups_panel", onTabChanged, this);
00129 }
00130 
00131 LLFloaterDirectory::~LLFloaterDirectory()
00132 {
00133         sInstance = NULL;
00134 
00135         //Note: this function is defined in the class LLFloater.
00136         //however, it causes crash if this line is postponed to ~LLFloater(). 
00137         //because it uses some pointers deleted below. That is, those pointers are used again after deleting.
00138         setMinimized( FALSE );
00139 
00140         delete mPanelAvatarp; mPanelAvatarp = NULL;
00141         delete mPanelEventp; mPanelEventp = NULL;
00142         delete mPanelGroupp; mPanelGroupp = NULL;
00143         delete mPanelGroupHolderp; mPanelGroupHolderp = NULL;
00144         delete mPanelPlacep; mPanelPlacep = NULL;
00145         delete mPanelPlaceSmallp; mPanelPlaceSmallp = NULL;
00146         delete mPanelClassifiedp; mPanelClassifiedp = NULL;
00147         gSavedSettings.setBOOL("ShowDirectory", FALSE);
00148 }
00149 
00150 // static
00151 void *LLFloaterDirectory::createFindAll(void* userdata)
00152 {
00153         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00154         self->mFindAllPanel = LLPanelDirFindAllInterface::create(self);
00155         return self->mFindAllPanel;
00156 }
00157 
00158 // static
00159 void* LLFloaterDirectory::createClassified(void* userdata)
00160 {
00161         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00162         self->mClassifiedPanel = new LLPanelDirClassified("classified_panel", self);
00163         return self->mClassifiedPanel;
00164 }
00165 
00166 // static
00167 void* LLFloaterDirectory::createEvents(void* userdata)
00168 {
00169         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00170         self->mEventsPanel = new LLPanelDirEvents("events_panel", self);
00171         return self->mEventsPanel;
00172 }
00173 
00174 // static
00175 void* LLFloaterDirectory::createShowcase(void* userdata)
00176 {
00177         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00178         return new LLPanelDirPopular("showcase_panel", self);
00179 }
00180 
00181 // static
00182 void* LLFloaterDirectory::createPlaces(void* userdata)
00183 {
00184         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00185         return new LLPanelDirPlaces("places_panel", self);
00186 }
00187 
00188 // static
00189 void* LLFloaterDirectory::createLand(void* userdata)
00190 {
00191         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00192         self->mLandPanel = new LLPanelDirLand("land_panel", self);
00193         return self->mLandPanel;
00194 }
00195 
00196 
00197 // static
00198 void* LLFloaterDirectory::createPeople(void* userdata)
00199 {
00200         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00201         return new LLPanelDirPeople("people_panel", self);
00202 }
00203 
00204 // static
00205 void* LLFloaterDirectory::createGroups(void* userdata)
00206 {
00207         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00208         return new LLPanelDirGroups("people_groups", self);
00209 }
00210 
00211 // static
00212 void* LLFloaterDirectory::createClassifiedDetail(void* userdata)
00213 {
00214         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00215         self->mPanelClassifiedp = new LLPanelClassified(true, false);
00216         self->mPanelClassifiedp->setVisible(FALSE);
00217         return self->mPanelClassifiedp;
00218 }
00219 
00220 //----------------------------------------------------------------------------
00221 
00222 void*   LLFloaterDirectory::createPanelAvatar(void*     data)
00223 {
00224         LLFloaterDirectory* self = (LLFloaterDirectory*)data;
00225         self->mPanelAvatarp = new LLPanelAvatar("Avatar", LLRect(), 
00226                 FALSE); // disallow editing in search context (SL-48632)
00227         self->mPanelAvatarp->setVisible(FALSE);
00228         return self->mPanelAvatarp;
00229 
00230 }
00231 
00232 
00233 //----------------------------------------------------------------------------
00234 
00235 // static
00236 void* LLFloaterDirectory::createEventDetail(void* userdata)
00237 {
00238         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00239         self->mPanelEventp = new LLPanelEvent();
00240         LLUICtrlFactory::getInstance()->buildPanel(self->mPanelEventp, "panel_event.xml");
00241         self->mPanelEventp->setVisible(FALSE);
00242         return self->mPanelEventp;
00243 }
00244 
00245 // static
00246 void* LLFloaterDirectory::createGroupDetail(void* userdata)
00247 {
00248         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00249         self->mPanelGroupp = new LLPanelGroup("panel_group.xml",
00250                                                                                   "PanelGroup",
00251                                                                                   gAgent.getGroupID());
00252         self->mPanelGroupp->setAllowEdit(FALSE);
00253         self->mPanelGroupp->setVisible(FALSE);
00254         return self->mPanelGroupp;
00255 }
00256 
00257 // static
00258 void* LLFloaterDirectory::createGroupDetailHolder(void* userdata)
00259 {
00260         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00261         self->mPanelGroupHolderp = new LLPanel("PanelGroupHolder");
00262         self->mPanelGroupHolderp->setVisible(FALSE);
00263         return self->mPanelGroupHolderp;
00264 }
00265 
00266 // static
00267 void* LLFloaterDirectory::createPlaceDetail(void* userdata)
00268 {
00269         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00270         self->mPanelPlacep = new LLPanelPlace();
00271         LLUICtrlFactory::getInstance()->buildPanel(self->mPanelPlacep, "panel_place.xml");
00272         self->mPanelPlacep->setVisible(FALSE);
00273         return self->mPanelPlacep;
00274 }
00275 
00276 // static
00277 void* LLFloaterDirectory::createPlaceDetailSmall(void* userdata)
00278 {
00279         LLFloaterDirectory *self = (LLFloaterDirectory*)userdata;
00280         self->mPanelPlaceSmallp = new LLPanelPlace();
00281         LLUICtrlFactory::getInstance()->buildPanel(self->mPanelPlaceSmallp, "panel_place_small.xml");
00282         self->mPanelPlaceSmallp->setVisible(FALSE);
00283         return self->mPanelPlaceSmallp;
00284 }
00285 
00286 // static
00287 void LLFloaterDirectory::requestClassifieds()
00288 {
00289         if (sInstance && sInstance->mClassifiedPanel)
00290         {
00291                 sInstance->mClassifiedPanel->performQuery();
00292         }
00293 }
00294 
00295 void LLFloaterDirectory::showFindAll(const std::string& search_text)
00296 {
00297         showPanel("find_all_panel");
00298         LLPanelDirFindAllInterface::search(sInstance->mFindAllPanel, search_text);
00299 }
00300 
00301 
00302 void LLFloaterDirectory::showClassified(const LLUUID& classified_id)
00303 {
00304         showPanel("classified_panel");
00305 
00306         if (sInstance->mClassifiedPanel)
00307         {
00308                 sInstance->mClassifiedPanel->selectByUUID(classified_id);
00309         }
00310 }
00311 
00312 
00313 // static
00314 void LLFloaterDirectory::showEvents(S32 event_id)
00315 {
00316         showPanel("events_panel"); 
00317 
00318         if (sInstance->mEventsPanel)
00319         {
00320                 // HACK: force query for today's events
00321                 sInstance->mEventsPanel->setDay(0);
00322                 sInstance->mEventsPanel->performQuery();
00323                 if (event_id != 0)
00324                 {
00325                         sInstance->mEventsPanel->selectEventByID(event_id);     
00326                 }
00327         }
00328 }
00329 
00330 // static
00331 void LLFloaterDirectory::showLandForSale(const LLUUID& parcel_id)
00332 {
00333         showPanel("land_sales_panel");
00334 
00335         if (sInstance->mLandPanel)
00336         {
00337                 sInstance->mLandPanel->selectByUUID(parcel_id);
00338         }
00339 }
00340 
00341 // static
00342 void LLFloaterDirectory::showGroups()
00343 {
00344         showPanel("groups_panel");
00345 }
00346 
00347 // static
00348 void LLFloaterDirectory::refreshGroup(const LLUUID& group_id)
00349 {
00350         if (sInstance && sInstance->mPanelGroupp
00351                 && (sInstance->mPanelGroupp->getID() == group_id) )
00352         {
00353                 sInstance->mPanelGroupp->refreshData();
00354         }
00355 }
00356 
00357 void LLFloaterDirectory::focusCurrentPanel()
00358 {
00359         LLTabContainer* tabs = getChild<LLTabContainer>("Directory Tabs");
00360         if (!tabs) return;
00361 
00362         LLPanel* panel = tabs->getCurrentPanel();
00363         if (!panel) return;
00364 
00365         panel->setFocus(TRUE);
00366 }
00367 
00368 // static
00369 void LLFloaterDirectory::showPanel(const std::string& tabname)
00370 {
00371         // This function gets called when web browser clicks are processed,
00372         // so we don't delete the existing panel, which would delete the 
00373         // web browser instance currently handling the click. JC
00374         if (!sInstance)
00375         {
00376                 sInstance =  new LLFloaterDirectory("directory");
00377         }
00378         sInstance->open();      /*Flawfinder: ignore*/
00379         sInstance->childShowTab("Directory Tabs", tabname);
00380         sInstance->focusCurrentPanel();
00381 }
00382 
00383 // static
00384 void LLFloaterDirectory::toggleFind(void*)
00385 {
00386 #ifndef LL_RELEASE_FOR_DOWNLOAD
00387         delete sInstance;
00388         sInstance = NULL;
00389 #endif
00390         if (!sInstance)
00391         {
00392                 LLString panel = gSavedSettings.getString("LastFindPanel");
00393                 showPanel(panel);
00394 
00395                 // HACK: force query for today's events
00396                 if (sInstance->mEventsPanel)
00397                 {
00398                         sInstance->mEventsPanel->setDay(0);
00399                         //sInstance->mEventsPanel->performQuery(); // Temporary change to help DB - Sabin
00400                 }
00401                 return;
00402         }
00403 
00404         BOOL panel_visible = sInstance->getVisible();
00405         if (!panel_visible)
00406         {
00407                 sInstance->open(); /*Flawfinder: ignore*/
00408                 sInstance->focusCurrentPanel();
00409         }
00410         else
00411         {
00412                 sInstance->close();
00413         }
00414 }
00415 
00416 // static
00417 void LLFloaterDirectory::toggleEvents(void*)
00418 {
00419         if (!sInstance)
00420         {
00421                 showEvents(0);
00422                 return;
00423         }
00424 
00425         BOOL panel_visible = sInstance->getVisible();
00426         if (!panel_visible)
00427         {
00428                 sInstance->open();      /*Flawfinder: ignore*/
00429                 sInstance->showEvents(0);
00430         }
00431         else
00432         {
00433                 LLPanel *current_panel = sInstance->childGetVisibleTab("Directory Tabs");
00434                 if (current_panel == sInstance->mEventsPanel)
00435                 {
00436                         sInstance->close();
00437                 }
00438                 else
00439                 {
00440                         sInstance->showEvents(0);
00441                 }
00442         }
00443 }
00444 
00445 // static
00446 void LLFloaterDirectory::hide(void*)
00447 {
00448         if (sInstance)
00449         {
00450                 sInstance->close();
00451         }
00452 }
00453 
00454 // virtual
00455 void LLFloaterDirectory::setVisible(BOOL visible)
00456 {
00457         gSavedSettings.setBOOL("ShowDirectory", visible);
00458         LLFloater::setVisible(visible);
00459 }
00460 
00461 void LLFloaterDirectory::onClose(bool app_quitting)
00462 {
00463         setVisible(FALSE);
00464 }
00465 
00466 // static
00467 void LLFloaterDirectory::onTabChanged(void* data, bool from_click)
00468 {
00469         LLFloaterDirectory* self = (LLFloaterDirectory*)data;
00470         if (!self) return;
00471 
00472         LLPanel *panel = self->childGetVisibleTab("Directory Tabs");
00473         if (panel)
00474         {
00475                 gSavedSettings.setString("LastFindPanel", panel->getName());
00476         }
00477 }
00478 
00479 void LLFloaterDirectory::hideAllDetailPanels()
00480 {
00481         if (mPanelAvatarp) mPanelAvatarp->setVisible(FALSE);
00482         if (mPanelEventp) mPanelEventp->setVisible(FALSE);
00483         if (mPanelGroupp) mPanelGroupp->setVisible(FALSE);
00484         if (mPanelGroupHolderp) mPanelGroupHolderp->setVisible(FALSE);
00485         if (mPanelPlacep) mPanelPlacep->setVisible(FALSE);
00486         if (mPanelPlaceSmallp) mPanelPlaceSmallp->setVisible(FALSE);
00487         if (mPanelClassifiedp) mPanelClassifiedp->setVisible(FALSE);
00488 }

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