2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2022-08-10 17:23:06 +02:00
|
|
|
#include <QApplication>
|
2011-03-04 12:15:18 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QItemSelection>
|
|
|
|
|
#include <QModelIndex>
|
|
|
|
|
|
|
|
|
|
#include <valgrind/xmlprotocol/error.h>
|
|
|
|
|
#include <valgrind/xmlprotocol/errorlistmodel.h>
|
|
|
|
|
#include <valgrind/xmlprotocol/stackmodel.h>
|
2017-06-21 08:08:43 +02:00
|
|
|
#include <valgrind/valgrindrunner.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
class ModelDemo : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2017-06-21 08:08:43 +02:00
|
|
|
explicit ModelDemo(Valgrind::ValgrindRunner *r, QObject *parent = 0)
|
2011-03-04 12:15:18 +01:00
|
|
|
: QObject(parent)
|
|
|
|
|
, runner(r)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Valgrind::XmlProtocol::StackModel* stackModel;
|
|
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
|
void finished() {
|
|
|
|
|
qDebug() << runner->errorString();
|
2022-08-10 17:23:06 +02:00
|
|
|
qApp->exit(!runner->errorString().isEmpty());
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void selectionChanged(const QItemSelection &sel, const QItemSelection &) {
|
|
|
|
|
if (sel.indexes().isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
const QModelIndex idx = sel.indexes().first();
|
|
|
|
|
const Valgrind::XmlProtocol::Error err = idx.data(Valgrind::XmlProtocol::ErrorListModel::ErrorRole).value<Valgrind::XmlProtocol::Error>();
|
|
|
|
|
qDebug() << idx.row() << err.what();
|
|
|
|
|
stackModel->setError(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2017-06-21 08:08:43 +02:00
|
|
|
Valgrind::ValgrindRunner *runner;
|
2011-03-04 12:15:18 +01:00
|
|
|
};
|