kspread

kspread_dlg_goto.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 1999-2003 Laurent Montel <montel@kde.org>
00003              (C) 2003 Philipp Mueller <philipp.mueller@gmx.de>
00004              (C) 2003 Ariya Hidayat <ariya@kde.org>
00005              (C) 2003 Norbert Andres <nandres@web.de>
00006              (C) 1999 Stephan Kulow <coolo@kde.org>
00007              (C) 1998-2000 Torben Weis <weis@kde.org>
00008 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public
00011    License as published by the Free Software Foundation; either
00012    version 2 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018 
00019    You should have received a copy of the GNU Library General Public License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00022  * Boston, MA 02110-1301, USA.
00023 */
00024 
00025 #include <qlabel.h>
00026 #include <qlayout.h>
00027 
00028 #include <klineedit.h>
00029 
00030 #include "kspread_canvas.h"
00031 #include "kspread_doc.h"
00032 #include "kspread_locale.h"
00033 #include "kspread_util.h"
00034 #include "kspread_view.h"
00035 #include "selection.h"
00036 
00037 #include "kspread_dlg_goto.h"
00038 
00039 using namespace KSpread;
00040 
00041 GotoDialog::GotoDialog( View* parent, const char* name )
00042     : KDialogBase( parent, name, TRUE, i18n("Goto Cell"), Ok|Cancel )
00043 {
00044   m_pView = parent;
00045   QWidget *page = new QWidget( this );
00046   setMainWidget(page);
00047   QVBoxLayout *lay1 = new QVBoxLayout( page, 0, spacingHint() );
00048 
00049   QLabel *label = new QLabel(i18n("Enter cell:"), page);
00050   lay1->addWidget(label);
00051 
00052   m_nameCell = new KLineEdit( page );
00053   lay1->addWidget(m_nameCell);
00054 
00055   m_nameCell->setFocus();
00056   enableButtonOK( false );
00057 
00058   connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00059   connect( m_nameCell, SIGNAL(textChanged ( const QString & )),
00060            this, SLOT(textChanged ( const QString & )));
00061 }
00062 
00063 void GotoDialog::textChanged ( const QString &_text )
00064 {
00065     enableButtonOK(!_text.isEmpty());
00066 }
00067 
00068 void GotoDialog::slotOk()
00069 {
00070     m_pView->doc()->emitBeginOperation( false );
00071 
00072     QString tmp_upper;
00073     tmp_upper=m_nameCell->text().upper();
00074     Region region(m_pView, tmp_upper);
00075     if ( region.isValid() )
00076     {
00077       m_pView->selectionInfo()->initialize(region);
00078       accept();
00079     }
00080     else
00081     {
00082         m_nameCell->clear();
00083     }
00084     m_pView->slotUpdateView( m_pView->activeSheet() );
00085 }
00086 
00087 #include "kspread_dlg_goto.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys