当前位置: 首页>>代码示例>>C++>>正文


C++ QRegExp::isValid方法代码示例

本文整理汇总了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);
    }
}
开发者ID:cephdon,项目名称:OMOptim,代码行数:34,代码来源:ModItemsTree.cpp

示例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;
}
开发者ID:zhongxingzhi,项目名称:qtcreator,代码行数:34,代码来源:customparserconfigdialog.cpp

示例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);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:7,代码来源:layout_propertysheet.cpp

示例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);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:26,代码来源:itemeditorwidget.cpp

示例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");
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:28,代码来源:searchdialog.cpp

示例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;
}
开发者ID:AlexeyProkhin,项目名称:qutim,代码行数:35,代码来源:scriptplugin.cpp

示例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();
    }
}
开发者ID:AliYousuf,项目名称:pdfedit-ng-,代码行数:34,代码来源:qsregexp_object.cpp

示例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;
}
开发者ID:pitonyak,项目名称:ADPStampInventory,代码行数:31,代码来源:xmlutility.cpp

示例9: setColumnGroupRegex

void ModelGrouper::setColumnGroupRegex( int column, const QRegExp & regEx )
{
	if( regEx.isValid() )
		mColumnRegexMap[column] = regEx;
	else
		mColumnRegexMap.remove(column);
}
开发者ID:carriercomm,项目名称:arsenalsuite,代码行数:7,代码来源:modelgrouper.cpp

示例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);
}
开发者ID:aschet,项目名称:qsaqt5,代码行数:33,代码来源:qsglobal_object.cpp

示例11: slotRegExpChanged

void QtLineEditFactory::slotRegExpChanged(QtProperty *property,
            const QRegExp &regExp)
{
    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);
    }
}
开发者ID:Masstronaut,项目名称:phantom-cpp,代码行数:25,代码来源:qteditorfactory.cpp

示例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()));
	}
}
开发者ID:CyberSys,项目名称:qutim,代码行数:59,代码来源:jsoftwaredetection.cpp

示例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;
}
开发者ID:vohulg,项目名称:qregx,代码行数:9,代码来源:mainwindow.cpp

示例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();
}
开发者ID:Gardenya,项目名称:qtcreator,代码行数:9,代码来源:persistentsettings.cpp

示例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;
}
开发者ID:carriercomm,项目名称:arsenalsuite,代码行数:9,代码来源:modelgrouper.cpp


注:本文中的QRegExp::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。