00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (c) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library 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 GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #include "qurlpropertywidgetitem.h" 00021 00022 #include <QtCore/QUrl> 00023 #include <QtGui/QLayout> 00024 #include <KLineEdit> 00025 00026 REGISTER_PROPERTYWIDGETITEM( GluonCreator, QUrlPropertyWidgetItem ) 00027 00028 using namespace GluonCreator; 00029 00030 QUrlPropertyWidgetItem::QUrlPropertyWidgetItem( QWidget* parent, Qt::WindowFlags f ) 00031 : PropertyWidgetItem( parent, f ) 00032 { 00033 KLineEdit* input = new KLineEdit( this ); 00034 //input->setInputMask(""); 00035 connect( input, SIGNAL( editingFinished() ), this, SLOT( urlValueChanged() ) ); 00036 setEditWidget( input ); 00037 } 00038 00039 QUrlPropertyWidgetItem::~QUrlPropertyWidgetItem() 00040 { } 00041 00042 GluonCreator::PropertyWidgetItem* 00043 QUrlPropertyWidgetItem::instantiate() 00044 { 00045 return new QUrlPropertyWidgetItem(); 00046 } 00047 00048 QStringList 00049 QUrlPropertyWidgetItem::supportedDataTypes() const 00050 { 00051 QStringList supportedTypes; 00052 supportedTypes.append( "QUrl" ); 00053 return supportedTypes; 00054 } 00055 00056 void 00057 QUrlPropertyWidgetItem::setEditValue( const QVariant& value ) 00058 { 00059 editWidget()->setProperty( "text", value.value<QUrl>().toString() ); 00060 } 00061 00062 void 00063 QUrlPropertyWidgetItem::urlValueChanged() 00064 { 00065 PropertyWidgetItem::valueChanged( QVariant( QUrl( editWidget()->property( "text" ).toString() ) ) ); 00066 }