本文整理汇总了C++中QRegExp::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExp::isEmpty方法的具体用法?C++ QRegExp::isEmpty怎么用?C++ QRegExp::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegExp
的用法示例。
在下文中一共展示了QRegExp::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changed
void CustomParserConfigDialog::changed()
{
QRegExp rx;
rx.setPattern(ui->errorPattern->text());
rx.setMinimal(true);
QPalette palette;
palette.setColor(QPalette::Text, rx.isValid() ? Qt::black : Qt::red);
ui->errorPattern->setPalette(palette);
ui->errorPattern->setToolTip(rx.isValid() ? QString() : rx.errorString());
int pos = rx.indexIn(ui->errorMessage->text());
if (rx.isEmpty() || !rx.isValid() || pos < 0) {
QString error = QLatin1String("<font color=\"red\">") + tr("Not applicable: ");
if (rx.isEmpty())
error += tr("Pattern is empty.");
else if (!rx.isValid())
error += rx.errorString();
else
error += tr("Pattern does not match the error message.");
ui->fileNameTest->setText(error);
ui->lineNumberTest->setText(error);
ui->messageTest->setText(error);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
return;
}
ui->fileNameTest->setText(rx.cap(ui->fileNameCap->value()));
ui->lineNumberTest->setText(rx.cap(ui->lineNumberCap->value()));
ui->messageTest->setText(rx.cap(ui->messageCap->value()));
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
m_dirty = true;
}
示例2: filtersFromModel
void SettingsDialog::filtersFromModel(const ApiTraceFilter *model)
{
ApiTraceFilter::FilterOptions opts = model->filterOptions();
extensionsBox->setChecked(opts & ApiTraceFilter::ExtensionsFilter);
functionsBox->setChecked(opts & ApiTraceFilter::ResolutionsFilter);
errorsBox->setChecked(opts & ApiTraceFilter::ErrorsQueryFilter);
statesBox->setChecked(opts & ApiTraceFilter::ExtraStateFilter);
QRegExp regexp = model->filterRegexp();
if (regexp.isEmpty()) {
showFilterBox->setChecked(false);
} else {
showFilterBox->setChecked(true);
QMap<QString, QRegExp>::const_iterator itr;
int i = 0;
for (itr = m_showFilters.constBegin();
itr != m_showFilters.constEnd(); ++itr, ++i) {
if (itr.value() == regexp) {
showFilterCB->setCurrentIndex(i);
showFilterEdit->setText(itr.value().pattern());
return;
}
}
/* custom filter */
showFilterCB->setCurrentIndex(m_showFilters.count());
showFilterEdit->setText(regexp.pattern());
}
}
示例3: fetchValue
QSObject QSRegExpClass::fetchValue( const QSObject *objPtr,
const QSMember &mem ) const
{
if ( mem.type() != QSMember::Custom )
return QSWritableClass::fetchValue( objPtr, mem );
QRegExp *re = regExp( objPtr );
switch ( mem.index() ) {
case Valid:
return createBoolean( re->isValid() );
case Empty:
return createBoolean( re->isEmpty() );
case MLength:
return createNumber( re->matchedLength() );
case Source:
return createString( source(objPtr) );
case Global:
return createBoolean( isGlobal(objPtr) );
case IgnoreCase:
return createBoolean( isIgnoreCase(objPtr) );
case CTexts: {
QSArray array( env() );
QStringList ct = re->capturedTexts();
QStringList::ConstIterator it = ct.begin();
int i = 0;
for ( ; it != ct.end(); ++it, ++i )
array.put( QString::number( i ), createString( *it ) );
array.put( QString::fromLatin1("length"), createNumber( i ) );
return array;
}
default:
return createUndefined();
}
}
示例4: update
/*!
Reads the given \a spec and displays its values
in this PluginDetailsView.
*/
void PluginDetailsView::update(PluginSpec *spec)
{
m_ui->name->setText(spec->name());
m_ui->version->setText(spec->version());
m_ui->compatVersion->setText(spec->compatVersion());
m_ui->vendor->setText(spec->vendor());
const QString link = QString::fromLatin1("<a href=\"%1\">%1</a>").arg(spec->url());
m_ui->url->setText(link);
QString component = tr("None");
if (!spec->category().isEmpty())
component = spec->category();
m_ui->component->setText(component);
m_ui->location->setText(QDir::toNativeSeparators(spec->filePath()));
m_ui->description->setText(spec->description());
m_ui->copyright->setText(spec->copyright());
m_ui->license->setText(spec->license());
const QRegExp platforms = spec->platformSpecification();
m_ui->platforms->setText(platforms.isEmpty() ? tr("All") : platforms.pattern());
QStringList depStrings;
foreach (const PluginDependency &dep, spec->dependencies()) {
QString depString = dep.name;
depString += QLatin1String(" (");
depString += dep.version;
if (dep.type == PluginDependency::Optional)
depString += QLatin1String(", optional");
depString += QLatin1Char(')');
depStrings.append(depString);
}
m_ui->dependencies->addItems(depStrings);
}
示例5: findAll
int GenericCodeEditor::findAll( const QRegExp &expr, QTextDocument::FindFlags options )
{
mSearchSelections.clear();
if(expr.isEmpty()) {
this->updateExtraSelections();
return 0;
}
QTextEdit::ExtraSelection selection;
selection.format = mSearchResultTextFormat;
QTextDocument *doc = QPlainTextEdit::document();
QTextBlock block = doc->begin();
QTextCursor cursor;
while (block.isValid()) {
int blockPos = block.position();
int offset = 0;
while(findInBlock(doc, block, expr, offset, options, cursor)) {
offset = cursor.selectionEnd() - blockPos;
if (cursor.hasSelection()) {
selection.cursor = cursor;
mSearchSelections.append(selection);
} else
offset += 1;
}
block = block.next();
}
this->updateExtraSelections();
return mSearchSelections.count();
}
示例6: highlight
void ItemText::highlight(const QRegExp &re, const QFont &highlightFont, const QPalette &highlightPalette)
{
QList<QTextBrowser::ExtraSelection> selections;
if ( !re.isEmpty() ) {
QTextBrowser::ExtraSelection selection;
selection.format.setBackground( highlightPalette.base() );
selection.format.setForeground( highlightPalette.text() );
selection.format.setFont(highlightFont);
QTextCursor cur = m_textDocument.find(re);
int a = cur.position();
while ( !cur.isNull() ) {
if ( cur.hasSelection() ) {
selection.cursor = cur;
selections.append(selection);
} else {
cur.movePosition(QTextCursor::NextCharacter);
}
cur = m_textDocument.find(re, cur);
int b = cur.position();
if (a == b) {
cur.movePosition(QTextCursor::NextCharacter);
cur = m_textDocument.find(re, cur);
b = cur.position();
if (a == b) break;
}
a = b;
}
}
setExtraSelections(selections);
update();
}
示例7: compare
bool AppLinkItem::compare(const QRegExp ®Exp) const
{
if (regExp.isEmpty())
return false;
return mProgram.contains(regExp) ||
mTitle.contains(regExp) ;
}
示例8: QgsDialog
QgsNewNameDialog::QgsNewNameDialog( const QString &source, const QString &initial,
const QStringList &extensions, const QStringList &existing,
const QRegExp ®exp, Qt::CaseSensitivity cs,
QWidget *parent, Qt::WindowFlags flags )
: QgsDialog( parent, flags, QDialogButtonBox::Ok | QDialogButtonBox::Cancel )
, mExiting( existing )
, mExtensions( extensions )
, mCaseSensitivity( cs )
, mNamesLabel( nullptr )
, mRegexp( regexp )
, mOverwriteEnabled( true )
{
setWindowTitle( tr( "New name" ) );
QDialog::layout()->setSizeConstraint( QLayout::SetMinimumSize );
layout()->setSizeConstraint( QLayout::SetMinimumSize );
layout()->setSpacing( 6 );
mOkString = buttonBox()->button( QDialogButtonBox::Ok )->text();
QString hintString;
QString nameDesc = mExtensions.isEmpty() ? tr( "name" ) : tr( "base name" );
if ( source.isEmpty() )
{
hintString = tr( "Enter new %1" ).arg( nameDesc );
}
else
{
hintString = tr( "Enter new %1 for %2" ).arg( nameDesc, source );
}
mHintLabel = new QLabel( hintString, this );
layout()->addWidget( mHintLabel );
mLineEdit = new QLineEdit( initial, this );
if ( !regexp.isEmpty() )
{
QRegExpValidator *validator = new QRegExpValidator( regexp, this );
mLineEdit->setValidator( validator );
}
mLineEdit->setMinimumWidth( mLineEdit->fontMetrics().width( QStringLiteral( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ) ) );
connect( mLineEdit, &QLineEdit::textChanged, this, &QgsNewNameDialog::nameChanged );
layout()->addWidget( mLineEdit );
mNamesLabel = new QLabel( QStringLiteral( " " ), this );
mNamesLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
if ( !mExtensions.isEmpty() )
{
mNamesLabel->setWordWrap( true );
layout()->addWidget( mNamesLabel );
}
mErrorLabel = new QLabel( QStringLiteral( " " ), this );
mErrorLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
mErrorLabel->setWordWrap( true );
layout()->addWidget( mErrorLabel );
mLineEdit->setFocus();
mLineEdit->selectAll();
nameChanged();
}
示例9: keys
QStringList IniConfig::keys( const QRegExp & regEx ) const
{
QStringList ret;
QList<QString> keys = mValMap[mSection].keys();
foreach( QString it, keys )
if( regEx.isEmpty() || regEx.exactMatch( it ) )
ret += it;
return ret;
}
示例10: highlight
void ItemWeb::highlight(const QRegExp &re, const QFont &, const QPalette &)
{
// FIXME: Set hightlight color and font!
// FIXME: Hightlight text matching regular expression!
findText( QString(), QWebPage::HighlightAllOccurrences );
if ( !re.isEmpty() )
findText( re.pattern(), QWebPage::HighlightAllOccurrences );
}
示例11: checkRegx
bool MainWindow::checkRegx(QRegExp rx)
{
if (!rx.isValid() && rx.isEmpty() && rx.exactMatch("")){
QMessageBox::information(this, "", "Not valid regx");
return false;
}
else
return true;
}
示例12: groupValue
QString ModelGrouper::groupValue( const QModelIndex & idx )
{
QRegExp regEx = columnGroupRegex(mGroupColumn);
QString strValue = model()->data( idx.column() == mGroupColumn ? idx : idx.sibling(idx.row(),mGroupColumn), Qt::DisplayRole ).toString();
if( !regEx.isEmpty() && regEx.isValid() && strValue.contains(regEx) )
strValue = regEx.cap(regEx.captureCount() > 1 ? 1 : 0);
//LOG_5( QString("Index %1 grouped with value %2").arg(indexToStr(idx)).arg(strValue) );
return strValue;
}
示例13: search
void ItemEditorWidget::search(const QRegExp &re)
{
if ( !re.isValid() || re.isEmpty() )
return;
auto tc = textCursor();
tc.setPosition(tc.selectionStart());
setTextCursor(tc);
findNext(re);
}
示例14: setFilter
void RedisConnectionsManager::setFilter(QRegExp & pattern)
{
if (pattern.isEmpty()) {
return;
}
filter = pattern;
updateFilter();
}
示例15: setStringRegExp
void GenericProperty::setStringRegExp(const QRegExp &new_value) {
if (!new_value.isValid() || new_value.isEmpty())
return;
if (d->string_reg_exp != new_value) {
if (d->type == TypeString && !new_value.exactMatch(d->value))
setValueString(d->default_value);
d->string_reg_exp = new_value;
emit possibleValuesDisplayedChanged(this);
}
}