import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import "../style"

RowLayout {
    id: root

    property var recordsController: null
    property var recordsModel: null

    AppToolButton {
        text: "‹"
        enabled: root.recordsController
                 && root.recordsController.hasRecords
        onClicked: root.recordsController.previous()
    }

    Label {
        renderType: Text.NativeRendering
        Layout.fillWidth: true
        horizontalAlignment: Text.AlignHCenter
        text: {
            if (!root.recordsModel || root.recordsModel.count === 0)
                return "Записей нет"
            var selected = root.recordsController
                    ? root.recordsController.selectedIndex + 1 : 0
            return "Запись " + selected
                    + " из " + root.recordsModel.count
        }
        color: "#405164"
    }

    AppToolButton {
        text: "›"
        enabled: root.recordsController
                 && root.recordsController.hasRecords
        onClicked: root.recordsController.next()
    }
}
