lib
KoUserStyleCollection Class Reference
#include <KoUserStyleCollection.h>

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.
Public Member Functions | |
KoUserStyleCollection (const QString &prefix) | |
~KoUserStyleCollection () | |
void | clear () |
bool | isEmpty () const |
int | count () const |
int | indexOf (KoUserStyle *style) const |
QValueList< KoUserStyle * > | styleList () const |
QString | generateUniqueName () const |
QStringList | displayNameList () const |
KoUserStyle * | findStyle (const QString &name, const QString &defaultStyleName) const |
KoUserStyle * | findStyleByDisplayName (const QString &displayName) const |
void | removeStyle (KoUserStyle *style) |
void | updateStyleListOrder (const QStringList &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 | |
QValueList< KoUserStyle * > | m_styleList |
Constructor & Destructor Documentation
KoUserStyleCollection::KoUserStyleCollection | ( | const QString & | 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::KoUserStyleCollection | ( | const KoUserStyleCollection & | rhs | ) | [protected] |
forbidden
Member Function Documentation
void KoUserStyleCollection::clear | ( | void | ) |
bool KoUserStyleCollection::isEmpty | ( | ) | const [inline] |
int KoUserStyleCollection::count | ( | ) | const [inline] |
- Returns:
- the number of items in the collection
Definition at line 60 of file KoUserStyleCollection.h.
int KoUserStyleCollection::indexOf | ( | KoUserStyle * | style | ) | const [inline] |
QValueList<KoUserStyle *> KoUserStyleCollection::styleList | ( | ) | const [inline] |
Return the list of all styles in the collection.
Definition at line 69 of file KoUserStyleCollection.h.
QString 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.
QStringList 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.
KoUserStyle * KoUserStyleCollection::findStyle | ( | const QString & | name, | |
const QString & | 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.
KoUserStyle * KoUserStyleCollection::findStyleByDisplayName | ( | const QString & | 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.
Reimplemented in KoStyleCollection.
Definition at line 49 of file KoUserStyleCollection.cpp.
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.
void KoUserStyleCollection::updateStyleListOrder | ( | const QStringList & | 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.
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.
bool KoUserStyleCollection::isDefault | ( | ) | const [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.
void KoUserStyleCollection::setDefault | ( | bool | d | ) | [inline] |
Set whether this collection only holds the default styles provided by the application.
Definition at line 133 of file KoUserStyleCollection.h.
void KoUserStyleCollection::operator= | ( | const KoUserStyleCollection & | rhs | ) | [protected] |
forbidden
The documentation for this class was generated from the following files: