File indexing completed on 2024-05-05 05:21:41

0001 /*
0002   SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 */
0007 
0008 #include "inserttabledialog.h"
0009 #include "inserttablewidget.h"
0010 
0011 #include <KLocalizedString>
0012 #include <KSeparator>
0013 
0014 #include <QDialogButtonBox>
0015 #include <QPushButton>
0016 #include <QVBoxLayout>
0017 
0018 using namespace KPIMTextEdit;
0019 
0020 class InsertTableDialog::InsertTableDialogPrivate
0021 {
0022 public:
0023     explicit InsertTableDialogPrivate(InsertTableDialog *qq)
0024         : q(qq)
0025     {
0026         q->setWindowTitle(i18nc("@title:window", "Insert Table"));
0027         auto mainLayout = new QVBoxLayout(q);
0028 
0029         insertTableWidget = new InsertTableWidget(q);
0030         mainLayout->addWidget(insertTableWidget);
0031 
0032         auto sep = new KSeparator(q);
0033         mainLayout->addWidget(sep);
0034 
0035         auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, q);
0036         QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0037         okButton->setText(i18n("Insert"));
0038         okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0039         q->connect(buttonBox, &QDialogButtonBox::accepted, q, &QDialog::accept);
0040         q->connect(buttonBox, &QDialogButtonBox::rejected, q, &QDialog::reject);
0041 
0042         mainLayout->addWidget(buttonBox);
0043     }
0044 
0045     InsertTableWidget *insertTableWidget = nullptr;
0046     InsertTableDialog *const q;
0047 };
0048 
0049 InsertTableDialog::InsertTableDialog(QWidget *parent)
0050     : QDialog(parent)
0051     , d(new InsertTableDialogPrivate(this))
0052 {
0053 }
0054 
0055 InsertTableDialog::~InsertTableDialog() = default;
0056 
0057 int InsertTableDialog::columns() const
0058 {
0059     return d->insertTableWidget->columns();
0060 }
0061 
0062 int InsertTableDialog::rows() const
0063 {
0064     return d->insertTableWidget->rows();
0065 }
0066 
0067 int InsertTableDialog::border() const
0068 {
0069     return d->insertTableWidget->border();
0070 }
0071 
0072 QTextLength::Type InsertTableDialog::typeOfLength() const
0073 {
0074     return d->insertTableWidget->typeOfLength();
0075 }
0076 
0077 int InsertTableDialog::length() const
0078 {
0079     return d->insertTableWidget->length();
0080 }
0081 
0082 void InsertTableDialog::setColumns(int col)
0083 {
0084     d->insertTableWidget->setColumns(col);
0085 }
0086 
0087 void InsertTableDialog::setRows(int rows)
0088 {
0089     d->insertTableWidget->setRows(rows);
0090 }
0091 
0092 void InsertTableDialog::setBorder(int border)
0093 {
0094     d->insertTableWidget->setBorder(border);
0095 }
0096 
0097 void InsertTableDialog::setLength(int val)
0098 {
0099     d->insertTableWidget->setLength(val);
0100 }
0101 
0102 void InsertTableDialog::setTypeOfLength(QTextLength::Type type)
0103 {
0104     d->insertTableWidget->setTypeOfLength(type);
0105 }
0106 
0107 #include "moc_inserttabledialog.cpp"