QMimeData *InventoryItemModel::mimeData(const QModelIndexList &indexes) const { QMimeData *mimeData = new QMimeData(); QByteArray encodedData; QDataStream stream(&encodedData, QIODevice::WriteOnly); foreach(QModelIndex index, indexes) { if (index.isValid()) { QString info, asset_type, asset_ref; AbstractInventoryItem *item = GetItem(index); InventoryAsset *asset = dynamic_cast<InventoryAsset *>(item); if (asset) { asset_type.append(QString("%1").arg(asset->GetAssetType())); asset_ref = asset->GetAssetReference(); } else { asset_type.append(QString("%1").arg(RexTypes::RexAT_None)); asset_ref = RexUUID().ToString().c_str(); } info.append(asset_type + ";" + item->GetID() + ";" + item->GetName() + ";" + asset_ref); stream << info; } } mimeData->setData("application/vnd.inventory.item", encodedData); return mimeData; }
void InventoryModule::OpenItemPropertiesWindow(const QString &inventory_id) { boost::shared_ptr<UiServices::UiModule> ui_module = GetFramework()->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock(); if (!ui_module.get()) return; // Check that item properties window for this item doesn't already exists. // If it does, bring it to front and set focus to it. QMap<QString, ItemPropertiesWindow *>::iterator it = itemPropertiesWindows_.find(inventory_id); if (it != itemPropertiesWindows_.end()) { ui_module->GetInworldSceneController()->BringProxyToFront(it.value()); return; } InventoryAsset *asset = dynamic_cast<InventoryAsset *>(inventory_->GetChildById(inventory_id)); if (!asset) return; ItemPropertiesWindow *wnd = new ItemPropertiesWindow(this); connect(wnd, SIGNAL(Closed(const QString &, bool)), this, SLOT(CloseItemPropertiesWindow(const QString &, bool))); wnd->SetItem(asset); itemPropertiesWindows_[inventory_id] = wnd; if (inventoryType_ == IDMT_OpenSim) { static_cast<OpenSimInventoryDataModel *>(inventory_.get())->SendNameUuidRequest(asset); // Get asset service interface and check if the asset is in cache. // If it is, show file size to item properties UI. SLUDP protocol doesn't support querying asset size // and we don't want download asset only just to know its size. ///\todo If WebDAV supports this, utilize it. Foundation::ServiceManagerPtr service_manager = framework_->GetServiceManager(); if (!service_manager->IsRegistered(Foundation::Service::ST_Asset)) return; boost::shared_ptr<Foundation::AssetServiceInterface> asset_service = service_manager->GetService<Foundation::AssetServiceInterface>(Foundation::Service::ST_Asset).lock(); Foundation::AssetPtr assetPtr = asset_service->GetAsset(asset->GetAssetReference().toStdString(), GetTypeNameFromAssetType(asset->GetAssetType())); if (assetPtr && assetPtr->GetSize() > 0) wnd->SetFileSize(assetPtr->GetSize()); } }