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

0001 /*
0002     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0003     SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KDEVPLATFORM_VCSANNOTATION_H
0009 #define KDEVPLATFORM_VCSANNOTATION_H
0010 
0011 #include "vcsexport.h"
0012 #include <QMetaType>
0013 #include <QSharedDataPointer>
0014 
0015 class QString;
0016 class QDateTime;
0017 class QUrl;
0018 
0019 namespace KDevelop
0020 {
0021 class VcsRevision;
0022 
0023 /**
0024  * Annotation information for a line of a version controlled file
0025  */
0026 class KDEVPLATFORMVCS_EXPORT VcsAnnotationLine
0027 {
0028 public:
0029     VcsAnnotationLine();
0030     VcsAnnotationLine( const VcsAnnotationLine& );
0031     virtual ~VcsAnnotationLine();
0032     /**
0033      * @return the line number of this annotation line
0034      */
0035     int lineNumber() const;
0036     /**
0037      * @return the text of this line
0038      */
0039     QString text() const;
0040     /**
0041      * @return the author that last changed this line
0042      */
0043     QString author() const;
0044     /**
0045      * @return the revision this line was last changed
0046      */
0047     VcsRevision revision() const;
0048     /**
0049      * @return the date of the last change to this line
0050      */
0051     QDateTime date() const;
0052     /**
0053      * @return the commit message of the revision in this line
0054      */
0055     QString commitMessage() const;
0056     /**
0057      * set the line number of this annotation line
0058      * @param lineno the line number
0059      */
0060     void setLineNumber( int lineno );
0061     /**
0062      * set the text of this annotation line
0063      * @param text the text of the line
0064      */
0065     void setText( const QString& text );
0066     /**
0067      * set the author of this annotation line
0068      * @param author the author of the last change
0069      */
0070     void setAuthor( const QString& author );
0071     /**
0072      * set the revision of this annotation line
0073      * @param revision the revision of the last change
0074      */
0075     void setRevision( const VcsRevision& revision );
0076     /**
0077      * set the date of this annotation line
0078      * @param date the date of the last change
0079      */
0080     void setDate( const QDateTime& date );
0081     /**
0082      * set the commit message of the revision in this
0083      * line
0084      * @param msg the message of the commit
0085      */
0086     void setCommitMessage( const QString& msg );
0087     
0088     VcsAnnotationLine& operator=( const VcsAnnotationLine& rhs);
0089 
0090 private:
0091     QSharedDataPointer<class VcsAnnotationLinePrivate> d;
0092 };
0093 
0094 /**
0095  * Annotations for a local file.
0096  *
0097  * This class lets the user fetch information for each line of a local file,
0098  * including date of last change, author of last change and revision of
0099  * last change to the line.
0100  */
0101 class KDEVPLATFORMVCS_EXPORT VcsAnnotation
0102 {
0103 public:
0104     VcsAnnotation();
0105     VcsAnnotation(const VcsAnnotation&);
0106     virtual ~VcsAnnotation();
0107     /**
0108      * @return the local url of the file
0109      */
0110     QUrl location() const;
0111     /**
0112      * @return the number of lines in the file
0113      */
0114     int lineCount() const;
0115 
0116     /**
0117      * retrieve the annotation line for the given number
0118      */
0119     VcsAnnotationLine line( int linenumber ) const;
0120 
0121     /**
0122      * insert a new line to list of lines using
0123      * the parameters
0124      *
0125      * @param lineno the line for which to insert the content
0126      * @param line the annotation line that should be inserted
0127      *
0128      */
0129     void insertLine( int lineno, const VcsAnnotationLine& line );
0130 
0131     /**
0132      * @param location the location of the file
0133      */
0134     void setLocation( const QUrl& location );
0135 
0136     bool containsLine( int lineno ) const;
0137 
0138     VcsAnnotation& operator=( const VcsAnnotation& rhs);
0139 
0140 private:
0141     QSharedDataPointer<class VcsAnnotationPrivate> d;
0142 };
0143 
0144 }
0145 
0146 Q_DECLARE_METATYPE( KDevelop::VcsAnnotation )
0147 Q_DECLARE_TYPEINFO( KDevelop::VcsAnnotation, Q_MOVABLE_TYPE );
0148 Q_DECLARE_METATYPE( KDevelop::VcsAnnotationLine )
0149 Q_DECLARE_TYPEINFO( KDevelop::VcsAnnotationLine, Q_MOVABLE_TYPE);
0150 
0151 #endif
0152