LogsView.qml 3.29 KB
Newer Older
Camilo higuita's avatar
Camilo higuita committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
import QtQuick 2.9
import QtQuick.Controls 2.3
import org.kde.mauikit 1.0 as Maui
import UnionModels 1.0

import "../contacts"

Maui.Page
{
    id: control
    headBarExit: false
    headBar.visible: false

    colorScheme.accentColor: "#615f7d"
    colorScheme.backgroundColor: backgroundColor
    colorScheme.textColor: textColor

    BaseModel
    {
        id: _contactsModel
        list: _callLogsModel
    }

    CallLogs
    {
        id: _callLogsModel
    }

Camilo higuita's avatar
Camilo higuita committed
29
    Maui.Menu
Camilo higuita's avatar
Camilo higuita committed
30
    {
Camilo higuita's avatar
Camilo higuita committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
        id: _menu
        Maui.MenuItem
        {
            text: qsTr("Call")
            icon.name: "dialer-call"
            onTriggered:
            {
                if(isAndroid)
                    Maui.Android.call(_callLogsModel.get(_listView.currentIndex).tel)
            }
        }

        Maui.MenuItem
        {
            text: qsTr("Save as..")
            icon.name: "list-add-user"
            onTriggered:
            {
                _newContactDialog.contact = _callLogsModel.get(_listView.currentIndex)
                _newContactDialog.open()
            }
        }
    }

    ListView
    {

        id: _listView
Camilo higuita's avatar
Camilo higuita committed
59 60 61 62
        anchors.fill: parent
        spacing: space.big
        clip: true

Camilo higuita's avatar
Camilo higuita committed
63
        section.property: "modified"
Camilo higuita's avatar
Camilo higuita committed
64 65 66 67
        section.criteria: ViewSection.FullString
        section.labelPositioning: ViewSection.InlineLabels
        section.delegate: Maui.LabelDelegate
        {
Camilo higuita's avatar
Camilo higuita committed
68
            label: section
Camilo higuita's avatar
Camilo higuita committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
            isSection: true
            boldLabel: true
            //            colorScheme.backgroundColor: "#333"
            //            colorScheme.textColor: "#fafafa"
            //            width: iconSize

            //            background: Rectangle
            //            {
            //                color:  colorScheme.backgroundColor
            //                radius: radiusV

            //            }


        }

        model: _contactsModel
        delegate: ContactDelegate
        {
            id: _delegate

Camilo higuita's avatar
Camilo higuita committed
90 91
            label1.text: model.n
            label2.text: Maui.FM.formatDate(model.date, "HH:mm", "dd-MM-yyyy HH:mm") + " / " + new Date(model.duration * 1000).toISOString().substr(11, 8);
Camilo higuita's avatar
Camilo higuita committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
            label3.text: model.type

            height: unit * 60
            width: isWide ? control.width * 0.8 : control.width * 0.95
            anchors.horizontalCenter: parent.horizontalCenter
            showMenuIcon: false

            quickButtons: Maui.ToolButton
            {
                iconName: switch (model.type)
                          {
                          case "INCOMING" : return "go-bottom";
                          case "OUTGOING" : return "go-top";
                          case "MISSED" : return "dialog-close";

                          }
Camilo higuita's avatar
Camilo higuita committed
108 109 110 111 112 113 114 115

                iconColor: switch (model.type)
                           {
                           case "INCOMING" : return suggestedColor;
                           case "OUTGOING" : return warningColor;
                           case "MISSED" : return dangerColor;

                           }
Camilo higuita's avatar
Camilo higuita committed
116 117 118 119 120 121 122
            }

            Connections
            {
                target: _delegate
                onClicked:
                {
Camilo higuita's avatar
Camilo higuita committed
123 124
                    _listView.currentIndex = index
                    _menu.popup()
Camilo higuita's avatar
Camilo higuita committed
125 126 127 128 129 130 131 132 133
                }
            }
        }

        ScrollBar.vertical: ScrollBar {}
    }


}