kdeprint Library API Documentation

qdirlineedit.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
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., 59 Temple Place - Suite 330,
00017  *  Boston, MA 02111-1307, USA.
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(QWidget *parent, const char *name)
00029     : QWidget(parent, name)
00030 {
00031     edit_ = new QLineEdit(this);
00032     //button_ = new QPushButton("Browse...", this);
00033     button_ = new KPushButton(this);
00034     button_->setPixmap(SmallIcon("fileopen"));
00035     connect(button_,SIGNAL(clicked()),SLOT(buttonClicked()));
00036 
00037     QHBoxLayout *main_ = new QHBoxLayout(this, 0, 10);
00038     main_->addWidget(edit_);
00039     main_->addWidget(button_);
00040 
00041     fileedit_ = false;
00042 }
00043 
00044 QDirLineEdit::~QDirLineEdit()
00045 {
00046 }
00047 
00048 void QDirLineEdit::setText(const QString& txt)
00049 {
00050     edit_->setText(txt);
00051 }
00052 
00053 void QDirLineEdit::setButtonText(const QString& txt)
00054 {
00055     button_->setText(txt);
00056 }
00057 
00058 QString QDirLineEdit::text()
00059 {
00060     return edit_->text();
00061 }
00062 
00063 QSize QDirLineEdit::sizeHint() const
00064 {
00065     QSize   s1(edit_->sizeHint()), s2(button_->sizeHint());
00066     return QSize(s1.width()+s2.width()+10,s1.height());
00067 }
00068 
00069 void QDirLineEdit::buttonClicked()
00070 {
00071     QString dirname;
00072     if (!fileedit_) dirname = KFileDialog::getExistingDirectory(edit_->text(), this);
00073     else dirname = KFileDialog::getOpenFileName(edit_->text(), QString::null, this);
00074     if (!dirname.isEmpty()) edit_->setText(dirname);
00075 }
00076 
00077 void QDirLineEdit::setFileEdit(bool on)
00078 {
00079     fileedit_ = on;
00080 }
00081 #include "qdirlineedit.moc"
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Feb 18 15:11:20 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003