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

Generated on Thu Jul 1 06:08:33 2010 for Second Life Viewer by  doxygen 1.4.7