Libkleo

treeview.h
1/*
2 ui/treeview.h
3
4 This file is part of libkleopatra
5 SPDX-FileCopyrightText: 2022 g10 Code GmbH
6 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#pragma once
12
13#include "kleo_export.h"
14
15#include <QTreeView>
16
17namespace Kleo
18{
19
20/**
21 * A tree view that allows accessible column by column keyboard navigation
22 * and that has customizable columns through a context menu in the header.
23 *
24 * Column by column navigation is required to make a tree view accessible.
25 *
26 * The TreeView allows column by column keyboard navigation even if
27 * the selection behavior is set to SelectRows and users can expand/collapse
28 * list items. To achieve this it deactivates the standard behavior of QTreeView
29 * to expand/collapse items if the left/right arrow keys are used.
30 *
31 * Additionally, you may want to disable parent-child navigation in tree views
32 * with left/right arrow keys because this also interferes with column by column
33 * navigation. You can do this by setting
34 * "QTreeView { arrow-keys-navigate-into-children: 0; }"
35 * as application style sheet.
36 *
37 * \sa TreeWidget
38 */
39class KLEO_EXPORT TreeView : public QTreeView
40{
41 Q_OBJECT
42public:
43 TreeView(QWidget *parent = nullptr);
44 ~TreeView() override;
45
46 /**
47 * Restores the layout state under key @p stateGroupName and enables state
48 * saving when the object is destroyed. Make sure that @p stateGroupName is
49 * unique for each place the widget occurs. Returns true if some state was
50 * restored. If false is returned, no state was restored and the caller should
51 * apply the default configuration.
52 */
53 bool restoreColumnLayout(const QString &stateGroupName);
54
55 /**
56 * Set the state config group name to use for saving the state. Only needs
57 * to be done if the state should be saged, but was not previously loaded
58 * using TreeView::restoreColumnLayout.
59 */
60 void saveColumnLayout(const QString &stateGroupName);
61 void resizeToContentsLimited();
62Q_SIGNALS:
63 void columnEnabled(int column);
64 void columnDisabled(int column);
65
66protected:
67 bool eventFilter(QObject *watched, QEvent *event) override;
68
69 void focusInEvent(QFocusEvent *event) override;
70 void keyPressEvent(QKeyEvent *event) override;
71
72 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
73
74private:
75 class Private;
76 const std::unique_ptr<Private> d;
77};
78}
A tree view that allows accessible column by column keyboard navigation and that has customizable col...
Definition treeview.h:40
typedef KeyboardModifiers
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.