tdeprint
qdirlineedit.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "qdirlineedit.h"
00021
00022 #include <tqlineedit.h>
00023 #include <tqlayout.h>
00024 #include <kpushbutton.h>
00025 #include <tdefiledialog.h>
00026 #include <kiconloader.h>
00027
00028 QDirLineEdit::QDirLineEdit(bool file, TQWidget *parent, const char *name)
00029 : TQWidget(parent, name)
00030 {
00031 edit_ = new TQLineEdit(this);
00032 button_ = new KPushButton(this);
00033 button_->setPixmap(SmallIcon("document-open"));
00034 connect(button_,TQT_SIGNAL(clicked()),TQT_SLOT(buttonClicked()));
00035
00036 TQHBoxLayout *main_ = new TQHBoxLayout(this, 0, 3);
00037 main_->addWidget(edit_);
00038 main_->addWidget(button_);
00039
00040 fileedit_ = file;
00041 }
00042
00043 QDirLineEdit::~QDirLineEdit()
00044 {
00045 }
00046
00047 void QDirLineEdit::setURL(const TQString& txt)
00048 {
00049 edit_->setText(txt);
00050 }
00051
00052 TQString QDirLineEdit::url()
00053 {
00054 return edit_->text();
00055 }
00056
00057 void QDirLineEdit::buttonClicked()
00058 {
00059 TQString dirname;
00060 if (!fileedit_)
00061 dirname = KFileDialog::getExistingDirectory(edit_->text(), this);
00062 else
00063 dirname = KFileDialog::getOpenFileName(edit_->text(), TQString::null, this);
00064 if (!dirname.isEmpty())
00065 edit_->setText(dirname);
00066 }
00067
00068 void QDirLineEdit::setFileEdit(bool on)
00069 {
00070 fileedit_ = on;
00071 }
00072
00073 #include "qdirlineedit.moc"