UBLibraryWidget.cpp 20.5 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
15 16
#include <QList>
#include <QFileInfo>
17
#include <QDir>
18 19 20 21 22 23 24 25

#include "UBLibraryWidget.h"
#include "core/UBSettings.h"
#include "core/UBSetting.h"
#include "core/UBApplication.h"

#include "board/UBBoardController.h"
#include "board/UBLibraryController.h"
26
#include "board/UBBoardPaletteManager.h"
27

28
#include "core/UBDownloadManager.h"
29

30
#include "frameworks/UBFileSystemUtils.h"
31
#include "frameworks/UBPlatformUtils.h"
32

33 34
#include "core/memcheck.h"

35 36 37 38 39 40
/**
 * \brief Constructor
 * @param parent as the parent widget
 * @param name as the widget object name
 */
UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailWidget(parent)
41
    , chainedElements(NULL)
42
    , mLibraryController(NULL)
43 44
    , mpCrntDir(NULL)
    , mpCrntElem(NULL)
45
    , mpTmpElem(NULL)
46 47 48 49 50 51 52 53 54 55 56
{
    setObjectName(name);
    setSpacing(5);
    mLibraryController = new UBLibraryController(parentWidget());
}

/**
 * \brief Destructor
 */
UBLibraryWidget::~UBLibraryWidget()
{
57
    if(NULL != mLibraryController){
58 59 60
        delete mLibraryController;
        mLibraryController = NULL;
    }
61
    if(NULL != mpCrntDir){
62 63
        delete mpCrntDir;
        mpCrntDir = NULL;
64 65
    }
    if(NULL != mpCrntElem){
66 67
        delete mpCrntElem;
        mpCrntElem = NULL;
68 69 70 71 72
    }
    if(NULL != mpTmpElem){
         delete mpTmpElem;
         mpTmpElem = NULL;
    }
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
}

/**
 * \brief Initialize the widget content
 */
void UBLibraryWidget::init()
{
    setAcceptDrops(true);
    mpCrntElem = new UBLibElement();
    mpCrntElem->setThumbnail(QImage(":images/libpalette/home.png"));
    chainedElements = new UBChainedLibElement(mpCrntElem);
    QList<UBLibElement*> qlElems = mLibraryController->getContent(mpCrntElem);
    mCurrentElems = qlElems;

    setCurrentElemsAndRefresh(chainedElements);

    connect(this, SIGNAL(mouseClick(QGraphicsItem*,int)), this, SLOT(onItemClicked(QGraphicsItem*,int)));
    connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
91
    connect(UBDownloadManager::downloadManager(), SIGNAL(addDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)), this, SLOT(onAddDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)));
92
    connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata(QMap<QString,QString>)));
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
}

/**
 * \brief Refresh the view
 */
void UBLibraryWidget::refreshView()
{
    // Clear the view
    mItems.clear();
    mLabels.clear();
    mItemsPaths.clear();
    mGraphicItems.clear();

    // Generate the graphics items
    generateItems();

    // Set the new items
    setGraphicsItems(mGraphicItems, mItemsPaths, mLabels);

    // Refresh the view
    refreshScene();

    emit navigBarUpdate(mpCrntElem);

    bool bFavorite = false;
    if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
    {
        bFavorite = true;
    }
    emit favoritesEntered(bFavorite);
}

/**
 * \brief Generate the graphic items related to the current directory
 */
void UBLibraryWidget::generateItems()
{
    for(int i = 0; i < mCurrentElems.size(); i++)
    {
        UBLibElement* pElem = mCurrentElems.at(i);
        mLabels << pElem->name();
        mItemsPaths << pElem->path();
        QGraphicsPixmapItem *pixmapItem = new UBThumbnailPixmap(QPixmap::fromImage(*pElem->thumbnail()));
        mGraphicItems << pixmapItem;
    }
}

/**
 * \brief Handles the click on an item
 * @param item as the clicked item
 * @param index as the given index
 */
void UBLibraryWidget::onItemClicked(QGraphicsItem *item, int index)
{
    Q_UNUSED(index);
    if(NULL != item)
    {
        int iItem = mGraphicItems.indexOf(item);
        if(0 <= iItem)
        {
            UBLibElement* pElem = mCurrentElems.at(iItem);
            if(NULL != pElem)
            {
                delete mpCrntElem;
                mpCrntElem = new UBLibElement(pElem);
158 159
                if(eUBLibElementType_Folder == pElem->type() || eUBLibElementType_VirtualFolder == pElem->type())
                {
160 161 162 163 164 165 166 167 168 169 170 171 172
                    // Add the clicked element to the end of the elements list
                    // (at this level, the user can only go down in the path)
                    UBChainedLibElement* pNextElem = new UBChainedLibElement(pElem);
                    appendChainedElement(pNextElem, chainedElements);
                    delete mpCrntDir;
                    mpCrntDir = new UBLibElement(pElem);
                    // Display the content of the folder
                    QList<UBLibElement*> qlElems = mLibraryController->getContent(mpCrntDir);
                    mCurrentElems = qlElems;
                    refreshView();
                }
                else
                {
173 174 175 176 177 178 179 180 181
                    if ("application/search" == UBFileSystemUtils::mimeTypeFromFileName(pElem->path().toLocalFile()))
                    {
                        emit displaySearchEngine(pElem);
                    }
                    else
                    {
                        // Display the properties view
                        emit propertiesRequested(pElem);
                    }
182 183
                }
            }
184
            emit itemClicked();
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
        }
    }
}

/**
 * \brief Append the given element to the given chain
 * @param element as the element to append
 * @param toElem as the given chain
 */
void UBLibraryWidget::appendChainedElement(UBChainedLibElement *element, UBChainedLibElement *toElem)
{
    if(NULL != toElem)
    {
        if(NULL != toElem->nextElement())
        {
            appendChainedElement(element, toElem->nextElement());
        }
        else
        {
            toElem->setNextElement(element);
        }
    }
}

/**
 * \brief Set the current element and refresh the scene
 * @param elem as the current element
 */
void UBLibraryWidget::setCurrentElemsAndRefresh(UBChainedLibElement *elem)
{
    if(NULL != elem)
    {
        UBLibElement* pLibElem = elem->element();
        if(NULL != pLibElem)
        {
            if(eUBLibElementType_Item != pLibElem->type())
            {
                QList<UBLibElement*> qlElements = mLibraryController->getContent(pLibElem);
                mCurrentElems = qlElements;
                delete mpCrntElem;
                mpCrntElem = new UBLibElement(pLibElem);
                refreshView();
                delete mpCrntDir;
                mpCrntDir = new UBLibElement(pLibElem);
                bool bFavorite = false;
                if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
                {
                    bFavorite = true;
                }
                emit favoritesEntered(bFavorite);
            }
        }
    }
}

/**
 * \brief Handles the selection changed event
 */
void UBLibraryWidget::onSelectionChanged()
{
    // Get the selected items
    QList<UBLibElement*> qlSelectedItems;
    QList<QGraphicsItem*> qlGI = selectedItems();

    bCanDrag = true;
    foreach(QGraphicsItem* it, qlGI)
    {
        int itIndex = mGraphicItems.indexOf(it);
        if(0 <= itIndex)
        {
            UBLibElement* pElem = mCurrentElems.at(itIndex);
            if(NULL != pElem)
            {
                if(eUBLibElementType_Category != pElem->type() && eUBLibElementType_VirtualFolder != pElem->type()) {
                    qlSelectedItems << pElem;
                }

                if(!pElem->isMoveable())
                {
                    bCanDrag = false;
                }
            }
        }
    }

    // Check if we are in the trash folder
    bool bInTrash = false;
    if(NULL != mpCrntDir)
    {
        if("Trash" == mpCrntDir->name())
        {
            bInTrash = true;
        }
    }

    // Send the signal with these items
    emit itemsSelected(qlSelectedItems, bInTrash);
}

/**
 * \brief Handle the delete done event
 */
void UBLibraryWidget::onRefreshCurrentFolder()
{
    // Refresh the current view
    mCurrentElems = mLibraryController->getContent(mpCrntDir);
    refreshView();
}

/**
 * \brief Handles the drag enter event
 * @param event as the drag enter event
 */
void UBLibraryWidget::dragEnterEvent(QDragEnterEvent *event)
{
    event->acceptProposedAction();
}

/**
 * \brief Handles the drag move event
 * @param event as the drag move event
 */
void UBLibraryWidget::dragMoveEvent(QDragMoveEvent *event)
{
    UBLibElement* pElem = elementAt(event->pos());
    if(NULL != pElem)
    {
        // We can only drop an item into a folder
        if(eUBLibElementType_Folder == pElem->type() ||
           eUBLibElementType_VirtualFolder == pElem->type())
        {
            event->acceptProposedAction();
        }
    }
}

void UBLibraryWidget::onDropMe(const QMimeData *_data)
{
	Q_UNUSED(_data);
}

/**
 * \brief Handles the drop event
 * @param event as the drop event
 */
void UBLibraryWidget::dropEvent(QDropEvent *event)
{
    const QMimeData* pMimeData = event->mimeData();
333
    if(event->source() == this){
334 335 336 337
        event->accept();

        // Get the destination item
        UBLibElement* pElem = elementAt(event->pos());
338 339
        if(NULL != pElem){
            if(eUBLibElementType_Folder == pElem->type()){
340 341 342
                // The drag comes from this application, we have now to get the list of UBLibElements*
                QList<QString> qlDroppedElems;

343
                foreach(QUrl url, pMimeData->urls()){
344 345 346 347 348 349 350 351
                    qlDroppedElems << url.toString();
                }

                if(!qlDroppedElems.empty())
                    onElementsDropped(qlDroppedElems, pElem);
            }
        }
    }
352
    else{
353
        bool bDropAccepted = false;
354 355 356 357

        //  We must check the URLs first because an image dropped from the web can contains the image datas, as well as the URLs
        //  and if we want to display the download widget in order to make the user wait for the end of the download, we need
        //  to check the URLs first!
358
        if (pMimeData->hasUrls()){
359
            QList<QUrl> urlList = pMimeData->urls();
360
            for (int i = 0; i < urlList.size() && i < 32; ++i){
361
                QString filePath;
362 363 364 365 366 367 368
                QString crntPath = urlList.at(i).toString();

                if(crntPath.startsWith("file:") || crntPath.startsWith("/")){
                    filePath = QUrl(crntPath).toLocalFile();
                }else{
                    filePath = crntPath;
                }
369

370 371 372
                mLibraryController->importItemOnLibrary(filePath);
                bDropAccepted = true;
            }
373
        }
374 375 376
        //  When an HTML is present, it means that we dropped something from the web. Normally, the HTML contains the element
        //  of the webpage and has a 'src' attribute containing the URL of the web ressource. Here we are looking for this
        //  'src' attribute, get its value and download the ressource from this URL.
377
        if (!bDropAccepted && pMimeData->hasHtml()){
378 379
            QString html = pMimeData->html();
            QString url = UBApplication::urlFromHtml(html);
380
            if("" != url){
381 382 383
                mLibraryController->importItemOnLibrary(url);
                bDropAccepted = true;
            }
384
        }
385
        if (!bDropAccepted && pMimeData->hasText()){
386 387
            // On linux external dragged element are considered as text;
            QString filePath = QUrl(pMimeData->text()).toLocalFile();
388 389 390 391
            if("" != filePath){
                mLibraryController->importItemOnLibrary(filePath);
                bDropAccepted = true;
            }
392 393 394 395 396 397 398 399 400 401 402 403 404
            else{
#ifdef Q_WS_MACX
                //  With Safari, in 95% of the drops, the mime datas are hidden in Apple Web Archive pasteboard type.
                //  This is due to the way Safari is working so we have to dig into the pasteboard in order to retrieve
                //  the data.
                QString qsUrl = UBPlatformUtils::urlFromClipboard();
                if("" != qsUrl){
                    // We finally got the url of the dropped ressource! Let's import it!
                    mLibraryController->importItemOnLibrary(qsUrl);
                    bDropAccepted = true;
                }
#endif
            }
405
        }
406
        if (!bDropAccepted && pMimeData->hasImage()){
407 408 409
            QImage image = qvariant_cast<QImage>(pMimeData->imageData());
            mLibraryController->importImageOnLibrary(image);
            bDropAccepted = true;
410 411
        }

412
        if(bDropAccepted){
413
            onRefreshCurrentFolder();
414 415 416
#ifdef Q_WS_MACX
            event->acceptProposedAction();
#else
417
            event->accept();
418
#endif
419
        }
420
        else{
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
            event->ignore();
        }
    }
}

/**
 * \brief Get the element at the given position
 * @param p as the given position
 * @return a pointer on the related element
 */
UBLibElement* UBLibraryWidget::elementAt(QPoint p)
{
    QGraphicsItem* pItem = itemAt(p);
    if(NULL != pItem)
    {
        int iItem = mGraphicItems.indexOf(pItem);
        if(-1 != iItem)
        {
            return mCurrentElems.at(iItem);
        }
    }

    // If no element is found, return NULL
    return NULL;
}


/**
 * \brief Get the element from the given name
 * @param name as the given element name
 * @return the UBLibElement related to the given name
 */
UBLibElement* UBLibraryWidget::elementFromFilePath(const QString &filePath)
{
    UBLibElement* pElem = NULL;

    foreach(UBLibElement* elem, mCurrentElems)
    {
        if(elem->path().toLocalFile() == QUrl(filePath).toLocalFile())
        {
            return elem;
        }

    }

    return pElem;
}


/**
 * \brief Update the thumbnails size
 * @param newSize as the thumbnail size
 */
void UBLibraryWidget::updateThumbnailsSize(int newSize)
{
    setThumbnailWidth(newSize);
    refreshView();
}

/**
 * \brief Handles the element dropped event
 * @param elements as the list of dropped elements
 * @param target as the drop target
 */
void UBLibraryWidget::onElementsDropped(QList<QString> elements, UBLibElement *target)
{
    if(target != mpCrntDir)
    {
        QList<UBLibElement*> qlElements;

        foreach(QString qsElem, elements)
            qlElements << elementFromFilePath(qsElem);

        mLibraryController->moveContent(qlElements, target);
        mCurrentElems = mLibraryController->getContent(mpCrntDir);
        refreshView();
    }
}

/**
 * \brief Search the element related to the given text
 * @param elem as the searched element name
 */
void UBLibraryWidget::onSearchElement(QString elem)
{
    // Store the original list of items
    mOrigCurrentElems = mLibraryController->getContent(mpCrntDir);

    // Build the filtered list
    mCurrentElems.clear();
    if(elem.isEmpty())
    {
        mCurrentElems = mOrigCurrentElems;
    }
    else
    {
        foreach(UBLibElement* ubLibElem, mOrigCurrentElems)
        {
            if(ubLibElem->name().toLower().contains(elem.toLower()))
            {
                mCurrentElems << ubLibElem;
            }
        }
    }
    refreshView();
}

/**
 * \brief Create a new folder
 */
void UBLibraryWidget::onNewFolderToCreate()
{
    // Create here a dialog asking the name of the new folder
    UBNewFolderDlg dlg;
    if(QDialog::Accepted == dlg.exec())
    {
        mLibraryController->createNewFolder(dlg.folderName(), mpCrntElem);
        onRefreshCurrentFolder();
    }
}

/**
 * \brief Constructor
 * @param parent as the parent widget
 * @param name as the object name
 */
UBNewFolderDlg::UBNewFolderDlg(QWidget *parent, const char *name):QDialog(parent)
    , mpLabel(NULL)
    , mpLineEdit(NULL)
    , mpButtons(NULL)
551 552
    , mpAddButton(NULL)
    , mpCancelButton(NULL)
553 554 555 556 557 558 559 560
    , mpLayout(NULL)
    , mpHLayout(NULL)
{
    setObjectName(name);
    setWindowTitle(tr("Add new folder"));

    mpLabel = new QLabel(tr("New Folder name:"),this);
    mpLineEdit = new QLineEdit(this);
561 562 563 564 565 566 567
    mpAddButton = new QPushButton(tr("Add"));
    mpAddButton->setDefault(true);

    mpCancelButton = new QPushButton(tr("Cancel"));
    mpCancelButton->setAutoDefault(false);

    mpButtons = new QDialogButtonBox(Qt::Horizontal, this);
568 569 570 571 572 573
    mpLayout = new QVBoxLayout(this);
    mpHLayout = new QHBoxLayout(this);
    setLayout(mpLayout);
    mpLayout->addLayout(mpHLayout, 0);
    mpHLayout->addWidget(mpLabel, 0);
    mpHLayout->addWidget(mpLineEdit, 1);
574 575 576

    mpButtons->addButton(mpAddButton,QDialogButtonBox::ActionRole);
    mpButtons->addButton(mpCancelButton,QDialogButtonBox::ActionRole);
577 578
    mpLayout->addWidget(mpButtons);

579 580
    connect(mpAddButton, SIGNAL(clicked()), this, SLOT(accept()));
    connect(mpCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
581 582
    connect(mpLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(text_Changed(const QString &)));
    connect(mpLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(text_Edited(const QString &)));
583 584 585 586 587 588 589 590 591 592

    setMaximumHeight(100);
    setMinimumHeight(100);
}

/**
 * \brief Destructor
 */
UBNewFolderDlg::~UBNewFolderDlg()
{
593 594 595 596 597 598 599 600 601 602 603
    if(NULL != mpAddButton)
    {
        delete mpAddButton;
        mpAddButton = NULL;
    }

    if(NULL != mpCancelButton)
    {
        delete mpCancelButton;
        mpCancelButton = NULL;
    }
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
    if(NULL != mpButtons)
    {
        delete mpButtons;
        mpButtons = NULL;
    }
    if(NULL != mpLineEdit)
    {
        delete mpLineEdit;
        mpLineEdit = NULL;
    }
    if(NULL != mpLabel)
    {
        delete mpLabel;
        mpLabel = NULL;
    }
    if(NULL != mpHLayout)
    {
        delete mpHLayout;
        mpHLayout = NULL;
    }
    if(NULL != mpLayout)
    {
        delete mpLayout;
        mpLayout = NULL;
    }
}

/**
 * \brief Get the folder name
 * @return the entered folder name
 */
QString UBNewFolderDlg::folderName()
{
    return mpLineEdit->text();
}
639 640 641

void UBNewFolderDlg::text_Changed(const QString &newText)
{
Claudio Valerio's avatar
Claudio Valerio committed
642
	Q_UNUSED(newText);
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
}

/*
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash) // Note: The C++ compiler transforms backslashes in strings. To include a \ in a regexp, enter it twice, i.e. \\. To match the backslash character itself, enter it four times, i.e. \\\\.
| (vertical bar or pipe)
? (question mark)
* (asterisk)

*/

void UBNewFolderDlg::text_Edited(const QString &newText)
{

    QString new_text = newText;

#ifdef Q_WS_WIN // Defined on Windows.
    QString illegalCharList("      < > : \" / \\ | ? * ");
    QRegExp regExp("[<>:\"/\\\\|?*]");
#endif

#ifdef Q_WS_QWS // Defined on Qt for Embedded Linux.
    QString illegalCharList("      < > : \" / \\ | ? * ");
    QRegExp regExp("[<>:\"/\\\\|?*]");
#endif

#ifdef Q_WS_MAC // Defined on Mac OS X.
    QString illegalCharList("      < > : \" / \\ | ? * ");
    QRegExp regExp("[<>:\"/\\\\|?*]");
#endif

#ifdef Q_WS_X11 // Defined on X11.
    QString illegalCharList("      < > : \" / \\ | ? * ");
    QRegExp regExp("[<>:\"/\\\\|?*]");
#endif

    if(new_text.indexOf(regExp) > -1)
    {
        new_text.remove(regExp);
        mpLineEdit->setText(new_text);
        QToolTip::showText(mpLineEdit->mapToGlobal(QPoint()), "A file name can`t contain any of the following characters:\r\n"+illegalCharList);
    }
}
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712

void UBLibraryWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData)
{
    Q_UNUSED(pContentHeader);
    if(pSuccess)
    {
        QDir dir;
        dir.mkdir("tmp");
        QString qsFileName = QFileInfo(sourceUrl.toString()).fileName();
        QString qsFilePath = UBFileSystemUtils::normalizeFilePath(QString("tmp/%0").arg(qsFileName));
        QFile f(qsFilePath);
        if(f.open(QIODevice::WriteOnly))
        {
            f.write(pData);
            f.close();
        }
        mLibraryController->routeItem(qsFilePath);
        dir.remove(qsFileName);
        dir.rmdir("tmp");       // Due to Qt, the directoy will be removed only if it's empty :)
    }
}
713 714 715 716 717 718 719 720 721 722 723 724 725

void UBLibraryWidget::onDisplayMetadata(QMap<QString, QString> metadatas)
{
    mpTmpElem = new UBLibElement();
    mpTmpElem->setMetadata(metadatas);
    mpTmpElem->setPath(QUrl(metadatas["Url"]));

    // As the content comes from the web (and need a download), we will not display its thumbnail.
    mpTmpElem->setThumbnail(QImage(":images/libpalette/notFound.png"));

    // Display the properties view
    emit propertiesRequested(mpTmpElem);
}