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 <qlineedit.h>
00023 #include <qlayout.h>
00024 #include <kpushbutton.h>
00025 #include <kfiledialog.h>
00026 #include <kiconloader.h>
00027 
00028 QDirLineEdit::QDirLineEdit(bool file, QWidget *parent, const char *name)
00029     : QWidget(parent, name)
00030 {
00031     edit_ = new QLineEdit(this);
00032     button_ = new KPushButton(this);
00033     button_->setPixmap(SmallIcon("fileopen"));
00034     connect(button_,SIGNAL(clicked()),SLOT(buttonClicked()));
00035 
00036     QHBoxLayout *main_ = new QHBoxLayout(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 QString& txt)
00048 {
00049     edit_->setText(txt);
00050 }
00051 
00052 QString QDirLineEdit::url()
00053 {
00054     return edit_->text();
00055 }
00056 
00057 void QDirLineEdit::buttonClicked()
00058 {
00059     QString dirname;
00060     if (!fileedit_)
00061         dirname = KFileDialog::getExistingDirectory(edit_->text(), this);
00062     else
00063         dirname = KFileDialog::getOpenFileName(edit_->text(), QString::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"
 
This file is part of the documentation for kdeprint Library Version 3.2.0.