00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llenum.h"
00035
00036 #include "llpaneldirclassified.h"
00037
00038 #include "llclassifiedflags.h"
00039
00040
00041 #include "llfontgl.h"
00042 #include "message.h"
00043 #include "llqueryflags.h"
00044
00045
00046 #include "llagent.h"
00047 #include "llbutton.h"
00048 #include "llcontrol.h"
00049 #include "llcombobox.h"
00050 #include "llclassifiedinfo.h"
00051 #include "lluiconstants.h"
00052 #include "llpaneldirbrowser.h"
00053 #include "lltextbox.h"
00054
00055 #include "llcheckboxctrl.h"
00056 #include "llfloaterdirectory.h"
00057 #include "lllineeditor.h"
00058 #include "llpaneldirbrowser.h"
00059 #include "lltextbox.h"
00060 #include "llviewermessage.h"
00061 #include "llvieweruictrlfactory.h"
00062 #include "llworldmap.h"
00063
00064
00065 #include "llfloateravatarinfo.h"
00066 #include "llviewermenu.h"
00067
00068
00069
00070
00071
00072 LLPanelDirClassified::LLPanelDirClassified(const char* name, LLFloaterDirectory* floater)
00073 : LLPanelDirBrowser(name, floater)
00074 {
00075 }
00076
00077 BOOL LLPanelDirClassified::postBuild()
00078 {
00079 LLPanelDirBrowser::postBuild();
00080
00081
00082 if (gAgent.isTeen())
00083 {
00084 childSetValue("incmature", FALSE);
00085 childHide("incmature");
00086 }
00087
00088
00089 childSetKeystrokeCallback("name", onKeystrokeNameClassified, this);
00090
00091 childSetAction("Search", onClickSearchCore, this);
00092 childSetAction("Browse", onClickSearchCore, this);
00093 setDefaultBtn( "Browse" );
00094
00095 childSetAction("Place an Ad...", onClickCreateNewClassified, this);
00096
00097 childSetAction("Delete", onClickDelete, this);
00098 childDisable("Delete");
00099 childHide("Delete");
00100
00101
00102
00103
00104 return TRUE;
00105 }
00106
00107
00108 LLPanelDirClassified::~LLPanelDirClassified()
00109 {
00110
00111 }
00112
00113
00114 void LLPanelDirClassified::draw()
00115 {
00116 refresh();
00117
00118 LLPanelDirBrowser::draw();
00119 }
00120
00121 void LLPanelDirClassified::refresh()
00122 {
00123 BOOL godlike = gAgent.isGodlike();
00124 childSetVisible("Delete", godlike);
00125 childSetEnabled("Delete", godlike);
00126 }
00127
00128
00129 void LLPanelDirClassified::onClickCreateNewClassified(void *userdata)
00130 {
00131 LLFloaterAvatarInfo::showFromObject(gAgent.getID(), "Classified");
00132 }
00133
00134
00135 void LLPanelDirClassified::onClickDelete(void *userdata)
00136 {
00137 LLPanelDirClassified *self = (LLPanelDirClassified *)userdata;
00138
00139 LLUUID classified_id;
00140 S32 type;
00141
00142 self->getSelectedInfo(&classified_id, &type);
00143
00144
00145
00146 self->setupNewSearch();
00147
00148 LLMessageSystem* msg = gMessageSystem;
00149
00150 msg->newMessageFast(_PREHASH_ClassifiedGodDelete);
00151 msg->nextBlockFast(_PREHASH_AgentData);
00152 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00153 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00154 msg->nextBlockFast(_PREHASH_Data);
00155 msg->addUUIDFast(_PREHASH_ClassifiedID, classified_id);
00156 msg->addUUIDFast(_PREHASH_QueryID, self->mSearchID);
00157 gAgent.sendReliableMessage();
00158 }
00159
00160
00161 void LLPanelDirClassified::performQuery()
00162 {
00163 lldebugs << "LLPanelDirClassified::performQuery()" << llendl;
00164
00165 setupNewSearch();
00166
00167
00168 LLMessageSystem *msg = gMessageSystem;
00169 msg->newMessageFast(_PREHASH_DirClassifiedQuery);
00170 msg->nextBlockFast(_PREHASH_AgentData);
00171 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
00172 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00173
00174 BOOL filter_mature = !childGetValue("incmature").asBoolean();
00175 BOOL filter_auto_renew = FALSE;
00176 U32 query_flags = pack_classified_flags(filter_mature, filter_auto_renew);
00177
00178
00179 U32 category = childGetValue("Category").asInteger();
00180
00181 msg->nextBlockFast(_PREHASH_QueryData);
00182 msg->addUUIDFast(_PREHASH_QueryID, mSearchID );
00183 msg->addStringFast(_PREHASH_QueryText, childGetValue("name").asString());
00184 msg->addU32Fast(_PREHASH_QueryFlags, query_flags);
00185 msg->addU32Fast(_PREHASH_Category, category);
00186 msg->addS32Fast(_PREHASH_QueryStart,mSearchStart);
00187
00188 gAgent.sendReliableMessage();
00189 }
00190
00191 void LLPanelDirClassified::onKeystrokeNameClassified(LLLineEditor* line, void* data)
00192 {
00193 LLPanelDirClassified *self = (LLPanelDirClassified*)data;
00194
00195 S32 len = line->getLength();
00196 if (len == 0
00197 || len >= 3)
00198 {
00199
00200 self->setDefaultBtn( "Search" );
00201 self->childEnable("Search");
00202 }
00203 else
00204 {
00205 self->setDefaultBtn();
00206 self->childDisable("Search");
00207 }
00208
00209
00210 if (len > 0)
00211 {
00212 self->childSetVisible("Search", TRUE);
00213 self->childSetVisible("Browse", FALSE);
00214 }
00215 else
00216 {
00217 self->setDefaultBtn( "Browse" );
00218 self->childSetVisible("Search", FALSE);
00219 self->childSetVisible("Browse", TRUE);
00220 }
00221 }