kword

KWInsertDia.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003    Copyright (C)  2005 Thomas Zander <zander@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
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 ); // +1 due to the fact that humans count starting at 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"
KDE Home | KDE Accessibility Home | Description of Access Keys