1 /***************************************************************************
2  *   Copyright (C) 2004 by David Saxton                                    *
3  *   david@bluehaze.org                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  ***************************************************************************/
10 
11 #include "externalconnection.h"
12 #include "libraryitem.h"
13 
14 #include <KLocalizedString>
15 #include <QPainter>
16 
construct(ItemDocument * itemDocument,bool newItem,const char * id)17 Item* ExternalConnection::construct( ItemDocument *itemDocument, bool newItem, const char *id )
18 {
19 	return new ExternalConnection( (ICNDocument*)itemDocument, newItem, id );
20 }
21 
libraryItem()22 LibraryItem* ExternalConnection::libraryItem()
23 {
24 	return new LibraryItem(
25 		QStringList(QString("ec/external_connection")),
26 		i18n("External Connection"),
27 		i18n("Connections"),
28 		"external_connection.png",
29 		LibraryItem::lit_component,
30 		ExternalConnection::construct );
31 }
32 
ExternalConnection(ICNDocument * icnDocument,bool newItem,const char * id)33 ExternalConnection::ExternalConnection( ICNDocument *icnDocument, bool newItem, const char *id )
34 	: Component( icnDocument, newItem, id ? id : "external_connection" )
35 {
36 	m_name = i18n("External Connection");
37 	setSize( -8, -8, 16, 16 );
38 
39 	createProperty( "name", Variant::Type::Combo );
40 	property("name")->setCaption( i18n("Name") );
41 	property("name")->setValue("ExtCon");
42 
43 	init1PinLeft();
44 
45 	addDisplayText( "name", QRect( -24, 8, 3*width(), 16 ), "ExtCon" );
46 }
47 
~ExternalConnection()48 ExternalConnection::~ExternalConnection()
49 {
50 }
51 
52 
dataChanged()53 void ExternalConnection::dataChanged()
54 {
55 	QString name = dataString("name");
56 
57 	QRect r( -width(), 16, 3*width(), 16 );
58 	setDisplayText( "name", name );
59 }
60 
61 
drawShape(QPainter & p)62 void ExternalConnection::drawShape( QPainter &p )
63 {
64 	initPainter(p);
65 	int _x = (int)x()-8;
66 	int _y = (int)y()-8;
67 	p.drawEllipse( _x, _y, width(), height() );
68 
69 	p.drawLine( _x+3, _y+6, _x+12, _y+6 );
70 	p.drawLine( _x+8, _y+3, _x+12, _y+6 );
71 
72 	p.drawLine( _x+3, _y+9, _x+12, _y+9 );
73 	p.drawLine( _x+3, _y+9, _x+8, _y+12 );
74 
75 	deinitPainter(p);
76 }
77 
78