本文整理汇总了C++中qstringlist::iterator::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::remove方法的具体用法?C++ iterator::remove怎么用?C++ iterator::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstringlist::iterator
的用法示例。
在下文中一共展示了iterator::remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotPasteAsQuotation
void ComposerTextEdit::slotPasteAsQuotation()
{
QString text = qApp->clipboard()->text();
if (text.isEmpty())
return;
QStringList lines = text.split(QLatin1Char('\n'));
for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it) {
it->remove(QLatin1Char('\r'));
if (it->startsWith(QLatin1Char('>'))) {
*it = QLatin1Char('>') + *it;
} else {
*it = QLatin1String("> ") + *it;
}
}
text = lines.join(QStringLiteral("\n"));
if (!text.endsWith(QLatin1Char('\n'))) {
text += QLatin1Char('\n');
}
QTextCursor cursor = textCursor();
cursor.beginEditBlock();
cursor.insertBlock();
cursor.insertText(text);
cursor.endEditBlock();
setTextCursor(cursor);
}
示例2: getAttributeInfo
void synaxErrorJudger::getAttributeInfo(vector<string> &attributeNameList,
vector<pair<int, size_t>> &dataTypeInfo, set<string> &uniqueAttribute)
{
int begin = sqlExp.indexOf('(') + 1;
int end = sqlExp.lastIndexOf(',') - 1;
QStringList attrList = sqlExp.mid(begin, end - begin + 1).split(',');
QStringList::iterator it;
for (it = attrList.begin(); it != attrList.end(); ++it) {
if (it->trimmed() == "") {
throw QString("Synax Error: Create statement's format is incorrect.");
}
string attributeName = it->section(' ', 0, 0, QString::SectionSkipEmpty).trimmed().toStdString();
attributeNameList.push_back(attributeName);
if (it->indexOf("unique") != -1) {
uniqueAttribute.insert(attributeName);
it->remove(it->indexOf("unique"), sizeof("unique") - 1);
}
it->remove(it->indexOf(attributeName.c_str()), attributeName.size());
*it = it->trimmed();
if (*it == "int") {
dataTypeInfo.push_back(pair<int, size_t>(_INT, sizeof(int)));
}
else if (*it == "char") {
dataTypeInfo.push_back(pair<int, size_t>(_CHAR, sizeof(char)));
}
else if (*it == "float") {
dataTypeInfo.push_back(pair<int, size_t>(_FLOAT, sizeof(float)));
}
else { //一定是char(n,因为通过了前面正则表达式的匹配
it->remove("char").remove('(').remove(')'); //去除括号
int length = it->trimmed().toInt();
if (length < 1 || length > 255) {
throw QString("Synax Error: The length of string is overflow.");
}
dataTypeInfo.push_back(pair<int, size_t>(_STRING, sizeof(char) * length));
}
}
}
示例3: isAlldataTypeValid
bool synaxErrorJudger::isAlldataTypeValid(QStringList &data, vector<pair<int, size_t>> &dataTypeInfo)
{
QStringList::iterator it;
for (it = data.begin(); it != data.end(); ++it) {
*it = it->trimmed();
if (*it == "") {
return false;
}
bool ok;
if (it->indexOf('\'') != -1) { //引号'应该是字符或字符串
it->remove(0, 1).remove(QRegExp("'$"));
size_t len = it->size();
if (len < 1 || len > 255) {
return false;
}
else if (len == 1) {
dataTypeInfo.push_back(pair<int, size_t>(_CHAR, sizeof(char)));
}
else {
dataTypeInfo.push_back(pair<int, size_t>(_STRING, len * sizeof(char)));
}
}
else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
it->toFloat(&ok);
if (!ok) {
return false;
}
else {
dataTypeInfo.push_back(pair<int, size_t>(_FLOAT, sizeof(float)));
}
}
else { //剩下的应该是int类型
it->toInt(&ok);
if (!ok) {
return false;
}
else {
dataTypeInfo.push_back(pair<int, size_t>(_INT, sizeof(int)));
}
}
}
return true;
}
示例4: parseOption
EngineOption* XboardEngine::parseOption(const QString& line)
{
int start = line.indexOf('-');
if (start < 2)
return 0;
QString name(line.left(start - 1));
start++;
int end = line.indexOf(' ', start);
if (end == -1)
end = line.length();
QString type(line.mid(start, end - start));
if (type == "button" || type == "save")
return new EngineButtonOption(name);
if (type == "check")
{
bool value = line.mid(end + 1) == "1";
return new EngineCheckOption(name, value, value);
}
if (type == "string" || type == "file" || type == "path")
{
QString value(line.mid(end + 1));
EngineTextOption::EditorType editorType;
if (type == "file")
editorType = EngineTextOption::FileDialog;
else if (type == "path")
editorType = EngineTextOption::FolderDialog;
else
editorType = EngineTextOption::LineEdit;
return new EngineTextOption(name, value, value, QString(), editorType);
}
if (type == "spin" || type == "slider")
{
QStringList params(line.mid(end + 1).split(' ', QString::SkipEmptyParts));
if (params.size() != 3)
return 0;
bool ok = false;
int value = params.at(0).toInt(&ok);
if (!ok)
return 0;
int min = params.at(1).toInt(&ok);
if (!ok || min > value)
return 0;
int max = params.at(2).toInt(&ok);
if (!ok || max < value)
return 0;
return new EngineSpinOption(name, value, value, min, max);
}
if (type == "combo")
{
QStringList choices = line.mid(end + 1).split(" /// ", QString::SkipEmptyParts);
if (choices.isEmpty())
return 0;
QString value;
QStringList::iterator it;
for (it = choices.begin(); it != choices.end(); ++it)
{
if (it->startsWith('*'))
{
it->remove(0, 1);
value = *it;
}
}
if (value.isEmpty())
value = choices.first();
return new EngineComboOption(name, value, value, choices);
}
return 0;
}
示例5: if
//.........这里部分代码省略.........
else
db.fvorites_only = false ;
if ( db.p_chiave )
{
QString testo = ui->ParoleChiave->text() ;
testo = testo.replace( "*" , "%" ) ;
QStringList parole_c = testo.split( " " , QString::SkipEmptyParts ) ;
db.setParoleChiave( parole_c );
QString testo_b = ui->ParoleChiaveAbstract->text() ;
testo_b = testo_b.replace( "*" , "%" ) ;
QStringList parole_c_a = testo_b.split(" " , QString::SkipEmptyParts ) ;
db.setParoleChiaveAbstract( parole_c_a );;
// Nuovo in sviluppo
query_data.setParoleChiaveTitolo( ui->ParoleChiave->text() );
query_data.setParoleChiaveAbstract( ui->ParoleChiaveAbstract->text() );
}
if ( db.rubriche )
{
QStringList lista_rubriche ;
lista_rubriche = ReadSelectedItems( ui->ListaRubriche ) ;
db.setListaRubriche( lista_rubriche );
query_data.setRubriche( lista_rubriche );
}
if ( db.categorie )
{
QStringList lista_categorie ;
lista_categorie = ReadSelectedItems( ui->ListaCategorie ) ;
db.setListaCategorie( lista_categorie ) ;
query_data.setCategorie( lista_categorie );
}
if( db.autori_l )
{
QStringList lista_autori ;
lista_autori = ReadSelectedItems( ui->ListaAutori ) ;
db.setListaAutori( lista_autori ); ;
}
if( db.anno )
{
QStringList lista_anni ;
lista_anni = ReadSelectedItems( ui->ListaAnni ) ;
db.setListaAnni( lista_anni );
}
if ( db.testo )
{
QStringList lista_frasi ;
QString frasi = ui->ParoleChiaveTesto->text() ;
//qDebug() << "frase: " << frasi ;
QString word_char = "\\w\\.:;,\\+-/\\*'`" ;
//QString word_char = "\\w" ;
QString S_regx = QString( "(\"[%1\\s]+\"|\\s[%1]+\\s|[%1]+\\s|^[%1]+\\s|\\s[%1]+$|[%1]+$|^[%1]+$)" ).arg(word_char) ;
//QString S_regx = QString( "(\\s[%1]+\\s)" ).arg(word_char) ;
QRegExp regx( S_regx ) ;
if ( !regx.isValid() )
{
qDebug() << "Regex Error: " << regx.errorString() ;
}
qDebug() << S_regx ;
int pos = 0;
while ( pos >= 0 )
{
pos = regx.indexIn( frasi, pos ) ;
if ( pos > -1 )
{
lista_frasi += regx.cap(1) ;
pos += regx.matchedLength() ;
}
}
for (QStringList::iterator it = lista_frasi.begin(); it < lista_frasi.end(); it++ )
{
it->remove( QRegExp("(\"|^\\s|\\s$)") ) ;
qDebug() << "parola: " << *it ;
}
db.setFrasiTestoEsteso( lista_frasi ) ;
}
QueryResult q_result ;
db.execMainQuery( q_result ) ;
fillResultTable( q_result ) ;
return true ;
}
示例6: generateCondition
void synaxErrorJudger::generateCondition()
{
int begin = sqlExp.indexOf("where") + 5;
int end = sqlExp.indexOf(QRegExp(";$")) - 1;
QStringList conditions = sqlExp.mid(begin, end - begin + 1).split("and");
QStringList::iterator it;
pair<int, size_t> dataType;
int logicType;
string rightSide, leftSide;
for (it = conditions.begin(); it != conditions.end(); ++it) {
*it = it->trimmed();
if (*it == "") {
throw QString("Synax Error: Conditions' format is incorrect.");
}
int begin = 0;
int end = it->indexOf(QRegExp("[=><]"))-1;
rightSide = it->mid(begin, end - begin + 1).trimmed().toStdString();
begin = end + 1;
end = it->indexOf(QRegExp("[=><]"), begin + 1);
if (end - begin > 1 || end == -1) { //如果下一个"=",">","<"号出现在较远处
end = begin; //说明这个逻辑关系是"=",">","<"而非">=", "<=", "<>"
}
logicType = condition::getLogicTypeFromStr(it->mid(begin, end - begin + 1).toStdString());
if (logicType == _ERROR) {
throw QString("Synax Error: The logic arithemtic is invalid.");
}
bool ok;
*it = it->mid(end + 1).trimmed();
if (it->indexOf(QRegExp("^'")) != -1) { //引号'应该是字符或字符串
it->remove(0, 1).remove(QRegExp("'$"));
size_t len = it->size();
pair<int, size_t> dType;
Api::cManager.getAttributeDataType(*tblName, rightSide, dType);
if (len < 1 || len > 255 || len > dType.second) {
throw QString("Synax Error: The length of string is overflow.");
}
else if (len == 1) {
dataType = pair<int, size_t>(_CHAR, sizeof(char));
}
else {
dataType = pair<int, size_t>(_STRING, dType.second * sizeof(char));
}
}
else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
it->toFloat(&ok);
if (!ok) {
;
}
else {
dataType = pair<int, size_t>(_FLOAT, sizeof(float));
}
}
else { //剩下的应该是int类型
it->toInt(&ok);
if (!ok) {
;
}
else {
dataType = pair<int, size_t>(_INT, sizeof(int));
}
}
leftSide = it->toStdString();
if (cond == 0) {
cond = new vector<condition>;
}
cond->push_back(condition(rightSide, logicType, dataType, leftSide));
}
}
示例7: save
//.........这里部分代码省略.........
else
pos++;
}
text.replace('"',"\\\"");
#if 0
if ( m_wrapWidth == -1 )
{
// Traditional KBabel wrapping
QStringList list = text.split( '\n', QString::SkipEmptyParts );
if ( text.startsWith( '\n' ) )
list.prepend( QString() );
if(list.isEmpty())
list.append( QString() );
if( list.count() > 1 )
list.prepend( QString() );
stream << keyword << ' ';
QStringList::const_iterator it;
for( it = list.constBegin(); it != list.constEnd(); ++it )
stream << '\"' << (*it) << "\"\n";
return;
}
#endif
if ( m_wrapWidth == 0 ) // Unknown special wrapping, so assume "no wrap" instead
{
// No wrapping (like Gettext's --no.wrap or -w0 )
// we need to remove the \n characters, as they are extra characters
QString realText( text );
realText.remove( '\n' );
stream << keyword << " \"" << realText << "\"\n";
return;
}
else if ( m_wrapWidth < 0 )
{
// No change in wrapping
QStringList list = text.split( '\n');
if (list.count()>1 || startedWithEmptyLine /* || keyword.length()+3+text.length()>=80*/)
list.prepend(QString());
stream << keyword << " ";
QStringList::const_iterator it;
for( it = list.constBegin(); it != list.constEnd(); ++it )
stream << "\"" << (*it) << "\"\n";
return;
}
// lazy wrapping
QStringList list = text.split( '\n', QString::SkipEmptyParts );
if ( text.startsWith( '\n' ) )
list.prepend( QString() );
if(list.isEmpty())
list.append( QString() );
static QRegExp breakStopReForHtml("[ >.%]", Qt::CaseSensitive, QRegExp::Wildcard);
QRegExp breakStopRe=containsHtml?breakStopReForHtml:QRegExp("[ .%]", Qt::CaseSensitive, QRegExp::Wildcard);
int max=m_wrapWidth-2;
bool prependedEmptyLine=false;
示例8: d
void
ExportGroupTemplateDialog::onOkClicked()
{
QString dirPath = _imp->fileEdit->text();
if ( !dirPath.isEmpty() && ( dirPath[dirPath.size() - 1] == QLatin1Char('/') ) ) {
dirPath.remove(dirPath.size() - 1, 1);
}
QDir d(dirPath);
if ( !d.exists() ) {
Dialogs::errorDialog( tr("Error").toStdString(), tr("You must specify a directory to save the script").toStdString() );
return;
}
QString pluginLabel = _imp->labelEdit->text();
if ( pluginLabel.isEmpty() ) {
Dialogs::errorDialog( tr("Error").toStdString(), tr("You must specify a label to name the script").toStdString() );
return;
} else {
pluginLabel = QString::fromUtf8( NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly( pluginLabel.toStdString() ).c_str() );
}
QString pluginID = _imp->idEdit->text();
if ( pluginID.isEmpty() ) {
Dialogs::errorDialog( tr("Error").toStdString(), tr("You must specify a unique ID to identify the script").toStdString() );
return;
}
QString iconPath = _imp->iconPath->text();
QString grouping = _imp->groupingEdit->text();
QString description = _imp->descriptionEdit->getText();
QString filePath = d.absolutePath() + QLatin1Char('/') + pluginLabel + QString::fromUtf8(".py");
QStringList filters;
filters.push_back( QString( pluginLabel + QString::fromUtf8(".py") ) );
if ( !d.entryList(filters, QDir::Files | QDir::NoDotAndDotDot).isEmpty() ) {
StandardButtonEnum rep = Dialogs::questionDialog(tr("Existing plug-in").toStdString(),
tr("A group plug-in with the same name already exists "
"would you like to "
"override it?").toStdString(), false);
if (rep == eStandardButtonNo) {
return;
}
}
bool foundInPath = false;
QStringList groupSearchPath = appPTR->getAllNonOFXPluginsPaths();
for (QStringList::iterator it = groupSearchPath.begin(); it != groupSearchPath.end(); ++it) {
if ( !it->isEmpty() && ( it->at(it->size() - 1) == QLatin1Char('/') ) ) {
it->remove(it->size() - 1, 1);
}
if (*it == dirPath) {
foundInPath = true;
}
}
if (!foundInPath) {
QString message = dirPath + tr(" does not exist in the group plug-in search path, would you like to add it?");
StandardButtonEnum rep = Dialogs::questionDialog(tr("Plug-in path").toStdString(),
message.toStdString(), false);
if (rep == eStandardButtonYes) {
appPTR->getCurrentSettings()->appendPythonGroupsPath( dirPath.toStdString() );
}
}
QFile file(filePath);
if ( !file.open(QIODevice::ReadWrite | QIODevice::Truncate) ) {
Dialogs::errorDialog( tr("Error").toStdString(), QString(tr("Cannot open ") + filePath).toStdString() );
return;
}
QTextStream ts(&file);
QString content;
_imp->group->exportGroupToPython(pluginID, pluginLabel, description, iconPath, grouping, content);
ts << content;
accept();
} // ExportGroupTemplateDialog::onOkClicked