File indexing completed on 2025-02-23 04:34:24

0001 /**
0002  * \file tagformatbox.cpp
0003  * Group box containing tag format options.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 12 Nov 2017
0008  *
0009  * Copyright (C) 2017-2018  Urs Fleisch
0010  *
0011  * This file is part of Kid3.
0012  *
0013  * Kid3 is free software; you can redistribute it and/or modify
0014  * it under the terms of the GNU General Public License as published by
0015  * the Free Software Foundation; either version 2 of the License, or
0016  * (at your option) any later version.
0017  *
0018  * Kid3 is distributed in the hope that it will be useful,
0019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021  * GNU General Public License for more details.
0022  *
0023  * You should have received a copy of the GNU General Public License
0024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0025  */
0026 
0027 #include "tagformatbox.h"
0028 #include <QFormLayout>
0029 #include <QCheckBox>
0030 #include "formatconfig.h"
0031 
0032 /**
0033  * Constructor.
0034  *
0035  * @param title  title
0036  * @param parent parent widget
0037  */
0038 TagFormatBox::TagFormatBox(const QString& title, QWidget* parent)
0039   : FormatBox(title, parent),
0040     m_validationCheckBox(nullptr)
0041 {
0042   if (auto formLayout = getFormLayout()) {
0043     m_validationCheckBox = new QCheckBox(tr("Validation"));
0044     formLayout->insertRow(1, m_validationCheckBox);
0045   }
0046 }
0047 
0048 /**
0049  * Set the values from a format configuration.
0050  *
0051  * @param cfg format configuration
0052  */
0053 void TagFormatBox::fromFormatConfig(const FormatConfig& cfg)
0054 {
0055   FormatBox::fromFormatConfig(cfg);
0056   if (m_validationCheckBox) {
0057     m_validationCheckBox->setChecked(cfg.enableValidation());
0058   }
0059 }
0060 
0061 /**
0062  * Store the values in a format configuration.
0063  *
0064  * @param cfg format configuration
0065  */
0066 void TagFormatBox::toFormatConfig(FormatConfig& cfg) const
0067 {
0068   FormatBox::toFormatConfig(cfg);
0069   if (m_validationCheckBox) {
0070     cfg.setEnableValidation(m_validationCheckBox->isChecked());
0071   }
0072 }