Gerrit: No need to subclass FancyLineEdit

Change-Id: I9b25c1e0a72e8a7e5ba268e539cf71f5b28d420b
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-10-12 16:17:29 +02:00
parent 0aad5fac70
commit 2a014eaee6
4 changed files with 30 additions and 64 deletions

View File

@@ -409,7 +409,6 @@ void QueryContext::timeout()
GerritModel::GerritModel(const QSharedPointer<GerritParameters> &p, QObject *parent)
: QStandardItemModel(0, ColumnCount, parent)
, m_parameters(p)
, m_query(0)
{
QStringList headers; // Keep in sync with GerritChange::toHtml()
headers << QLatin1String("#") << tr("Subject") << tr("Owner")
@@ -546,6 +545,7 @@ void GerritModel::refresh(const QString &query)
connect(m_query, &QueryContext::finished, this, &GerritModel::queriesFinished);
emit refreshStateChanged(true);
m_query->start();
setState(Running);
}
void GerritModel::clearData()
@@ -554,6 +554,14 @@ void GerritModel::clearData()
removeRows(0, rows);
}
void GerritModel::setState(GerritModel::QueryState s)
{
if (s == m_state)
return;
m_state = s;
emit stateChanged();
}
/* Parse gerrit query Json output.
* See http://gerrit.googlecode.com/svn/documentation/2.1.5/cmd-query.html
* Note: The url will be present only if "canonicalWebUrl" is configured
@@ -746,8 +754,8 @@ bool gerritChangeLessThan(const GerritChangePtr &c1, const GerritChangePtr &c2)
void GerritModel::queryFinished(const QByteArray &output)
{
QList<GerritChangePtr> changes;
if (!parseOutput(m_parameters, output, changes))
emit queryError();
setState(parseOutput(m_parameters, output, changes) ? Ok : Error);
// Populate a hash with indices for faster access.
QHash<QString, int> idIndexHash;
const int count = changes.size();
@@ -813,6 +821,7 @@ void GerritModel::queriesFinished()
{
m_query->deleteLater();
m_query = 0;
setState(Idle);
emit refreshStateChanged(false);
}