mirror of
https://github.com/YACReader/yacreader
synced 2025-07-27 01:15:07 -04:00
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:
@ -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]
|
||||
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user