forked from bdenne2/gitit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitchangedstatusmodel.cpp
39 lines (37 loc) · 1.09 KB
/
gitchangedstatusmodel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "gitchangedstatusmodel.h"
#include <QSettings>
GitChangedStatusModel::GitChangedStatusModel(QObject *parent) :
QAbstractListModel(parent),
fileList(new QStringList)
{
}
GitChangedStatusModel::~GitChangedStatusModel()
{
delete fileList;
}
int GitChangedStatusModel::rowCount(const QModelIndex & /* parent */) const
{
return fileList->count();
}
QVariant GitChangedStatusModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= fileList->count() || index.row() < 0)
return QVariant();
if (role == Qt::DisplayRole)
{
return (*fileList)[index.row()];
}
return QVariant();
}
void GitChangedStatusModel::update(QStringList files)
{
QRegExp rx("^(.\\S).*$"); // " M filname" "MM filename" "AM filename"
rx.setPatternSyntax(QRegExp::RegExp2);
*fileList = files.filter(rx);
QRegExp awesome("^...");
awesome.setPatternSyntax(QRegExp::RegExp2);
fileList->replaceInStrings( awesome, "" );
emit dataChanged( createIndex(0,0), createIndex( fileList->count() ,0 ) );
}