MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / dropEvent

Method dropEvent

Gui/TableModelView.cpp:1403–1479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1401}
1402
1403void
1404TableView::dropEvent(QDropEvent* e)
1405{
1406 // QTreeView::dropEvent(e);
1407
1408 DropIndicatorPosition position = dropIndicatorPosition();
1409
1410 switch (position) {
1411 case QAbstractItemView::OnItem:
1412 case QAbstractItemView::OnViewport:
1413 default:
1414
1415 return;
1416
1417 case QAbstractItemView::AboveItem:
1418 case QAbstractItemView::BelowItem:
1419 break;
1420 }
1421 TableItem* into = itemAt( e->pos() );
1422
1423 if ( !into || _imp->draggedItems.empty() ) {
1424 return;
1425 }
1426 Q_EMIT aboutToDrop();
1427 int targetRow = into->row();
1428
1429 //We only support full rows
1430 assert(selectionBehavior() == QAbstractItemView::SelectRows);
1431
1432 ///Remove the items
1433 std::map<int, std::map<int, TableItem*> > rowMoved;
1434 for (std::list<TableItem*>::iterator it = _imp->draggedItems.begin(); it != _imp->draggedItems.end(); ++it) {
1435 rowMoved[(*it)->row()][(*it)->column()] = *it;
1436 TableItem* taken = _imp->model->takeItem( (*it)->row(), (*it)->column() );
1437 assert(taken == *it);
1438 Q_UNUSED(taken);
1439 }
1440 /// remove the rows in reverse order so that indexes are still valid
1441 for (std::map<int, std::map<int, TableItem*> >::reverse_iterator it = rowMoved.rbegin(); it != rowMoved.rend(); ++it) {
1442 _imp->model->removeRows(it->first);
1443 if (it->first <= targetRow) {
1444 --targetRow;
1445 }
1446 }
1447 _imp->draggedItems.clear();
1448 ///insert back at the correct position
1449
1450 int nRows = _imp->model->rowCount();
1451 switch (position) {
1452 case QAbstractItemView::AboveItem: {
1453 _imp->model->insertRows( targetRow, rowMoved.size() );
1454 break;
1455 }
1456 case QAbstractItemView::BelowItem: {
1457 ++targetRow;
1458 if (targetRow > nRows) {
1459 targetRow = nRows;
1460 }

Callers

nothing calls this directly

Calls 12

emptyMethod · 0.80
columnMethod · 0.80
takeItemMethod · 0.80
removeRowsMethod · 0.80
insertRowsMethod · 0.80
setItemMethod · 0.80
rowMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
rowCountMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected