# kdeprint Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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(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.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:06 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003