Tracing: Add hasMixedTypesInExpandedState property to TimelineModel

If the property is true, it disables the functionality to select the
type of row by clicking on the row label.
This is required by the CtfVisualizer plugin that shows more than one
type of events per row in the expanded state which would make the above
mentioned functionality meaningless.
This change doesn't change the current default behavior.

Change-Id: I20d42404a4cd3c9142bf0b59b57f4de083be07f3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Tim Henning
2019-08-29 11:37:14 +02:00
parent 96ecbf363c
commit 41361047b4
4 changed files with 22 additions and 2 deletions

View File

@@ -121,6 +121,8 @@ Item {
sourceComponent: RowLabel { sourceComponent: RowLabel {
label: labels[index]; label: labels[index];
onSelectBySelectionId: { onSelectBySelectionId: {
if (labelContainer.model.hasMixedTypesInExpandedState)
return;
if (labelContainer.reverseSelect) { if (labelContainer.reverseSelect) {
labelContainer.selectPrevBySelectionId(label.id); labelContainer.selectPrevBySelectionId(label.id);
} else { } else {

View File

@@ -135,8 +135,8 @@ int TimelineModel::row(int index) const
} }
TimelineModel::TimelineModelPrivate::TimelineModelPrivate(int modelId) : TimelineModel::TimelineModelPrivate::TimelineModelPrivate(int modelId) :
modelId(modelId), categoryColor(Qt::transparent), expanded(false), modelId(modelId), categoryColor(Qt::transparent), hasMixedTypesInExpandedState(false),
hidden(false), expandedRowCount(1), collapsedRowCount(1) expanded(false), hidden(false), expandedRowCount(1), collapsedRowCount(1)
{ {
} }
@@ -536,6 +536,17 @@ void TimelineModel::setCategoryColor(const QColor &color)
emit categoryColorChanged(); emit categoryColorChanged();
} }
bool TimelineModel::hasMixedTypesInExpandedState() const
{
return d->hasMixedTypesInExpandedState;
}
void TimelineModel::setHasMixedTypesInExpandedState(bool value)
{
d->hasMixedTypesInExpandedState = value;
emit hasMixedTypesInExpandedStateChanged();
}
QRgb TimelineModel::color(int index) const QRgb TimelineModel::color(int index) const
{ {
Q_UNUSED(index) Q_UNUSED(index)

View File

@@ -42,6 +42,7 @@ class TRACING_EXPORT TimelineModel : public QObject
Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged) Q_PROPERTY(QString displayName READ displayName WRITE setDisplayName NOTIFY displayNameChanged)
Q_PROPERTY(QString tooltip READ tooltip NOTIFY tooltipChanged) Q_PROPERTY(QString tooltip READ tooltip NOTIFY tooltipChanged)
Q_PROPERTY(QColor categoryColor READ categoryColor NOTIFY categoryColorChanged) Q_PROPERTY(QColor categoryColor READ categoryColor NOTIFY categoryColorChanged)
Q_PROPERTY(bool hasMixedTypesInExpandedState READ hasMixedTypesInExpandedState NOTIFY hasMixedTypesInExpandedStateChanged)
Q_PROPERTY(bool empty READ isEmpty NOTIFY contentChanged) Q_PROPERTY(bool empty READ isEmpty NOTIFY contentChanged)
Q_PROPERTY(bool hidden READ hidden WRITE setHidden NOTIFY hiddenChanged) Q_PROPERTY(bool hidden READ hidden WRITE setHidden NOTIFY hiddenChanged)
Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged) Q_PROPERTY(bool expanded READ expanded WRITE setExpanded NOTIFY expandedChanged)
@@ -100,6 +101,10 @@ public:
QColor categoryColor() const; QColor categoryColor() const;
void setCategoryColor(const QColor &color); void setCategoryColor(const QColor &color);
// if this is disabled, a click on the row label will select the single type it contains
bool hasMixedTypesInExpandedState() const;
void setHasMixedTypesInExpandedState(bool value);
// Methods which can optionally be implemented by child models. // Methods which can optionally be implemented by child models.
Q_INVOKABLE virtual QRgb color(int index) const; Q_INVOKABLE virtual QRgb color(int index) const;
virtual QVariantList labels() const; virtual QVariantList labels() const;
@@ -135,6 +140,7 @@ signals:
void displayNameChanged(); void displayNameChanged();
void tooltipChanged(); void tooltipChanged();
void categoryColorChanged(); void categoryColorChanged();
void hasMixedTypesInExpandedStateChanged();
void labelsChanged(); void labelsChanged();
void detailsChanged(); void detailsChanged();

View File

@@ -140,6 +140,7 @@ public:
QString displayName; QString displayName;
QString tooltip; QString tooltip;
QColor categoryColor; QColor categoryColor;
bool hasMixedTypesInExpandedState;
bool expanded; bool expanded;
bool hidden; bool hidden;