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


C++ QStringList::replaceInStrings方法代码示例

本文整理汇总了C++中QStringList::replaceInStrings方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::replaceInStrings方法的具体用法?C++ QStringList::replaceInStrings怎么用?C++ QStringList::replaceInStrings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStringList的用法示例。


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

示例1: updateLdPath

void CProject::updateLdPath()
{
	// ldPathList
	QStringList paths = libraryPathList;
	QStringList files = libraryFileList;

	if (!paths.isEmpty()) {
		// 去除 paths 中开头的"-L", 开头的双引号, 末尾的双引号
		paths.replaceInStrings(QRegExp("^-L\\s*"), "");
		paths.replaceInStrings(QRegExp("^\""), "");
		paths.replaceInStrings(QRegExp("\"$"), "");
		ldPathList << paths;
	}

	if (!files.isEmpty()) {
		// 去除 files 中开头的"-l", 开头的双引号, 末尾的双引号 
		files.replaceInStrings(QRegExp("^-l\\s*"), "");
		files.replaceInStrings(QRegExp("^\""), "");
		files.replaceInStrings(QRegExp("\"$"), "");
		
		// 如果 files 中的链接文件不是单独的"-l名称", 而是"-l路径/名称", 则将路径加入到ldPathList中.
		QStringList::const_iterator constIterator = files.constBegin();
		QStringList::const_iterator endIterator = files.constEnd();
		while (constIterator != endIterator) {
			QString str = *constIterator;
			if (str.contains("/")) { // 如果包含"/"
				str.remove(str.lastIndexOf("/"), str.length() - 1); // 去掉最后一个"/" 到末尾
				if (!ldPathList.contains(str))						// 如果ldPathList没有包含str
					ldPathList << str;
			}
			++constIterator;
		}
	}
}
开发者ID:fkfj,项目名称:dosmall,代码行数:34,代码来源:cproject.cpp

示例2: while

QStringList Kopete::ChatSession::findUrls(const Kopete::Message &msg )
{
	Kopete::Message message = msg;
	//we check the message for every pattern
	QString tempstr = message.plainBody();
	QStringList regexppatterns = message.regexpPatterns();
	QRegExp linkregexp;
	QMap<int,QString> mapUrl;

	for (int i = 0; i < regexppatterns.size(); ++i) {
	  linkregexp.setPattern(regexppatterns[i]);
	  int pos = 0;
	  while ((pos = linkregexp.indexIn(tempstr, pos)) != -1) {
	    mapUrl.insert(pos,linkregexp.cap(0));
	    pos += linkregexp.matchedLength(); }
	}
	//we use QMap to sort links as they are in the message (if there are many links in one message)
	//lasturllist[0] - is the earliest
	QStringList lasturllist;
	QMapIterator< int, QString > i(mapUrl);
	while (i.hasNext()) { i.next(); lasturllist << i.value(); }
	lasturllist.replaceInStrings(" ", "");
	//add "http://" to link if needed to open it with a browser
	lasturllist.replaceInStrings(QRegExp( regexppatterns[1] ), QLatin1String("\\1http://\\2\\3" ));

	return lasturllist;
}
开发者ID:stegmannt,项目名称:kopete-xep0280,代码行数:27,代码来源:kopetechatsession.cpp

示例3:

  TablaModelR::TablaModelR(QObject *parent, QString ** &vec, QStringList &cabecH, QStringList &cabecV):QAbstractTableModel(parent)
  {
    distances = vec;
    cabeceraH = cabecH.replaceInStrings(".", ",");
    cabeceraV = cabecV.replaceInStrings(".", ",");
	Todos = true;    
  }
开发者ID:Teide2,项目名称:teide2,代码行数:7,代码来源:TablaModelR.cpp

示例4: programPath

QProcess * Engine::run(QFileInfo input, QObject * parent /* = nullptr */)
{
	QString exeFilePath = programPath(program());
	if (exeFilePath.isEmpty())
		return nullptr;

	QStringList env = QProcess::systemEnvironment();
	QProcess * process = new QProcess(parent);

	QString workingDir = input.canonicalPath();
#if defined(Q_OS_WIN)
	// files in the root directory of the current drive have to be handled specially
	// because QFileInfo::canonicalPath() returns a path without trailing slash
	// (i.e., a bare drive letter)
	if (workingDir.length() == 2 && workingDir.endsWith(QChar::fromLatin1(':')))
		workingDir.append(QChar::fromLatin1('/'));
#endif
	process->setWorkingDirectory(workingDir);


#if !defined(Q_OS_DARWIN) // not supported on OS X yet :(
	// Add a (customized) TEXEDIT environment variable
	env << QString::fromLatin1("TEXEDIT=%1 --position=%d %s").arg(QCoreApplication::applicationFilePath());

	#if defined(Q_OS_WIN) // MiKTeX apparently uses it's own variable
	env << QString::fromLatin1("MIKTEX_EDITOR=%1 --position=%l \"%f\"").arg(QCoreApplication::applicationFilePath());
	#endif
#endif

	QStringList args = arguments();

#if !defined(MIKTEX)
	// for old MikTeX versions: delete $synctexoption if it causes an error
	static bool checkedForSynctex = false;
	static bool synctexSupported = true;
	if (!checkedForSynctex) {
		QString pdftex = programPath(QString::fromLatin1("pdftex"));
		if (!pdftex.isEmpty()) {
			int result = QProcess::execute(pdftex, QStringList() << QString::fromLatin1("-synctex=1") << QString::fromLatin1("-version"));
			synctexSupported = (result == 0);
		}
		checkedForSynctex = true;
	}
	if (!synctexSupported)
		args.removeAll(QString::fromLatin1("$synctexoption"));
#endif

	args.replaceInStrings(QString::fromLatin1("$synctexoption"), QString::fromLatin1("-synctex=1"));
	args.replaceInStrings(QString::fromLatin1("$fullname"), input.fileName());
	args.replaceInStrings(QString::fromLatin1("$basename"), input.completeBaseName());
	args.replaceInStrings(QString::fromLatin1("$suffix"), input.suffix());
	args.replaceInStrings(QString::fromLatin1("$directory"), input.absoluteDir().absolutePath());

	process->setEnvironment(env);
	process->setProcessChannelMode(QProcess::MergedChannels);

	process->start(exeFilePath, args);

	return process;
}
开发者ID:MiKTeX,项目名称:miktex,代码行数:60,代码来源:Engine.cpp

示例5: setCurrencyCabec

 void TablaModelR::setCurrencyCabec(QStringList &cabecH, QStringList &cabecV)   // cuando modifiquemos las cabeceras
 {
    beginResetModel();
    cabeceraH = cabecH.replaceInStrings(".", ",");
    cabeceraV = cabecV.replaceInStrings(".", ",");
    endResetModel();     
 }
开发者ID:Teide2,项目名称:teide2,代码行数:7,代码来源:TablaModelR.cpp

示例6: slotAddFile

void KOpenBabel::slotAddFile()
{
    QStringList InputType;
    vector<string> InputFormat = OBConvObject->GetSupportedInputFormat();
    for (vector<string>::iterator it = InputFormat.begin(); it!=InputFormat.end(); ++it) {
        InputType << QString((*it).c_str());
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // InputType is now something like this:                                                                                    //
    // "acr -- ACR format [Read-only]", "alc -- Alchemy format", "arc -- Accelrys/MSI Biosym/Insight II CAR format [Read-only]" //
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    QStringList tmpList = InputType;
    tmpList.replaceInStrings(QRegExp("^"), "*.");
    tmpList.replaceInStrings(QRegExp(" -- "), "|");
    tmpList.replaceInStrings(QRegExp("/"), "\\/"); //escape all '/' (because of MimeTypes)
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // tmpList is now something like this:                                                                                      //
    // "*.acr|ACR format [Read-only]", "*.alc|Alchemy format"                                                                   //
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    QList<QUrl> fl = KFileDialog::getOpenUrls(
            QUrl(),
            "*|" +i18n("All Files") + '\n' + tmpList.join("\n") //add all possible extensions like "*.cml *.mol"
            );

    foreach (const QUrl &u , fl) {
        new QListWidgetItem(u.toDisplayString(), ui.FileListView);
    }
开发者ID:KDE,项目名称:kalzium,代码行数:29,代码来源:obconverter.cpp

示例7: QDialog

AboutDialog::AboutDialog(QWidget *parent)
  : QDialog(parent) {
   setupUi(this);

#ifdef KST_HAVE_REVISION_H
   QStringList utf8Authors = QString::fromUtf8(kst_authors).trimmed().split(';');
   QStringList authors;
   foreach(const QString& a, utf8Authors) {
     if (!a.startsWith('#')) {
      authors << a;
     }
   }
#else
// qmake support
  QStringList authors = QStringList()
    << "Barth Netterfield"
    << "Joshua Netterfield"
    << "Matthew Truch"
    << "Nicolas Brisset"
    << "Staikos Computing Services Inc."
    << "Rick Chern"
    << "Sumus Technology Limited"
    << "Ted Kisner"
    << "The University of British Columbia"
    << "The University of Toronto"
    << "Andrew Walker"
    << "Peter Kümmel"
    << "Zongyi Zang";
#endif

  authors.sort();
  authors.replaceInStrings("<", "&lt;");
  authors.replaceInStrings(">", "&gt;");
  authors.replaceInStrings(QRegExp("^(.*)"), "<li>\\1</li>");

  QStringList msg = QStringList()
  << tr("<qt><h2>Kst "KSTVERSION" - A data viewing program.</h2>")
#ifdef KST_REVISION
  << tr("Revision "KST_REVISION"<br><hr>")
#endif
  << tr("Copyright &copy; 2000-2014 Barth Netterfield<br><hr>")
  << tr("Homepage: <a href=\"http://kst-plot.kde.org/\">http://kst-plot.kde.org/</a><br>")
  << tr("Please report bugs with the 'Bug Report Wizard' of the 'Help' menu.<br>")
  << tr("<br>Authors and contributors (sorted alphabetically):")
  << QString("<ul>")
  << authors
  << QString("</ul>");
  
  text->setText(msg.join("\n"));
  connect(text, SIGNAL(anchorClicked(QUrl)), this, SLOT(launchURL(QUrl)));
}
开发者ID:jmlee4301,项目名称:kst,代码行数:51,代码来源:aboutdialog.cpp

示例8: loadToAppend

void Jmplayer::loadToAppend()
{
    QStringList tempFilesList = QFileDialog::getOpenFileNames(this,tr("Open File"),".",tr("audios et videos (*.mp3 *.wma *.ogg *.wave *.midi *.mp4 *.flv *.ogv *.mpeg *.mpg *.avi *.divx *.wmv *.mov)"));
    QStringList tempFilesList2 = tempFilesList; 
    tempFilesList.replaceInStrings(" ", "\\ ");    
    tempFilesList.replaceInStrings("(", "\\(");  
    tempFilesList.replaceInStrings(")", "\\)");    
    tempFilesList.replaceInStrings("'", "\\'"); 
    for (int i = 0; i < tempFilesList2.size(); ++i) {
        QString append = "loadfile "+tempFilesList2.at(i)+" 1\n";
        myProcess->write(append.toLatin1().data());     
    }
    getFilesInfosToAppend(tempFilesList,tempFilesList2);
}
开发者ID:jabouzi,项目名称:jmplayer,代码行数:14,代码来源:jmplayer.cpp

示例9: dropEvent

void ListView::dropEvent(QDropEvent *event)
{
  const QMimeData *mimeData = event->mimeData();

  QStringList imagePaths;
  QList<QUrl> imageUrls = mimeData->urls();
  QList<QUrl>::const_iterator end = imageUrls.constEnd();

  for (QList<QUrl>::const_iterator count = imageUrls.constBegin(); count != end; count++) {
    QString path = (*count).toLocalFile();
    if (!path.isEmpty() && path.contains(GCore::Data::self()->supportedFormats()))
      imagePaths << path;
  }

  QString image = imagePaths.first();
  image.remove(QRegExp("^.+/"));
  QString path = imagePaths.first();
  path.remove(image);

  QStringList pictures = imagePaths;
  pictures.replaceInStrings(path, QString());

  QAction *choice = Data::self()->dropContextMenu()->exec(mapToGlobal(event->pos()));

  if (!choice)
    return;

  if (choice->data().toInt() == 0) {
    NewGalleryWizard *wizard = new NewGalleryWizard(path, pictures, this);
    wizard->show();
  } else if (choice->data().toInt() == 1) {
    Job job = JobManager::self()->addImages(rootIndex(), imagePaths);
    connect(job.jobPtr(), SIGNAL(progress(int, int, const QString&, const QImage&)), GCore::Data::self()->imageAddProgress(), SLOT(setProgress(int, int, const QString&, const QImage&)));
  }
开发者ID:BackupTheBerlios,项目名称:galerist-svn,代码行数:34,代码来源:listview.cpp

示例10: updateFields

void PerforceSubmitEditor::updateFields()
{
    PerforceSubmitEditorWidget *widget = submitEditorWidget();
    widget->setData(m_entries.value(QLatin1String("Change")).trimmed(),
                    m_entries.value(QLatin1String("Client")).trimmed(),
                    m_entries.value(QLatin1String("User")).trimmed());

    const QString newLine = QString(QLatin1Char('\n'));
    QStringList lines = m_entries.value(QLatin1String("Description")).split(newLine);
    lines.removeFirst(); // that is the line break after 'Description:'
    lines.removeLast(); // that is the empty line at the end

    const QRegExp leadingTabPattern = QRegExp(QLatin1String("^\\t"));
    QTC_ASSERT(leadingTabPattern.isValid(), /**/);

    lines.replaceInStrings(leadingTabPattern, QString());
    widget->setDescriptionText(lines.join(newLine));

    lines = m_entries.value(QLatin1String("Files")).split(newLine);
    // split up "file#add" and store complete spec line as user data
    foreach (const QString &specLine, lines) {
        const QStringList list = specLine.split(QLatin1Char('#'));
        if (list.size() == 2) {
            const QString file = list.at(0).trimmed();
            const QString state = list.at(1).trimmed();
            m_fileModel->addFile(file, state).at(0)->setData(specLine, FileSpecRole);
        }
    }
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例11: findQmFiles

QStringList GeneralSettingsPage::findQmFiles()
{
    QDir dir(translationPath);
    QStringList fileNames = dir.entryList(QStringList(translationPrefix + "_*.qm"), QDir::Files, QDir::Name);
    fileNames.replaceInStrings(QRegExp(translationPrefix + "_(.*)\\.qm"), "\\1");
    return fileNames;
}
开发者ID:sugitime,项目名称:Cockatrice,代码行数:7,代码来源:dlg_settings.cpp

示例12: main2

int main2(int argc, char**argv)
{
    QStringList list;
    list << "foo" << "bar" << "baz";

    QString all = list.join(";");

    QStringList::const_iterator listIterator;

    for(listIterator = list.begin(); listIterator != list.end(); ++listIterator)
        qDebug() << *listIterator;

    qDebug() << "joined value: " << all;

    //replace a with oo in all strings of list
    list.replaceInStrings("a", "oo");

    for(listIterator = list.begin(); listIterator != list.end(); ++listIterator)
        qDebug() << *listIterator;

    list << all.split(";");

    qDebug() << "\n";
    for(listIterator = list.begin(); listIterator != list.end(); ++listIterator)
        qDebug() << *listIterator;

    return 0;
}
开发者ID:KleineKarsten,项目名称:FoundationsOfQtDev,代码行数:28,代码来源:specialList.cpp

示例13: testTagSeparatorWrite

void TagsReadWriteTest::testTagSeparatorWrite()
{
    DMetadata dmeta;

    DMetadataSettingsContainer dmsettings;
    QStringList readResult;
    QStringList expected;

    NamespaceEntry tagNs3;
    tagNs3.namespaceName   = QLatin1String("Xmp.lr.hierarchicalSubject");
    tagNs3.tagPaths        = NamespaceEntry::TAGPATH;
    tagNs3.separator       = QLatin1Char('|');
    tagNs3.nsType          = NamespaceEntry::TAGS;
    tagNs3.index           = 2;
    tagNs3.specialOpts     = NamespaceEntry::TAG_XMPBAG;
    tagNs3.subspace        = NamespaceEntry::XMP;
    tagNs3.alternativeName = QLatin1String("Xmp.lr.HierarchicalSubject");
    tagNs3.secondNameOpts  = NamespaceEntry::TAG_XMPSEQ;

    dmsettings.getWriteMapping(QString::fromUtf8(DM_TAG_CONTAINER)).clear();
    dmsettings.getWriteMapping(QString::fromUtf8(DM_TAG_CONTAINER))
             << tagNs3;

    dmeta.setItemTagsPath(tagSet1, dmsettings);

    readResult = dmeta.getXmpTagStringBag("Xmp.lr.hierarchicalSubject", false);

    expected   = tagSet1;
    expected   = expected.replaceInStrings(QLatin1String("/"), QLatin1String("|"));

    QCOMPARE(readResult, expected);
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例14: availableLanguages

QStringList availableLanguages()
{
    QDir dir;
    dir.setPath(datadir() + LANGUAGEROOT);

    // add all translations
    QStringList filters;
    filters << "*.qm";
    dir.setNameFilters(filters);
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);

    // remove extension
    QStringList list = dir.entryList();
    list.replaceInStrings(".qm", "");

    // remove system translations
    foreach (QString str, list)
    {
        if (str.startsWith("qt_"))
            list.removeOne(str);
        if (str.startsWith("plugin_"))
            list.removeOne(str);
    }

    return list;
}
开发者ID:panek50,项目名称:agros2d,代码行数:26,代码来源:util.cpp

示例15: getGSLinuxPath

QString getGSLinuxPath( QString apps  )
{
    QStringList potential_paths;
    potential_paths.append("/usr/local/bin");
    potential_paths.append("/sw/bin");   /* to use on mac as same */
    potential_paths.append("/opt/bin");
    QProcess *process = new QProcess(NULL);
    process->setReadChannelMode(QProcess::MergedChannels);
    QStringList env = process->systemEnvironment();
    env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;"+potential_paths.join(";"));
    process->setEnvironment(env);
    
        process->start( QString("which") ,  QStringList() << apps , QIODevice::ReadOnly );
          if (!process->waitForFinished()) {
          return QString();
          } else {
              QString finder = process->readAll().trimmed();
              if (finder.endsWith(apps,Qt::CaseInsensitive)) {
                 ///////////// qDebug() << "### finder " <<  finder;
                return finder;  
              } else {
                return QString(); 
              }
          }
}
开发者ID:SorinS,项目名称:fop-miniscribus,代码行数:25,代码来源:scribemime.cpp


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