Files
qt-creator/tests/auto/valgrind/memcheck/modeldemo.h
hjk 88fd4043d8 Valgrind: Merge MemCheckRunner and ValgrindRunner base
It's mostly the xml/log handling, which can be re-used in other tools.

The change is purely mechanical, including some style fixes and
some modernization.

Change-Id: I6b44ae71451e8d3e26df40b9af9b4ec70038a92d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-06-23 09:41:28 +00:00

69 lines
2.3 KiB
C++

/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Author: Frank Osterfeld, KDAB (frank.osterfeld@kdab.com)
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** 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.
**
** 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.
**
****************************************************************************/
#pragma once
#include <QObject>
#include <QDebug>
#include <QItemSelection>
#include <QModelIndex>
#include <valgrind/xmlprotocol/error.h>
#include <valgrind/xmlprotocol/errorlistmodel.h>
#include <valgrind/xmlprotocol/stackmodel.h>
#include <valgrind/valgrindrunner.h>
class ModelDemo : public QObject
{
Q_OBJECT
public:
explicit ModelDemo(Valgrind::ValgrindRunner *r, QObject *parent = 0)
: QObject(parent)
, runner(r)
{
}
Valgrind::XmlProtocol::StackModel* stackModel;
public Q_SLOTS:
void finished() {
qDebug() << runner->errorString();
}
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:
Valgrind::ValgrindRunner *runner;
};