Files
qt5-legatus-legacy/Lts/Plugins/EffectManagement/Gui/SoundArea/efm_switch_item_delegate.cpp
T
2026-08-13 18:33:10 +02:00

38 lines
965 B
C++
Executable File

/**
* @RDE_HEADER@
* Item Delegate class to show On/Off switch buttons.
* $Id$
* $HeadURL$
* $Author$
* Created by Filip Biedziak, NLE, 2020-08-10
*/
#include "efm_switch_item_delegate.h"
#include "../logger.h"
#include <QDebug>
namespace EffectManagement
{
const QIcon SwitchItemDelegate::s_iconOn = QIcon(QStringLiteral("icon:switch_on.svg"));
const QIcon SwitchItemDelegate::s_iconOff = QIcon(QStringLiteral("icon:switch_off.svg"));
SwitchItemDelegate::SwitchItemDelegate(QObject *parent)
: QStyledItemDelegate(parent)
, m_logger(getLogger("Plugins.Gui.SoundArea.SwitchItemDelegate"))
{
}
void SwitchItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (index.data().toInt() == 1)
s_iconOn.paint(painter, option.rect, Qt::AlignCenter);
else if (index.data().toInt() == -1)
s_iconOff.paint(painter, option.rect, Qt::AlignCenter);
}
} // namespace EffectManagement