kspread_dlg_area.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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"
This file is part of the documentation for kspread Library Version 1.4.2.