kspread Library API Documentation

kspread_dlg_area.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
00003              (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
00004              (C) 2002 John Dailey <dailey@vt.edu>
00005              (C) 1999-2001 Laurent Montel <montel@kde.org>
00006              (C) 1998-1999 Torben Weis <weis@kde.org>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License as published by the Free Software Foundation; either
00011    version 2 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public License
00019    along with this library; see the file COPYING.LIB.  If not, write to
00020    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021    Boston, MA 02111-1307, USA.
00022 */
00023 
00024 
00025 
00026 #include "kspread_dlg_area.h"
00027 #include "kspread_view.h"
00028 #include "kspread_sheet.h"
00029 #include "kspread_doc.h"
00030 #include "kspread_locale.h"
00031 
00032 #include <qlayout.h>
00033 #include <qlabel.h>
00034 #include <qlineedit.h>
00035 #include <kmessagebox.h>
00036 
00037 KSpreadarea::KSpreadarea( KSpreadView * parent, const char * name, const QPoint & _marker )
00038   : KDialogBase( parent, name, TRUE, i18n("Area Name"), Ok | Cancel )
00039 {
00040   m_pView  = parent;
00041   m_marker = _marker;
00042 
00043   QWidget * page = new QWidget( this );
00044   setMainWidget(page);
00045   QVBoxLayout * lay1 = new QVBoxLayout( page, 0, spacingHint() );
00046 
00047   QLabel * label = new QLabel( i18n("Enter the area name:"), page );
00048   lay1->addWidget( label );
00049 
00050   m_areaName = new QLineEdit(page);
00051   m_areaName->setMinimumWidth( m_areaName->sizeHint().width() * 3 );
00052 
00053   lay1->addWidget( m_areaName );
00054   m_areaName->setFocus();
00055   connect ( m_areaName, SIGNAL(textChanged ( const QString & )), this, SLOT(slotAreaNamechanged( const QString &)));
00056   connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00057   enableButtonOK(!m_areaName->text().isEmpty());
00058 
00059 }
00060 
00061 void KSpreadarea::slotAreaNamechanged( const QString & text)
00062 {
00063   enableButtonOK(!text.isEmpty());
00064 }
00065 
00066 void KSpreadarea::slotOk()
00067 {
00068   QString tmp(m_areaName->text());
00069   if( !tmp.isEmpty() )
00070   {
00071     tmp = tmp.lower();
00072 
00073     QRect rect( m_pView->selection() );
00074     bool newName = true;
00075     QValueList<Reference>::Iterator it;
00076     QValueList<Reference> area = m_pView->doc()->listArea();
00077     for ( it = area.begin(); it != area.end(); ++it )
00078     {
00079       if(tmp == (*it).ref_name)
00080         newName = false;
00081     }
00082     if (newName)
00083     {
00084       m_pView->doc()->emitBeginOperation( false );
00085       m_pView->doc()->addAreaName(rect, tmp, m_pView->activeSheet()->sheetName());
00086       m_pView->slotUpdateView( m_pView->activeSheet() );
00087       accept();
00088     }
00089     else
00090       KMessageBox::error( this, i18n("This name is already used."));
00091   }
00092   else
00093   {
00094     KMessageBox::error( this, i18n("Area text is empty.") );
00095   }
00096 }
00097 
00098 #include "kspread_dlg_area.moc"
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:42:54 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003