Some DOM code in place for export of style scopes, but without CSS translation
[kworship.git] / kworship / css / KwCssStyles.cpp
blob3d50a39518a8bed22c7c92b22f02d41953f18134
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 /**
21 * @file KwCssStyles.cpp
22 * @brief Set of cascading style properties.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwCssStyles.h"
27 #include "KwCssStyleStates.h"
28 #include "KwCssAbstractStyle.h"
29 #include "KwCssAbstractStyleState.h"
32 * Constructors + destructors
35 /// Default constructor.
36 KwCssStyles::KwCssStyles()
37 : m_styles()
41 /// Copy constructor.
42 KwCssStyles::KwCssStyles(const KwCssStyles& other)
43 : m_styles()
45 StyleDictionary::const_iterator it;
46 for (it = other.m_styles.begin(); it != other.m_styles.end(); ++it)
48 m_styles[it.key()] = (*it)->duplicate();
52 /// Destructor.
53 KwCssStyles::~KwCssStyles()
55 StyleDictionary::iterator it;
56 for (it = m_styles.begin(); it != m_styles.end(); ++it)
58 delete *it;
63 * Main interface
66 /// Set a style.
67 void KwCssStyles::setRawStyle(QString name, KwCssAbstractStyle* style)
69 // Delete previous value
70 StyleDictionary::iterator it = m_styles.find(name);
71 if (it != m_styles.end())
73 delete *it;
75 // Set new value
76 m_styles[name] = style;
79 /// Return whether the styles container is empty.
80 bool KwCssStyles::isEmpty() const
82 return m_styles.isEmpty();
85 /// Convert to CSS-like format.
86 QString KwCssStyles::toString() const
88 return "/* KwCssStyle::toString() unimplemented */";
92 * Operators
95 /// Apply styles.
96 KwCssStyleStates& operator << (KwCssStyleStates& states, const KwCssStyles& styles)
98 // go through styles, adjusting the states
99 KwCssStyles::StyleDictionary::const_iterator it;
100 for (it = styles.m_styles.begin(); it != styles.m_styles.end(); ++it)
102 KwCssAbstractStyleState*& state = states[it.key()];
103 if (0 == state)
105 state = (*it)->getNewState();
107 (*state) << (*it);
109 return states;