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 KwCssStyleSheet.cpp
22 * @brief Cascading style sheet.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwCssStyleSheet.h"
27 #include "KwCssStyleRule.h"
32 * Constructors + destructors
35 /// Default constructor.
36 KwCssStyleSheet::KwCssStyleSheet()
43 * This copies all except the actual styles in each rule which are aliased.
45 KwCssStyleSheet::KwCssStyleSheet(const KwCssStyleSheet
& copy
)
49 assert(0&&"unimplemented");
53 KwCssStyleSheet::~KwCssStyleSheet()
62 void KwCssStyleSheet::clear()
68 void KwCssStyleSheet::addRule(const KwCssStyleRule
& rule
)
70 m_rules
.push_back(rule
);
73 /// Import another stylesheet.
74 void KwCssStyleSheet::importStyleSheet(const KwCssStyleSheet
* styleSheet
)
76 m_rules
+= styleSheet
->m_rules
;
80 /// Import from CSS-like format into the sheet.
81 void KwCssStyleSheet::import(const QString
& sheet
)
83 std::cout
<< __PRETTY_FUNCTION__
<< ": " << (const char*)sheet
.toAscii() << std::endl
;
91 KwCssStyleSheet::RuleList
& KwCssStyleSheet::getRules()
96 /// Get the constant rules.
97 const KwCssStyleSheet::RuleList
& KwCssStyleSheet::getRules() const
102 /// Convert to CSS-like format.
103 QString
KwCssStyleSheet::toString() const
105 /// @todo Take into account of shared styles in rules!
106 QString result
= "/* Doesn't take shared styles into account */\n";
107 foreach (const KwCssStyleRule
& rule
, m_rules
)
109 result
+= rule
.toString();