File indexing completed on 2024-05-05 05:46:05

0001 /***************************************************************************
0002  *   Copyright (C) 2004 by David Saxton                                    *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #include "externalconnection.h"
0012 #include "libraryitem.h"
0013 
0014 #include <KLocalizedString>
0015 #include <QPainter>
0016 
0017 Item *ExternalConnection::construct(ItemDocument *itemDocument, bool newItem, const char *id)
0018 {
0019     return new ExternalConnection(static_cast<ICNDocument *>(itemDocument), newItem, id);
0020 }
0021 
0022 LibraryItem *ExternalConnection::libraryItem()
0023 {
0024     return new LibraryItem(QStringList(QString("ec/external_connection")), i18n("External Connection"), i18n("Connections"), "external_connection.png", LibraryItem::lit_component, ExternalConnection::construct);
0025 }
0026 
0027 ExternalConnection::ExternalConnection(ICNDocument *icnDocument, bool newItem, const char *id)
0028     : Component(icnDocument, newItem, id ? id : "external_connection")
0029 {
0030     m_name = i18n("External Connection");
0031     setSize(-8, -8, 16, 16);
0032 
0033     createProperty("name", Variant::Type::Combo);
0034     property("name")->setCaption(i18n("Name"));
0035     property("name")->setValue("ExtCon");
0036 
0037     init1PinLeft();
0038 
0039     addDisplayText("name", QRect(-24, 8, 3 * width(), 16), "ExtCon");
0040 }
0041 
0042 ExternalConnection::~ExternalConnection()
0043 {
0044 }
0045 
0046 void ExternalConnection::dataChanged()
0047 {
0048     QString name = dataString("name");
0049 
0050     QRect r(-width(), 16, 3 * width(), 16);
0051     setDisplayText("name", name);
0052 }
0053 
0054 void ExternalConnection::drawShape(QPainter &p)
0055 {
0056     initPainter(p);
0057     int _x = int(x()) - 8;
0058     int _y = int(y()) - 8;
0059     p.drawEllipse(_x, _y, width(), height());
0060 
0061     p.drawLine(_x + 3, _y + 6, _x + 12, _y + 6);
0062     p.drawLine(_x + 8, _y + 3, _x + 12, _y + 6);
0063 
0064     p.drawLine(_x + 3, _y + 9, _x + 12, _y + 9);
0065     p.drawLine(_x + 3, _y + 9, _x + 8, _y + 12);
0066 
0067     deinitPainter(p);
0068 }