Warning, file /plasma/plasma-nm/libs/editor/widgets/intdelegate.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2011 Ilia Kats <ilia-kats@gmx.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #include "intdelegate.h"
0008 #include <QIntValidator>
0009 
0010 IntDelegate::IntDelegate(QObject *parent)
0011     : Delegate(parent)
0012     , m_boundary(false)
0013 {
0014 }
0015 IntDelegate::IntDelegate(int min, int max, QObject *parent)
0016     : Delegate(parent)
0017     , m_min(min)
0018     , m_max(max)
0019     , m_boundary(true)
0020 {
0021 }
0022 IntDelegate::~IntDelegate() = default;
0023 
0024 QWidget *IntDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
0025 {
0026     auto editor = new QLineEdit(parent);
0027     if (m_boundary)
0028         editor->setValidator(new QIntValidator(m_min, m_max, editor));
0029     else
0030         editor->setValidator(new QIntValidator(editor));
0031 
0032     return editor;
0033 }