~ubuntu-branches/ubuntu/wily/kid3/wily

« back to all changes in this revision

Viewing changes to src/qml/app/FileList.qml

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2015-05-12 18:56:41 UTC
  • mfrom: (1.1.19) (2.3.3 sid)
  • Revision ID: package-import@ubuntu.com-20150512185641-hgeys2pingwq9mwn
Tags: 3.2.1-1
* New upstream release.
  - Add new build dependency qt4-dev-tools.
* Uploading to unstable.
* Switch to DEP5 debian/copyright format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \file FileList.qml
 
3
 * List of files in current directory.
 
4
 *
 
5
 * \b Project: Kid3
 
6
 * \author Urs Fleisch
 
7
 * \date 16 Feb 2015
 
8
 *
 
9
 * Copyright (C) 2015  Urs Fleisch
 
10
 *
 
11
 * This program is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU Lesser General Public License as published by
 
13
 * the Free Software Foundation; version 3.
 
14
 *
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU Lesser General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU Lesser General Public License
 
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
22
 */
 
23
 
 
24
import QtQuick 2.2
 
25
import "../componentsqtquick" //@!Ubuntu
 
26
//import Ubuntu.Components 1.1 //@Ubuntu
 
27
//import Ubuntu.Components.Popups 1.0 //@Ubuntu
 
28
//import Ubuntu.Components.ListItems 1.0 //@Ubuntu
 
29
import Kid3 1.0
 
30
 
 
31
RaisableRectangle {
 
32
  function currentFilePath() {
 
33
    return fileModel.getDataValue(fileModel.currentRow,
 
34
                                  "filePath")
 
35
  }
 
36
 
 
37
  Row {
 
38
    id: fileButtonRow
 
39
    anchors.left: parent.left
 
40
    anchors.top: parent.top
 
41
    spacing: constants.spacing
 
42
    Button {
 
43
      id: parentDirButton
 
44
      iconName: "go-up"
 
45
      width: height
 
46
      onClicked: confirmedOpenDirectory(
 
47
                   script.getIndexRoleData(fileModel.parentModelIndex(),
 
48
                                           "filePath"))
 
49
    }
 
50
    Button {
 
51
      property bool selectAll: true
 
52
      iconName: "select"
 
53
      width: height
 
54
      onClicked: {
 
55
        if (selectAll) {
 
56
          app.selectAllFiles()
 
57
        } else {
 
58
          app.deselectAllFiles()
 
59
        }
 
60
        selectAll = !selectAll
 
61
      }
 
62
    }
 
63
    Button {
 
64
      iconName: "go-previous"
 
65
      width: height
 
66
      onClicked: app.previousFile()
 
67
    }
 
68
    Button {
 
69
      iconName: "go-next"
 
70
      width: height
 
71
      onClicked: app.nextFile()
 
72
    }
 
73
  }
 
74
 
 
75
  ListView {
 
76
    id: fileList
 
77
 
 
78
    anchors.left: parent.left
 
79
    anchors.top: fileButtonRow.bottom
 
80
    anchors.bottom: parent.bottom
 
81
    anchors.right: parent.right
 
82
    anchors.margins: constants.margins
 
83
    clip: true
 
84
 
 
85
    model: CheckableListModel {
 
86
      id: fileModel
 
87
      sourceModel: app.fileProxyModel
 
88
      selectionModel: app.fileSelectionModel
 
89
      rootIndex: app.fileRootIndex
 
90
      onCurrentRowChanged: {
 
91
        fileList.currentIndex = row
 
92
      }
 
93
    }
 
94
 
 
95
    delegate: Standard {
 
96
      id: fileDelegate
 
97
      progression: isDir
 
98
      onClicked: {
 
99
        if (!isDir) {
 
100
          ListView.view.currentIndex = index
 
101
          fileModel.currentRow = index
 
102
        } else {
 
103
          confirmedOpenDirectory(filePath)
 
104
        }
 
105
      }
 
106
      selected: ListView.isCurrentItem
 
107
      Row {
 
108
        anchors.fill: parent
 
109
 
 
110
        CheckBox {
 
111
          id: checkField
 
112
          anchors.verticalCenter: parent.verticalCenter
 
113
          onClicked: {
 
114
            // QTBUG-7932, assigning is not possible
 
115
            fileModel.setDataValue(index, "checkState",
 
116
                                   checked ? Qt.Checked : Qt.Unchecked)
 
117
          }
 
118
        }
 
119
        Binding {
 
120
          // workaround for QTBUG-31627
 
121
          // should work with "checked: checkState === Qt.Checked"
 
122
          target: checkField
 
123
          property: "checked"
 
124
          value: checkState === Qt.Checked
 
125
        }
 
126
        Rectangle {
 
127
          id: fileImage
 
128
          anchors.verticalCenter: parent.verticalCenter
 
129
          color: truncated ? constants.errorColor : "transparent"
 
130
          width: 16
 
131
          height: 16
 
132
          Image {
 
133
            anchors.fill: parent
 
134
            source: "image://kid3/fileicon/" + iconId
 
135
          }
 
136
        }
 
137
        Label {
 
138
          id: fileText
 
139
          anchors.verticalCenter: parent.verticalCenter
 
140
          text: fileName
 
141
          color: selected
 
142
            ? constants.selectedTextColor : constants.backgroundTextColor
 
143
        }
 
144
      }
 
145
    }
 
146
  }
 
147
}