Skip to contentSkip to conversation

kernel-shark-qt: Correct the coordinates of the Quick Context Menu

PATCH In review Yordan Karadzhov 2 participants 3 messages Dec 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kernel-shark-qt: Correct the coordinates of the Quick Context Menu

The "Y" coordinate of the Quick Context Menu has to be corrected in the case when the menu gets opened from the Graph widget. This is needed because the Graph widget is nested inside a scroll area and we have to take into account the offset of the vertical scrollbar.

---
 kernel-shark-qt/src/KsTraceGraph.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel-shark-qt/src/KsTraceGraph.cpp +7 -1
index 0b5a8b1..858930c 100644
@@ -782,6 +782,12 @@ void KsTraceGraph::_onCustomContextMenu(const QPoint &point)
 		connect(menu,	&KsQuickMarkerMenu::deselect,
 			this,	&KsTraceGraph::deselect);
 
-		menu->exec(mapToGlobal(point));
+		QPoint global = mapToGlobal(point);
+		/*
+		 * The global coordinates have to be corrected for the offset
+		 * of the vertical scrollbar.
+		 */
+		global.ry() -= _scrollArea.verticalScrollBar()->value();
+		menu->exec(global);
 	}
 }
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 kernel-shark-qt: Add better handling of the search iterator.

This patch provides better handling of the search iterator in the case when no matches are found. Without these fixes, the search iterator shows an arbitrary value when we load a session that has the active marker being set.

---
 kernel-shark-qt/src/KsTraceViewer.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
kernel-shark-qt/src/KsTraceViewer.cpp +8 -3
index d52d7e3..a308ea0 100644
@@ -420,8 +420,13 @@ void KsTraceViewer::_prev()
 
 void KsTraceViewer::_updateSearchCount()
 {
-	int index(_it - _matchList.begin());
-	int total(_matchList.count());
+	int index, total;
+
+	if (_matchList.isEmpty())
+		return;
+
+	index = _it - _matchList.begin();
+	total =_matchList.count();
 
 	_searchCountLabel.setText(QString(" %1 / %2").arg(index).arg(total));
 }
@@ -655,6 +660,7 @@ size_t KsTraceViewer::_searchItems(int column,
 
 void KsTraceViewer::_setSearchIterator(int row)
 {
+	_it = _matchList.begin();
 	if (_matchList.isEmpty())
 		return;
 
@@ -662,7 +668,6 @@ void KsTraceViewer::_setSearchIterator(int row)
 	 * Move the iterator to the first element of the match list
 	 * after the selected one.
 	 */
-	_it = _matchList.begin();
 	while (*_it < row) {
 		++_it;  // Move the iterator.
 		if (_it == _matchList.end()) {
Signature · 1 line
2.17.1
#2 lore raw
In reply to Yordan Karadzhov
Quoted 6 lines · On Fri, 30 Nov 2018 15:38:11 +0000 Yordan Karadzhov <[email protected]>…

The "Y" coordinate of the Quick Context Menu has to be corrected in the case when the menu gets opened from the Graph widget. This is needed because the Graph widget is nested inside a scroll area and we have to take into account the offset of the vertical scrollbar.

Thanks!

I applied both patches.

-- Steve

Quoted 22 lines
---
 kernel-shark-qt/src/KsTraceGraph.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
kernel-shark-qt/src/KsTraceGraph.cpp +7 -1
index 0b5a8b1..858930c 100644
@@ -782,6 +782,12 @@ void KsTraceGraph::_onCustomContextMenu(const QPoint &point)
 		connect(menu,	&KsQuickMarkerMenu::deselect,
 			this,	&KsTraceGraph::deselect);
 
-		menu->exec(mapToGlobal(point));
+		QPoint global = mapToGlobal(point);
+		/*
+		 * The global coordinates have to be corrected for the offset
+		 * of the vertical scrollbar.
+		 */
+		global.ry() -= _scrollArea.verticalScrollBar()->value();
+		menu->exec(global);
 	}
 }