2015-11-13 18:03:23 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-14 11:03:04 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-11-13 18:03:23 +01:00
|
|
|
**
|
2016-01-14 11:03:04 +01:00
|
|
|
** This file is part of Qt Creator.
|
2015-11-13 18:03:23 +01:00
|
|
|
**
|
2016-01-14 11:03:04 +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
|
2015-11-13 18:03:23 +01:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-14 11:03:04 +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.
|
2015-11-13 18:03:23 +01:00
|
|
|
**
|
2016-01-14 11:03:04 +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.
|
2015-11-13 18:03:23 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "debugmessagesmodel.h"
|
2016-08-09 18:38:15 +02:00
|
|
|
#include "qmlprofilerconstants.h"
|
2016-09-16 16:10:19 +02:00
|
|
|
#include <timeline/timelineformattime.h>
|
2015-11-13 18:03:23 +01:00
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
namespace QmlProfiler {
|
2015-11-13 18:03:23 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
DebugMessagesModel::DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent) :
|
2016-05-02 12:18:57 +02:00
|
|
|
QmlProfilerTimelineModel(manager, DebugMessage, MaximumRangeType, ProfileDebugMessages, parent),
|
|
|
|
|
m_maximumMsgType(-1)
|
2015-11-13 18:03:23 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DebugMessagesModel::typeId(int index) const
|
|
|
|
|
{
|
|
|
|
|
return m_data[index].typeId;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 18:11:36 +01:00
|
|
|
QRgb DebugMessagesModel::color(int index) const
|
2015-11-13 18:03:23 +01:00
|
|
|
{
|
|
|
|
|
return colorBySelectionId(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *messageTypes[] = {
|
|
|
|
|
QT_TRANSLATE_NOOP("DebugMessagesModel", "Debug Message"),
|
|
|
|
|
QT_TRANSLATE_NOOP("DebugMessagesModel", "Warning Message"),
|
|
|
|
|
QT_TRANSLATE_NOOP("DebugMessagesModel", "Critical Message"),
|
|
|
|
|
QT_TRANSLATE_NOOP("DebugMessagesModel", "Fatal Message"),
|
|
|
|
|
QT_TRANSLATE_NOOP("DebugMessagesModel", "Info Message"),
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-23 15:46:41 +01:00
|
|
|
QString DebugMessagesModel::messageType(uint i)
|
|
|
|
|
{
|
|
|
|
|
return i < sizeof(messageTypes) / sizeof(char *) ? tr(messageTypes[i]) :
|
|
|
|
|
tr("Unknown Message %1").arg(i);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 18:03:23 +01:00
|
|
|
QVariantList DebugMessagesModel::labels() const
|
|
|
|
|
{
|
|
|
|
|
QVariantList result;
|
|
|
|
|
|
2015-11-23 15:46:41 +01:00
|
|
|
for (int i = 0; i <= m_maximumMsgType; ++i) {
|
2015-11-13 18:03:23 +01:00
|
|
|
QVariantMap element;
|
2015-11-23 15:46:41 +01:00
|
|
|
element.insert(QLatin1String("description"), messageType(i));
|
2015-11-13 18:03:23 +01:00
|
|
|
element.insert(QLatin1String("id"), i);
|
|
|
|
|
result << element;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap DebugMessagesModel::details(int index) const
|
|
|
|
|
{
|
2017-01-02 19:15:17 +01:00
|
|
|
const QmlProfilerModelManager *manager = modelManager();
|
|
|
|
|
const QmlEventType &type = manager->qmlModel()->eventTypes()[m_data[index].typeId];
|
2015-11-13 18:03:23 +01:00
|
|
|
|
|
|
|
|
QVariantMap result;
|
2016-06-06 19:51:55 +02:00
|
|
|
result.insert(QLatin1String("displayName"), messageType(type.detailType()));
|
2017-01-02 19:15:17 +01:00
|
|
|
result.insert(tr("Timestamp"), Timeline::formatTime(startTime(index),
|
|
|
|
|
manager->traceTime()->duration()));
|
2015-11-13 18:03:23 +01:00
|
|
|
result.insert(tr("Message"), m_data[index].text);
|
2016-06-06 19:51:55 +02:00
|
|
|
result.insert(tr("Location"), type.displayName());
|
2015-11-13 18:03:23 +01:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DebugMessagesModel::expandedRow(int index) const
|
|
|
|
|
{
|
|
|
|
|
return selectionId(index) + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int DebugMessagesModel::collapsedRow(int index) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(index);
|
2016-08-09 18:38:15 +02:00
|
|
|
return Constants::QML_MIN_LEVEL;
|
2015-11-13 18:03:23 +01:00
|
|
|
}
|
|
|
|
|
|
2016-04-26 13:23:35 +02:00
|
|
|
void DebugMessagesModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
|
2015-11-13 18:03:23 +01:00
|
|
|
{
|
2016-06-06 19:51:55 +02:00
|
|
|
m_data.insert(insert(event.timestamp(), 0, type.detailType()),
|
2016-04-26 13:23:35 +02:00
|
|
|
MessageData(event.string(), event.typeIndex()));
|
2016-06-06 19:51:55 +02:00
|
|
|
if (type.detailType() > m_maximumMsgType)
|
2016-09-13 15:54:20 +02:00
|
|
|
m_maximumMsgType = type.detailType();
|
2016-04-26 13:23:35 +02:00
|
|
|
}
|
2015-11-13 18:03:23 +01:00
|
|
|
|
2016-04-26 13:23:35 +02:00
|
|
|
void DebugMessagesModel::finalize()
|
|
|
|
|
{
|
2016-08-09 18:38:15 +02:00
|
|
|
setCollapsedRowCount(Constants::QML_MIN_LEVEL + 1);
|
2015-11-23 15:46:41 +01:00
|
|
|
setExpandedRowCount(m_maximumMsgType + 2);
|
2015-11-13 18:03:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebugMessagesModel::clear()
|
|
|
|
|
{
|
|
|
|
|
m_data.clear();
|
2015-11-23 15:46:41 +01:00
|
|
|
m_maximumMsgType = -1;
|
2015-11-13 18:03:23 +01:00
|
|
|
QmlProfilerTimelineModel::clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap DebugMessagesModel::location(int index) const
|
|
|
|
|
{
|
|
|
|
|
return locationFromTypeId(index);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 10:21:00 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProfiler
|