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


C++ QRegularExpression函数代码示例

本文整理汇总了C++中QRegularExpression函数的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpression函数的具体用法?C++ QRegularExpression怎么用?C++ QRegularExpression使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QRegularExpression函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QObject

KNMusicLrcParser::KNMusicLrcParser(QObject *parent) :
    QObject(parent),
    m_frameCatchRegExp(QRegularExpression("\\[[^\\]]*\\]")),
    m_noneNumberRegExp(QRegularExpression("[^0-9]")),
    m_utf8Codec(QTextCodec::codecForName("UTF-8")),
    m_localeCodec(knI18n->localeCodec())
{
}
开发者ID:Kreogist,项目名称:Mu,代码行数:8,代码来源:knmusiclrcparser.cpp

示例2: cleanupFileName

/**
 * Does a file name cleanup
 */
QString Note::cleanupFileName(QString name) {
    // remove characters from the name that are problematic
    name.remove(QRegularExpression("[\\/\\\\:]"));

    // remove multiple whitespaces from the name
    name.replace(QRegularExpression("\\s+"), " ");

    return name;
}
开发者ID:guija,项目名称:QOwnNotes,代码行数:12,代码来源:note.cpp

示例3: addAvion

void AvionShow::addAvion()
{
    Direction * dir=dynamic_cast<Direction *>(g());
    QString idc,idm;
    idc=_idc->model()->index(0,0).data().toString().split(QRegularExpression("\\s+"))[0];
    idm=_idm->model()->index(0,0).data().toString().split(QRegularExpression("\\s+"))[0];
    dir->setIAvion();
    connect(dir,SIGNAL(doneAddingAvion()),this,SLOT(maktir3ambetfidbascava()));
    dir->addAvion(idm,idc,ui->IdAvC->text(),"0");
}
开发者ID:NZBinome,项目名称:Genie-Logicel,代码行数:10,代码来源:avionshow.cpp

示例4: defined

QRegularExpression SystemFactory::supportedUpdateFiles() {
#if defined(Q_OS_WIN)
  return QRegularExpression(QSL(".+win.+\\.(exe|7z)"));
#elif defined(Q_OS_MAC)
  return QRegularExpression(QSL(".dmg"));
#elif defined(Q_OS_LINUX)
  return QRegularExpression(QSL(".AppImage"));
#else
  return QRegularExpression(QSL(".*"));
#endif
}
开发者ID:martinrotter,项目名称:rssguard,代码行数:11,代码来源:systemfactory.cpp

示例5: QRegularExpression

void PsUpdateDownloader::initOutput() {
	QString fileName;
	QRegularExpressionMatch m = QRegularExpression(qsl("/([^/\\?]+)(\\?|$)")).match(updateUrl);
	if (m.hasMatch()) {
		fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
	}
	if (fileName.isEmpty()) {
		fileName = qsl("tupdate-%1").arg(rand());
	}
	QString dirStr = cWorkingDir() + qsl("tupdates/");
	fileName = dirStr + fileName;
	QFileInfo file(fileName);

	QDir dir(dirStr);
	if (dir.exists()) {
		QFileInfoList all = dir.entryInfoList(QDir::Files);
		for (QFileInfoList::iterator i = all.begin(), e = all.end(); i != e; ++i) {
			if (i->absoluteFilePath() != file.absoluteFilePath()) {
				QFile::remove(i->absoluteFilePath());
			}
		}
	} else {
		dir.mkdir(dir.absolutePath());
	}
	outputFile.setFileName(fileName);
	if (file.exists()) {
		uint64 fullSize = file.size();
		if (fullSize < INT_MAX) {
			int32 goodSize = (int32)fullSize;
			if (goodSize % UpdateChunk) {
				goodSize = goodSize - (goodSize % UpdateChunk);
				if (goodSize) {
					if (outputFile.open(QIODevice::ReadOnly)) {
						QByteArray goodData = outputFile.readAll().mid(0, goodSize);
						outputFile.close();
						if (outputFile.open(QIODevice::WriteOnly)) {
							outputFile.write(goodData);
							outputFile.close();

							QMutexLocker lock(&mutex);
							already = goodSize;
						}
					}
				}
			} else {
				QMutexLocker lock(&mutex);
				already = goodSize;
			}
		}
		if (!already) {
			QFile::remove(fileName);
		}
	}
}
开发者ID:jubalh,项目名称:tdesktop,代码行数:54,代码来源:pspecific_mac.cpp

示例6: blocker

/**
 * Parses a text document and builds the navigation tree for it
 */
void NavigationWidget::parse(QTextDocument *document) {
    const QSignalBlocker blocker(this);
    Q_UNUSED(blocker);

    setDocument(document);
    clear();
    _lastHeadingItemList.clear();

    for (int i = 0; i < document->blockCount(); i++) {
        QTextBlock block = document->findBlockByNumber(i);
        int elementType = block.userState();

        // ignore all non headline types
        if ((elementType < pmh_H1) || (elementType > pmh_H6)) {
            continue;
        }

        QString text = block.text();

        text.remove(QRegularExpression("^#+"))
                .remove(QRegularExpression("#+$"))
                .remove(QRegularExpression("^\\s+"))
                .remove(QRegularExpression("^=+$"))
                .remove(QRegularExpression("^-+$"));

        if (text.isEmpty()) {
            continue;
        }

        QTreeWidgetItem *item = new QTreeWidgetItem();
        item->setText(0, text);
        item->setData(0, Qt::UserRole, block.position());
        item->setToolTip(0, tr("headline %1").arg(elementType - pmh_H1 + 1));

        // attempt to find a suitable parent item for the element type
        QTreeWidgetItem *lastHigherItem = findSuitableParentItem(elementType);

        if (lastHigherItem == NULL) {
            // if there wasn't a last higher level item then add the current
            // item to the top level
            addTopLevelItem(item);
        } else {
            // if there was a last higher level item then add the current
            // item as child of that item
            lastHigherItem->addChild(item);
        }

        _lastHeadingItemList[elementType] = item;
    }

    expandAll();
}
开发者ID:XavierCLL,项目名称:QOwnNotes,代码行数:55,代码来源:navigationwidget.cpp

示例7: QRegularExpression

void Template::translate(ITemplateTranslationProvider &provider)
{
	//This regex captures expressions of the form
	//<?= tr("This is a test") ?> and <?= tr("optional %1 parameters %2","bla","blu") ?>
	//The first capture group is the key (untranslated string), the second the optional list of parameters
	const QRegularExpression regexp = QRegularExpression("<\\?=\\s*tr\\(\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"((?:,\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")*)\\s*\\)\\?>");
	//This one is used to extract the parameters using global matching
	const QRegularExpression paramExp = QRegularExpression(",\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"");

	int offset = 0;
	QRegularExpressionMatch match;
	do
	{
		match = regexp.match(*this,offset);

		if(match.hasMatch())
		{
			int start = match.capturedStart(0);
			int len = match.capturedLength(0);
			QString key = match.captured(1);

			//replace escaped double and single quotes
			key.replace("\\\"","\"");
			key.replace("\\'", "'");

			QString translation = provider.getTranslation(key);

			//find out if we have optional parameters
			if(match.capturedLength(2)>0)
			{
				QString params = match.captured(2);
				//extract each optional parameter
				QRegularExpressionMatchIterator it = paramExp.globalMatch(params);
				while(it.hasNext())
				{
					QRegularExpressionMatch paramMatch = it.next();
					QString param = paramMatch.captured(1);

					//replace escaped quotes
					param.replace("\\\"","\"");
					param.replace("\\'", "'");

					//apply the param
					translation = translation.arg(param);
				}
			}

			this->replace(start,len,translation);
			offset = start+translation.length();
		}
	}while(match.hasMatch());
}
开发者ID:PhiTheta,项目名称:stellarium,代码行数:52,代码来源:template.cpp

示例8: text

void ScintillaEditor::changeSpacesToTabs() {
/*  -changes spaces into tabs */
    //go through the text line by line and replace spaces with tabs
    QStringList editorTextLines = text().split( QRegularExpression("\n") );

    QString textExpression = tr("\\s{2,%1}").arg( tabWidth() );

    for (int i = 0, l = editorTextLines.length(); i < l; i++) {
        editorTextLines[i].replace( QRegularExpression(textExpression), "\t");
    }

    setText( editorTextLines.join("\n") );
}
开发者ID:Leonardo2718,项目名称:Lepton_Editor,代码行数:13,代码来源:scintillaeditor.cpp

示例9: Q_D

void FloorCapVector::UnpackVector()
{
    Q_D(FloorCapVector);
    d->m_FloorVal.clear();
    d->m_CapVal.clear();
    if (d->m_Vector.isEmpty()) return;
    ExtractAnchorDate();
    QString TempVec(d->m_Vector.trimmed().toUpper());
    QStringList StringParts = TempVec.trimmed().toUpper().split(QRegularExpression("\\s"), QString::SkipEmptyParts);
    int StepLen;
    QString TempStr;
    for (int i = 1; i < StringParts.size(); i += 2) {
        TempStr = StringParts.at(i);
        TempStr.replace(QRegularExpression("\\D"), "");
        StepLen = TempStr.toInt();
        TempStr = StringParts.at(i);
        TempStr.replace(QRegularExpression("\\d"), "");
        for (int j = 0; j < StepLen; j++) {
            QString RawVal = StringParts.at(i - 1);
            RawVal.replace("[", "");
            RawVal.replace("]", "");
            auto CapFloor = RawVal.split(',', QString::KeepEmptyParts);
            if (CapFloor.size() > 0) {
                if (CapFloor.at(0).isEmpty()) d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
                else d->m_FloorVal.append(std::make_shared<double>(CapFloor.at(0).toDouble()));
            }
            else d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
            if (CapFloor.size() > 1) {
                if (CapFloor.at(1).isEmpty()) d->m_CapVal.append(std::shared_ptr<double>(nullptr));
                else d->m_CapVal.append(std::make_shared<double>(CapFloor.at(1).toDouble()));
            }
            else d->m_CapVal.append(std::shared_ptr<double>(nullptr));
        }
    }
    {
        QString RawVal = StringParts.last();
        RawVal.replace("[", "");
        RawVal.replace("]", "");
        auto CapFloor = RawVal.split(',', QString::KeepEmptyParts);
        if (CapFloor.size() > 0) {
            if (CapFloor.at(0).isEmpty()) d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
            else d->m_FloorVal.append(std::make_shared<double>(CapFloor.at(0).toDouble()));
        }
        else d->m_FloorVal.append(std::shared_ptr<double>(nullptr));
        if (CapFloor.size() > 1) {
            if (CapFloor.at(1).isEmpty()) d->m_CapVal.append(std::shared_ptr<double>(nullptr));
            else d->m_CapVal.append(std::make_shared<double>(CapFloor.at(1).toDouble()));
        }
        else d->m_CapVal.append(std::shared_ptr<double>(nullptr));
    }
}
开发者ID:VSRonin,项目名称:CLOModel,代码行数:51,代码来源:FloorCapVector.cpp

示例10: QRegularExpression

QPointF SymbolDataEditor::getMovePoint(const QString &path)
{
    QString move = QRegularExpression("^[mM] *-?\\d+\\.?\\d*,? ?-?\\d+\\.?\\d*").match(path).captured();
    move.remove(QRegularExpression("^[mM] *"));
    int indexOfSeparator = move.indexOf(QRegularExpression("[ ,]"));

    if (indexOfSeparator >= 0 && indexOfSeparator + 1 < move.size())
    {
        QString x = move.left(indexOfSeparator);
        QString y = move.mid(indexOfSeparator + 1);
        return QPointF(x.toDouble(), y.toDouble());
    }

    return QPointF(0.0, 0.0);
}
开发者ID:aizenbit,项目名称:Scribbler,代码行数:15,代码来源:symboldataeditor.cpp

示例11: createSafeSheetName

/*
  Creates a valid sheet name
    minimum length is 1
    maximum length is 31
    doesn't contain special chars: / \ ? * ] [ :
    Sheet names must not begin or end with ' (apostrophe)

  Invalid characters are replaced by one space character ' '.
 */
QString createSafeSheetName(const QString &nameProposal)
{
    if (nameProposal.isEmpty())
        return QString();

    QString ret = nameProposal;
    if (nameProposal.contains(QRegularExpression(QStringLiteral("[/\\\\?*\\][:]+"))))
        ret.replace(QRegularExpression(QStringLiteral("[/\\\\?*\\][:]+")), QStringLiteral(" "));
    while(ret.contains(QRegularExpression(QStringLiteral("^\\s*'\\s*|\\s*'\\s*$"))))
        ret.remove(QRegularExpression(QStringLiteral("^\\s*'\\s*|\\s*'\\s*$")));
    ret = ret.trimmed();
    if (ret.size() > 31)
        ret = ret.left(31);
    return ret;
}
开发者ID:BlackNib,项目名称:QtXlsxWriter,代码行数:24,代码来源:xlsxutility.cpp

示例12: QString

void LoadJob::onNewEntry(const Archive::Entry *entry)
{
    m_extractedFilesSize += entry->property("size").toLongLong();
    m_isPasswordProtected |= entry->property("isPasswordProtected").toBool();

    if (entry->isDir()) {
        m_dirCount++;
    } else {
        m_filesCount++;
    }

    if (m_isSingleFolderArchive) {
        // RPM filenames have the ./ prefix, and "." would be detected as the subfolder name, so we remove it.
        const QString fullPath = entry->fullPath().replace(QRegularExpression(QStringLiteral("^\\./")), QString());
        const QString basePath = fullPath.split(QLatin1Char('/')).at(0);

        if (m_basePath.isEmpty()) {
            m_basePath = basePath;
            m_subfolderName = basePath;
        } else {
            if (m_basePath != basePath) {
                m_isSingleFolderArchive = false;
                m_subfolderName.clear();
            }
        }
    }
}
开发者ID:aelog,项目名称:ark,代码行数:27,代码来源:jobs.cpp

示例13: saveAllSheetsToImages

void MainWindow::saveAllSheetsToImages(const QString &fileName)
{
    int indexOfExtension = fileName.indexOf(QRegularExpression("\\.\\w+$"), 0);
    QString currentFileName;
    currentSheetNumber = -1;
    ui->toolBar->actions()[ToolButton::Next]->setEnabled(true);
    ui->svgView->hideBorders(true);

    while (ui->toolBar->actions()[ToolButton::Next]->isEnabled()) //while "Next Sheet" tool button is enabled,
    {                                                             //i.e. while rendering all sheets
        renderNextSheet();
        currentFileName = fileName;

        if (currentSheetNumber > 0 || ui->toolBar->actions()[ToolButton::Next]->isEnabled())
            //i.e. there is more than one sheet
            currentFileName.insert(indexOfExtension, QString("_%1").arg(currentSheetNumber));

        saveSheet(currentFileName);
    }

    ui->svgView->hideBorders(false);

    //we used renderNextSheet() for the first sheet instead of renderFirstSheet()
    //so we need to check the number of sheet and disable previous toolbutton if needed
    if (currentSheetNumber == 0)
        ui->toolBar->actions()[ToolButton::Previous]->setDisabled(true);
}
开发者ID:aizenbit,项目名称:Scribbler,代码行数:27,代码来源:mainwindow.cpp

示例14: QRegularExpression

void WebLoadManager::onMeta() {
	QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
	if (!reply) return;

	Replies::iterator j = _replies.find(reply);
	if (j == _replies.cend()) { // handled already
		return;
	}
	webFileLoaderPrivate *loader = j.value();

	typedef QList<QNetworkReply::RawHeaderPair> Pairs;
	Pairs pairs = reply->rawHeaderPairs();
	for (Pairs::iterator i = pairs.begin(), e = pairs.end(); i != e; ++i) {
		if (QString::fromUtf8(i->first).toLower() == "content-range") {
			QRegularExpressionMatch m = QRegularExpression(qsl("/(\\d+)([^\\d]|$)")).match(QString::fromUtf8(i->second));
			if (m.hasMatch()) {
				loader->setProgress(qMax(qint64(loader->data().size()), loader->already()), m.captured(1).toLongLong());
				if (!handleReplyResult(loader, WebReplyProcessProgress)) {
					_replies.erase(j);
					_loaders.remove(loader);
					delete loader;

					reply->abort();
					reply->deleteLater();
				}
			}
		}
	}
}
开发者ID:2asoft,项目名称:tdesktop,代码行数:29,代码来源:file_download.cpp

示例15: set

void MCGUILayoutAxis::set(const QString &str) {
    QString s = str;
    if (s.size() <= 0)
        return;
    s.replace(" ", "");
    QStringList a = s.split(QRegularExpression("(?=\\-|\\+)"));
    components.clear();
    for (QString p : a) {
        if (p.length() <= 0)
            continue;
        int i = p.indexOf("%");
        Component c;
        if (i >= 0) {
            c.value = p.midRef(0, i).toFloat() / 100.f;
            if (p.endsWith("x"))
                c.unit = Component::Unit::PERCENT_X;
            else if (p.endsWith("y"))
                c.unit = Component::Unit::PERCENT_Y;
            else
                c.unit = (axis == Axis::X ? Component::Unit::PERCENT_X : Component::Unit::PERCENT_Y);
        } else {
            if (p.endsWith("px"))
                c.value = p.midRef(0, p.length() - 2).toFloat();
            else
                c.value = p.toFloat();

            c.unit = Component::Unit::PIXELS;
        }
        components.push_back(c);
    }
}
开发者ID:MCMrARM,项目名称:mcpe-json-editor,代码行数:31,代码来源:MinecraftGUIComponent.cpp


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