Warning, /multimedia/amarok/src/context/applets/albums/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /****************************************************************************************
0002  * Copyright (c) 2017 Malte Veerman <malte.veerman@gmail.com>                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 import QtQuick 2.4
0018 import QtQuick.Controls 1.4
0019 import QtQml.Models 2.2
0020 import org.kde.amarok.qml 1.0 as AmarokQml
0021 import org.kde.amarok.albums 1.0
0022 
0023 AmarokQml.Applet {
0024     id: applet
0025 
0026     TreeView {
0027         id: treeView
0028 
0029         anchors.fill: parent
0030         sortIndicatorVisible: false
0031         headerVisible: false
0032         model: AlbumsEngine.model
0033         selectionMode: SelectionMode.ExtendedSelection
0034         selection: ItemSelectionModel {
0035             id: selectionModel
0036 
0037             model: AlbumsEngine.model
0038         }
0039 
0040         itemDelegate: Row {
0041             Loader {
0042                 active: !!model && !!model["albumCover"]
0043                 height: parent.height
0044                 width: height
0045                 visible: active
0046 
0047                 AmarokQml.PixmapItem {
0048                     source: !!model ? model["albumCover"] : undefined
0049                 }
0050             }
0051             Text {
0052                 anchors.verticalCenter: parent.verticalCenter
0053                 color: styleData.selected ? applet.palette.highlightedText : applet.palette.text
0054                 elide: styleData.elideMode
0055                 text: styleData.value
0056             }
0057         }
0058 
0059         rowDelegate: Rectangle {
0060             property color backgroundColor: styleData.alternate ? applet.palette.alternateBase : applet.palette.base
0061 
0062             height: !!model && !!model["size"] ? model["size"].height : 0
0063             width: parent.width
0064             color: styleData.selected ? applet.palette.highlight : backgroundColor
0065 
0066             MouseArea {
0067                 id: rowMouseArea
0068 
0069                 anchors.fill: parent
0070                 hoverEnabled: true
0071                 acceptedButtons: Qt.NoButton
0072             }
0073         }
0074 
0075         TableViewColumn {
0076             title: i18n("Display")
0077             role: "display"
0078         }
0079 
0080         MouseArea {
0081             anchors.fill: parent
0082             acceptedButtons: Qt.RightButton
0083             onClicked: {
0084                 var index = treeView.indexAt(mouse.x, mouse.y);
0085                 if (!selectionModel.isSelected(index)) {
0086                     selectionModel.select(index, ItemSelectionModel.ClearAndSelect);
0087                 }
0088                 AlbumsEngine.showContextMenu(selectionModel.selectedIndexes, index);
0089             }
0090         }
0091 
0092         Component.onCompleted: {
0093             __mouseArea.pressAndHoldInterval=200;
0094         }
0095 
0096         Item {
0097             id: dragItem
0098             width: 1; height: 1
0099             Drag.hotSpot.x: 1
0100             Drag.hotSpot.y: 1
0101             Drag.supportedActions: Qt.CopyAction
0102             function updateMimedata() {
0103                 Drag.mimeData={"text/plain": AlbumsEngine.getSelectedUrlList(selectionModel.selectedIndexes),
0104                                "text/uri-list": AlbumsEngine.getSelectedUrlList(selectionModel.selectedIndexes)}
0105             }
0106 
0107             Drag.dragType: Drag.Automatic
0108         }
0109 
0110         onPressAndHold: function() {
0111             dragItem.updateMimedata();
0112             dragItem.Drag.active=true;
0113         }
0114     }
0115 }