Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdialogbuttonbox_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QDIALOGBUTTONBOX_P_H
6#define QDIALOGBUTTONBOX_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qwidget_p.h>
20#include <private/qflatmap_p.h>
21#include <qdialogbuttonbox.h>
22
23QT_BEGIN_NAMESPACE
24
25class Q_AUTOTEST_EXPORT QDialogButtonBoxPrivate : public QWidgetPrivate
26{
27 Q_DECLARE_PUBLIC(QDialogButtonBox)
28
29public:
30 enum class RemoveReason {
31 HideEvent,
32 ManualRemove,
33 Destroyed,
34 };
35 enum class LayoutRule {
36 DoLayout,
37 SkipLayout,
38 };
39 enum class AddRule {
40 Connect,
41 SkipConnect,
42 };
43
44 QDialogButtonBoxPrivate(Qt::Orientation orient);
45
46 QList<QAbstractButton *> buttonLists[QDialogButtonBox::NRoles];
47 QVarLengthFlatMap<QPushButton *, QDialogButtonBox::StandardButton, 8> standardButtonMap;
48 QVarLengthFlatMap<QAbstractButton *, QDialogButtonBox::ButtonRole, 8> hiddenButtons;
49
50 Qt::Orientation orientation;
51 QDialogButtonBox::ButtonLayout layoutPolicy;
52 QBoxLayout *buttonLayout;
53 std::unique_ptr<QObject> filter;
54 bool center;
55 bool ignoreShowAndHide = false;
56
57 void createStandardButtons(QDialogButtonBox::StandardButtons buttons);
58
59 void removeButton(QAbstractButton *button, RemoveReason reason);
60 void layoutButtons();
61 void initLayout();
62 void resetLayout();
63 QPushButton *createButton(QDialogButtonBox::StandardButton button,
64 LayoutRule layoutRule = LayoutRule::DoLayout);
65 void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role,
66 LayoutRule layoutRule = LayoutRule::DoLayout,
67 AddRule addRule = AddRule::Connect);
68 void handleButtonDestroyed();
69 void handleButtonClicked();
70 bool handleButtonShowAndHide(QAbstractButton *button, QEvent *event);
71 void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse);
72 void ensureFirstAcceptIsDefault();
73 void retranslateStrings();
74 void disconnectAll();
75 QList<QAbstractButton *> allButtons() const;
76 QList<QAbstractButton *> visibleButtons() const;
77 QDialogButtonBox::ButtonRole buttonRole(QAbstractButton *button) const;
78};
79
81
82#endif // QDIALOGBUTTONBOX_P_H