diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterinspect.cpp | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterinspect.cpp b/linden/indra/newview/llfloaterinspect.cpp new file mode 100644 index 0000000..40132ce --- /dev/null +++ b/linden/indra/newview/llfloaterinspect.cpp | |||
@@ -0,0 +1,221 @@ | |||
1 | #include "llviewerprecompiledheaders.h" | ||
2 | #include "llfloateravatarinfo.h" | ||
3 | #include "llfloaterinspect.h" | ||
4 | #include "llfloatertools.h" | ||
5 | #include "llcachename.h" | ||
6 | #include "llscrolllistctrl.h" | ||
7 | #include "llselectmgr.h" | ||
8 | #include "lltoolcomp.h" | ||
9 | #include "lltoolmgr.h" | ||
10 | #include "llviewercontrol.h" | ||
11 | #include "llviewerobject.h" | ||
12 | #include "llvieweruictrlfactory.h" | ||
13 | |||
14 | LLFloaterInspect* LLFloaterInspect::sInstance = NULL; | ||
15 | |||
16 | LLFloaterInspect::LLFloaterInspect(void) : | ||
17 | LLFloater("Inspect Object"), | ||
18 | mDirty(FALSE) | ||
19 | { | ||
20 | sInstance = this; | ||
21 | gUICtrlFactory->buildFloater(this, "floater_inspect.xml"); | ||
22 | } | ||
23 | |||
24 | LLFloaterInspect::~LLFloaterInspect(void) | ||
25 | { | ||
26 | if(!gFloaterTools->getVisible()) | ||
27 | { | ||
28 | if(gToolMgr->getCurrentTool(MASK_NONE) == gToolInspect) | ||
29 | { | ||
30 | select_tool(gToolNull); | ||
31 | } | ||
32 | gSelectMgr->deselectAll(); | ||
33 | // Switch back to basic toolset | ||
34 | gCurrentToolset = gBasicToolset; | ||
35 | gBasicToolset->selectFirstTool(); | ||
36 | gToolMgr->useSelectedTool( gBasicToolset ); | ||
37 | } | ||
38 | else | ||
39 | { | ||
40 | gFloaterTools->setFocus(TRUE); | ||
41 | } | ||
42 | sInstance = NULL; | ||
43 | } | ||
44 | |||
45 | BOOL LLFloaterInspect::isVisible() | ||
46 | { | ||
47 | return (!!sInstance); | ||
48 | } | ||
49 | |||
50 | void LLFloaterInspect::show(void* ignored) | ||
51 | { | ||
52 | if(sInstance) | ||
53 | { | ||
54 | sInstance->open(); | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | LLFloaterInspect* self = new LLFloaterInspect; | ||
59 | self->open(); | ||
60 | } | ||
61 | select_tool(gToolInspect); | ||
62 | } | ||
63 | |||
64 | void LLFloaterInspect::onClickCreatorProfile(void* ctrl) | ||
65 | { | ||
66 | if(sInstance->mObjectList->getAllSelected().size() == 0) return; | ||
67 | LLSelectNode* obj = gSelectMgr->getFirstNode(); | ||
68 | LLUUID obj_id, creator_id; | ||
69 | obj_id = sInstance->mObjectList->getFirstSelected()->getUUID(); | ||
70 | while(obj) | ||
71 | { | ||
72 | if(obj_id == obj->getObject()->getID()) | ||
73 | { | ||
74 | creator_id = obj->mPermissions->getCreator(); | ||
75 | break; | ||
76 | } | ||
77 | obj = gSelectMgr->getNextNode(); | ||
78 | } | ||
79 | if(obj) | ||
80 | { | ||
81 | LLFloaterAvatarInfo::showFromDirectory(creator_id); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | void LLFloaterInspect::onClickOwnerProfile(void* ctrl) | ||
86 | { | ||
87 | if(sInstance->mObjectList->getAllSelected().size() == 0) return; | ||
88 | LLSelectNode* obj = gSelectMgr->getFirstNode(); | ||
89 | LLUUID obj_id, owner_id; | ||
90 | obj_id = sInstance->mObjectList->getFirstSelected()->getUUID(); | ||
91 | while(obj) | ||
92 | { | ||
93 | if(obj_id == obj->getObject()->getID()) | ||
94 | { | ||
95 | owner_id = obj->mPermissions->getOwner(); | ||
96 | break; | ||
97 | } | ||
98 | obj = gSelectMgr->getNextNode(); | ||
99 | } | ||
100 | if(obj) | ||
101 | { | ||
102 | LLFloaterAvatarInfo::showFromDirectory(owner_id); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | BOOL LLFloaterInspect::postBuild() | ||
107 | { | ||
108 | mObjectList = LLUICtrlFactory::getScrollListByName(this, "object_list"); | ||
109 | childSetAction("button owner",onClickOwnerProfile, this); | ||
110 | childSetAction("button creator",onClickCreatorProfile, this); | ||
111 | childSetCommitCallback("object_list", onSelectObject); | ||
112 | refresh(); | ||
113 | return TRUE; | ||
114 | } | ||
115 | |||
116 | void LLFloaterInspect::onSelectObject(LLUICtrl* ctrl, void* user_data) | ||
117 | { | ||
118 | if(LLFloaterInspect::getSelectedUUID() != LLUUID::null) | ||
119 | { | ||
120 | sInstance->childSetEnabled("button owner", true); | ||
121 | sInstance->childSetEnabled("button creator", true); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | LLUUID LLFloaterInspect::getSelectedUUID() | ||
126 | { | ||
127 | if(sInstance) | ||
128 | { | ||
129 | if(sInstance->mObjectList->getAllSelected().size() > 0) return sInstance->mObjectList->getFirstSelected()->getUUID(); | ||
130 | } | ||
131 | return LLUUID::null; | ||
132 | } | ||
133 | |||
134 | void LLFloaterInspect::refresh() | ||
135 | { | ||
136 | LLUUID creator_id; | ||
137 | LLString creator_name; | ||
138 | S32 pos = mObjectList->getScrollPos(); | ||
139 | childSetEnabled("button owner", false); | ||
140 | childSetEnabled("button creator", false); | ||
141 | LLUUID selected_uuid; | ||
142 | S32 selected_index = mObjectList->getFirstSelectedIndex(); | ||
143 | if(selected_index > -1) selected_uuid = mObjectList->getFirstSelected()->getUUID(); | ||
144 | mObjectList->operateOnAll(LLScrollListCtrl::OP_DELETE); | ||
145 | //List all transient objects, then all linked objects | ||
146 | LLSelectNode* obj = gSelectMgr->getFirstNode(); | ||
147 | LLSD row; | ||
148 | while(obj) | ||
149 | { | ||
150 | char owner_first_name[MAX_STRING], owner_last_name[MAX_STRING]; | ||
151 | char creator_first_name[MAX_STRING], creator_last_name[MAX_STRING]; | ||
152 | char time[MAX_STRING]; | ||
153 | std::ostringstream owner_name, creator_name, date; | ||
154 | time_t timestamp = (time_t) (obj->mCreationDate/1000000); | ||
155 | LLString::copy(time, ctime(×tamp), MAX_STRING); | ||
156 | time[24] = '\0'; | ||
157 | date << obj->mCreationDate; | ||
158 | gCacheName->getName(obj->mPermissions->getOwner(), owner_first_name, owner_last_name); | ||
159 | owner_name << owner_first_name << " " << owner_last_name; | ||
160 | gCacheName->getName(obj->mPermissions->getCreator(), creator_first_name, creator_last_name); | ||
161 | creator_name << creator_first_name << " " << creator_last_name; | ||
162 | row["id"] = obj->getObject()->getID(); | ||
163 | row["columns"][0]["column"] = "object_name"; | ||
164 | row["columns"][0]["type"] = "text"; | ||
165 | // make sure we're either at the top of the link chain | ||
166 | // or top of the editable chain, for attachments | ||
167 | if(!(obj->getObject()->isRoot() || obj->getObject()->isRootEdit())) | ||
168 | { | ||
169 | row["columns"][0]["value"] = LLString(" ") + obj->mName; | ||
170 | } | ||
171 | else | ||
172 | { | ||
173 | row["columns"][0]["value"] = obj->mName; | ||
174 | } | ||
175 | row["columns"][1]["column"] = "owner_name"; | ||
176 | row["columns"][1]["type"] = "text"; | ||
177 | row["columns"][1]["value"] = owner_name.str().c_str(); | ||
178 | row["columns"][2]["column"] = "creator_name"; | ||
179 | row["columns"][2]["type"] = "text"; | ||
180 | row["columns"][2]["value"] = creator_name.str().c_str(); | ||
181 | row["columns"][3]["column"] = "creation_date"; | ||
182 | row["columns"][3]["type"] = "text"; | ||
183 | row["columns"][3]["value"] = time; | ||
184 | mObjectList->addElement(row, ADD_TOP); | ||
185 | obj = gSelectMgr->getNextNode(); | ||
186 | } | ||
187 | if(selected_index > -1 && mObjectList->getItemIndex(selected_uuid) == selected_index) | ||
188 | { | ||
189 | mObjectList->selectNthItem(selected_index); | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | mObjectList->selectNthItem(0); | ||
194 | } | ||
195 | onSelectObject(this, NULL); | ||
196 | mObjectList->setScrollPos(pos); | ||
197 | } | ||
198 | |||
199 | void LLFloaterInspect::onFocusReceived() | ||
200 | { | ||
201 | select_tool(gToolInspect); | ||
202 | } | ||
203 | |||
204 | void LLFloaterInspect::dirty() | ||
205 | { | ||
206 | if(sInstance) | ||
207 | { | ||
208 | sInstance->setDirty(); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | void LLFloaterInspect::draw() | ||
213 | { | ||
214 | if (mDirty) | ||
215 | { | ||
216 | refresh(); | ||
217 | mDirty = FALSE; | ||
218 | } | ||
219 | |||
220 | LLFloater::draw(); | ||
221 | } \ No newline at end of file | ||