File indexing completed on 2024-05-12 04:52:54
0001 /* 0002 SPDX-FileCopyrightText: 2016 Nicolas Carion 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 0008 #include "assets/view/widgets/abstractparamwidget.hpp" 0009 #include "ui_listparamwidget_ui.h" 0010 #include <QVariant> 0011 #include <QWidget> 0012 0013 class AssetParameterModel; 0014 0015 /** @brief This class represents a parameter that requires 0016 the user to choose a value from a list 0017 */ 0018 class ListParamWidget : public AbstractParamWidget, public Ui::ListParamWidget_UI 0019 { 0020 Q_OBJECT 0021 public: 0022 /** @brief Constructor for the widgetComment 0023 @param name String containing the name of the parameter 0024 @param comment Optional string containing the comment associated to the parameter 0025 @param parent Parent widget 0026 */ 0027 ListParamWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent); 0028 0029 /** @brief Set the index of the current displayed element 0030 @param index Integer holding the index of the target element (0-indexed) 0031 */ 0032 void setCurrentIndex(int index); 0033 0034 /** @brief Set the text currently displayed on the list 0035 @param text String containing the text of the element to show 0036 */ 0037 void setCurrentText(const QString &text); 0038 0039 /** @brief Add an item to the list. 0040 @param text String to be displayed in the list 0041 @param value Underlying value corresponding to the text 0042 */ 0043 void addItem(const QString &text, const QVariant &value = QVariant()); 0044 0045 /** @brief Set the icon of a given element 0046 @param index Integer holding the index of the target element (0-indexed) 0047 @param icon The corresponding icon 0048 */ 0049 void setItemIcon(int index, const QIcon &icon); 0050 0051 /** @brief Set the size of the icons shown in the list 0052 @param size Target size of the icon 0053 */ 0054 void setIconSize(const QSize &size); 0055 0056 /** @brief Returns the current value of the parameter 0057 */ 0058 QString getValue(); 0059 0060 public Q_SLOTS: 0061 /** @brief Toggle the comments on or off 0062 */ 0063 void slotShowComment(bool show) override; 0064 0065 /** @brief refresh the properties to reflect changes in the model 0066 */ 0067 void slotRefresh() override; 0068 0069 };