예제 #1
0
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);
    }
}
예제 #2
0
    /**
     * @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;
    }
예제 #3
0
/*!
   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;
}
예제 #4
0
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();
}
예제 #5
0
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();
}
예제 #6
0
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);
    }
예제 #7
0
파일: pref.cpp 프로젝트: akhilo/cmplayer
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;
}
예제 #8
0
파일: config.cpp 프로젝트: cedrus/qt
/*!
  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;
}
예제 #9
0
파일: config.cpp 프로젝트: cedrus/qt
/*!
   \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;
}
예제 #10
0
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() );
  }

}
예제 #11
0
파일: main.cpp 프로젝트: giucam/qtbase
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;
}
예제 #12
0
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());
    }
예제 #13
0
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());
  }
}
예제 #14
0
void GSettings::setStoredApplications(const QStringList &storedApplications)
{
    QStringList gSettingsList;
    gSettingsList.reserve(storedApplications.count());
    Q_FOREACH(const QString &entry, storedApplications) {
        gSettingsList << QStringLiteral("appid://%1").arg(entry);
    }
예제 #15
0
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(", ") );
    }
}
예제 #16
0
bool HistoryFeedHook::hook(const FeedNotify &notify, QVariantMap &out)
{
  if (notify.name() != MESSAGES_FEED_LAST_REQ && notify.name() != MESSAGES_FEED_SINCE_REQ)
    return false;

  QVariantMap data = out.value(FeedNotify::kData).toMap();
  if (data.isEmpty())
    return false;

  const QStringList messages = data.value(MESSAGES_FEED_MESSAGES_KEY).toStringList();
  if (messages.isEmpty())
    return false;

  QStringList list;
# if QT_VERSION >= 0x040700
  list.reserve(messages.size());
# endif

  ChatId id;

  foreach (const QString &message, messages) {
    id.init(message.toLatin1());
    if (id.hasOid())
      list.append(ChatId::toBase32(id.oid().byteArray()));
    else
      list.append(message);
  }
예제 #17
0
bool QCSVWriter::write()
{
    QStringList row;

    row.reserve(size());
    for (QVector<QCSVCell>::iterator icells(begin());
         icells != end(); ++icells) {
        const QString &val(*icells);

        if (val.contains(_cellSeparator_) ||
                val.contains("\"") ||
                val.contains("\n") ||
                val.contains("\r")) {
            QString s(val);
            s.replace("\"", "\"\"");
            row.append(QString("\"%1\"").arg(s));
        }
        else
            row.append(val);
        (*icells).clear();
    }

    QString rowS(row.join(_cellSeparator_));
    if (hasRows) {
        rowS = QString("\r\n") + rowS;
    } else
        hasRows = true;

    const QByteArray array(rowS.toUtf8());
    qint64 wsize(file.write(array));

    return (wsize == array.size());
}
예제 #18
0
    bool getXmpTagStringBag(Exiv2::XmpData &xmpData, const char *propertyName, QStringList &bag) {
        bool found = false;

        Exiv2::XmpKey key(propertyName);
        Exiv2::XmpData::iterator it = xmpData.findKey(key);

        if ((it != xmpData.end()) && (it->typeId() == Exiv2::xmpBag)) {
            found = true;
            int count = it->count();
            bag.reserve(count);

            if (count == 1) {
                QString bagValue = QString::fromUtf8(it->toString(0).c_str());
                if (bagValue.contains(',')) {
                    LOG_DEBUG << "processing legacy saved keywords";
                    bag += decomposeKeyword(bagValue);
                } else {
                    bag.append(bagValue);
                }
            } else {
                for (int i = 0; i < count; i++) {
                    QString bagValue = QString::fromUtf8(it->toString(i).c_str());
                    bag.append(bagValue);
                }
            }
        }

        return found;
    }
예제 #19
0
파일: QmlAVPlayer.cpp 프로젝트: Czhian/QtAV
static QStringList idsToNames(QVector<ID> ids) {
    QStringList decs;
    if (!ids.isEmpty()) {
        decs.reserve(ids.size());
        foreach (ID id, ids) {
            decs.append(QString::fromLatin1(T::name(id)));
        }
예제 #20
0
void MainWindow::exportGrid()
{
  const QList<Exporter*> &exporters=get_exporters();

  QStringList filters;
  filters.reserve(exporters.size());
  foreach (Exporter *exp, exporters) filters += exp->name()+" ("+exp->filter()+")";

  QFileDialog fd(this, "Export file...");
  fd.setNameFilters(filters);
  fd.setAcceptMode(QFileDialog::AcceptSave);
  fd.selectNameFilter(m_appSettings.value("lastExportFilter", QString()).toString());
  fd.selectFile(m_appSettings.value("lastExportFile", QString()).toString());
  if (!fd.exec()) return;

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

  QString filename=files[0];
  if (QFileInfo(filename).isDir()) return;

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

  if (!activeExporter) return;

  if (!activeExporter->doExport(filename, m_project, m_glModelWidget->getSprite()))
    QMessageBox::critical(this, "Sproxel Error", QString("Failed to export ")+filename);

  m_appSettings.setValue("lastExportFile", filename);
  m_appSettings.setValue("lastExportFilter", activeFilter);
}
예제 #21
0
void initColors(QStringList &list)
{
	const char *colors[] = {
	    "aqua", "aquamarine", "blue", "blueviolet", "brown", "burlywood",
	    "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
	    "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
	    "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen",
	    "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
	    "darkslateblue", "darkslategrey", "darkturquoise", "darkviolet",
	    "deeppink", "deepskyblue", "dimgrey", "dodgerblue", "firebrick",
	    "forestgreen", "fuchsia", "gold", "goldenrod", "green", "greenyellow",
	    "grey", "hotpink", "indianred", "indigo", "lawngreen", "lightblue",
	    "lightcoral", "lightgreen", "lightgrey", "lightpink", "lightsalmon",
	    "lightseagreen", "lightskyblue", "lightslategrey", "lightsteelblue",
	    "lime", "limegreen", "magenta", "maroon", "mediumaquamarine", "mediumblue",
	    "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue",
	    "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue",
	    "navy", "olive", "olivedrab", "orange", "orangered", "orchid", "palegreen",
	    "paleturquoise", "palevioletred", "peru", "pink", "plum", "powderblue",
	    "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon",
	    "sandybrown", "seagreen", "sienna", "silver", "skyblue", "slateblue",
	    "slategrey", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato",
	    "turquoise", "violet", "yellowgreen"
	};
	int size = sizeof(colors) / sizeof(colors[0]);
	list.reserve(size);
	for (int i = 0; i < size; ++i)
		list << QLatin1String(colors[i]);
}
예제 #22
0
QStringList ProStringList::toQStringList() const
{
    QStringList ret;
    ret.reserve(size());
    for (int i = 0; i < size(); i++) // foreach causes MSVC2010 ICE
        ret << at(i).toQString();
    return ret;
}
예제 #23
0
파일: main.cpp 프로젝트: FlavioFalcao/qt5
static QStringList byteArrayToStringList(const QList<QByteArray> &in)
{
    QStringList result;
    result.reserve(in.size());
    foreach (const QByteArray &function, in)
        result.push_back(QString::fromLatin1(function));
    return result;
}
예제 #24
0
파일: main.cpp 프로젝트: FlavioFalcao/qt5
static QStringList availableFunctions()
{
    QStringList result;
    result.reserve(TrFunctionAliasManager::NumTrFunctions);
    for (int i = 0; i < TrFunctionAliasManager::NumTrFunctions; ++i)
        result.push_back(QString::fromLatin1(defaultTrFunctionNames[i]));
    return result;
}
예제 #25
0
QStringList ProStringList::toQStringList() const
{
    QStringList ret;
    ret.reserve(size());
    foreach (const ProString &str, *this)
        ret << str.toQString();
    return ret;
}
예제 #26
0
QStringList Image::tagsString() const
{
	QStringList tags;
	tags.reserve(m_tags.count());
	for (const Tag &tag : m_tags)
		tags.append(tag.text());
	return tags;
}
예제 #27
0
void CChessModel::storeGameState()
{
	using namespace std;
	QStringList gameState;
	gameState.reserve(SIZE*SIZE);
	copy(begin(m_cells), end(m_cells), back_insert_iterator<QStringList>(gameState));
	m_gameStates << gameState;
}
예제 #28
0
파일: proitems.cpp 프로젝트: RSATom/Qt
QStringList ProStringList::toQStringList() const
{
    QStringList ret;
    ret.reserve(size());
    for (const auto &e : *this)
        ret.append(e.toQString());
    return ret;
}
예제 #29
0
static QString toString(const QList<QKeySequence> &list)
{
  QStringList items;
  items.reserve(list.size());
  Q_FOREACH (const auto &item, list) {
    items << item.toString();
  }
  return items.join(QStringLiteral(", "));
}
예제 #30
0
QStringList ProFileEvaluator::values(const QString &variableName) const
{
    const ProStringList &values = d->values(ProKey(variableName));
    QStringList ret;
    ret.reserve(values.size());
    foreach (const ProString &str, values)
        ret << d->m_option->expandEnvVars(str.toQString());
    return ret;
}