File indexing completed on 2024-05-12 16:35:23
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003 Norbert Andres <nandres@web.de> 0003 (C) 2002 Philipp Mueller <philipp.mueller@gmx.de> 0004 (C) 2002 John Dailey <dailey@vt.edu> 0005 (C) 2000-2002 Laurent Montel <montel@kde.org> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 0023 // Local 0024 #include "PasteInsertDialog.h" 0025 0026 #include <QApplication> 0027 #include <QGroupBox> 0028 #include <QVBoxLayout> 0029 #include <KLocalizedString> 0030 0031 #include <QRadioButton> 0032 #include <QCheckBox> 0033 0034 #include "commands/PasteCommand.h" 0035 #include "Map.h" 0036 #include "ui/Selection.h" 0037 #include "Sheet.h" 0038 0039 using namespace Calligra::Sheets; 0040 0041 PasteInsertDialog::PasteInsertDialog(QWidget* parent, Selection* selection) 0042 : KoDialog(parent) 0043 { 0044 setCaption(i18n("Paste Inserting Cells")); 0045 setObjectName(QLatin1String("PasteInsertDialog")); 0046 setModal(true); 0047 setButtons(Ok | Cancel); 0048 m_selection = selection; 0049 rect = selection->lastRange(); 0050 0051 QWidget *page = new QWidget(); 0052 setMainWidget(page); 0053 QVBoxLayout *lay1 = new QVBoxLayout(page); 0054 0055 QGroupBox *grp = new QGroupBox(i18n("Insert"), page); 0056 QVBoxLayout *vbox = new QVBoxLayout; 0057 vbox->addWidget(rb1 = new QRadioButton(i18n("Move towards right"))); 0058 vbox->addWidget(rb2 = new QRadioButton(i18n("Move towards bottom"))); 0059 rb1->setChecked(true); 0060 grp->setLayout(vbox); 0061 lay1->addWidget(grp); 0062 0063 connect(this, SIGNAL(okClicked()), this, SLOT(slotOk())); 0064 } 0065 0066 void PasteInsertDialog::slotOk() 0067 { 0068 PasteCommand *const command = new PasteCommand(); 0069 command->setSheet(m_selection->activeSheet()); 0070 command->add(*m_selection); 0071 command->setMimeData(QApplication::clipboard()->mimeData()); 0072 if (rb1->isChecked()) { 0073 command->setInsertionMode(PasteCommand::ShiftCellsRight); 0074 } else if (rb2->isChecked()) { 0075 command->setInsertionMode(PasteCommand::ShiftCellsDown); 0076 } 0077 m_selection->activeSheet()->map()->addCommand(command); 0078 accept(); 0079 }