forked from qt-creator/qt-creator
QmlProfiler: Keep TimelineRenderer and Button states in sync
You could enable the select-on-hover mode by clicking in an empty time line, even though the buttons bar was disabled. You could also trigger various bad behavior by clearing the view and restarting the profiler. Properly initializing and clearing all members, and sending change signals on clearing helps with that. Change-Id: Ie7df80a52daaf166c3a4adb2eb1f28a59c21df57 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -43,10 +43,10 @@ using namespace QmlProfiler::Internal;
|
||||
|
||||
TimelineRenderer::TimelineRenderer(QQuickPaintedItem *parent) :
|
||||
QQuickPaintedItem(parent), m_startTime(0), m_endTime(0), m_spacing(0), m_spacedDuration(0),
|
||||
m_lastStartTime(0), m_lastEndTime(0)
|
||||
, m_profilerModelProxy(0)
|
||||
m_lastStartTime(0), m_lastEndTime(0), m_profilerModelProxy(0), m_selectedItem(-1),
|
||||
m_selectedModel(-1), m_selectionLocked(true), m_startDragArea(-1), m_endDragArea(-1)
|
||||
{
|
||||
clearData();
|
||||
resetCurrentSelection();
|
||||
setAcceptedMouseButtons(Qt::LeftButton);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
@@ -102,6 +102,15 @@ inline void TimelineRenderer::getItemXExtent(int modelIndex, int i, int ¤t
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineRenderer::resetCurrentSelection()
|
||||
{
|
||||
m_currentSelection.startTime = -1;
|
||||
m_currentSelection.endTime = -1;
|
||||
m_currentSelection.row = -1;
|
||||
m_currentSelection.eventIndex = -1;
|
||||
m_currentSelection.modelIndex = -1;
|
||||
}
|
||||
|
||||
void TimelineRenderer::paint(QPainter *p)
|
||||
{
|
||||
qint64 windowDuration = m_endTime - m_startTime;
|
||||
@@ -318,7 +327,8 @@ void TimelineRenderer::mousePressEvent(QMouseEvent *event)
|
||||
void TimelineRenderer::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
manageClicked();
|
||||
if (!m_profilerModelProxy->isEmpty())
|
||||
manageClicked();
|
||||
}
|
||||
|
||||
void TimelineRenderer::mouseMoveEvent(QMouseEvent *event)
|
||||
@@ -415,18 +425,18 @@ void TimelineRenderer::manageHovered(int mouseX, int mouseY)
|
||||
|
||||
void TimelineRenderer::clearData()
|
||||
{
|
||||
m_startTime = 0;
|
||||
m_endTime = 0;
|
||||
m_lastStartTime = 0;
|
||||
m_lastEndTime = 0;
|
||||
m_currentSelection.startTime = -1;
|
||||
m_currentSelection.endTime = -1;
|
||||
m_currentSelection.row = -1;
|
||||
m_currentSelection.eventIndex = -1;
|
||||
m_currentSelection.modelIndex = -1;
|
||||
m_selectedItem = -1;
|
||||
m_selectedModel = -1;
|
||||
m_selectionLocked = true;
|
||||
m_spacing = 0;
|
||||
m_spacedDuration = 0;
|
||||
resetCurrentSelection();
|
||||
setStartTime(0);
|
||||
setEndTime(0);
|
||||
setSelectedItem(-1);
|
||||
setSelectedModel(-1);
|
||||
setSelectionLocked(true);
|
||||
setStartDragArea(-1);
|
||||
setEndDragArea(-1);
|
||||
}
|
||||
|
||||
int TimelineRenderer::getYPosition(int modelIndex, int index) const
|
||||
|
||||
@@ -198,6 +198,7 @@ private:
|
||||
private:
|
||||
static const int OutOfScreenMargin = 3; // margin to make sure the rectangles stay invisible
|
||||
inline void getItemXExtent(int modelIndex, int i, int ¤tX, int &itemWidth);
|
||||
void resetCurrentSelection();
|
||||
|
||||
qint64 m_startTime;
|
||||
qint64 m_endTime;
|
||||
|
||||
Reference in New Issue
Block a user