1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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 ***************************************************************************/
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()
42 KwCssStyles::KwCssStyles(const KwCssStyles
& other
)
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();
53 KwCssStyles::~KwCssStyles()
55 StyleDictionary::iterator it
;
56 for (it
= m_styles
.begin(); it
!= m_styles
.end(); ++it
)
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())
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 */";
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()];
105 state
= (*it
)->getNewState();