F:/KPlato/koffice/libs/kofficeui/KoEditPath.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C)  2002 Montel Laurent <lmontel@mandrakesoft.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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"

Généré le Wed Nov 22 23:41:04 2006 pour KPlato par  doxygen 1.5.1-p1