lib Library API Documentation

koeditpath.cc

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., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
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"
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:47:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003