Pages
API Documentation
On this page

KBreadcrumbSelectionModel Class

Selects the parents of selected items to create breadcrumbs. More...

  • Header: #include <KBreadcrumbSelectionModel>
  • CMake: find_package(KF6 REQUIRED COMPONENTS ItemModels)
    target_link_libraries(mytarget PRIVATE KF6::ItemModels)
  • Inherits: QItemSelectionModel

List of all members, including inherited members

Public Types

Public Functions

Detailed Description

For example, if the tree is

- A
- B
- - C
- - D
- - - E
- - - - F

and E is selected, the selection can contain

- B
- D

or

- B
- D
- E

if isActualSelectionIncluded is true.

The depth of the selection may also be set. For example if the breadcrumbLength is 1:

- D
- E

And if breadcrumbLength is 2:

- B
- D
- E

A KBreadcrumbsSelectionModel with a breadcrumbLength of 0 and including the actual selection is the same as a KSelectionProxyModel in the KSelectionProxyModel::ExactSelection configuration.

view1->setModel(rootModel);

QItemSelectionModel *breadcrumbSelectionModel = new QItemSelectionModel(rootModel, this);

KBreadcrumbSelectionModel *breadcrumbProxySelector = new KBreadcrumbSelectionModel(breadcrumbSelectionModel, rootModel, this);

view1->setSelectionModel(breadcrumbProxySelector);

KSelectionProxyModel *breadcrumbSelectionProxyModel = new KSelectionProxyModel( breadcrumbSelectionModel, this);
breadcrumbSelectionProxyModel->setSourceModel( rootModel );
breadcrumbSelectionProxyModel->setFilterBehavior( KSelectionProxyModel::ExactSelection );

view2->setModel(breadcrumbSelectionProxyModel);

This can work in two directions. One option is for a single selection in the KBreadcrumbSelectionModel to invoke the breadcrumb selection in its constructor argument.

The other is for a selection in the itemselectionmodel in the constructor argument to cause a breadcrumb selection in this.

Member Type Documentation

Constant
KBreadcrumbSelectionModel::MakeBreadcrumbSelectionInOther 0
KBreadcrumbSelectionModel::MakeBreadcrumbSelectionInSelf 1

Member Function Documentation

[explicit] KBreadcrumbSelectionModel::KBreadcrumbSelectionModel(QItemSelectionModel *selectionModel, QObject *parent = nullptr)

KBreadcrumbSelectionModel::KBreadcrumbSelectionModel(QItemSelectionModel *selectionModel, KBreadcrumbSelectionModel::BreadcrumbTarget target, QObject *parent = nullptr)

Returns the depth that the breadcrumb selection should go to.

See also setBreadcrumbLength()

bool KBreadcrumbSelectionModel::isActualSelectionIncluded() const

Returns whether the actual selection in included in the proxy.

The default is true.

void KBreadcrumbSelectionModel::setActualSelectionIncluded(bool isActualSelectionIncluded)

Set whether the actual selection in included in the proxy to isActualSelectionIncluded.

See also isActualSelectionIncluded()

void KBreadcrumbSelectionModel::setBreadcrumbLength(int breadcrumbLength)

Sets the depth that the breadcrumb selection should go to.

If the breadcrumbLength is -1, all breadcrumbs are selected. The default is -1

See also breadcrumbLength()

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.