File indexing completed on 2024-12-08 11:06:54
0001 /*************************************************************************** 0002 * Copyright (C) 2003 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 "readport.h" 0012 0013 #include "flowcode.h" 0014 #include "libraryitem.h" 0015 #include "icndocument.h" 0016 0017 #include <KLocalizedString> 0018 0019 Item *ReadPort::construct(ItemDocument *itemDocument, bool newItem, const char *id) 0020 { 0021 return new ReadPort(static_cast<ICNDocument *>(itemDocument), newItem, id); 0022 } 0023 0024 LibraryItem *ReadPort::libraryItem() 0025 { 0026 return new LibraryItem(QStringList(QString("flow/readport")), i18n("Read from Port"), i18n("I\\/O"), "portread.png", LibraryItem::lit_flowpart, ReadPort::construct); 0027 } 0028 0029 ReadPort::ReadPort(ICNDocument *icnDocument, bool newItem, const char *id) 0030 : FlowPart(icnDocument, newItem, id ? id : "readport") 0031 { 0032 m_name = i18n("Read from Port"); 0033 initIOSymbol(); 0034 createStdInput(); 0035 createStdOutput(); 0036 0037 createProperty("0-port", Variant::Type::Port); 0038 property("0-port")->setToolbarCaption(i18n("Read")); 0039 property("0-port")->setEditorCaption(i18n("Port")); 0040 property("0-port")->setValue("PORTA"); 0041 0042 createProperty("1-var", Variant::Type::VarName); 0043 property("1-var")->setToolbarCaption(i18nc("read from port to x", "to")); 0044 property("1-var")->setEditorCaption(i18n("Variable")); 0045 property("1-var")->setValue("x"); 0046 } 0047 0048 ReadPort::~ReadPort() 0049 { 0050 } 0051 0052 void ReadPort::dataChanged() 0053 { 0054 setCaption(i18n("Read %1 to %2", dataString("0-port"), dataString("1-var"))); 0055 } 0056 0057 void ReadPort::generateMicrobe(FlowCode *code) 0058 { 0059 code->addCode(dataString("1-var") + " = " + dataString("0-port")); 0060 code->addCodeBranch(outputPart("stdoutput")); 0061 }