File indexing completed on 2025-12-07 04:08:18

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-08-16
0007  * Description : a combo box widget re-implemented with a
0008  *               reset button to switch to a default item
0009  *
0010  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_DCOMBO_BOX_H
0017 #define DIGIKAM_DCOMBO_BOX_H
0018 
0019 // Qt includes
0020 
0021 #include <QWidget>
0022 #include <QComboBox>
0023 #include <QVariant>
0024 
0025 // Local includes
0026 
0027 #include "digikam_export.h"
0028 
0029 namespace Digikam
0030 {
0031 
0032 class DIGIKAM_EXPORT DComboBox : public QWidget
0033 {
0034 
0035     Q_OBJECT
0036 
0037 public:
0038 
0039     explicit DComboBox(QWidget* const parent = nullptr);
0040     ~DComboBox() override;
0041 
0042     void setCurrentIndex(int d);
0043     int  currentIndex() const;
0044 
0045     void setDefaultIndex(int d);
0046     int  defaultIndex() const;
0047 
0048     QComboBox* combo()  const;
0049 
0050     void addItem(const QString& t,
0051                  const QVariant& data = QVariant());
0052     void insertItem(int index, const QString& t,
0053                     const QVariant& data = QVariant());
0054 
0055 Q_SIGNALS:
0056 
0057     void reset();
0058     void activated(int);
0059     void currentIndexChanged(int);
0060 
0061 public Q_SLOTS:
0062 
0063     void slotReset();
0064 
0065 private Q_SLOTS:
0066 
0067     void slotItemActivated(int);
0068     void slotCurrentIndexChanged(int);
0069 
0070 private:
0071 
0072     class Private;
0073     Private* const d;
0074 };
0075 
0076 } // namespace Digikam
0077 
0078 #endif // DIGIKAM_DCOMBO_BOX_H