llpaneldirland.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llpaneldirland.h"
00035 
00036 // linden library includes
00037 #include "llfontgl.h"
00038 #include "llparcel.h"
00039 #include "llqueryflags.h"
00040 #include "message.h"
00041 
00042 // viewer project includes
00043 #include "llagent.h"
00044 #include "llcheckboxctrl.h"
00045 #include "llcombobox.h"
00046 #include "lllineeditor.h"
00047 #include "llscrolllistctrl.h"
00048 #include "llstatusbar.h"
00049 #include "lluiconstants.h"
00050 #include "lltextbox.h"
00051 #include "llviewercontrol.h"
00052 #include "llviewermessage.h"
00053 
00054 //-----------------------------------------------------------------------------
00055 // Constants
00056 //-----------------------------------------------------------------------------
00057 
00058 static const char FIND_ALL[] = "All Types";
00059 static const char FIND_AUCTION[] = "Auction";
00060 static const char FIND_MAINLANDSALES[] = "Mainland Sales";
00061 static const char FIND_ESTATESALES[] = "Estate Sales";
00062 
00063 const char PG_ONLY[]     = "PG only";
00064 const char MATURE_ONLY[] = "Mature only";
00065 const char PG_MATURE[]   = "PG & Mature";
00066 
00067 LLPanelDirLand::LLPanelDirLand(const std::string& name, LLFloaterDirectory* floater)
00068         :       LLPanelDirBrowser(name, floater)
00069 {
00070 }
00071 
00072 BOOL LLPanelDirLand::postBuild()
00073 {
00074         LLPanelDirBrowser::postBuild();
00075 
00076         childSetValue("type", gSavedSettings.getString("FindLandType"));
00077 
00078         if (gAgent.isTeen())
00079         {
00080                 childSetValue("rating", PG_ONLY);
00081                 childDisable("rating");
00082         }
00083 
00084         childSetCommitCallback("pricecheck", onCommitPrice, this);
00085         childSetCommitCallback("areacheck", onCommitArea, this);
00086 
00087         childSetValue("priceedit", gStatusBar->getBalance());
00088         childSetEnabled("priceedit", gSavedSettings.getBOOL("FindLandPrice"));
00089         childSetPrevalidate("priceedit", LLLineEditor::prevalidateNonNegativeS32);
00090         
00091         childSetEnabled("areaedit", gSavedSettings.getBOOL("FindLandArea"));
00092         childSetPrevalidate("areaedit", LLLineEditor::prevalidateNonNegativeS32);
00093 
00094         childSetAction("Search", onClickSearchCore, this);
00095         setDefaultBtn("Search");
00096 
00097         mCurrentSortColumn = "per_meter";
00098 
00099         LLScrollListCtrl* results = (LLScrollListCtrl*)getChildByName("results");
00100         if (results)
00101         {
00102                 results->setSortChangedCallback(onClickSort);
00103                 results->sortByColumn(mCurrentSortColumn,mCurrentSortAscending);
00104         }
00105 
00106         return TRUE;
00107 }
00108 
00109 LLPanelDirLand::~LLPanelDirLand()
00110 {
00111         // Children all cleaned up by default view destructor.
00112 }
00113 
00114 
00115 void LLPanelDirLand::onClickSort(void* data)
00116 {
00117         LLPanelDirLand* self = (LLPanelDirLand*)data;
00118         if (!self) return;
00119         self->performQuery();
00120 }
00121 
00122 // static 
00123 void LLPanelDirLand::onCommitPrice(LLUICtrl* ctrl, void* data)
00124 {
00125         LLPanelDirLand* self = (LLPanelDirLand*)data;
00126         LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
00127 
00128         if (!self || !check) return;
00129         self->childSetEnabled("priceedit", check->get());
00130 }
00131 
00132 // static 
00133 void LLPanelDirLand::onCommitArea(LLUICtrl* ctrl, void* data)
00134 {
00135         LLPanelDirLand* self = (LLPanelDirLand*)data;
00136         LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
00137 
00138         if (!self || !check) return;
00139         self->childSetEnabled("areaedit", check->get());
00140 }
00141 
00142 void LLPanelDirLand::performQuery()
00143 {
00144         LLMessageSystem* msg = gMessageSystem;
00145 
00146         setupNewSearch();
00147 
00148         // We could change the UI to allow arbitrary combinations of these options
00149         U32 search_type = ST_ALL;
00150         const std::string& type = childGetValue("type").asString();
00151         if(!type.empty())
00152         {
00153                 if (FIND_AUCTION == type) search_type = ST_AUCTION;
00154                 else if(FIND_MAINLANDSALES == type) search_type = ST_MAINLAND;
00155                 else if(FIND_ESTATESALES == type) search_type = ST_ESTATE;
00156         }
00157 
00158         U32 query_flags = 0x0;
00159         if (gAgent.isTeen()) query_flags |= DFQ_PG_SIMS_ONLY;
00160 
00161         const std::string& rating = childGetValue("rating").asString();
00162         if (rating == PG_ONLY)
00163         {
00164                 query_flags |= DFQ_PG_SIMS_ONLY;
00165         }
00166         else if (rating == MATURE_ONLY)
00167         {
00168                 query_flags |= DFQ_MATURE_SIMS_ONLY;
00169         }
00170 
00171         LLScrollListCtrl* list = (LLScrollListCtrl*)getChildByName("results");
00172         if (list)
00173         {
00174                 std::string sort_name = list->getSortColumnName();
00175                 BOOL sort_asc = list->getSortAscending();
00176 
00177                 if (sort_name == "name")
00178                 {
00179                         query_flags |= DFQ_NAME_SORT;
00180                 }
00181                 else if (sort_name == "price")
00182                 {
00183                         query_flags |= DFQ_PRICE_SORT;
00184                 }
00185                 else if (sort_name == "per_meter")
00186                 {
00187                         query_flags |= DFQ_PER_METER_SORT;
00188                 }
00189                 else if (sort_name == "area")
00190                 {
00191                         query_flags |= DFQ_AREA_SORT;
00192                 }
00193 
00194                 if (sort_asc)
00195                 {
00196                         query_flags |= DFQ_SORT_ASC;
00197                 }
00198         }
00199 
00200         if (childGetValue("pricecheck").asBoolean())
00201         {
00202                 query_flags |= DFQ_LIMIT_BY_PRICE;
00203         }
00204 
00205         if (childGetValue("areacheck").asBoolean())
00206         {
00207                 query_flags |= DFQ_LIMIT_BY_AREA;
00208         }
00209 
00210         msg->newMessage("DirLandQuery");
00211         msg->nextBlock("AgentData");
00212         msg->addUUID("AgentID", gAgent.getID());
00213         msg->addUUID("SessionID", gAgent.getSessionID());
00214         msg->nextBlock("QueryData");
00215         msg->addUUID("QueryID", getSearchID());
00216         msg->addU32("QueryFlags", query_flags);
00217         msg->addU32("SearchType", search_type);
00218         msg->addS32("Price", childGetValue("priceedit").asInteger());
00219         msg->addS32("Area", childGetValue("areaedit").asInteger());
00220         msg->addS32Fast(_PREHASH_QueryStart,mSearchStart);
00221         gAgent.sendReliableMessage();
00222 }

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