~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kword/KWInsertDia.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
 
3
   Copyright (C)  2005 Thomas Zander <zander@kde.org>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Library General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Library General Public License
 
16
   along with this library; see the file COPYING.LIB.  If not, write to
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
 
19
*/
 
20
 
 
21
#include "KWInsertDia.h"
 
22
#include "KWTableFrameSet.h"
 
23
#include "KWView.h"
 
24
 
 
25
#include <klocale.h>
 
26
 
 
27
#include <qlabel.h>
 
28
#include <qspinbox.h>
 
29
#include <qradiobutton.h>
 
30
#include <qbuttongroup.h>
 
31
#include <qlayout.h>
 
32
 
 
33
KWInsertDia::KWInsertDia( KWView *parent, KWTableFrameSet *table, InsertType type, int insertHint)
 
34
    : KDialogBase( Plain, (type==insertRow?i18n("Insert Row") : i18n("Insert Column")), Ok | Cancel, Ok, parent, "Insert Table items dialog", true )
 
35
{
 
36
    m_type = type;
 
37
    m_table = table;
 
38
    m_view = parent;
 
39
 
 
40
    setupTab1(insertHint);
 
41
}
 
42
 
 
43
void KWInsertDia::setupTab1(int insertHint)
 
44
{
 
45
    QWidget *tab1 = plainPage();
 
46
    QGridLayout *grid1 = new QGridLayout( tab1, 2, 2, 0, KDialog::spacingHint() );
 
47
 
 
48
    QButtonGroup *grp = new QButtonGroup( m_type == insertRow ? i18n( "Insert New Row" ) : i18n( "Insert New Column" ), tab1 );
 
49
 
 
50
    QGridLayout *grid2 = new QGridLayout( grp, 3, 1, KDialog::marginHint(), KDialog::spacingHint() );
 
51
 
 
52
    m_rBefore = new QRadioButton( i18n( "Before" ), grp, "before_radio_button" );
 
53
    grp->insert( m_rBefore );
 
54
    grid2->addWidget( m_rBefore, 1, 0 );
 
55
 
 
56
    QRadioButton *rAfter = new QRadioButton( i18n( "After" ), grp,  "after_radio_button");
 
57
    grp->insert( rAfter );
 
58
    grid2->addWidget( rAfter, 2, 0 );
 
59
    rAfter->setChecked( true );
 
60
 
 
61
    grid2->addRowSpacing( 0, 7 );
 
62
 
 
63
    grid1->addMultiCellWidget ( grp, 0, 0, 0, 1 );
 
64
 
 
65
    QLabel *rc = new QLabel( m_type == insertRow ? i18n( "Row:" ) : i18n( "Column:" ), tab1 );
 
66
    grid1->addWidget( rc, 1, 0 );
 
67
 
 
68
    m_value = new QSpinBox( 1, m_type == insertRow ? m_table->getRows() : m_table->getColumns(),
 
69
        1, tab1, "row_col_spinbox" );
 
70
    m_value->setValue( insertHint + 1 ); // +1 due to the fact that humans count starting at 1
 
71
 
 
72
    grid1->addWidget( m_value, 1, 1 );
 
73
}
 
74
 
 
75
void KWInsertDia::slotOk()
 
76
{
 
77
    unsigned int insert = m_value->value() - ( m_rBefore->isChecked() ? 1 : 0 );
 
78
    if ( m_type == insertRow )
 
79
        m_view->tableInsertRow(insert, m_table);
 
80
    else
 
81
        m_view->tableInsertCol(insert, m_table);
 
82
      KDialogBase::slotOk();
 
83
}
 
84
 
 
85
#include "KWInsertDia.moc"