File indexing completed on 2024-05-19 15:27:51

0001 /* This file is part of KGraphViewer.
0002    Copyright (C) 2005-2007 Gael de Chalendar <kleag@free.fr>
0003 
0004    KGraphViewer is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, version 2.
0007 
0008    This program is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    General Public License for more details.
0012 
0013    You should have received a copy of the GNU General Public License
0014    along with this program; if not, write to the Free Software
0015    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0016    02110-1301, USA
0017 */
0018 
0019 /* This file was part of the KDE project
0020    Copyright (C) 2005 Jarosław Staniek <staniek@kde.org>
0021 
0022    This program is free software; you can redistribute it and/or
0023    modify it under the terms of the GNU Library General Public
0024    License as published by the Free Software Foundation; either
0025    version 2 of the License, or (at your option) any later version.
0026  */
0027 
0028 #include <KgvPageLayoutHeader.h>
0029 #include <KgvUnitWidgets.h>
0030 
0031 #include <qcheckbox.h>
0032 #include <qlayout.h>
0033 // Added by qt3to4:
0034 #include <QHBoxLayout>
0035 
0036 KgvPageLayoutHeader::KgvPageLayoutHeader(QWidget *parent, KgvUnit::Unit unit, const KgvKWHeaderFooter &kwhf)
0037     : QWidget(parent)
0038     , Ui::KgvPageLayoutHeaderBase()
0039 {
0040     m_headerFooters = kwhf;
0041     QHBoxLayout *lay = new QHBoxLayout(headerSpacingPane);
0042     m_headerSpacing = new KgvUnitDoubleSpinBox(headerSpacingPane, 0.0, 999.0, 0.5, kwhf.ptHeaderBodySpacing, unit);
0043     lay->addWidget(m_headerSpacing);
0044 
0045     lay = new QHBoxLayout(footerSpacingPane);
0046     m_footerSpacing = new KgvUnitDoubleSpinBox(footerSpacingPane, 0.0, 999.0, 0.5, kwhf.ptFooterBodySpacing, unit);
0047     lay->addWidget(m_footerSpacing);
0048 
0049     lay = new QHBoxLayout(footnotePane);
0050     m_footnoteSpacing = new KgvUnitDoubleSpinBox(footnotePane, 0.0, 999.0, 0.5, kwhf.ptFootNoteBodySpacing, unit);
0051     lay->addWidget(m_footnoteSpacing);
0052 
0053     if (kwhf.header == HF_FIRST_DIFF || kwhf.header == HF_FIRST_EO_DIFF)
0054         rhFirst->setChecked(true);
0055     if (kwhf.header == HF_EO_DIFF || kwhf.header == HF_FIRST_EO_DIFF)
0056         rhEvenOdd->setChecked(true);
0057     if (kwhf.footer == HF_FIRST_DIFF || kwhf.footer == HF_FIRST_EO_DIFF)
0058         rfFirst->setChecked(true);
0059     if (kwhf.footer == HF_EO_DIFF || kwhf.footer == HF_FIRST_EO_DIFF)
0060         rfEvenOdd->setChecked(true);
0061 }
0062 
0063 const KgvKWHeaderFooter &KgvPageLayoutHeader::headerFooter()
0064 {
0065     if (rhFirst->isChecked() && rhEvenOdd->isChecked())
0066         m_headerFooters.header = HF_FIRST_EO_DIFF;
0067     else if (rhFirst->isChecked())
0068         m_headerFooters.header = HF_FIRST_DIFF;
0069     else if (rhEvenOdd->isChecked())
0070         m_headerFooters.header = HF_EO_DIFF;
0071     else
0072         m_headerFooters.header = HF_SAME;
0073 
0074     m_headerFooters.ptHeaderBodySpacing = m_headerSpacing->value();
0075     m_headerFooters.ptFooterBodySpacing = m_footerSpacing->value();
0076     m_headerFooters.ptFootNoteBodySpacing = m_footnoteSpacing->value();
0077     if (rfFirst->isChecked() && rfEvenOdd->isChecked())
0078         m_headerFooters.footer = HF_FIRST_EO_DIFF;
0079     else if (rfFirst->isChecked())
0080         m_headerFooters.footer = HF_FIRST_DIFF;
0081     else if (rfEvenOdd->isChecked())
0082         m_headerFooters.footer = HF_EO_DIFF;
0083     else
0084         m_headerFooters.footer = HF_SAME;
0085     return m_headerFooters;
0086 }
0087 
0088 #include "moc_KgvPageLayoutHeader.cpp"