aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-23 15:46:41 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-23 14:53:50 +0000
commit77fc9a38a271e589a228ac9d9a6644d47c6744e8 (patch)
tree6f8743ceb1f5f282c20284ced359c442c5446c5e
parent8183d81c3e04234beb0e200897ad4dbe5d5c0ec6 (diff)
Avoid using API introduced in Qt 5.5
Especially, QMetaEnum::fromType() and friends. Tracking which kinds of messages were actually generated is better anyway, as we don't get empty rows like this. Change-Id: I23c560d9071c0ff5a33dff660e4dbb1552890df8 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--plugins/qmlprofiler/debugmessagesmodel.cpp19
-rw-r--r--plugins/qmlprofiler/debugmessagesmodel.h3
-rw-r--r--plugins/qmlprofiler/inputeventsmodel.cpp18
-rw-r--r--plugins/qmlprofiler/inputeventsmodel.h1
4 files changed, 28 insertions, 13 deletions
diff --git a/plugins/qmlprofiler/debugmessagesmodel.cpp b/plugins/qmlprofiler/debugmessagesmodel.cpp
index 246e7c32f2..1ac3ac83e6 100644
--- a/plugins/qmlprofiler/debugmessagesmodel.cpp
+++ b/plugins/qmlprofiler/debugmessagesmodel.cpp
@@ -30,7 +30,7 @@ bool DebugMessagesModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &
DebugMessagesModel::DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent) :
QmlProfilerTimelineModel(manager, QmlDebug::DebugMessage, QmlDebug::MaximumRangeType,
- QmlDebug::ProfileDebugMessages, parent)
+ QmlDebug::ProfileDebugMessages, parent), m_maximumMsgType(-1)
{
}
@@ -52,13 +52,19 @@ static const char *messageTypes[] = {
QT_TRANSLATE_NOOP("DebugMessagesModel", "Info Message"),
};
+QString DebugMessagesModel::messageType(uint i)
+{
+ return i < sizeof(messageTypes) / sizeof(char *) ? tr(messageTypes[i]) :
+ tr("Unknown Message %1").arg(i);
+}
+
QVariantList DebugMessagesModel::labels() const
{
QVariantList result;
- for (int i = QtDebugMsg; i <= QtInfoMsg; ++i) {
+ for (int i = 0; i <= m_maximumMsgType; ++i) {
QVariantMap element;
- element.insert(QLatin1String("description"), tr(messageTypes[i]));
+ element.insert(QLatin1String("description"), messageType(i));
element.insert(QLatin1String("id"), i);
result << element;
}
@@ -71,7 +77,7 @@ QVariantMap DebugMessagesModel::details(int index) const
modelManager()->qmlModel()->getEventTypes()[m_data[index].typeId];
QVariantMap result;
- result.insert(QLatin1String("displayName"), tr(messageTypes[type.detailType]));
+ result.insert(QLatin1String("displayName"), messageType(type.detailType));
result.insert(tr("Timestamp"), QmlProfilerDataModel::formatTime(startTime(index)));
result.insert(tr("Message"), m_data[index].text);
result.insert(tr("Location"), type.displayName);
@@ -104,16 +110,19 @@ void DebugMessagesModel::loadData()
m_data.insert(insert(event.startTime(), 0, type.detailType),
MessageData(event.stringData(), event.typeIndex()));
+ if (type.detailType > m_maximumMsgType)
+ m_maximumMsgType = event.typeIndex();
updateProgress(count(), simpleModel->getEvents().count());
}
setCollapsedRowCount(2);
- setExpandedRowCount(6); // 5 QtMsgTypes + 1
+ setExpandedRowCount(m_maximumMsgType + 2);
updateProgress(1, 1);
}
void DebugMessagesModel::clear()
{
m_data.clear();
+ m_maximumMsgType = -1;
QmlProfilerTimelineModel::clear();
}
diff --git a/plugins/qmlprofiler/debugmessagesmodel.h b/plugins/qmlprofiler/debugmessagesmodel.h
index 33629a1b95..879dbd4c0f 100644
--- a/plugins/qmlprofiler/debugmessagesmodel.h
+++ b/plugins/qmlprofiler/debugmessagesmodel.h
@@ -45,6 +45,8 @@ public:
QVariantMap location(int index) const override;
private:
+ static QString messageType(uint i);
+
struct MessageData {
MessageData(const QString &text = QString(), int typeId = -1) :
text(text), typeId(typeId) {}
@@ -52,6 +54,7 @@ private:
int typeId;
};
+ int m_maximumMsgType;
QVector<MessageData> m_data;
};
diff --git a/plugins/qmlprofiler/inputeventsmodel.cpp b/plugins/qmlprofiler/inputeventsmodel.cpp
index be610ee8b6..c788fd9893 100644
--- a/plugins/qmlprofiler/inputeventsmodel.cpp
+++ b/plugins/qmlprofiler/inputeventsmodel.cpp
@@ -63,6 +63,11 @@ QVariantList InputEventsModel::labels() const
return result;
}
+QMetaEnum InputEventsModel::metaEnum(const char *name)
+{
+ return staticQtMetaObject.enumerator(staticQtMetaObject.indexOfEnumerator(name));
+}
+
QVariantMap InputEventsModel::details(int index) const
{
QVariantMap result;
@@ -76,12 +81,11 @@ QVariantMap InputEventsModel::details(int index) const
if (type.isEmpty())
type = tr("Key Release");
if (event.a != 0) {
- result.insert(tr("Key"), QLatin1String(
- QMetaEnum::fromType<Qt::Key>().valueToKey(event.a)));
+ result.insert(tr("Key"), QLatin1String(metaEnum("Key").valueToKey(event.a)));
}
if (event.b != 0) {
- result.insert(tr("Modifiers"), QLatin1String(
- QMetaEnum::fromType<Qt::KeyboardModifiers>().valueToKeys(event.b)));
+ result.insert(tr("Modifiers"),
+ QLatin1String(metaEnum("KeyboardModifiers").valueToKeys(event.b)));
}
break;
case QmlDebug::InputMouseDoubleClick:
@@ -92,10 +96,8 @@ QVariantMap InputEventsModel::details(int index) const
case QmlDebug::InputMouseRelease:
if (type.isEmpty())
type = tr("Mouse Release");
- result.insert(tr("Button"), QLatin1String(
- QMetaEnum::fromType<Qt::MouseButtons>().valueToKey(event.a)));
- result.insert(tr("Result"), QLatin1String(
- QMetaEnum::fromType<Qt::MouseButtons>().valueToKeys(event.b)));
+ result.insert(tr("Button"), QLatin1String(metaEnum("MouseButtons").valueToKey(event.a)));
+ result.insert(tr("Result"), QLatin1String(metaEnum("MouseButtons").valueToKeys(event.b)));
break;
case QmlDebug::InputMouseMove:
type = tr("Mouse Move");
diff --git a/plugins/qmlprofiler/inputeventsmodel.h b/plugins/qmlprofiler/inputeventsmodel.h
index 8c0ff17216..24dae3f386 100644
--- a/plugins/qmlprofiler/inputeventsmodel.h
+++ b/plugins/qmlprofiler/inputeventsmodel.h
@@ -52,6 +52,7 @@ public:
void clear();
private:
+ static QMetaEnum metaEnum(const char *name);
int m_keyTypeId;
int m_mouseTypeId;