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
|
||||
spacing: 3
|
||||
property int indexDragged
|
||||
property int moveToIndex
|
||||
property int draggedY
|
||||
|
||||
addDisplaced: Transition {
|
||||
|
@ -255,24 +256,11 @@ ColumnLayout {
|
|||
}
|
||||
|
||||
function updateDrag(y) {
|
||||
var newIndex;
|
||||
print(serviceItemList.indexAt(0,y));
|
||||
serviceItemList.draggedY = y;
|
||||
if (y < 30) {
|
||||
indexedHLRec.y = 0;
|
||||
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)
|
||||
}
|
||||
if (moveToIndex === serviceItemList.indexAt(0,y))
|
||||
return;
|
||||
else
|
||||
moveToIndex = serviceItemList.indexAt(0,y);
|
||||
moveRequested(indexDragged, moveToIndex);
|
||||
}
|
||||
|
||||
function moveRequested(oldIndex, newIndex) {
|
||||
|
|
|
@ -183,16 +183,20 @@ bool ServiceItemModel::move(int sourceIndex, int destIndex) {
|
|||
qDebug() << index(destIndex).row();
|
||||
// beginResetModel();
|
||||
QModelIndex parent = index(sourceIndex).parent();
|
||||
if (sourceIndex >= 0 && sourceIndex != destIndex && destIndex >= 0 && destIndex < rowCount() && sourceIndex < rowCount()) {
|
||||
qDebug() << "starting move of: " << "source: " << sourceIndex << "dest: " << destIndex;
|
||||
bool begsuc = beginMoveRows(QModelIndex(), sourceIndex, sourceIndex, QModelIndex(), destIndex);
|
||||
if (begsuc)
|
||||
m_items.move(sourceIndex, destIndex);
|
||||
endMoveRows();
|
||||
if (sourceIndex >= 0 && sourceIndex != destIndex &&
|
||||
destIndex >= -1 && destIndex < rowCount() &&
|
||||
sourceIndex < rowCount()) {
|
||||
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);
|
||||
endMoveRows();
|
||||
}
|
||||
}
|
||||
// endResetModel();
|
||||
// emit dataChanged(index(sourceIndex), QModelIndex());
|
||||
// qDebug() << success;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue