コード例 #1
0
void DownloadRemoteFileDialog::accept()
{
    defaultDB = getDBId();
    
    QString resourceId = getResourceId();
    if( resourceId.isEmpty() ) {
        QMessageBox::critical(this, L10N::errorTitle(), tr("Resource id is empty!"));
        ui->idLineEdit->setFocus();
        return;
    }
    QString fullPath = getFullpath();
    if( ui->saveFilenameLineEdit->text().isEmpty() ) {
        QMessageBox::critical(this, L10N::errorTitle(), tr("No folder selected for saving file!"));
        ui->saveFilenameLineEdit->setFocus();
        return;
    }

    U2OpStatus2Log os;
    fullPath = GUrlUtils::prepareDirLocation(fullPath, os);

    if (fullPath.isEmpty()) {
        QMessageBox::critical(this, L10N::errorTitle(), os.getError());
        ui->saveFilenameLineEdit->setFocus();
        return;
    }        
    
    QString dbId = getDBId();
    QStringList resIds = resourceId.split(QRegExp("[\\s,;]+"));
    QList<Task*> tasks;

    QString fileFormat;
    if (ui->formatBox->count() > 0) {
        fileFormat = ui->formatBox->currentText();
    }

    QVariantMap hints;
    hints.insert(FORCE_DOWNLOAD_SEQUENCE_HINT, ui->chbForceDownloadSequence->isVisible() && ui->chbForceDownloadSequence->isChecked());

    int taskCount = 0;
    bool addToProject = ui->chbAddToProjectCheck->isChecked();
    if (addToProject && resIds.size() >= 100) {
        QString message =  tr("There are more than 100 files found for download.\nAre you sure you want to open all of them?");
        int button = QMessageBox::question(QApplication::activeWindow(), tr("Warning"), message, 
                                           tr("Cancel"), tr("Open anyway"), tr("Don't open"));
        if (button == 0) {
            return; // return to dialog
        } else if (button == 2) {
            addToProject = false;
        }
    }
    bool hasLoadOnlyDocuments = false;
    foreach (const QString &resId, resIds) {
        LoadRemoteDocumentMode mode = LoadRemoteDocumentMode_LoadOnly;
        if (addToProject) {
            mode = taskCount < OpenViewTask::MAX_DOC_NUMBER_TO_OPEN_VIEWS ? LoadRemoteDocumentMode_OpenView : LoadRemoteDocumentMode_AddToProject;
        }
        hasLoadOnlyDocuments = hasLoadOnlyDocuments || mode == LoadRemoteDocumentMode_LoadOnly;
        tasks.append(new LoadRemoteDocumentAndAddToProjectTask(resId, dbId, fullPath, fileFormat, hints, mode));
        taskCount++;
    }
コード例 #2
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include "material_browser.h"
#include "material_tree.h"

//****************************************************************************/
MaterialTreeDockWidget::MaterialTreeDockWidget(const QString& iconDir, const QString& title, QMainWindow* parent, Qt::WindowFlags flags) :
    QDockWidget (title, parent, flags),
    mParent(parent)
{
    mIconDir = iconDir;
    mEmptyString = "";
    mResourceTreeWidget = new Magus::QtResourceTreeWidget(iconDir);
    mResourceTreeWidget->mActionDuplicateAssetText = QString("Clone material");
    mResourceTreeWidget->mActionDeleteResourceText = QString("Remove from list");
    mResourceTreeWidget->setAddAssetAfterDuplicateAssetSelected(false); // Do not duplicate automatically
    mResourceTreeWidget->setCreateTopLevelGroupContextMenuItemEnabled(false);
    mResourceTreeWidget->setDeleteTopLevelGroupEnabled(false);
    mResourceTreeWidget->setTopLevelGroupItemEditable(false);
    mResourceTreeWidget->setSubLevelGroupItemEditable(true);
    mResourceTreeWidget->setCreateAssetContextMenuItemEnabled(false);
    mResourceTreeWidget->setAssetItemEditable(false);
    mResourceTreeWidget->setDeleteResourceContextMenuItemEnabled(true);
    mResourceTreeWidget->setImportAssetContextMenuItemEnabled(false);
    mResourceTreeWidget->setDuplicateAssetContextMenuItemEnabled(true);

    // Miscellanious settings
    mResourceTreeWidget->addCustomContextMenuItem(ACTION_EDIT);

    // Listen to events.
    // Note, that although the 'create asset' context menu is disabled, the MaterialTreeDockWidget must still handle the 'resourceAdded'
    // signal, because it is also emitted when a subgroup is created in the mResourceTreeWidget; the subgroup must be added to
    // mSourceInfo after creation, to be able to recursively delete any assets resided in subgroups (these assets must also be
    // properly deleted from the MaterialThumbsDockWidget).
    connect(mResourceTreeWidget, SIGNAL(resourceSelected(int)), this, SLOT(handleResourceSelected(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceDoubleClicked(int)), this, SLOT(handleResourceDoubleClicked(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceAdded(int)), this, SLOT(handleResourceAdded(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceDeleted(int)), this, SLOT(handleResourceDeleted(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceMoved(int)), this, SLOT(handleResourceMoved(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceSearched(QString)), this, SLOT(handleResourceSearched(QString)));
    connect(mResourceTreeWidget, SIGNAL(resourceSearchReset()), this, SLOT(handleResourceSearchReset()));
    connect(mResourceTreeWidget, SIGNAL(assetDuplicated(int)), this, SLOT(handleResourceDuplicated(int)));
    connect(mResourceTreeWidget, SIGNAL(customContextMenuItemSelected(QString,int)), this, SLOT(handleCustomContextMenuItemSelected(QString, int)));
    mInnerMain = new QMainWindow();
    mInnerMain->setMinimumSize(100,100);
    mInnerMain->setCentralWidget(mResourceTreeWidget);
    setWidget(mInnerMain);
    QWidget* oldTitleBar = titleBarWidget();
    setTitleBarWidget(new QWidget());
    delete oldTitleBar;

    // Add toplevel groups
    initializeResourceTree();
}

//****************************************************************************/
void MaterialTreeDockWidget::initializeResourceTree (void)
{
    // Initialize; add toplevel groups to the mResourceTreeWidget up front
    QtSourcesInfo info;

    // HLMS PBS
    mResourceTreeWidget->addResource (TOOL_SOURCES_LEVEL_X000_PBS,
                                      TOOL_SOURCES_LEVEL_X000_PBS,
                                      0,
                                      QString("PBS"),
                                      QString("PBS"),
                                      ICON_PBS_DATABLOCK_NO_PATH);
    info.toplevelId = TOOL_SOURCES_LEVEL_X000_PBS;
    info.resourceId = TOOL_SOURCES_LEVEL_X000_PBS;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_TOPLEVEL_GROUP;
    info.parentId = 0;
    info.fileName = QString("PBS");
    info.baseName = info.fileName;
    //info.filter = TOOL_SOURCES_FORMAT_PBS;
    info.filter = QString("");
    info.baseNameThumb = ICON_PBS_DATABLOCK;
    mSourceInfo[TOOL_SOURCES_LEVEL_X000_PBS] = info;

    // HLMS UNLIT
    mResourceTreeWidget->addResource (TOOL_SOURCES_LEVEL_X000_UNLIT,
                                      TOOL_SOURCES_LEVEL_X000_UNLIT,
                                      0,
                                      QString("Unlit"),
                                      QString("Unlit"),
                                      ICON_UNLIT_DATABLOCK_NO_PATH);
    info.toplevelId = TOOL_SOURCES_LEVEL_X000_UNLIT;
    info.resourceId = TOOL_SOURCES_LEVEL_X000_UNLIT;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_TOPLEVEL_GROUP;
    info.parentId = 0;
    info.fileName = QString("Unlit");
    info.baseName = info.fileName;
    //info.filter = TOOL_SOURCES_FORMAT_UNLIT;
    info.filter = QString("");
    info.baseNameThumb = ICON_UNLIT_DATABLOCK;
    mSourceInfo[TOOL_SOURCES_LEVEL_X000_UNLIT] = info;

    // Determine what is enabled/disabled if a toplevelgroup is selected
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateSubGroupText, true);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionDuplicateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionDeleteResourceText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(ACTION_EDIT, false);

    // Determine what is enabled/disabled if a subgroup is selected
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateSubGroupText, true);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionDuplicateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionDeleteResourceText, true);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(ACTION_EDIT, false);

    // Determine what is enabled/disabled if an asset is selected
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateSubGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionDuplicateAssetText, true);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionDeleteResourceText, true);
    mResourceTreeWidget->enableContextMenuItemForAsset(ACTION_EDIT, true);
}

//****************************************************************************/
MaterialTreeDockWidget::~MaterialTreeDockWidget(void)
{
}

//****************************************************************************/
QVector<Magus::QtResourceInfo*>& MaterialTreeDockWidget::getResources (void)
{
    // Delegate to mResourceTreeWidget; this is the component that actually retrieves the data
    return mResourceTreeWidget->getResources();
}

//****************************************************************************/
void MaterialTreeDockWidget::setResources(const QVector<Magus::QtResourceInfo*>& resources)
{
    // Add resources to the resource tree
    mResourceTreeWidget->setResources(resources, true);

    // Iterate again through the list to make sure that the thumb info is set
    QVectorIterator<Magus::QtResourceInfo*> it(resources);
    it.toFront();
    Magus::QtResourceInfo* resourceInfo;
    while (it.hasNext())
    {
        resourceInfo = it.next();
        QtSourcesInfo info;
        info.toplevelId = resourceInfo->topLevelId;
        info.resourceId = resourceInfo->resourceId;
        info.resourceType = resourceInfo->resourceType;
        info.parentId = resourceInfo->parentId;
        info.fileName = resourceInfo->fullQualifiedName;
        info.baseName = resourceInfo->resourceName;
        info.baseNameThumb = resourceInfo->resourceName + QString (".png"); // Do not forget
        mSourceInfo[resourceInfo->resourceId] = info;
    }

    mResourceTreeWidget->expandAll();
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::getSelectedFullQualifiedName(void)
{
    QTreeWidgetItem* item = mResourceTreeWidget->getSelectedResourceItem ();
    if (item)
    {
        if (mResourceTreeWidget->isItemAsset(item))
            return mResourceTreeWidget->getFullQualifiedNameFromItem(item);
    }

    return mEmptyString;
}

//****************************************************************************/
bool MaterialTreeDockWidget::addMaterial(const QString& baseNameJson,
                                      const QString& fullNameJson,
                                      const QString& baseNameThumb,
                                      EditorHlmsTypes type)
{
    switch (type)
    {
        case HLMS_PBS:
        {
            return addAssetQuiet(TOOL_SOURCES_LEVEL_X000_PBS, fullNameJson, baseNameJson, baseNameThumb);
        }
        break;

        case HLMS_UNLIT:
        {
            return addAssetQuiet(TOOL_SOURCES_LEVEL_X000_UNLIT, fullNameJson, baseNameJson, baseNameThumb);
        }
        break;
    }
}

//****************************************************************************/
void MaterialTreeDockWidget::selectTopLevel(int toplevelId)
{
    mResourceTreeWidget->selectResource(toplevelId, false);
}

//****************************************************************************/
void MaterialTreeDockWidget::clearContent(void)
{
    mResourceTreeWidget->clear();
    initializeResourceTree();
}

//****************************************************************************/
bool MaterialTreeDockWidget::addAssetQuiet(int toplevelId,
                                           const QString& name,
                                           const QString& baseName,
                                           const QString& baseNameThumb)
{
    // Always add it even if the resource exists (sometimes the resourcetree and mSourceInfo are out-of-sync)
    if (isResourceExisting(baseName))
    {
        // delete it first
        deleteAssetQuiet(toplevelId, name, baseName);
    }

    // Suppress the signal that a resource was added, otherwise the signal causes the asset to
    // be added to the asset widget
    int resourceId = mResourceTreeWidget->addResource(toplevelId, baseName, name, name, true, true);
    mResourceTreeWidget->expand(toplevelId);

    // Also add/set it to mSourceInfo
    QtSourcesInfo info;
    info.toplevelId = toplevelId;
    info.resourceId = resourceId;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_ASSET; // It is an asset
    info.parentId = toplevelId;
    info.fileName = name;
    info.baseName = baseName;
    info.baseNameThumb = baseNameThumb;
    mSourceInfo[resourceId] = info;
    return true;
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::setSelectAssetQuiet(const QString& baseNameThumb)
{
    int id = getResourceId(baseNameThumb);
    if (id != -1)
    {
        mResourceTreeWidget->selectResource(id, false);
        return mSourceInfo[id].fileName;
    }

    return mEmptyString;
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::doubleClicked(const QString& baseNameThumb)
{
    int id = getResourceId(baseNameThumb);
    if (id != -1)
    {
        return mSourceInfo[id].fileName;
    }

    return mEmptyString;
}

//****************************************************************************/
void MaterialTreeDockWidget::deleteAssetQuiet(int toplevelId, const QString& name, const QString& baseName)
{
    // First, delete it from mResourceTreeWidget
    int resourceId = mResourceTreeWidget->getResourceIdFromToplevelIdAndName(toplevelId, name);
    if (resourceId < 0)
        return;

    mResourceTreeWidget->deleteResource(resourceId, true);

    // find the underlying asset (filenames) + delete it from the mSourceInfo
    mSourceInfo.remove(resourceId);
}

//****************************************************************************/
void MaterialTreeDockWidget::deleteAssetQuiet(const QString& baseNameThumb)
{
    int id = getResourceId(baseNameThumb);
    if (id != -1)
    {
        QtSourcesInfo info = mSourceInfo[id];
        mSourceInfo.remove(id);
        mResourceTreeWidget->deleteResource(info.toplevelId, info.fileName, true);
    }
}
コード例 #3
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include "material_browser.h"
#include "material_tree.h"

//****************************************************************************/
MaterialTreeDockWidget::MaterialTreeDockWidget(const QString& iconDir, const QString& title, QMainWindow* parent, Qt::WindowFlags flags) :
    QDockWidget (title, parent, flags),
    mParent(parent)
{
    mIconDir = iconDir;
    mEmptyString = "";
    mResourceTreeWidget = new Magus::QtResourceTreeWidget(iconDir);
    mResourceTreeWidget->mActionDuplicateAssetText = QString("Clone material");
    mResourceTreeWidget->mActionDeleteResourceText = QString("Remove from list");
    mResourceTreeWidget->setAddAssetAfterDuplicateAssetSelected(false); // Do not duplicate automatically
    mResourceTreeWidget->setCreateTopLevelGroupContextMenuItemEnabled(false);
    mResourceTreeWidget->setDeleteTopLevelGroupEnabled(false);
    mResourceTreeWidget->setTopLevelGroupItemEditable(false);
    mResourceTreeWidget->setSubLevelGroupItemEditable(true);
    mResourceTreeWidget->setCreateAssetContextMenuItemEnabled(false);
    mResourceTreeWidget->setAssetItemEditable(false);
    mResourceTreeWidget->setDeleteResourceContextMenuItemEnabled(true);
    mResourceTreeWidget->setImportAssetContextMenuItemEnabled(false);
    mResourceTreeWidget->setDuplicateAssetContextMenuItemEnabled(true);

    // Miscellanious settings
    mResourceTreeWidget->addCustomContextMenuItem(ACTION_EDIT);

    // Listen to events.
    // Note, that although the 'create asset' context menu is disabled, the MaterialTreeDockWidget must still handle the 'resourceAdded'
    // signal, because it is also emitted when a subgroup is created in the mResourceTreeWidget; the subgroup must be added to
    // mSourceInfo after creation, to be able to recursively delete any assets resided in subgroups (these assets must also be
    // properly deleted from the MaterialThumbsDockWidget).
    connect(mResourceTreeWidget, SIGNAL(resourceSelected(int)), this, SLOT(handleResourceSelected(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceDoubleClicked(int)), this, SLOT(handleResourceDoubleClicked(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceAdded(int)), this, SLOT(handleResourceAdded(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceDeleted(int)), this, SLOT(handleResourceDeleted(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceMoved(int)), this, SLOT(handleResourceMoved(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceSearched(QString)), this, SLOT(handleResourceSearched(QString)));
    connect(mResourceTreeWidget, SIGNAL(resourceSearchReset()), this, SLOT(handleResourceSearchReset()));
    connect(mResourceTreeWidget, SIGNAL(assetDuplicated(int)), this, SLOT(handleResourceDuplicated(int)));
    connect(mResourceTreeWidget, SIGNAL(customContextMenuItemSelected(QString,int)), this, SLOT(handleCustomContextMenuItemSelected(QString, int)));
    mInnerMain = new QMainWindow();
    mInnerMain->setMinimumSize(100,100);
    mInnerMain->setCentralWidget(mResourceTreeWidget);
    setWidget(mInnerMain);
    QWidget* oldTitleBar = titleBarWidget();
    setTitleBarWidget(new QWidget());
    delete oldTitleBar;

    // Add toplevel groups
    initializeResourceTree();
}

//****************************************************************************/
void MaterialTreeDockWidget::initializeResourceTree (void)
{
    // Initialize; add toplevel groups to the mResourceTreeWidget up front
    QtSourcesInfo info;

    // HLMS PBS
    mResourceTreeWidget->addResource (TOOL_SOURCES_LEVEL_X000_PBS,
                                      TOOL_SOURCES_LEVEL_X000_PBS,
                                      0,
                                      QString("PBS"),
                                      QString("PBS"),
                                      ICON_PBS_DATABLOCK_NO_PATH);
    info.toplevelId = TOOL_SOURCES_LEVEL_X000_PBS;
    info.resourceId = TOOL_SOURCES_LEVEL_X000_PBS;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_TOPLEVEL_GROUP;
    info.parentId = 0;
    info.fileName = QString("PBS");
    info.baseName = info.fileName;
    //info.filter = TOOL_SOURCES_FORMAT_PBS;
    info.filter = QString("");
    info.baseNameThumb = ICON_PBS_DATABLOCK;
    mSourceInfo[TOOL_SOURCES_LEVEL_X000_PBS] = info;

    // HLMS UNLIT
    mResourceTreeWidget->addResource (TOOL_SOURCES_LEVEL_X000_UNLIT,
                                      TOOL_SOURCES_LEVEL_X000_UNLIT,
                                      0,
                                      QString("Unlit"),
                                      QString("Unlit"),
                                      ICON_UNLIT_DATABLOCK_NO_PATH);
    info.toplevelId = TOOL_SOURCES_LEVEL_X000_UNLIT;
    info.resourceId = TOOL_SOURCES_LEVEL_X000_UNLIT;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_TOPLEVEL_GROUP;
    info.parentId = 0;
    info.fileName = QString("Unlit");
    info.baseName = info.fileName;
    //info.filter = TOOL_SOURCES_FORMAT_UNLIT;
    info.filter = QString("");
    info.baseNameThumb = ICON_UNLIT_DATABLOCK;
    mSourceInfo[TOOL_SOURCES_LEVEL_X000_UNLIT] = info;

    // Determine what is enabled/disabled if a toplevelgroup is selected
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateSubGroupText, true);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionDuplicateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionDeleteResourceText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(ACTION_EDIT, false);

    // Determine what is enabled/disabled if a subgroup is selected
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateSubGroupText, true);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionDuplicateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionDeleteResourceText, true);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(ACTION_EDIT, false);

    // Determine what is enabled/disabled if an asset is selected
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateSubGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionDuplicateAssetText, true);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionDeleteResourceText, true);
    mResourceTreeWidget->enableContextMenuItemForAsset(ACTION_EDIT, true);
}

//****************************************************************************/
MaterialTreeDockWidget::~MaterialTreeDockWidget(void)
{
}

//****************************************************************************/
QVector<Magus::QtResourceInfo*>& MaterialTreeDockWidget::getResources (void)
{
    // Delegate to mResourceTreeWidget; this is the component that actually retrieves the data
    return mResourceTreeWidget->getResources();
}

//****************************************************************************/
void MaterialTreeDockWidget::setResources(const QVector<Magus::QtResourceInfo*>& resources)
{
    // Add resources to the resource tree
    mResourceTreeWidget->setResources(resources, true);

    // Iterate again through the list to make sure that the thumb info is set
    QVectorIterator<Magus::QtResourceInfo*> it(resources);
    it.toFront();
    Magus::QtResourceInfo* resourceInfo;
    while (it.hasNext())
    {
        resourceInfo = it.next();
        QtSourcesInfo info;
        info.toplevelId = resourceInfo->topLevelId;
        info.resourceId = resourceInfo->resourceId;
        info.resourceType = resourceInfo->resourceType;
        info.parentId = resourceInfo->parentId;
        info.fileName = resourceInfo->fullQualifiedName;
        info.baseName = resourceInfo->resourceName;
        info.baseNameThumb = resourceInfo->resourceName + QString (".png"); // Do not forget
        mSourceInfo[resourceInfo->resourceId] = info;
    }

    mResourceTreeWidget->expandAll();
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::getSelectedFullQualifiedName(void)
{
    QTreeWidgetItem* item = mResourceTreeWidget->getSelectedResourceItem ();
    if (item)
    {
        if (mResourceTreeWidget->isItemAsset(item))
            return mResourceTreeWidget->getFullQualifiedNameFromItem(item);
    }

    return mEmptyString;
}

//****************************************************************************/
bool MaterialTreeDockWidget::addMaterial(const QString& baseNameJson,
                                      const QString& fullNameJson,
                                      const QString& baseNameThumb,
                                      EditorHlmsTypes type)
{
    switch (type)
    {
        case HLMS_PBS:
        {
            return addAssetQuiet(TOOL_SOURCES_LEVEL_X000_PBS, fullNameJson, baseNameJson, baseNameThumb);
        }
        break;

        case HLMS_UNLIT:
        {
            return addAssetQuiet(TOOL_SOURCES_LEVEL_X000_UNLIT, fullNameJson, baseNameJson, baseNameThumb);
        }
        break;
    }
}

//****************************************************************************/
void MaterialTreeDockWidget::selectTopLevel(int toplevelId)
{
    mResourceTreeWidget->selectResource(toplevelId, false);
}

//****************************************************************************/
void MaterialTreeDockWidget::clearContent(void)
{
    mResourceTreeWidget->clear();
    initializeResourceTree();
}

//****************************************************************************/
bool MaterialTreeDockWidget::addAssetQuiet(int toplevelId,
                                           const QString& name,
                                           const QString& baseName,
                                           const QString& baseNameThumb)
{
    // Always add it even if the resource exists (sometimes the resourcetree and mSourceInfo are out-of-sync)
    if (isResourceExisting(baseName))
    {
        // delete it first
        deleteAssetQuiet(toplevelId, name, baseName);
    }

    // Suppress the signal that a resource was added, otherwise the signal causes the asset to
    // be added to the asset widget
    int resourceId = mResourceTreeWidget->addResource(toplevelId, baseName, name, name, true, true);
    mResourceTreeWidget->expand(toplevelId);

    // Also add/set it to mSourceInfo
    QtSourcesInfo info;
    info.toplevelId = toplevelId;
    info.resourceId = resourceId;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_ASSET; // It is an asset
    info.parentId = toplevelId;
    info.fileName = name;
    info.baseName = baseName;
    info.baseNameThumb = baseNameThumb;
    mSourceInfo[resourceId] = info;
    return true;
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::setSelectAssetQuiet(const QString& baseNameThumb)
{
    int id = getResourceId(baseNameThumb);
    if (id != -1)
    {
        mResourceTreeWidget->selectResource(id, false);
        return mSourceInfo[id].fileName;
    }

    return mEmptyString;
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::doubleClicked(const QString& baseNameThumb)
{
    int id = getResourceId(baseNameThumb);
    if (id != -1)
    {
        return mSourceInfo[id].fileName;
    }

    return mEmptyString;
}
コード例 #4
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include "material_browser.h"
#include "material_tree.h"

//****************************************************************************/
MaterialTreeDockWidget::MaterialTreeDockWidget(const QString& iconDir, const QString& title, QMainWindow* parent, Qt::WindowFlags flags) :
    QDockWidget (title, parent, flags),
    mParent(parent)
{
    mIconDir = iconDir;
    mEmptyString = "";
    mResourceTreeWidget = new Magus::QtResourceTreeWidget(iconDir);
    mResourceTreeWidget->mActionDuplicateAssetText = QString("Clone material");
    mResourceTreeWidget->mActionDeleteResourceText = QString("Remove from list");
    mResourceTreeWidget->setAddAssetAfterDuplicateAssetSelected(false); // Do not duplicate automatically
    mResourceTreeWidget->setCreateTopLevelGroupContextMenuItemEnabled(false);
    mResourceTreeWidget->setDeleteTopLevelGroupEnabled(false);
    mResourceTreeWidget->setTopLevelGroupItemEditable(false);
    mResourceTreeWidget->setSubLevelGroupItemEditable(true);
    mResourceTreeWidget->setCreateAssetContextMenuItemEnabled(false);
    mResourceTreeWidget->setAssetItemEditable(false);
    mResourceTreeWidget->setDeleteResourceContextMenuItemEnabled(true);
    mResourceTreeWidget->setImportAssetContextMenuItemEnabled(false);
    mResourceTreeWidget->setDuplicateAssetContextMenuItemEnabled(true);

    // Miscellanious settings
    mResourceTreeWidget->addCustomContextMenuItem(ACTION_EDIT);

    // Listen to events.
    // Note, that although the 'create asset' context menu is disabled, the MaterialTreeDockWidget must still handle the 'resourceAdded'
    // signal, because it is also emitted when a subgroup is created in the mResourceTreeWidget; the subgroup must be added to
    // mSourceInfo after creation, to be able to recursively delete any assets resided in subgroups (these assets must also be
    // properly deleted from the MaterialThumbsDockWidget).
    connect(mResourceTreeWidget, SIGNAL(resourceSelected(int)), this, SLOT(handleResourceSelected(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceDoubleClicked(int)), this, SLOT(handleResourceDoubleClicked(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceAdded(int)), this, SLOT(handleResourceAdded(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceDeleted(int)), this, SLOT(handleResourceDeleted(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceMoved(int)), this, SLOT(handleResourceMoved(int)));
    connect(mResourceTreeWidget, SIGNAL(resourceSearched(QString)), this, SLOT(handleResourceSearched(QString)));
    connect(mResourceTreeWidget, SIGNAL(resourceSearchReset()), this, SLOT(handleResourceSearchReset()));
    connect(mResourceTreeWidget, SIGNAL(assetDuplicated(int)), this, SLOT(handleResourceDuplicated(int)));
    connect(mResourceTreeWidget, SIGNAL(customContextMenuItemSelected(QString,int)), this, SLOT(handleCustomContextMenuItemSelected(QString, int)));
    mInnerMain = new QMainWindow();
    mInnerMain->setMinimumSize(100,100);
    mInnerMain->setCentralWidget(mResourceTreeWidget);
    setWidget(mInnerMain);
    QWidget* oldTitleBar = titleBarWidget();
    setTitleBarWidget(new QWidget());
    delete oldTitleBar;

    // Add toplevel groups
    initializeResourceTree();
}

//****************************************************************************/
void MaterialTreeDockWidget::initializeResourceTree (void)
{
    // Initialize; add toplevel groups to the mResourceTreeWidget up front
    QtSourcesInfo info;

    // HLMS PBS
    mResourceTreeWidget->addResource (TOOL_SOURCES_LEVEL_X000_PBS,
                                      TOOL_SOURCES_LEVEL_X000_PBS,
                                      0,
                                      QString("PBS"),
                                      QString("PBS"),
                                      ICON_PBS_DATABLOCK_NO_PATH);
    info.toplevelId = TOOL_SOURCES_LEVEL_X000_PBS;
    info.resourceId = TOOL_SOURCES_LEVEL_X000_PBS;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_TOPLEVEL_GROUP;
    info.parentId = 0;
    info.fileName = QString("PBS");
    info.baseName = info.fileName;
    //info.filter = TOOL_SOURCES_FORMAT_PBS;
    info.filter = QString("");
    info.baseNameThumb = ICON_PBS_DATABLOCK;
    mSourceInfo[TOOL_SOURCES_LEVEL_X000_PBS] = info;

    // HLMS UNLIT
    mResourceTreeWidget->addResource (TOOL_SOURCES_LEVEL_X000_UNLIT,
                                      TOOL_SOURCES_LEVEL_X000_UNLIT,
                                      0,
                                      QString("Unlit"),
                                      QString("Unlit"),
                                      ICON_UNLIT_DATABLOCK_NO_PATH);
    info.toplevelId = TOOL_SOURCES_LEVEL_X000_UNLIT;
    info.resourceId = TOOL_SOURCES_LEVEL_X000_UNLIT;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_TOPLEVEL_GROUP;
    info.parentId = 0;
    info.fileName = QString("Unlit");
    info.baseName = info.fileName;
    //info.filter = TOOL_SOURCES_FORMAT_UNLIT;
    info.filter = QString("");
    info.baseNameThumb = ICON_UNLIT_DATABLOCK;
    mSourceInfo[TOOL_SOURCES_LEVEL_X000_UNLIT] = info;

    // Determine what is enabled/disabled if a toplevelgroup is selected
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateSubGroupText, true);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionDuplicateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(mResourceTreeWidget->mActionDeleteResourceText, false);
    mResourceTreeWidget->enableContextMenuItemForTopLevelGroup(ACTION_EDIT, false);

    // Determine what is enabled/disabled if a subgroup is selected
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateSubGroupText, true);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionDuplicateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(mResourceTreeWidget->mActionDeleteResourceText, true);
    mResourceTreeWidget->enableContextMenuItemForSubGroup(ACTION_EDIT, false);

    // Determine what is enabled/disabled if an asset is selected
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateToplevelGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateSubGroupText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionCreateAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionImportAssetText, false);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionDuplicateAssetText, true);
    mResourceTreeWidget->enableContextMenuItemForAsset(mResourceTreeWidget->mActionDeleteResourceText, true);
    mResourceTreeWidget->enableContextMenuItemForAsset(ACTION_EDIT, true);
}

//****************************************************************************/
MaterialTreeDockWidget::~MaterialTreeDockWidget(void)
{
}

//****************************************************************************/
QVector<Magus::QtResourceInfo*>& MaterialTreeDockWidget::getResources (void)
{
    // Delegate to mResourceTreeWidget; this is the component that actually retrieves the data
    return mResourceTreeWidget->getResources();
}

//****************************************************************************/
void MaterialTreeDockWidget::setResources(const QVector<Magus::QtResourceInfo*>& resources)
{
    // Add resources to the resource tree
    mResourceTreeWidget->setResources(resources, true);

    // Iterate again through the list to make sure that the thumb info is set
    QVectorIterator<Magus::QtResourceInfo*> it(resources);
    it.toFront();
    Magus::QtResourceInfo* resourceInfo;
    while (it.hasNext())
    {
        resourceInfo = it.next();
        QtSourcesInfo info;
        info.toplevelId = resourceInfo->topLevelId;
        info.resourceId = resourceInfo->resourceId;
        info.resourceType = resourceInfo->resourceType;
        info.parentId = resourceInfo->parentId;
        info.fileName = resourceInfo->fullQualifiedName;
        info.baseName = resourceInfo->resourceName;
        info.baseNameThumb = resourceInfo->resourceName + QString (".png"); // Do not forget
        mSourceInfo[resourceInfo->resourceId] = info;
    }

    mResourceTreeWidget->expandAll();
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::getSelectedFullQualifiedName(void)
{
    QTreeWidgetItem* item = mResourceTreeWidget->getSelectedResourceItem ();
    if (item)
    {
        if (mResourceTreeWidget->isItemAsset(item))
            return mResourceTreeWidget->getFullQualifiedNameFromItem(item);
    }

    return mEmptyString;
}

//****************************************************************************/
bool MaterialTreeDockWidget::addMaterial(const QString& baseNameJson,
                                      const QString& fullNameJson,
                                      const QString& baseNameThumb,
                                      EditorHlmsTypes type)
{
    switch (type)
    {
        case HLMS_PBS:
        {
            return addAssetQuiet(TOOL_SOURCES_LEVEL_X000_PBS, fullNameJson, baseNameJson, baseNameThumb);
        }
        break;

        case HLMS_UNLIT:
        {
            return addAssetQuiet(TOOL_SOURCES_LEVEL_X000_UNLIT, fullNameJson, baseNameJson, baseNameThumb);
        }
        break;
    }
}

//****************************************************************************/
void MaterialTreeDockWidget::selectTopLevel(int toplevelId)
{
    mResourceTreeWidget->selectResource(toplevelId, false);
}

//****************************************************************************/
void MaterialTreeDockWidget::clearContent(void)
{
    mResourceTreeWidget->clear();
    initializeResourceTree();
}

//****************************************************************************/
bool MaterialTreeDockWidget::addAssetQuiet(int toplevelId,
                                           const QString& name,
                                           const QString& baseName,
                                           const QString& baseNameThumb)
{
    // Always add it even if the resource exists (sometimes the resourcetree and mSourceInfo are out-of-sync)
    if (isResourceExisting(baseName))
    {
        // delete it first
        deleteAssetQuiet(toplevelId, name, baseName);
    }

    // Suppress the signal that a resource was added, otherwise the signal causes the asset to
    // be added to the asset widget
    int resourceId = mResourceTreeWidget->addResource(toplevelId, baseName, name, name, true, true);
    mResourceTreeWidget->expand(toplevelId);

    // Also add/set it to mSourceInfo
    QtSourcesInfo info;
    info.toplevelId = toplevelId;
    info.resourceId = resourceId;
    info.resourceType = Magus::TOOL_RESOURCETREE_KEY_TYPE_ASSET; // It is an asset
    info.parentId = toplevelId;
    info.fileName = name;
    info.baseName = baseName;
    info.baseNameThumb = baseNameThumb;
    mSourceInfo[resourceId] = info;
    return true;
}

//****************************************************************************/
const QString& MaterialTreeDockWidget::setSelectAssetQuiet(const QString& baseNameThumb)
{
    int id = getResourceId(baseNameThumb);
    if (id != -1)
    {
        mResourceTreeWidget->selectResource(id, false);
        return mSourceInfo[id].fileName;
    }

    return mEmptyString;
}
コード例 #5
0
ファイル: dlnavideoitem.cpp プロジェクト: topillar/DlnaServer
/*
* Returns XML (DIDL) representation of the DLNA node. It gives a
* complete representation of the item, with as many tags as available.
*
* Reference: http://www.upnp.org/specs/av/UPnP-av-ContentDirectory-v1-Service.pdf
*/
QDomElement DlnaVideoItem::getXmlContentDirectory(QDomDocument *xml, QStringList properties) const {
    if (!xml)
        return QDomElement();

    QDomElement xml_obj = xml->createElement("item");

    updateXmlContentDirectory(xml, &xml_obj, properties);

    // properties optional of videoItem

    if (properties.contains("*") or properties.contains("upnp:genre")) {
        QDomElement upnpGenre = xml->createElement("upnp:genre");
        upnpGenre.appendChild(xml->createTextNode(metaDataGenre()));
        xml_obj.appendChild(upnpGenre);
    }

    if (properties.contains("*") or properties.contains("upnp:longDescription")) {

    }

    if (properties.contains("*") or properties.contains("upnp:producer")) {

    }

    if (properties.contains("*") or properties.contains("upnp:rating")) {

    }

    if (properties.contains("*") or properties.contains("upnp:actor")) {

    }

    if (properties.contains("*") or properties.contains("upnp:director")) {

    }

    if (properties.contains("*") or properties.contains("dc:description")) {

    }

    if (properties.contains("*") or properties.contains("dc:publisher")) {

    }

    if (properties.contains("*") or properties.contains("dc:language")) {

    }

    if (properties.contains("*") or properties.contains("dc:relation")) {

    }

    // add <res> element

    QTime duration(0, 0, 0);
    QDomElement res = xml->createElement("res");
    res.setAttribute("xmlns:dlna", "urn:schemas-dlna-org:metadata-1-0/");

    // mandatory properties: protocolInfo
    res.setAttribute("protocolInfo", getProtocolInfo());

    // optional properties
    if ((properties.contains("*") or properties.contains("res@bitrate")) and bitrate() != -1) {
        // bitrate in bytes/sec
        res.setAttribute("bitrate", QString("%1").arg(qRound(double(bitrate())/8.0)));
    }

    if (properties.contains("*") or properties.contains("res@resolution")) {
        res.setAttribute("resolution", resolution());
    }

    if (properties.contains("*") or properties.contains("res@duration")) {
        res.setAttribute("duration", QString("%1").arg(duration.addSecs(getLengthInSeconds()).toString("hh:mm:ss")));
    }

    if (properties.contains("*") or properties.contains("res@sampleFrequency")) {
        res.setAttribute("sampleFrequency", QString("%1").arg(samplerate()));
    }

    if (properties.contains("*") or properties.contains("res@nrAudioChannels")) {
        res.setAttribute("nrAudioChannels", QString("%1").arg(channelCount()));
    }

    if ((properties.contains("*") or properties.contains("res@size")) and size() != -1) {
        // size in bytes
        res.setAttribute("size", QString("%1").arg(size()));
    }

    res.appendChild(xml->createTextNode(QString("http://%2:%3/get/%1/%4").arg(getResourceId()).arg(host).arg(port).arg(getName().toUtf8().toPercentEncoding().constData())));

    xml_obj.appendChild(res);

    return xml_obj;
}