1 /***************************************************************************
2 * This file is part of KDevelop *
3 * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
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. *
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. *
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>
27 #include "vcsrevision.h"
32 class VcsAnnotationPrivate
35 QHash
<int, VcsAnnotationLine
> lines
;
39 class VcsAnnotationLinePrivate
50 VcsAnnotationLine::VcsAnnotationLine()
51 : d( new VcsAnnotationLinePrivate
)
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()
72 int VcsAnnotationLine::lineNumber() const
77 QString
VcsAnnotationLine::text() const
82 QString
VcsAnnotationLine::author() const
87 VcsRevision
VcsAnnotationLine::revision() const
92 QDateTime
VcsAnnotationLine::date() const
97 void VcsAnnotationLine::setLineNumber( int lineno
)
102 void VcsAnnotationLine::setText( const QString
& text
)
107 void VcsAnnotationLine::setAuthor( const QString
& author
)
112 void VcsAnnotationLine::setRevision( const VcsRevision
& revision
)
114 d
->revision
= revision
;
117 void VcsAnnotationLine::setDate( const QDateTime
& date
)
122 VcsAnnotationLine
& VcsAnnotationLine::operator=( const VcsAnnotationLine
& rhs
)
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
;
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()
152 KUrl
VcsAnnotation::location() const
157 int VcsAnnotation::lineCount() const
159 return d
->lines
.count();
162 void VcsAnnotation::insertLine( int lineno
, const VcsAnnotationLine
& line
)
168 d
->lines
.insert( lineno
, line
);
171 void VcsAnnotation::setLocation(const KUrl
& u
)
176 VcsAnnotationLine
VcsAnnotation::line( int lineno
) const
178 return d
->lines
[lineno
];
181 VcsAnnotation
& VcsAnnotation::operator=( const VcsAnnotation
& rhs
)
185 d
->location
= rhs
.d
->location
;
186 d
->lines
= rhs
.d
->lines
;