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


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

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


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

示例1: addItemsRGB

void ScalarFieldsComboBox::addItemsRGB(bool add_also_composite)
{

    QStringList list;
    if (add_also_composite)
        list.reserve(4);
    else
        list.reserve(3);

    list.append("R Color");
    list.append("G Color");
    list.append("B Color");
    if (add_also_composite)
        list.append("RGB Composite");


    for (int i =0; i < list.size(); ++i)
    {
        ComboItemDescriptor desc;
        desc.name = list.at(i);
        desc.index_in_cloud = i;
        desc.index_in_combo = this->count()  + 1;
        desc.type = desc.RGB;

        QVariant data;
        data.setValue(desc);
        
        this->addItem(list.at(i), data);
    }
}
开发者ID:luca-penasa,项目名称:vombat,代码行数:30,代码来源:ScalarFieldsComboBox.cpp

示例2: makeMethod

    /**
     * @brief SignatureMaker::makeMethod
     * @param method
     * @return
     */
    QString SignatureMaker::makeMethod(const Entity::SharedMethod &method) const
    {
        if (!method)
            return "";

        QString result;

        // Add return type id
        auto returnType = typeSignatureById(method->returnTypeId());
        if (returnType.isEmpty())
            return "";
        result.append(returnType);

        // Add name
        if (method->name().isEmpty())
            return "";
        result.append(QChar::Space).append(method->name());

        // Add parameters
        auto parameters = method->parameters();
        QStringList parametersString;
        parametersString.reserve(parameters.size());
        for (auto &&p : parameters) {
            const auto &s = makeField(p);
            if (s.isEmpty())
                return "";
            parametersString << s;
        }
        result.append("(").append(parametersString.join(", ")).append(")");

        // Add const
        if (method->isConst())
            result.append(QChar::Space).append("const");

        // Add rhs, e.g. default
        if (Entity::RhsIdentificator::None != method->rhsIdentificator())
            result.append(QChar::Space).append(Util::methodRhsIdToString(method->rhsIdentificator()));

        // Add lhs, e.g. static
        auto lhsIds = method->lhsIdentificators();
        if (!lhsIds.isEmpty()) {
            QStringList lhsStrings;
            lhsStrings.reserve(lhsIds.count());
            for (auto &&id : lhsIds)
                lhsStrings << Util::methodLhsIdToString(id);
            result.prepend(QChar::Space).prepend(lhsStrings.join(QChar::Space));
        }

        return result;
    }
开发者ID:vt4a2h,项目名称:uml-tool,代码行数:55,代码来源:signaturemaker.cpp

示例3: getCanonicalPathList

/*!
   Returns the a path list where all paths from the config variable \a var
   are canonicalized. If \a validate is true, a warning for invalid paths is
   generated.

   First, this function looks up the configuration variable \a var
   in the location map and, if found, sets the internal variable
   \c{lastLocation_} the Location that \a var maps to.

   Then it looks up the configuration variable \a var in the string
   list map, which maps to one or more records that each contains a
   list of file paths.

   \sa Location::canonicalRelativePath()
 */
QStringList Config::getCanonicalPathList(const QString& var, bool validate) const
{
    QStringList t;
    QList<ConfigVar> configVars = configVars_.values(var);
    if (!configVars.empty()) {
        int i = configVars.size() - 1;
        while (i >= 0) {
            const ConfigVar& cv = configVars[i];
            if (!cv.location_.isEmpty())
                (Location&) lastLocation_ = cv.location_;
            if (!cv.plus_)
                t.clear();
            const QString d = cv.currentPath_;
            const QStringList& sl = cv.values_;
            if (!sl.isEmpty()) {
                t.reserve(t.size() + sl.size());
                for (int i=0; i<sl.size(); ++i) {
                    QDir dir(sl[i].simplified());
                    QString path = dir.path();
                    if (dir.isRelative())
                        dir.setPath(d + "/" + path);
                    if (validate && !QFileInfo::exists(dir.path()))
                        lastLocation_.warning(tr("Cannot find file or directory: %1").arg(path));
                    else
                        t.append(dir.canonicalPath());
                }
            }
            --i;
        }
    }
    return t;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:47,代码来源:config.cpp

示例4: save

void PreferencesSearchPageWidget::save()
{
	for (int i = 0; i < m_filesToRemove.count(); ++i)
	{
		QFile::remove(m_filesToRemove.at(i));
	}

	m_filesToRemove.clear();

	QStringList searchEnginesOrder;
	searchEnginesOrder.reserve(m_ui->searchViewWidget->getRowCount());

	QString defaultSearchEngine;

	for (int i = 0; i < m_ui->searchViewWidget->getRowCount(); ++i)
	{
		const QString identifier(m_ui->searchViewWidget->getIndex(i, 0).data(IdentifierRole).toString());
		const QString keyword(m_ui->searchViewWidget->getIndex(i, 1).data(Qt::DisplayRole).toString());

		if (!identifier.isEmpty())
		{
			searchEnginesOrder.append(identifier);

			if (m_ui->searchViewWidget->getIndex(i, 0).data(Qt::CheckStateRole) == Qt::Checked)
			{
				defaultSearchEngine = identifier;
			}
		}

		if (m_searchEngines.contains(identifier) && m_searchEngines[identifier].second.keyword != keyword)
		{
			m_searchEngines[identifier].first = true;
			m_searchEngines[identifier].second.keyword = keyword;
		}
	}

	QHash<QString, QPair<bool, SearchEnginesManager::SearchEngineDefinition> >::iterator searchEnginesIterator;

	for (searchEnginesIterator = m_searchEngines.begin(); searchEnginesIterator != m_searchEngines.end(); ++searchEnginesIterator)
	{
		if (searchEnginesIterator.value().first)
		{
			SearchEnginesManager::saveSearchEngine(searchEnginesIterator.value().second);
		}
	}

	if (SettingsManager::getOption(SettingsManager::Search_SearchEnginesOrderOption).toStringList() == searchEnginesOrder)
	{
		SearchEnginesManager::loadSearchEngines();
	}
	else
	{
		SettingsManager::setOption(SettingsManager::Search_SearchEnginesOrderOption, searchEnginesOrder);
	}

	SettingsManager::setOption(SettingsManager::Search_DefaultSearchEngineOption, defaultSearchEngine);
	SettingsManager::setOption(SettingsManager::Search_SearchEnginesSuggestionsOption, m_ui->searchSuggestionsCheckBox->isChecked());

	updateReaddSearchEngineMenu();
}
开发者ID:haydara,项目名称:otter,代码行数:60,代码来源:PreferencesSearchPageWidget.cpp

示例5: setRoomsList

void RoomsListModel::setRoomsList(const QStringList & rooms)
{
    beginResetModel();

    m_data.clear();

    int nRooms = rooms.size();

    for (int i = 0; i < nRooms; i += c_nColumns)
    {
        QStringList l;

#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
        l.reserve(c_nColumns);  // small optimisation not supported in old Qt
#endif

        for (int t = 0; t < c_nColumns; t++)
        {
            l.append(rooms[i + t]);
        }

        m_data.append(l);
    }

    endResetModel();
}
开发者ID:LocutusOfBorg,项目名称:hw,代码行数:26,代码来源:roomslistmodel.cpp

示例6: parseStream

bool RelationFetch::parseStream()
{
    Protocol::FetchRelationsCommand cmd(m_command);

    SelectQueryBuilder<Relation> relationQuery;
    if (cmd.side() > 0) {
        Query::Condition c;
        c.setSubQueryMode(Query::Or);
        c.addValueCondition(Relation::leftIdFullColumnName(), Query::Equals, cmd.side());
        c.addValueCondition(Relation::rightIdFullColumnName(), Query::Equals, cmd.side());
        relationQuery.addCondition(c);
    } else {
        if (cmd.left() > 0) {
            relationQuery.addValueCondition(Relation::leftIdFullColumnName(), Query::Equals, cmd.left());
        }
        if (cmd.right() > 0) {
            relationQuery.addValueCondition(Relation::rightIdFullColumnName(), Query::Equals, cmd.right());
        }
    }
    if (!cmd.types().isEmpty()) {
        relationQuery.addJoin(QueryBuilder::InnerJoin, RelationType::tableName(), Relation::typeIdFullColumnName(), RelationType::idFullColumnName());
        QStringList types;
        types.reserve(cmd.types().size());
        Q_FOREACH (const QByteArray &type, cmd.types()) {
            types << QString::fromUtf8(type);
        }
        relationQuery.addValueCondition(RelationType::nameFullColumnName(), Query::In, types);
    }
开发者ID:quazgar,项目名称:akonadi,代码行数:28,代码来源:relationfetch.cpp

示例7: toStringList

static QStringList toStringList(const QList<T> &list) {
	QStringList ret;
	ret.reserve(list.size());
	for (int i=0; i<list.size(); ++i)
		ret.push_back(list[i].toString());
	return ret;
}
开发者ID:akhilo,项目名称:cmplayer,代码行数:7,代码来源:pref.cpp

示例8: getPathList

/*!
  This function should only be called when the configuration
  variable \a var maps to string lists that contain file paths.
  It cleans the paths with QDir::cleanPath() before returning
  them.

  First, this function looks up the configuration variable \a var
  in the location map and, if found, sets the internal variable
  \c{lastLocation_} the Location that \a var maps to.

  Then it looks up the configuration variable \a var in the string
  list map, which maps to one or more records that each contains a
  list of file paths.

  These paths might not be clean, so QDir::cleanPath() is called
  for each one. The string list returned contains cleaned paths.
 */
QStringList Config::getPathList(const QString& var) const
{
    QStringList t;
    QList<ConfigVar> configVars = configVars_.values(var);
    if (!configVars.empty()) {
        int i = configVars.size() - 1;
        while (i >= 0) {
            const ConfigVar& cv = configVars[i];
            if (!cv.plus_)
                t.clear();
            if (!cv.location_.isEmpty())
                (Location&) lastLocation_ = cv.location_;
            const QString d = cv.currentPath_;
            const QStringList& sl = cv.values_;
            if (!sl.isEmpty()) {
                t.reserve(t.size() + sl.size());
                for (int i=0; i<sl.size(); ++i) {
                    QFileInfo fileInfo;
                    QString path = d + "/" + QDir::cleanPath(sl[i].simplified());
                    fileInfo.setFile(path);
                    if (!fileInfo.exists())
                        lastLocation_.warning(tr("File '%1' does not exist").arg(path));
                    else
                        t.append(path);
                }
            }
            --i;
        }
    }
    return t;
}
开发者ID:cedrus,项目名称:qt,代码行数:48,代码来源:config.cpp

示例9: getCanonicalPathList

/*!
   \brief Returns the a path list where all paths are canonicalized, then
          made relative to the config file.
   \param var The variable containing the list of paths.
   \see   Location::canonicalRelativePath()
 */
QStringList Config::getCanonicalPathList(const QString& var) const
{
    QStringList t;
    QList<ConfigVar> configVars = configVars_.values(var);
    if (!configVars.empty()) {
        int i = configVars.size() - 1;
        while (i >= 0) {
            const ConfigVar& cv = configVars[i];
            if (!cv.location_.isEmpty())
                (Location&) lastLocation_ = cv.location_;
            if (!cv.plus_) {
                t.clear();
            }
            const QString d = cv.currentPath_;
            const QStringList& sl = cv.values_;
            if (!sl.isEmpty()) {
                t.reserve(t.size() + sl.size());
                for (int i=0; i<sl.size(); ++i) {
                    QDir dir(d + "/" + sl[i]);
                    t.append(dir.canonicalPath());
                }
            }
            --i;
        }
    }
    return t;
}
开发者ID:cedrus,项目名称:qt,代码行数:33,代码来源:config.cpp

示例10: quotedValue

QString QgsExpression::quotedValue( const QVariant &value, QVariant::Type type )
{
  if ( value.isNull() )
    return QStringLiteral( "NULL" );

  switch ( type )
  {
    case QVariant::Int:
    case QVariant::LongLong:
    case QVariant::Double:
      return value.toString();

    case QVariant::Bool:
      return value.toBool() ? QStringLiteral( "TRUE" ) : QStringLiteral( "FALSE" );

    case QVariant::List:
    {
      QStringList quotedValues;
      const QVariantList values = value.toList();
      quotedValues.reserve( values.count() );
      for ( const QVariant &v : values )
      {
        quotedValues += quotedValue( v );
      }
      return QStringLiteral( "array( %1 )" ).arg( quotedValues.join( QStringLiteral( ", " ) ) );
    }

    default:
    case QVariant::String:
      return quotedString( value.toString() );
  }

}
开发者ID:telwertowski,项目名称:Quantum-GIS,代码行数:33,代码来源:qgsexpression.cpp

示例11: argumentsFromCommandLineAndFile

static QStringList argumentsFromCommandLineAndFile(const QStringList &arguments)
{
    QStringList allArguments;
    allArguments.reserve(arguments.size());
    foreach (const QString &argument, arguments) {
        // "@file" doesn't start with a '-' so we can't use QCommandLineParser for it
        if (argument.startsWith(QLatin1Char('@'))) {
            QString optionsFile = argument;
            optionsFile.remove(0, 1);
            if (optionsFile.isEmpty()) {
                error("The @ option requires an input file");
                return QStringList();
            }
            QFile f(optionsFile);
            if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
                error("Cannot open options file specified with @");
                return QStringList();
            }
            while (!f.atEnd()) {
                QString line = QString::fromLocal8Bit(f.readLine().trimmed());
                if (!line.isEmpty())
                    allArguments << line;
            }
        } else {
            allArguments << argument;
        }
    }
    return allArguments;
}
开发者ID:giucam,项目名称:qtbase,代码行数:29,代码来源:main.cpp

示例12: selectCollections

void ETMViewStateSaver::selectCollections(const Akonadi::Collection::List &list)
{
    QStringList colStrings;
    colStrings.reserve(list.count());
    Q_FOREACH (const Collection &col, list) {
        colStrings << QStringLiteral("c%1").arg(col.id());
    }
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:7,代码来源:etmviewstatesaver.cpp

示例13: import

void MainWindow::import()
{
  const QList<Importer*> &importers=get_importers();

  QStringList filters;
  filters.reserve(importers.size());
  foreach (Importer *imp, importers) filters += imp->name()+" ("+imp->filter()+")";

  QFileDialog fd(this, "Import file...");
  fd.setNameFilters(filters);
  fd.setAcceptMode(QFileDialog::AcceptOpen);
  fd.setFileMode(QFileDialog::ExistingFiles);
  if (!fd.exec()) return;

  QStringList files=fd.selectedFiles();
  if (files.isEmpty()) return;

  QString activeFilter=fd.selectedNameFilter();
  Importer *activeImporter=NULL;
  for (int i=0; i<filters.size(); ++i)
    if (filters[i]==activeFilter) { activeImporter=importers[i]; break; }

  if (!activeImporter) return;

  foreach (const QString &filename, files)
  {
    if (QFileInfo(filename).isDir()) continue;
    activeImporter->doImport(filename, &m_undoManager, m_project, m_glModelWidget->getSprite());
  }
}
开发者ID:BackupGGCode,项目名称:sproxel,代码行数:30,代码来源:MainWindow.cpp

示例14: setStoredApplications

void GSettings::setStoredApplications(const QStringList &storedApplications)
{
    QStringList gSettingsList;
    gSettingsList.reserve(storedApplications.count());
    Q_FOREACH(const QString &entry, storedApplications) {
        gSettingsList << QStringLiteral("appid://%1").arg(entry);
    }
开发者ID:dumpster-of-things,项目名称:unity8,代码行数:7,代码来源:gsettings.cpp

示例15: generatePrettyContents

QString SessionPrivate::generatePrettyContents( const SessionInfo& info )
{
    if( info.projects.isEmpty() )
        return QString();

    QStringList projectNames;
    projectNames.reserve( info.projects.size() );

    foreach( const QUrl& url, info.projects ) {
        IProject* project = nullptr;
        if( ICore::self() && ICore::self()->projectController() ) {
            project = ICore::self()->projectController()->findProjectForUrl( url );
        }

        if( project ) {
            projectNames << project->name();
        } else {
            QString projectName = url.fileName();
            projectName.remove( QRegExp( "\\.kdev4$", Qt::CaseInsensitive ) );
            projectNames << projectName;
        }
    }

    if( projectNames.isEmpty() ) {
        return i18n("(no projects)");
    } else {
        return projectNames.join( QStringLiteral(", ") );
    }
}
开发者ID:KDE,项目名称:kdevplatform,代码行数:29,代码来源:session.cpp


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