TreeViewItemPlaylist::TreeViewItemPlaylist(PlaylistCollection *collection,
                                           const PlaylistSearch &search,
                                           const QString &name) :
    SearchPlaylist(collection, search, name, false)
{
    PlaylistSearch::Component component = *(search.components().begin());
    m_columnType = static_cast<PlaylistItem::ColumnType>(*(component.columns().begin()));
}
Ejemplo n.º 2
0
AdvancedSearchDialog::AdvancedSearchDialog(const QString &defaultName,
                                           const PlaylistSearch &defaultSearch,
                                           QWidget *parent,
                                           const char *name) :
    KDialog(parent)
{
    setCaption( i18n("Create Search Playlist") );
    setButtons( Ok|Cancel );
    setDefaultButton( Ok );
    setObjectName( QLatin1String( name ) );
    setModal(true);

    KVBox *mw = new KVBox(this);
    setMainWidget(mw);

    KHBox *box = new KHBox(mw);
    box->setSpacing(5);

    new QLabel(i18n("Playlist name:"), box);
    m_playlistNameLineEdit = new KLineEdit(defaultName, box);

    QGroupBox *criteriaGroupBox = new QGroupBox(i18n("Search Criteria"), mw);
    mw->setStretchFactor(criteriaGroupBox, 1);

    m_criteriaLayout = new QVBoxLayout;

    QGroupBox *group = new QGroupBox();

    m_matchAnyButton = new QRadioButton(i18n("Match any of the following"));
    m_matchAllButton = new QRadioButton(i18n("Match all of the following"));

    QHBoxLayout *hgroupbox = new QHBoxLayout;
    hgroupbox->addWidget(m_matchAnyButton);
    hgroupbox->addWidget(m_matchAllButton);

    group->setLayout(hgroupbox);

    m_criteriaLayout->addWidget(group);

    if(defaultSearch.isNull()) {
        SearchLine *newSearchLine = new SearchLine(this);
        m_searchLines.append(newSearchLine);
        m_criteriaLayout->addWidget(newSearchLine);
        newSearchLine = new SearchLine(this);
        m_searchLines.append(newSearchLine);
        m_criteriaLayout->addWidget(newSearchLine);
        m_matchAnyButton->setChecked(true);
    }
    else {
        PlaylistSearch::ComponentList components = defaultSearch.components();
        for(PlaylistSearch::ComponentList::ConstIterator it = components.constBegin();
            it != components.constEnd();
            ++it)
        {
            SearchLine *s = new SearchLine(this);
            s->setSearchComponent(*it);
            m_searchLines.append(s);
            m_criteriaLayout->addWidget(s);
        }
        if(defaultSearch.searchMode() == PlaylistSearch::MatchAny)
            m_matchAnyButton->setChecked(true);
        else
            m_matchAllButton->setChecked(true);
    }

    QWidget *buttons = new QWidget(mw);
    QHBoxLayout *l = new QHBoxLayout(buttons);
    l->setSpacing(5);
    l->setMargin(0);

    KPushButton *clearButton = new KPushButton(KStandardGuiItem::clear(), buttons);
    connect(clearButton, SIGNAL(clicked()), SLOT(clear()));
    l->addWidget(clearButton);

    l->addStretch(1);

    m_moreButton = new KPushButton(i18nc("additional search options", "More"), buttons);
    connect(m_moreButton, SIGNAL(clicked()), SLOT(more()));
    l->addWidget(m_moreButton);

    m_fewerButton = new KPushButton(i18n("Fewer"), buttons);
    connect(m_fewerButton, SIGNAL(clicked()), SLOT(fewer()));
    l->addWidget(m_fewerButton);

    m_criteriaLayout->addStretch(1);

    criteriaGroupBox->setLayout(m_criteriaLayout);

    m_playlistNameLineEdit->setFocus();
}