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) {
|
if (newCount == 0) {
|
||||||
m_currentRealIndex = -1;
|
m_currentRealIndex = -1;
|
||||||
|
m_currentItem = nullptr;
|
||||||
|
emit currentItemChanged();
|
||||||
|
|
||||||
releaseAllItems();
|
releaseAllItems();
|
||||||
rebuildArrangement();
|
rebuildArrangement();
|
||||||
@@ -248,6 +250,22 @@ void CarouselView::setCurrentIndex(int idx) {
|
|||||||
goToIndex(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) {
|
void CarouselView::geometryChange(const QRectF& newGeo, const QRectF& oldGeo) {
|
||||||
QQuickItem::geometryChange(newGeo, oldGeo);
|
QQuickItem::geometryChange(newGeo, oldGeo);
|
||||||
|
|
||||||
@@ -844,6 +862,7 @@ void CarouselView::relayout() {
|
|||||||
if (s.item) s.item->setVisible(false);
|
if (s.item) s.item->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCurrentItem();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -918,6 +937,8 @@ void CarouselView::relayout() {
|
|||||||
for (const Slot& s : std::as_const(m_slots)) {
|
for (const Slot& s : std::as_const(m_slots)) {
|
||||||
positionSlot(s);
|
positionSlot(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCurrentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::cancelAnimations() {
|
void CarouselView::cancelAnimations() {
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ class CarouselView : public QQuickItem {
|
|||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY
|
int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY
|
||||||
currentIndexChanged)
|
currentIndexChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(
|
||||||
|
QQuickItem* currentItem READ currentItem NOTIFY currentItemChanged)
|
||||||
|
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
int glideDuration READ glideDuration WRITE setGlideDuration NOTIFY
|
int glideDuration READ glideDuration WRITE setGlideDuration NOTIFY
|
||||||
glideDurationChanged)
|
glideDurationChanged)
|
||||||
@@ -79,6 +83,8 @@ class CarouselView : public QQuickItem {
|
|||||||
int currentIndex() const { return m_currentRealIndex; }
|
int currentIndex() const { return m_currentRealIndex; }
|
||||||
void setCurrentIndex(int idx);
|
void setCurrentIndex(int idx);
|
||||||
|
|
||||||
|
QQuickItem* currentItem() const { return m_currentItem; }
|
||||||
|
|
||||||
int glideDuration() const { return m_glideDuration; }
|
int glideDuration() const { return m_glideDuration; }
|
||||||
void setGlideDuration(int v);
|
void setGlideDuration(int v);
|
||||||
|
|
||||||
@@ -103,6 +109,7 @@ class CarouselView : public QQuickItem {
|
|||||||
void tileHeightChanged();
|
void tileHeightChanged();
|
||||||
void maxWidthChanged();
|
void maxWidthChanged();
|
||||||
void currentIndexChanged();
|
void currentIndexChanged();
|
||||||
|
void currentItemChanged();
|
||||||
void glideDurationChanged();
|
void glideDurationChanged();
|
||||||
void glideEasingTypeChanged();
|
void glideEasingTypeChanged();
|
||||||
void delegatePropertiesChanged();
|
void delegatePropertiesChanged();
|
||||||
@@ -173,6 +180,8 @@ class CarouselView : public QQuickItem {
|
|||||||
|
|
||||||
void updateCurrentIndexFromContentX(bool emitPreview);
|
void updateCurrentIndexFromContentX(bool emitPreview);
|
||||||
|
|
||||||
|
void updateCurrentItem();
|
||||||
|
|
||||||
void wrapContentIfNeeded();
|
void wrapContentIfNeeded();
|
||||||
void centerInstantlyOnReal(int realIndex);
|
void centerInstantlyOnReal(int realIndex);
|
||||||
|
|
||||||
@@ -198,6 +207,8 @@ class CarouselView : public QQuickItem {
|
|||||||
int m_currentRealIndex = -1;
|
int m_currentRealIndex = -1;
|
||||||
int m_previewRealIndex = -1;
|
int m_previewRealIndex = -1;
|
||||||
|
|
||||||
|
QQuickItem* m_currentItem = nullptr;
|
||||||
|
|
||||||
int m_centerBlockStart = 0;
|
int m_centerBlockStart = 0;
|
||||||
|
|
||||||
QList<Slot> m_slots;
|
QList<Slot> m_slots;
|
||||||
|
|||||||
Reference in New Issue
Block a user