File indexing completed on 2024-03-24 16:13:25

0001 /** ===========================================================
0002  * @file
0003  *
0004  * This file is a part of KDE project
0005  * <a href="https://commits.kde.org/libmediawiki">libmediawiki</a>
0006  *
0007  * @date   2011-03-22
0008  * @brief  a MediaWiki C++ interface for KDE
0009  *
0010  * @author Copyright (C) 2011-2012 by Gilles Caulier
0011  *         <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
0012  * @author Copyright (C) 2010 by Robin Bussenot
0013  *         <a href="mailto:bussenot dot robin at gmail dot com">bussenot dot robin at gmail dot com</a>
0014  *
0015  * This program is free software; you can redistribute it
0016  * and/or modify it under the terms of the GNU General
0017  * Public License as published by the Free Software Foundation;
0018  * either version 2, or (at your option)
0019  * any later version.
0020  *
0021  * This program is distributed in the hope that it will be useful,
0022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0024  * GNU General Public License for more details.
0025  *
0026  * ============================================================ */
0027 
0028 #include "revision.h"
0029 
0030 // C++ includes
0031 
0032 #include <algorithm>
0033 
0034 namespace mediawiki
0035 {
0036 
0037 class Q_DECL_HIDDEN Revision::RevisionPrivate
0038 {
0039 public:
0040 
0041     int       revId;
0042     int       parentId;
0043     int       size;
0044     bool      minorRevision;
0045     QString   user;
0046     QDateTime timestamp;
0047     QString   comment;
0048     QString   content;
0049     QString   parseTree;
0050     QString   rollback;
0051 };
0052 
0053 Revision::Revision()
0054     : d(new RevisionPrivate())
0055 {
0056     d->minorRevision = false;
0057     d->revId         = -1;
0058     d->parentId      = -1;
0059     d->size          = -1;
0060 }
0061 
0062 Revision::~Revision()
0063 {
0064     delete d;
0065 }
0066 
0067 Revision::Revision( const Revision& other)
0068         : d(new RevisionPrivate(*(other.d)))
0069 {
0070 }
0071 
0072 Revision& Revision::operator=(Revision other)
0073 {
0074     *d = *other.d;
0075     return *this;
0076 }
0077 
0078 bool Revision::operator==(const Revision& other) const
0079 {
0080     return timestamp()     == other.timestamp()     &&
0081            user()          == other.user()          &&
0082            comment()       == other.comment()       &&
0083            content()       == other.content()       &&
0084            size()          == other.size()          &&
0085            minorRevision() == other.minorRevision() &&
0086            parseTree()     == other.parseTree()     &&
0087            parentId()      == other.parentId()      &&
0088            rollback()      == other.rollback()      &&
0089            revisionId()    == other.revisionId();
0090 }
0091 
0092 void Revision::setRevisionId(int revisionId)
0093 {
0094     d->revId=revisionId;
0095 }
0096 
0097 int Revision::revisionId() const
0098 {
0099     return d->revId;
0100 }
0101 
0102 void Revision::setParentId(int parentId)
0103 {
0104     d->parentId=parentId;
0105 }
0106 
0107 int Revision::parentId() const
0108 {
0109     return d->parentId;
0110 }
0111 
0112 void Revision::setSize(int size)
0113 {
0114     d->size=size;
0115 }
0116 
0117 int Revision::size() const
0118 {
0119     return d->size;
0120 }
0121 
0122 void Revision::setMinorRevision(bool minorRevision)
0123 {
0124     d->minorRevision=minorRevision;
0125 }
0126 bool Revision::minorRevision() const
0127 {
0128     return d->minorRevision;
0129 }
0130 
0131 QDateTime Revision::timestamp() const
0132 {
0133     return d->timestamp;
0134 }
0135 
0136 void Revision::setTimestamp(const QDateTime& timestamp)
0137 {
0138     d->timestamp = timestamp;
0139 }
0140 
0141 QString Revision::user() const
0142 {
0143     return d->user;
0144 }
0145 
0146 void Revision::setUser(const QString& user)
0147 {
0148     d->user = user;
0149 }
0150 
0151 void Revision::setComment(const QString& com)
0152 {
0153     d->comment = com;
0154 }
0155 
0156 QString Revision::comment() const
0157 {
0158     return d->comment;
0159 }
0160 
0161 QString Revision::content() const
0162 {
0163     return d->content;
0164 }
0165 
0166 void Revision::setContent(const QString& content)
0167 {
0168     d->content=content;
0169 }
0170 
0171 void Revision::setParseTree(const QString& parseTree)
0172 {
0173     d->parseTree=parseTree;
0174 }
0175 
0176 QString Revision::parseTree() const
0177 {
0178     return d->parseTree;
0179 }
0180 
0181 void Revision::setRollback(const QString& rollback)
0182 {
0183     d->parseTree=rollback;
0184 }
0185 
0186 QString Revision::rollback() const
0187 {
0188     return d->rollback;
0189 }
0190 
0191 } // namespace mediawiki