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) |
Since: | KDE Frameworks 4.5 |
Inherits: | QItemSelectionModel |
Public Functions
int | breadcrumbLength() const |
bool | isActualSelectionIncluded() const |
void | setActualSelectionIncluded(bool isActualSelectionIncluded) |
void | setBreadcrumbLength(int breadcrumbLength) |
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 Function Documentation
int KBreadcrumbSelectionModel::breadcrumbLength() const
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().