F:/KPlato/koffice/libs/kotext/styles/KoListStyle.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; version 2.
00007  *
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Library General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Library General Public License
00014  * along with this library; see the file COPYING.LIB.  If not, write to
00015  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  * Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef KOLISTSTYLE_H
00019 #define KOLISTSTYLE_H
00020 
00021 #include <QTextFormat>
00022 #include <QMap>
00023 #include <QPointer>
00024 #include <QTextList>
00025 
00026 class StylePrivate;
00027 
00028 
00036 class KoListStyle {
00037 public:
00039     enum Style {
00041         SquareItem = QTextListFormat::ListSquare,
00043         DiscItem = QTextListFormat::ListDisc,
00045         CircleItem = QTextListFormat::ListCircle,
00047         DecimalItem = QTextListFormat::ListDecimal,
00049         AlphaLowerItem = QTextListFormat::ListLowerAlpha,
00051         UpperAlphaItem = QTextListFormat::ListUpperAlpha,
00053         NoItem = 1,
00055         RomanLowerItem,
00057         UpperRomanItem,
00059         BoxItem,
00061         CustomCharItem
00062          // TODO look at css 3 for things like hebrew counters
00063          // TODO allow a bitmap 'bullet'
00064     };
00065 
00067     enum Property {
00068         ListItemPrefix = QTextFormat::UserProperty+1000, 
00069         ListItemSuffix, 
00070         ConsecutiveNumbering,   
00071         StartValue,     
00072         Level,          
00073         DisplayLevel,   
00074         CharacterStyleId,
00075         BulletCharacter,
00076         BulletSize,     
00077         ListHeader,     
00078         NoListItem,     
00079         ExplicitListValue 
00080     };
00081 
00083     KoListStyle();
00085     KoListStyle(const KoListStyle &orig);
00086 
00088     void setStyle(Style style) { setProperty(QTextListFormat::ListStyle, (int) style); }
00090     Style style() const { return static_cast<Style> (propertyInt(QTextListFormat::ListStyle)); }
00091     void setListItemPrefix(const QString &prefix) { setProperty(ListItemPrefix, prefix ); }
00092     QString listItemPrefix() const { return propertyString(ListItemPrefix); }
00093     void setListItemSuffix(const QString &suffix) { setProperty(ListItemSuffix, suffix  ); }
00094     QString listItemSuffix() const { return propertyString(ListItemSuffix); }
00100     void setConsecutiveNumbering(bool on) { setProperty(ConsecutiveNumbering, on  ); }
00106     bool consecutiveNumbering() const { return propertyBoolean (ConsecutiveNumbering); }
00107     void setStartValue(int value) { setProperty(StartValue, value  ); }
00108     int startValue() const { return propertyInt (StartValue); }
00109     void setLevel(int level) { setProperty(Level, level  ); }
00110     int level() const { return propertyInt (Level); }
00111     void setDisplayLevel(int level) { setProperty(DisplayLevel, level  ); }
00112     int displayLevel() const { return propertyInt (DisplayLevel); }
00113     void setCharacterStyleId(int id) { setProperty(CharacterStyleId, id  ); }
00114     int characterStyleId() const { return propertyInt (CharacterStyleId); }
00115     void setBulletCharacter(QChar character) { setProperty(BulletCharacter, (int) character.unicode() ); }
00116     QChar bulletCharacter() const { return propertyInt (BulletCharacter); }
00117     void setRelativeBulletSize(int percent) { setProperty(BulletSize, percent  ); }
00118     int relativeBulletSize() const { return propertyInt (BulletSize); }
00119 
00121     const QString& name() const { return m_name; }
00122 
00124     void setName(const QString &name) { m_name = name; }
00125 
00130     void applyStyle(const QTextBlock &block);
00131 
00132 protected:
00133     friend class KoParagraphStyle;
00134     void addUser() { m_refCount++; }
00135     void removeUser() { m_refCount--; }
00136     int userCount() const { return m_refCount; }
00137 
00138     void apply(const KoListStyle &other);
00139 
00140 private:
00141     void setProperty(int key, const QVariant &value);
00142     int propertyInt(int key) const;
00143     bool propertyBoolean(int key) const;
00144     QString propertyString(int key) const;
00145 
00146 private:
00147     QString m_name;
00148     StylePrivate *m_stylesPrivate;
00149     QMap<const QTextDocument*, QPointer<QTextList> > m_textLists;
00150     int m_refCount;
00151 };
00152 
00153 #endif

Généré le Wed Nov 22 23:41:11 2006 pour KPlato par  doxygen 1.5.1-p1