Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Private Member Functions | Private Attributes
StyleSet< STYLE > Class Template Reference

#include <styleset.h>

Inheritance diagram for StyleSet< STYLE >:
Inheritance graph
[legend]
Collaboration diagram for StyleSet< STYLE >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

STYLE & operator[] (uint index)
const STYLE & operator[] (const QString &name) const
const STYLE & operator[] (uint index) const
int find (const QString &name) const
const Style * resolve (const QString &name) const
uint count () const
STYLE * append (STYLE *style)
void remove (uint index)
void redefine (const StyleSet< STYLE > &defs, bool removeUnused=false)
void rename (const QMap< QString, QString > &newNames)
STYLE * create (const STYLE &proto)
void makeDefault (STYLE *def)
bool isDefault (const STYLE &style) const
 StyleSet ()
 ~StyleSet ()
void clear ()
void setContext (const StyleContext *context)
const StyleContext * context () const

Private Member Functions

 StyleSet (const StyleSet &)
StyleSetoperator= (const StyleSet &)

Private Attributes

QValueList< STYLE * > styles
const StyleContext * m_context
STYLE * m_default

Detailed Description

template<class STYLE>
class StyleSet< STYLE >

Definition at line 11 of file styleset.h.


Constructor & Destructor Documentation

template<class STYLE>
StyleSet< STYLE >::StyleSet ( ) [inline]

Definition at line 62 of file styleset.h.

: styles(), m_context(NULL), m_default(NULL) {}
template<class STYLE>
StyleSet< STYLE >::~StyleSet ( ) [inline]

Definition at line 64 of file styleset.h.

                   { 
              clear(); 
       }
template<class STYLE>
StyleSet< STYLE >::StyleSet ( const StyleSet< STYLE > &  ) [inline, private]

Definition at line 89 of file styleset.h.

{ assert(false); }

Member Function Documentation

template<class STYLE>
STYLE* StyleSet< STYLE >::append ( STYLE *  style) [inline]

Definition at line 35 of file styleset.h.

                                   { 
              styles.append(style); 
              style->setContext(this); 
              return style; 
       }

Here is the caller graph for this function:

template<class STYLE>
void StyleSet< STYLE >::clear ( ) [inline]

Definition at line 68 of file styleset.h.

                    { 
              while(styles.count()>0) 
              { 
                     delete styles.front(); 
                     styles.pop_front(); 
              }
              invalidate();
       }

Here is the caller graph for this function:

template<class STYLE>
const StyleContext* StyleSet< STYLE >::context ( ) const [inline]

Definition at line 84 of file styleset.h.

                                           { 
              return m_context; 
       }

Here is the caller graph for this function:

template<class STYLE>
uint StyleSet< STYLE >::count ( ) const [inline]

Definition at line 31 of file styleset.h.

                          { 
              return (uint) styles.count(); 
       }

Here is the caller graph for this function:

template<class STYLE>
STYLE* StyleSet< STYLE >::create ( const STYLE &  proto) [inline]

Definition at line 47 of file styleset.h.

                                         { 
              return append(new STYLE(proto)); 
       }

Here is the caller graph for this function:

template<class STYLE >
int StyleSet< STYLE >::find ( const QString &  name) const [inline]

Definition at line 109 of file styleset.h.

{
       for (uint i=0; i < styles.count(); ++i)
              if (styles[i]->name() == name)
                     return i;
       return -1;
}

Here is the caller graph for this function:

template<class STYLE>
bool StyleSet< STYLE >::isDefault ( const STYLE &  style) const [inline]

Definition at line 58 of file styleset.h.

                                                {
              return &style == m_default;
       }

Here is the caller graph for this function:

template<class STYLE>
void StyleSet< STYLE >::makeDefault ( STYLE *  def) [inline]

Definition at line 51 of file styleset.h.

                                    { 
              m_default = def; 
              if(def) 
                     def->setContext(this);
              invalidate();
       }
template<class STYLE>
StyleSet& StyleSet< STYLE >::operator= ( const StyleSet< STYLE > &  ) [inline, private]

Definition at line 90 of file styleset.h.

{ assert(false); return *this; }
template<class STYLE>
STYLE& StyleSet< STYLE >::operator[] ( uint  index) [inline]

Definition at line 13 of file styleset.h.

                                      { 
              assert(index < styles.count()); 
              return * styles[index]; 
       }
template<class STYLE>
const STYLE& StyleSet< STYLE >::operator[] ( const QString &  name) const [inline]

Definition at line 18 of file styleset.h.

                                                           { 
              return * dynamic_cast<const STYLE*>(resolve(name)); 
       }
template<class STYLE>
const STYLE& StyleSet< STYLE >::operator[] ( uint  index) const [inline]

Definition at line 22 of file styleset.h.

                                                  { 
              assert(index < styles.count()); 
              return * styles[index]; 
       }
template<class STYLE>
void StyleSet< STYLE >::redefine ( const StyleSet< STYLE > &  defs,
bool  removeUnused = false 
) [inline]

Definition at line 131 of file styleset.h.

{
       for (int i=signed(styles.count())-1; i >= 0; --i) 
       {
              bool found = false;
              for (uint j=0; j < defs.count(); ++j) 
              {
                     if (styles[i]->name() == defs[j].name()) 
                     {
                            found = true;
                            (*styles[i]) = defs[j];
                            (*styles[i]).setContext(this);
                            if (defs.m_default == defs.styles[j])
                                   makeDefault(styles[i]);
                            break;
                     }
              }
              if (!found && removeUnused) 
              {
                     if (styles[i] == m_default)
                            makeDefault(NULL);
                     remove(i);
              }
       }
       for (uint j=0; j < defs.count(); ++j) 
       {
              if (find(defs[j].name()) < 0) 
              {
                     STYLE* newStyle = create(defs[j]);
                     if (defs.m_default == defs.styles[j])
                            makeDefault(newStyle);
              }
       }
       invalidate();
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class STYLE >
void StyleSet< STYLE >::remove ( uint  index) [inline]

Definition at line 98 of file styleset.h.

{
       assert(index < styles.count()); 
       typename QValueList<STYLE*>::Iterator it = styles.at(index);
       if (*it == m_default)
              return;
       delete (*it);
       styles.erase(it);
}

Here is the caller graph for this function:

template<class STYLE >
void StyleSet< STYLE >::rename ( const QMap< QString, QString > &  newNames) [inline]

Definition at line 168 of file styleset.h.

{
       for (uint i=0; i < styles.count(); ++i)
       { 
              QMap<QString,QString>::ConstIterator it;
              
              it = newNames.find(styles[i]->name());
              if (it != newNames.end())
                     styles[i]->setName(it.data());
       
              it = newNames.find(styles[i]->parent());
              if (it != newNames.end())
                     styles[i]->setParent(it.data());
       }
       invalidate();
}
template<class STYLE >
const Style * StyleSet< STYLE >::resolve ( const QString &  name) const [inline]

Definition at line 118 of file styleset.h.

{
       if (name.isEmpty())
              return m_default;
       for (uint i=0; i < styles.count(); ++i)
       {
              if (styles[i]->name() == name)
                     return styles[i];
       }
       return m_context ? m_context->resolve(name) : NULL;
}

Here is the caller graph for this function:

template<class STYLE>
void StyleSet< STYLE >::setContext ( const StyleContext *  context) [inline]

Definition at line 77 of file styleset.h.

                                                    {
              bool reallyNew = m_context != context;
              m_context = context; 
              if (reallyNew)
                     invalidate();
       }

Here is the caller graph for this function:


Member Data Documentation

template<class STYLE>
const StyleContext* StyleSet< STYLE >::m_context [private]

Definition at line 93 of file styleset.h.

template<class STYLE>
STYLE* StyleSet< STYLE >::m_default [private]

Definition at line 94 of file styleset.h.

template<class STYLE>
QValueList<STYLE*> StyleSet< STYLE >::styles [private]

Definition at line 92 of file styleset.h.


The documentation for this class was generated from the following file: