94 lines
3.0 KiB
C++
94 lines
3.0 KiB
C++
#include "cellsettingsdialog.h"
|
|
#include <QDebug>
|
|
|
|
CellSettingsDialog::CellSettingsDialog(int row, int column, const QString &cellName,
|
|
int currentStretch,
|
|
bool currentIsHeader,
|
|
bool currentIsUnderline,
|
|
QWidget *parent)
|
|
: QDialog(parent)
|
|
, m_row(row)
|
|
, m_column(column)
|
|
, m_cellName(cellName)
|
|
{
|
|
qDebug() << "CellSettingsDialog::CellSettingsDialog: Создаем диалог для ячейки row=" << row << "column=" << column;
|
|
setUp();
|
|
setUpConnections();
|
|
|
|
if (m_stretchSpinBox) {
|
|
m_stretchSpinBox->setValue(currentStretch);
|
|
}
|
|
if (m_isHeaderCheckBox) {
|
|
m_isHeaderCheckBox->setChecked(currentIsHeader);
|
|
}
|
|
if (m_isUnderlineCheckBox) {
|
|
m_isUnderlineCheckBox->setChecked(currentIsUnderline);
|
|
}
|
|
}
|
|
|
|
CellSettingsDialog::~CellSettingsDialog()
|
|
{
|
|
}
|
|
|
|
void CellSettingsDialog::setUp()
|
|
{
|
|
setWindowTitle("Настройка ячейки");
|
|
setModal(true);
|
|
resize(300, 200);
|
|
|
|
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
|
|
|
// Информация о ячейке
|
|
m_cellNameLabel = new QLabel(QString("Ячейка: %1 (строка %2, колонка %3)").arg(m_cellName).arg(m_row + 1).arg(m_column + 1), this);
|
|
mainLayout->addWidget(m_cellNameLabel);
|
|
|
|
// Поле поджима
|
|
QHBoxLayout *stretchLayout = new QHBoxLayout();
|
|
QLabel *stretchLabel = new QLabel("Поджим по ширине:", this);
|
|
m_stretchSpinBox = new QSpinBox(this);
|
|
m_stretchSpinBox->setMinimum(50);
|
|
m_stretchSpinBox->setMaximum(200);
|
|
m_stretchSpinBox->setValue(100);
|
|
m_stretchSpinBox->setSuffix("%");
|
|
stretchLayout->addWidget(stretchLabel);
|
|
stretchLayout->addWidget(m_stretchSpinBox);
|
|
stretchLayout->addStretch();
|
|
mainLayout->addLayout(stretchLayout);
|
|
|
|
// Чекбокс для isHeader
|
|
m_isHeaderCheckBox = new QCheckBox("Является заголовком", this);
|
|
mainLayout->addWidget(m_isHeaderCheckBox);
|
|
|
|
// Чекбокс для isUnderline
|
|
m_isUnderlineCheckBox = new QCheckBox("Подчеркивать текст", this);
|
|
mainLayout->addWidget(m_isUnderlineCheckBox);
|
|
|
|
// Кнопки
|
|
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
|
mainLayout->addWidget(m_buttonBox);
|
|
|
|
mainLayout->addStretch();
|
|
}
|
|
|
|
void CellSettingsDialog::setUpConnections()
|
|
{
|
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
}
|
|
|
|
int CellSettingsDialog::getStretch() const
|
|
{
|
|
return m_stretchSpinBox ? m_stretchSpinBox->value() : 100;
|
|
}
|
|
|
|
bool CellSettingsDialog::isHeader() const
|
|
{
|
|
return m_isHeaderCheckBox ? m_isHeaderCheckBox->isChecked() : false;
|
|
}
|
|
|
|
bool CellSettingsDialog::isUnderline() const
|
|
{
|
|
return m_isUnderlineCheckBox ? m_isUnderlineCheckBox->isChecked() : true;
|
|
}
|
|
|