added drag support to classic and grid view. by now grid doesn't support multiple drags and pressents some secondary effects (cells are moved inside the grid, and target is not working properly)

This commit is contained in:
Luis Ángel San Martín
2014-11-02 23:00:11 +01:00
parent ac3b3a8a85
commit 9325eb5a7b
3 changed files with 49 additions and 23 deletions

View File

@ -148,7 +148,7 @@ Qt::ItemFlags ComicModel::flags(const QModelIndex &index) const
return 0;
if(index.column() == ComicModel::Rating)
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
}
//! [4]

View File

@ -28,6 +28,8 @@ Rectangle {
height: grid.cellHeight
color: backgroundColor
MouseArea {
id: mouseArea
drag.target: realCell
anchors.fill: parent
onClicked: {
comicsSelectionHelper.clear();
@ -38,7 +40,14 @@ Rectangle {
Rectangle {
id: realCell
width: 156; height: 287
Drag.active: mouseArea.drag.active
Drag.hotSpot.x: 32
Drag.hotSpot.y: 32
Drag.dragType: Drag.Automatic
Drag.mimeData: { "text/plain": "comic" }
Drag.proposedAction: Qt.CopyAction
width: 156; height: 287
color: ((dummyValue || !dummyValue) && comicsSelectionHelper.isSelectedIndex(index)) || grid.currentIndex === index?selectedColor:cellColor;
anchors.horizontalCenter: parent.horizontalCenter