LogsView.qml 2.92 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 29 30 31 32 33 34
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
    }

      ListView
    {
        anchors.fill: parent
        spacing: space.big
        clip: true

Camilo higuita's avatar
Camilo higuita committed
35
        section.property: "modified"
Camilo higuita's avatar
Camilo higuita committed
36 37 38 39
        section.criteria: ViewSection.FullString
        section.labelPositioning: ViewSection.InlineLabels
        section.delegate: Maui.LabelDelegate
        {
Camilo higuita's avatar
Camilo higuita committed
40
            label: section
Camilo higuita's avatar
Camilo higuita committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
            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
62 63
            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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
            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
80 81 82 83 84 85 86 87

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

                           }
Camilo higuita's avatar
Camilo higuita committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
            }

            Connections
            {
                target: _delegate
                onClicked:
                {
                    view.currentIndex = index
                    _contactDialog.show(list.get(index))
                }
                onFavClicked:
                {
                    var item = _contactsList.get(index)
                    item["fav"] = item.fav == "1" ? "0" : "1"
                    _contactsList.update(item, index)
                }
            }
        }

        ScrollBar.vertical: ScrollBar {}
    }


}