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 <tdeversion.h>
21#include <tdelocale.h>
22#include <tqlayout.h>
23#include <tqpushbutton.h>
24#include <tqlistbox.h>
25#include "KoEditPath.h"
26#include <keditlistbox.h>
27#include <tdefiledialog.h>
28#include <kurlrequester.h>
29#include <tqhbox.h>
30#include <klineedit.h>
31#include <tqvbox.h>
32#include <tqcheckbox.h>
33#include <tqlabel.h>
34
35KoEditPathDia::KoEditPathDia( const TQString & _path, TQWidget *parent, const char *name )
36 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
37{
38 setCaption( i18n("Edit Path") );
39 TQWidget *page = new TQWidget( this );
40 setMainWidget(page);
41 TQGridLayout * grid = new TQGridLayout(page, 5, 2, KDialog::marginHint(), KDialog::spacingHint());
42
43 urlReq = new KURLRequester();
44 urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
45
46 KEditListBox::CustomEditor tmp(urlReq, urlReq->lineEdit());
47
48 m_listpath = new KEditListBox( i18n("Expression Path"),
49 tmp,page, "list_editor" , false, KEditListBox::Add|KEditListBox::Remove );
50
51 grid->addMultiCellWidget(m_listpath, 0, 4, 0, 0);
52 m_listpath->listBox()->insertStringList(TQStringList::split(TQString(";"), _path));
53 setFocus();
54 resize( 500, 300);
55}
56
57TQString KoEditPathDia::newPath()const
58{
59 TQString tmp;
60 for (int i = 0; i <(int)m_listpath->listBox()->count(); i++)
61 {
62 if ( i!=0)
63 tmp +=";";
64 tmp += m_listpath->listBox()->text( i );
65 }
66 return tmp;
67}
68
69
70KoChangePathDia::KoChangePathDia( const TQString & _path, TQWidget *parent, const char *name )
71 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
72{
73 setCaption( i18n("Edit Path") );
74
75 TQVBox *page =makeVBoxMainWidget();
76 new TQLabel( i18n("Location:"), page);
77 m_urlReq = new KURLRequester(page);
78 m_urlReq->setMinimumWidth( m_urlReq->sizeHint().width() * 3 );
79
80 m_urlReq->lineEdit()->setText( _path );
81 m_urlReq->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
82 m_defaultPath = new TQCheckBox( i18n("Default path"), page );
83 connect( m_defaultPath, TQ_SIGNAL(toggled ( bool )), this, TQ_SLOT( slotChangeDefaultValue( bool )));
84 slotChangeDefaultValue( _path.isEmpty() );
85 m_defaultPath->setChecked( _path.isEmpty() );
86}
87
88TQString KoChangePathDia::newPath() const
89{
90 return m_defaultPath->isChecked() ? TQString() : m_urlReq->lineEdit()->text();
91}
92
93void KoChangePathDia::slotChangeDefaultValue( bool _b)
94{
95 m_urlReq->setEnabled( !_b);
96}
97
98#include "KoEditPath.moc"
static int marginHint()
static int spacingHint()
const char * name(StdAction id)