kspread
AngleDialog.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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"
|