This repository was archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWorkingTreeFileItem.cpp
More file actions
139 lines (115 loc) · 3.19 KB
/
WorkingTreeFileItem.cpp
File metadata and controls
139 lines (115 loc) · 3.19 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
* MacGitver
* Copyright (C) 2012 Sascha Cunz <sascha@babbelbox.org>
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License (Version 2) as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, see <http://www.gnu.org/licenses/>.
*
*/
#include <QVariant>
#include <QColor>
#include "WorkingTreeFileItem.h"
WorkingTreeFileItem::WorkingTreeFileItem( WorkingTreeModel* model, WorkingTreeAbstractItem* parent )
: WorkingTreeAbstractItem( model, parent )
, mSize( 0 )
, mState( Git::FileInvalidStatus )
{
}
WorkingTreeFileItem::~WorkingTreeFileItem()
{
}
int WorkingTreeFileItem::childCount() const
{
return 0;
}
WorkingTreeAbstractItem* WorkingTreeFileItem::childAt( int index )
{
Q_UNUSED( index );
return NULL;
}
QVariant WorkingTreeFileItem::data( int column, int role ) const
{
switch( role )
{
case Qt::DisplayRole:
switch( column )
{
case 0: return mName;
case 1: return mSize;
case 2: return mLastMod;
case 3: return mOwner;
}
break;
case Qt::DecorationRole:
if( column == 0 )
return mIcon;
break;
case Qt::ForegroundRole:
if( mState & Git::FileUnchanged ) return QColor( Qt::black );
else if( mState & Git::FileWorkingTreeModified ) return QColor( Qt::blue );
else if( mState & Git::FileWorkingTreeNew ) return QColor( Qt::darkGreen );
else if( mState & Git::FileWorkingTreeDeleted ) return QColor( Qt::red );
else if( mState & Git::FileIgnored ) return QColor( Qt::gray );
else return QColor( 0xFFCCFF );
case WorkingTreeAbstractItem::StatusRole:
return int( mState );
default:
break;
}
return QVariant();
}
WorkingTreeAbstractItem* WorkingTreeFileItem::parent()
{
return mParent;
}
int WorkingTreeFileItem::row() const
{
return 0;
}
WorkingTreeAbstractItem* WorkingTreeFileItem::childByName( const QString& name )
{
return NULL;
}
bool WorkingTreeFileItem::isDirectory() const
{
return false;
}
void WorkingTreeFileItem::setName( const QString& name )
{
mName = name;
}
void WorkingTreeFileItem::setState( Git::StatusFlags state )
{
mState = state;
}
void WorkingTreeFileItem::setIcon( const QIcon& icon )
{
mIcon = icon;
}
void WorkingTreeFileItem::setSize( qint64 size )
{
mSize = size;
}
void WorkingTreeFileItem::setOwner( const QString& owner )
{
mOwner = owner;
}
void WorkingTreeFileItem::setLastModified( const QDateTime& lastMod )
{
mLastMod = lastMod;
}
QString WorkingTreeFileItem::name() const
{
return mName;
}
void WorkingTreeFileItem::removeChild( WorkingTreeAbstractItem* child )
{
Q_UNUSED( child );
}