kspread_dlg_insert.cc
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
00026
00027
00028 #include "kspread_dlg_insert.h"
00029 #include "kspread_view.h"
00030 #include "kspread_doc.h"
00031 #include "kspread_sheet.h"
00032
00033 #include <qlayout.h>
00034 #include <kbuttonbox.h>
00035 #include <klocale.h>
00036 #include <qbuttongroup.h>
00037 #include <kdebug.h>
00038 #include <qradiobutton.h>
00039 #include <qcheckbox.h>
00040 #include <kmessagebox.h>
00041
00042 KSpreadinsert::KSpreadinsert( KSpreadView* parent, const char* name,const QRect &_rect,Mode _mode)
00043 : KDialogBase( parent, name, TRUE,"",Ok|Cancel )
00044 {
00045 m_pView = parent;
00046 rect=_rect;
00047 insRem=_mode;
00048
00049 QWidget *page = new QWidget( this );
00050 setMainWidget(page);
00051 QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00052
00053 QButtonGroup *grp = new QButtonGroup( 1, QGroupBox::Horizontal, i18n("Insert"),page);
00054 grp->setRadioButtonExclusive( TRUE );
00055 grp->layout();
00056 lay1->addWidget(grp);
00057 if( insRem==Insert)
00058 {
00059 rb1 = new QRadioButton( i18n("Move towards right"), grp );
00060 rb2 = new QRadioButton( i18n("Move towards bottom"), grp );
00061 rb3 = new QRadioButton( i18n("Insert rows"), grp );
00062 rb4 = new QRadioButton( i18n("Insert columns"), grp );
00063 setCaption( i18n("Insert Cells") );
00064 }
00065 else if(insRem==Remove)
00066 {
00067 grp->setTitle(i18n("Remove"));
00068 rb1 = new QRadioButton( i18n("Move towards left"), grp );
00069 rb2 = new QRadioButton( i18n("Move towards top"), grp );
00070 rb3 = new QRadioButton( i18n("Remove rows"), grp );
00071 rb4 = new QRadioButton( i18n("Remove columns"), grp );
00072 setCaption( i18n("Remove Cells") );
00073 }
00074 else
00075 kdDebug(36001) << "Error in kspread_dlg_insert" << endl;
00076
00077 rb1->setChecked(true);
00078
00079
00080 connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00081 }
00082
00083 void KSpreadinsert::slotOk()
00084 {
00085 m_pView->doc()->emitBeginOperation( false );
00086 if( rb1->isChecked() )
00087 {
00088 if( insRem == Insert )
00089 {
00090 if ( !m_pView->activeSheet()->shiftRow( rect ) )
00091 KMessageBox::error( this, i18n("The row is full. Cannot move cells to the right.") );
00092 }
00093 else if( insRem == Remove )
00094 {
00095 m_pView->activeSheet()->unshiftRow(rect);
00096 }
00097 }
00098 else if( rb2->isChecked() )
00099 {
00100 if( insRem == Insert )
00101 {
00102 if ( !m_pView->activeSheet()->shiftColumn( rect ) )
00103 KMessageBox::error( this, i18n("The column is full. Cannot move cells towards the bottom.") );
00104 }
00105 else if( insRem == Remove )
00106 {
00107 m_pView->activeSheet()->unshiftColumn( rect );
00108 }
00109 }
00110 else if( rb3->isChecked() )
00111 {
00112 if( insRem == Insert )
00113 {
00114 if ( !m_pView->activeSheet()->insertRow( rect.top(),(rect.bottom()-rect.top() ) ) )
00115 KMessageBox::error( this, i18n("The row is full. Cannot move cells to the right.") );
00116 }
00117 else if( insRem == Remove )
00118 {
00119 m_pView->activeSheet()->removeRow( rect.top(),(rect.bottom()-rect.top() ) );
00120 }
00121 }
00122 else if( rb4->isChecked() )
00123 {
00124 if( insRem == Insert )
00125 {
00126 if ( !m_pView->activeSheet()->insertColumn( rect.left(),(rect.right()-rect.left() )) )
00127 KMessageBox::error( this, i18n("The column is full. Cannot move cells towards the bottom.") );
00128 }
00129 else if( insRem == Remove )
00130 {
00131 m_pView->activeSheet()->removeColumn( rect.left(),(rect.right()-rect.left() ) );
00132 }
00133 }
00134 else
00135 {
00136 kdDebug(36001) << "Error in kspread_dlg_insert" << endl;
00137 }
00138
00139 m_pView->updateEditWidget();
00140
00141 m_pView->slotUpdateView( m_pView->activeSheet() );
00142 accept();
00143 }
00144
00145
00146 #include "kspread_dlg_insert.moc"
This file is part of the documentation for kspread Library Version 1.4.2.