本文整理汇总了C++中QStringList::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringList::erase方法的具体用法?C++ QStringList::erase怎么用?C++ QStringList::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringList
的用法示例。
在下文中一共展示了QStringList::erase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save
void KateFindInFilesOptions::save(KConfigGroup& config)
{
if (this != &self()) {
self().save(config);
return;
}
// first remove duplicates, as setDuplicatesEnabled does not work for QComboBox with Model
// further, limit count of entries to 15. then save
QStringList stringList = m_searchItems.stringList();
stringList.removeDuplicates();
if (stringList.count() > 15)
stringList.erase(stringList.begin() + 15, stringList.end());
config.writeEntry("LastSearchItems", stringList);
stringList = m_searchPaths.stringList();
stringList.removeDuplicates();
if (stringList.count() > 15)
stringList.erase(stringList.begin() + 15, stringList.end());
config.writeEntry("LastSearchPaths", stringList);
stringList = m_searchFilters.stringList();
stringList.removeDuplicates();
if (stringList.count() > 15)
stringList.erase(stringList.begin() + 15, stringList.end());
config.writeEntry("LastSearchFiles", stringList);
config.writeEntry("Recursive", m_recursive);
config.writeEntry("CaseSensitive", m_casesensitive);
config.writeEntry("RegExp", m_regexp);
config.writeEntry("FollowDirectorySymlinks", m_followDirectorySymlinks);
config.writeEntry("IncludeHiddenFiles", m_includeHiddenFiles);
}
示例2: combinePath
QByteArray combinePath(const char *infile, const char *outfile)
{
QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile));
QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile));
int numCommonComponents = 0;
QStringList inSplitted = inFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
QStringList outSplitted = outFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
while (!inSplitted.isEmpty() && !outSplitted.isEmpty() &&
inSplitted.first() == outSplitted.first()) {
inSplitted.erase(inSplitted.begin());
outSplitted.erase(outSplitted.begin());
numCommonComponents++;
}
if (numCommonComponents < 2) {
/*
The paths don't have the same drive, or they don't have the
same root directory. Use an absolute path.
*/
return QFile::encodeName(inFileInfo.absoluteFilePath());
} else {
/*
The paths have something in common. Use a path relative to
the output file.
*/
while (!outSplitted.isEmpty()) {
outSplitted.erase(outSplitted.begin());
inSplitted.prepend(QLatin1String(".."));
}
inSplitted.append(inFileInfo.fileName());
return QFile::encodeName(inSplitted.join(QLatin1String("/")));
}
}
示例3: expandAliases
QString PrePost::expandAliases(const QString& from, const QString& msg) {
int pos = msg.indexOf(' ');
QString word = (pos != -1)?msg.left(pos):msg;
QStringList args;
if(pos != -1)
args = msg.right(msg.length() - pos - 1).split(' ',QString::SkipEmptyParts);
QStringList largs;
for(AliasMap::Iterator it = alias[from].begin(); it != alias[from].end(); ++it) {
if(it.key() == word) {
QString tmp = *it;
QString res;
int i = 0;
while((i = tmp.indexOf('$')) != -1) {
res += tmp.left(i);
tmp.remove(0,i);
if(tmp.startsWith("$$")) {
res += "$";
tmp.remove(0,2);
} else if (tmp.startsWith("$*")) {
res += args.join(" ");
tmp.remove(0,2);
} else if (tmp.startsWith("$n")) {
res += "\n";
tmp.remove(0,2);
} else if (tmp.startsWith("$+")) {
if(args.begin() != args.end()) {
largs << *(args.begin());
args.erase(args.begin());
}
tmp.remove(0,2);
} else if (tmp.startsWith("$-")) {
if(largs.begin() != largs.end()) {
QStringList::Iterator p = --largs.end();
args.prepend(*p);
largs.erase(p);
}
tmp.remove(0,2);
} else {
QRegExp re("^\\$(\\d).*");
if(re.exactMatch(tmp)) {
int number = re.cap(1).toInt();
res += args[number-1];
tmp.remove(0,2);
} else {
QString error("Wrong argument : \"" + tmp.left(2) + "\"");
manager()->connectionPlugin()->serverSend(from,error);
return "";
}
}
}
res += tmp;
return res;
}
}
return msg;
}
示例4: setConnected
void Connector::setConnected(bool state)
{
QStringList args;
QString cmd;
if(conn_connected!=state) {
if(!conn_is_stopping) {
if(state) {
if(conn_script_up_process==NULL) {
if(!conn_script_up.isEmpty()) {
args=conn_script_up.split(" ");
cmd=args[0];
args.erase(args.begin());
conn_script_up_process=new QProcess(this);
connect(conn_script_up_process,
SIGNAL(error(QProcess::ProcessError)),
this,SLOT(scriptErrorData(QProcess::ProcessError)));
connect(conn_script_up_process,
SIGNAL(finished(int,QProcess::ExitStatus)),
this,SLOT(scriptUpFinishedData(int,QProcess::ExitStatus)));
conn_script_up_process->start(cmd,args);
}
}
else {
if(global_log_verbose) {
Log(LOG_WARNING,"curl(1) script-up command overrun, cmd: \""+
args.join(" ")+"\"");
}
else {
Log(LOG_WARNING,"curl(1) command overrun");
}
}
}
else {
if(conn_script_down_process==NULL) {
示例5: clearmsgCmd
void Msg::clearmsgCmd(const QString& from, const QStringList& list) {
if(list[0] == "") { // no arg
QFile f(manager()->dataDir() + "/msg/" + from);
f.remove();
QString txt("You clear your messages");
manager()->connectionPlugin()->serverSend(from,txt);
}
else {
if (list[0].toInt() < 1) {
manager()->connectionPlugin()->serverSend(from, "Parameter(s) must be greater than 0!");
return;
}
int start = list[0].toInt() - 1;
int stop = (list[1] == "")?(start+1):(list[1].toInt());
QFile f(manager()->dataDir() + "/msg/" + from);
if (!f.open(QIODevice::ReadOnly)) {
octInfo("Could not read message file\n");
return;
}
QTextStream stream(&f);
QString line;
QStringList l;
while((line = stream.readLine()) != QString::null) l << line;
f.close();
if (start >= l.count()) {
manager()->connectionPlugin()->serverSend(from, "Too large(s) parameter(s)!");
return;
}
if (stop > l.count())
stop = l.count();
l.erase(l.begin() + start, l.begin() + stop);
if (l.count()) {
if (!f.open(QIODevice::WriteOnly)) {
octInfo("Could not write message file.\n");
return;
}
QTextStream stream2(&f);
for(QStringList::Iterator it = l.begin(); it != l.end(); ++it)
stream2 << (*it + "\n");
f.close();
} else
f.remove();
QString txt("You clear message");
if (start + 1 == stop)
txt += " " + QString::number(stop);
else
txt += "s " + QString::number(start+1) + " to " + QString::number(stop);
manager()->connectionPlugin()->serverSend(from,txt);
}
}
示例6: resolveLocationIssues
void QrcEditor::resolveLocationIssues(QStringList &files)
{
const QDir dir = QFileInfo(m_treeview->fileName()).absoluteDir();
const QString dotdotSlash = QLatin1String("../");
int i = 0;
const int count = files.count();
const int initialCount = files.count();
// Find first troublesome file
for (; i < count; i++) {
QString const &file = files.at(i);
const QString relativePath = dir.relativeFilePath(file);
if (relativePath.startsWith(dotdotSlash))
break;
}
// All paths fine -> no interaction needed
if (i == count) {
return;
}
// Interact with user from now on
ResolveLocationContext context;
bool abort = false;
for (QStringList::iterator it = files.begin(); it != files.end(); ) {
// Path fine -> skip file
QString const &file = *it;
QString const relativePath = dir.relativeFilePath(file);
if (!relativePath.startsWith(dotdotSlash)) {
continue;
}
// Path troublesome and aborted -> remove file
bool ok = false;
if (!abort) {
// Path troublesome -> query user "Do you want copy/abort/skip".
QAbstractButton *clickedButton = context.execLocationMessageBox(this, file, initialCount > 1);
if (clickedButton == context.copyButton) {
const QFileInfo fi(file);
QFileInfo suggestion;
QDir tmpTarget(dir.path() + QString(QDir::separator()) + QString("Resources"));;
if (tmpTarget.exists())
suggestion.setFile(tmpTarget, fi.fileName());
else
suggestion.setFile(dir, fi.fileName());
// Prompt for copy location, copy and replace name.
const QString copyName = context.execCopyFileDialog(this, dir, suggestion.absoluteFilePath());
ok = !copyName.isEmpty() && copyFile(file, copyName, this);
if (ok)
*it = copyName;
} else if (clickedButton == context.abortButton) {
abort = true;
}
} // !abort
if (ok) { // Remove files where user canceled or failures occurred.
++it;
} else {
it = files.erase(it);
}
} // for files
}
示例7: saveUserAddedThemes
void ThemesDlg::saveUserAddedThemes()
{
KStandardDirs ksd;
QStringList t = themes();
QStringList dirs = ksd.findDirs("data", QString(kapp->objectName()) + "/themes");
QStringList::Iterator it = t.begin();
bool remove;
while (it != t.end()) {
remove = false;
QStringList::Iterator jtend(dirs.end());
for (QStringList::Iterator jt = dirs.begin(); jt != jtend; ++jt) {
if (QString(QFileInfo(*it).dir().path() + '/') == *jt) {
remove = true;
break;
}
}
if (remove)
it = t.erase(it);
else
++it;
}
SuperKarambaSettings::setUserAddedThemes(t);
SuperKarambaSettings::self()->writeConfig();
}
示例8: process
// Main Command processing function
void cCommands::process( cUOSocket *socket, const QString &command )
{
if( !socket->player() )
return;
P_PLAYER pChar = socket->player();
QStringList pArgs = QStringList::split( " ", command, true );
// No Command? No Processing
if( pArgs.isEmpty() )
return;
QString pCommand = pArgs[0].upper(); // First element should be the command
// Remove it from the argument list
pArgs.erase( pArgs.begin() );
// Check if the priviledges are ok
if( !pChar->account()->authorized("command", pCommand.latin1() ))
{
socket->sysMessage( tr( "Access to command '%1' was denied" ).arg( pCommand.lower() ) );
socket->log( QString("Access to command '%1' was denied\n").arg(pCommand.lower()) );
return;
}
// Dispatch the command
if ( dispatch( socket, pCommand, pArgs ) )
socket->log( QString( "Used command '%1'.\n" ).arg( command ) );
}
示例9: children
QStringList QMacSettingsPrivate::children(const QString &prefix, ChildSpec spec) const
{
QStringList result;
int startPos = prefix.size();
for (int i = 0; i < numDomains; ++i) {
for (int j = 0; j < numHostNames; ++j) {
QCFType<CFArrayRef> cfarray = CFPreferencesCopyKeyList(domains[i].applicationOrSuiteId,
domains[i].userName,
hostNames[j]);
if (cfarray) {
CFIndex size = CFArrayGetCount(cfarray);
for (CFIndex k = 0; k < size; ++k) {
QString currentKey =
qtKey(static_cast<CFStringRef>(CFArrayGetValueAtIndex(cfarray, k)));
if (currentKey.startsWith(prefix))
processChild(currentKey.midRef(startPos), spec, result);
}
}
}
if (!fallbacks)
break;
}
std::sort(result.begin(), result.end());
result.erase(std::unique(result.begin(), result.end()),
result.end());
return result;
}
示例10: classes
/*!
Returns the list of classes of this element.
*/
QStringList QWebElement::classes() const
{
if (!hasAttribute(QLatin1String("class")))
return QStringList();
QStringList classes = attribute(QLatin1String("class")).simplified().split(QLatin1Char(' '), QString::SkipEmptyParts);
#if QT_VERSION >= 0x040500
classes.removeDuplicates();
#else
int n = classes.size();
int j = 0;
QSet<QString> seen;
seen.reserve(n);
for (int i = 0; i < n; ++i) {
const QString& s = classes.at(i);
if (seen.contains(s))
continue;
seen.insert(s);
if (j != i)
classes[j] = s;
++j;
}
if (n != j)
classes.erase(classes.begin() + j, classes.end());
#endif
return classes;
}
示例11: prepareBranchesForCommit
QString DiffEditorController::prepareBranchesForCommit(const QString &output)
{
// TODO: More git-specific code...
QString moreBranches;
QString branches;
QStringList res;
foreach (const QString &branch, output.split(QLatin1Char('\n'))) {
const QString b = branch.mid(2).trimmed();
if (!b.isEmpty())
res << b;
}
const int branchCount = res.count();
// If there are more than 20 branches, list first 10 followed by a hint
if (branchCount > 20) {
const int leave = 10;
//: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'"
// in git show.
moreBranches = QLatin1Char(' ') + tr("and %n more", 0, branchCount - leave);
res.erase(res.begin() + leave, res.end());
}
branches = QLatin1String("Branches: ");
if (res.isEmpty())
branches += tr("<None>");
else
branches += res.join(QLatin1String(", ")) + moreBranches;
return branches;
}
示例12: updateArguments
void NimCompilerBuildStep::updateArguments()
{
auto bc = qobject_cast<NimBuildConfiguration *>(buildConfiguration());
QTC_ASSERT(bc, return);
QStringList arguments;
arguments << QStringLiteral("c");
switch (m_defaultOptions) {
case Release:
arguments << QStringLiteral("-d:release");
break;
case Debug:
arguments << QStringLiteral("--debugInfo")
<< QStringLiteral("--lineDir:on");
break;
default:
break;
}
arguments << QStringLiteral("--out:%1").arg(m_outFilePath.toString());
arguments << QStringLiteral("--nimCache:%1").arg(bc->cacheDirectory().toString());
arguments << m_userCompilerOptions;
arguments << m_targetNimFile.toString();
// Remove empty args
auto predicate = [](const QString &str) { return str.isEmpty(); };
auto it = std::remove_if(arguments.begin(), arguments.end(), predicate);
arguments.erase(it, arguments.end());
processParameters()->setArguments(arguments.join(QChar::Space));
}
示例13: KApplication
QtUiApplication::QtUiApplication(int &argc, char **argv)
#ifdef HAVE_KDE4
: KApplication(), // KApplication is deprecated in KF5
#else
: QApplication(argc, argv),
#endif
Quassel(),
_aboutToQuit(false)
{
#ifdef HAVE_KDE4
Q_UNUSED(argc); Q_UNUSED(argv);
// Setup KDE's data dirs
// Because we can't use KDE stuff in (the class) Quassel directly, we need to do this here...
QStringList dataDirs = KGlobal::dirs()->findDirs("data", "");
// Just in case, also check our install prefix
dataDirs << QCoreApplication::applicationDirPath() + "/../share/apps/";
// Normalize and append our application name
for (int i = 0; i < dataDirs.count(); i++)
dataDirs[i] = QDir::cleanPath(dataDirs.at(i)) + "/quassel/";
// Add resource path and just in case.
// Workdir should have precedence
dataDirs.prepend(QCoreApplication::applicationDirPath() + "/data/");
dataDirs.append(":/data/");
// Append trailing '/' and check for existence
auto iter = dataDirs.begin();
while (iter != dataDirs.end()) {
if (!iter->endsWith(QDir::separator()) && !iter->endsWith('/'))
iter->append(QDir::separator());
if (!QFile::exists(*iter))
iter = dataDirs.erase(iter);
else
++iter;
}
dataDirs.removeDuplicates();
setDataDirPaths(dataDirs);
#else /* HAVE_KDE4 */
setDataDirPaths(findDataDirPaths());
#endif /* HAVE_KDE4 */
#if defined(HAVE_KDE4) || defined(Q_OS_MAC)
disableCrashhandler();
#endif /* HAVE_KDE4 || Q_OS_MAC */
setRunMode(Quassel::ClientOnly);
#if QT_VERSION < 0x050000
qInstallMsgHandler(Client::logMessage);
#else
qInstallMessageHandler(Client::logMessage);
#endif
}
示例14: QRegExp
bool
DropJob::validateLocalFiles(const QString &paths, const QString &suffix)
{
QStringList filePaths = paths.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
for ( QStringList::iterator it = filePaths.begin(); it != filePaths.end(); ++it )
if ( !validateLocalFile( *it, suffix ) )
filePaths.erase( it );
return !filePaths.isEmpty();
}
示例15: QApplication
: QApplication(argc, argv)
#endif
{
#ifdef HAVE_KDE4
Q_UNUSED(argc); Q_UNUSED(argv);
// Setup KDE's data dirs
// Because we can't use KDE stuff in (the class) Quassel directly, we need to do this here...
QStringList dataDirs = KGlobal::dirs()->findDirs("data", "");
// Just in case, also check our install prefix
dataDirs << QCoreApplication::applicationDirPath() + "/../share/apps/";
// Normalize and append our application name
for (int i = 0; i < dataDirs.count(); i++)
dataDirs[i] = QDir::cleanPath(dataDirs.at(i)) + "/quassel/";
// Add resource path and just in case.
// Workdir should have precedence
dataDirs.prepend(QCoreApplication::applicationDirPath() + "/data/");
dataDirs.append(":/data/");
// Append trailing '/' and check for existence
auto iter = dataDirs.begin();
while (iter != dataDirs.end()) {
if (!iter->endsWith(QDir::separator()) && !iter->endsWith('/'))
iter->append(QDir::separator());
if (!QFile::exists(*iter))
iter = dataDirs.erase(iter);
else
++iter;
}
dataDirs.removeDuplicates();
Quassel::setDataDirPaths(dataDirs);
#else /* HAVE_KDE4 */
Quassel::setDataDirPaths(Quassel::findDataDirPaths());
#endif /* HAVE_KDE4 */
#if defined(HAVE_KDE4) || defined(Q_OS_MAC)
Quassel::disableCrashHandler();
#endif /* HAVE_KDE4 || Q_OS_MAC */
Quassel::setRunMode(Quassel::ClientOnly);
#if QT_VERSION >= 0x050000
connect(this, &QGuiApplication::commitDataRequest, this, &QtUiApplication::commitData, Qt::DirectConnection);
connect(this, &QGuiApplication::saveStateRequest, this, &QtUiApplication::saveState, Qt::DirectConnection);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QGuiApplication::setFallbackSessionManagementEnabled(false);
#endif
}