delegate: Item{ id: treeDelegate implicitWidth: padding + text.x + text.implicitWidth + padding implicitHeight: text.height property var delegateIndex : treeDelegate.treeView.index(row, column) readonly property real indent: 20 readonly property real padding: 5 required property TreeView treeView required property bool isTreeNode required property bool expanded required property bool selected required property int hasChildren required property int depth Item { id: rectIndicator height: parent.height width: height anchors.verticalCenter: parent.verticalCenter x: padding + (treeDelegate.depth * treeDelegate.indent) visible: treeViewBookmark.model.isHasChild(treeDelegate.delegateIndex) Image { id: indicator anchors.fill: parent height: 5 verticalAlignment: Image.AlignVCenter horizontalAlignment: Image.AlignHCenter source: model.eIndicator rotation: treeDelegate.expanded ? 90 : 0 } } Rectangle { id: labelRect color: treeViewBookmark.idx === treeDelegate.delegateIndex ? model.eColorBackgroundWithoutChild : style.hovered ? model.eColorBackgroundWithChild : "transparent" border.width: 1 border.color: model.eBorderColor // вот эта ролько обработка которой и нужна width: text.width height: text.height x: padding + (treeDelegate.isTreeNode ? (treeDelegate.depth + 1) * treeDelegate.indent : 0) HoverHandler { id: style } Text { id: text clip: true text: model.display color: model.eValueTextColor font.pixelSize: 10 // constant from XD antialiasing: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } TapHandler { acceptedButtons: Qt.LeftButton onTapped: { treeViewBookmark.toggleExpanded(row) var numberPage = treeViewBookmark.model.page(delegateIndex) root.pelData.signalUpdateCurrentPage(numberPage) } } }
void CC2gdocv_CustomPdfBookmarkModel::setCurrentPage(int currentPage){ m_SelectedCurrentPage.setValue(currentPage);}QBindable<int> CC2gdocv_CustomPdfBookmarkModel::getCurrentPage(){ return &m_SelectedCurrentPage;}QVariant CC2gdocv_CustomPdfBookmarkModel::data(const QModelIndex &index, int role) const{ if (!index.isValid()) { return QVariant{}; } if (role == Qt::DisplayRole) { role = Qt::UserRole + index.column(); } switch (role) { case static_cast<int>(RoleAttributes::eNameRole): { return QPdfBookmarkModel::data(index, role).toString(); } case static_cast<int>(RoleAttributes::ePageRole): { auto localRole = static_cast<int>(QPdfBookmarkModel::Role::Page); auto localRoleTitle = static_cast<int>(QPdfBookmarkModel::Role::Title);// auto localIndex = QPdfBookmarkModel::index(index.row(), 0, index); qDebug() << "DATA role page: " << QPdfBookmarkModel::data( index, localRole).toInt() + 1 << QPdfBookmarkModel::data( index, localRoleTitle).toString(); return QPdfBookmarkModel::data( index, role).toInt() + 1; } case static_cast<int>(RoleAttributes::eBorderColor): { auto localRole = static_cast<int>(QPdfBookmarkModel::Role::Page); const int intNumberPage = QPdfBookmarkModel::data( index, localRole).toInt(); qDebug() << intNumberPage << ": " << m_SelectedCurrentPage.value(); if(intNumberPage == m_SelectedCurrentPage.value()) { return QVariant::fromValue(getColorBorder() ); } else { return QVariant::fromValue(QColor(Qt::transparent )); }// qDebug() << "DATA role page: " << QPdfBookmarkModel::data( index, localRole).toInt() + 1; } default: break; } return QVariant{};}
C++ (Qt)QList{{static_cast<int>(RoleAttributes::eBorderColor)}}// orQList<int>{} << static_cast<int>(RoleAttributes::eBorderColor)