forked from qt-creator/qt-creator
Git: Minor cleanup in BranchModel
* Use member initialization * Use nullptr * Remove unneeded local var Change-Id: Ibca6c3bc5caf9e028166b833ba1ed9fc165e290b Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
ad8b797860
commit
8478e35384
@@ -55,13 +55,12 @@ class BranchNode
|
||||
{
|
||||
public:
|
||||
BranchNode() :
|
||||
parent(0),
|
||||
name("<ROOT>")
|
||||
{ }
|
||||
|
||||
BranchNode(const QString &n, const QString &s = QString(), const QString &t = QString(),
|
||||
const QDateTime &dt = QDateTime()) :
|
||||
parent(0), name(n), sha(s), tracking(t), dateTime(dt)
|
||||
name(n), sha(s), tracking(t), dateTime(dt)
|
||||
{ }
|
||||
|
||||
~BranchNode()
|
||||
@@ -120,7 +119,7 @@ public:
|
||||
if (children.at(i)->name == name)
|
||||
return children.at(i);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QStringList fullName(bool includePrefix = false) const
|
||||
@@ -182,7 +181,7 @@ public:
|
||||
return children.indexOf(node);
|
||||
}
|
||||
|
||||
BranchNode *parent;
|
||||
BranchNode *parent = nullptr;
|
||||
QList<BranchNode *> children;
|
||||
|
||||
QString name;
|
||||
@@ -349,7 +348,7 @@ void BranchModel::clear()
|
||||
if (hasTags())
|
||||
m_rootNode->children.takeLast();
|
||||
|
||||
m_currentBranch = 0;
|
||||
m_currentBranch = nullptr;
|
||||
m_obsoleteLocalBranches.clear();
|
||||
}
|
||||
|
||||
@@ -376,7 +375,7 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
|
||||
|
||||
if (m_currentBranch) {
|
||||
if (m_currentBranch->parent == m_rootNode->children.at(LocalBranches))
|
||||
m_currentBranch = 0;
|
||||
m_currentBranch = nullptr;
|
||||
setCurrentBranch();
|
||||
}
|
||||
|
||||
@@ -448,8 +447,7 @@ QString BranchModel::fullName(const QModelIndex &idx, bool includePrefix) const
|
||||
BranchNode *node = indexToNode(idx);
|
||||
if (!node || !node->isLeaf())
|
||||
return QString();
|
||||
QStringList path = node->fullName(includePrefix);
|
||||
return path.join('/');
|
||||
return node->fullName(includePrefix).join('/');
|
||||
}
|
||||
|
||||
QStringList BranchModel::localBranchNames() const
|
||||
@@ -623,7 +621,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
|
||||
if (slash != -1) {
|
||||
const QString nodeName = name.left(slash);
|
||||
int pos = positionForName(local, nodeName);
|
||||
BranchNode *child = (pos == local->count()) ? 0 : local->children.at(pos);
|
||||
BranchNode *child = (pos == local->count()) ? nullptr : local->children.at(pos);
|
||||
if (!child || child->name != nodeName) {
|
||||
child = new BranchNode(nodeName);
|
||||
beginInsertRows(nodeToIndex(local, 0), pos, pos);
|
||||
@@ -697,7 +695,7 @@ void BranchModel::parseOutputLine(const QString &line)
|
||||
QStringList nameParts = fullName.split('/');
|
||||
nameParts.removeFirst(); // remove refs...
|
||||
|
||||
BranchNode *root = 0;
|
||||
BranchNode *root = nullptr;
|
||||
if (nameParts.first() == "heads") {
|
||||
root = m_rootNode->children.at(LocalBranches);
|
||||
} else if (nameParts.first() == "remotes") {
|
||||
@@ -731,7 +729,7 @@ void BranchModel::parseOutputLine(const QString &line)
|
||||
BranchNode *BranchModel::indexToNode(const QModelIndex &index) const
|
||||
{
|
||||
if (index.column() > 1)
|
||||
return 0;
|
||||
return nullptr;
|
||||
if (!index.isValid())
|
||||
return m_rootNode;
|
||||
return static_cast<BranchNode *>(index.internalPointer());
|
||||
|
||||
Reference in New Issue
Block a user