Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Commit

Permalink
Rename Style to DefaultStyle to avoid ambiquity.
Browse files Browse the repository at this point in the history
  • Loading branch information
pasnox committed Sep 16, 2012
1 parent d7fc249 commit 6d1e618
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/QodeEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ QodeEdit {
IncludeRulesRule
};

enum Style {
enum DefaultStyle {
InvalidStyle = -1,
NormalStyle,
KeywordStyle,
Expand Down
10 changes: 5 additions & 5 deletions src/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Tools {
static CaseInsensitiveEnumerator ruler( mo().enumerator( mo().indexOfEnumerator( "Ruler" ) ) );
static CaseInsensitiveEnumerator margin( mo().enumerator( mo().indexOfEnumerator( "Margin" ) ) );
static CaseInsensitiveEnumerator rule( mo().enumerator( mo().indexOfEnumerator( "Rule" ) ) );
static CaseInsensitiveEnumerator style( mo().enumerator( mo().indexOfEnumerator( "Style" ) ) );
static CaseInsensitiveEnumerator defaultStyle( mo().enumerator( mo().indexOfEnumerator( "DefaultStyle" ) ) );
}; // Tools

}; // QodeEdit
Expand Down Expand Up @@ -108,14 +108,14 @@ QodeEdit::Rule QodeEdit::Tools::stringToRule( const QString& string )
return QodeEdit::Rule( QodeEdit::Tools::rule.keyToValue( string ) );
}

QString QodeEdit::Tools::styleToString( QodeEdit::Style style )
QString QodeEdit::Tools::defaultStyleToString( QodeEdit::DefaultStyle style )
{
return QodeEdit::Tools::style.valueToKey( style );
return QodeEdit::Tools::defaultStyle.valueToKey( style );
}

QodeEdit::Style QodeEdit::Tools::stringToStyle( const QString& string )
QodeEdit::DefaultStyle QodeEdit::Tools::stringToDefaultStyle( const QString& string )
{
return QodeEdit::Style( QodeEdit::Tools::style.keyToValue( string ) );
return QodeEdit::DefaultStyle( QodeEdit::Tools::defaultStyle.keyToValue( string ) );
}

bool QodeEdit::Tools::stringEquals( const QString& left, const QString& right, Qt::CaseSensitivity sensitivity )
Expand Down
4 changes: 2 additions & 2 deletions src/Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace Tools {
QString ruleToString( QodeEdit::Rule rule );
QodeEdit::Rule stringToRule( const QString& string );

QString styleToString( QodeEdit::Style style );
QodeEdit::Style stringToStyle( const QString& string );
QString defaultStyleToString( QodeEdit::DefaultStyle style );
QodeEdit::DefaultStyle stringToDefaultStyle( const QString& string );

bool stringEquals( const QString& left, const QString& right, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive );
bool stringLessThan( const QString& left, const QString& right, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive );
Expand Down
2 changes: 1 addition & 1 deletion src/syntax/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ bool Syntax::Parser::startElement( const QString& namespaceURI, const QString& l
else if ( QodeEdit::Tools::stringEquals( name, "defStyleNum" ) ) {
itemData.defStyleNum() = atts.value( i );

if ( QodeEdit::Tools::stringToStyle( itemData.defStyleNum() ) == -1 ) {
if ( QodeEdit::Tools::stringToDefaultStyle( itemData.defStyleNum() ) == -1 ) {
qWarning( "%s: Fixed invalid style to dsNormal in %s", Q_FUNC_INFO, qPrintable( d->document->name() ) );
itemData.defStyleNum() = "dsNormal";
}
Expand Down
46 changes: 23 additions & 23 deletions src/theme/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class Theme::SchemaData : public QSharedData
{
public:
QHash<QodeEdit::Style, Theme::Style> styles;
QHash<QodeEdit::DefaultStyle, Theme::Style> defaultStyles;
QString name;

SchemaData()
Expand All @@ -32,7 +32,7 @@ class Theme::SchemaData : public QSharedData

SchemaData( const Theme::SchemaData& other )
: QSharedData( other ),
QE_OTHER_INIT( styles ),
QE_OTHER_INIT( defaultStyles ),
QE_OTHER_INIT( name )
{
}
Expand All @@ -41,34 +41,34 @@ class Theme::SchemaData : public QSharedData
}

void initToDefault() {
//styles[ QodeEdit::NormalStyle ].;
//defaultStyles[ QodeEdit::NormalStyle ].;

styles[ QodeEdit::KeywordStyle ].setFontWeight( QFont::Bold );
defaultStyles[ QodeEdit::KeywordStyle ].setFontWeight( QFont::Bold );

styles[ QodeEdit::DataTypeStyle ].setForeground( QBrush( QColor( "#0057ae" ) ) );
defaultStyles[ QodeEdit::DataTypeStyle ].setForeground( QBrush( QColor( "#0057ae" ) ) );

styles[ QodeEdit::DecValStyle ].setForeground( QBrush( QColor( "#b07e00" ) ) );
styles[ QodeEdit::BaseNStyle ].setForeground( QBrush( QColor( "#b07e00" ) ) );
styles[ QodeEdit::FloatStyle ].setForeground( QBrush( QColor( "#b07e00" ) ) );
defaultStyles[ QodeEdit::DecValStyle ].setForeground( QBrush( QColor( "#b07e00" ) ) );
defaultStyles[ QodeEdit::BaseNStyle ].setForeground( QBrush( QColor( "#b07e00" ) ) );
defaultStyles[ QodeEdit::FloatStyle ].setForeground( QBrush( QColor( "#b07e00" ) ) );

styles[ QodeEdit::CharStyle ].setForeground( QBrush( QColor( "#ff80e0" ) ) );
defaultStyles[ QodeEdit::CharStyle ].setForeground( QBrush( QColor( "#ff80e0" ) ) );

styles[ QodeEdit::StringStyle ].setForeground( QBrush( QColor( "#bf0303" ) ) );
defaultStyles[ QodeEdit::StringStyle ].setForeground( QBrush( QColor( "#bf0303" ) ) );

styles[ QodeEdit::CommentStyle ].setForeground( QBrush( QColor( "#888786" ) ) );
styles[ QodeEdit::CommentStyle ].setFontItalic( true );
defaultStyles[ QodeEdit::CommentStyle ].setForeground( QBrush( QColor( "#888786" ) ) );
defaultStyles[ QodeEdit::CommentStyle ].setFontItalic( true );

styles[ QodeEdit::OthersStyle ].setForeground( QBrush( QColor( "#006e26" ) ) );
defaultStyles[ QodeEdit::OthersStyle ].setForeground( QBrush( QColor( "#006e26" ) ) );

styles[ QodeEdit::AlertStyle ].setForeground( QBrush( QColor( "#bf0303" ) ) );
styles[ QodeEdit::AlertStyle ].setBackground( QBrush( QColor( "#f7e7e7" ) ) );
styles[ QodeEdit::AlertStyle ].setFontWeight( QFont::Bold );
defaultStyles[ QodeEdit::AlertStyle ].setForeground( QBrush( QColor( "#bf0303" ) ) );
defaultStyles[ QodeEdit::AlertStyle ].setBackground( QBrush( QColor( "#f7e7e7" ) ) );
defaultStyles[ QodeEdit::AlertStyle ].setFontWeight( QFont::Bold );

styles[ QodeEdit::FunctionStyle ].setForeground( QBrush( QColor( "#442886" ) ) );
defaultStyles[ QodeEdit::FunctionStyle ].setForeground( QBrush( QColor( "#442886" ) ) );

styles[ QodeEdit::RegionMarkerStyle ].setForeground( QBrush( QColor( "#0057ae" ) ) );
defaultStyles[ QodeEdit::RegionMarkerStyle ].setForeground( QBrush( QColor( "#0057ae" ) ) );

styles[ QodeEdit::ErrorStyle ].setForeground( QBrush( QColor( "#e1eaf8" ) ) );
defaultStyles[ QodeEdit::ErrorStyle ].setForeground( QBrush( QColor( "#e1eaf8" ) ) );
}
};

Expand All @@ -88,12 +88,12 @@ void Theme::Schema::setName( const QString& name )
d->name = name;
}

Theme::Style Theme::Schema::style( QodeEdit::Style type ) const
Theme::Style Theme::Schema::defaultStyle( QodeEdit::DefaultStyle type ) const
{
return d->styles.value( type );
return d->defaultStyles.value( type );
}

void Theme::Schema::setStyle( QodeEdit::Style type, const Theme::Style& style )
void Theme::Schema::setDefaultStyle( QodeEdit::DefaultStyle type, const Theme::Style& style )
{
d->styles[ type ] = style;
d->defaultStyles[ type ] = style;
}
6 changes: 2 additions & 4 deletions src/theme/Theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class Style : public QTextCharFormat

class Schema
{
Q_ENUMS( DefaultStyle )

private:
QExplicitlySharedDataPointer<Theme::SchemaData> d;

Expand All @@ -45,8 +43,8 @@ class Schema

QString name() const;

Theme::Style style( QodeEdit::Style type ) const;
void setStyle( QodeEdit::Style type, const Theme::Style& style );
Theme::Style defaultStyle( QodeEdit::DefaultStyle type ) const;
void setDefaultStyle( QodeEdit::DefaultStyle type, const Theme::Style& style );

protected:
void setName( const QString& name );
Expand Down

0 comments on commit 6d1e618

Please sign in to comment.