File indexing completed on 2025-01-05 04:55:50
0001 /* 0002 ui/treeview.h 0003 0004 This file is part of libkleopatra 0005 SPDX-FileCopyrightText: 2022 g10 Code GmbH 0006 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 #include "kleo_export.h" 0014 0015 #include <QTreeView> 0016 0017 namespace Kleo 0018 { 0019 0020 /** 0021 * A tree view that allows accessible column by column keyboard navigation 0022 * and that has customizable columns through a context menu in the header. 0023 * 0024 * Column by column navigation is required to make a tree view accessible. 0025 * 0026 * The TreeView allows column by column keyboard navigation even if 0027 * the selection behavior is set to SelectRows and users can expand/collapse 0028 * list items. To achieve this it deactivates the standard behavior of QTreeView 0029 * to expand/collapse items if the left/right arrow keys are used. 0030 * 0031 * Additionally, you may want to disable parent-child navigation in tree views 0032 * with left/right arrow keys because this also interferes with column by column 0033 * navigation. You can do this by setting 0034 * "QTreeView { arrow-keys-navigate-into-children: 0; }" 0035 * as application style sheet. 0036 * 0037 * \sa TreeWidget 0038 */ 0039 class KLEO_EXPORT TreeView : public QTreeView 0040 { 0041 Q_OBJECT 0042 public: 0043 TreeView(QWidget *parent = nullptr); 0044 ~TreeView() override; 0045 0046 /** 0047 * Restores the layout state under key @p stateGroupName and enables state 0048 * saving when the object is destroyed. Make sure that @p stateGroupName is 0049 * unique for each place the widget occurs. Returns true if some state was 0050 * restored. If false is returned, no state was restored and the caller should 0051 * apply the default configuration. 0052 */ 0053 bool restoreColumnLayout(const QString &stateGroupName); 0054 Q_SIGNALS: 0055 void columnEnabled(int column); 0056 void columnDisabled(int column); 0057 0058 protected: 0059 bool eventFilter(QObject *watched, QEvent *event) override; 0060 0061 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; 0062 0063 private: 0064 class Private; 0065 const std::unique_ptr<Private> d; 0066 }; 0067 }