#include <KoUserStyleCollection.h>
Public Member Functions | |
| KoUserStyleCollection (const TQString &prefix) | |
| ~KoUserStyleCollection () | |
| void | clear () |
| bool | isEmpty () const |
| int | count () const |
| int | indexOf (KoUserStyle *style) const |
| TQValueList< KoUserStyle * > | styleList () const |
| TQString | generateUniqueName () const |
| TQStringList | displayNameList () const |
| KoUserStyle * | findStyle (const TQString &name, const TQString &defaultStyleName) const |
| KoUserStyle * | findStyleByDisplayName (const TQString &displayName) const |
| void | removeStyle (KoUserStyle *style) |
| void | updateStyleListOrder (const TQStringList &list) |
| KoUserStyle * | addStyle (KoUserStyle *sty) |
| bool | isDefault () const |
| void | setDefault (bool d) |
Protected Member Functions | |
| KoUserStyleCollection (const KoUserStyleCollection &rhs) | |
| void | operator= (const KoUserStyleCollection &rhs) |
Protected Attributes | |
| TQValueList< KoUserStyle * > | m_styleList |
Detailed Description
Generic style collection class, for all "user styles" (see KoUserStyle).
To use this for a particular kind of style, derive from KoUserStyle (to add the properties) and derive from KoUserStyleCollection (to add loading, saving, as well as re-defined findStyle and addStyle in order to cast to the correct style class).
Definition at line 32 of file KoUserStyleCollection.h.
Constructor & Destructor Documentation
◆ KoUserStyleCollection() [1/2]
| KoUserStyleCollection::KoUserStyleCollection | ( | const TQString & | prefix | ) |
Constructor.
- Parameters
-
prefix used by generateUniqueName to prefix new style names (to avoid clashes between different kinds of styles)
Definition at line 23 of file KoUserStyleCollection.cpp.
◆ ~KoUserStyleCollection()
| KoUserStyleCollection::~KoUserStyleCollection | ( | ) |
Destructor Deletes all styles.
Definition at line 74 of file KoUserStyleCollection.cpp.
◆ KoUserStyleCollection() [2/2]
|
protected |
forbidden
Member Function Documentation
◆ addStyle()
| KoUserStyle * KoUserStyleCollection::addStyle | ( | KoUserStyle * | sty | ) |
Try adding sty to the collection.
From the moment of this call, the collection owns the style.
Either this succeeds, and sty is returned, or a style with the exact same internal name and display name is present already, in which case the existing style is updated, sty is deleted, and the existing style is returned.
WARNING: sty can be deleted; use the returned value for any further processing.
Definition at line 99 of file KoUserStyleCollection.cpp.
◆ clear()
| void KoUserStyleCollection::clear | ( | ) |
Erase all styles.
Definition at line 79 of file KoUserStyleCollection.cpp.
◆ count()
|
inline |
- Returns
- the number of items in the collection
Definition at line 60 of file KoUserStyleCollection.h.
◆ displayNameList()
| TQStringList KoUserStyleCollection::displayNameList | ( | ) | const |
Return the list composed of the display-name of each style in the collection.
Definition at line 91 of file KoUserStyleCollection.cpp.
◆ findStyle()
| KoUserStyle * KoUserStyleCollection::findStyle | ( | const TQString & | name, |
| const TQString & | defaultStyleName | ||
| ) | const |
Find style based on the internal name name.
If the style with that name can't be found, then
1) if name equals defaultStyleName, return the first one, never 0
2) otherwise return 0
Definition at line 30 of file KoUserStyleCollection.cpp.
◆ findStyleByDisplayName()
| KoUserStyle * KoUserStyleCollection::findStyleByDisplayName | ( | const TQString & | displayName | ) | const |
Find style based on the display name displayName.
There could be 0, 1 or more than 1 style with that name, the method simply returns the first one found, or 0 if none was found. This is mostly useful to detect similar styles when importing styles from another document.
Definition at line 49 of file KoUserStyleCollection.cpp.
◆ generateUniqueName()
| TQString KoUserStyleCollection::generateUniqueName | ( | ) | const |
Generate a new unique name, to create a style whose internal name differs from the internal name of all existing styles.
The prefix passed to the constructor is used here.
Definition at line 64 of file KoUserStyleCollection.cpp.
◆ indexOf()
|
inline |
- Returns
- the index of
stylein the collection
Definition at line 64 of file KoUserStyleCollection.h.
◆ isDefault()
|
inline |
- Returns
- true if this collection only holds the default styles provided by the application When true, those styles don't need to be saved.
Definition at line 129 of file KoUserStyleCollection.h.
◆ isEmpty()
|
inline |
- Returns
- true if the collection is empty
Definition at line 56 of file KoUserStyleCollection.h.
◆ operator=()
|
protected |
forbidden
◆ removeStyle()
| void KoUserStyleCollection::removeStyle | ( | KoUserStyle * | style | ) |
Remove style from the collection.
If the style isn't in the collection, nothing happens. The style mustn't be deleted yet; it is stored into a list of styles to delete in clear().
Definition at line 123 of file KoUserStyleCollection.cpp.
◆ setDefault()
|
inline |
Set whether this collection only holds the default styles provided by the application.
Definition at line 133 of file KoUserStyleCollection.h.
◆ styleList()
|
inline |
Return the list of all styles in the collection.
Definition at line 69 of file KoUserStyleCollection.h.
◆ updateStyleListOrder()
| void KoUserStyleCollection::updateStyleListOrder | ( | const TQStringList & | list | ) |
Reorder the styles in the collection.
- Parameters
-
list the list of internal names of the styles WARNING, if an existing style isn't listed, it will be lost
Definition at line 132 of file KoUserStyleCollection.cpp.
Member Data Documentation
◆ m_styleList
|
protected |
Definition at line 139 of file KoUserStyleCollection.h.
The documentation for this class was generated from the following files:
