~neon/plasmate/frameworks

« back to all changes in this revision

Viewing changes to plasmate/plugins/savesystemview/commitsmodel.cpp

  • Committer: Giorgos Tsiapaliokas
  • Date: 2015-03-14 12:58:48 UTC
  • mfrom: (972.1.19)
  • Revision ID: git-v1:7b24cb2599e2bea0612cb492d2395bb6c44722ed
Merge branch 'review_savesystem_updated' into frameworks

REVIEW: 121206

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2014 Giorgos Tsiapaliokas <giorgos.tsiapaliokas@kde.org>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License as published by the Free Software Foundation; either
 
7
    version 2 of the License, or (at your option) any later version.
 
8
 
 
9
    This library is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
    Library General Public License for more details.
 
13
 
 
14
    You should have received a copy of the GNU Library General Public License
 
15
    along with this library; see the file COPYING.LIB.  If not, write to
 
16
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
    Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
#include "commitsmodel.h"
 
21
#include "git.h"
 
22
 
 
23
#include <QDateTime>
 
24
 
 
25
CommitsModel::CommitsModel(Git* parent)
 
26
    : QIdentityProxyModel(parent),
 
27
      m_git(parent)
 
28
{
 
29
}
 
30
 
 
31
CommitsModel::~CommitsModel()
 
32
{
 
33
}
 
34
 
 
35
QVariant CommitsModel::data(const QModelIndex &index, int role) const
 
36
{
 
37
    int column;
 
38
    switch(role) {
 
39
        case Author:
 
40
            column = 2;
 
41
            break;
 
42
        case Date:
 
43
            column = 3;
 
44
            break;
 
45
        case Message:
 
46
            column = 1;
 
47
            break;
 
48
        default:
 
49
            return QVariant();
 
50
    }
 
51
 
 
52
    QModelIndex idx = sourceModel()->index(index.row(), column);
 
53
    return sourceModel()->data(idx, Qt::DisplayRole);
 
54
}
 
55
 
 
56
QHash<int, QByteArray> CommitsModel::roleNames() const
 
57
{
 
58
    QHash<int, QByteArray> roleNames;
 
59
    roleNames[CommitsModel::Author] = "author";
 
60
    roleNames[CommitsModel::Date] = "CommitDate";
 
61
    roleNames[CommitsModel::Message] = "message";
 
62
 
 
63
    return roleNames;
 
64
}
 
65