File: TableCell.qml

package info (click to toggle)
qt6-declarative 6.8.2%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 305,852 kB
  • sloc: cpp: 760,684; javascript: 514,174; xml: 10,618; python: 2,806; ansic: 2,253; java: 815; sh: 213; makefile: 41; php: 27
file content (41 lines) | stat: -rw-r--r-- 1,237 bytes parent folder | download
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
35
36
37
38
39
40
41
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls

Rectangle {
    id: root
    clip: true

    property alias text: textItem.text
    property bool highlight: false
    required property bool current
    required property bool selected
    required property bool editing
    required property string edit

    signal commit(text: string)

    readonly property bool __darkMode: Qt.styleHints.colorScheme === Qt.Dark
    border {
        width: (!editing && current) ? 1 : 0
        color: current ? palette.highlight.darker(__darkMode ? 0.7 : 1.9) : palette.base
    }
    readonly property color __highlight_color: __darkMode
                                               ? palette.highlight.darker(1.9)
                                               : palette.highlight.lighter(1.9)
    color: highlight ? __highlight_color : selected ? palette.highlight : palette.base

    Label {
        id: textItem
        anchors { fill: parent; margins: 5 }
        visible: !root.editing
    }

    TableView.editDelegate: TextField {
        anchors.fill: root
        text: root.edit
        TableView.onCommit: root.commit(text)
    }
}