diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2019-05-05 23:13:41 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2019-05-06 06:19:40 +0000 |
commit | b374086624535d0b584dc8f9fb4057481aa2d558 (patch) | |
tree | e75f8259be164bc4df342027291c249a3d99ba82 /src/plugins/git | |
parent | 6595a161fc91572198d0d84561652e153b9a5773 (diff) | |
download | qt-creator-b374086624535d0b584dc8f9fb4057481aa2d558.tar.gz |
Git: Move parseOutputLine to BranchModel::Private
Change-Id: I885a0f6c6848b63bca0cb3047b28c984087f0bc8
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/branchmodel.cpp | 34 | ||||
-rw-r--r-- | src/plugins/git/branchmodel.h | 2 |
2 files changed, 17 insertions, 19 deletions
diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index 52223031bb..34b19ad449 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -213,6 +213,9 @@ public: delete rootNode; } + bool hasTags() const { return rootNode->children.count() > Tags; } + void parseOutputLine(const QString &line); + GitClient *client; QString workingDirectory; BranchNode *rootNode; @@ -369,7 +372,7 @@ void BranchModel::clear() while (root->count()) delete root->children.takeLast(); } - if (hasTags()) + if (d->hasTags()) d->rootNode->children.takeLast(); d->currentSha.clear(); @@ -406,7 +409,7 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage } const QStringList lines = output.split('\n'); for (const QString &l : lines) - parseOutputLine(l); + d->parseOutputLine(l); if (d->currentBranch) { if (d->currentBranch->isLocal()) @@ -519,10 +522,7 @@ QDateTime BranchModel::dateTime(const QModelIndex &idx) const return node->dateTime; } -bool BranchModel::hasTags() const -{ - return d->rootNode->children.count() > Tags; -} + bool BranchModel::isHead(const QModelIndex &idx) const { @@ -550,7 +550,7 @@ bool BranchModel::isLeaf(const QModelIndex &idx) const bool BranchModel::isTag(const QModelIndex &idx) const { - if (!idx.isValid() || !hasTags()) + if (!idx.isValid() || !d->hasTags()) return false; return indexToNode(idx)->isTag(); } @@ -723,7 +723,7 @@ Utils::optional<QString> BranchModel::remoteName(const QModelIndex &idx) const return Utils::nullopt; } -void BranchModel::parseOutputLine(const QString &line) +void BranchModel::Private::parseOutputLine(const QString &line) { if (line.size() < 3) return; @@ -735,7 +735,7 @@ void BranchModel::parseOutputLine(const QString &line) const QString fullName = lineParts.at(1); const QString upstream = lineParts.at(2); QDateTime dateTime; - const bool current = (sha == d->currentSha); + const bool current = (sha == currentSha); QString strDateTime = lineParts.at(5); if (strDateTime.isEmpty()) strDateTime = lineParts.at(4); @@ -744,16 +744,16 @@ void BranchModel::parseOutputLine(const QString &line) dateTime = QDateTime::fromSecsSinceEpoch(timeT); } - if (!d->oldBranchesIncluded && !current && dateTime.isValid()) { + if (!oldBranchesIncluded && !current && dateTime.isValid()) { const qint64 age = dateTime.daysTo(QDateTime::currentDateTime()); if (age > Constants::OBSOLETE_COMMIT_AGE_IN_DAYS) { const QString heads = "refs/heads/"; if (fullName.startsWith(heads)) - d->obsoleteLocalBranches.append(fullName.mid(heads.size())); + obsoleteLocalBranches.append(fullName.mid(heads.size())); return; } } - bool showTags = d->client->settings().boolValue(GitSettings::showTagsKey); + bool showTags = client->settings().boolValue(GitSettings::showTagsKey); // insert node into tree: QStringList nameParts = fullName.split('/'); @@ -761,13 +761,13 @@ void BranchModel::parseOutputLine(const QString &line) BranchNode *root = nullptr; if (nameParts.first() == "heads") { - root = d->rootNode->children.at(LocalBranches); + root = rootNode->children.at(LocalBranches); } else if (nameParts.first() == "remotes") { - root = d->rootNode->children.at(RemoteBranches); + root = rootNode->children.at(RemoteBranches); } else if (showTags && nameParts.first() == "tags") { if (!hasTags()) // Tags is missing, add it - d->rootNode->append(new BranchNode(tr("Tags"), "refs/tags")); - root = d->rootNode->children.at(Tags); + rootNode->append(new BranchNode(tr("Tags"), "refs/tags")); + root = rootNode->children.at(Tags); } else { return; } @@ -787,7 +787,7 @@ void BranchModel::parseOutputLine(const QString &line) auto newNode = new BranchNode(name, sha, upstream, dateTime); root->insert(nameParts, newNode); if (current) - d->currentBranch = newNode; + currentBranch = newNode; } BranchNode *BranchModel::indexToNode(const QModelIndex &index) const diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h index 083f6d59f7..5c163801fd 100644 --- a/src/plugins/git/branchmodel.h +++ b/src/plugins/git/branchmodel.h @@ -71,7 +71,6 @@ public: QStringList localBranchNames() const; QString sha(const QModelIndex &idx) const; QDateTime dateTime(const QModelIndex &idx) const; - bool hasTags() const; bool isHead(const QModelIndex &idx) const; bool isLocal(const QModelIndex &idx) const; bool isLeaf(const QModelIndex &idx) const; @@ -87,7 +86,6 @@ public: Utils::optional<QString> remoteName(const QModelIndex &idx) const; private: - void parseOutputLine(const QString &line); void setCurrentBranch(); BranchNode *indexToNode(const QModelIndex &index) const; QModelIndex nodeToIndex(BranchNode *node, int column) const; |