Пример #1
0
void IconView::UpdateImage(MythUIButtonListItem *item)
{
    if (!m_selectedImage)
        return;

    ThumbItem *thumbitem = item->GetData().value<ThumbItem *>();

    QString selectedimage;
    if (thumbitem)
    {
        selectedimage = thumbitem->GetImageFilename();
        selectedimage = (selectedimage.isNull()) ? "" : selectedimage;
    }
    m_selectedImage->SetFilename(selectedimage);
    m_selectedImage->Load();
}
Пример #2
0
void IconView::customEvent(QEvent *event)
{
    if (event->type() == ThumbGenEvent::kEventType)
    {
        ThumbGenEvent *tge = dynamic_cast<ThumbGenEvent *>(event);

        if (!tge)
            return;

        ThumbData *td = tge->thumbData;
        if (!td)
            return;

        ThumbItem *thumbitem = m_itemHash.value(td->fileName);
        if (thumbitem)
        {
            int rotateAngle = thumbitem->GetRotationAngle();

            if (rotateAngle)
            {
                QMatrix matrix;
                matrix.rotate(rotateAngle);
                td->thumb = td->thumb.transformed(
                    matrix, Qt::SmoothTransformation);
            }

            int pos = m_itemList.indexOf(thumbitem);

            LoadThumbnail(thumbitem);

            MythUIButtonListItem *item = m_imageList->GetItemAt(pos);
            if (QFile(thumbitem->GetImageFilename()).exists())
                item->SetImage(thumbitem->GetImageFilename());

            if (m_imageList->GetCurrentPos() == pos)
                UpdateImage(item);
        }
        delete td;
    }
    else if (event->type() == ChildCountEvent::kEventType)
    {
        ChildCountEvent *cce = dynamic_cast<ChildCountEvent *>(event);

        if (!cce)
            return;

        ChildCountData *ccd = cce->childCountData;
        if (!ccd)
            return;

        ThumbItem *thumbitem = m_itemHash.value(ccd->fileName);
        if (thumbitem)
        {
            int pos = m_itemList.indexOf(thumbitem);
            MythUIButtonListItem *item = m_imageList->GetItemAt(pos);
            if (item)
                item->SetText(QString("%1").arg(ccd->count), "childcount");
        }
        delete ccd;
    }
    else if (event->type() == DialogCompletionEvent::kEventType)
    {
        DialogCompletionEvent *dce = (DialogCompletionEvent*)(event);

        QString resultid  = dce->GetId();
        int resultdata = dce->GetData().toInt();

        if (resultid == "mainmenu")
        {
            switch (resultdata)
            {
                case 0:
                    HandleSlideShow();
                    break;
                case 1:
                    HandleRandomShow();
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    HandleSubMenuFilter();
                    break;
                case 5:
                    break;
                case 6:
                    HandleSettings();
                    break;
                case 7:
                    HandleSeasonalShow();
                    break;
            }
        }
        else if (resultid == "metadatamenu")
        {
            switch (resultdata)
            {
                case 0:
                    HandleRotateCW();
                    break;
                case 1:
                    HandleRotateCCW();
                    break;
            }
        }
        else if (resultid == "markingmenu")
        {
            switch (resultdata)
            {
                case 0:
                    HandleSelectOne();
                    break;
                case 1:
                    HandleClearOneMarked();
                    break;
                case 2:
                    HandleSelectAll();
                    break;
                case 3:
                    HandleClearMarked();
                    break;
            }
        }
        else if (resultid == "filemenu")
        {
            switch (resultdata)
            {
                case 0:
                    HandleShowDevices();
                    break;
                case 1:
                    HandleEject();
                    break;
                case 2:
                    HandleImport();
                    break;
                case 3:
                    HandleCopyHere();
                    break;
                case 4:
                    HandleMoveHere();
                    break;
                case 5:
                    HandleDelete();
                    break;
                case 6:
                    HandleMkDir();
                    break;
                case 7:
                    HandleRename();
                    break;
            }
        }

        m_menuPopup = NULL;

    }

}
Пример #3
0
void IconView::LoadDirectory(const QString &dir)
{
    if (m_thumbGen && m_thumbGen->isRunning())
        m_thumbGen->cancel();

    if (m_childCountThread && m_childCountThread->isRunning())
        m_childCountThread->cancel();

    QDir d(dir);
    if (!d.exists())
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "LoadDirectory called with " +
                QString("non-existant directory: '%1'").arg(dir));
        return;
    }

    m_showDevices = false;

    m_currDir = d.absolutePath();

    while (!m_itemList.isEmpty())
        delete m_itemList.takeFirst();

    m_itemHash.clear();
    m_imageList->Reset();

    m_isGallery = GalleryUtil::LoadDirectory(m_itemList, dir, *m_galleryFilter,
                                             false, &m_itemHash, m_thumbGen);

    if (m_thumbGen && !m_thumbGen->isRunning())
        m_thumbGen->start();

    ThumbItem *thumbitem;
    for (int x = 0; x < m_itemList.size(); x++)
    {
        thumbitem = m_itemList.at(x);

        thumbitem->InitCaption(m_showcaption);
        MythUIButtonListItem* item =
            new MythUIButtonListItem(m_imageList, thumbitem->GetCaption(), 0,
                                     true, MythUIButtonListItem::NotChecked);
        item->SetData(qVariantFromValue(thumbitem));
        if (thumbitem->IsDir())
        {
            item->DisplayState("subfolder", "nodetype");
            m_childCountThread->addFile(thumbitem->GetPath());
        }

        LoadThumbnail(thumbitem);

        if (QFile(thumbitem->GetImageFilename()).exists())
            item->SetImage(thumbitem->GetImageFilename());

        if (m_itemMarked.contains(thumbitem->GetPath()))
            item->setChecked(MythUIButtonListItem::FullChecked);
    }

    if (m_childCountThread && !m_childCountThread->isRunning())
                m_childCountThread->start();

    if (m_noImagesText)
        m_noImagesText->SetVisible(m_itemList.isEmpty());

    if (!m_itemList.isEmpty())
    {
        UpdateText(m_imageList->GetItemCurrent());
        UpdateImage(m_imageList->GetItemCurrent());
    }
}