KDevelop API Documentation

pfontcombo.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2002-2004 by Alexander Dymo                             *
00003  *   cloudtemple@mskat.net                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Library General Public License as       *
00007  *   published by the Free Software Foundation; either version 2 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU Library General Public     *
00016  *   License along with this program; if not, write to the                 *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "pfontcombo.h"
00021 
00022 #ifndef PURE_QT
00023 #include <kfontcombo.h>
00024 #else
00025 #include <qcombobox.h>
00026 #endif
00027 
00028 #include <qlayout.h>
00029 
00030 #ifdef PURE_QT
00031 #include <qfontdatabase.h>
00032 #endif
00033 
00034 namespace PropertyLib{
00035 
00036 PFontCombo::PFontCombo(MultiProperty *property, QWidget *parent, const char *name)
00037     :PropertyWidget(property, parent, name)
00038 {
00039     QHBoxLayout *l = new QHBoxLayout(this, 0, 0);
00040     m_edit = new KFontCombo(this);
00041     m_edit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
00042     l->addWidget(m_edit);
00043     
00044     /*adymo: KFontCombo seems to have a bug: when it is not editable, the signals
00045     activated(int) and textChanged(const QString &) are not emitted*/
00046 #ifdef PURE_QT
00047     QFontDatabase fonts;
00048     insertStringList(fonts.families());
00049 #endif
00050     connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
00051 }
00052 
00053 QVariant PFontCombo::value() const
00054 {
00055 #ifndef PURE_QT
00056     return QVariant(m_edit->currentFont());
00057 #else
00058     return QVariant(m_edit->currentText());
00059 #endif
00060 }
00061 
00062 void PFontCombo::setValue(const QVariant &value, bool emitChange)
00063 {
00064     disconnect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
00065 #ifndef PURE_QT
00066     m_edit->setCurrentFont(value.toString());
00067 #else
00068     m_edit->setCurrentText(value.toString());
00069 #endif
00070     connect(m_edit, SIGNAL(textChanged(const QString&)), this, SLOT(updateProperty(const QString&)));
00071     if (emitChange)
00072         emit propertyChanged(m_property, value);
00073 }
00074 
00075 void PFontCombo::updateProperty(const QString &val)
00076 {
00077     emit propertyChanged(m_property, QVariant(val));
00078 }
00079 
00080 }
00081 
00082 #ifndef PURE_QT
00083 #include "pfontcombo.moc"
00084 #endif
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:53 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003