00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <klocale.h>
00021
00022 #include <kvbox.h>
00023 #include <QLabel>
00024 #include <QLineEdit>
00025 #include "KoCreateStyleDia.h"
00026 #include <kmessagebox.h>
00027
00028 KoCreateStyleDia::KoCreateStyleDia( const QStringList & _list, QWidget *parent, const char *name )
00029 : KDialog( parent )
00030 {
00031 setModal( true );
00032 setObjectName( name );
00033 setButtons( Ok|Cancel );
00034 setDefaultButton( Ok );
00035 showButtonSeparator( true );
00036 styleList=_list;
00037 setCaption( i18n("Create New Style") );
00038 KVBox *page = new KVBox();
00039 setMainWidget(page);
00040 new QLabel(i18n("Please specify a new style name:"), page);
00041 m_styleName = new QLineEdit( page );
00042 m_styleName->setMinimumWidth( m_styleName->sizeHint().width() * 3 );
00043
00044 connect( m_styleName, SIGNAL(textChanged ( const QString & )), this, SLOT(nameChanged( const QString &)));
00045 m_styleName->setFocus();
00046 enableButtonOk( false );
00047 }
00048
00049 void KoCreateStyleDia::slotOk()
00050 {
00051 if ( styleList.findIndex(m_styleName->text() ) != -1 )
00052 {
00053 KMessageBox::error(this, i18n("Name already exists! Please choose another name"));
00054 m_styleName->clear();
00055 }
00056 else
00057 slotButtonClicked( Ok );
00058 }
00059
00060 QString KoCreateStyleDia::nameOfNewStyle()const
00061 {
00062 return m_styleName->text();
00063 }
00064
00065 void KoCreateStyleDia::nameChanged( const QString &text)
00066 {
00067 enableButtonOk( !text.isEmpty() );
00068 }
00069 #include "KoCreateStyleDia.moc"