File indexing completed on 2024-04-28 04:52:50

0001 /*
0002  * SPDX-FileCopyrightText: 2022 Julius Künzel <jk.kdedev@smartlab.uber.space>
0003  * SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004  */
0005 
0006 #pragma once
0007 
0008 #include <QComboBox>
0009 #include <QWidget>
0010 
0011 class MarkerListModel;
0012 
0013 class MarkerCategoryChooser : public QComboBox
0014 {
0015     Q_OBJECT
0016     Q_PROPERTY(bool allowAll READ allowAll WRITE setAllowAll NOTIFY changed)
0017     Q_PROPERTY(bool onlyUsed READ onlyUsed WRITE setOnlyUsed NOTIFY changed)
0018 
0019 public:
0020     MarkerCategoryChooser(QWidget *parent = nullptr);
0021     /** @brief Set currently selected category by its number. */
0022     void setCurrentCategory(int category);
0023     /** @brief get the number of the currently selected category. */
0024     int currentCategory();
0025     /** @brief Set the marker model of the chooser. Only needed if @property onlyUsed is true.*/
0026     void setMarkerModel(const MarkerListModel *model);
0027     /** @brief Whether the user should be able to select "All Categories" */
0028     void setAllowAll(bool allowAll);
0029     /** @brief Show only categories that are used by markers in the model.
0030      *  If no model is set, all categories will be show. @see setMarkerModel
0031      */
0032     void setOnlyUsed(bool onlyUsed);
0033 
0034 private:
0035     const MarkerListModel *m_markerListModel;
0036     bool m_allowAll;
0037     bool m_onlyUsed;
0038 
0039     void refresh();
0040     bool allowAll() { return m_allowAll; };
0041     bool onlyUsed() { return m_onlyUsed; };
0042 
0043 Q_SIGNALS:
0044     void changed();
0045 };