Annotation of /trunk/indra/newview/llfloaterlandmark.cpp
Parent Directory
|
Revision Log
Revision 135 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llfloaterlandmark.cpp | ||
| 3 : | * @author Richard Nelson, James Cook, Sam Kolb | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | * Copyright (c) 2007-2009, Linden Research, Inc. | ||
| 8 : | * | ||
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llfloaterlandmark.h" | ||
| 36 : | |||
| 37 : | #include "llagent.h" | ||
| 38 : | #include "llcheckboxctrl.h" | ||
| 39 : | #include "llviewerparcelmgr.h" | ||
| 40 : | #include "llfolderview.h" | ||
| 41 : | #include "llinventory.h" | ||
| 42 : | #include "llinventorymodel.h" | ||
| 43 : | #include "llinventoryview.h" | ||
| 44 : | #include "llviewerinventory.h" | ||
| 45 : | #include "llpermissions.h" | ||
| 46 : | #include "llsaleinfo.h" | ||
| 47 : | #include "llparcel.h" | ||
| 48 : | |||
| 49 : | #include "llviewerwindow.h" | ||
| 50 : | #include "llviewercontrol.h" | ||
| 51 : | #include "lluictrlfactory.h" | ||
| 52 : | |||
| 53 : | #include "roles_constants.h" // GP_LAND_ALLOW_LANDMARK | ||
| 54 : | |||
| 55 : | |||
| 56 : | static const F32 CONTEXT_CONE_IN_ALPHA = 0.0f; | ||
| 57 : | static const F32 CONTEXT_CONE_OUT_ALPHA = 1.f; | ||
| 58 : | static const F32 CONTEXT_FADE_TIME = 0.08f; | ||
| 59 : | |||
| 60 : | |||
| 61 : | LLFloaterLandmark::LLFloaterLandmark(const LLSD& data) | ||
| 62 : | : | ||
| 63 : | mTentativeLabel(NULL), | ||
| 64 : | mResolutionLabel(NULL), | ||
| 65 : | mIsDirty( FALSE ), | ||
| 66 : | mActive( TRUE ), | ||
| 67 : | mSearchEdit(NULL), | ||
| 68 : | mContextConeOpacity(0.f) | ||
| 69 : | { | ||
| 70 : | LLUICtrlFactory::getInstance()->buildFloater(this,"floater_landmark_ctrl.xml"); | ||
| 71 : | |||
| 72 : | mTentativeLabel = getChild<LLTextBox>("Multiple"); | ||
| 73 : | |||
| 74 : | mResolutionLabel = getChild<LLTextBox>("unknown"); | ||
| 75 : | |||
| 76 : | |||
| 77 : | childSetCommitCallback("show_folders_check", onShowFolders, this); | ||
| 78 : | childSetVisible("show_folders_check", FALSE); | ||
| 79 : | |||
| 80 : | mSearchEdit = getChild<LLSearchEditor>("inventory search editor"); | ||
| 81 : | mSearchEdit->setSearchCallback(onSearchEdit, this); | ||
| 82 : | |||
| 83 : | mInventoryPanel = getChild<LLInventoryPanel>("inventory panel"); | ||
| 84 : | |||
| 85 : | if(mInventoryPanel) | ||
| 86 : | { | ||
| 87 : | U32 filter_types = 0x0; | ||
| 88 : | filter_types |= 0x1 << LLInventoryType::IT_LANDMARK; | ||
| 89 : | // filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT; | ||
| 90 : | |||
| 91 : | mInventoryPanel->setFilterTypes(filter_types); | ||
| 92 : | //mInventoryPanel->setFilterPermMask(getFilterPermMask()); //Commented out due to no-copy texture loss. | ||
| 93 : | mInventoryPanel->setSelectCallback(onSelectionChange, this); | ||
| 94 : | mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); | ||
| 95 : | mInventoryPanel->setAllowMultiSelect(FALSE); | ||
| 96 : | |||
| 97 : | // store this filter as the default one | ||
| 98 : | mInventoryPanel->getRootFolder()->getFilter()->markDefault(); | ||
| 99 : | |||
| 100 : | // Commented out to stop opening all folders with textures | ||
| 101 : | mInventoryPanel->openDefaultFolderForType(LLAssetType::AT_LANDMARK); | ||
| 102 : | |||
| 103 : | // don't put keyboard focus on selected item, because the selection callback | ||
| 104 : | // will assume that this was user input | ||
| 105 : | mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO); | ||
| 106 : | } | ||
| 107 : | |||
| 108 : | mSavedFolderState = new LLSaveFolderState(); | ||
| 109 : | mNoCopyLandmarkSelected = FALSE; | ||
| 110 : | |||
| 111 : | childSetAction("Close", LLFloaterLandmark::onBtnClose,this); | ||
| 112 : | childSetAction("New", LLFloaterLandmark::onBtnNew,this); | ||
| 113 : | childSetAction("NewFolder", LLFloaterLandmark::onBtnNewFolder,this); | ||
| 114 : | childSetAction("Edit", LLFloaterLandmark::onBtnEdit,this); | ||
| 115 : | childSetAction("Rename", LLFloaterLandmark::onBtnRename,this); | ||
| 116 : | childSetAction("Delete", LLFloaterLandmark::onBtnDelete,this); | ||
| 117 : | |||
| 118 : | setCanMinimize(FALSE); | ||
| 119 : | |||
| 120 : | mSavedFolderState->setApply(FALSE); | ||
| 121 : | } | ||
| 122 : | |||
| 123 : | LLFloaterLandmark::~LLFloaterLandmark() | ||
| 124 : | { | ||
| 125 : | delete mSavedFolderState; | ||
| 126 : | mSavedFolderState = NULL; | ||
| 127 : | } | ||
| 128 : | |||
| 129 : | void LLFloaterLandmark::setActive( BOOL active ) | ||
| 130 : | { | ||
| 131 : | mActive = active; | ||
| 132 : | } | ||
| 133 : | |||
| 134 : | // virtual | ||
| 135 : | BOOL LLFloaterLandmark::handleDragAndDrop( | ||
| 136 : | S32 x, S32 y, MASK mask, | ||
| 137 : | BOOL drop, | ||
| 138 : | EDragAndDropType cargo_type, void *cargo_data, | ||
| 139 : | EAcceptance *accept, | ||
| 140 : | std::string& tooltip_msg) | ||
| 141 : | { | ||
| 142 : | BOOL handled = FALSE; | ||
| 143 : | |||
| 144 : | if (cargo_type == DAD_LANDMARK) | ||
| 145 : | { | ||
| 146 : | LLInventoryItem *item = (LLInventoryItem *)cargo_data; | ||
| 147 : | |||
| 148 : | BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID()); | ||
| 149 : | BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID()); | ||
| 150 : | BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER, | ||
| 151 : | gAgent.getID()); | ||
| 152 : | |||
| 153 : | PermissionMask item_perm_mask = 0; | ||
| 154 : | if (copy) item_perm_mask |= PERM_COPY; | ||
| 155 : | if (mod) item_perm_mask |= PERM_MODIFY; | ||
| 156 : | if (xfer) item_perm_mask |= PERM_TRANSFER; | ||
| 157 : | |||
| 158 : | //PermissionMask filter_perm_mask = getFilterPermMask(); Commented out due to no-copy texture loss. | ||
| 159 : | PermissionMask filter_perm_mask = mImmediateFilterPermMask; | ||
| 160 : | if ( (item_perm_mask & filter_perm_mask) == filter_perm_mask ) | ||
| 161 : | { | ||
| 162 : | |||
| 163 : | *accept = ACCEPT_YES_SINGLE; | ||
| 164 : | } | ||
| 165 : | else | ||
| 166 : | { | ||
| 167 : | *accept = ACCEPT_NO; | ||
| 168 : | } | ||
| 169 : | } | ||
| 170 : | else | ||
| 171 : | { | ||
| 172 : | *accept = ACCEPT_NO; | ||
| 173 : | } | ||
| 174 : | |||
| 175 : | handled = TRUE; | ||
| 176 : | lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFloaterLandmark " << getName() << llendl; | ||
| 177 : | |||
| 178 : | return handled; | ||
| 179 : | } | ||
| 180 : | |||
| 181 : | BOOL LLFloaterLandmark::handleKeyHere(KEY key, MASK mask) | ||
| 182 : | { | ||
| 183 : | LLFolderView* root_folder = mInventoryPanel->getRootFolder(); | ||
| 184 : | |||
| 185 : | if (root_folder && mSearchEdit) | ||
| 186 : | { | ||
| 187 : | if (mSearchEdit->hasFocus() && | ||
| 188 : | (key == KEY_RETURN || key == KEY_DOWN) && | ||
| 189 : | mask == MASK_NONE) | ||
| 190 : | { | ||
| 191 : | if (!root_folder->getCurSelectedItem()) | ||
| 192 : | { | ||
| 193 : | LLFolderViewItem* itemp = root_folder->getItemByID(gAgent.getInventoryRootID()); | ||
| 194 : | if (itemp) | ||
| 195 : | { | ||
| 196 : | root_folder->setSelection(itemp, FALSE, FALSE); | ||
| 197 : | } | ||
| 198 : | } | ||
| 199 : | root_folder->scrollToShowSelection(); | ||
| 200 : | |||
| 201 : | // move focus to inventory proper | ||
| 202 : | root_folder->setFocus(TRUE); | ||
| 203 : | |||
| 204 : | return TRUE; | ||
| 205 : | } | ||
| 206 : | |||
| 207 : | if (root_folder->hasFocus() && key == KEY_UP) | ||
| 208 : | { | ||
| 209 : | mSearchEdit->focusFirstItem(TRUE); | ||
| 210 : | } | ||
| 211 : | } | ||
| 212 : | |||
| 213 : | return LLFloater::handleKeyHere(key, mask); | ||
| 214 : | } | ||
| 215 : | |||
| 216 : | // virtual | ||
| 217 : | void LLFloaterLandmark::onClose(bool app_quitting) | ||
| 218 : | { | ||
| 219 : | destroy(); | ||
| 220 : | } | ||
| 221 : | |||
| 222 : | |||
| 223 : | |||
| 224 : | const LLUUID& LLFloaterLandmark::findItemID(const LLUUID& asset_id, BOOL copyable_only) | ||
| 225 : | { | ||
| 226 : | LLViewerInventoryCategory::cat_array_t cats; | ||
| 227 : | LLViewerInventoryItem::item_array_t items; | ||
| 228 : | LLAssetIDMatches asset_id_matches(asset_id); | ||
| 229 : | gInventory.collectDescendentsIf(LLUUID::null, | ||
| 230 : | cats, | ||
| 231 : | items, | ||
| 232 : | LLInventoryModel::INCLUDE_TRASH, | ||
| 233 : | asset_id_matches); | ||
| 234 : | |||
| 235 : | if (items.count()) | ||
| 236 : | { | ||
| 237 : | // search for copyable version first | ||
| 238 : | for (S32 i = 0; i < items.count(); i++) | ||
| 239 : | { | ||
| 240 : | LLInventoryItem* itemp = items[i]; | ||
| 241 : | LLPermissions item_permissions = itemp->getPermissions(); | ||
| 242 : | if (item_permissions.allowCopyBy(gAgent.getID(), gAgent.getGroupID())) | ||
| 243 : | { | ||
| 244 : | return itemp->getUUID(); | ||
| 245 : | } | ||
| 246 : | } | ||
| 247 : | // otherwise just return first instance, unless copyable requested | ||
| 248 : | if (copyable_only) | ||
| 249 : | { | ||
| 250 : | return LLUUID::null; | ||
| 251 : | } | ||
| 252 : | else | ||
| 253 : | { | ||
| 254 : | return items[0]->getUUID(); | ||
| 255 : | } | ||
| 256 : | } | ||
| 257 : | |||
| 258 : | return LLUUID::null; | ||
| 259 : | } | ||
| 260 : | |||
| 261 : | // static | ||
| 262 : | void LLFloaterLandmark::onBtnClose(void* userdata) | ||
| 263 : | { | ||
| 264 : | LLFloaterLandmark* self = (LLFloaterLandmark*) userdata; | ||
| 265 : | self->mIsDirty = FALSE; | ||
| 266 : | self->close(); | ||
| 267 : | } | ||
| 268 : | |||
| 269 : | // static | ||
| 270 : | void LLFloaterLandmark::onBtnEdit(void* userdata) | ||
| 271 : | { | ||
| 272 : | LLFloaterLandmark* self = (LLFloaterLandmark*) userdata; | ||
| 273 : | // There isn't one, so make a new preview | ||
| 274 : | LLViewerInventoryItem* itemp = gInventory.getItem(self->mImageAssetID); | ||
| 275 : | if(itemp) | ||
| 276 : | { | ||
| 277 : | open_landmark(itemp, itemp->getName(), TRUE); | ||
| 278 : | } | ||
| 279 : | } | ||
| 280 : | // static | ||
| 281 : | void LLFloaterLandmark::onBtnNew(void* userdata) | ||
| 282 : | { | ||
| 283 : | LLViewerRegion* agent_region = gAgent.getRegion(); | ||
| 284 : | if(!agent_region) | ||
| 285 : | { | ||
| 286 : | llwarns << "No agent region" << llendl; | ||
| 287 : | return; | ||
| 288 : | } | ||
| 289 : | LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); | ||
| 290 : | if (!agent_parcel) | ||
| 291 : | { | ||
| 292 : | llwarns << "No agent parcel" << llendl; | ||
| 293 : | return; | ||
| 294 : | } | ||
| 295 : | if (!agent_parcel->getAllowLandmark() | ||
| 296 : | && !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK)) | ||
| 297 : | { | ||
| 298 : | LLNotifications::instance().add("CannotCreateLandmarkNotOwner"); | ||
| 299 : | return; | ||
| 300 : | } | ||
| 301 : | |||
| 302 : | LLUUID folder_id; | ||
| 303 : | folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK); | ||
| 304 : | std::string pos_string; | ||
| 305 : | gAgent.buildLocationString(pos_string); | ||
| 306 : | |||
| 307 : | create_inventory_item(gAgent.getID(), gAgent.getSessionID(), | ||
| 308 : | folder_id, LLTransactionID::tnull, | ||
| 309 : | pos_string, pos_string, // name, desc | ||
| 310 : | LLAssetType::AT_LANDMARK, | ||
| 311 : | LLInventoryType::IT_LANDMARK, | ||
| 312 : | NOT_WEARABLE, PERM_ALL, | ||
| 313 : | NULL); | ||
| 314 : | } | ||
| 315 : | // static | ||
| 316 : | void LLFloaterLandmark::onBtnNewFolder(void* userdata) | ||
| 317 : | { | ||
| 318 : | |||
| 319 : | } | ||
| 320 : | // static | ||
| 321 : | void LLFloaterLandmark::onBtnDelete(void* userdata) | ||
| 322 : | { | ||
| 323 : | LLFloaterLandmark* self = (LLFloaterLandmark*)userdata; | ||
| 324 : | |||
| 325 : | LLViewerInventoryItem* item = gInventory.getItem(self->mImageAssetID); | ||
| 326 : | if(item) | ||
| 327 : | { | ||
| 328 : | // Move the item to the trash | ||
| 329 : | LLUUID trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH); | ||
| 330 : | if (item->getParentUUID() != trash_id) | ||
| 331 : | { | ||
| 332 : | LLInventoryModel::update_list_t update; | ||
| 333 : | LLInventoryModel::LLCategoryUpdate old_folder(item->getParentUUID(),-1); | ||
| 334 : | update.push_back(old_folder); | ||
| 335 : | LLInventoryModel::LLCategoryUpdate new_folder(trash_id, 1); | ||
| 336 : | update.push_back(new_folder); | ||
| 337 : | gInventory.accountForUpdate(update); | ||
| 338 : | |||
| 339 : | LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); | ||
| 340 : | new_item->setParent(trash_id); | ||
| 341 : | // no need to restamp it though it's a move into trash because | ||
| 342 : | // it's a brand new item already. | ||
| 343 : | new_item->updateParentOnServer(FALSE); | ||
| 344 : | gInventory.updateItem(new_item); | ||
| 345 : | gInventory.notifyObservers(); | ||
| 346 : | } | ||
| 347 : | } | ||
| 348 : | |||
| 349 : | // Delete the item entirely | ||
| 350 : | /* | ||
| 351 : | item->removeFromServer(); | ||
| 352 : | gInventory.deleteObject(item->getUUID()); | ||
| 353 : | gInventory.notifyObservers(); | ||
| 354 : | */ | ||
| 355 : | |||
| 356 : | |||
| 357 : | } | ||
| 358 : | |||
| 359 : | // static | ||
| 360 : | void LLFloaterLandmark::onBtnRename(void* userdata) | ||
| 361 : | { | ||
| 362 : | |||
| 363 : | } | ||
| 364 : | |||
| 365 : | // static | ||
| 366 : | void LLFloaterLandmark::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data) | ||
| 367 : | { | ||
| 368 : | LLFloaterLandmark* self = (LLFloaterLandmark*)data; | ||
| 369 : | if (items.size()) | ||
| 370 : | { | ||
| 371 : | LLFolderViewItem* first_item = items.front(); | ||
| 372 : | LLInventoryItem* itemp = gInventory.getItem(first_item->getListener()->getUUID()); | ||
| 373 : | self->mNoCopyLandmarkSelected = FALSE; | ||
| 374 : | if (itemp) | ||
| 375 : | { | ||
| 376 : | if (!itemp->getPermissions().allowCopyBy(gAgent.getID())) | ||
| 377 : | { | ||
| 378 : | self->mNoCopyLandmarkSelected = TRUE; | ||
| 379 : | } | ||
| 380 : | self->mImageAssetID = itemp->getUUID(); | ||
| 381 : | self->mIsDirty = TRUE; | ||
| 382 : | } | ||
| 383 : | } | ||
| 384 : | } | ||
| 385 : | |||
| 386 : | // static | ||
| 387 : | void LLFloaterLandmark::onShowFolders(LLUICtrl* ctrl, void *user_data) | ||
| 388 : | { | ||
| 389 : | LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl; | ||
| 390 : | LLFloaterLandmark* picker = (LLFloaterLandmark*)user_data; | ||
| 391 : | |||
| 392 : | if (check_box->get()) | ||
| 393 : | { | ||
| 394 : | picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); | ||
| 395 : | } | ||
| 396 : | else | ||
| 397 : | { | ||
| 398 : | picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NO_FOLDERS); | ||
| 399 : | } | ||
| 400 : | } | ||
| 401 : | |||
| 402 : | void LLFloaterLandmark::onSearchEdit(const std::string& search_string, void* user_data ) | ||
| 403 : | { | ||
| 404 : | LLFloaterLandmark* picker = (LLFloaterLandmark*)user_data; | ||
| 405 : | |||
| 406 : | std::string upper_case_search_string = search_string; | ||
| 407 : | LLStringUtil::toUpper(upper_case_search_string); | ||
| 408 : | |||
| 409 : | if (upper_case_search_string.empty()) | ||
| 410 : | { | ||
| 411 : | if (picker->mInventoryPanel->getFilterSubString().empty()) | ||
| 412 : | { | ||
| 413 : | // current filter and new filter empty, do nothing | ||
| 414 : | return; | ||
| 415 : | } | ||
| 416 : | |||
| 417 : | picker->mSavedFolderState->setApply(TRUE); | ||
| 418 : | picker->mInventoryPanel->getRootFolder()->applyFunctorRecursively(*picker->mSavedFolderState); | ||
| 419 : | // add folder with current item to list of previously opened folders | ||
| 420 : | LLOpenFoldersWithSelection opener; | ||
| 421 : | picker->mInventoryPanel->getRootFolder()->applyFunctorRecursively(opener); | ||
| 422 : | picker->mInventoryPanel->getRootFolder()->scrollToShowSelection(); | ||
| 423 : | |||
| 424 : | } | ||
| 425 : | else if (picker->mInventoryPanel->getFilterSubString().empty()) | ||
| 426 : | { | ||
| 427 : | // first letter in search term, save existing folder open state | ||
| 428 : | if (!picker->mInventoryPanel->getRootFolder()->isFilterModified()) | ||
| 429 : | { | ||
| 430 : | picker->mSavedFolderState->setApply(FALSE); | ||
| 431 : | picker->mInventoryPanel->getRootFolder()->applyFunctorRecursively(*picker->mSavedFolderState); | ||
| 432 : | } | ||
| 433 : | } | ||
| 434 : | |||
| 435 : | picker->mInventoryPanel->setFilterSubString(upper_case_search_string); | ||
| 436 : | } | ||
| 437 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

