kspread
kspread_dlg_area.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <qlayout.h>
00025 #include <qlabel.h>
00026 #include <qlineedit.h>
00027
00028 #include <kmessagebox.h>
00029
00030 #include "kspread_doc.h"
00031 #include "kspread_locale.h"
00032 #include "kspread_sheet.h"
00033 #include "kspread_view.h"
00034 #include "selection.h"
00035
00036 #include "kspread_dlg_area.h"
00037
00038 using namespace KSpread;
00039
00040 AreaDialog::AreaDialog( View * parent, const char * name, const QPoint & _marker )
00041 : KDialogBase( parent, name, TRUE, i18n("Area Name"), Ok | Cancel )
00042 {
00043 m_pView = parent;
00044 m_marker = _marker;
00045
00046 QWidget * page = new QWidget( this );
00047 setMainWidget(page);
00048 QVBoxLayout * lay1 = new QVBoxLayout( page, 0, spacingHint() );
00049
00050 QLabel * label = new QLabel( i18n("Enter the area name:"), page );
00051 lay1->addWidget( label );
00052
00053 m_areaName = new QLineEdit(page);
00054 m_areaName->setMinimumWidth( m_areaName->sizeHint().width() * 3 );
00055
00056 lay1->addWidget( m_areaName );
00057 m_areaName->setFocus();
00058 connect ( m_areaName, SIGNAL(textChanged ( const QString & )), this, SLOT(slotAreaNamechanged( const QString &)));
00059 connect( this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) );
00060 enableButtonOK(!m_areaName->text().isEmpty());
00061
00062 }
00063
00064 void AreaDialog::slotAreaNamechanged( const QString & text)
00065 {
00066 enableButtonOK(!text.isEmpty());
00067 }
00068
00069 void AreaDialog::slotOk()
00070 {
00071 QString tmp(m_areaName->text());
00072 if( !tmp.isEmpty() )
00073 {
00074 tmp = tmp.lower();
00075
00076 QRect rect( m_pView->selectionInfo()->selection() );
00077 bool newName = true;
00078 QValueList<Reference>::Iterator it;
00079 QValueList<Reference> area = m_pView->doc()->listArea();
00080 for ( it = area.begin(); it != area.end(); ++it )
00081 {
00082 if(tmp == (*it).ref_name)
00083 newName = false;
00084 }
00085 if (newName)
00086 {
00087 m_pView->doc()->emitBeginOperation( false );
00088 m_pView->doc()->addAreaName(rect, tmp, m_pView->activeSheet()->sheetName());
00089 m_pView->slotUpdateView( m_pView->activeSheet() );
00090 accept();
00091 }
00092 else
00093 KMessageBox::error( this, i18n("This name is already used."));
00094 }
00095 else
00096 {
00097 KMessageBox::error( this, i18n("Area text is empty.") );
00098 }
00099 }
00100
00101 #include "kspread_dlg_area.moc"
|