File indexing completed on 2024-04-14 05:36:43

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