本文整理汇总了C++中QRegExp::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegExp::isValid方法的具体用法?C++ QRegExp::isValid怎么用?C++ QRegExp::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegExp
的用法示例。
在下文中一共展示了QRegExp::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
void ModItemsTree::findCompOfInheritingClassesInDescendants2(const QStringList & classNames,QString parentName,QString parentClass,QMultiMap<QString,QString> &result,QRegExp classFilter)
{
if(classFilter.isValid() && !parentClass.contains(classFilter))
return ;// no need to carry on
QStringList compShortNames,compClasses;
QString childLongName;
// quick version but does not catch everything
_moomc->getContainedComponents(parentClass,compShortNames,compClasses,true);
foreach(QString className, classNames)
{
for(int i=0;i<compClasses.size();i++)
{
if(!classFilter.isValid() || parentClass.contains(classFilter))
{
if((compClasses.at(i)==className)||_moomc->inherits(compClasses.at(i),className))
{
childLongName = parentClass.isEmpty() ? compShortNames.at(i) : parentName+"."+compShortNames.at(i);
result.insert(className,childLongName);
}
}
}
}
ModItem* compItem;
for(int i=0;i<compClasses.size();i++)
{
childLongName = parentClass.isEmpty() ? compShortNames.at(i) : parentName+"."+compShortNames.at(i);
findCompOfInheritingClassesInDescendants2(classNames,childLongName,compClasses.at(i),result,classFilter);
}
}
示例2: 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;
}
示例3: isIntegerList
static bool isIntegerList(const QString &s)
{
// Check for empty string or comma-separated list of integers
static const QRegExp re(QLatin1String("[0-9]+(,[0-9]+)+"));
Q_ASSERT(re.isValid());
return s.isEmpty() || re.exactMatch(s);
}
示例4: search
void ItemEditorWidget::search(const QRegExp &re, bool backwards)
{
if ( !re.isValid() )
return;
auto tc = textCursor();
if ( tc.isNull() )
return;
QTextDocument::FindFlags flags;
if (backwards)
flags = QTextDocument::FindBackward;
auto tc2 = tc.document()->find(re, tc, flags);
if (tc2.isNull()) {
tc2 = tc;
if (backwards)
tc2.movePosition(QTextCursor::End);
else
tc2.movePosition(QTextCursor::Start);
tc2 = tc.document()->find(re, tc2, flags);
}
if (!tc2.isNull())
setTextCursor(tc2);
}
示例5: doSearch
void SearchDialog::doSearch()
{
QRegExp re;
re.setWildcard(true); // most people understand these better.
re.setCaseSensitive(false);
re.setPattern(searchEdit->text());
if(!re.isValid())
{
KMessageBox::sorry(this,
i18n("Invalid search expression, cannot perform "
"the search. Please enter a search expression "
"using the wildcard characters '*' and '?' "
"where needed."));
return;
}
search(re);
listView->showIncidences(mMatchedEvents);
if(mMatchedEvents.count() == 0)
{
KMessageBox::information(this,
i18n("No events were found matching your search expression."),
"NoSearchResults");
}
}
示例6: doHandle
MessageHandler::Result ScriptMessageHandler::doHandle(Message &message, QString *reason)
{
Q_UNUSED(reason);
if (message.isIncoming())
return MessageHandler::Accept;
QLatin1Literal command("/script");
QString text = message.text();
if (text.size() < command.size() + 2
|| !text.startsWith(QLatin1String(command.data()))
|| !text.at(command.size()).isSpace()) {
static QRegExp regexp("\\[\\[(.*)\\]\\]", Qt::CaseInsensitive);
Q_ASSERT(regexp.isValid());
int pos = 0;
bool first = true;
while ((pos = regexp.indexIn(text, pos)) != -1) {
if (first) {
first = false;
openContext(message.chatUnit());
}
QString result = m_engine->evaluate(regexp.cap(1)).toString();
debug() << regexp.cap(1) << result;
text.replace(pos, regexp.matchedLength(), result);
pos += result.length();
}
if (!first) {
closeContext();
message.setText(text);
}
return MessageHandler::Accept;
}
openContext(message.chatUnit());
m_engine->evaluate(message.text().mid(command.size() + 1));
closeContext();
return MessageHandler::Reject;
}
示例7: 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();
}
}
示例8: readRegExp
QRegExp* XMLUtility::readRegExp(QXmlStreamReader& reader)
{
QRegExp* regExp = new QRegExp();
if (reader.attributes().hasAttribute("IsMinimal"))
{
regExp->setMinimal(stringToBoolean(reader.attributes().value("IsMinimal").toString()));
}
if (reader.attributes().hasAttribute("CaseSensitive"))
{
regExp->setCaseSensitivity(stringToCase(reader.attributes().value("CaseSensitive").toString()));
}
if (reader.attributes().hasAttribute("PatternSyntax"))
{
regExp->setPatternSyntax(getEnumMapper().stringToPatternSyntax(reader.attributes().value("PatternSyntax").toString()));
}
while (!reader.isEndElement())
{
if (reader.isCharacters())
{
regExp->setPattern(reader.text().toString());
}
reader.readNext();
}
if (!regExp->isValid())
{
delete regExp;
regExp = nullptr;
}
return regExp;
}
示例9: setColumnGroupRegex
void ModelGrouper::setColumnGroupRegex( int column, const QRegExp & regEx )
{
if( regEx.isValid() )
mColumnRegexMap[column] = regEx;
else
mColumnRegexMap.remove(column);
}
示例10: qsParseInt
// parseInt()
static QSObject qsParseInt( QSEnv *env )
{
if( env->numArgs() < 1 )
return QSObject();
QString str = env->arg( 0 ).toString();
int radix;
if (env->numArgs()==1) {
if (str.startsWith(QString::fromLatin1("0x")))
radix = 16;
else if (str.startsWith(QString::fromLatin1("0")))
radix = 8;
else
radix = 10;
} else {
radix = env->arg( 1 ).toInt32();
if (radix < 2 || radix > 36 )
return env->createNumber(NaN);
}
QRegExp re = qs_regexp_for_radix(radix);
Q_ASSERT(re.isValid());
int pos = str.indexOf(re);
if (pos >= 0) {
str = re.cap(1);
bool ok = false;
int val = str.toInt(&ok, radix);
if (ok)
return env->createNumber(val);
}
return env->createNumber(NaN);
}
示例11: slotRegExpChanged
void QtLineEditFactory::slotRegExpChanged(QtProperty *property,
const QRegExp ®Exp)
{
if (!m_createdEditors.contains(property))
return;
QtStringPropertyManager *manager = this->propertyManager(property);
if (!manager)
return;
QListIterator<QLineEdit *> itEditor(m_createdEditors[property]);
while (itEditor.hasNext()) {
QLineEdit *editor = itEditor.next();
editor->blockSignals(true);
const QValidator *oldValidator = editor->validator();
QValidator *newValidator = 0;
if (regExp.isValid()) {
newValidator = new QRegExpValidator(regExp, editor);
}
editor->setValidator(newValidator);
if (oldValidator)
delete oldValidator;
editor->blockSignals(false);
}
}
示例12: handlePresence
void JSoftwareDetection::handlePresence(const Jreen::Presence &presence)
{
QString jid = presence.from().full();
ChatUnit *unit = m_account->getUnit(jid, false);
if (JContactResource *resource = qobject_cast<JContactResource *>(unit)) {
if (!resource->features().isEmpty())
return;
setClientInfo(resource, "", "unknown-client");
QString node;
if (Jreen::Capabilities::Ptr caps = presence.payload<Jreen::Capabilities>()) {
// qDebug() << "handle caps" << caps->node();
QString capsNode = caps->node();
if(capsNode == QLatin1String("http://www.android.com/gtalk/client/caps")) {
QString software = "GTalk (Android)";
QString softwareVersion = caps->ver();
QString client = getClientDescription(software, softwareVersion, QString());
updateClientData(resource, client, software, softwareVersion, QString(), "gtalk-android");
return;
}
static const QRegExp regExp("^http://.*google.com/.*client/caps$");
Q_ASSERT(regExp.isValid());
if(regExp.exactMatch(capsNode)) {
QString software = "GTalk";
if(capsNode.startsWith("http://mail."))
software += " (GMail)";
else if(capsNode.startsWith("http://talkgadget."))
software += " (Gadget)";
QString softwareVersion = caps->ver();
QString client = getClientDescription(software, softwareVersion, QString());
updateClientData(resource, client, software, softwareVersion, QString(), "gtalk");
return;
} else {
node = caps->node() + '#' + caps->ver();
unit->setProperty("node", node);
SoftwareInfoHash::iterator it = m_hash.find(node);
// qDebug() << "find from hash" << m_hash.count();
if (it != m_hash.end()) {
SoftwareInfo &info = *it;
resource->setFeatures(info.features);
// qDebug() << info.name;
if (!info.finished) {
// qDebug() << "Send software version request";
requestSoftware(presence.from());
} else {
updateClientData(resource, info.description, info.name, info.version, info.os, info.icon);
}
return;
}
}
}
setClientInfo(resource, "", "unknown-client");
Jreen::Disco::Item discoItem(presence.from(), node, QString());
Jreen::DiscoReply *reply = m_account->client()->disco()->requestInfo(discoItem);
connect(reply, SIGNAL(finished()), SLOT(onInfoRequestFinished()));
}
}
示例13: checkRegx
bool MainWindow::checkRegx(QRegExp rx)
{
if (!rx.isValid() && rx.isEmpty() && rx.exactMatch("")){
QMessageBox::information(this, "", "Not valid regx");
return false;
}
else
return true;
}
示例14: stringToRectangle
static QRect stringToRectangle(const QString &v)
{
static QRegExp pattern(QLatin1String("(\\d+)x(\\d+)([-+]\\d+)([-+]\\d+)"));
Q_ASSERT(pattern.isValid());
return pattern.exactMatch(v) ?
QRect(QPoint(pattern.cap(3).toInt(), pattern.cap(4).toInt()),
QSize(pattern.cap(1).toInt(), pattern.cap(2).toInt())) :
QRect();
}
示例15: 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;
}