forked from qt-creator/qt-creator
Gerrit: Simplify query model
Use plain QString for queries instead of QStringList Change-Id: Ia8a9086937fa34bce91d62d7434b26aa33b41163 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
committed by
Friedemann Kleint
parent
eebdd459dd
commit
e6820b741d
@@ -240,9 +240,7 @@ QStringList GerritChange::gitFetchArguments(const QSharedPointer<GerritParameter
|
|||||||
class QueryContext : public QObject {
|
class QueryContext : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
typedef QList<QStringList> StringListList;
|
QueryContext(const QStringList &queries,
|
||||||
|
|
||||||
QueryContext(const StringListList &queries,
|
|
||||||
const QSharedPointer<GerritParameters> &p,
|
const QSharedPointer<GerritParameters> &p,
|
||||||
QObject *parent = 0);
|
QObject *parent = 0);
|
||||||
|
|
||||||
@@ -264,11 +262,11 @@ private slots:
|
|||||||
void readyReadStandardOutput();
|
void readyReadStandardOutput();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startQuery(const QStringList &queryArguments);
|
void startQuery(const QString &query);
|
||||||
void errorTermination(const QString &msg);
|
void errorTermination(const QString &msg);
|
||||||
|
|
||||||
const QSharedPointer<GerritParameters> m_parameters;
|
const QSharedPointer<GerritParameters> m_parameters;
|
||||||
const StringListList m_queries;
|
const QStringList m_queries;
|
||||||
QProcess m_process;
|
QProcess m_process;
|
||||||
QString m_binary;
|
QString m_binary;
|
||||||
QByteArray m_output;
|
QByteArray m_output;
|
||||||
@@ -277,7 +275,7 @@ private:
|
|||||||
QStringList m_baseArguments;
|
QStringList m_baseArguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
QueryContext::QueryContext(const StringListList &queries,
|
QueryContext::QueryContext(const QStringList &queries,
|
||||||
const QSharedPointer<GerritParameters> &p,
|
const QSharedPointer<GerritParameters> &p,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@@ -321,9 +319,10 @@ void QueryContext::start()
|
|||||||
startQuery(m_queries.front()); // Order: synchronous call to error handling if something goes wrong.
|
startQuery(m_queries.front()); // Order: synchronous call to error handling if something goes wrong.
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryContext::startQuery(const QStringList &queryArguments)
|
void QueryContext::startQuery(const QString &query)
|
||||||
{
|
{
|
||||||
const QStringList arguments = m_baseArguments + queryArguments;
|
QStringList arguments = m_baseArguments;
|
||||||
|
arguments.push_back(query);
|
||||||
VcsBase::VcsBaseOutputWindow::instance()
|
VcsBase::VcsBaseOutputWindow::instance()
|
||||||
->appendCommand(m_process.workingDirectory(), m_binary, arguments);
|
->appendCommand(m_process.workingDirectory(), m_binary, arguments);
|
||||||
m_process.start(m_binary, arguments);
|
m_process.start(m_binary, arguments);
|
||||||
@@ -413,8 +412,6 @@ int GerritModel::indexOf(int gerritNumber) const
|
|||||||
|
|
||||||
void GerritModel::refresh()
|
void GerritModel::refresh()
|
||||||
{
|
{
|
||||||
typedef QueryContext::StringListList StringListList;
|
|
||||||
|
|
||||||
if (m_query) {
|
if (m_query) {
|
||||||
qWarning("%s: Another query is still running", Q_FUNC_INFO);
|
qWarning("%s: Another query is still running", Q_FUNC_INFO);
|
||||||
return;
|
return;
|
||||||
@@ -424,30 +421,20 @@ void GerritModel::refresh()
|
|||||||
// Assemble list of queries
|
// Assemble list of queries
|
||||||
const QString statusOpenQuery = QLatin1String("status:open");
|
const QString statusOpenQuery = QLatin1String("status:open");
|
||||||
|
|
||||||
StringListList queries;
|
QStringList queries;
|
||||||
QStringList queryArguments;
|
|
||||||
if (m_parameters->user.isEmpty()) {
|
if (m_parameters->user.isEmpty()) {
|
||||||
queryArguments << statusOpenQuery;
|
queries.push_back(statusOpenQuery);
|
||||||
queries.push_back(queryArguments);
|
|
||||||
queryArguments.clear();
|
|
||||||
} else {
|
} else {
|
||||||
// Owned by:
|
// Owned by:
|
||||||
queryArguments << (QLatin1String("owner:") + m_parameters->user) << statusOpenQuery;
|
queries.push_back(statusOpenQuery + QLatin1String(" owner:") + m_parameters->user);
|
||||||
queries.push_back(queryArguments);
|
|
||||||
queryArguments.clear();
|
|
||||||
// For Review by:
|
// For Review by:
|
||||||
queryArguments << (QLatin1String("reviewer:") + m_parameters->user) << statusOpenQuery;
|
queries.push_back(statusOpenQuery + QLatin1String(" reviewer:") + m_parameters->user);
|
||||||
queries.push_back(queryArguments);
|
|
||||||
queryArguments.clear();
|
|
||||||
}
|
}
|
||||||
// Any custom queries?
|
// Any custom queries?
|
||||||
if (!m_parameters->additionalQueries.isEmpty()) {
|
if (!m_parameters->additionalQueries.isEmpty()) {
|
||||||
foreach (const QString &customQuery, m_parameters->additionalQueries.split(QString::SkipEmptyParts)) {
|
foreach (const QString &customQuery, m_parameters->additionalQueries.split(QString::SkipEmptyParts)) {
|
||||||
queryArguments = customQuery.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
if (!customQuery.trimmed().isEmpty())
|
||||||
if (!queryArguments.isEmpty()) {
|
queries.push_back(customQuery);
|
||||||
queries.push_back(queryArguments);
|
|
||||||
queryArguments.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user