forked from qt-creator/qt-creator
Git: Use enums instead of numbers for branch root nodes
Change-Id: I52e9fce33c2a157389a88377e2f24695e8c3722d Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com> Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
e6de18eaab
commit
ea424a076c
@@ -361,7 +361,7 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
|
|||||||
parseOutputLine(l);
|
parseOutputLine(l);
|
||||||
|
|
||||||
if (m_currentBranch) {
|
if (m_currentBranch) {
|
||||||
if (m_currentBranch->parent == m_rootNode->children[0])
|
if (m_currentBranch->parent == m_rootNode->children.at(LocalBranches))
|
||||||
m_currentBranch = 0;
|
m_currentBranch = 0;
|
||||||
setCurrentBranch();
|
setCurrentBranch();
|
||||||
}
|
}
|
||||||
@@ -377,7 +377,7 @@ void BranchModel::setCurrentBranch()
|
|||||||
if (currentBranch.isEmpty())
|
if (currentBranch.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BranchNode *local = m_rootNode->children.at(0);
|
BranchNode *local = m_rootNode->children.at(LocalBranches);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (pos = 0; pos < local->count(); ++pos) {
|
for (pos = 0; pos < local->count(); ++pos) {
|
||||||
if (local->children.at(pos)->name == currentBranch) {
|
if (local->children.at(pos)->name == currentBranch) {
|
||||||
@@ -446,7 +446,7 @@ QStringList BranchModel::localBranchNames() const
|
|||||||
if (!m_rootNode || !m_rootNode->count())
|
if (!m_rootNode || !m_rootNode->count())
|
||||||
return QStringList();
|
return QStringList();
|
||||||
|
|
||||||
return m_rootNode->children.at(0)->childrenNames();
|
return m_rootNode->children.at(LocalBranches)->childrenNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BranchModel::sha(const QModelIndex &idx) const
|
QString BranchModel::sha(const QModelIndex &idx) const
|
||||||
@@ -583,7 +583,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchNode *local = m_rootNode->children.at(0);
|
BranchNode *local = m_rootNode->children.at(LocalBranches);
|
||||||
const int slash = name.indexOf(QLatin1Char('/'));
|
const int slash = name.indexOf(QLatin1Char('/'));
|
||||||
const QString leafName = slash == -1 ? name : name.mid(slash + 1);
|
const QString leafName = slash == -1 ? name : name.mid(slash + 1);
|
||||||
bool added = false;
|
bool added = false;
|
||||||
@@ -641,11 +641,11 @@ void BranchModel::parseOutputLine(const QString &line)
|
|||||||
|
|
||||||
BranchNode *root = 0;
|
BranchNode *root = 0;
|
||||||
if (nameParts.first() == QLatin1String("heads"))
|
if (nameParts.first() == QLatin1String("heads"))
|
||||||
root = m_rootNode->children.at(0); // Insert the local designator
|
root = m_rootNode->children.at(LocalBranches);
|
||||||
else if (nameParts.first() == QLatin1String("remotes"))
|
else if (nameParts.first() == QLatin1String("remotes"))
|
||||||
root = m_rootNode->children.at(1);
|
root = m_rootNode->children.at(RemoteBranches);
|
||||||
else if (showTags && nameParts.first() == QLatin1String("tags"))
|
else if (showTags && nameParts.first() == QLatin1String("tags"))
|
||||||
root = m_rootNode->children.at(2);
|
root = m_rootNode->children.at(Tags);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user