/*! \qmlmethod ListModel::move(int from, int to, int n) Moves \a n items \a from one position \a to another. The from and to ranges must exist; for example, to move the first 3 items to the end of the list: \code fruitModel.move(0, fruitModel.count - 3, 3) \endcode \sa append() */ void QDeclarativeListModel::move(int from, int to, int n) { if (n==0 || from==to) return; if (!canMove(from, to, n)) { qmlInfo(this) << tr("move: out of range"); return; } int origfrom = from; int origto = to; int orign = n; if (from > to) { // Only move forwards - flip if backwards moving int tfrom = from; int tto = to; from = tto; to = tto+n; n = tfrom-tto; } if (m_flat) m_flat->move(from, to, n); else m_nested->move(from, to, n); if (!inWorkerThread()) emit itemsMoved(origfrom, origto, orign); }
bool Test::moveItems(int from, int to, int count) { QList<QIcon> moved; for (int i = 0; i < count; ++i) moved.append(icons.takeAt((from))); for (int j = 0; j < count; ++j) moved.insert(to, moved.takeFirst()); emit itemsMoved(from, to, count); return true; }
int QtListModelInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: itemsInserted((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 1: itemsRemoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 2: itemsMoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 3: itemsChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< const QList<QByteArray>(*)>(_a[3]))); break; default: ; } _id -= 4; } return _id; }