• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kfile
 

kio/kfile

  • kio
  • kfile
kurlrequesterdlg.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 Wilco Greven <greven@kde.org>
3 
4  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 
21 #include <sys/stat.h>
22 #include <unistd.h>
23 
24 #include <tqlabel.h>
25 #include <tqlayout.h>
26 #include <tqstring.h>
27 #include <tqtoolbutton.h>
28 
29 #include <kaccel.h>
30 #include <kfiledialog.h>
31 #include <kglobal.h>
32 #include <kiconloader.h>
33 #include <klineedit.h>
34 #include <klocale.h>
35 #include <krecentdocument.h>
36 #include <kurl.h>
37 #include <kurlrequester.h>
38 
39 #include "kurlrequesterdlg.h"
40 
41 
42 KURLRequesterDlg::KURLRequesterDlg( const TQString& urlName, TQWidget *parent,
43  const char *name, bool modal )
44  : KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, name,
45  modal, true, KStdGuiItem::clear() )
46 {
47  initDialog(i18n( "Location:" ), urlName);
48 }
49 
50 KURLRequesterDlg::KURLRequesterDlg( const TQString& urlName, const TQString& _text, TQWidget *parent, const char *name, bool modal )
51  : KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, name,
52  modal, true, KStdGuiItem::clear() )
53 {
54  initDialog(_text, urlName);
55 }
56 
57 KURLRequesterDlg::~KURLRequesterDlg()
58 {
59 }
60 
61 void KURLRequesterDlg::initDialog(const TQString &text,const TQString &urlName)
62 {
63  TQVBoxLayout * topLayout = new TQVBoxLayout( plainPage(), 0,
64  spacingHint() );
65 
66  TQLabel * label = new TQLabel( text , plainPage() );
67  topLayout->addWidget( label );
68 
69  urlRequester_ = new KURLRequester( urlName, plainPage(), "urlRequester" );
70  urlRequester_->setMinimumWidth( urlRequester_->sizeHint().width() * 3 );
71  topLayout->addWidget( urlRequester_ );
72  urlRequester_->setFocus();
73  connect( urlRequester_->lineEdit(), TQT_SIGNAL(textChanged(const TQString&)),
74  TQT_SLOT(slotTextChanged(const TQString&)) );
75  bool state = !urlName.isEmpty();
76  enableButtonOK( state );
77  enableButton( KDialogBase::User1, state );
78  /*
79  KFile::Mode mode = static_cast<KFile::Mode>( KFile::File |
80  KFile::ExistingOnly );
81  urlRequester_->setMode( mode );
82  */
83  connect( this, TQT_SIGNAL( user1Clicked() ), TQT_SLOT( slotClear() ) );
84 }
85 
86 void KURLRequesterDlg::slotTextChanged(const TQString & text)
87 {
88  bool state = !text.stripWhiteSpace().isEmpty();
89  enableButtonOK( state );
90  enableButton( KDialogBase::User1, state );
91 }
92 
93 void KURLRequesterDlg::slotClear()
94 {
95  urlRequester_->clear();
96 }
97 
98 KURL KURLRequesterDlg::selectedURL() const
99 {
100  if ( result() == TQDialog::Accepted )
101  return KURL::fromPathOrURL( urlRequester_->url() );
102  else
103  return KURL();
104 }
105 
106 
107 KURL KURLRequesterDlg::getURL(const TQString& dir, TQWidget *parent,
108  const TQString& caption)
109 {
110  KURLRequesterDlg dlg(dir, parent, "filedialog", true);
111 
112  dlg.setCaption(caption.isNull() ? i18n("Open") : caption);
113 
114  dlg.exec();
115 
116  const KURL& url = dlg.selectedURL();
117  if (url.isValid())
118  KRecentDocument::add(url);
119 
120  return url;
121 }
122 
123 KFileDialog * KURLRequesterDlg::fileDialog()
124 {
125  return urlRequester_->fileDialog();
126 }
127 
128 KURLRequester * KURLRequesterDlg::urlRequester()
129 {
130  return urlRequester_;
131 }
132 
133 #include "kurlrequesterdlg.moc"
134 
135 // vim:ts=4:sw=4:tw=78

kio/kfile

Skip menu "kio/kfile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kio/kfile

Skip menu "kio/kfile"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kfile by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |