EventDelegate.qml 2.54 KB
Newer Older
1
/*
2
    SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3

4
    SPDX-License-Identifier: LGPL-2.0-or-later
5
6
7
8
9
*/

import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
10
import org.kde.kirigami 2.17 as Kirigami
11
12
13
14
15
16
import org.kde.itinerary 1.0
import "." as App

App.TimelineDelegate {
    id: root

17
18
19
    headerIconSource: "meeting-attending"
    headerItem: RowLayout {
        QQC2.Label {
20
            text: root.rangeType == TimelineElement.RangeEnd ?
21
                i18n("End: %1", reservationFor.name) : reservationFor.name
22
23
            font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
            color: Kirigami.Theme.textColor
24
            elide: Text.ElideRight
25
26
27
            Layout.fillWidth: true
        }
        QQC2.Label {
28
            text: {
29
                if (root.rangeType == TimelineElement.RangeEnd)
30
31
32
33
34
                    return Localizer.formatTime(reservationFor, "endDate");
                if (reservationFor.doorTime > 0)
                    return Localizer.formatTime(reservationFor, "doorTime");
                return Localizer.formatTime(reservationFor, "startDate");
            }
35
36
            font.pointSize: Kirigami.Theme.defaultFont.pointSize * root.headerFontScale
            color: Kirigami.Theme.textColor
37
38
39
        }
    }

40
    contentItem: Column {
41
        id: topLayout
42
        spacing: Kirigami.Units.smallSpacing
43
44

        QQC2.Label {
45
            text: reservationFor.location != undefined ? reservationFor.location.name : ""
46
            visible: text !== ""
47
48
            wrapMode: Text.WordWrap
            width: topLayout.width
49
50
51
        }
        App.PlaceDelegate {
            place: reservationFor.location
Volker Krause's avatar
Volker Krause committed
52
            controller: root.controller
53
54
            isRangeBegin: root.rangeType == TimelineElement.RangeBegin
            isRangeEnd: root.rangeType == TimelineElement.RangeEnd
55
            width: topLayout.width
56
            visible: reservationFor.location != undefined
57
        }
58
59
        QQC2.Label {
            text: i18n("Start time: %1", Localizer.formatDateTime(reservationFor, "startDate"))
60
            visible: root.rangeType != TimelineElement.RangeEnd && reservationFor.doorTime > 0
61
        }
62
63
        QQC2.Label {
            text: i18n("End time: %1", Localizer.formatDateTime(reservationFor, "endDate"));
64
            visible: root.rangeType != TimelineElement.RangeEnd && reservationFor.endDate > 0
65
66
67
        }
    }

68
69
70
    Component {
        id: detailsComponent
        App.EventPage {
71
            batchId: root.batchId
72
73
74
        }
    }

75
    onClicked: showDetails(detailsComponent)
76
}