Ejemplo n.º 1
0
void IconView::HandleSelectAll(void)
{
    ThumbItem *item;
    for (int x = 0; x < m_itemList.size(); x++)
    {
        item = m_itemList.at(x);

        if (!m_itemMarked.contains(item->GetPath()))
            m_itemMarked.append(item->GetPath());
    }

    m_imageList->SetAllChecked(MythUIButtonListItem::FullChecked);
}
Ejemplo n.º 2
0
void IconView::HandleItemSelect(MythUIButtonListItem *item)
{
    bool handled = false;

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

    if (!thumbitem)
        return;

    // if the selected thumbitem is a Media Device
    // attempt to mount it if it isn't already
    if (thumbitem->GetMediaDevice())
        handled = HandleMediaDeviceSelect(thumbitem);

    if (!handled && thumbitem->IsDir())
    {
        m_history.push_back(m_imageList->GetCurrentPos());
        LoadDirectory(thumbitem->GetPath());

        handled = true;
    }

    if (!handled)
        HandleImageSelect("SELECT");
}
Ejemplo n.º 3
0
void IconView::UpdateText(MythUIButtonListItem *item)
{
    if (!item)
    {
        if (m_positionText)
            m_positionText->Reset();
        return;
    }

    if (m_positionText)
        m_positionText->SetText(tr("%1 of %2")
                                .arg(m_imageList->IsEmpty() ? 0 : m_imageList->GetCurrentPos() + 1)
                                .arg(m_imageList->GetCount()));

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

    if (m_crumbsText)
    {
        QString path = thumbitem->GetPath();
        path.replace(m_galleryDir, tr("Gallery Home"));
        path.replace("/", " > ");
        m_crumbsText->SetText(path);
    }

    if (m_captionText)
    {
        QString caption;
        caption = thumbitem->GetCaption();
        caption = (caption.isNull()) ? "" : caption;
        m_captionText->SetText(caption);
    }
}
Ejemplo n.º 4
0
void ImageView::LoadAlbumRunnable::run()
{
    while (!m_dirList.empty())
    {
        ThumbItem *dir = m_dirList.takeFirst();
        ThumbList children;
        GalleryUtil::LoadDirectory(children, dir->GetPath(),
                                   GalleryFilter(m_sortorder != 0),
                                   false, NULL, NULL);

        {
            QMutexLocker guard(&m_isAliveLock);
            if (!m_isAlive)
            {
                break;
            }
        }

        // The first images should not always come from the first directory.
        if (m_slideshow_sequencing > 1)
        {
            std::random_shuffle(children.begin(), children.end());
        }

        ThumbList fileList;
        filterDirectories(children, fileList, m_dirList);
        if (!fileList.empty())
        {
            m_parent->AddItems(fileList);
        }
    }
}
Ejemplo n.º 5
0
void IconView::DoDeleteCurrent(bool doDelete)
{
    if (doDelete)
    {
        ThumbItem *thumbitem = GetCurrentThumb();

        if (!thumbitem)
            return;

        QFileInfo fi;
        fi.setFile(thumbitem->GetPath());
        GalleryUtil::Delete(fi);

        LoadDirectory(m_currDir);
    }
}
Ejemplo n.º 6
0
void IconView::DoDeleteCurrent(bool doDelete)
{
    if (doDelete)
    {
        ThumbItem *thumbitem = GetCurrentThumb();

        int currPos = 0;
        MythUIButtonListItem *item = m_imageList->GetItemCurrent();
        if (item)
            currPos = m_imageList->GetCurrentPos();

        if (!thumbitem)
            return;

        QFileInfo fi;
        fi.setFile(thumbitem->GetPath());
        GalleryUtil::Delete(fi);

        LoadDirectory(m_currDir);

        m_imageList->SetItemCurrent(currPos);
    }
}
Ejemplo n.º 7
0
bool IconView::keyPressEvent(QKeyEvent *event)
{
    if (GetFocusWidget()->keyPressEvent(event))
        return true;

    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("Gallery", event, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (!m_itemList.isEmpty())
        {
            if (action == "ROTRIGHT")
                HandleRotateCW();
            else if (action == "ROTLEFT")
                HandleRotateCCW();
            else if (action == "DELETE")
                HandleDelete();
            else if (action == "EDIT")
                HandleRename();
            else if (action == "MARK")
            {
                ThumbItem *thumbitem = GetCurrentThumb();
                MythUIButtonListItem *item = m_imageList->GetItemCurrent();

                if (thumbitem)
                {
                    if (!m_itemMarked.contains(thumbitem->GetPath()))
                    {
                        m_itemMarked.append(thumbitem->GetPath());
                        item->setChecked(MythUIButtonListItem::FullChecked);
                    }
                    else
                    {
                        m_itemMarked.removeAll(thumbitem->GetPath());
                        item->setChecked(MythUIButtonListItem::NotChecked);
                    }
                }
            }
            else if (action == "SLIDESHOW")
                HandleSlideShow();
            else if (action == "RANDOMSHOW")
                HandleRandomShow();
            else if (action == "SEASONALSHOW")
                HandleSeasonalShow();
            else
                handled = false;
        }

        if (action == "ESCAPE")
        {
            if (GetMythMainWindow()->IsExitingToMain())
            {
                while ( m_currDir != m_galleryDir &&
                        HandleSubDirEscape(m_galleryDir) );
            }
            handled = HandleEscape();
        }
        else if (action == "MENU")
        {
            HandleMainMenu();
        }
    }

    if (!handled && MythScreenType::keyPressEvent(event))
        handled = true;

    return handled;
}
Ejemplo n.º 8
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());
    }
}