focus tab chain fixed
This commit is contained in:
parent
3f97502a91
commit
cf7603da37
@ -43,33 +43,46 @@ static void qskUpdateFocusChain(
|
|||||||
QskGridBox* box, const QskGridLayoutEngine* engine,
|
QskGridBox* box, const QskGridLayoutEngine* engine,
|
||||||
QQuickItem* item, const QRect& grid )
|
QQuickItem* item, const QRect& grid )
|
||||||
{
|
{
|
||||||
auto comparePosition =
|
/*
|
||||||
[item, engine]( const QPoint& pos, const QQuickItem* child )
|
We are running over all entries each time an item gets inserted.
|
||||||
{
|
There should be a faster way TODO ...
|
||||||
if ( item != child )
|
*/
|
||||||
{
|
|
||||||
const int index = engine->indexOf( child );
|
|
||||||
if ( index >= 0 )
|
|
||||||
{
|
|
||||||
const auto grid = engine->gridAt( index );
|
|
||||||
if ( pos.y() < grid.y() )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if ( pos.y() == grid.y() && pos.x() < grid.x() )
|
const int cellIndex = grid.y() * engine->rowCount() + grid.x();
|
||||||
return true;
|
|
||||||
|
QQuickItem* itemNext = nullptr;
|
||||||
|
int minDelta = -1;
|
||||||
|
|
||||||
|
for ( int i = 0; i < engine->count(); i++ )
|
||||||
|
{
|
||||||
|
const auto itemAt = engine->itemAt( i );
|
||||||
|
|
||||||
|
if ( itemAt && item != itemAt )
|
||||||
|
{
|
||||||
|
const auto gridAt = engine->gridAt( i );
|
||||||
|
const int delta = gridAt.y() * engine->rowCount() + gridAt.x() - cellIndex;
|
||||||
|
|
||||||
|
if ( delta > 0 )
|
||||||
|
{
|
||||||
|
if ( itemNext == nullptr || delta < minDelta )
|
||||||
|
{
|
||||||
|
itemNext = itemAt;
|
||||||
|
minDelta = delta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
if ( itemNext )
|
||||||
};
|
{
|
||||||
|
item->stackBefore( itemNext );
|
||||||
const auto children = box->childItems();
|
}
|
||||||
|
else
|
||||||
auto it = std::upper_bound( children.begin(), children.end(),
|
{
|
||||||
grid.topLeft(), comparePosition );
|
const auto itemLast = box->childItems().last();
|
||||||
|
if ( itemLast != item )
|
||||||
if ( it != children.end() )
|
item->stackAfter( itemLast );
|
||||||
item->stackBefore( *it );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class QskGridBox::PrivateData
|
class QskGridBox::PrivateData
|
||||||
|
Loading…
x
Reference in New Issue
Block a user