File indexing completed on 2025-01-19 03:55:41

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-07-05
0007  * Description : A combobox which also has an intermediate state.
0008  *               This is akin to the intermediate state in a checkbox and
0009  *               needed when a single combobox controls more than one item,
0010  *               which are manually set to different states.
0011  *               The intermediate state is indicated by appending an extra item
0012  *               with a user specified text (default is "Various"). Whenever an
0013  *               other item is set, this special state is removed from the list
0014  *               so it can never be selected explicitly.
0015  *
0016  * SPDX-FileCopyrightText: 2009      by Pieter Edelman <pieter dot edelman at gmx dot net>
0017  * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0018  *
0019  * SPDX-License-Identifier: GPL-2.0-or-later
0020  *
0021  * ============================================================ */
0022 
0023 #ifndef DIGIKAM_WS_COMBO_BOX_INTERMEDIATE_H
0024 #define DIGIKAM_WS_COMBO_BOX_INTERMEDIATE_H
0025 
0026 // Qt includes
0027 
0028 #include <QComboBox>
0029 #include <QString>
0030 
0031 // Local includes
0032 
0033 #include "digikam_export.h"
0034 
0035 namespace Digikam
0036 {
0037 
0038 class DIGIKAM_EXPORT WSComboBoxIntermediate : public QComboBox
0039 {
0040     Q_OBJECT
0041 
0042 public:
0043 
0044     /**
0045      * Initialize the combobox with a parent and a string to indicate the
0046      * intermediate state.
0047      */
0048     explicit WSComboBoxIntermediate(QWidget* const = nullptr, const QString& = QString());
0049     ~WSComboBoxIntermediate() override;
0050 
0051     /**
0052      * Set the state of the combobox to intermediate. The intermediate state is
0053      * 'unset' when another index is selected.
0054      */
0055     void setIntermediate(bool);
0056 
0057 private Q_SLOTS:
0058 
0059     void slotIndexChanged(int);
0060 
0061 private:
0062 
0063     class Private;
0064     Private* const d;
0065 };
0066 
0067 } // namespace Digikam
0068 
0069 #endif // DIGIKAM_WS_COMBO_BOX_INTERMEDIATE_H