summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-04-30 13:49:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-04-30 14:00:41 +0200
commitd681bc10c9977036e02d84c9e3023bd86050abee (patch)
tree94d202c02eec74de1bac9979fde8e8d90a93ed89
parent19a5cbe0580c797784eb7bcfec9c64a07fffc5a3 (diff)
downloadqt-creator-d681bc10c9977036e02d84c9e3023bd86050abee.tar.gz
Gerrit: Introduce bold marking of changes.
Owned changes: Mark using bold if approval != 0,1. Changes for review: Mark using bold if review is missing. Derive verbose user name from first query. Change-Id: I0ba85c1c7fff088846261b3ba8c5dbaaf259db9a Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
-rw-r--r--src/plugins/git/gerrit/gerritmodel.cpp49
-rw-r--r--src/plugins/git/gerrit/gerritmodel.h3
2 files changed, 52 insertions, 0 deletions
diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp
index a0e61e2f55..1e9351adb9 100644
--- a/src/plugins/git/gerrit/gerritmodel.cpp
+++ b/src/plugins/git/gerrit/gerritmodel.cpp
@@ -91,6 +91,31 @@ QString GerritPatchSet::approvalsToolTip() const
return result;
}
+bool GerritPatchSet::hasApproval(const QString &userName) const
+{
+ foreach (const Approval &a, approvals)
+ if (a.first == userName)
+ return true;
+ return false;
+}
+
+/* Return the approval level: Negative values take preference. */
+int GerritPatchSet::approvalLevel() const
+{
+ if (approvals.isEmpty())
+ return 0;
+
+ int maxLevel = -3;
+ int minLevel = 3;
+ foreach (const Approval &a, approvals) {
+ if (a.second > maxLevel)
+ maxLevel = a.second;
+ if (a.second < minLevel)
+ minLevel = a.second;
+ }
+ return minLevel < 0 ? minLevel : maxLevel;
+}
+
QString GerritChange::toolTip() const
{
static const QString format = GerritModel::tr(
@@ -143,6 +168,8 @@ public:
~QueryContext();
+ int currentQuery() const { return m_currentQuery; }
+
public slots:
void start();
@@ -589,6 +616,10 @@ void GerritModel::queryFinished(const QByteArray &output)
// Avoid duplicate entries for example in the (unlikely)
// case people do self-reviews.
if (indexOf(c->number) == -1) {
+ // Determine the verbose user name from the owner of the first query.
+ // It used for marking the changes pending for review in bold.
+ if (m_userName.isEmpty() && !m_query->currentQuery())
+ m_userName = c->owner;
const QVariant filterV = QVariant(c->filterString());
const QString toolTip = c->toolTip();
const QVariant changeV = qVariantFromValue(c);
@@ -617,6 +648,24 @@ void GerritModel::queryFinished(const QByteArray &output)
approvals.append(QString::number(a.second));
}
row[ApprovalsColumn]->setText(approvals);
+ // Mark changes awaiting action using a bold font.
+ bool bold = false;
+ switch (m_query->currentQuery()) {
+ case 0: { // Owned changes: Review != 0,1. Submit or amend.
+ const int level = c->currentPatchSet.approvalLevel();
+ bold = level != 0 && level != 1;
+ }
+ break;
+ case 1: // Changes pending for review: No review yet.
+ bold = !m_userName.isEmpty() && !c->currentPatchSet.hasApproval(m_userName);
+ break;
+ }
+ if (bold) {
+ QFont font = row.first()->font();
+ font.setBold(true);
+ for (int i = 0; i < GerritModel::ColumnCount; ++i)
+ row[i]->setFont(font);
+ }
appendRow(row);
}
}
diff --git a/src/plugins/git/gerrit/gerritmodel.h b/src/plugins/git/gerrit/gerritmodel.h
index 743f3048ff..85d5ef760d 100644
--- a/src/plugins/git/gerrit/gerritmodel.h
+++ b/src/plugins/git/gerrit/gerritmodel.h
@@ -54,6 +54,8 @@ public:
GerritPatchSet() : patchSetNumber(1) {}
QString approvalsToolTip() const;
+ bool hasApproval(const QString &userName) const;
+ int approvalLevel() const;
QString ref;
int patchSetNumber;
@@ -129,6 +131,7 @@ private:
const QSharedPointer<GerritParameters> m_parameters;
QueryContext *m_query;
+ QString m_userName;
};
} // namespace Internal