kspread

kspread_dlg_special.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
3 (C) 2003 Norbert Andres <nandres@web.de>
4 (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
5 (C) 2002 John Dailey <dailey@vt.edu>
6 (C) 1998-1999 Torben Weis <weis@kde.org>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21*/
22
23#include <tqlayout.h>
24#include <tqbuttongroup.h>
25#include <tqradiobutton.h>
26
27#include <tdelocale.h>
28
29#include "kspread_canvas.h"
30#include "kspread_doc.h"
31#include "kspread_sheet.h"
32#include "kspread_view.h"
33#include "selection.h"
34
35#include "kspread_dlg_special.h"
36
37using namespace KSpread;
38
39SpecialDialog::SpecialDialog( View* parent, const char* name )
40 : KDialogBase( parent, name, true,i18n("Special Paste"),Ok|Cancel )
41{
42 m_pView = parent;
43 TQWidget *page = new TQWidget( this );
44 setMainWidget(page);
45 TQVBoxLayout *lay1 = new TQVBoxLayout( page, 0, spacingHint() );
46
47 TQButtonGroup *grp = new TQButtonGroup( 1, TQt::Horizontal, i18n( "Paste What" ),page );
48 grp->setRadioButtonExclusive( true );
49 grp->layout();
50 lay1->addWidget(grp);
51 rb1 = new TQRadioButton( i18n("Everything"), grp );
52 rb2 = new TQRadioButton( i18n("Text"), grp );
53 rb3 = new TQRadioButton( i18n("Format"), grp );
54 rb10 = new TQRadioButton( i18n("Comment"), grp );
55 rb11 = new TQRadioButton( i18n("Result"), grp );
56
57 rb4 = new TQRadioButton( i18n("Everything without border"), grp );
58 rb1->setChecked(true);
59
60 grp = new TQButtonGroup( 1, TQt::Horizontal, i18n("Operation"),page);
61 grp->setRadioButtonExclusive( true );
62 grp->layout();
63 lay1->addWidget(grp);
64
65
66 rb5 = new TQRadioButton( i18n("Overwrite"), grp );
67 rb6 = new TQRadioButton( i18n("Addition"), grp );
68 rb7 = new TQRadioButton( i18n("Subtraction"), grp );
69 rb8 = new TQRadioButton( i18n("Multiplication"), grp );
70 rb9 = new TQRadioButton( i18n("Division"), grp );
71 rb5->setChecked(true);
72
73 // cb = new TQCheckBox(i18n("Transpose"),this);
74 // cb->layout();
75 // lay1->addWidget(cb);
76
77 connect( this, TQ_SIGNAL( okClicked() ), this, TQ_SLOT( slotOk() ) );
78 connect( rb3, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotToggled( bool ) ) );
79 connect( rb10, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotToggled( bool ) ) );
80}
81
82void SpecialDialog::slotOk()
83{
86
87 /* if( rb1->isChecked() )
88 sp = cb->isChecked() ? NormalAndTranspose : Normal;
89 else if( rb2->isChecked() )
90 sp = cb->isChecked() ? TextAndTranspose : Text;
91 else if( rb3->isChecked() )
92 sp = cb->isChecked() ? FormatAndTranspose : Format;
93 else if( rb4->isChecked() )
94 sp = cb->isChecked() ? NoBorderAndTranspose : NoBorder; */
95
96 if( rb1->isChecked() )
97 sp = Paste::Normal;
98 else if( rb2->isChecked() )
99 sp = Paste::Text;
100 else if( rb3->isChecked() )
101 sp = Paste::Format;
102 else if( rb4->isChecked() )
103 sp = Paste::NoBorder;
104 else if( rb10->isChecked() )
105 sp = Paste::Comment;
106 else if( rb11->isChecked() )
107 sp = Paste::Result;
108
109 if( rb5->isChecked() )
110 op = Paste::OverWrite;
111 if( rb6->isChecked() )
112 op = Paste::Add;
113 if( rb7->isChecked() )
114 op = Paste::Sub;
115 if( rb8->isChecked() )
116 op = Paste::Mul;
117 if( rb9->isChecked() )
118 op = Paste::Div;
119
120 m_pView->doc()->emitBeginOperation( false );
121 m_pView->activeSheet()->paste( m_pView->selectionInfo()->lastRange(), true, sp, op );
122 m_pView->slotUpdateView( m_pView->activeSheet() );
123 accept();
124}
125
126void SpecialDialog::slotToggled( bool b )
127{
128 rb5->setEnabled( !b );
129 rb6->setEnabled( !b );
130 rb7->setEnabled( !b );
131 rb8->setEnabled( !b );
132 rb9->setEnabled( !b );
133}
134
135#include "kspread_dlg_special.moc"
The View class displays a KSpread document.
Operation
The current cell value treatment.
@ Sub
Substract.
@ OverWrite
Overwrite.
Mode
The pasted content.
@ Result
Result only, no formula.
@ Format
Format only.
@ Comment
Comment only.
@ Text
Text only.
@ NoBorder
not the borders
@ Normal
Everything.
The KSpread namespace.
Definition commands.h:39