Libkleo

treewidget.h
1/*
2 ui/treewidget.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 <QTreeWidget>
16
17namespace Kleo
18{
19
20/**
21 * A tree widget that allows accessible column by column keyboard navigation
22 * and that has customizable columns through a context menu in the header.
23 *
24 * This is the QTreeWidget-derived variant of TreeView.
25 *
26 * \sa TreeView
27 */
28class KLEO_EXPORT TreeWidget : public QTreeWidget
29{
31public:
32 TreeWidget(QWidget *parent = nullptr);
33 ~TreeWidget() override;
34
35 /**
36 * Hides the column with logical index @p column and doesn't allow the user
37 * to show it.
38 */
39 void forceColumnHidden(int column);
40
41 /**
42 * Restores the layout state under key @p stateGroupName and enables state
43 * saving when the object is destroyed. Make sure that @p stateGroupName is
44 * unique for each place the widget occurs. Returns true if some state was
45 * restored. If false is returned, no state was restored and the caller should
46 * apply the default configuration.
47 */
48 bool restoreColumnLayout(const QString &stateGroupName);
49 void resizeToContentsLimited();
51 void columnEnabled(int column);
52 void columnDisabled(int column);
53
54protected:
55 bool eventFilter(QObject *watched, QEvent *event) override;
56
57 void focusInEvent(QFocusEvent *event) override;
58 void keyPressEvent(QKeyEvent *event) override;
59
60 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
61
62private:
63 class Private;
64 const std::unique_ptr<Private> d;
65};
66
67}
bool restoreColumnLayout(const QString &stateGroupName)
Restores the layout state under key stateGroupName and enables state saving when the object is destro...
void forceColumnHidden(int column)
Hides the column with logical index column and doesn't allow the user to show it.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
typedef KeyboardModifiers
QTreeWidget(QWidget *parent)
virtual bool event(QEvent *e) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:50:12 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.