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

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 "inputbutton.h"
0012 #include "flowcode.h"
0013 #include "libraryitem.h"
0014 #include "icndocument.h"
0015 
0016 #include <KLocalizedString>
0017 
0018 Item *InputButton::construct(ItemDocument *itemDocument, bool newItem, const char *id)
0019 {
0020     return new InputButton(static_cast<ICNDocument *>(itemDocument), newItem, id);
0021 }
0022 
0023 LibraryItem *InputButton::libraryItem()
0024 {
0025     return new LibraryItem(QStringList(QString("flow/inputbutton")), i18n("InputButton"), i18n("Functions"), "ppinputbutton.png", LibraryItem::lit_flowpart, InputButton::construct);
0026 }
0027 
0028 InputButton::InputButton(ICNDocument *icnDocument, bool newItem, const char *id)
0029     : FlowPart(icnDocument, newItem, id ? id : "inputbutton")
0030 {
0031     m_name = i18n("InputButton");
0032     initProcessSymbol();
0033     createStdInput();
0034     createStdOutput();
0035 
0036     createProperty("0-trigger", Variant::Type::Select);
0037     property("0-trigger")->setCaption(i18n("Trigger"));
0038     property("0-trigger")->setAllowed((QStringList("rising") << "falling"));
0039     property("0-trigger")->setValue("rising");
0040 
0041     createProperty("1-pin", Variant::Type::Pin);
0042     property("1-pin")->setCaption(i18n("Pin"));
0043     property("1-pin")->setValue("RA0");
0044 }
0045 
0046 InputButton::~InputButton()
0047 {
0048 }
0049 
0050 void InputButton::dataChanged()
0051 {
0052     setCaption(i18n("Continue on %1 %2", dataString("0-trigger"), dataString("1-pin")));
0053 }
0054 
0055 void InputButton::generateMicrobe(FlowCode *code)
0056 {
0057     code->addCodeBranch(outputPart("stdoutput"));
0058 }