AdvancedFilterForm::AdvancedFilterForm(QWidget* parent, bool all, QList<int> descrDetDescr, QList<int> contNCont, QStringList text, bool caseSensitive, const QString& textToSettings): QDialog(parent) { atts=textToSettings; assert(descrDetDescr.count()==contNCont.count()); assert(contNCont.count()==text.count()); assert(text.count()>=ADVANCED_FILTER_MIN_ROWS && text.count()<=ADVANCED_FILTER_MAX_ROWS); rows=descrDetDescr.count(); setWindowTitle(tr("Advanced filter for constraints")); allRadio=new QRadioButton(tr("Match all of the following:")); anyRadio=new QRadioButton(tr("Match any of the following:")); if(all) allRadio->setChecked(true); else anyRadio->setChecked(true); caseSensitiveCheckBox=new QCheckBox(tr("Case sensitive")); caseSensitiveCheckBox->setChecked(caseSensitive); caseSensitiveLayout=new QHBoxLayout(); caseSensitiveLayout->addStretch(); caseSensitiveLayout->addWidget(caseSensitiveCheckBox); allAnyLayout=new QVBoxLayout(); allAnyLayout->addWidget(allRadio); allAnyLayout->addWidget(anyRadio); for(int i=0; i<ADVANCED_FILTER_MAX_ROWS; i++){ QComboBox* cb1=new QComboBox(); cb1->addItem(tr("Description")); cb1->addItem(tr("Detailed description")); if(i<rows) cb1->setCurrentIndex(descrDetDescr.at(i)); else cb1->setCurrentIndex(0); QComboBox* cb2=new QComboBox(); cb2->addItem(tr("Contains", "A text string contains other substring")); cb2->addItem(tr("Does not contain", "A text string does not contain other substring")); cb2->addItem(tr("Matches regular expr.", "A text string matches a regular expression (regexp)." " Regular expressions are a complex notion, see definition on the internet if you don't know about them or how to translate the words. " "\nDefinition from Wikipedia: 'In computing, regular expressions, also referred to as regex or regexp, provide a concise and flexible means " "for identifying strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in " "a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or " "examines text and identifies parts that match the provided specification.")); cb2->addItem(tr("Does not match reg. expr.", "A text string does not match a regular expression (regexp)." " Regular expressions are a complex notion, see definition on the internet if you don't know about them or how to translate the words. " "\nDefinition from Wikipedia: 'In computing, regular expressions, also referred to as regex or regexp, provide a concise and flexible means " "for identifying strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in " "a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or " "examines text and identifies parts that match the provided specification.")); if(i<rows) cb2->setCurrentIndex(contNCont.at(i)); else cb2->setCurrentIndex(0); QLineEdit* ln1=new QLineEdit(); if(i<rows) ln1->setText(text.at(i)); else ln1->setText(QString("")); descrDetDescrComboBoxList.append(cb1); contNContReNReComboBoxList.append(cb2); textLineEditList.append(ln1); } filtersLayout=new QGridLayout(); assert(descrDetDescrComboBoxList.count()==contNContReNReComboBoxList.count()); assert(descrDetDescrComboBoxList.count()==textLineEditList.count()); assert(descrDetDescrComboBoxList.count()==ADVANCED_FILTER_MAX_ROWS); for(int i=0; i<ADVANCED_FILTER_MAX_ROWS; i++){ QComboBox* cb1=descrDetDescrComboBoxList.at(i); QComboBox* cb2=contNContReNReComboBoxList.at(i); QLineEdit* ln1=textLineEditList.at(i); filtersLayout->addWidget(cb1, i, 0); filtersLayout->addWidget(cb2, i, 1); filtersLayout->addWidget(ln1, i, 2); } morePushButton=new QPushButton(tr("More")); fewerPushButton=new QPushButton(tr("Fewer")); moreFewerLayout=new QHBoxLayout(); moreFewerLayout->addWidget(morePushButton); moreFewerLayout->addWidget(fewerPushButton); moreFewerLayout->addStretch(); morePushButton->setEnabled(rows<ADVANCED_FILTER_MAX_ROWS); fewerPushButton->setEnabled(rows>ADVANCED_FILTER_MIN_ROWS); resetPushButton=new QPushButton(tr("Reset")); okPushButton=new QPushButton(tr("OK")); okPushButton->setDefault(true); cancelPushButton=new QPushButton(tr("Cancel")); buttonsLayout=new QHBoxLayout(); buttonsLayout->addWidget(resetPushButton); buttonsLayout->addStretch(); buttonsLayout->addWidget(okPushButton); buttonsLayout->addWidget(cancelPushButton); layout=new QVBoxLayout(this); layout->addLayout(allAnyLayout); layout->addLayout(filtersLayout); layout->addLayout(moreFewerLayout); layout->addLayout(caseSensitiveLayout); layout->addStretch(); layout->addLayout(buttonsLayout); connect(resetPushButton, SIGNAL(clicked()), this, SLOT(reset())); connect(okPushButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(reject())); connect(morePushButton, SIGNAL(clicked()), this, SLOT(more())); connect(fewerPushButton, SIGNAL(clicked()), this, SLOT(fewer())); int w=this->sizeHint().width(); int h=this->sizeHint().height(); this->resize(w, h); centerWidgetOnScreen(this); restoreFETDialogGeometry(this, atts); for(int i=0; i<ADVANCED_FILTER_MAX_ROWS; i++){ descrDetDescrComboBoxList.at(i)->setVisible(i<rows); contNContReNReComboBoxList.at(i)->setVisible(i<rows); textLineEditList.at(i)->setVisible(i<rows); } assert(textLineEditList.at(0)!=NULL); textLineEditList.at(0)->selectAll(); textLineEditList.at(0)->setFocus(); }
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(); }