2014-10-07 15:51:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-10-07 15:51:02 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-22 10:37:55 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
#include "testresult.h"
|
|
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
2014-10-21 13:10:37 +02:00
|
|
|
#include <QSortFilterProxyModel>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <QFont>
|
2014-10-21 13:10:37 +02:00
|
|
|
#include <QSet>
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2015-08-20 15:59:15 +02:00
|
|
|
#include <utils/treemodel.h>
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-08-20 15:59:15 +02:00
|
|
|
class TestResultItem : public Utils::TreeItem
|
|
|
|
|
{
|
|
|
|
|
public:
|
2016-02-25 13:02:31 +01:00
|
|
|
explicit TestResultItem(const TestResultPtr &testResult);
|
2015-08-20 15:59:15 +02:00
|
|
|
~TestResultItem();
|
2016-09-29 12:15:43 +02:00
|
|
|
QVariant data(int column, int role) const override;
|
2016-02-25 13:02:31 +01:00
|
|
|
const TestResult *testResult() const { return m_testResult.data(); }
|
2015-08-20 15:59:15 +02:00
|
|
|
void updateDescription(const QString &description);
|
|
|
|
|
void updateResult();
|
|
|
|
|
|
|
|
|
|
private:
|
2016-02-25 13:02:31 +01:00
|
|
|
TestResultPtr m_testResult;
|
2015-08-20 15:59:15 +02:00
|
|
|
};
|
|
|
|
|
|
2016-06-24 09:36:42 +02:00
|
|
|
class TestResultModel : public Utils::TreeModel<>
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit TestResultModel(QObject *parent = 0);
|
2015-08-20 15:59:15 +02:00
|
|
|
|
2016-02-25 13:02:31 +01:00
|
|
|
void addTestResult(const TestResultPtr &testResult, bool autoExpand = false);
|
2014-12-05 14:01:16 +01:00
|
|
|
void removeCurrentTestMessage();
|
2014-10-07 15:51:02 +02:00
|
|
|
void clearTestResults();
|
|
|
|
|
|
2016-04-13 10:20:17 +02:00
|
|
|
const TestResult *testResult(const QModelIndex &idx);
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
int maxWidthOfFileName(const QFont &font);
|
|
|
|
|
int maxWidthOfLineNumber(const QFont &font);
|
|
|
|
|
|
2015-08-20 15:59:15 +02:00
|
|
|
int resultTypeCount(Result::Type type) const { return m_testResultCount.value(type, 0); }
|
2015-12-14 12:48:58 +01:00
|
|
|
int disabledTests() const { return m_disabled; }
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
private:
|
2015-01-08 13:46:28 +01:00
|
|
|
QMap<Result::Type, int> m_testResultCount;
|
2016-09-29 12:15:43 +02:00
|
|
|
int m_widthOfLineNumber = 0;
|
|
|
|
|
int m_maxWidthOfFileName = 0;
|
|
|
|
|
int m_disabled = 0;
|
2015-08-20 15:59:15 +02:00
|
|
|
QList<int> m_processedIndices;
|
2014-10-07 15:51:02 +02:00
|
|
|
QFont m_measurementFont;
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-21 13:10:37 +02:00
|
|
|
class TestResultFilterModel : public QSortFilterProxyModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2016-09-29 12:15:43 +02:00
|
|
|
explicit TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = 0);
|
2014-10-21 13:10:37 +02:00
|
|
|
|
|
|
|
|
void enableAllResultTypes();
|
2015-01-08 13:46:28 +01:00
|
|
|
void toggleTestResultType(Result::Type type);
|
2014-10-21 13:10:37 +02:00
|
|
|
void clearTestResults();
|
|
|
|
|
bool hasResults();
|
2016-04-13 10:20:17 +02:00
|
|
|
const TestResult *testResult(const QModelIndex &index) const;
|
2014-10-21 13:10:37 +02:00
|
|
|
|
|
|
|
|
protected:
|
2016-09-29 12:15:43 +02:00
|
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
2014-10-21 13:10:37 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-06-15 13:28:50 +02:00
|
|
|
bool acceptTestCaseResult(const QModelIndex &index) const;
|
2014-10-21 13:10:37 +02:00
|
|
|
TestResultModel *m_sourceModel;
|
2015-01-08 13:46:28 +01:00
|
|
|
QSet<Result::Type> m_enabled;
|
2014-10-21 13:10:37 +02:00
|
|
|
};
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|