~ubuntu-branches/ubuntu/wily/kid3/wily-proposed

« back to all changes in this revision

Viewing changes to kid3/formatbox.cpp

  • Committer: Package Import Robot
  • Author(s): Ana Beatriz Guerrero Lopez, Patrick Matthäi, Ana Beatriz Guerrero Lopez
  • Date: 2011-11-13 16:34:13 UTC
  • mfrom: (1.1.13) (2.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20111113163413-5y0anlc4dqf511uh
Tags: 2.0.1-1
* New upstream release.

[ Patrick Matthäi ]
* Adjust build system.
* Add build dependency xsltproc.

[ Ana Beatriz Guerrero Lopez ]
* Some more adjustments to the build system taken from upstream's deb/
* directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * \file formatbox.cpp
3
 
 * Group box containing format options.
4
 
 *
5
 
 * \b Project: Kid3
6
 
 * \author Urs Fleisch
7
 
 * \date 17 Sep 2003
8
 
 *
9
 
 * Copyright (C) 2003-2009  Urs Fleisch
10
 
 *
11
 
 * This file is part of Kid3.
12
 
 *
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.
17
 
 *
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.
22
 
 *
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/>.
25
 
 */
26
 
 
27
 
#include <qlabel.h>
28
 
#include <qcombobox.h>
29
 
#include <qcheckbox.h>
30
 
#include <qstring.h>
31
 
#include "formatconfig.h"
32
 
#include "formatbox.h"
33
 
#include "configtable.h"
34
 
#if QT_VERSION >= 0x040000
35
 
#include <QVBoxLayout>
36
 
#endif
37
 
 
38
 
/**
39
 
 * Constructor.
40
 
 *
41
 
 * @param title  title
42
 
 * @param parent parent widget
43
 
 */
44
 
FormatBox::FormatBox(const QString& title, QWidget* parent) :
45
 
#if QT_VERSION >= 0x040000
46
 
        QGroupBox(title, parent)
47
 
#else
48
 
        QGroupBox(5, Qt::Vertical, title, parent)
49
 
#endif
50
 
{
51
 
        m_formatEditingCheckBox = new QCheckBox(i18n("Format while editing"),
52
 
                                                                                                                                                                        this);
53
 
 
54
 
        QLabel* caseConvLabel = new QLabel(this);
55
 
        caseConvLabel->setText(i18n("Case conversion:"));
56
 
 
57
 
        m_caseConvComboBox = new QComboBox(this);
58
 
        m_caseConvComboBox->setEditable(false);
59
 
        m_caseConvComboBox->clear();
60
 
        m_caseConvComboBox->QCM_insertItem(FormatConfig::NoChanges,
61
 
                                                                                                                                                 i18n("No changes"));
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"));
70
 
 
71
 
        m_strRepCheckBox = new QCheckBox(this);
72
 
        m_strRepCheckBox->setText(i18n("String replacement:"));
73
 
        m_strReplTable = new ConfigTable(
74
 
                QStringList() << i18n("From") << i18n("To"),
75
 
                this);
76
 
#if QT_VERSION >= 0x040000
77
 
        QVBoxLayout* vbox = new QVBoxLayout;
78
 
        vbox->setMargin(2);
79
 
        vbox->addWidget(m_formatEditingCheckBox);
80
 
        vbox->addWidget(caseConvLabel);
81
 
        vbox->addWidget(m_caseConvComboBox);
82
 
        vbox->addWidget(m_strRepCheckBox);
83
 
        vbox->addWidget(m_strReplTable);
84
 
        setLayout(vbox);
85
 
#endif
86
 
}
87
 
 
88
 
/**
89
 
 * Destructor.
90
 
 */
91
 
FormatBox::~FormatBox() {}
92
 
 
93
 
/**
94
 
 * Set the values from a format configuration.
95
 
 *
96
 
 * @param cfg format configuration
97
 
 */
98
 
void FormatBox::fromFormatConfig(const FormatConfig* cfg)
99
 
{
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);
104
 
}
105
 
 
106
 
/**
107
 
 * Store the values in a format configuration.
108
 
 *
109
 
 * @param cfg format configuration
110
 
 */
111
 
void FormatBox::toFormatConfig(FormatConfig* cfg) const
112
 
{
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;
118
 
        }
119
 
        cfg->m_strRepEnabled = m_strRepCheckBox->isChecked();
120
 
        m_strReplTable->toMap(cfg->m_strRepMap);
121
 
}