Пример #1
0
void AudioSetupWizard::Init(void)
{
    for (QVector<AudioOutput::AudioDeviceConfig>::const_iterator it = m_outputlist->begin();
        it != m_outputlist->end(); it++)
    {
        QString name = it->name;
        MythUIButtonListItem *output =
                new MythUIButtonListItem(m_audioDeviceButtonList, name);
        output->SetData(name);
    }

    MythUIButtonListItem *stereo =
                new MythUIButtonListItem(m_speakerNumberButtonList, "Stereo");
    stereo->SetData(2);

    MythUIButtonListItem *sixchan =
                new MythUIButtonListItem(m_speakerNumberButtonList, "5.1 Channel Audio");
    sixchan->SetData(6);

    MythUIButtonListItem *eightchan =
                new MythUIButtonListItem(m_speakerNumberButtonList, "7.1 Channel Audio");
    eightchan->SetData(8);

    // If there is a DB value for device and channels, set the buttons accordingly.

    QString currentDevice = gCoreContext->GetSetting("AudioOutputDevice");
    int channels = gCoreContext->GetNumSetting("MaxChannels", 2);

    if (!currentDevice.isEmpty())
        m_audioDeviceButtonList->SetValueByData(qVariantFromValue(currentDevice));
    m_speakerNumberButtonList->SetValueByData(qVariantFromValue(channels));
}
Пример #2
0
void PlayerSettings::fillRegionList()
{
    MythUIButtonListItem *noRegion =
            new MythUIButtonListItem(m_blurayRegionList, tr("No Region"));
    noRegion->SetData(0);

    MythUIButtonListItem *regionA =
            new MythUIButtonListItem(m_blurayRegionList, tr("Region A: "
                                     "The Americas, Southeast Asia, Japan"));
    regionA->SetData(1);

    MythUIButtonListItem *regionB =
            new MythUIButtonListItem(m_blurayRegionList, tr("Region B: "
                                     "Europe, Middle East, Africa, Oceania"));
    regionB->SetData(2);

    MythUIButtonListItem *regionC =
            new MythUIButtonListItem(m_blurayRegionList, tr("Region C: "
                                     "Eastern Europe, Central and South Asia"));
    regionC->SetData(4);

    int region = gCoreContext->GetNumSetting("BlurayRegionCode", 0);

    MythUIButtonListItem *item = m_blurayRegionList->GetItemByData(region);

    if (item)
        m_blurayRegionList->SetItemCurrent(item);
}
Пример #3
0
void SearchEditor::fillGrabberButtonList()
{
    for (GrabberScript::scriptList::iterator i = m_grabberList.begin();
            i != m_grabberList.end(); ++i)
    {
        MythUIButtonListItem *item =
                    new MythUIButtonListItem(m_grabbers, (*i)->GetTitle());
        if (item)
        {
            item->SetText((*i)->GetTitle(), "title");
            item->SetData(qVariantFromValue(*i));
            QString img = (*i)->GetImage();
            QString thumb;
            if (!img.startsWith("/") && !img.isEmpty())
                thumb = QString("%1mythnetvision/icons/%2").arg(GetShareDir())
                            .arg((*i)->GetImage());
            else
                thumb = img;
            item->SetImage(thumb);
            item->setCheckable(true);
            item->setChecked(MythUIButtonListItem::NotChecked);
            QFileInfo fi((*i)->GetCommandline());
            if (findSearchGrabberInDB(fi.fileName(), VIDEO))
                item->setChecked(MythUIButtonListItem::FullChecked);
        }
        else
            delete item;
    }
}
Пример #4
0
void BookmarkManager::UpdateURLList(void)
{
    m_bookmarkList->Reset();

    if (m_messageText)
        m_messageText->SetVisible((m_siteList.count() == 0));

    MythUIButtonListItem *item = m_groupList->GetItemCurrent();
    if (!item)
        return;

    QString group = item->GetText();

    for (int x = 0; x < m_siteList.count(); x++)
    {
        Bookmark *site = m_siteList.at(x);

        if (group == site->category)
        {
            MythUIButtonListItem *item = new MythUIButtonListItem(
                    m_bookmarkList, "", "", true, MythUIButtonListItem::NotChecked);
            item->SetText(site->name, "name");
            item->SetText(site->url, "url");
            if (site->isHomepage)
                item->DisplayState("yes", "homepage");
            item->SetData(qVariantFromValue(site));
            item->setChecked(site->selected ?
                    MythUIButtonListItem::FullChecked : MythUIButtonListItem::NotChecked);
        }
    }
}
Пример #5
0
void MythDialogBox::updateMenu(void)
{
    if (!m_buttonList)
    {
         LOG(VB_GENERAL, LOG_ERR, "UpdateMenu() called before we have a button list to update!");
         return;
    }

    if (!m_currentMenu)
        return;

    if (m_titlearea)
        m_titlearea->SetText(m_currentMenu->m_title);

    m_textarea->SetText(m_currentMenu->m_text);

    m_buttonList->Reset();

    for (int x = 0; x < m_currentMenu->m_menuItems.count(); x++)
    {
        MythMenuItem *menuItem = m_currentMenu->m_menuItems.at(x);
        MythUIButtonListItem *button = new MythUIButtonListItem(m_buttonList, menuItem->Text);
        button->SetData(qVariantFromValue(menuItem));
        button->setDrawArrow((menuItem->SubMenu != NULL));

        if (m_currentMenu->m_selectedItem == x)
            m_buttonList->SetItemCurrent(button);
    }
}
Пример #6
0
void ExportNative::updateArchiveList(void)
{
    m_archiveButtonList->Reset();

    if (m_archiveList.size() == 0)
    {
        m_titleText->SetText("");
        m_datetimeText->SetText("");
        m_descriptionText->SetText("");
        m_filesizeText->SetText("");
        m_nofilesText->Show();
    }
    else
    {
        ArchiveItem *a;
        for (int x = 0;  x < m_archiveList.size(); x++)
        {
            a = m_archiveList.at(x);

            MythUIButtonListItem* item = new MythUIButtonListItem(m_archiveButtonList, a->title);
            item->SetData(qVariantFromValue(a));
        }

        m_archiveButtonList->SetItemCurrent(m_archiveButtonList->GetItemFirst());
        titleChanged(m_archiveButtonList->GetItemCurrent());
        m_nofilesText->Hide();
    }

    updateSizeBar();
}
Пример #7
0
void AudioSetupWizard::Init(void)
{
    QString current = gCoreContext->GetSetting(QString("AudioOutputDevice"));
    bool found = false;

    if (!current.isEmpty())
    {
        for (AudioOutput::ADCVect::const_iterator it = m_outputlist->begin();
             it != m_outputlist->end(); ++it)
        {
            if (it->name == current)
            {
                found = true;
                break;
            }
        }
        if (!found)
        {
            AudioOutput::AudioDeviceConfig *adc =
                AudioOutput::GetAudioDeviceConfig(current, current, true);
            if (adc->settings.IsInvalid())
            {
                LOG(VB_GENERAL, LOG_ERR, QString("Audio device %1 isn't usable")
                    .arg(current));
            }
            else
            {
                    // only insert the device if it is valid
                m_outputlist->insert(0, *adc);
            }
            delete adc;
        }
    }
    for (AudioOutput::ADCVect::const_iterator it = m_outputlist->begin();
         it != m_outputlist->end(); ++it)
    {
        QString name = it->name;
        MythUIButtonListItem *output =
                new MythUIButtonListItem(m_audioDeviceButtonList, name);
        output->SetData(name);
    }
    if (found)
    {
        m_audioDeviceButtonList->SetValueByData(qVariantFromValue(current));
    }

    m_maxspeakers = gCoreContext->GetNumSetting("MaxChannels", 2);
    m_lastAudioDevice = m_audioDeviceButtonList->GetItemCurrent()->GetText();

    // Update list for default audio device
    UpdateCapabilities();

    connect(m_ac3Check,
            SIGNAL(valueChanged()), SLOT(UpdateCapabilitiesAC3()));
    connect(m_audioDeviceButtonList,
            SIGNAL(itemSelected(MythUIButtonListItem*)),
            SLOT(UpdateCapabilities(MythUIButtonListItem*)));
}
Пример #8
0
void Ripper::updateTrackList(void)
{
    if (m_tracks->isEmpty())
        return;

    QString tmptitle;
    if (m_trackList)
    {
        m_trackList->Reset();

        int i;
        for (i = 0; i < (int)m_tracks->size(); i++)
        {
            if (i >= m_tracks->size())
                break;

            RipTrack *track = m_tracks->at(i);
            Metadata *metadata = track->metadata;

            MythUIButtonListItem *item = new MythUIButtonListItem(m_trackList,"");

            item->setCheckable(true);

            item->SetData(qVariantFromValue(track));

            if (track->isNew)
                item->DisplayState("new", "yes");
            else
                item->DisplayState("new", "no");

            if (track->active)
                item->setChecked(MythUIButtonListItem::FullChecked);
            else
                item->setChecked(MythUIButtonListItem::NotChecked);

            item->SetText(QString::number(metadata->Track()), "track");
            item->SetText(metadata->Title(), "title");
            item->SetText(metadata->Artist(), "artist");

            int length = track->length / 1000;
            if (length > 0)
            {
                int min, sec;
                min = length / 60;
                sec = length % 60;
                QString s;
                s.sprintf("%02d:%02d", min, sec);
                item->SetText(s, "length");
            }
            else
                item->SetText("", "length");

//             if (i == m_currentTrack)
//                 m_trackList->SetItemCurrent(i);
        }
    }
}
Пример #9
0
bool SelectDestination::Create(void)
{
    bool foundtheme = false;

    // Load the theme for this screen
    foundtheme = LoadWindowFromXML("mytharchive-ui.xml", "selectdestination", this);

    if (!foundtheme)
        return false;

    bool err = false;
    UIUtilE::Assign(this, m_createISOCheck, "makeisoimage_check", &err);
    UIUtilE::Assign(this, m_doBurnCheck, "burntodvdr_check", &err);
    UIUtilE::Assign(this, m_doBurnText, "burntodvdr_text", &err);
    UIUtilE::Assign(this, m_eraseDvdRwCheck, "erasedvdrw_check", &err);
    UIUtilE::Assign(this, m_eraseDvdRwText, "erasedvdrw_text", &err);
    UIUtilE::Assign(this, m_nextButton, "next_button", &err);
    UIUtilE::Assign(this, m_prevButton, "prev_button", &err);
    UIUtilE::Assign(this, m_cancelButton, "cancel_button", &err);
    UIUtilE::Assign(this, m_destinationSelector, "destination_selector", &err);
    UIUtilE::Assign(this, m_destinationText, "destination_text", &err);
    UIUtilE::Assign(this, m_findButton, "find_button", &err);
    UIUtilE::Assign(this, m_filenameEdit, "filename_edit", &err);
    UIUtilE::Assign(this, m_freespaceText, "freespace_text", &err);

    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'selectdestination'");
        return false;
    }

    connect(m_nextButton, SIGNAL(Clicked()), this, SLOT(handleNextPage()));
    connect(m_prevButton, SIGNAL(Clicked()), this, SLOT(handlePrevPage()));
    connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(handleCancel()));

    connect(m_destinationSelector, SIGNAL(itemSelected(MythUIButtonListItem*)),
            this, SLOT(setDestination(MythUIButtonListItem*)));

    for (int x = 0; x < ArchiveDestinationsCount; x++)
    {
        MythUIButtonListItem *item = new 
            MythUIButtonListItem(m_destinationSelector, tr(ArchiveDestinations[x].name));
        item->SetData(qVariantFromValue(ArchiveDestinations[x].type));
    }
    connect(m_findButton, SIGNAL(Clicked()), this, SLOT(handleFind()));

    connect(m_filenameEdit, SIGNAL(LosingFocus()), this,
            SLOT(filenameEditLostFocus()));

    BuildFocusList();

    SetFocusWidget(m_nextButton);

    loadConfiguration();

    return true;
}
Пример #10
0
void MythDialogBox::AddButton(const QString &title, QVariant data, bool newMenu,
                              bool setCurrent)
{
    MythUIButtonListItem *button = new MythUIButtonListItem(m_buttonList, title);
    button->SetData(data);
    button->setDrawArrow(newMenu);

    if (setCurrent)
        m_buttonList->SetItemCurrent(button);
}
Пример #11
0
void VideoSelector::updateVideoList(void)
{
    if (!m_videoList)
        return;

    m_videoButtonList->Reset();

    if (m_categorySelector)
    {
        VideoInfo *v;
        vector<VideoInfo *>::iterator i = m_videoList->begin();
        for ( ; i != m_videoList->end(); ++i)
        {
            v = *i;

            if (v->category == m_categorySelector->GetValue() ||
                m_categorySelector->GetValue() == tr("All Videos"))
            {
                if (v->parentalLevel <= m_currentParentalLevel)
                {
                    MythUIButtonListItem* item = new MythUIButtonListItem(
                            m_videoButtonList, v->title);
                    item->setCheckable(true);
                    if (m_selectedList.indexOf((VideoInfo *) v) != -1)
                    {
                        item->setChecked(MythUIButtonListItem::FullChecked);
                    }
                    else
                    {
                        item->setChecked(MythUIButtonListItem::NotChecked);
                    }

                    item->SetData(qVariantFromValue(v));
                }
            }
        }
    }

    if (m_videoButtonList->GetCount() > 0)
    {
        m_videoButtonList->SetItemCurrent(m_videoButtonList->GetItemFirst());
        titleChanged(m_videoButtonList->GetItemCurrent());
        m_warningText->Hide();
    }
    else
    {
        m_warningText->Show();
        m_titleText->Reset();
        m_plotText->Reset();
        m_coverImage->SetFilename("blank.png");
        m_coverImage->Load();
        m_filesizeText->Reset();
    }
}
Пример #12
0
MythUIButtonListItem *MythGenericTree::CreateListButton(MythUIButtonList *list)
{
    MythUIButtonListItem *item = new MythUIButtonListItem(list, getString());
    item->SetData(qVariantFromValue(this));
    item->SetTextFromMap(m_strings);
    item->SetImageFromMap(m_imageFilenames);

    if (visibleChildCount() > 0)
        item->setDrawArrow(true);

    return item;
}
Пример #13
0
void CustomEdit::storeRule(bool is_search, bool is_new)
{
    CustomRuleInfo rule;
    rule.recordid = '0';
    rule.title = m_titleEdit->GetText();
    rule.subtitle = m_subtitleEdit->GetText();
    rule.description = m_descriptionEdit->GetText();

    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("REPLACE INTO customexample "
                   "(rulename,fromclause,whereclause,search) "
                   "VALUES(:RULE,:FROMC,:WHEREC,:SEARCH);");
    query.bindValue(":RULE", rule.title);
    query.bindValue(":FROMC", rule.subtitle);
    query.bindValue(":WHEREC", rule.description);
    query.bindValue(":SEARCH", is_search);

    if (is_search)
        rule.title += m_seSuffix;
    else
        rule.title += m_exSuffix;

    if (!query.exec())
        MythDB::DBError("Store custom example", query);
    else if (is_new)
    {
        new MythUIButtonListItem(m_clauseList, rule.title,
                                 qVariantFromValue(rule));
    }
    else
    {
        /* Modify the existing entry.  We know one exists from the database
           search but do not know its position in the clause list.  It may
           or may not be the current item. */
        for (int i = m_maxex; i < m_clauseList->GetCount(); i++)
        {
            MythUIButtonListItem* item = m_clauseList->GetItemAt(i);
            QString removedStr = item->GetText().remove(m_seSuffix)
                                                .remove(m_exSuffix);
            if (m_titleEdit->GetText() == removedStr)
            {
                item->SetData(qVariantFromValue(rule));
                clauseChanged(item);
                break;
            }
        }
    }


}
Пример #14
0
void MythDialogBox::AddButton(const QString &title, const char *slot,
                              bool newMenu, bool setCurrent)
{
    MythUIButtonListItem *button = new MythUIButtonListItem(m_buttonList, title);

    m_useSlots = true;

    if (slot)
        button->SetData(qVariantFromValue(slot));
    button->setDrawArrow(newMenu);

    if (setCurrent)
        m_buttonList->SetItemCurrent(button);
}
Пример #15
0
void MythNews::loadSites(void)
{
    QMutexLocker locker(&m_lock);

    clearSites();

    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare(
        "SELECT name, url, ico, updated, podcast "
        "FROM newssites "
        "ORDER BY name");

    if (!query.exec())
    {
        MythDB::DBError(LOC_ERR + "Could not load sites from DB", query);
        return;
    }

    while (query.next())
    {
        QString name = query.value(0).toString();
        QString url  = query.value(1).toString();
        QString icon = query.value(2).toString();
        QDateTime time = MythDate::fromTime_t(query.value(3).toUInt());
        bool podcast = query.value(4).toInt();
        m_NewsSites.push_back(new NewsSite(name, url, time, podcast));
    }

    NewsSite::List::iterator it = m_NewsSites.begin();
    for (; it != m_NewsSites.end(); ++it)
    {
        MythUIButtonListItem *item =
            new MythUIButtonListItem(m_sitesList, (*it)->name());
        item->SetData(qVariantFromValue(*it));

        connect(*it, SIGNAL(finished(NewsSite*)),
                this, SLOT(slotNewsRetrieved(NewsSite*)));
    }

    slotRetrieveNews();

    if (m_nositesText)
    {
        if (m_NewsSites.size() == 0)
            m_nositesText->Show();
        else
            m_nositesText->Hide();
    }
}
Пример #16
0
void MythNewsConfig::loadData(void)
{
    QMutexLocker locker(&m_lock);

    NewsCategory::List::iterator it = m_priv->categoryList.begin();
    for (; it != m_priv->categoryList.end(); ++it)
    {
        MythUIButtonListItem *item =
            new MythUIButtonListItem(m_categoriesList, (*it).name);
        item->SetData(qVariantFromValue(&(*it)));
        if (!(*it).siteList.empty())
            item->setDrawArrow(true);
    }
    slotCategoryChanged(m_categoriesList->GetItemFirst());
}
Пример #17
0
void NetTree::loadData(void)
{
    if (m_type == DLG_TREE)
        m_siteMap->AssignTree(m_siteGeneric);
    else
    {
        m_siteButtonList->Reset();

        if (!m_currentNode)
            SetCurrentNode(m_siteGeneric);

        if (!m_currentNode)
            return;

        MythGenericTree *selectedNode = m_currentNode->getSelectedChild();

        typedef QList<MythGenericTree *> MGTreeChildList;
        MGTreeChildList *lchildren = m_currentNode->getAllChildren();

        for (MGTreeChildList::const_iterator p = lchildren->begin();
                p != lchildren->end(); ++p)
        {
            if (*p != NULL)
            {
                MythUIButtonListItem *item =
                        new MythUIButtonListItem(m_siteButtonList, QString(), 0,
                                true, MythUIButtonListItem::NotChecked);

                item->SetData(qVariantFromValue(*p));

                UpdateItem(item);

                if (*p == selectedNode)
                    m_siteButtonList->SetItemCurrent(item);
            }
        }

        slotItemChanged();
    }

    if (m_siteGeneric->childCount() == 0 && m_noSites)
        m_noSites->SetVisible(true);
    else if (m_noSites)
        m_noSites->SetVisible(false);

    if (m_siteGeneric->childCount() == 0)
        runTreeEditor();
}
Пример #18
0
void NetSearch::FillGrabberButtonList()
{
    m_siteList->Reset();

    for (GrabberScript::scriptList::iterator i = m_grabberList.begin();
            i != m_grabberList.end(); ++i)
    {
        MythUIButtonListItem *item =
                    new MythUIButtonListItem(m_siteList, (*i)->GetTitle());
        item->SetText((*i)->GetTitle(), "title");
        item->SetData((*i)->GetCommandline());
        QString thumb = QString("%1mythnetvision/icons/%2").arg(GetShareDir())
                            .arg((*i)->GetImage());
        item->SetImage(thumb);
    }
}
Пример #19
0
void RSSEditor::fillRSSButtonList()
{
    QMutexLocker locker(&m_lock);

    m_sites->Reset();

    for (RSSSite::rssList::iterator i = m_siteList.begin();
            i != m_siteList.end(); ++i)
    {
        MythUIButtonListItem *item =
                    new MythUIButtonListItem(m_sites, (*i)->GetTitle());
        item->SetText((*i)->GetTitle(), "title");
        item->SetText((*i)->GetDescription(), "description");
        item->SetText((*i)->GetURL(), "url");
        item->SetText((*i)->GetAuthor(), "author");
        item->SetData(qVariantFromValue(*i));
        item->SetImage((*i)->GetImage());
    }
}
Пример #20
0
void NetSearch::populateResultList(ResultItem::resultList list)
{
    QMutexLocker locker(&m_lock);

    for (ResultItem::resultList::iterator i = list.begin();
            i != list.end(); ++i)
    {
        QString title = (*i)->GetTitle();
        MythUIButtonListItem *item =
                    new MythUIButtonListItem(
                    m_searchResultList, title);
        if (item)
        {
            MetadataMap metadataMap;
            (*i)->toMap(metadataMap);
            item->SetTextFromMap(metadataMap);

            item->SetData(qVariantFromValue(*i));

            if (!(*i)->GetThumbnail().isEmpty())
            {
                QString dlfile = (*i)->GetThumbnail();

                if (dlfile.contains("%SHAREDIR%"))
                {
                    dlfile.replace("%SHAREDIR%", GetShareDir());
                    item->SetImage(dlfile);
                }
                else
                {
                    uint pos = m_searchResultList->GetItemPos(item);

                    m_imageDownload->addThumb((*i)->GetTitle(),
                                              (*i)->GetThumbnail(),
                                              qVariantFromValue<uint>(pos));
                }
            }
        }
        else
            delete item;
    }
}
Пример #21
0
void VideoSetupWizard::loadData(void)
{
    QStringList profiles = m_vdp->GetProfiles(gCoreContext->GetHostName());

    for (QStringList::const_iterator i = profiles.begin();
         i != profiles.end(); ++i)
    {
        MythUIButtonListItem *item =
            new MythUIButtonListItem(m_playbackProfileButtonList, *i);
        item->SetData(*i);
    }

    QString currentpbp = m_vdp->GetDefaultProfileName(gCoreContext->GetHostName());
    if (!currentpbp.isEmpty())
    {
        MythUIButtonListItem *set =
                m_playbackProfileButtonList->GetItemByData(currentpbp);
        m_playbackProfileButtonList->SetItemCurrent(set);
    }
}
Пример #22
0
void RecordingSelector::updateRecordingList(void)
{
    if (!m_recordingList || m_recordingList->size() == 0)
        return;

    m_recordingButtonList->Reset();

    if (m_categorySelector)
    {
        ProgramInfo *p;
        vector<ProgramInfo *>::iterator i = m_recordingList->begin();
        for ( ; i != m_recordingList->end(); i++)
        {
            p = *i;

            if (p->GetTitle() == m_categorySelector->GetValue() ||
                m_categorySelector->GetValue() == tr("All Recordings"))
            {
                MythUIButtonListItem* item = new MythUIButtonListItem(
                    m_recordingButtonList,
                    p->GetTitle() + " ~ " +
                    p->GetScheduledStartTime().toString("dd MMM yy (hh:mm)"));
                item->setCheckable(true);
                if (m_selectedList.indexOf((ProgramInfo *) p) != -1)
                {
                    item->setChecked(MythUIButtonListItem::FullChecked);
                }
                else
                {
                    item->setChecked(MythUIButtonListItem::NotChecked);
                }

                item->SetData(qVariantFromValue(p));
            }
            qApp->processEvents();
        }
    }

    m_recordingButtonList->SetItemCurrent(m_recordingButtonList->GetItemFirst());
    titleChanged(m_recordingButtonList->GetItemCurrent());
}
Пример #23
0
void ImportFile::updateRecordingList(void)
{
    if (m_recordingList.empty())
        return;

    m_recordingButtonList->Reset();

    if (m_categorySelector)
    {
        ImportItem *i;
        for (int x = 0; x < m_recordingList.count(); x++)
        {
            i = m_recordingList.at(x);

            if (i->category == m_categorySelector->GetValue() ||
                m_categorySelector->GetValue() == tr("All Recordings"))
            {
                MythUIButtonListItem* item = new MythUIButtonListItem(
                    m_recordingButtonList,
                    i->title + " ~ " + MythDate::toString(i->startTime, MythDate::kDateTimeFull + MythDate::kAutoYear));
                item->setCheckable(true);

                if (m_selectedList.indexOf((ImportItem *) i) != -1)
                {
                    item->setChecked(MythUIButtonListItem::FullChecked);
                }
                else
                {
                    item->setChecked(MythUIButtonListItem::NotChecked);
                }

                item->SetData(qVariantFromValue(i));
            }
            qApp->processEvents();
        }
    }

    m_recordingButtonList->SetItemCurrent(m_recordingButtonList->GetItemFirst());
    titleChanged(m_recordingButtonList->GetItemCurrent());
}
Пример #24
0
/** \fn     GalleryView::UpdateImageList()
 *  \brief  Updates the visible items
 *  \return void
 */
void GalleryView::UpdateImageList()
{
    m_imageList->Reset();

    // get all children from the the selected node
    MythGenericTree *selectedNode = m_galleryViewHelper->m_currentNode->getSelectedChild();
    QList<MythGenericTree *> *childs = m_galleryViewHelper->m_currentNode->getAllChildren();

    // go through the entire list and update
    QList<MythGenericTree *>::const_iterator it;
    for (it = childs->begin(); it != childs->end(); ++it)
    {
        if (*it != NULL)
        {
            MythUIButtonListItem *item = new MythUIButtonListItem(
                    m_imageList, QString(), 0,
                    true, MythUIButtonListItem::NotChecked);
            item->SetData(qVariantFromValue(*it));

            // assign and display all information about
            // the current item, like title and subdirectory count
            UpdateImageItem(item);

            // set the currently active node as selected in the image list
            if (*it == selectedNode)
                m_imageList->SetItemCurrent(item);
        }
    }

    // when the UpdateImageItem method is called the current node will also
    // be set to the current image item. After updating all items in the
    // image list we need to set the current node back to the on it was before
    m_galleryViewHelper->m_currentNode->setSelectedChild(selectedNode);

    // Updates all other widgets on the screen that show
    // information about the selected MythUIButtonListItem
    UpdateText(m_imageList->GetItemCurrent());
}
Пример #25
0
void MythNewsConfig::slotCategoryChanged(MythUIButtonListItem *item)
{
    QMutexLocker locker(&m_lock);

    if (!item)
        return;

    m_siteList->Reset();

    NewsCategory *cat = qVariantValue<NewsCategory*>(item->GetData());
    if (!cat)
        return;

    NewsSiteItem::List::iterator it = cat->siteList.begin();
    for (; it != cat->siteList.end(); ++it)
    {
        MythUIButtonListItem *newitem =
            new MythUIButtonListItem(m_siteList, (*it).name, 0, true,
                                     (*it).inDB ?
                                     MythUIButtonListItem::FullChecked :
                                     MythUIButtonListItem::NotChecked);
        newitem->SetData(qVariantFromValue(&(*it)));
    }
}
Пример #26
0
void LanguageSelection::Load(void)
{
    MythLocale *locale = new MythLocale();

    QString langCode;

    if (gCoreContext->GetLocale())
    {
        // If the global MythLocale instance exists, then we should use it
        // since it's informed by previously chosen values from the
        // database.
        *locale = *gCoreContext->GetLocale();
    }
    else
    {
        // If no global MythLocale instance exists then we're probably
        // bootstrapping before the database is available, in that case
        // we want to load language from the locale XML defaults if they
        // exist.
        // e.g. the locale defaults might define en_GB for Australia which has
        // no translation of it's own. We can't automatically derive en_GB
        // from en_AU which MythLocale will arrive at and there is no 'en'
        // translation.
        langCode = locale->GetLocaleSetting("Language");
    }

    if (langCode.isEmpty())
        langCode = locale->GetLanguageCode();
    QString localeCode = locale->GetLocaleCode();
    QString countryCode = locale->GetCountryCode();

    LOG(VB_GENERAL, LOG_INFO, 
             QString("System Locale (%1), Country (%2), Language (%3)")
                     .arg(localeCode).arg(countryCode).arg(langCode));

    QMap<QString,QString> langMap = MythTranslation::getLanguages();
    QStringList langs = langMap.values();
    langs.sort();
    MythUIButtonListItem *item;
    bool foundLanguage = false;
    for (QStringList::Iterator it = langs.begin(); it != langs.end(); ++it)
    {
        QString nativeLang = *it;
        QString code = langMap.key(nativeLang); // Slow, but map is small
        QString language = GetISO639EnglishLanguageName(code);
        item = new MythUIButtonListItem(m_languageList, nativeLang);
        item->SetText(language, "language");
        item->SetText(nativeLang, "nativelanguage");
        item->SetData(code);

         // We have to compare against locale for languages like en_GB
        if (code.toLower() == m_language.toLower() ||
            code == langCode || code == localeCode)
        {
            m_languageList->SetItemCurrent(item);
            foundLanguage = true;
        }
    }

    if (m_languageList->IsEmpty())
    {
        LOG(VB_GUI, LOG_ERR, "ERROR - Failed to load translations, at least "
                             "one translation file MUST be installed.");
        
        item = new MythUIButtonListItem(m_languageList,
                                        "English (United States)");
        item->SetText("English (United States)", "language");
        item->SetText("English (United States)", "nativelanguage");
        item->SetData("en_US");
    }

    if (!foundLanguage)
        m_languageList->SetValueByData("en_US");

    ISO3166ToNameMap localesMap = GetISO3166EnglishCountryMap();
    QStringList locales = localesMap.values();
    locales.sort();
    for (QStringList::Iterator it = locales.begin(); it != locales.end();
         ++it)
    {
        QString country = *it;
        QString code = localesMap.key(country); // Slow, but map is small
        QString nativeCountry = GetISO3166CountryName(code);
        item = new MythUIButtonListItem(m_countryList, country);
        item->SetData(code);
        item->SetText(country, "country");
        item->SetText(nativeCountry, "nativecountry");
        item->SetImage(QString("locale/%1.png").arg(code.toLower()));

        if (code == m_country || code == countryCode)
            m_countryList->SetItemCurrent(item);
    }

    delete locale;
}
Пример #27
0
bool MetadataResultsDialog::Create()
{
    if (!LoadWindowFromXML("base.xml", "MythMetadataResults", this))
        return false;

    bool err = false;
    UIUtilE::Assign(this, m_resultsList, "results", &err);
    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythMetadataResults'");
        return false;
    }

    for (int i = 0;
            i != m_results.count(); ++i)
    {
        MythUIButtonListItem *button =
            new MythUIButtonListItem(m_resultsList,
                m_results[i]->GetTitle());
        InfoMap metadataMap;
        m_results[i]->toMap(metadataMap);

        QString coverartfile;
        ArtworkList art = m_results[i]->GetArtwork(kArtworkCoverart);
        if (art.count() > 0)
            coverartfile = art.takeFirst().thumbnail;

        if (coverartfile.isEmpty())
        {
            art = m_results[i]->GetArtwork(kArtworkBanner);
            if (art.count() > 0)
               coverartfile = art.takeFirst().thumbnail;
        }

        if (coverartfile.isEmpty())
        {
            art = m_results[i]->GetArtwork(kArtworkScreenshot);
            if (art.count() > 0)
                coverartfile = art.takeFirst().thumbnail;
        }

        QString dlfile = getDownloadFilename(m_results[i]->GetTitle(),
            coverartfile);

        if (!coverartfile.isEmpty())
        {
            int pos = m_resultsList->GetItemPos(button);

            if (QFile::exists(dlfile))
                button->SetImage(dlfile);
            else
                m_imageDownload->addThumb(m_results[i]->GetTitle(),
                                 coverartfile,
                                 qVariantFromValue<uint>(pos));
        }

        button->SetTextFromMap(metadataMap);
        button->SetData(qVariantFromValue<uint>(i));
    }

    connect(m_resultsList, SIGNAL(itemClicked(MythUIButtonListItem *)),
            SLOT(sendResult(MythUIButtonListItem *)));

    BuildFocusList();

    return true;
}
Пример #28
0
void GrabberSettings::Init(void)
{
    for (QList<MetaGrabberScript*>::const_iterator it =
             m_movieGrabberList.begin();
         it != m_movieGrabberList.end(); ++it)
    {
        QString commandline = QString("metadata/Movie/%1")
                    .arg((*it)->GetCommand());
        InfoMap map;
        (*it)->toMap(map);
        MythUIButtonListItem *item =
                    new MythUIButtonListItem(m_movieGrabberButtonList, (*it)->GetName());
        item->SetData(commandline);
        item->SetTextFromMap(map);
    }

    m_movieGrabberList.clear();

    for (QList<MetaGrabberScript*>::const_iterator it = m_tvGrabberList.begin();
         it != m_tvGrabberList.end(); ++it)
    {
        QString commandline = QString("metadata/Television/%1")
                    .arg((*it)->GetCommand());
        InfoMap map;
        (*it)->toMap(map);
        MythUIButtonListItem *item =
                    new MythUIButtonListItem(m_tvGrabberButtonList, (*it)->GetName());
        item->SetData(commandline);
        item->SetTextFromMap(map);
    }

    m_tvGrabberList.clear();

    for (QList<MetaGrabberScript*>::const_iterator it =
             m_gameGrabberList.begin();
         it != m_gameGrabberList.end(); ++it)
    {
        QString commandline = QString("metadata/Game/%1")
                    .arg((*it)->GetCommand());
        InfoMap map;
        (*it)->toMap(map);
        MythUIButtonListItem *item =
                    new MythUIButtonListItem(m_gameGrabberButtonList, (*it)->GetName());
        item->SetData(commandline);
        item->SetTextFromMap(map);
    }

    m_gameGrabberList.clear();

    QString currentTVGrabber = gCoreContext->GetSetting("TelevisionGrabber",
                                         "metadata/Television/ttvdb.py");
    QString currentMovieGrabber = gCoreContext->GetSetting("MovieGrabber",
                                         "metadata/Movie/tmdb3.py");
    QString currentGameGrabber = gCoreContext->GetSetting("mythgame.MetadataGrabber",
                                         "metadata/Game/giantbomb.py");

    m_movieGrabberButtonList->SetValueByData(qVariantFromValue(currentMovieGrabber));
    m_tvGrabberButtonList->SetValueByData(qVariantFromValue(currentTVGrabber));
    m_gameGrabberButtonList->SetValueByData(qVariantFromValue(currentGameGrabber));

    int updates =
        gCoreContext->GetNumSetting("DailyArtworkUpdates", 0);
    if (updates == 1)
        m_dailyUpdatesCheck->SetCheckState(MythUIStateType::Full);
}
Пример #29
0
void SearchView::updateTracksList(void)
{
    m_tracksList->Reset();

    MythUIButtonListItem *item = m_fieldList->GetItemCurrent();

    if (!item)
        return;

    QString searchStr = m_criteriaEdit->GetText();
    int field = item->GetData().toInt();

    QString sql;
    MSqlQuery query(MSqlQuery::InitCon());

    if (searchStr.isEmpty())
    {
        sql = "SELECT song_id "
              "FROM music_songs ";

        query.prepare(sql);
    }
    else
    {
        switch(field)
        {
            case 1: // artist
            {
                sql = "SELECT song_id "
                      "FROM music_songs "
                      "LEFT JOIN music_artists ON "
                      "    music_songs.artist_id=music_artists.artist_id "
                      "WHERE music_artists.artist_name LIKE '%" + searchStr + "%' ";
                query.prepare(sql);
                break;
            }
            case 2: // album
            {
                sql = "SELECT song_id "
                      "FROM music_songs "
                      "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
                      "WHERE music_albums.album_name LIKE '%" + searchStr + "%' ";
                query.prepare(sql);
                break;
            }
            case 3: // title
            {
                sql = "SELECT song_id "
                      "FROM music_songs "
                      "WHERE music_songs.name LIKE '%" + searchStr + "%' ";
                query.prepare(sql);
                break;
            }
            case 4: // genre
            {
                sql = "SELECT song_id "
                      "FROM music_songs "
                      "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
                      "WHERE music_genres.genre LIKE '%" + searchStr + "%' ";
                query.prepare(sql);
                break;
            }
            case 5: // tags
            {
                //TODO add tag query
            }
            case 0: // all fields
            default:
            {
                sql = "SELECT song_id "
                      "FROM music_songs "
                      "LEFT JOIN music_artists ON "
                      "    music_songs.artist_id=music_artists.artist_id "
                      "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
                      "LEFT JOIN music_artists AS music_comp_artists ON "
                      "    music_albums.artist_id=music_comp_artists.artist_id "
                      "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
                      "WHERE music_songs.name LIKE '%" + searchStr + "%' "
                      "OR music_artists.artist_name LIKE '%" + searchStr + "%' "
                      "OR music_albums.album_name LIKE '%" + searchStr + "%' "
                      "OR music_genres.genre LIKE '%" + searchStr + "%' ";

                query.prepare(sql);
            }
        }
    }

    if (!query.exec() || !query.isActive())
    {
        MythDB::DBError("Search music database", query);
        return;
    }

    while (query.next())
    {
        int trackid = query.value(0).toInt();

        MusicMetadata *mdata = gMusicData->all_music->getMetadata(trackid);
        if (mdata)
        {
            MythUIButtonListItem *newitem = new MythUIButtonListItem(m_tracksList, "");
            newitem->SetData(qVariantFromValue(mdata));
            InfoMap metadataMap;
            mdata->toMap(metadataMap);
            newitem->SetTextFromMap(metadataMap);

            if (gPlayer->getCurrentPlaylist() && gPlayer->getCurrentPlaylist()->checkTrack(mdata->ID()))
                newitem->DisplayState("on", "selectedstate");
            else
                newitem->DisplayState("off", "selectedstate");

            // TODO rating state etc
        }
    }

    trackVisible(m_tracksList->GetItemCurrent());

    if (m_matchesText)
        m_matchesText->SetText(QString("%1").arg(m_tracksList->GetCount()));
}
Пример #30
0
bool MythTimeInputDialog::Create()
{
    if (!CopyWindowFromBase("MythTimeInputDialog", this))
        return false;

    MythUIText *messageText = NULL;
    MythUIButton *okButton = NULL;

    bool err = false;
    UIUtilE::Assign(this, messageText, "message", &err);
    UIUtilE::Assign(this, m_dateList, "dates", &err);
    UIUtilE::Assign(this, m_timeList, "times", &err);
    UIUtilE::Assign(this, okButton, "ok", &err);

    if (err)
    {
        LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythTimeInputDialog'");
        return false;
    }

    m_dateList->SetVisible(false);
    m_timeList->SetVisible(false);

    MythUIButtonListItem *item;
    // Date
    if (kNoDate != (m_resolution & 0xF))
    {
        const QDate startdate(m_startTime.toLocalTime().date());
        QDate date(startdate);

        int limit = 0;
        if (m_resolution & kFutureDates)
        {
            limit += m_rangeLimit;
        }
        if (m_resolution & kPastDates)
        {
            limit += m_rangeLimit;
            date = date.addDays(0-m_rangeLimit);
        }

        QString text;
        int flags;
        bool selected = false;
        for (int x = 0; x <= limit; x++)
        {
            selected = false;
            if (m_resolution & kDay)
            {
                date = date.addDays(1);
                flags = MythDate::kDateFull | MythDate::kSimplify;
                if (m_rangeLimit >= 356)
                    flags |= MythDate::kAddYear;
                text = MythDate::toString(date, flags);

                if (date == startdate)
                    selected = true;
            }
            else if (m_resolution & kMonth)
            {
                date = date.addMonths(1);
                text = date.toString("MMM yyyy");

                if ((date.month() == startdate.month()) &&
                    (date.year() == startdate.year()))
                    selected = true;
            }
            else if (m_resolution & kYear)
            {
                date = date.addYears(1);
                text = date.toString("yyyy");
                if (date.year() == startdate.year())
                    selected = true;
            }

            item = new MythUIButtonListItem(m_dateList, text, NULL, false);
            item->SetData(QVariant(date));

            if (selected)
                m_dateList->SetItemCurrent(item);
        }
        m_dateList->SetVisible(true);
    }

    // Time
    if (kNoTime != (m_resolution & 0xF0))
    {
        QDate startdate(m_startTime.toLocalTime().date());
        QTime starttime(m_startTime.toLocalTime().time());
        QTime time(0,0,0);
        QString text;
        bool selected = false;

        int limit = (m_resolution & kMinutes) ? (60 * 24) : 24;

        for (int x = 0; x < limit; x++)
        {
            selected = false;
            if (m_resolution & kMinutes)
            {
                time = time.addSecs(60);
                QDateTime dt = QDateTime(startdate, time, Qt::LocalTime);
                text = MythDate::toString(dt, MythDate::kTime);

                if (time == starttime)
                    selected = true;
            }
            else if (m_resolution & kHours)
            {
                time = time.addSecs(60*60);
                text = time.toString("hh:00");

                if (time.hour() == starttime.hour())
                    selected = true;
            }

            item = new MythUIButtonListItem(m_timeList, text, NULL, false);
            item->SetData(QVariant(time));

            if (selected)
                m_timeList->SetItemCurrent(item);
        }
        m_timeList->SetVisible(true);
    }

    if (messageText && !m_message.isEmpty())
        messageText->SetText(m_message);

    connect(okButton, SIGNAL(Clicked()), SLOT(okClicked()));

    BuildFocusList();

    return true;
}