diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e9ae80694875f869892f13f4fcaf1170a00dea41 (patch) | |
tree | aa2f8d8a217e2d376224c8d46b7397b68d35de2d /quanta/dialogs/filecombo.cpp | |
download | tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'quanta/dialogs/filecombo.cpp')
-rw-r--r-- | quanta/dialogs/filecombo.cpp | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/quanta/dialogs/filecombo.cpp b/quanta/dialogs/filecombo.cpp new file mode 100644 index 00000000..40415757 --- /dev/null +++ b/quanta/dialogs/filecombo.cpp @@ -0,0 +1,122 @@ +/*************************************************************************** + filecombo.cpp - description + ------------------- + begin : Wed Sep 27 2000 + copyright : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev & Eric Laffoon <pdima@users.sourceforge.net,yshurik@penguinpowered.com,sequitur@easystreet.com> + (C) 2002-2003 Andras Mantia <amantia@kde.org> + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +// QT includes +#include <qlayout.h> +#include <qcombobox.h> +#include <qpushbutton.h> + +// KDE includes +#include <klocale.h> +#include <kfiledialog.h> +#include <kurl.h> + +// app include +#include "filecombo.h" +#include "qextfileinfo.h" + +FileCombo::FileCombo(const KURL& a_baseURL, QWidget *parent, const char *name ) + :QWidget(parent,name) +{ + baseURL = a_baseURL; + m_absolutePath = false; + + QHBoxLayout *layout = new QHBoxLayout(this); + + combo = new QComboBox(true,this); + combo->setEditable(true); + button = new QPushButton(this); + + button ->setFixedSize(35,25); + button ->setText(i18n("...")); + + layout ->addWidget( combo ); + layout ->addWidget( button ); + + connect( button, SIGNAL(clicked()), this, SLOT(slotFileSelect()) ); + connect( combo, SIGNAL(activated(const QString&)), SLOT(slotComboActivated(const QString&))); + connect( combo, SIGNAL(textChanged(const QString&)), SLOT(slotComboActivated(const QString&))); + setFocusProxy(combo); +} + +FileCombo::FileCombo( QWidget *parent, const char *name ) + :QWidget( parent, name ) +{ + baseURL.setPath("."); + + QHBoxLayout *layout = new QHBoxLayout(this); + + combo = new QComboBox(true,this); + button = new QPushButton(this); + + button ->setFixedSize(35,25); + button ->setText(i18n("...")); + + layout ->addWidget( combo ); + layout ->addWidget( button ); + + connect( button, SIGNAL(clicked()), this, SLOT(slotFileSelect()) ); + connect( combo, SIGNAL(activated(const QString&)), SLOT(slotComboActivated(const QString&))); + connect( combo, SIGNAL(textChanged(const QString&)), SLOT(slotComboActivated(const QString&))); + setFocusProxy(combo); +} + +FileCombo::~FileCombo(){ +} + +QString FileCombo::text() const +{ + return combo->currentText(); +} + +void FileCombo::setText( const QString &_txt ) +{ + combo ->setEditText( _txt ); +} + +void FileCombo::slotFileSelect() +{ + KFileDialog *dlg = new KFileDialog(baseURL.url(), i18n("*|All Files"), this, "", true); + dlg->setMode(KFile::File | KFile::Directory | KFile::ExistingOnly); + dlg->exec(); + KURL url = dlg->selectedURL(); + delete dlg; + if ( !url.isEmpty() ) + { + if (!m_absolutePath) url = QExtFileInfo::toRelative(url, baseURL); + combo->setEditText( url.path() ); + } +} + +/** No descriptions */ +void FileCombo::setBaseURL(const KURL& a_baseURL) +{ + baseURL = a_baseURL; +} + +/** No descriptions */ +void FileCombo::setReturnAbsolutePath(bool absolutePath) +{ + m_absolutePath = absolutePath; +} + +void FileCombo::slotComboActivated(const QString&s) +{ + emit activated(s); +} + +#include "filecombo.moc" |