2
* sxerecord.h - A class for storing the record of an individual node
3
* Copyright (C) 2007 Joonas Govenius
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program 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 this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#ifndef SXDEMETADATA_H
22
#define SXDEMETADATA_H
24
#include "sxerecordedit.h"
25
#include "sxenewedit.h"
26
#include "sxeremoveedit.h"
28
/*! \brief A class for storing the record of an individual node.*/
29
class SxeRecord : public QObject {
32
/*! \brief A class used for keeping track of the values at each version.
33
* Note that this info could be retrieved by analyzing the Edits but would be more troublesome
37
/*! \brief Default constructor */
38
VersionData(QString _parent = QString(), /*QString _ns = QString(),*/ QString _identifier = QString(), QString _data = QString());
39
/*! \brief Copy constructor */
40
VersionData(const VersionData &other);
51
/*! \brief Constructor
52
* Constructs a SxeRecordEdit for \a node.
54
SxeRecord(QString rid);
55
/*! \brief Desctructor */
58
/*! \brief Returns the node that the record underlies. */
59
QDomNode node() const;
60
/*! \brief Applies \a edit to the node. Takes ownership of \a edit. */
61
void apply(QDomDocument &doc, SxeEdit* edit, bool importing);
62
/*! \brief Returns a list of edits to the node.*/
63
QList<const SxeEdit*> edits() const;
64
/*! \brief Returns the rid of the node that the record belongs to. */
66
/*! \brief Returns the rid of the parent.*/
67
QString parent() const;
68
/*! \brief Returns the primary-weight of the node.*/
69
double primaryWeight() const;
70
/*! \brief Returns the version of the record. */
72
/*! \brief Returns the name of the node, if any.*/
74
/*! \brief Returns the name of the node, if any.*/
75
QString nameSpace() const;
76
/*! \brief Returns the chdata of the node, if any.*/
77
QString chdata() const;
78
/*! \brief Returns the processing instruction target, if any.*/
79
QString processingInstructionTarget() const;
80
/*! \brief Returns the processing instruction data, if any.*/
81
QString processingInstructionData() const;
83
bool hasSmallerSecondaryWeight(const SxeRecord &other) const;
85
bool operator==(const SxeRecord &other) const;
86
bool operator<(const SxeRecord &other) const;
87
bool operator>(const SxeRecord &other) const;
90
/*! \brief Emitted when the node is first created. */
91
void nodeToBeAdded(const QDomNode &node, bool remote, const QString &id);
92
/*! \brief Emitted after the node has been placed in the document tree. */
93
// void nodeAdded(const QDomNode &node, bool remote);
94
/*! \brief Emitted just before the node is removed. */
95
void nodeToBeRemoved(const QDomNode &node, bool remote);
96
/*! \brief Emitted when the node is removed. */
97
void nodeRemoved(const QDomNode &node, bool remote);
98
/*! \brief Emitted when primary-weight or parent record is changed. */
99
void nodeToBeMoved(const QDomNode &node, bool remote);
100
/*! \brief Emitted after the node has been repositioned. */
101
// void nodeMoved(const QDomNode &node, bool remote);
102
/*! \brief Emitted when the name of the node is changed. */
103
// void nameChanged(const QDomNode &node, bool remote);
104
/*! \brief Emitted when the chdata of the node is changed. */
105
void chdataChanged(const QDomNode &node, bool remote);
106
/*! \brief Emitted just before the chdata of the node is changed. */
107
void chdataToBeChanged(const QDomNode &node, bool remote);
108
/*! \brief Emitted when the target of the processing instruction is changed. */
109
void processingInstructionTargetChanged(const QDomNode &node, bool remote);
110
/*! \brief Emitted just before the target of the processing instruction is changed. */
111
void processingInstructionTargetToBeChanged(const QDomNode &node, bool remote);
112
/*! \brief Emitted when the data of the processing instruction is changed. */
113
void processingInstructionDataChanged(const QDomNode &node, bool remote);
114
/*! \brief Emitted just before the data of the processing instruction is changed. */
115
void processingInstructionDataToBeChanged(const QDomNode &node, bool remote);
116
/*! \brief Emitted if a conflicting edit of some kind is applied. */
117
void nodeRemovalRequired(const QDomNode &node);
121
/*! \brief Applies SxeNewEdit \a edit to the node.*/
122
bool applySxeNewEdit(QDomDocument &doc, const SxeNewEdit* edit);
123
/*! \brief Applies SxeRemoveEdit \a edit to the node.*/
124
bool applySxeRemoveEdit(const SxeRemoveEdit* edit);
125
/*! \brief Applies SxeRecordEdit \a edit to the node.*/
126
bool applySxeRecordEdit(const SxeRecordEdit* edit, bool importing = false);
128
QList<SxeEdit*> edits_;
129
QList<VersionData*> versions_;