File indexing completed on 2024-04-28 05:43:23

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