Commit 4653a602 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Show status and count in the second column

parent 892b94ca
......@@ -31,62 +31,62 @@ GitUtils::GitParsedStatus GitUtils::parseStatus(const QByteArray &raw)
switch (xy) {
case StatusXY::QQ:
untracked.append({QString::fromUtf8(file, size), GitStatus::Untracked});
untracked.append({QString::fromUtf8(file, size), GitStatus::Untracked, 'U'});
break;
case StatusXY::II:
untracked.append({QString::fromUtf8(file, size), GitStatus::Ignored});
untracked.append({QString::fromUtf8(file, size), GitStatus::Ignored, 'I'});
break;
case StatusXY::DD:
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_BothDeleted});
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_BothDeleted, x});
break;
case StatusXY::AU:
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_AddedByUs});
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_AddedByUs, x});
break;
case StatusXY::UD:
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_DeletedByThem});
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_DeletedByThem, x});
break;
case StatusXY::UA:
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_AddedByThem});
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_AddedByThem, x});
break;
case StatusXY::DU:
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_DeletedByUs});
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_DeletedByUs, x});
break;
case StatusXY::AA:
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_BothAdded});
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_BothAdded, x});
break;
case StatusXY::UU:
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_BothModified});
unmerge.append({QString::fromUtf8(file, size), GitStatus::Unmerge_BothModified, x});
break;
}
switch (x) {
case 'M':
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Modified});
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Modified, x});
break;
case 'A':
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Added});
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Added, x});
break;
case 'D':
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Deleted});
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Deleted, x});
break;
case 'R':
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Renamed});
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Renamed, x});
break;
case 'C':
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Copied});
staged.append({QString::fromUtf8(file, size), GitStatus::Index_Copied, x});
break;
}
switch (y) {
case 'M':
changed.append({QString::fromUtf8(file, size), GitStatus::WorkingTree_Modified});
changed.append({QString::fromUtf8(file, size), GitStatus::WorkingTree_Modified, y});
break;
case 'D':
changed.append({QString::fromUtf8(file, size), GitStatus::WorkingTree_Deleted});
changed.append({QString::fromUtf8(file, size), GitStatus::WorkingTree_Deleted, y});
break;
case 'A':
changed.append({QString::fromUtf8(file, size), GitStatus::WorkingTree_IntentToAdd});
changed.append({QString::fromUtf8(file, size), GitStatus::WorkingTree_IntentToAdd, y});
break;
}
}
......
......@@ -30,8 +30,6 @@ enum GitStatus {
WorkingTree_Deleted,
WorkingTree_IntentToAdd,
IndexWorkingTree_Modified,
Untracked,
Ignored
};
......@@ -45,17 +43,6 @@ enum StatusXY {
AA = 0x4141,
UU = 0x5555,
/* underscore represents space */
// M_ = 0x4d20,
// A_ = 0x4120,
// D_ = 0x4420,
// R_ = 0x5220,
// C_ = 0x4320,
// _M = 0x204d,
// _D = 0x2044,
// _A = 0x2041,
//??
QQ = 0x3f3f,
//!!
......@@ -65,6 +52,7 @@ enum StatusXY {
struct StatusItem {
QString file;
GitStatus status;
char statusChar;
};
struct GitParsedStatus {
......
......@@ -64,7 +64,7 @@ int GitStatusModel::rowCount(const QModelIndex &parent) const
int GitStatusModel::columnCount(const QModelIndex &) const
{
return 1;
return 2;
}
QVariant GitStatusModel::data(const QModelIndex &index, int role) const
......@@ -77,16 +77,20 @@ QVariant GitStatusModel::data(const QModelIndex &index, int role) const
if (index.internalId() == Root) {
if (role == Qt::DisplayRole) {
if (row == Staged) {
return i18n("Staged (%1)", m_nodes[Staged].count());
} else if (row == Untrack) {
return i18n("Untracked (%1)", m_nodes[Untrack].count());
} else if (row == Conflict) {
return i18n("Conflict (%1)", m_nodes[Conflict].count());
} else if (row == Changed) {
return i18n("Modified (%1)", m_nodes[Changed].count());
if (index.column() == 1) {
return QString::number(m_nodes[row].count());
} else {
Q_UNREACHABLE();
if (row == Staged) {
return i18n("Staged");
} else if (row == Untrack) {
return i18n("Untracked");
} else if (row == Conflict) {
return i18n("Conflict");
} else if (row == Changed) {
return i18n("Modified");
} else {
Q_UNREACHABLE();
}
}
} else if (role == Qt::FontRole) {
QFont bold;
......@@ -97,6 +101,12 @@ QVariant GitStatusModel::data(const QModelIndex &index, int role) const
return branchIcon;
} else if (role == Role::TreeItemType) {
return NodeStage + row;
} else if (role == Qt::TextAlignmentRole) {
if (index.column() == 0) {
return Qt::AlignLeft;
} else {
return Qt::AlignRight;
}
}
} else {
int rootIndex = index.internalId();
......@@ -110,6 +120,12 @@ QVariant GitStatusModel::data(const QModelIndex &index, int role) const
return QIcon::fromTheme(QMimeDatabase().mimeTypeForFile(m_nodes[rootIndex].at(row).file, QMimeDatabase::MatchExtension).iconName());
} else if (role == Role::TreeItemType) {
return ItemType::NodeFile;
} else if (role == Qt::TextAlignmentRole) {
if (index.column() == 0) {
return Qt::AlignLeft;
} else {
return Qt::AlignRight;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment