aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterimport.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llfloaterimport.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llfloaterimport.cpp')
-rw-r--r--linden/indra/newview/llfloaterimport.cpp669
1 files changed, 0 insertions, 669 deletions
diff --git a/linden/indra/newview/llfloaterimport.cpp b/linden/indra/newview/llfloaterimport.cpp
deleted file mode 100644
index 77f1206..0000000
--- a/linden/indra/newview/llfloaterimport.cpp
+++ /dev/null
@@ -1,669 +0,0 @@
1/**
2 * @file llfloaterimport.cpp
3 * @brief LLFloaterImport class implementation
4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 *
7 * Copyright (c) 2005-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llviewerprecompiledheaders.h"
33
34#include "llfloaterimport.h"
35
36#include "llapr.h"
37
38#include "llimagebmp.h"
39#include "llimagetga.h"
40#include "llimagejpeg.h"
41
42#include "llagent.h"
43#include "llbutton.h"
44#include "llcombobox.h"
45#include "lldrawable.h"
46#include "lldrawpoolavatar.h"
47#include "llface.h"
48#include "llinventorymodel.h"
49#include "lllineeditor.h"
50#include "llresourcedata.h"
51#include "lltextbox.h"
52#include "lltoolmgr.h"
53#include "llui.h"
54#include "lluploaddialog.h"
55#include "llviewercamera.h"
56#include "llviewermenufile.h" // upload_new_resource()
57#include "llviewerwindow.h"
58#include "llvoavatar.h"
59#include "pipeline.h"
60#include "llvieweruictrlfactory.h"
61#include "llmd5.h"
62
63extern LLInventoryModel gInventory;
64
65//statics
66//LLUploadDialog *LLFloaterImport::sImportDialog = NULL;
67LLUUID LLFloaterImport::sImportRequestID;
68LLString LLFloaterImport::sOKText = LLString();
69
70const S32 PREVIEW_BORDER_WIDTH = 2;
71const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
72const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
73const S32 PREF_BUTTON_HEIGHT = 16;
74const S32 PREVIEW_TEXTURE_HEIGHT = 300;
75
76//-----------------------------------------------------------------------------
77// LLFloaterImport()
78//-----------------------------------------------------------------------------
79LLFloaterImport::LLFloaterImport(const std::string filename)
80 : LLFloater("Import")
81{
82 mFilenameAndPath = filename;
83
84 char file_path[256]; /*Flawfinder: ignore*/
85 strncpy(file_path, mFilenameAndPath.c_str(), sizeof(file_path) -1); /*Flawfinder: ignore*/
86 file_path[sizeof(file_path) -1] = '\0';
87 char *file_name = strrchr( file_path, gDirUtilp->getDirDelimiter()[0]);
88 file_name[0] = 0;
89
90 mFilename.assign(file_name + 1);
91 mFilePath.assign(file_path);
92
93 //LLString::toLower(mFilename);
94
95 LLXMLNode::parseFile(filename, mObjectFile, NULL);
96}
97
98//-----------------------------------------------------------------------------
99// postBuild()
100//-----------------------------------------------------------------------------
101BOOL LLFloaterImport::postBuild()
102{
103 LLString asset_name = mFilename;
104 LLString::replaceNonstandardASCII( asset_name, '?' );
105 LLString::replaceChar(asset_name, '|', '?');
106 LLString::stripNonprintable(asset_name);
107 LLString::trim(asset_name);
108
109 char* asset_name_str = (char*)asset_name.c_str();
110 char* end_p = strrchr(asset_name_str, '.'); // strip extension if exists
111 if( !end_p )
112 {
113 end_p = asset_name_str + strlen( asset_name_str ); /*Flawfinder: ignore*/
114 }
115
116 S32 len = llmin( (S32) (DB_INV_ITEM_NAME_STR_LEN), (S32) (end_p - asset_name_str) );
117
118 asset_name = asset_name.substr( 0, len );
119
120 setTitle(mFilename);
121
122 {
123 // Center the window
124 LLRect window_rect = gViewerWindow->getRootView()->getRect();
125
126 S32 dialog_left = window_rect.mLeft + (window_rect.getWidth() - mRect.getWidth()) / 2;
127 S32 dialog_bottom = window_rect.mBottom + (window_rect.getHeight() - mRect.getHeight()) / 2;
128
129 translate( dialog_left - mRect.mLeft, dialog_bottom - mRect.mBottom );
130 }
131
132 mNameEditor = LLViewerUICtrlFactory::getLineEditorByName(this, "name_form");
133 mNameEditor->setMaxTextLength(DB_INV_ITEM_NAME_STR_LEN);
134 //mNameEditor->setCommitCallback(onCommit);
135 mNameEditor->setPrevalidate(&LLLineEditor::prevalidatePrintableNotPipe);
136
137 mNameEditor->setText(asset_name);
138
139 mDescEditor = LLViewerUICtrlFactory::getLineEditorByName(this, "description_form");
140 mDescEditor->setMaxTextLength(DB_INV_ITEM_DESC_STR_LEN);
141 //mDescEditor->setCommitCallback(onCommit);
142 mDescEditor->setPrevalidate(&LLLineEditor::prevalidatePrintableNotPipe);
143
144 // Cancel button
145 mCancelBtn = LLViewerUICtrlFactory::getButtonByName(this, "cancel_btn");
146 mCancelBtn->setClickedCallback(onBtnCancel);
147 mCancelBtn->setCallbackUserData(this);
148
149 // OK button
150 mOKBtn = LLViewerUICtrlFactory::getButtonByName(this, "ok_btn");
151 mOKBtn->setClickedCallback(onBtnOK);
152 mOKBtn->setCallbackUserData(this);
153 setDefaultBtn(mOKBtn);
154
155 mImageLabel = LLViewerUICtrlFactory::getTextBoxByName(this, "preview_label");
156 mImportList = LLViewerUICtrlFactory::getScrollListByName(this, "upload_list");
157
158 bool object_file_read = false;
159 int object_count = 0, image_count = 0;
160 if (mObjectFile)
161 {
162 LLXMLNodeList object_list;
163 mObjectFile->findName("object", object_list);
164 LLXMLNodeList::iterator itor;
165 LLXMLNodeList::iterator itor2;
166 for (itor = object_list.begin(); itor != object_list.end(); ++itor)
167 {
168 LLXMLNode *object = itor->second;
169 LLXMLNodeList tasks_list;
170 object->getChildren("task", tasks_list, FALSE);
171 for (itor2 = tasks_list.begin(); itor2 != tasks_list.end(); ++itor2)
172 {
173 LLXMLNode *task = itor2->second;
174 LLXMLNodePtr temp_node;
175 if (!task->getChild("root", temp_node, FALSE))
176 {
177 // This task is a root
178 LLString task_name = "(unnamed object)";
179 LLXMLNodePtr task_name_node;
180 if (task->getChild("name", task_name_node, FALSE))
181 {
182 task_name_node->getStringValue(1, &task_name);
183 }
184 {
185 LLString output_line;
186 char buffer[20]; /*Flawfinder: ignore*/
187 snprintf(buffer, sizeof(buffer), "%d", (S32)tasks_list.size()); /* Flawfinder: ignore */
188 output_line.append(buffer);
189 output_line.append(" prims");
190
191 LLSD row;
192 row["columns"][0]["value"] = "OBJECT";
193 row["columns"][0]["width"] = 60;
194 row["columns"][1]["value"] = output_line;
195 row["columns"][1]["width"] = 80;
196 row["columns"][2]["value"] = task_name;
197 row["enabled"] = false;
198 mImportList->addElement(row);
199 }
200 mImportList->setCanSelect(TRUE);
201 mImportList->setAllowMultipleSelection(TRUE);
202 object_file_read = true;
203 object_count++;
204 break;
205 }
206 }
207 }
208
209 if (object_count > 0)
210 {
211 std::string::size_type pos = mFilenameAndPath.rfind(".");
212 if (pos != mFilenameAndPath.npos)
213 {
214 mInventoryPath = mFilenameAndPath.substr(0, pos);
215 }
216 else
217 {
218 mInventoryPath = mFilenameAndPath;
219 }
220 mInventoryPath.append("_inventory");
221
222 LLXMLNodeList image_list;
223 mObjectFile->findName("sl:image", image_list);
224 std::vector<LLString> unique_images;
225 std::vector<LLUUID> unique_ids;
226 std::vector<bool> image_changed;
227 for (itor = image_list.begin(); itor != image_list.end(); ++itor)
228 {
229 LLXMLNode *image_node = itor->second;
230 LLString image_id = image_node->getID();
231
232 LLUUID image_uuid;
233 image_node->getUUIDValue(1, &image_uuid);
234
235 bool found_image = false;
236 for (U32 image_num=0; image_num<unique_images.size(); ++image_num)
237 {
238 if (unique_images[image_num] == image_id)
239 {
240 found_image = true;
241 continue;
242 }
243 }
244 if (!found_image)
245 {
246 unique_images.push_back(image_id);
247 unique_ids.push_back(image_uuid);
248
249 LLString node_hash = "00000000000000000000000000000000";
250 LLXMLNodePtr image_hash_node;
251 if (image_node->getChild("checksum", image_hash_node))
252 {
253 image_hash_node->getStringValue(1, &node_hash);
254 }
255
256 llinfos << "Node hash: " << node_hash << llendl;
257
258 // Try to find image and get checksum
259 LLString image_path = mInventoryPath;
260 image_path.append(gDirUtilp->getDirDelimiter());
261 image_path.append(image_id);
262 image_path.append(".tga");
263
264 llinfos << "Getting hash for " << image_path << llendl;
265
266 char md5_hash_string[33]; /*Flawfinder: ignore*/
267 strcpy(md5_hash_string, "00000000000000000000000000000000"); /*Flawfinder: ignore*/
268 FILE* fCheck = LLFile::fopen(image_path.c_str(), "rb"); /*Flawfinder: ignore*/
269 if (fCheck)
270 {
271 LLMD5 my_md5_hash(fCheck); // this fclose()s fCheck too
272 my_md5_hash.hex_digest(md5_hash_string);
273
274 llinfos << "hash: " << md5_hash_string << llendl;
275 }
276
277 LoadPreviewImage(image_path, image_uuid);
278
279 if (memcmp(md5_hash_string, node_hash.c_str(), 32) == 0)
280 {
281 // Image has not changed
282 image_changed.push_back(false);
283 }
284 else
285 {
286 // Image has changed
287 image_changed.push_back(true);
288 }
289 }
290 }
291 for (U32 image_num=0; image_num<unique_images.size(); ++image_num)
292 {
293 LLSD row;
294 row["columns"][0]["value"] = "IMAGE";
295 row["columns"][0]["width"] = 60;
296 row["columns"][1]["value"] = image_changed[image_num]?"NEW":"NOT NEW";
297 row["columns"][1]["width"] = 80;
298 row["columns"][2]["value"] = unique_images[image_num];
299 mImportList->addElement(row);
300 mImportList->setCanSelect(TRUE);
301 image_count++;
302 }
303 }
304 }
305
306 if (!object_file_read)
307 {
308 mImportList->addCommentText("Error: Invalid object file.");
309 mImportList->setCanSelect(FALSE);
310 mOKBtn->setEnabled(FALSE);
311 }
312 else
313 {
314 recalcCost();
315 }
316
317 return TRUE;
318}
319
320void LLFloaterImport::LoadPreviewImage(LLString image_path, LLUUID image_uuid)
321{
322 LLPointer<LLImageRaw> raw_image = new LLImageRaw;
323 LLPointer<LLImageTGA> tga_image = new LLImageTGA;
324
325 if (!tga_image->load(image_path))
326 {
327 return;
328 }
329
330 if (!tga_image->decode(raw_image))
331 {
332 return;
333 }
334
335 if( (tga_image->getComponents() != 3) &&
336 (tga_image->getComponents() != 4) )
337 {
338 tga_image->setLastError( "Image files with less than 3 or more than 4 components are not supported." );
339 return;
340 }
341
342 raw_image->biasedScaleToPowerOfTwo(256);
343
344 mPreviewImages[image_uuid] = raw_image;
345}
346
347//-----------------------------------------------------------------------------
348// LLFloaterImport()
349//-----------------------------------------------------------------------------
350LLFloaterImport::~LLFloaterImport()
351{
352 if (mGLName)
353 {
354 glDeleteTextures(1, &mGLName );
355 }
356}
357
358//-----------------------------------------------------------------------------
359// recalcCost()
360//-----------------------------------------------------------------------------
361void LLFloaterImport::recalcCost()
362{
363 /*S32 cost = 0;
364 LLScrollListItem *item = mImportList->getFirstData();
365 while (item)
366 {
367 LLString item_type = item->getColumn(0)->getText();
368
369 if (item_type == "IMAGE" && item->getSelected())
370 {
371 cost += 10; // hypothetical image cost
372 }
373 if (item_type == "OBJECT")
374 {
375 cost += 10; // hypothetical object cost
376 }
377 item = mImportList->getNextData();
378 }
379
380 char buffer[20];
381 sOKText = "Upload (L$";
382 sprintf(buffer, "%d", cost);
383 sOKText.append(buffer);
384 sOKText.append(")");
385 mOKBtn->setLabelSelected(sOKText.c_str());
386 mOKBtn->setLabelUnselected(sOKText.c_str());
387 mOKBtn->setEnabled(TRUE);*/
388}
389
390//-----------------------------------------------------------------------------
391// draw()
392//-----------------------------------------------------------------------------
393void LLFloaterImport::draw()
394{
395 LLFloater::draw();
396
397 LLRect PreviewImageRect;
398 BOOL has_rect = childGetRect("dummy_preview", PreviewImageRect);
399
400 if (mCurrentPreviewImage.notNull() && has_rect)
401 {
402 gl_rect_2d_checkerboard(PreviewImageRect);
403
404 GLenum format_options[4] = { GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA };
405 GLenum format = format_options[mCurrentPreviewImage->getComponents()-1];
406
407 GLenum internal_format_options[4] = { GL_LUMINANCE8, GL_LUMINANCE8_ALPHA8, GL_RGB8, GL_RGBA8 };
408 GLenum internal_format = internal_format_options[mCurrentPreviewImage->getComponents()-1];
409
410 if (mGLName)
411 {
412 LLImageGL::bindExternalTexture( mGLName, 0, GL_TEXTURE_2D );
413 }
414 else
415 {
416 glGenTextures(1, &mGLName );
417 stop_glerror();
418
419 LLImageGL::bindExternalTexture( mGLName, 0, GL_TEXTURE_2D );
420 stop_glerror();
421
422 glTexImage2D(
423 GL_TEXTURE_2D, 0, internal_format,
424 mCurrentPreviewImage->getWidth(), mCurrentPreviewImage->getHeight(),
425 0, format, GL_UNSIGNED_BYTE, mCurrentPreviewImage->getData());
426 stop_glerror();
427
428 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
429 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
430
431 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
432 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
433 }
434
435 glColor3f(1.f, 1.f, 1.f);
436 glBegin( GL_QUADS );
437 {
438 glTexCoord2f(0, 1);
439 glVertex2i(PreviewImageRect.mLeft, PreviewImageRect.mTop);
440 glTexCoord2f(0, 0);
441 glVertex2i(PreviewImageRect.mLeft, PreviewImageRect.mBottom);
442 glTexCoord2f(1, 0);
443 glVertex2i(PreviewImageRect.mRight, PreviewImageRect.mBottom);
444 glTexCoord2f(1, 1);
445 glVertex2i(PreviewImageRect.mRight, PreviewImageRect.mTop);
446 }
447 glEnd();
448
449 LLImageGL::unbindTexture(0, GL_TEXTURE_2D);
450
451 stop_glerror();
452 }
453}
454
455// static
456void LLFloaterImport::finishImport(ImportAssetInfo *info)
457{
458 // Commenting this code out and removing
459 // ObjectImport message from the message template
460 /*
461 llinfos << "Uploading object " << info->FilenameAndPath << "..." << llendl;
462
463 LLUUID new_file_id;
464 new_file_id.generate();
465 bool generated_file = false;
466
467 {
468 // Copy file into a local directory
469 LLString new_file = "TEMP";
470 new_file.append(new_file_id.asString());
471 new_file.append(".slobject");
472
473 S32 length;
474 apr_file_t* fIn = ll_apr_file_open(info->FilenameAndPath.c_str(), LL_APR_RB, &length);
475 if (fIn)
476 {
477 apr_file_t* fOut = ll_apr_file_open(new_file, LL_APR_WB);
478 if (fOut)
479 {
480 char *buffer = new char[length];
481 ll_apr_file_read(fIn, buffer, length);
482 ll_apr_file_write(fOut, buffer, length);
483 delete[] buffer;
484 generated_file = true;
485 apr_file_close(fOut);
486 }
487 apr_file_close(fIn);
488 }
489 }
490
491 if (generated_file)
492 {
493 LLMessageSystem *msg = gMessageSystem;
494 msg->newMessageFast(_PREHASH_ObjectImport);
495 msg->nextBlockFast(_PREHASH_AgentData);
496 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
497 msg->addUUIDFast(_PREHASH_FolderID, gInventory.findCategoryUUIDForType(LLAssetType::AT_OBJECT));
498 msg->nextBlockFast(_PREHASH_AssetData);
499 msg->addUUIDFast(_PREHASH_FileID, new_file_id);
500 msg->addStringFast(_PREHASH_ObjectName, info->Name);
501 msg->addStringFast(_PREHASH_Description, info->Desc);
502 msg->sendReliable(gAgent.getRegionHost());
503
504 LLUploadDialog::modalUploadDialog("Importing geometry...");
505
506 sImportRequestID = new_file_id;
507 }
508 else
509 {
510 llinfos << "Failed to copy file." << llendl;
511 }*/
512}
513
514// static
515void LLFloaterImport::asset_uploaded_callback(const LLUUID& uuid, void* user_data, S32 result, LLExtStat ext_status)
516{
517 llinfos << "LLFloaterImport: Finished uploading image." << llendl;
518 LLResourceData *resource_data = (LLResourceData*)user_data;
519 ImportAssetInfo *info = (ImportAssetInfo*)resource_data->mUserData;
520
521 info->NewImageIDList.push_back(resource_data->mAssetInfo.mUuid.asString());
522
523 LLUploadDialog::modalUploadFinished();
524 if (info->ImageFileQueue.size() == 0)
525 {
526 finishImport(info);
527 }
528 else
529 {
530 // Start the next download
531 LLString current_image = info->ImageFileQueue[0].c_str();
532 info->ImageFileQueue.erase(info->ImageFileQueue.begin());
533
534 upload_new_resource(current_image, info->Name, // file
535 info->Desc, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
536 PERM_NONE, LLString::null, asset_uploaded_callback, info);
537 }
538}
539
540//-----------------------------------------------------------------------------
541// static onBtnOK()
542//-----------------------------------------------------------------------------
543void LLFloaterImport::onBtnOK(void*userdata)
544{
545 LLFloaterImport *fp =(LLFloaterImport*)userdata;
546
547 ImportAssetInfo *asset_info = new ImportAssetInfo();
548 asset_info->Name = fp->mNameEditor->getText();
549 asset_info->Desc = fp->mDescEditor->getText();
550 asset_info->FilenameAndPath = fp->mFilenameAndPath;
551 asset_info->SourcePath = fp->mInventoryPath;
552
553 std::vector<LLScrollListItem*> items = fp->mImportList->getAllSelected();
554 std::vector<LLScrollListItem*>::iterator itor;
555 if (items.size() > 0)
556 {
557 for (itor = items.begin(); itor != items.end(); ++itor)
558 {
559 LLUUID id = (*itor)->getUUID();
560
561 //if (!id->isNull())
562 LLString *image_id = (LLString *)(*itor)->getUserdata();
563 if (image_id)
564 {
565 asset_info->OldImageIDList.push_back(id.asString());
566 LLString image_file = fp->mInventoryPath;
567 image_file.append(gDirUtilp->getDirDelimiter());
568 image_file.append(*image_id);
569 image_file.append(".tga");
570 llinfos << "Uploading image " << image_file << "..." << llendl;
571 asset_info->ImageFileQueue.push_back(image_file);
572 }
573 }
574 if (asset_info->ImageFileQueue.size() == 0)
575 {
576 finishImport(asset_info);
577 }
578 else
579 {
580 // Start the first download
581 LLString current_image = asset_info->ImageFileQueue[0].c_str();
582 asset_info->ImageFileQueue.erase(asset_info->ImageFileQueue.begin());
583
584 upload_new_resource(current_image, asset_info->Name, // file
585 asset_info->Desc, 0, LLAssetType::AT_NONE, LLInventoryType::IT_NONE,
586 PERM_NONE, LLString::null, asset_uploaded_callback, asset_info);
587 }
588 }
589 else
590 {
591 finishImport(asset_info);
592 }
593
594 fp->close(false);
595}
596
597//-----------------------------------------------------------------------------
598// static onBtnCancel()
599//-----------------------------------------------------------------------------
600void LLFloaterImport::onBtnCancel(void*userdata)
601{
602 LLFloaterImport *fp =(LLFloaterImport*)userdata;
603 fp->close(false);
604}
605
606
607//-----------------------------------------------------------------------------
608// virtual handleMouseDown()
609//-----------------------------------------------------------------------------
610BOOL LLFloaterImport::handleMouseDown(S32 x, S32 y, MASK mask)
611{
612 BOOL ret = LLFloater::handleMouseDown(x, y, mask);
613 recalcCost();
614
615 LLUUID current_preview_uuid;
616 LLString current_preview_name = "none";
617
618 LLScrollListItem *item;
619
620 // Did we just select something?
621 item = mImportList->getLastSelectedItem();
622 if (item)
623 {
624 current_preview_uuid = item->getUUID();
625 current_preview_name = item->getColumn(2)->getValue().asString();
626 }
627 else
628 {
629 // If not, see if exactly one object is selected
630 std::vector<LLScrollListItem*> items = mImportList->getAllSelected();
631 std::vector<LLScrollListItem*>::iterator itor;
632 for (itor = items.begin(); itor != items.end(); ++itor)
633 {
634 if (current_preview_uuid.isNull())
635 {
636 current_preview_uuid = (*itor)->getUUID();
637 current_preview_name = (*itor)->getColumn(2)->getValue().asString();
638 }
639 else
640 {
641 // More than one item is selected. Turn off preview
642 current_preview_uuid.setNull();
643 current_preview_name = "none";
644 break;
645 }
646 }
647 }
648
649 mCurrentPreviewImage = NULL;
650 if (current_preview_uuid.notNull())
651 {
652 image_map_t::iterator itor;
653 itor = mPreviewImages.find(current_preview_uuid);
654 if (itor != mPreviewImages.end())
655 {
656 mCurrentPreviewImage = itor->second;
657 if (mGLName)
658 {
659 glDeleteTextures(1, &mGLName );
660 }
661 mGLName = 0;
662 }
663 }
664 LLString label_text = "Image Preview: ";
665 label_text.append(current_preview_name);
666 mImageLabel->setText(label_text);
667
668 return ret;
669}