[kdevplatform] vcs/models: Show author name and year instead of revision number in the vcs annotation
Sven Brauch
svenbrauch at googlemail.com
Sun Mar 2 22:44:11 UTC 2014
Git commit bbefbc6d0f297339c652230c6559f17d1dc7ac6c by Sven Brauch.
Committed on 02/03/2014 at 18:23.
Pushed by brauch into branch 'master'.
Show author name and year instead of revision number in the vcs annotation
CCMAIL:kdevelop-devel at kde.org
M +10 -1 vcs/models/vcsannotationmodel.cpp
http://commits.kde.org/kdevplatform/bbefbc6d0f297339c652230c6559f17d1dc7ac6c
diff --git a/vcs/models/vcsannotationmodel.cpp b/vcs/models/vcsannotationmodel.cpp
index 3506a40..afcbfdc 100644
--- a/vcs/models/vcsannotationmodel.cpp
+++ b/vcs/models/vcsannotationmodel.cpp
@@ -96,6 +96,12 @@ VcsAnnotationModel::~VcsAnnotationModel()
delete d;
}
+static QString abbreviateLastName(const QString& author) {
+ auto parts = author.split(' ');
+ bool onlyOneFragment = parts.size() == 1 || ( parts.size() == 2 && parts.at(1).isEmpty() );
+ return onlyOneFragment ? parts.first() : parts.first() + QString(" %1.").arg(parts.last()[0]);
+}
+
QVariant VcsAnnotationModel::data( int line, Qt::ItemDataRole role ) const
{
if( line < 0 || !d->m_annotation.containsLine( line ) )
@@ -113,7 +119,10 @@ QVariant VcsAnnotationModel::data( int line, Qt::ItemDataRole role ) const
return QVariant( d->m_brushes[aline.revision()] );
} else if( role == Qt::DisplayRole )
{
- return QVariant( aline.revision().revisionValue() );
+ return QVariant( QString("%1 ").arg(aline.date().date().year()) + abbreviateLastName(aline.author()) );
+ } else if( role == Qt::UserRole ) // TODO KDE5: replace by KTextEditor::AnnotationModel::GroupIdentifierRole
+ {
+ return aline.revision().revisionValue();
} else if( role == Qt::ToolTipRole )
{
return QVariant( i18n("Author: %1\nDate: %2\nCommit Message: %3",
More information about the KDevelop-devel
mailing list