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

Commit

Permalink
Add named style support
Browse files Browse the repository at this point in the history
  • Loading branch information
pasnox committed Sep 16, 2012
1 parent 6d1e618 commit fca181a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
19 changes: 11 additions & 8 deletions src/theme/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Theme::SchemaData : public QSharedData
{
public:
QHash<QodeEdit::DefaultStyle, Theme::Style> defaultStyles;
QHash<QString, Theme::Style> styles;
QString name;

SchemaData()
Expand All @@ -33,6 +34,7 @@ class Theme::SchemaData : public QSharedData
SchemaData( const Theme::SchemaData& other )
: QSharedData( other ),
QE_OTHER_INIT( defaultStyles ),
QE_OTHER_INIT( styles ),
QE_OTHER_INIT( name )
{
}
Expand Down Expand Up @@ -73,27 +75,28 @@ class Theme::SchemaData : public QSharedData
};

QE_IMPL_SHARED_CLASS( Schema, Theme )
QE_IMPL_MEMBER( QString, name, Schema, Theme )

Theme::Schema::~Schema()
{
}

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

void Theme::Schema::setName( const QString& name )
void Theme::Schema::setDefaultStyle( QodeEdit::DefaultStyle type, const Theme::Style& style )
{
d->name = name;
d->defaultStyles[ type ] = style;
}

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

void Theme::Schema::setDefaultStyle( QodeEdit::DefaultStyle type, const Theme::Style& style )
void Theme::Schema::setStyle( const QString& name, const Theme::Style& style )
{
d->defaultStyles[ type ] = style;
d->styles[ name.toLower().trimmed() ] = style;
}
9 changes: 4 additions & 5 deletions src/theme/Theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ class Schema
typedef QList<Theme::Style> List;

QE_DECL_SHARED_CLASS( Schema, Theme );

QString name() const;
QE_DECL_MEMBER( QString, name );

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

protected:
void setName( const QString& name );
Theme::Style style( const QString& name ) const;
void setStyle( const QString& name, const Theme::Style& style );
};

}; // Theme
Expand Down

0 comments on commit fca181a

Please sign in to comment.