hoping to fix the moving items in leftdock
This commit is contained in:
parent
16b068e884
commit
19c7e4cd40
2 changed files with 19 additions and 27 deletions
|
@ -59,6 +59,7 @@ ColumnLayout {
|
||||||
clip: true
|
clip: true
|
||||||
spacing: 3
|
spacing: 3
|
||||||
property int indexDragged
|
property int indexDragged
|
||||||
|
property int moveToIndex
|
||||||
property int draggedY
|
property int draggedY
|
||||||
|
|
||||||
addDisplaced: Transition {
|
addDisplaced: Transition {
|
||||||
|
@ -255,24 +256,11 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDrag(y) {
|
function updateDrag(y) {
|
||||||
var newIndex;
|
if (moveToIndex === serviceItemList.indexAt(0,y))
|
||||||
print(serviceItemList.indexAt(0,y));
|
return;
|
||||||
serviceItemList.draggedY = y;
|
else
|
||||||
if (y < 30) {
|
moveToIndex = serviceItemList.indexAt(0,y);
|
||||||
indexedHLRec.y = 0;
|
moveRequested(indexDragged, moveToIndex);
|
||||||
newIndex = 0;
|
|
||||||
moveRequested(indexDragged, newIndex)
|
|
||||||
}
|
|
||||||
else if (y < 80) {
|
|
||||||
indexedHLRec.y = 50;
|
|
||||||
newIndex = 1;
|
|
||||||
moveRequested(indexDragged, newIndex)
|
|
||||||
}
|
|
||||||
else if (y < 130) {
|
|
||||||
indexedHLRec.y = 100;
|
|
||||||
newIndex = 2;
|
|
||||||
moveRequested(indexDragged, newIndex)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveRequested(oldIndex, newIndex) {
|
function moveRequested(oldIndex, newIndex) {
|
||||||
|
|
|
@ -183,16 +183,20 @@ bool ServiceItemModel::move(int sourceIndex, int destIndex) {
|
||||||
qDebug() << index(destIndex).row();
|
qDebug() << index(destIndex).row();
|
||||||
// beginResetModel();
|
// beginResetModel();
|
||||||
QModelIndex parent = index(sourceIndex).parent();
|
QModelIndex parent = index(sourceIndex).parent();
|
||||||
if (sourceIndex >= 0 && sourceIndex != destIndex && destIndex >= 0 && destIndex < rowCount() && sourceIndex < rowCount()) {
|
if (sourceIndex >= 0 && sourceIndex != destIndex &&
|
||||||
qDebug() << "starting move of: " << "source: " << sourceIndex << "dest: " << destIndex;
|
destIndex >= -1 && destIndex < rowCount() &&
|
||||||
bool begsuc = beginMoveRows(QModelIndex(), sourceIndex, sourceIndex, QModelIndex(), destIndex);
|
sourceIndex < rowCount()) {
|
||||||
if (begsuc)
|
qDebug() << "starting move: " << "source: " << sourceIndex << "dest: " << destIndex;
|
||||||
|
bool begsuc = beginMoveRows(QModelIndex(), sourceIndex,
|
||||||
|
sourceIndex, QModelIndex(), destIndex);
|
||||||
|
if (begsuc) {
|
||||||
|
if (destIndex = -1)
|
||||||
|
m_item.move(sourceIndex, 0);
|
||||||
|
else
|
||||||
m_items.move(sourceIndex, destIndex);
|
m_items.move(sourceIndex, destIndex);
|
||||||
endMoveRows();
|
endMoveRows();
|
||||||
}
|
}
|
||||||
// endResetModel();
|
}
|
||||||
// emit dataChanged(index(sourceIndex), QModelIndex());
|
|
||||||
// qDebug() << success;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue