00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00063
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