File indexing completed on 2024-06-09 13:46:33

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 "callsub.h"
0012 
0013 #include "flowcode.h"
0014 #include "libraryitem.h"
0015 #include "icndocument.h"
0016 
0017 #include <KLocalizedString>
0018 
0019 Item *CallSub::construct(ItemDocument *itemDocument, bool newItem, const char *id)
0020 {
0021     return new CallSub(static_cast<ICNDocument *>(itemDocument), newItem, id);
0022 }
0023 
0024 LibraryItem *CallSub::libraryItem()
0025 {
0026     return new LibraryItem(QStringList(QString("flow/callsub")), i18n("Sub Call"), i18n("Common"), "subcall.png", LibraryItem::lit_flowpart, CallSub::construct);
0027 }
0028 
0029 CallSub::CallSub(ICNDocument *icnDocument, bool newItem, const char *id)
0030     : FlowPart(icnDocument, newItem, id ? id : "callsub")
0031 {
0032     m_name = i18n("Sub Call");
0033     initCallSymbol();
0034     createStdInput();
0035     createStdOutput();
0036 
0037     createProperty("sub", Variant::Type::Combo);
0038     property("sub")->setCaption(i18n("Subroutine"));
0039     property("sub")->setValue("MySub");
0040 }
0041 
0042 CallSub::~CallSub()
0043 {
0044 }
0045 
0046 void CallSub::dataChanged()
0047 {
0048     setCaption(i18n("Call %1", dataString("sub")));
0049 }
0050 
0051 void CallSub::generateMicrobe(FlowCode *code)
0052 {
0053     code->addCode("call " + dataString("sub"));
0054     code->addCodeBranch(outputPart("stdoutput"));
0055 }