3
* Group box containing format options.
9
* Copyright (C) 2003-2009 Urs Fleisch
11
* This file is part of Kid3.
13
* Kid3 is free software; you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation; either version 2 of the License, or
16
* (at your option) any later version.
18
* Kid3 is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
23
* You should have received a copy of the GNU General Public License
24
* along with this program. If not, see <http://www.gnu.org/licenses/>.
28
#include <qcombobox.h>
29
#include <qcheckbox.h>
31
#include "formatconfig.h"
32
#include "formatbox.h"
33
#include "configtable.h"
34
#if QT_VERSION >= 0x040000
35
#include <QVBoxLayout>
42
* @param parent parent widget
44
FormatBox::FormatBox(const QString& title, QWidget* parent) :
45
#if QT_VERSION >= 0x040000
46
QGroupBox(title, parent)
48
QGroupBox(5, Qt::Vertical, title, parent)
51
m_formatEditingCheckBox = new QCheckBox(i18n("Format while editing"),
54
QLabel* caseConvLabel = new QLabel(this);
55
caseConvLabel->setText(i18n("Case conversion:"));
57
m_caseConvComboBox = new QComboBox(this);
58
m_caseConvComboBox->setEditable(false);
59
m_caseConvComboBox->clear();
60
m_caseConvComboBox->QCM_insertItem(FormatConfig::NoChanges,
62
m_caseConvComboBox->QCM_insertItem(FormatConfig::AllLowercase,
63
i18n("All lowercase"));
64
m_caseConvComboBox->QCM_insertItem(FormatConfig::AllUppercase,
65
i18n("All uppercase"));
66
m_caseConvComboBox->QCM_insertItem(FormatConfig::FirstLetterUppercase,
67
i18n("First letter uppercase"));
68
m_caseConvComboBox->QCM_insertItem(FormatConfig::AllFirstLettersUppercase,
69
i18n("All first letters uppercase"));
71
m_strRepCheckBox = new QCheckBox(this);
72
m_strRepCheckBox->setText(i18n("String replacement:"));
73
m_strReplTable = new ConfigTable(
74
QStringList() << i18n("From") << i18n("To"),
76
#if QT_VERSION >= 0x040000
77
QVBoxLayout* vbox = new QVBoxLayout;
79
vbox->addWidget(m_formatEditingCheckBox);
80
vbox->addWidget(caseConvLabel);
81
vbox->addWidget(m_caseConvComboBox);
82
vbox->addWidget(m_strRepCheckBox);
83
vbox->addWidget(m_strReplTable);
91
FormatBox::~FormatBox() {}
94
* Set the values from a format configuration.
96
* @param cfg format configuration
98
void FormatBox::fromFormatConfig(const FormatConfig* cfg)
100
m_formatEditingCheckBox->setChecked(cfg->m_formatWhileEditing);
101
m_caseConvComboBox->QCM_setCurrentIndex(cfg->m_caseConversion);
102
m_strRepCheckBox->setChecked(cfg->m_strRepEnabled);
103
m_strReplTable->fromMap(cfg->m_strRepMap);
107
* Store the values in a format configuration.
109
* @param cfg format configuration
111
void FormatBox::toFormatConfig(FormatConfig* cfg) const
113
cfg->m_formatWhileEditing = m_formatEditingCheckBox->isChecked();
114
cfg->m_caseConversion =
115
(FormatConfig::CaseConversion)m_caseConvComboBox->QCM_currentIndex();
116
if (cfg->m_caseConversion >= FormatConfig::NumCaseConversions) {
117
cfg->m_caseConversion = FormatConfig::NoChanges;
119
cfg->m_strRepEnabled = m_strRepCheckBox->isChecked();
120
m_strReplTable->toMap(cfg->m_strRepMap);