kspread

kspread_dlg_special.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 1999-2004 Laurent Montel <montel@kde.org>
00003              (C) 2003 Norbert Andres <nandres@web.de>
00004              (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
00005              (C) 2002 John Dailey <dailey@vt.edu>
00006              (C) 1998-1999 Torben Weis <weis@kde.org>
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include <qlayout.h>
00024 #include <qbuttongroup.h>
00025 #include <qradiobutton.h>
00026 
00027 #include <klocale.h>
00028 
00029 #include "kspread_canvas.h"
00030 #include "kspread_doc.h"
00031 #include "kspread_sheet.h"
00032 #include "kspread_view.h"
00033 #include "selection.h"
00034 
00035 #include "kspread_dlg_special.h"
00036 
00037 using namespace KSpread;
00038 
00039 SpecialDialog::SpecialDialog( View* parent, const char* name )
00040     : KDialogBase( parent, name, TRUE,i18n("Special Paste"),Ok|Cancel  )
00041 {
00042     m_pView = parent;
00043     QWidget *page = new QWidget( this );
00044     setMainWidget(page);
00045     QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00046 
00047     QButtonGroup *grp = new QButtonGroup( 1, QGroupBox::Horizontal, i18n( "Paste What" ),page );
00048     grp->setRadioButtonExclusive( TRUE );
00049     grp->layout();
00050     lay1->addWidget(grp);
00051     rb1 = new QRadioButton( i18n("Everything"), grp );
00052     rb2 = new QRadioButton( i18n("Text"), grp );
00053     rb3 = new QRadioButton( i18n("Format"), grp );
00054     rb10 = new QRadioButton( i18n("Comment"), grp );
00055     rb11 = new QRadioButton( i18n("Result"), grp );
00056 
00057     rb4 = new QRadioButton( i18n("Everything without border"), grp );
00058     rb1->setChecked(true);
00059 
00060     grp = new QButtonGroup( 1, QGroupBox::Horizontal, i18n("Operation"),page);
00061     grp->setRadioButtonExclusive( TRUE );
00062     grp->layout();
00063     lay1->addWidget(grp);
00064 
00065 
00066     rb5 = new QRadioButton( i18n("Overwrite"), grp );
00067     rb6 = new QRadioButton( i18n("Addition"), grp );
00068     rb7 = new QRadioButton( i18n("Subtraction"), grp );
00069     rb8 = new QRadioButton( i18n("Multiplication"), grp );
00070     rb9 = new QRadioButton( i18n("Division"), grp );
00071     rb5->setChecked(true);
00072 
00073     // cb = new QCheckBox(i18n("Transpose"),this);
00074     // cb->layout();
00075     // lay1->addWidget(cb);
00076 
00077     connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00078     connect( rb3, SIGNAL( toggled( bool ) ), this, SLOT( slotToggled( bool ) ) );
00079     connect( rb10, SIGNAL( toggled( bool ) ), this, SLOT( slotToggled( bool ) ) );
00080 }
00081 
00082 void SpecialDialog::slotOk()
00083 {
00084   Paste::Mode sp = Paste::Normal;
00085   Paste::Operation op = Paste::OverWrite;
00086 
00087     /* if( rb1->isChecked() )
00088     sp = cb->isChecked() ? NormalAndTranspose : Normal;
00089     else if( rb2->isChecked() )
00090     sp = cb->isChecked() ? TextAndTranspose : Text;
00091     else if( rb3->isChecked() )
00092     sp = cb->isChecked() ? FormatAndTranspose : Format;
00093     else if( rb4->isChecked() )
00094     sp = cb->isChecked() ? NoBorderAndTranspose : NoBorder; */
00095 
00096     if( rb1->isChecked() )
00097       sp = Paste::Normal;
00098     else if( rb2->isChecked() )
00099       sp = Paste::Text;
00100     else if( rb3->isChecked() )
00101       sp = Paste::Format;
00102     else if( rb4->isChecked() )
00103       sp = Paste::NoBorder;
00104     else if( rb10->isChecked() )
00105       sp = Paste::Comment;
00106     else if( rb11->isChecked() )
00107       sp = Paste::Result;
00108 
00109     if( rb5->isChecked() )
00110       op = Paste::OverWrite;
00111     if( rb6->isChecked() )
00112       op = Paste::Add;
00113     if( rb7->isChecked() )
00114       op = Paste::Sub;
00115     if( rb8->isChecked() )
00116       op = Paste::Mul;
00117     if( rb9->isChecked() )
00118       op = Paste::Div;
00119 
00120     m_pView->doc()->emitBeginOperation( false );
00121     m_pView->activeSheet()->paste( m_pView->selectionInfo()->lastRange(), true, sp, op );
00122     m_pView->slotUpdateView( m_pView->activeSheet() );
00123     accept();
00124 }
00125 
00126 void SpecialDialog::slotToggled( bool b )
00127 {
00128     rb5->setEnabled( !b );
00129     rb6->setEnabled( !b );
00130     rb7->setEnabled( !b );
00131     rb8->setEnabled( !b );
00132     rb9->setEnabled( !b );
00133 }
00134 
00135 #include "kspread_dlg_special.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys