diff --git a/kdevplatform/vcs/vcsdiff.cpp b/kdevplatform/vcs/vcsdiff.cpp index b8f0f4a3e8..e4b98aecd0 100644 --- a/kdevplatform/vcs/vcsdiff.cpp +++ b/kdevplatform/vcs/vcsdiff.cpp @@ -1,185 +1,185 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * * * * This program 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 program 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 General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "vcsdiff.h" #include #include #include namespace KDevelop { class VcsDiffPrivate { public: QHash leftBinaries; QHash rightBinaries; QHash leftTexts; QHash rightTexts; QUrl baseDiff; QString diff; VcsDiff::Type type = VcsDiff::DiffDontCare; VcsDiff::Content content = VcsDiff::Text; uint depth = 0; }; VcsDiff::VcsDiff() : d(new VcsDiffPrivate) { } VcsDiff::~VcsDiff() = default; VcsDiff::VcsDiff( const VcsDiff& rhs ) : d(new VcsDiffPrivate) { *d = *rhs.d; } bool VcsDiff::isEmpty() const { return d->diff.isEmpty() && d->leftBinaries.isEmpty() && d->rightBinaries.isEmpty() && d->leftTexts.isEmpty() && d->rightTexts.isEmpty(); } VcsDiff::Type VcsDiff::type() const { return d->type; } VcsDiff::Content VcsDiff::contentType() const { return d->content; } QHash VcsDiff::leftBinaries() const { return d->leftBinaries; } QHash VcsDiff::rightBinaries() const { return d->rightBinaries; } QHash VcsDiff::leftTexts() const { return d->leftTexts; } QHash VcsDiff::rightTexts() const { return d->rightTexts; } QString VcsDiff::diff() const { return d->diff; } void VcsDiff::setDiff( const QString& s ) { d->diff = s; } void VcsDiff::addLeftBinary( const VcsLocation& loc, const QByteArray& b ) { d->leftBinaries[loc] = b; } void VcsDiff::addRightBinary( const VcsLocation& loc, const QByteArray& b ) { d->rightBinaries[loc] = b; } void VcsDiff::removeLeftBinary( const VcsLocation& loc ) { d->leftBinaries.remove( loc ); } void VcsDiff::removeRightBinary( const VcsLocation& loc ) { d->rightBinaries.remove( loc ); } void VcsDiff::addLeftText( const VcsLocation& loc, const QString& b ) { d->leftTexts[loc] = b; } void VcsDiff::addRightText( const VcsLocation& loc, const QString& b ) { d->rightTexts[loc] = b; } void VcsDiff::removeLeftText( const VcsLocation& loc ) { d->leftTexts.remove( loc ); } void VcsDiff::removeRightText( const VcsLocation& loc ) { d->rightTexts.remove( loc ); } void VcsDiff::setType( VcsDiff::Type t ) { d->type = t; } void VcsDiff::setContentType( VcsDiff::Content c ) { d->content = c; } VcsDiff& VcsDiff::operator=( const VcsDiff& rhs) { if (this != &rhs) { *d = *rhs.d; } return *this; } QUrl VcsDiff::baseDiff() const { return d->baseDiff; } uint VcsDiff::depth() const { return d->depth; } -void VcsDiff::setBaseDiff(const QUrl& url) const +void VcsDiff::setBaseDiff(const QUrl& url) { d->baseDiff=url; } -void VcsDiff::setDepth(const uint depth) const +void VcsDiff::setDepth(const uint depth) { d->depth = depth; } } diff --git a/kdevplatform/vcs/vcsdiff.h b/kdevplatform/vcs/vcsdiff.h index fd0bd51c74..16a72f8d1f 100644 --- a/kdevplatform/vcs/vcsdiff.h +++ b/kdevplatform/vcs/vcsdiff.h @@ -1,145 +1,145 @@ /* This file is part of KDevelop * * Copyright 2007 Andreas Pakulat * Copyright 2007 Matthew Woehlke * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #ifndef KDEVPLATFORM_VCSDIFF_H #define KDEVPLATFORM_VCSDIFF_H //Needed first as it provides a hash-function for QHash #include "vcslocation.h" #include #include "vcsexport.h" class QString; class QByteArray; namespace KDevelop { class KDEVPLATFORMVCS_EXPORT VcsDiff { public: /** * Specify the type of difference the diff() method should create. Note that a * request for DiffUnified may not be honored, e.g. if the items being diffed are * binary rather than text. */ enum Type { DiffRaw /**< Request complete copies of both items. */, DiffUnified /**< Request copy of first item with diff. */, DiffDontCare /**< Don't care; plugin will return whichever is easiest. */ }; enum Content { Binary /**< Binary diff, using the full content of both files.*/, Text /**< Textual diff.*/ }; VcsDiff(); virtual ~VcsDiff(); VcsDiff( const VcsDiff& ); /** * @returns the type of diff, i.e. raw or unified */ Type type() const; /** * @returns the content type, i.e. binary or text */ Content contentType() const; /** * @returns the binary content of the first file of the difference or * an empty QByteArray if this is a textual diff */ QHash leftBinaries() const; /** * @returns the binary content of the second file of the difference or * an empty QByteArray if this is a textual diff */ QHash rightBinaries() const; /** * @returns the textual content of the first file of the difference or * an empty QString if this is a binary diff */ QHash leftTexts() const; /** * @returns the textual content of the second file of the difference or * an empty QString if this is a unified or binary diff */ QHash rightTexts() const; /** * @returns the difference between the first and the second file in * unified diff format or an empty QString if this is a binary diff * or a textual diff using raw format */ QString diff() const; /** @returns the base directory of the diff. */ QUrl baseDiff() const; /** * Depth - number of directories to left-strip from paths in the patch - see "patch -p" * Defaults to 0 */ uint depth() const; /** Sets the base directory of the diff to the @p url */ - void setBaseDiff(const QUrl& url) const; + void setBaseDiff(const QUrl& url); /** Sets the depth of the diff to @p depth */ - void setDepth(const uint depth) const; + void setDepth(const uint depth); void setDiff( const QString& ); void addLeftBinary( const KDevelop::VcsLocation&, const QByteArray& ); void removeLeftBinary( const KDevelop::VcsLocation& ); void addRightBinary( const KDevelop::VcsLocation&, const QByteArray& ); void removeRightBinary( const KDevelop::VcsLocation& ); void addLeftText( const KDevelop::VcsLocation&, const QString& ); void removeLeftText( const KDevelop::VcsLocation& ); void addRightText( const KDevelop::VcsLocation&, const QString& ); void removeRightText( const KDevelop::VcsLocation& ); void setType( Type ); void setContentType( Content ); VcsDiff& operator=( const VcsDiff& rhs); /** @returns whether there are not changes on the diff */ bool isEmpty() const; private: const QScopedPointer d; }; } Q_DECLARE_METATYPE( KDevelop::VcsDiff ) #endif