1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/* This file is part of the KDE project
Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __rdf_KoRdfSemanticItemViewSite_h__
#define __rdf_KoRdfSemanticItemViewSite_h__
#include "kordf_export.h"
#include "RdfForward.h"
// Soprano
#include <Soprano/Soprano>
class KoCanvasBase;
class KoCanvasResourceManager;
class KoRdfSemanticItemViewSitePrivate;
/**
* @short Handling a specific reference to a semantic item in the document text.
* @author Ben Martin <ben.martin@kogmbh.com>
*
* There can be many references to a single RdfSemanticItem in a
* document. RdfSemanticItem is the model, this is the view/controller.
*
* For example:
* foaf pkg:idref frodo1
* foaf pkg:idref frodo2
*
* the foaf/contact data is the KoRdfSemanticItem (model) and each
* xml:id frodo1 and frodo2 are KoRdfSemanticItemViewSite instances.
* This class allows different stylesheets to present different
* formatting for each presentation of the same KoRdfSemanticItem
* (model).
*/
class KORDF_EXPORT KoRdfSemanticItemViewSite
{
KoRdfSemanticItemViewSitePrivate * const d;
public:
/**
* Performing actions on a specific reference to a semantic item in the document.
*/
KoRdfSemanticItemViewSite(hKoRdfSemanticItem si, const QString &xmlid);
~KoRdfSemanticItemViewSite();
/**
* The stylesheet that has been set for this view site
*/
hKoSemanticStylesheet stylesheet() const;
/**
* If there is a stylesheet set for this view site it is forgotten
* and the reference can be freely edited by the user
*/
void disassociateStylesheet();
/**
* Apply a stylesheet for the semantic item.
* Note that the setting is remembered for this site too.
*
* The application can be done separately using the setStylesheetWithoutReflow()
* and reflowUsingCurrentStylesheet() methods. Performing the stylesheet
* application in two parts is convenient if you are applying a stylesheet to many
* semantic items at once, or to all the locations in the document which reference
* a single semantic item.
*
* @see setStylesheetWithoutReflow()
* @see reflowUsingCurrentStylesheet()
*/
void applyStylesheet(KoTextEditor *editor, hKoSemanticStylesheet ss);
/**
* Remember that a specific stylesheet should be applied for this
* semantic item. No reflow of the document is performed and thus
* no layout or user visible changes occur.
*
* @see applyStylesheet()
*/
void setStylesheetWithoutReflow(hKoSemanticStylesheet ss);
/**
* Reflow the text that shows the user this semantic item in the
* document.
*
* @see applyStylesheet()
*/
void reflowUsingCurrentStylesheet(KoTextEditor *editor);
/**
* Select this view of the semantic item in the document.
*/
void select(KoCanvasBase *canvas);
private:
/**
* This is similar to the linkingSubject() used by KoRdfSemanticItem
* in that you have:
* linkingSubject() common#idref xml:id
* but metadata about the site at xml:id is stored as properties
* off the KoRdfSemanticItemViewSite::linkingSubject() subject.
*
* The difference between this linkingSubject() and KoRdfSemanticItem
* is that this is for Rdf describing a single xml:id site in the document,
* the KoRdfSemanticItem::linkingSubject() is the model that can be referenced
* by many xml:id sites.
*/
Soprano::Node linkingSubject() const;
/**
* Convenience method to get a specific property from the Rdf
* model. There should be either zero or only one value for X in
* the triple:
*
* linkingSubject(), prop, X
*
* if the property does not exist defval is returned.
*/
QString getProperty(const QString &prop, const QString &defval) const;
/**
* Set the single value for the Rdf predicate prop.
* @see getProperty()
*/
void setProperty(const QString &prop, const QString &v);
/**
* Convenience method to select from startpos to endpos in the
* document
*/
void selectRange(KoCanvasResourceManager *provider, int startpos, int endpos);
};
#endif
|