Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/plugins/folder/foldermodel.cpp
Show First 20 Lines • Show All 717 Lines • ▼ Show 20 Line(s) | 681 | { | |||
---|---|---|---|---|---|
718 | } | 718 | } | ||
719 | 719 | | |||
720 | drag->setPixmap(QPixmap::fromImage(dragImage)); | 720 | drag->setPixmap(QPixmap::fromImage(dragImage)); | ||
721 | drag->setHotSpot(QPoint(x - offset.x(), y - offset.y())); | 721 | drag->setHotSpot(QPoint(x - offset.x(), y - offset.y())); | ||
722 | } | 722 | } | ||
723 | 723 | | |||
724 | void FolderModel::dragSelected(int x, int y) | 724 | void FolderModel::dragSelected(int x, int y) | ||
725 | { | 725 | { | ||
726 | if (m_dragInProgress) { | ||||
727 | return; | ||||
728 | } | ||||
729 | | ||||
730 | m_dragInProgress = true; | ||||
731 | | ||||
726 | // Avoid starting a drag synchronously in a mouse handler or interferes with | 732 | // Avoid starting a drag synchronously in a mouse handler or interferes with | ||
727 | // child event filtering in parent items (and thus e.g. press-and-hold hand- | 733 | // child event filtering in parent items (and thus e.g. press-and-hold hand- | ||
728 | // ling in a containment). | 734 | // ling in a containment). | ||
729 | QMetaObject::invokeMethod(this, "dragSelectedInternal", Qt::QueuedConnection, | 735 | QMetaObject::invokeMethod(this, "dragSelectedInternal", Qt::QueuedConnection, | ||
730 | Q_ARG(int, x), | 736 | Q_ARG(int, x), | ||
731 | Q_ARG(int, y)); | 737 | Q_ARG(int, y)); | ||
732 | } | 738 | } | ||
733 | 739 | | |||
734 | void FolderModel::dragSelectedInternal(int x, int y) | 740 | void FolderModel::dragSelectedInternal(int x, int y) | ||
735 | { | 741 | { | ||
736 | if (!m_viewAdapter || !m_selectionModel->hasSelection()) { | 742 | if (!m_viewAdapter || !m_selectionModel->hasSelection()) { | ||
743 | m_dragInProgress = false; | ||||
737 | return; | 744 | return; | ||
738 | } | 745 | } | ||
739 | 746 | | |||
740 | ItemViewAdapter *adapter = qobject_cast<ItemViewAdapter *>(m_viewAdapter); | 747 | ItemViewAdapter *adapter = qobject_cast<ItemViewAdapter *>(m_viewAdapter); | ||
741 | QQuickItem *item = qobject_cast<QQuickItem *>(adapter->adapterView()); | 748 | QQuickItem *item = qobject_cast<QQuickItem *>(adapter->adapterView()); | ||
742 | 749 | | |||
743 | QDrag *drag = new QDrag(item); | 750 | QDrag *drag = new QDrag(item); | ||
744 | 751 | | |||
Show All 10 Lines | |||||
755 | 762 | | |||
756 | foreach (const QModelIndex &index, m_dragIndexes) { | 763 | foreach (const QModelIndex &index, m_dragIndexes) { | ||
757 | sourceDragIndexes.append(mapToSource(index)); | 764 | sourceDragIndexes.append(mapToSource(index)); | ||
758 | } | 765 | } | ||
759 | 766 | | |||
760 | drag->setMimeData(m_dirModel->mimeData(sourceDragIndexes)); | 767 | drag->setMimeData(m_dirModel->mimeData(sourceDragIndexes)); | ||
761 | 768 | | |||
762 | item->grabMouse(); | 769 | item->grabMouse(); | ||
763 | m_dragInProgress = true; | | |||
764 | drag->exec(supportedDragActions()); | 770 | drag->exec(supportedDragActions()); | ||
765 | m_dragInProgress = false; | 771 | m_dragInProgress = false; | ||
766 | item->ungrabMouse(); | 772 | item->ungrabMouse(); | ||
767 | 773 | | |||
768 | const QModelIndex first(m_dragIndexes.first()); | 774 | const QModelIndex first(m_dragIndexes.first()); | ||
769 | const QModelIndex last(m_dragIndexes.last()); | 775 | const QModelIndex last(m_dragIndexes.last()); | ||
770 | m_dragIndexes.clear(); | 776 | m_dragIndexes.clear(); | ||
771 | // TODO: Optimize to emit contiguous groups. | 777 | // TODO: Optimize to emit contiguous groups. | ||
▲ Show 20 Lines • Show All 695 Lines • Show Last 20 Lines |