27#include <tqbuttongroup.h>
28#include <tqradiobutton.h>
29#include <tqcheckbox.h>
32#include <kbuttonbox.h>
35#include <tdemessagebox.h>
37#include "kspread_doc.h"
38#include "kspread_sheet.h"
39#include "kspread_view.h"
41#include "kspread_dlg_insert.h"
45InsertDialog::InsertDialog( View* parent, const char* name, const TQRect &_rect,Mode _mode)
46 : KDialogBase( parent, name, true, "",Ok|Cancel )
52 TQWidget *page = new TQWidget( this );
54 TQVBoxLayout *lay1 = new TQVBoxLayout( page, 0, spacingHint() );
56 TQButtonGroup *grp = new TQButtonGroup( 1, TQt::Horizontal, i18n( "Insert"),page);
57 grp->setRadioButtonExclusive( true );
62 rb1 = new TQRadioButton( i18n( "Move towards right"), grp );
63 rb2 = new TQRadioButton( i18n( "Move towards bottom"), grp );
64 rb3 = new TQRadioButton( i18n( "Insert rows"), grp );
65 rb4 = new TQRadioButton( i18n( "Insert columns"), grp );
66 setCaption( i18n( "Insert Cells") );
68 else if(insRem==Remove)
70 grp->setTitle(i18n( "Remove"));
71 rb1 = new TQRadioButton( i18n( "Move towards left"), grp );
72 rb2 = new TQRadioButton( i18n( "Move towards top"), grp );
73 rb3 = new TQRadioButton( i18n( "Remove rows"), grp );
74 rb4 = new TQRadioButton( i18n( "Remove columns"), grp );
75 setCaption( i18n( "Remove Cells") );
78 kdDebug(36001) << "Error in kspread_dlg_InsertDialog" << endl;
80 rb1->setChecked( true);
83 connect( this, TQ_SIGNAL( okClicked() ), this, TQ_SLOT( slotOk() ) );
86void InsertDialog::slotOk()
88 m_pView->doc()->emitBeginOperation( false );
89 if( rb1->isChecked() )
91 if( insRem == Insert )
93 if ( !m_pView->activeSheet()->shiftRow( rect ) )
94 KMessageBox::error( this, i18n( "The row is full. Cannot move cells to the right.") );
96 else if( insRem == Remove )
98 m_pView->activeSheet()->unshiftRow(rect);
101 else if( rb2->isChecked() )
103 if( insRem == Insert )
105 if ( !m_pView->activeSheet()->shiftColumn( rect ) )
106 KMessageBox::error( this, i18n( "The column is full. Cannot move cells towards the bottom.") );
108 else if( insRem == Remove )
110 m_pView->activeSheet()->unshiftColumn( rect );
113 else if( rb3->isChecked() )
115 if( insRem == Insert )
117 if ( !m_pView->activeSheet()->insertRow( rect.top(),(rect.bottom()-rect.top() ) ) )
118 KMessageBox::error( this, i18n( "The row is full. Cannot move cells to the right.") );
120 else if( insRem == Remove )
122 m_pView->activeSheet()->removeRow( rect.top(),(rect.bottom()-rect.top() ) );
125 else if( rb4->isChecked() )
127 if( insRem == Insert )
129 if ( !m_pView->activeSheet()->insertColumn( rect.left(),(rect.right()-rect.left() )) )
130 KMessageBox::error( this, i18n( "The column is full. Cannot move cells towards the bottom.") );
132 else if( insRem == Remove )
134 m_pView->activeSheet()->removeColumn( rect.left(),(rect.right()-rect.left() ) );
139 kdDebug(36001) << "Error in kspread_dlg_InsertDialog" << endl;
142 m_pView->updateEditWidget();
144 m_pView->slotUpdateView( m_pView->activeSheet() );
148#include "kspread_dlg_insert.moc"
The View class displays a KSpread document.
|