1 /* This file is part of the KDE project
2    Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8 
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13 
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef __rdf_KoSemanticStylesheet_h__
21 #define __rdf_KoSemanticStylesheet_h__
22 
23 #include "kordf_export.h"
24 
25 #include "RdfForward.h"
26 // Qt
27 #include <QObject>
28 #include <QSharedData>
29 #include <QList>
30 #include <QString>
31 
32 class KoSemanticStylesheetPrivate;
33 
34 /**
35  * @short A stylesheet that knows how to format a given KoRdfSemanticItem
36  *
37  * If you are looking to apply a stylesheet you should use the KoRdfSemanticItemViewSite
38  * class. For example:
39  *
40  * KoRdfSemanticItemViewSite vs( SemanticItemPtr, xmlid );
41  * vs.applyStylesheet( canvas, StylesheetPtr );
42  *
43  * @author Ben Martin <ben.martin@kogmbh.com>
44  * @see KoRdfSemanticItem
45  * @see KoRdfSemanticItemViewSite
46  * @see KoDocumentRdf
47  */
48 class KORDF_EXPORT KoSemanticStylesheet : public QObject, public QSharedData
49 {
50     Q_OBJECT
51     KoSemanticStylesheetPrivate * const d;
52 protected:
53 
54     // Restrict who can make us
55     friend class KoRdfSemanticItem;
56     friend class KoRdfSemanticItemViewSite;
57 
58     KoSemanticStylesheet(const QString &uuid, const QString &name, const QString &templateString,
59                          const QString &type = "System", bool isMutable = false);
60 
61     /**
62      * Only called from KoRdfSemanticItemViewSite, this method actually
63      * applies the stylesheet to a specific reference to a semantic
64      * item in the document.
65      */
66     void format(hKoRdfSemanticItem obj, KoTextEditor *editor, const QString& xmlid = QString());
67 
68 public:
69     ~KoSemanticStylesheet();
70     static QString stylesheetTypeSystem();
71     static QString stylesheetTypeUser();
72 
73     QString uuid() const;
74     QString name() const;
75     QString templateString() const;
76     QString type() const;
77     bool isMutable() const;
78 
79     // if (isMutable()) these methods update
80     // user stylesheets are mutable, system ones are not
81     void name(const QString &v);
82     void templateString(const QString &v);
83 
84 Q_SIGNALS:
85     void nameChanging(hKoSemanticStylesheet, const QString &oldName, const QString &newName);
86 };
87 
88 #include <QMetaType>
89 Q_DECLARE_METATYPE(KoSemanticStylesheet*)
90 #endif
91