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>
00023 #include <QPushButton>
00024 #include <q3listbox.h>
00025 #include <QGridLayout>
00026 #include "KoEditPath.h"
00027 #include <keditlistbox.h>
00028 #include <kfiledialog.h>
00029 #include <kurlrequester.h>
00030 #include <q3hbox.h>
00031 #include <klineedit.h>
00032 #include <q3vbox.h>
00033 #include <QCheckBox>
00034 #include <QLabel>
00035
00036 KoEditPathDia::KoEditPathDia( const QString & _path, QWidget *parent, const char *name )
00037 : KDialog( parent )
00038 {
00039 setObjectName( name );
00040 setModal( true );
00041 setButtons( KDialog::Ok|KDialog::Cancel );
00042 setDefaultButton( KDialog::Ok );
00043
00044 setCaption( i18n("Edit Path") );
00045 QWidget *page = new QWidget( this );
00046 setMainWidget(page);
00047 QGridLayout * grid = new QGridLayout(page);
00048 grid->setMargin(KDialog::marginHint());
00049 grid->setSpacing(KDialog::spacingHint());
00050
00051 urlReq = new KUrlRequester();
00052 urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
00053
00054 KEditListBox::CustomEditor tmp(urlReq, urlReq->lineEdit());
00055
00056 m_listpath = new KEditListBox( i18n("Expression Path"),
00057 tmp,page, "list_editor" , false, KEditListBox::Add|KEditListBox::Remove );
00058
00059 grid->addWidget(m_listpath, 0, 0, 5, 1);
00060 m_listpath->setItems(_path.split(";", QString::SkipEmptyParts));
00061 setFocus();
00062 resize( 500, 300);
00063 }
00064
00065 QString KoEditPathDia::newPath()const
00066 {
00067 QString tmp;
00068 QStringList items = m_listpath->items();
00069 QStringList::iterator it = items.begin();
00070 QStringList::iterator endIt = items.end();
00071
00072 for (; it != endIt; ++it)
00073 {
00074 if (!tmp.isEmpty())
00075 tmp += ';';
00076 tmp += *it;
00077 }
00078 return tmp;
00079 }
00080
00081
00082 KoChangePathDia::KoChangePathDia( const QString & _path, QWidget *parent, const char *name )
00083 : KDialog( parent )
00084 {
00085 setObjectName( name );
00086 setModal( true );
00087 setButtons( KDialog::Ok|KDialog::Cancel );
00088 setDefaultButton( KDialog::Ok );
00089 setCaption( i18n("Edit Path") );
00090
00091 KVBox *page = new KVBox();
00092 setMainWidget(page);
00093 new QLabel( i18n("Location:"), page);
00094 m_urlReq = new KUrlRequester(page);
00095 m_urlReq->setMinimumWidth( m_urlReq->sizeHint().width() * 3 );
00096
00097 m_urlReq->lineEdit()->setText( _path );
00098 m_urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
00099 m_defaultPath = new QCheckBox( i18n("Default path"), page );
00100 connect( m_defaultPath, SIGNAL(toggled ( bool )), this, SLOT( slotChangeDefaultValue( bool )));
00101 slotChangeDefaultValue( _path.isEmpty() );
00102 m_defaultPath->setChecked( _path.isEmpty() );
00103 }
00104
00105 QString KoChangePathDia::newPath() const
00106 {
00107 return m_defaultPath->isChecked() ? QString::null : m_urlReq->lineEdit()->text();
00108 }
00109
00110 void KoChangePathDia::slotChangeDefaultValue( bool _b)
00111 {
00112 m_urlReq->setEnabled( !_b);
00113 }
00114
00115 #include "KoEditPath.moc"