forked from qt-creator/qt-creator
Tracing: Add tooltip and category color properties to TimelineModel
This doesn't change the existing behavior. The new properties are used by the upcoming CTF plugin. Change-Id: Ic375e8d70fdc7dbd3c124f83087a0e220a76f2c1 Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -53,15 +53,6 @@ Item {
|
||||
|
||||
property bool reverseSelect: false
|
||||
|
||||
Button {
|
||||
// dummy button to display a tooltip
|
||||
anchors.fill: txt
|
||||
ToolTip.text: labelContainer.text
|
||||
ToolTip.visible: enabled && hovered
|
||||
ToolTip.delay: 1000
|
||||
background: Item {}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: dragArea
|
||||
anchors.fill: txt
|
||||
@@ -70,6 +61,12 @@ Item {
|
||||
drag.minimumY: dragging ? 0 : -dragOffset // Account for parent change below
|
||||
drag.maximumY: draggerParent.height - (dragging ? 0 : dragOffset)
|
||||
drag.axis: Drag.YAxis
|
||||
hoverEnabled: true
|
||||
ToolTip {
|
||||
text: model.tooltip || labelContainer.text
|
||||
visible: enabled && parent.containsMouse
|
||||
delay: 1000
|
||||
}
|
||||
}
|
||||
|
||||
DropArea {
|
||||
|
@@ -404,17 +404,9 @@ Rectangle {
|
||||
|
||||
function showInfo() {
|
||||
var timelineModel = timelineModelAggregator.models[selectedModel];
|
||||
var eventData = timelineModel.details(selectedItem)
|
||||
var content = [];
|
||||
for (var k in eventData) {
|
||||
if (k === "displayName") {
|
||||
dialogTitle = eventData[k];
|
||||
} else {
|
||||
content.push(k);
|
||||
content.push(eventData[k]);
|
||||
}
|
||||
}
|
||||
rangeDetails.model = content;
|
||||
var eventData = timelineModel.orderedDetails(selectedItem)
|
||||
dialogTitle = eventData["title"] || "";
|
||||
rangeDetails.model = eventData["content"] || [];
|
||||
|
||||
var location = timelineModel.location(selectedItem)
|
||||
if (location.hasOwnProperty("file")) { // not empty
|
||||
|
@@ -86,6 +86,12 @@ Flickable {
|
||||
height: loader.height
|
||||
width: loader.width
|
||||
|
||||
Rectangle {
|
||||
height: loader.height
|
||||
width: 3
|
||||
color: modelData.categoryColor
|
||||
}
|
||||
|
||||
CategoryLabel {
|
||||
id: label
|
||||
model: modelData
|
||||
|
@@ -135,8 +135,8 @@ int TimelineModel::row(int index) const
|
||||
}
|
||||
|
||||
TimelineModel::TimelineModelPrivate::TimelineModelPrivate(int modelId) :
|
||||
modelId(modelId), expanded(false), hidden(false),
|
||||
expandedRowCount(1), collapsedRowCount(1)
|
||||
modelId(modelId), categoryColor(Qt::transparent), expanded(false),
|
||||
hidden(false), expandedRowCount(1), collapsedRowCount(1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -514,6 +514,28 @@ int TimelineModel::rowCount() const
|
||||
return d->expanded ? d->expandedRowCount : d->collapsedRowCount;
|
||||
}
|
||||
|
||||
QString TimelineModel::tooltip() const
|
||||
{
|
||||
return d->tooltip;
|
||||
}
|
||||
|
||||
void TimelineModel::setTooltip(const QString &text)
|
||||
{
|
||||
d->tooltip = text;
|
||||
emit tooltipChanged();
|
||||
}
|
||||
|
||||
QColor TimelineModel::categoryColor() const
|
||||
{
|
||||
return d->categoryColor;
|
||||
}
|
||||
|
||||
void TimelineModel::setCategoryColor(const QColor &color)
|
||||
{
|
||||
d->categoryColor = color;
|
||||
emit categoryColorChanged();
|
||||
}
|
||||
|
||||
QRgb TimelineModel::color(int index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
@@ -531,6 +553,32 @@ QVariantMap TimelineModel::details(int index) const
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TimelineModel::orderedDetails returns the title and content for the details popup
|
||||
* @param index of the selected item
|
||||
* @return QVariantMap containing the fields 'title' (QString) and 'content' (QVariantList
|
||||
* with alternating keys and values as QStrings)
|
||||
*/
|
||||
QVariantMap TimelineModel::orderedDetails(int index) const
|
||||
{
|
||||
QVariantMap info = details(index);
|
||||
QVariantMap data;
|
||||
QVariantList content;
|
||||
auto it = info.constBegin();
|
||||
auto end = info.constEnd();
|
||||
while (it != end) {
|
||||
if (it.key() == "displayName") {
|
||||
data.insert("title", it.value());
|
||||
} else {
|
||||
content.append(it.key());
|
||||
content.append(it.value());
|
||||
}
|
||||
++it;
|
||||
}
|
||||
data.insert("content", content);
|
||||
return data;
|
||||
}
|
||||
|
||||
int TimelineModel::expandedRow(int index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
|
@@ -40,6 +40,8 @@ class TRACING_EXPORT TimelineModel : public QObject
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int modelId READ modelId CONSTANT)
|
||||
Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
|
||||
Q_PROPERTY(QString tooltip READ tooltip NOTIFY tooltipChanged)
|
||||
Q_PROPERTY(QColor categoryColor READ categoryColor NOTIFY categoryColorChanged)
|
||||
Q_PROPERTY(bool empty READ isEmpty NOTIFY contentChanged)
|
||||
Q_PROPERTY(bool hidden READ hidden WRITE setHidden NOTIFY hiddenChanged)
|
||||
Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged)
|
||||
@@ -92,10 +94,17 @@ public:
|
||||
int collapsedRowCount() const;
|
||||
int rowCount() const;
|
||||
|
||||
QString tooltip() const;
|
||||
void setTooltip(const QString &text);
|
||||
|
||||
QColor categoryColor() const;
|
||||
void setCategoryColor(const QColor &color);
|
||||
|
||||
// Methods which can optionally be implemented by child models.
|
||||
Q_INVOKABLE virtual QRgb color(int index) const;
|
||||
virtual QVariantList labels() const;
|
||||
Q_INVOKABLE virtual QVariantMap details(int index) const;
|
||||
Q_INVOKABLE virtual QVariantMap orderedDetails(int index) const;
|
||||
Q_INVOKABLE virtual int expandedRow(int index) const;
|
||||
Q_INVOKABLE virtual int collapsedRow(int index) const;
|
||||
Q_INVOKABLE int row(int index) const;
|
||||
@@ -124,6 +133,8 @@ signals:
|
||||
void heightChanged();
|
||||
void rowCountChanged();
|
||||
void displayNameChanged();
|
||||
void tooltipChanged();
|
||||
void categoryColorChanged();
|
||||
void labelsChanged();
|
||||
void detailsChanged();
|
||||
|
||||
|
@@ -138,6 +138,8 @@ public:
|
||||
QVector<int> rowOffsets;
|
||||
const int modelId;
|
||||
QString displayName;
|
||||
QString tooltip;
|
||||
QColor categoryColor;
|
||||
|
||||
bool expanded;
|
||||
bool hidden;
|
||||
|
Reference in New Issue
Block a user