File indexing completed on 2024-04-28 04:37:45

0001 /*
0002     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "vcsannotation.h"
0008 
0009 #include <QSharedData>
0010 #include <QDateTime>
0011 #include <QHash>
0012 #include <QUrl>
0013 
0014 #include "vcsrevision.h"
0015 
0016 namespace KDevelop
0017 {
0018 
0019 class VcsAnnotationPrivate : public QSharedData
0020 {
0021 public:
0022     QHash<int, VcsAnnotationLine> lines;
0023     QUrl location;
0024 };
0025 
0026 class VcsAnnotationLinePrivate : public QSharedData
0027 {
0028 public:
0029     QString author;
0030     QDateTime date;
0031     QString text;
0032     QString line;
0033     VcsRevision revision;
0034     QString message;
0035     int lineno;
0036 };
0037 
0038 VcsAnnotationLine::VcsAnnotationLine()
0039     : d( new VcsAnnotationLinePrivate )
0040 {
0041     d->lineno = -1;
0042 }
0043 
0044 VcsAnnotationLine::VcsAnnotationLine( const VcsAnnotationLine& rhs )
0045     : d(rhs.d)
0046 {
0047 }
0048 
0049 VcsAnnotationLine::~VcsAnnotationLine() = default;
0050 
0051 int VcsAnnotationLine::lineNumber() const
0052 {
0053     return d->lineno;
0054 }
0055 
0056 QString VcsAnnotationLine::text() const
0057 {
0058     return d->text;
0059 }
0060 
0061 QString VcsAnnotationLine::author() const
0062 {
0063     return d->author;
0064 }
0065 
0066 VcsRevision VcsAnnotationLine::revision() const
0067 {
0068     return d->revision;
0069 }
0070 
0071 QDateTime VcsAnnotationLine::date() const
0072 {
0073     return d->date;
0074 }
0075 
0076 void VcsAnnotationLine::setLineNumber( int lineno )
0077 {
0078     d->lineno = lineno;
0079 }
0080 
0081 void VcsAnnotationLine::setText( const QString& text )
0082 {
0083     d->text = text;
0084 }
0085 
0086 void VcsAnnotationLine::setAuthor( const QString& author )
0087 {
0088     d->author = author;
0089 }
0090 
0091 void KDevelop::VcsAnnotationLine::setRevision( const KDevelop::VcsRevision& revision )
0092 {
0093     d->revision = revision;
0094 }
0095 
0096 void VcsAnnotationLine::setDate( const QDateTime& date )
0097 {
0098     d->date = date;
0099 }
0100 
0101 VcsAnnotationLine& VcsAnnotationLine::operator=( const VcsAnnotationLine& rhs)
0102 {
0103     d = rhs.d;
0104     return *this;
0105 }
0106 
0107 QString VcsAnnotationLine::commitMessage() const
0108 {
0109     return d->message;
0110 }
0111 
0112 
0113 void VcsAnnotationLine::setCommitMessage ( const QString& msg )
0114 {
0115     d->message = msg;
0116 }
0117 
0118 VcsAnnotation::VcsAnnotation()
0119     : d(new VcsAnnotationPrivate)
0120 {
0121 }
0122 
0123 VcsAnnotation::VcsAnnotation( const VcsAnnotation& rhs )
0124     : d(rhs.d)
0125 {
0126 }
0127 
0128 VcsAnnotation::~VcsAnnotation() = default;
0129 
0130 QUrl VcsAnnotation::location() const
0131 {
0132     return d->location;
0133 }
0134 
0135 int VcsAnnotation::lineCount() const
0136 {
0137     return d->lines.count();
0138 }
0139 
0140 void VcsAnnotation::insertLine( int lineno, const VcsAnnotationLine& line )
0141 {
0142     if( lineno < 0 )
0143     {
0144         return;
0145     }
0146     d->lines.insert( lineno, line );
0147 }
0148 
0149 void VcsAnnotation::setLocation(const QUrl& u)
0150 {
0151     d->location = u;
0152 }
0153 
0154 VcsAnnotationLine VcsAnnotation::line( int lineno ) const
0155 {
0156     return d->lines[lineno];
0157 }
0158 
0159 VcsAnnotation& VcsAnnotation::operator=( const VcsAnnotation& rhs)
0160 {
0161     d = rhs.d;
0162     return *this;
0163 }
0164 
0165 bool VcsAnnotation::containsLine( int lineno ) const
0166 {
0167     return d->lines.contains( lineno );
0168 }
0169 
0170 }
0171