Example #1
0
bool Dictionary::getOwnPropertiesAsStringHashMap(
    HashMap<String, String>& hashMap) const {
  v8::Local<v8::Object> object;
  if (!toObject(object))
    return false;

  v8::Local<v8::Array> properties;
  if (!object->GetOwnPropertyNames(v8Context()).ToLocal(&properties))
    return false;
  for (uint32_t i = 0; i < properties->Length(); ++i) {
    v8::Local<v8::String> key;
    if (!propertyKey(v8Context(), properties, i, key))
      continue;
    if (!v8CallBoolean(object->Has(v8Context(), key)))
      continue;

    v8::Local<v8::Value> value;
    if (!object->Get(v8Context(), key).ToLocal(&value))
      continue;
    TOSTRING_DEFAULT(V8StringResource<>, stringKey, key, false);
    TOSTRING_DEFAULT(V8StringResource<>, stringValue, value, false);
    if (!static_cast<const String&>(stringKey).isEmpty())
      hashMap.set(stringKey, stringValue);
  }

  return true;
}
Example #2
0
bool Dictionary::getPropertyNames(Vector<String>& names) const {
  v8::Local<v8::Object> object;
  if (!toObject(object))
    return false;

  v8::Local<v8::Array> properties;
  if (!object->GetPropertyNames(v8Context()).ToLocal(&properties))
    return false;
  for (uint32_t i = 0; i < properties->Length(); ++i) {
    v8::Local<v8::String> key;
    if (!propertyKey(v8Context(), properties, i, key))
      continue;
    if (!v8CallBoolean(object->Has(v8Context(), key)))
      continue;
    TOSTRING_DEFAULT(V8StringResource<>, stringKey, key, false);
    names.append(stringKey);
  }

  return true;
}
Example #3
0
/**
 * Reads style data from a QSettings object for the given node and all its
 * children.
 * @param  settings The QSettings object to read from
 * @param  node     The style node
 */
void LexerStyleModel::loadStyle(QSettings& settings, Node* node)
{
	// Get the lexer and style ID from the node data.
	StyleData* data = static_cast<StyleData*>(node->data());
	QsciLexer* lexer = data->lexer_;
	int style = data->style_;

	// Create a key template for the settings object, of the form
	// LEXER\STYLE\%1, where %1 will be replaced by the property name.
	QString key = QString("Style/%1/%2/%3").arg(lexer->lexer()).arg(style);

	// Get the properties.
	for (uint i = 0; i != _LastProperty; i++) {
		StyleProperty prop = static_cast<StyleProperty>(i);
		setProperty(settings.value(key.arg(propertyKey(prop))), node, prop,
		            propertyDefaultValue(lexer, style, prop));
	}

	// Recursive call.
	for (int i = 0; i < node->childCount(); i++)
		loadStyle(settings, node->child(i));
}
Example #4
0
/**
 * Writes style data to a QSettings object for the given node and all its
 * children.
 * @param  settings The QSettings object to write to
 * @param  node     The style node
 */
void LexerStyleModel::storeStyle(QSettings& settings, const Node* node) const
{
	// Get the lexer and style ID from the node data.
	StyleData* data = static_cast<StyleData*>(node->data());
	QsciLexer* lexer = data->lexer_;
	int style = data->style_;

	// Create a key template for the settings object, of the form
	// LEXER\STYLE\%1, where %1 will be replaced by the property name.
	QString key = QString("Style/%1/%2/%3").arg(lexer->lexer()).arg(style);

	// Get the properties.
	for (uint i = 0; i != _LastProperty; i++) {
		StyleProperty prop = static_cast<StyleProperty>(i);
		PropertyData* propData = propertyDataFromNode(node, prop);
		QVariant value = propData->inherited_ ? inheritValue_
		                                      : propData->value_;
		settings.setValue(key.arg(propertyKey(prop)), value);
	}

	// Recursive call.
	for (int i = 0; i < node->childCount(); i++)
		storeStyle(settings, node->child(i));
}
Example #5
0
/*!
    Returns the value of the \a key property.
 */
QString QContent::property( Property key ) const
{
    return property( propertyKey( key ) );
}
Example #6
0
/*!
    Sets the \a key property of a QContent to \a value.

    The property will not be written to the backing store until commit() is called.

    \sa commit()
 */
void QContent::setProperty( Property key, const QString &value )
{
    setProperty( propertyKey( key ), value );
}