fix currentItem property and signals
C++ / fmt (pull_request) Successful in 4s
JS/TS / lint (pull_request) Successful in 16s
JS/TS / fmt (pull_request) Successful in 18s
Python / static (pull_request) Successful in 58s
Rust / fmt (pull_request) Successful in 59s
C++ / build (pull_request) Successful in 2m16s
Rust / build (pull_request) Successful in 2m5s
Rust / clippy (pull_request) Successful in 1m30s
Python / verify (pull_request) Successful in 2m43s
C++ / clang-tidy (pull_request) Successful in 3m58s
C++ / fmt (pull_request) Successful in 4s
JS/TS / lint (pull_request) Successful in 16s
JS/TS / fmt (pull_request) Successful in 18s
Python / static (pull_request) Successful in 58s
Rust / fmt (pull_request) Successful in 59s
C++ / build (pull_request) Successful in 2m16s
Rust / build (pull_request) Successful in 2m5s
Rust / clippy (pull_request) Successful in 1m30s
Python / verify (pull_request) Successful in 2m43s
C++ / clang-tidy (pull_request) Successful in 3m58s
This commit is contained in:
@@ -89,6 +89,8 @@ void CarouselView::setModel(const QVariantList& m) {
|
||||
|
||||
if (newCount == 0) {
|
||||
m_currentRealIndex = -1;
|
||||
m_currentItem = nullptr;
|
||||
emit currentItemChanged();
|
||||
|
||||
releaseAllItems();
|
||||
rebuildArrangement();
|
||||
@@ -248,6 +250,22 @@ void CarouselView::setCurrentIndex(int idx) {
|
||||
goToIndex(idx);
|
||||
}
|
||||
|
||||
void CarouselView::updateCurrentItem() {
|
||||
QQuickItem* item = nullptr;
|
||||
|
||||
for (const Slot& s : std::as_const(m_slots)) {
|
||||
if (s.active && s.virtualIndex == m_currentVirtualIndex) {
|
||||
item = s.item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (item == m_currentItem) return;
|
||||
|
||||
m_currentItem = item;
|
||||
emit currentItemChanged();
|
||||
}
|
||||
|
||||
void CarouselView::geometryChange(const QRectF& newGeo, const QRectF& oldGeo) {
|
||||
QQuickItem::geometryChange(newGeo, oldGeo);
|
||||
|
||||
@@ -844,6 +862,7 @@ void CarouselView::relayout() {
|
||||
if (s.item) s.item->setVisible(false);
|
||||
}
|
||||
|
||||
updateCurrentItem();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -918,6 +937,8 @@ void CarouselView::relayout() {
|
||||
for (const Slot& s : std::as_const(m_slots)) {
|
||||
positionSlot(s);
|
||||
}
|
||||
|
||||
updateCurrentItem();
|
||||
}
|
||||
|
||||
void CarouselView::cancelAnimations() {
|
||||
|
||||
Reference in New Issue
Block a user