• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdefile
 

tdeio/tdefile

kurlrequesterdlg.cpp
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2000 Wilco Greven <greven@kde.org>
00003 
00004     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 
00021 #include <sys/stat.h>
00022 #include <unistd.h>
00023 
00024 #include <tqlabel.h>
00025 #include <tqlayout.h>
00026 #include <tqstring.h>
00027 #include <tqtoolbutton.h>
00028 
00029 #include <tdeaccel.h>
00030 #include <tdefiledialog.h>
00031 #include <tdeglobal.h>
00032 #include <kiconloader.h>
00033 #include <klineedit.h>
00034 #include <tdelocale.h>
00035 #include <tderecentdocument.h>
00036 #include <kurl.h>
00037 #include <kurlrequester.h>
00038 
00039 #include "kurlrequesterdlg.h"
00040 
00041 
00042 KURLRequesterDlg::KURLRequesterDlg( const TQString& urlName, TQWidget *parent,
00043         const char *name, bool modal )
00044     :   KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, name,
00045                 modal, true, KStdGuiItem::clear() )
00046 {
00047   initDialog(i18n( "Location:" ), urlName);
00048 }
00049 
00050 KURLRequesterDlg::KURLRequesterDlg( const TQString& urlName, const TQString& _text, TQWidget *parent, const char *name, bool modal )
00051     :   KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, name,
00052                 modal, true, KStdGuiItem::clear() )
00053 {
00054   initDialog(_text, urlName);
00055 }
00056 
00057 KURLRequesterDlg::~KURLRequesterDlg()
00058 {
00059 }
00060 
00061 void KURLRequesterDlg::initDialog(const TQString &text,const TQString &urlName)
00062 {
00063    TQVBoxLayout * topLayout = new TQVBoxLayout( plainPage(), 0,
00064             spacingHint() );
00065 
00066     TQLabel * label = new TQLabel( text , plainPage() );
00067     topLayout->addWidget( label );
00068 
00069     urlRequester_ = new KURLRequester( urlName, plainPage(), "urlRequester" );
00070     urlRequester_->setMinimumWidth( urlRequester_->sizeHint().width() * 3 );
00071     topLayout->addWidget( urlRequester_ );
00072     urlRequester_->setFocus();
00073     connect( urlRequester_->lineEdit(), TQT_SIGNAL(textChanged(const TQString&)),
00074              TQT_SLOT(slotTextChanged(const TQString&)) );
00075     bool state = !urlName.isEmpty();
00076     enableButtonOK( state );
00077     enableButton( KDialogBase::User1, state );
00078     /*
00079     KFile::Mode mode = static_cast<KFile::Mode>( KFile::File |
00080             KFile::ExistingOnly );
00081     urlRequester_->setMode( mode );
00082     */
00083     connect( this, TQT_SIGNAL( user1Clicked() ), TQT_SLOT( slotClear() ) );
00084 }
00085 
00086 void KURLRequesterDlg::slotTextChanged(const TQString & text)
00087 {
00088     bool state = !text.stripWhiteSpace().isEmpty();
00089     enableButtonOK( state );
00090     enableButton( KDialogBase::User1, state );
00091 }
00092 
00093 void KURLRequesterDlg::slotClear()
00094 {
00095     urlRequester_->clear();
00096 }
00097 
00098 KURL KURLRequesterDlg::selectedURL() const
00099 {
00100     if ( result() == TQDialog::Accepted )
00101         return KURL::fromPathOrURL( urlRequester_->url() );
00102     else
00103         return KURL();
00104 }
00105 
00106 
00107 KURL KURLRequesterDlg::getURL(const TQString& dir, TQWidget *parent,
00108         const TQString& caption)
00109 {
00110     KURLRequesterDlg dlg(dir, parent, "filedialog", true);
00111 
00112     dlg.setCaption(caption.isNull() ? i18n("Open") : caption);
00113 
00114     dlg.exec();
00115 
00116     const KURL& url = dlg.selectedURL();
00117     if (url.isValid())
00118         TDERecentDocument::add(url);
00119 
00120     return url;
00121 }
00122 
00123 KFileDialog * KURLRequesterDlg::fileDialog()
00124 {
00125     return urlRequester_->fileDialog();
00126 }
00127 
00128 KURLRequester * KURLRequesterDlg::urlRequester()
00129 {
00130     return urlRequester_;
00131 }
00132 
00133 #include "kurlrequesterdlg.moc"
00134 
00135 // vim:ts=4:sw=4:tw=78

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdefile by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.