X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=homescreen%2Fsrc%2Fapplicationmodel.cpp;fp=homescreen%2Fsrc%2Fapplicationmodel.cpp;h=417bc4ce6eb945538d8b6d31620cf8821587a3a7;hb=e412b716601f96466ca786784facb558e28e92e4;hp=c43e1bc34bb65029cd0a2b16fa2406a15ecd20cd;hpb=226982d32f334189b4f465a720a297548a42c077;p=apps%2Fhomescreen.git diff --git a/homescreen/src/applicationmodel.cpp b/homescreen/src/applicationmodel.cpp index c43e1bc..417bc4c 100644 --- a/homescreen/src/applicationmodel.cpp +++ b/homescreen/src/applicationmodel.cpp @@ -114,3 +114,31 @@ QHash ApplicationModel::roleNames() const roles[Qt::UserRole] = "id"; return roles; } + +QString ApplicationModel::id(int i) const +{ + return data(index(i), Qt::UserRole).toString(); +} + +void ApplicationModel::move(int from, int to) +{ + QModelIndex parent; + if (to < 0 || to > rowCount()) return; + if (from < to) { + if (!beginMoveRows(parent, from, from, parent, to + 1)) { + qDebug() << from << to << false; + return; + } + d->data.move(from, to); + endMoveRows(); + } else if (from > to) { + if (!beginMoveRows(parent, from, from, parent, to)) { + qDebug() << from << to << false; + return; + } + d->data.move(from, to); + endMoveRows(); + } else { + qDebug() << from << to << false; + } +}