Add line for debugging
[kdevelopdvcssupport.git] / vcs / vcsannotation.cpp
blob99f6b061a6b7b8147b6e7f4584d94d7beb9d6b95
1 /***************************************************************************
2 * This file is part of KDevelop *
3 * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License as *
7 * published by the Free Software Foundation; either version 2 of the *
8 * 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 Library General Public *
16 * License along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "vcsannotation.h"
23 #include <QtCore/QDateTime>
24 #include <QtCore/QHash>
25 #include <kurl.h>
27 #include "vcsrevision.h"
29 namespace KDevelop
32 class VcsAnnotationPrivate
34 public:
35 QHash<int, VcsAnnotationLine> lines;
36 KUrl location;
39 class VcsAnnotationLinePrivate
41 public:
42 QString author;
43 QDateTime date;
44 QString text;
45 QString line;
46 VcsRevision revision;
47 int lineno;
50 VcsAnnotationLine::VcsAnnotationLine()
51 : d( new VcsAnnotationLinePrivate )
53 d->lineno = -1;
56 VcsAnnotationLine::VcsAnnotationLine( const VcsAnnotationLine& rhs )
57 : d( new VcsAnnotationLinePrivate )
59 d->author = rhs.d->author;
60 d->line = rhs.d->line;
61 d->revision = rhs.d->revision;
62 d->lineno = rhs.d->lineno;
63 d->date = rhs.d->date;
64 d->text = rhs.d->text;
67 VcsAnnotationLine::~VcsAnnotationLine()
69 delete d;
72 int VcsAnnotationLine::lineNumber() const
74 return d->lineno;
77 QString VcsAnnotationLine::text() const
79 return d->text;
82 QString VcsAnnotationLine::author() const
84 return d->author;
87 VcsRevision VcsAnnotationLine::revision() const
89 return d->revision;
92 QDateTime VcsAnnotationLine::date() const
94 return d->date;
97 void VcsAnnotationLine::setLineNumber( int lineno )
99 d->lineno = lineno;
102 void VcsAnnotationLine::setText( const QString& text )
104 d->text = text;
107 void VcsAnnotationLine::setAuthor( const QString& author )
109 d->author = author;
112 void VcsAnnotationLine::setRevision( const VcsRevision& revision )
114 d->revision = revision;
117 void VcsAnnotationLine::setDate( const QDateTime& date )
119 d->date = date;
122 VcsAnnotationLine& VcsAnnotationLine::operator=( const VcsAnnotationLine& rhs)
124 if(this == &rhs)
125 return *this;
126 d->author = rhs.d->author;
127 d->line = rhs.d->line;
128 d->revision = rhs.d->revision;
129 d->lineno = rhs.d->lineno;
130 d->date = rhs.d->date;
131 d->text = rhs.d->text;
132 return *this;
135 VcsAnnotation::VcsAnnotation()
136 : d(new VcsAnnotationPrivate)
140 VcsAnnotation::VcsAnnotation( const VcsAnnotation& rhs )
141 : d(new VcsAnnotationPrivate)
143 d->lines = rhs.d->lines;
144 d->location = rhs.d->location;
147 VcsAnnotation::~VcsAnnotation()
149 delete d;
152 KUrl VcsAnnotation::location() const
154 return d->location;
157 int VcsAnnotation::lineCount() const
159 return d->lines.count();
162 void VcsAnnotation::insertLine( int lineno, const VcsAnnotationLine& line )
164 if( lineno < 0 )
166 return;
168 d->lines.insert( lineno, line );
171 void VcsAnnotation::setLocation(const KUrl& u)
173 d->location = u;
176 VcsAnnotationLine VcsAnnotation::line( int lineno ) const
178 return d->lines[lineno];
181 VcsAnnotation& VcsAnnotation::operator=( const VcsAnnotation& rhs)
183 if(this == &rhs)
184 return *this;
185 d->location = rhs.d->location;
186 d->lines = rhs.d->lines;
187 return *this;