File indexing completed on 2024-04-14 14:20:16

0001 /*
0002     This file is part of the KDE Libraries
0003 
0004     Copyright (C) 2006 Pino Toscano <toscano.pino@tiscali.it>
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Library General Public
0008     License as published by the Free Software Foundation; either
0009     version 2 of the License, or (at your option) any later version.
0010 
0011     This library is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014     Library General Public License for more details.
0015 
0016     You should have received a copy of the GNU Library General Public License
0017     along with this library; see the file COPYING.LIB. If not, write to
0018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019     Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef KBUTTONGROUP_H
0023 #define KBUTTONGROUP_H
0024 
0025 #include <kdelibs4support_export.h>
0026 #include <QGroupBox>
0027 
0028 class QAbstractButton;
0029 
0030 /**
0031  * @deprecated since 5.0, use QGroupBox and QButtonGroup instead
0032  *
0033  * @brief Group box with index of the selected button.
0034  *
0035  * KButtonGroup is a simple group box that can keep track of the current selected
0036  * button of the ones added to it.
0037  *
0038  * Use normally as you would with a QGroupBox.
0039  *
0040  * \image html kbuttongroup.png "KDE Button Group containing 3 KPushButtons"
0041  *
0042  * @author Pino Toscano <toscano.pino@tiscali.it>
0043  */
0044 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KButtonGroup : public QGroupBox
0045 {
0046     Q_OBJECT
0047 
0048     Q_PROPERTY(int current READ selected WRITE setSelected NOTIFY changed USER true)
0049 
0050 public:
0051     /**
0052      * Construct a new empty KGroupBox.
0053      */
0054     KDELIBS4SUPPORT_DEPRECATED explicit KButtonGroup(QWidget *parent = nullptr);
0055 
0056     /**
0057      * Destroys the widget.
0058      */
0059     ~KButtonGroup() override;
0060 
0061     /**
0062      * Return the index of the selected QAbstractButton, among the QAbstractButton's
0063      * added to the widget.
0064      * @return the index of the selected button
0065      */
0066     int selected() const;
0067 
0068     /**
0069      * @return the index of @p button.
0070      * @since 4.3
0071      */
0072     int id(QAbstractButton *button) const;
0073 
0074 public Q_SLOTS:
0075     /**
0076      * Select the \p id -th button
0077      */
0078     void setSelected(int id);
0079 
0080 Q_SIGNALS:
0081     /**
0082      * The button with index \p id was clicked
0083      */
0084     void clicked(int id);
0085     /**
0086      * The button with index \p id was pressed
0087      */
0088     void pressed(int id);
0089     /**
0090      * The button with index \p id was released
0091      */
0092     void released(int id);
0093     /**
0094      * Emitted when anything (a click on a button, or calling setSelected())
0095      * change the id of the current selected. \p id is the index of the new
0096      * selected button.
0097      */
0098     void changed(int id);
0099 
0100 protected:
0101     /**
0102      * Reimplemented from QGroupBox.
0103      */
0104     void childEvent(QChildEvent *event) override;
0105 
0106 private:
0107     Q_PRIVATE_SLOT(d, void slotClicked(int id))
0108 
0109     class Private;
0110     friend class Private;
0111     Private *const d;
0112 };
0113 
0114 #endif
0115