diff --git a/src/utils/attribute.cpp b/src/utils/attribute.cpp index c06815d8..3a941bfd 100644 --- a/src/utils/attribute.cpp +++ b/src/utils/attribute.cpp @@ -1,215 +1,215 @@ /* This file is part of the KDE libraries * Copyright (C) 2003-2005 Hamish Rodda * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "attribute.h" #include "kateextendedattribute.h" using namespace KTextEditor; class KTextEditor::AttributePrivate { public: AttributePrivate() { dynamicAttributes.append(Attribute::Ptr()); dynamicAttributes.append(Attribute::Ptr()); } QList dynamicAttributes; }; Attribute::Attribute() : d(new AttributePrivate()) { } Attribute::Attribute(const QString &name, DefaultStyle style) : d(new AttributePrivate()) { setName(name); setDefaultStyle(style); } Attribute::Attribute(const Attribute &a) : QTextCharFormat(a) , QSharedData() , d(new AttributePrivate()) { d->dynamicAttributes = a.d->dynamicAttributes; } Attribute::~Attribute() { delete d; } Attribute &Attribute::operator+=(const Attribute &a) { merge(a); for (int i = 0; i < a.d->dynamicAttributes.count(); ++i) if (i < d->dynamicAttributes.count()) { if (a.d->dynamicAttributes[i]) { d->dynamicAttributes[i] = a.d->dynamicAttributes[i]; } } else { d->dynamicAttributes.append(a.d->dynamicAttributes[i]); } return *this; } Attribute::Ptr Attribute::dynamicAttribute(ActivationType type) const { if (type < 0 || type >= d->dynamicAttributes.count()) { return Ptr(); } return d->dynamicAttributes[type]; } void Attribute::setDynamicAttribute(ActivationType type, Attribute::Ptr attribute) { if (type < 0 || type > ActivateCaretIn) { return; } d->dynamicAttributes[type] = attribute; } QString Attribute::name() const { return stringProperty(AttributeName); } void Attribute::setName(const QString &name) { setProperty(AttributeName, name); } DefaultStyle Attribute::defaultStyle() const { return static_cast (intProperty(AttributeDefaultStyleIndex)); } void Attribute::setDefaultStyle(DefaultStyle style) { setProperty(AttributeDefaultStyleIndex, QVariant(static_cast(style))); } bool Attribute::skipSpellChecking() const { return boolProperty(Spellchecking); } void Attribute::setSkipSpellChecking(bool skipspellchecking) { setProperty(Spellchecking, QVariant(skipspellchecking)); } QBrush Attribute::outline() const { if (hasProperty(Outline)) { return property(Outline).value(); } return QBrush(); } void Attribute::setOutline(const QBrush &brush) { setProperty(Outline, brush); } QBrush Attribute::selectedForeground() const { if (hasProperty(SelectedForeground)) { return property(SelectedForeground).value(); } return QBrush(); } void Attribute::setSelectedForeground(const QBrush &foreground) { setProperty(SelectedForeground, foreground); } bool Attribute::backgroundFillWhitespace() const { if (hasProperty(BackgroundFillWhitespace)) { return boolProperty(BackgroundFillWhitespace); } return true; } void Attribute::setBackgroundFillWhitespace(bool fillWhitespace) { setProperty(BackgroundFillWhitespace, fillWhitespace); } QBrush Attribute::selectedBackground() const { if (hasProperty(SelectedBackground)) { return property(SelectedBackground).value(); } return QBrush(); } void Attribute::setSelectedBackground(const QBrush &brush) { setProperty(SelectedBackground, brush); } void Attribute::clear() { QTextCharFormat::operator=(QTextCharFormat()); d->dynamicAttributes.clear(); d->dynamicAttributes.append(Ptr()); d->dynamicAttributes.append(Ptr()); } bool Attribute::fontBold() const { return fontWeight() == QFont::Bold; } void Attribute::setFontBold(bool bold) { - setFontWeight(bold ? QFont::Bold : 0); + setFontWeight(bold ? QFont::Bold : QFont::Normal); } bool Attribute::hasAnyProperty() const { return !properties().isEmpty(); } Attribute &KTextEditor::Attribute::operator =(const Attribute &a) { QTextCharFormat::operator=(a); Q_ASSERT(static_cast(*this) == a); d->dynamicAttributes = a.d->dynamicAttributes; return *this; }