Commit 84eadb01 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Update selection also when only model changes



Previously, if you selected an event with the same ID from a different
model the rangeDetails wouldn't be updated. Now modelId and itemId can only
be updated together and a single signal is emitted for that. This signal is
then used to update the details.

Change-Id: Ie1e971f5ac8c041b49df347fa0fbb401d5422766
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent fa1b5eeb
......@@ -172,13 +172,9 @@ Rectangle {
var modelIndex = qmlProfilerModelProxy.basicModelIndex();
var itemIndex = view.nextItemFromId(modelIndex, eventId);
// select an item, lock to it, and recenter if necessary
if (view.selectedItem != itemIndex || view.selectedModel != modelIndex) {
view.selectedModel = modelIndex;
view.selectedItem = itemIndex;
if (itemIndex !== -1) {
view.selectionLocked = true;
}
}
view.selectFromId(modelIndex, itemIndex); // triggers recentering
if (itemIndex !== -1)
view.selectionLocked = true;
lockItemSelection = false;
}
}
......@@ -331,7 +327,7 @@ Rectangle {
recursionGuard = false;
}
onSelectedItemChanged: {
onSelectionChanged: {
if (selectedItem !== -1) {
// display details
rangeDetails.showInfo(qmlProfilerModelProxy.getEventDetails(selectedModel, selectedItem));
......
......@@ -220,7 +220,7 @@ Item {
anchors.fill: parent
onClicked: {
root.hideRangeDetails();
view.selectedItem = -1;
view.selectFromId(view.selectedModel, -1);
}
}
}
......
......@@ -307,9 +307,7 @@ void TimelineRenderer::manageClicked()
} else {
setSelectionLocked(false);
}
setSelectedModel(m_currentSelection.modelIndex);
setSelectedItem(m_currentSelection.eventIndex);
selectFromId(m_currentSelection.modelIndex, m_currentSelection.eventIndex);
}
void TimelineRenderer::manageHovered(int mouseX, int mouseY)
......@@ -362,10 +360,8 @@ void TimelineRenderer::manageHovered(int mouseX, int mouseY)
m_currentSelection.endTime = itemEnd;
m_currentSelection.row = row;
m_currentSelection.modelIndex = modelIndex;
if (!m_selectionLocked) {
setSelectedModel(modelIndex);
setSelectedItem(i);
}
if (!m_selectionLocked)
selectFromId(modelIndex, i);
return;
}
}
......@@ -457,8 +453,7 @@ void TimelineRenderer::selectNext()
}
}
setSelectedModel(candidateModelIndex);
setSelectedItem(itemIndex);
selectFromId(candidateModelIndex, itemIndex);
}
void TimelineRenderer::selectPrev()
......@@ -510,8 +505,7 @@ void TimelineRenderer::selectPrev()
}
}
setSelectedModel(candidateModelIndex);
setSelectedItem(itemIndex);
selectFromId(candidateModelIndex, itemIndex);
}
int TimelineRenderer::nextItemFromId(int modelIndex, int eventId) const
......@@ -553,20 +547,21 @@ int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const
return -1;
}
void TimelineRenderer::selectNextFromId(int modelIndex, int eventId)
void TimelineRenderer::selectFromId(int modelIndex, int eventIndex)
{
int eventIndex = nextItemFromId(modelIndex, eventId);
if (eventIndex != -1) {
if (modelIndex != m_selectedModel || eventIndex != m_selectedItem) {
setSelectedModel(modelIndex);
setSelectedItem(eventIndex);
emit selectionChanged(modelIndex, eventIndex);
}
}
void TimelineRenderer::selectNextFromId(int modelIndex, int eventId)
{
selectFromId(modelIndex, nextItemFromId(modelIndex, eventId));
}
void TimelineRenderer::selectPrevFromId(int modelIndex, int eventId)
{
int eventIndex = prevItemFromId(modelIndex, eventId);
if (eventIndex != -1) {
setSelectedModel(modelIndex);
setSelectedItem(eventIndex);
}
selectFromId(modelIndex, prevItemFromId(modelIndex, eventId));
}
......@@ -45,8 +45,8 @@ class TimelineRenderer : public QQuickPaintedItem
Q_PROPERTY(qint64 endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
Q_PROPERTY(QObject *profilerModelProxy READ profilerModelProxy WRITE setProfilerModelProxy NOTIFY profilerModelProxyChanged)
Q_PROPERTY(bool selectionLocked READ selectionLocked WRITE setSelectionLocked NOTIFY selectionLockedChanged)
Q_PROPERTY(int selectedItem READ selectedItem WRITE setSelectedItem NOTIFY selectedItemChanged)
Q_PROPERTY(int selectedModel READ selectedModel WRITE setSelectedModel NOTIFY selectedModelChanged)
Q_PROPERTY(int selectedItem READ selectedItem NOTIFY selectedItemChanged)
Q_PROPERTY(int selectedModel READ selectedModel NOTIFY selectedModelChanged)
Q_PROPERTY(int startDragArea READ startDragArea WRITE setStartDragArea NOTIFY startDragAreaChanged)
Q_PROPERTY(int endDragArea READ endDragArea WRITE setEndDragArea NOTIFY endDragAreaChanged)
......@@ -97,6 +97,7 @@ public:
Q_INVOKABLE void selectPrev();
Q_INVOKABLE int nextItemFromId(int modelIndex, int eventId) const;
Q_INVOKABLE int prevItemFromId(int modelIndex, int eventId) const;
Q_INVOKABLE void selectFromId(int modelIndex, int eventId);
Q_INVOKABLE void selectNextFromId(int modelIndex, int eventId);
Q_INVOKABLE void selectPrevFromId(int modelIndex, int eventId);
......@@ -105,8 +106,9 @@ signals:
void endTimeChanged(qint64 arg);
void profilerModelProxyChanged(TimelineModelAggregator *list);
void selectionLockedChanged(bool locked);
void selectedItemChanged(int modelIndex, int itemIndex);
void selectedItemChanged(int itemIndex);
void selectedModelChanged(int modelIndex);
void selectionChanged(int modelIndex, int itemIndex);
void startDragAreaChanged(int startDragArea);
void endDragAreaChanged(int endDragArea);
void itemPressed(int modelIndex, int pressedItem);
......@@ -141,24 +143,6 @@ public slots:
}
}
void setSelectedItem(int itemIndex)
{
if (m_selectedItem != itemIndex) {
m_selectedItem = itemIndex;
update();
emit selectedItemChanged(m_selectedModel, itemIndex);
}
}
void setSelectedModel(int modelIndex)
{
if (m_selectedModel != modelIndex) {
m_selectedModel = modelIndex;
update();
emit selectedModelChanged(modelIndex);
}
}
void setStartDragArea(int startDragArea)
{
if (m_startDragArea != startDragArea) {
......@@ -192,6 +176,24 @@ private:
void manageClicked();
void manageHovered(int mouseX, int mouseY);
void setSelectedItem(int itemIndex)
{
if (m_selectedItem != itemIndex) {
m_selectedItem = itemIndex;
update();
emit selectedItemChanged(itemIndex);
}
}
void setSelectedModel(int modelIndex)
{
if (m_selectedModel != modelIndex) {
m_selectedModel = modelIndex;
update();
emit selectedModelChanged(modelIndex);
}
}
private:
qint64 m_startTime;
qint64 m_endTime;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment