kspread

AngleDialog.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 Norbert Andres<nandres@web.de>
00003              (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
00004              (C) 2002 Ariya Hidayat <ariya@kde.org>
00005              (C) 1999-2002 Laurent Montel <montel@kde.org>
00006              (C) 1998-1999 Torben Weis <weis@kde.org>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License as published by the Free Software Foundation; either
00011    version 2 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public License
00019    along with this library; see the file COPYING.LIB.  If not, write to
00020    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021    Boston, MA 02110-1301, USA.
00022 */
00023 
00024 // Local
00025 #include "AngleDialog.h"
00026 
00027 #include <QPushButton>
00028 #include <QVBoxLayout>
00029 
00030 #include <kdebug.h>
00031 #include <klocale.h>
00032 #include <knuminput.h>
00033 
00034 #include "Cell.h"
00035 #include "Selection.h"
00036 #include "Sheet.h"
00037 
00038 #include "commands/StyleCommand.h"
00039 #include "commands/RowColumnManipulators.h"
00040 
00041 using namespace KSpread;
00042 
00043 AngleDialog::AngleDialog(QWidget* parent, Selection* selection)
00044   : KDialog( parent )
00045 {
00046   setCaption( i18n("Change Angle") );
00047   setModal( true );
00048   setButtons( Ok|Cancel|Default );
00049 
00050   m_selection = selection;
00051 
00052   QWidget *page = new QWidget();
00053   setMainWidget( page );
00054 
00055   QVBoxLayout *lay = new QVBoxLayout( page );
00056   lay->setMargin(0);
00057   lay->setSpacing(spacingHint());
00058   m_pAngle = new KIntNumInput( page );
00059   m_pAngle->setRange( -90, 90, 1 );
00060   m_pAngle->setLabel( i18n("Angle:") );
00061   m_pAngle->setSuffix(" ");
00062   lay->addWidget( m_pAngle );
00063 
00064   QWidget* spacer = new QWidget( page );
00065   spacer->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ) );
00066   lay->addWidget( spacer );
00067 
00068   m_pAngle->setFocus();
00069 
00070   connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00071   connect( this, SIGNAL(defaultClicked()), this, SLOT(slotDefault()) );
00072   int angle = - Cell(m_selection->activeSheet(), m_selection->marker()).style().angle();
00073   m_pAngle->setValue( angle );
00074 }
00075 
00076 void AngleDialog::slotOk()
00077 {
00078     QUndoCommand* macroCommand = new QUndoCommand(i18n("Change Angle"));
00079 
00080     StyleCommand* manipulator = new StyleCommand(macroCommand);
00081     manipulator->setSheet(m_selection->activeSheet());
00082     manipulator->setAngle(-m_pAngle->value());
00083     manipulator->add(*m_selection);
00084 
00085     AdjustColumnRowManipulator* manipulator2 = new AdjustColumnRowManipulator(macroCommand);
00086     manipulator2->setSheet(m_selection->activeSheet());
00087     manipulator2->setAdjustColumn(true);
00088     manipulator2->setAdjustRow(true);
00089     manipulator2->add(*m_selection);
00090 
00091     m_selection->canvas()->addCommand(macroCommand);
00092     accept();
00093 }
00094 
00095 void AngleDialog::slotDefault()
00096 {
00097     m_pAngle->setValue( 0 );
00098 }
00099 
00100 
00101 #include "AngleDialog.moc"