~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to src/sxe/sxerecord.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * sxerecord.h - A class for storing the record of an individual node
 
3
 * Copyright (C) 2007  Joonas Govenius
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef SXDEMETADATA_H
 
22
#define SXDEMETADATA_H
 
23
 
 
24
#include "sxerecordedit.h"
 
25
#include "sxenewedit.h"
 
26
#include "sxeremoveedit.h"
 
27
 
 
28
/*! \brief A class for storing the record of an individual node.*/
 
29
class SxeRecord : public QObject {
 
30
    Q_OBJECT
 
31
 
 
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
 
34
     */
 
35
    class VersionData {
 
36
    public:
 
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);
 
41
        
 
42
        int version;
 
43
        QString parent;
 
44
        double primaryWeight;
 
45
        // QString ns;
 
46
        QString identifier;
 
47
        QString data;
 
48
    };
 
49
 
 
50
    public:
 
51
        /*! \brief Constructor
 
52
         *  Constructs a SxeRecordEdit for \a node.
 
53
         */
 
54
        SxeRecord(QString rid);
 
55
        /*! \brief Desctructor */
 
56
        ~SxeRecord();
 
57
 
 
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. */
 
65
        QString rid() const;
 
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. */
 
71
        int version() const;
 
72
        /*! \brief Returns the name of the node, if any.*/
 
73
        QString name() const;
 
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;
 
82
 
 
83
        bool hasSmallerSecondaryWeight(const SxeRecord &other) const;
 
84
 
 
85
        bool operator==(const SxeRecord &other) const;
 
86
        bool operator<(const SxeRecord &other) const;
 
87
        bool operator>(const SxeRecord &other) const;
 
88
 
 
89
    signals:
 
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);
 
118
 
 
119
    private:
 
120
        
 
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);
 
127
        
 
128
        QList<SxeEdit*> edits_;
 
129
        QList<VersionData*> versions_;
 
130
        QDomNode node_;
 
131
        QString rid_;
 
132
        int version_;
 
133
};
 
134
 
 
135
#endif