lib

KoEditPath.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Montel Laurent <lmontel@mandrakesoft.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tdelocale.h>
21#include <tqlayout.h>
22#include <tqpushbutton.h>
23#include <tqlistbox.h>
24#include "KoEditPath.h"
25#include <keditlistbox.h>
26#include <tdefiledialog.h>
27#include <kurlrequester.h>
28#include <tqhbox.h>
29#include <klineedit.h>
30#include <tqvbox.h>
31#include <tqcheckbox.h>
32#include <tqlabel.h>
33
34KoEditPathDia::KoEditPathDia( const TQString & _path, TQWidget *parent, const char *name )
35 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
36{
37 setCaption( i18n("Edit Path") );
38 TQWidget *page = new TQWidget( this );
39 setMainWidget(page);
40 TQGridLayout * grid = new TQGridLayout(page, 5, 2, KDialog::marginHint(), KDialog::spacingHint());
41
42 urlReq = new KURLRequester();
43 urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
44
45 KEditListBox::CustomEditor tmp(urlReq, urlReq->lineEdit());
46
47 m_listpath = new KEditListBox( i18n("Expression Path"),
48 tmp,page, "list_editor" , false, KEditListBox::Add|KEditListBox::Remove );
49
50 grid->addMultiCellWidget(m_listpath, 0, 4, 0, 0);
51 m_listpath->listBox()->insertStringList(TQStringList::split(TQString(";"), _path));
52 setFocus();
53 resize( 500, 300);
54}
55
56TQString KoEditPathDia::newPath()const
57{
58 TQString tmp;
59 for (int i = 0; i <(int)m_listpath->listBox()->count(); i++)
60 {
61 if ( i!=0)
62 tmp +=";";
63 tmp += m_listpath->listBox()->text( i );
64 }
65 return tmp;
66}
67
68
69KoChangePathDia::KoChangePathDia( const TQString & _path, TQWidget *parent, const char *name )
70 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
71{
72 setCaption( i18n("Edit Path") );
73
74 TQVBox *page =makeVBoxMainWidget();
75 new TQLabel( i18n("Location:"), page);
76 m_urlReq = new KURLRequester(page);
77 m_urlReq->setMinimumWidth( m_urlReq->sizeHint().width() * 3 );
78
79 m_urlReq->lineEdit()->setText( _path );
80 m_urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
81 m_defaultPath = new TQCheckBox( i18n("Default path"), page );
82 connect( m_defaultPath, TQ_SIGNAL(toggled ( bool )), this, TQ_SLOT( slotChangeDefaultValue( bool )));
83 slotChangeDefaultValue( _path.isEmpty() );
84 m_defaultPath->setChecked( _path.isEmpty() );
85}
86
87TQString KoChangePathDia::newPath() const
88{
89 return m_defaultPath->isChecked() ? TQString() : m_urlReq->lineEdit()->text();
90}
91
92void KoChangePathDia::slotChangeDefaultValue( bool _b)
93{
94 m_urlReq->setEnabled( !_b);
95}
96
97#include "KoEditPath.moc"
static int marginHint()
static int spacingHint()
const char * name(StdAction id)