00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KWInsertDia.h"
00022 #include "KWTableFrameSet.h"
00023 #include "KWView.h"
00024
00025 #include <klocale.h>
00026
00027 #include <qlabel.h>
00028 #include <qspinbox.h>
00029 #include <qradiobutton.h>
00030 #include <qbuttongroup.h>
00031 #include <qlayout.h>
00032
00033 KWInsertDia::KWInsertDia( KWView *parent, KWTableFrameSet *table, InsertType type, int insertHint)
00034 : KDialogBase( Plain, (type==insertRow?i18n("Insert Row") : i18n("Insert Column")), Ok | Cancel, Ok, parent, "Insert Table items dialog", true )
00035 {
00036 m_type = type;
00037 m_table = table;
00038 m_view = parent;
00039
00040 setupTab1(insertHint);
00041 }
00042
00043 void KWInsertDia::setupTab1(int insertHint)
00044 {
00045 QWidget *tab1 = plainPage();
00046 QGridLayout *grid1 = new QGridLayout( tab1, 2, 2, 0, KDialog::spacingHint() );
00047
00048 QButtonGroup *grp = new QButtonGroup( m_type == insertRow ? i18n( "Insert New Row" ) : i18n( "Insert New Column" ), tab1 );
00049
00050 QGridLayout *grid2 = new QGridLayout( grp, 3, 1, KDialog::marginHint(), KDialog::spacingHint() );
00051
00052 m_rBefore = new QRadioButton( i18n( "Before" ), grp, "before_radio_button" );
00053 grp->insert( m_rBefore );
00054 grid2->addWidget( m_rBefore, 1, 0 );
00055
00056 QRadioButton *rAfter = new QRadioButton( i18n( "After" ), grp, "after_radio_button");
00057 grp->insert( rAfter );
00058 grid2->addWidget( rAfter, 2, 0 );
00059 rAfter->setChecked( true );
00060
00061 grid2->addRowSpacing( 0, 7 );
00062
00063 grid1->addMultiCellWidget ( grp, 0, 0, 0, 1 );
00064
00065 QLabel *rc = new QLabel( m_type == insertRow ? i18n( "Row:" ) : i18n( "Column:" ), tab1 );
00066 grid1->addWidget( rc, 1, 0 );
00067
00068 m_value = new QSpinBox( 1, m_type == insertRow ? m_table->getRows() : m_table->getColumns(),
00069 1, tab1, "row_col_spinbox" );
00070 m_value->setValue( insertHint + 1 );
00071
00072 grid1->addWidget( m_value, 1, 1 );
00073 }
00074
00075 void KWInsertDia::slotOk()
00076 {
00077 unsigned int insert = m_value->value() - ( m_rBefore->isChecked() ? 1 : 0 );
00078 if ( m_type == insertRow )
00079 m_view->tableInsertRow(insert, m_table);
00080 else
00081 m_view->tableInsertCol(insert, m_table);
00082 KDialogBase::slotOk();
00083 }
00084
00085 #include "KWInsertDia.moc"