Commit 48f87e35 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Hide empty nodes

parent fc8aea4d
......@@ -124,3 +124,21 @@ void GitStatusModel::addItems(const QVector<GitUtils::StatusItem> &staged,
m_untracked = untracked;
endResetModel();
}
QVector<int> GitStatusModel::emptyRows()
{
QVector<int> empty;
if (m_staged.isEmpty()) {
empty.append(Staged);
}
if (m_untracked.isEmpty()) {
empty.append(Untrack);
}
if (m_unmerge.isEmpty()) {
empty.append(Conflict);
}
if (m_changed.isEmpty()) {
empty.append(Changed);
}
return empty;
}
......@@ -28,6 +28,7 @@ public:
const QVector<GitUtils::StatusItem> &changed,
const QVector<GitUtils::StatusItem> &unmerge,
const QVector<GitUtils::StatusItem> &untracked);
QVector<int> emptyRows();
private:
QVector<GitUtils::StatusItem> m_staged;
......
......@@ -150,8 +150,18 @@ GitWidget::GitParsedStatus GitWidget::parseStatus(const QByteArray &raw)
return {untracked, unmerge, staged, changed};
}
void GitWidget::hideEmptyTreeNodes()
{
const auto emptyRows = m_model->emptyRows();
for (const int row : emptyRows) {
m_treeView->setRowHidden(row, QModelIndex(), true);
}
}
void GitWidget::parseStatusReady()
{
GitParsedStatus s = m_gitStatusWatcher.result();
m_model->addItems(s.staged, s.changed, s.unmerge, s.untracked);
hideEmptyTreeNodes();
}
......@@ -37,6 +37,7 @@ private:
void getStatus(const QString &repo, bool submodules = false);
GitParsedStatus parseStatus(const QByteArray &raw);
void hideEmptyTreeNodes();
Q_SLOT void gitStatusReady();
Q_SLOT void parseStatusReady();
......
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