mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Improve implementation of TabWorkArea::posIsTab()
The Qt documentation states that tabAt() returns -1 if the position is not over a tab. This behavior has been consistent since Qt 4.3 [1]. This commit's improvement likely makes the code faster in two ways: (1) we do not need to loop through potentially all tabs (2) we only need to look up the tab index corresponding with one position posIsTab() is not currently used intensively so no practical gain in speed is achieved, but it protects against future use. [1] https://doc.qt.io/archives/4.3/qtabbar.html#tabAt
This commit is contained in:
parent
9c3ddbf7a0
commit
badb0bb96c
@ -1650,10 +1650,8 @@ void TabWorkArea::paintEvent(QPaintEvent * event)
|
|||||||
|
|
||||||
bool TabWorkArea::posIsTab(QPoint position)
|
bool TabWorkArea::posIsTab(QPoint position)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count(); ++i)
|
// tabAt returns -1 if tab does not covers position
|
||||||
if (tabBar()->tabRect(i).contains(position))
|
return tabBar()->tabAt(position) > -1;
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user