aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/extras
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-09-16 16:01:33 +0200
committerMitch Curtis <mitch.curtis@theqtcompany.com>2015-09-17 11:41:22 +0000
commit7c5c9d1fb8bff09d955489f65098f3f63c53bef5 (patch)
tree73bd900bc161a532031b263e2ba5723439513a52 /src/imports/extras
parent7e6973ad91efd62a3f4e4bb6592dd8e04e7225c0 (diff)
Move currentIndex, add/insert/removeItem to QQuickContainer
Change-Id: I6bb2adb4de972bb62f0e72c80cc50cf90964631f Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/imports/extras')
-rw-r--r--src/imports/extras/qquickswipeview.cpp67
-rw-r--r--src/imports/extras/qquickswipeview_p.h12
2 files changed, 5 insertions, 74 deletions
diff --git a/src/imports/extras/qquickswipeview.cpp b/src/imports/extras/qquickswipeview.cpp
index c6203f23..bb89f9fd 100644
--- a/src/imports/extras/qquickswipeview.cpp
+++ b/src/imports/extras/qquickswipeview.cpp
@@ -56,19 +56,17 @@ class QQuickSwipeViewPrivate : public QQuickContainerPrivate
Q_DECLARE_PUBLIC(QQuickSwipeView)
public:
- QQuickSwipeViewPrivate() : currentIndex(-1), updatingCurrent(false) { }
+ QQuickSwipeViewPrivate() : updatingCurrent(false) { }
void resizeItem(QQuickItem *item);
void resizeItems();
void _q_updateCurrent();
- void insertItem(int index, QQuickItem *item) Q_DECL_OVERRIDE;
- void moveItem(int from, int to) Q_DECL_OVERRIDE;
- void removeItem(int index, QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemInserted(int index, QQuickItem *item) Q_DECL_OVERRIDE;
+ void itemMoved(int from, int to) Q_DECL_OVERRIDE;
static QQuickSwipeViewPrivate *get(QQuickSwipeView *view);
- int currentIndex;
bool updatingCurrent;
};
@@ -90,23 +88,16 @@ void QQuickSwipeViewPrivate::_q_updateCurrent()
q->setCurrentIndex(contentItem ? contentItem->property("currentIndex").toInt() : -1);
}
-void QQuickSwipeViewPrivate::insertItem(int index, QQuickItem *item)
+void QQuickSwipeViewPrivate::itemInserted(int, QQuickItem *item)
{
Q_Q(QQuickSwipeView);
if (q->isComponentComplete())
item->setSize(QSizeF(contentItem->width(), contentItem->height()));
-
- QQuickContainerPrivate::insertItem(index, item);
-
- if (contentModel->count() == 1 && currentIndex == -1)
- q->setCurrentIndex(index);
}
-void QQuickSwipeViewPrivate::moveItem(int from, int to)
+void QQuickSwipeViewPrivate::itemMoved(int from, int to)
{
Q_Q(QQuickSwipeView);
- QQuickContainerPrivate::moveItem(from, to);
-
updatingCurrent = true;
if (from == currentIndex)
q->setCurrentIndex(to);
@@ -117,22 +108,6 @@ void QQuickSwipeViewPrivate::moveItem(int from, int to)
updatingCurrent = false;
}
-void QQuickSwipeViewPrivate::removeItem(int index, QQuickItem *item)
-{
- Q_Q(QQuickSwipeView);
- bool currentChanged = false;
- if (index == currentIndex) {
- q->setCurrentIndex(currentIndex - 1);
- } else if (index < currentIndex) {
- --currentIndex;
- currentChanged = true;
- }
-
- QQuickContainerPrivate::removeItem(index, item);
-
- if (currentChanged)
- emit q->currentIndexChanged();
-}
QQuickSwipeViewPrivate *QQuickSwipeViewPrivate::get(QQuickSwipeView *view)
{
@@ -146,38 +121,6 @@ QQuickSwipeView::QQuickSwipeView(QQuickItem *parent) :
setActiveFocusOnTab(true);
}
-/*!
- \qmlproperty int QtQuickControls2::SwipeView::currentIndex
-
- TODO
-*/
-int QQuickSwipeView::currentIndex() const
-{
- Q_D(const QQuickSwipeView);
- return d->currentIndex;
-}
-
-void QQuickSwipeView::setCurrentIndex(int index)
-{
- Q_D(QQuickSwipeView);
- if (d->currentIndex != index) {
- d->currentIndex = index;
- emit currentIndexChanged();
- emit currentItemChanged();
- }
-}
-
-/*!
- \qmlproperty Item QtQuickControls2::SwipeView::currentItem
-
- TODO
-*/
-QQuickItem *QQuickSwipeView::currentItem() const
-{
- Q_D(const QQuickSwipeView);
- return itemAt(d->currentIndex);
-}
-
QQuickSwipeViewAttached *QQuickSwipeView::qmlAttachedProperties(QObject *object)
{
QQuickItem *item = qobject_cast<QQuickItem *>(object);
diff --git a/src/imports/extras/qquickswipeview_p.h b/src/imports/extras/qquickswipeview_p.h
index 5541a677..89d344ef 100644
--- a/src/imports/extras/qquickswipeview_p.h
+++ b/src/imports/extras/qquickswipeview_p.h
@@ -58,24 +58,12 @@ class QQuickSwipeViewPrivate;
class QQuickSwipeView : public QQuickContainer
{
Q_OBJECT
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged FINAL)
- Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged FINAL)
public:
explicit QQuickSwipeView(QQuickItem *parent = Q_NULLPTR);
- int currentIndex() const;
- QQuickItem *currentItem() const;
-
static QQuickSwipeViewAttached *qmlAttachedProperties(QObject *object);
-public Q_SLOTS:
- void setCurrentIndex(int index);
-
-Q_SIGNALS:
- void currentIndexChanged();
- void currentItemChanged();
-
protected:
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_DECL_OVERRIDE;
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;