~nskaggs/ubuntu-filemanager-app/revert-rev132

142 by nskaggs
Rollback to last working version, with working cmake
1
/*
2
 * Copyright (C) 2013 Canonical Ltd
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License version 3 as
6
 * published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 *
16
 * Authored by: Arto Jalkanen <ajalkane@gmail.com>
17
 */
18
import QtQuick 2.0
19
import Ubuntu.Components 0.1
20
import Ubuntu.Components.Popups 0.1
21
22
Popover {
23
    id: root
24
    property var model
25
26
    property string path: model.path || (fileView.path + '/' + model.fileName)
27
28
    contentHeight: contents.height + 2 * contents.anchors.margins
29
30
    function dateTimeFormat(dateTime) {
31
        return Qt.formatDateTime(dateTime, Qt.DefaultLocaleShortDate) || "Unknown"
32
    }
33
34
    function permissionsToString(model) {
35
        var permissions = []
36
        if (model.isReadable) {
37
            permissions.push(i18n.tr("Readable"))
38
        }
39
        if (pathIsWritable()) {
40
            permissions.push(i18n.tr("Writable"))
41
        }
42
        if (model.isExecutable) {
43
            permissions.push(i18n.tr("Executable"))
44
        }
45
46
        // Now why does this not work?
47
        // return permissions.join(", ")
48
        var permStr = ""
49
        for (var i = 0; i < permissions.length; ++i) {
50
            if (permStr.length > 0) {
51
                permStr += ", "
52
            }
53
            permStr += permissions[i]
54
        }
55
        return permStr
56
    }
57
58
    Column {
59
        id: contents
60
        spacing: units.gu(1)
61
        anchors {
62
            margins: units.gu(2)
63
            left: parent.left
64
            right: parent.right
65
            top: parent.top
66
        }
67
68
        Row {
69
            spacing: units.gu(1)
70
            Image {
71
                anchors.verticalCenter: parent.verticalCenter
72
73
                // TODO: how to get proper icon?
74
                source: fileIcon(root.path, model.isDir)
75
            }
76
77
            Label {
78
                anchors.verticalCenter: parent.verticalCenter
79
80
                text: folderName(root.path)
81
                color: Theme.palette.normal.overlayText
82
                font.bold: true
83
            }
84
        }
85
86
        Grid {
87
            columns: 2
88
            spacing: units.gu(1)
89
90
            Label {
91
                text: i18n.tr("Path:")
92
                color: Theme.palette.normal.overlayText
93
            }
94
95
            Label {
96
                objectName: "pathLabel"
97
                text: root.path
98
                color: Theme.palette.normal.overlayText
99
            }
100
101
            Label {
102
                text: model.isDir ? i18n.tr("Contents:")
103
                                  : i18n.tr("Size:")
104
                color: Theme.palette.normal.overlayText
105
            }
106
            Label {
107
                text: model.fileSize
108
                color: Theme.palette.normal.overlayText
109
            }
110
111
            Label {
112
                text: i18n.tr("Accessed:")
113
                color: Theme.palette.normal.overlayText
114
            }
115
            Label {
116
                text: dateTimeFormat(pathAccessedDate())
117
                color: Theme.palette.normal.overlayText
118
            }
119
120
            Label {
121
                text: i18n.tr("Modified:")
122
                color: Theme.palette.normal.overlayText
123
            }
124
            Label {
125
                text: dateTimeFormat(pathModifiedDate())
126
                color: Theme.palette.normal.overlayText
127
            }
128
129
            Label {
130
                text: i18n.tr("Permissions:")
131
                color: Theme.palette.normal.overlayText
132
            }
133
            Label {
134
                text: permissionsToString(model)
135
                color: Theme.palette.normal.overlayText
136
            }
137
138
        }
139
    }
140
}