00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <kdeversion.h>
00021 #include <klocale.h>
00022 #include <qlayout.h>
00023 #include <qpushbutton.h>
00024 #include <qlistbox.h>
00025 #include "KoEditPath.h"
00026 #include <keditlistbox.h>
00027 #include <kfiledialog.h>
00028 #include <kurlrequester.h>
00029 #include <qhbox.h>
00030 #include <klineedit.h>
00031 #include <qvbox.h>
00032 #include <qcheckbox.h>
00033 #include <qlabel.h>
00034
00035 KoEditPathDia::KoEditPathDia( const QString & _path, QWidget *parent, const char *name )
00036 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
00037 {
00038 setCaption( i18n("Edit Path") );
00039 QWidget *page = new QWidget( this );
00040 setMainWidget(page);
00041 QGridLayout * grid = new QGridLayout(page, 5, 2, KDialog::marginHint(), KDialog::spacingHint());
00042
00043 urlReq = new KURLRequester();
00044 urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
00045
00046 KEditListBox::CustomEditor tmp(urlReq, urlReq->lineEdit());
00047
00048 m_listpath = new KEditListBox( i18n("Expression Path"),
00049 tmp,page, "list_editor" , false, KEditListBox::Add|KEditListBox::Remove );
00050
00051 grid->addMultiCellWidget(m_listpath, 0, 4, 0, 0);
00052 m_listpath->listBox()->insertStringList(QStringList::split(QString(";"), _path));
00053 setFocus();
00054 resize( 500, 300);
00055 }
00056
00057 QString KoEditPathDia::newPath()const
00058 {
00059 QString tmp;
00060 for (int i = 0; i <(int)m_listpath->listBox()->count(); i++)
00061 {
00062 if ( i!=0)
00063 tmp +=";";
00064 tmp += m_listpath->listBox()->text( i );
00065 }
00066 return tmp;
00067 }
00068
00069
00070 KoChangePathDia::KoChangePathDia( const QString & _path, QWidget *parent, const char *name )
00071 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
00072 {
00073 setCaption( i18n("Edit Path") );
00074
00075 QVBox *page =makeVBoxMainWidget();
00076 new QLabel( i18n("Location:"), page);
00077 m_urlReq = new KURLRequester(page);
00078 m_urlReq->setMinimumWidth( m_urlReq->sizeHint().width() * 3 );
00079
00080 m_urlReq->lineEdit()->setText( _path );
00081 m_urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
00082 m_defaultPath = new QCheckBox( i18n("Default path"), page );
00083 connect( m_defaultPath, SIGNAL(toggled ( bool )), this, SLOT( slotChangeDefaultValue( bool )));
00084 slotChangeDefaultValue( _path.isEmpty() );
00085 m_defaultPath->setChecked( _path.isEmpty() );
00086 }
00087
00088 QString KoChangePathDia::newPath() const
00089 {
00090 return m_defaultPath->isChecked() ? QString::null : m_urlReq->lineEdit()->text();
00091 }
00092
00093 void KoChangePathDia::slotChangeDefaultValue( bool _b)
00094 {
00095 m_urlReq->setEnabled( !_b);
00096 }
00097
00098 #include "KoEditPath.moc"