/** * 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)); }
/** * 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)); }