File indexing completed on 2024-05-19 15:27:50
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 <KgvPageLayoutColumns.h> 0029 #include <KgvPageLayoutDia.h> 0030 #include <KgvUnit.h> 0031 #include <KgvUnitWidgets.h> 0032 0033 #include <qlabel.h> 0034 #include <qlayout.h> 0035 // Added by qt3to4: 0036 #include <QHBoxLayout> 0037 0038 KgvPageLayoutColumns::KgvPageLayoutColumns(QWidget *parent, const KgvColumns &columns, KgvUnit::Unit unit, const KgvPageLayout &layout) 0039 : QWidget(parent) 0040 , Ui::KgvPageLayoutColumnsBase() 0041 { 0042 m_columns = columns; 0043 QHBoxLayout *lay = new QHBoxLayout(previewPane); 0044 m_preview = new KgvPagePreview(previewPane, "Preview", layout); 0045 lay->addWidget(m_preview); 0046 lay = new QHBoxLayout(columnSpacingPane); 0047 m_spacing = new KgvUnitDoubleSpinBox(columnSpacingPane); 0048 m_spacing->setValue(m_columns.ptColumnSpacing); 0049 m_spacing->setUnit(unit); 0050 double dStep = KgvUnit::fromUserValue(0.2, unit); 0051 m_spacing->setMinMaxStep(0, layout.ptWidth / 2, dStep); 0052 lay->addWidget(m_spacing); 0053 labelSpacing->setBuddy(m_spacing); 0054 nColumns->setValue(m_columns.columns); 0055 m_preview->setPageColumns(m_columns); 0056 0057 connect(nColumns, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &KgvPageLayoutColumns::nColChanged); 0058 connect(m_spacing, &KgvUnitDoubleSpinBox::valueChangedPt, this, &KgvPageLayoutColumns::nSpaceChanged); 0059 } 0060 0061 void KgvPageLayoutColumns::setEnableColumns(bool on) 0062 { 0063 nColumns->setEnabled(on); 0064 m_spacing->setEnabled(on); 0065 nColChanged(on ? nColumns->value() : 1); 0066 } 0067 0068 void KgvPageLayoutColumns::nColChanged(int columns) 0069 { 0070 m_columns.columns = columns; 0071 m_preview->setPageColumns(m_columns); 0072 emit propertyChange(m_columns); 0073 } 0074 0075 void KgvPageLayoutColumns::nSpaceChanged(double spacing) 0076 { 0077 m_columns.ptColumnSpacing = spacing; 0078 emit propertyChange(m_columns); 0079 } 0080 0081 void KgvPageLayoutColumns::setLayout(KgvPageLayout &layout) 0082 { 0083 m_preview->setPageLayout(layout); 0084 } 0085 0086 #include "moc_KgvPageLayoutColumns.cpp"