File indexing completed on 2024-12-01 11:20:47
0001 /*************************************************************************** 0002 * Copyright (C) 2003-2005 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 #ifndef FLOWCODEDOCUMENT_H 0012 #define FLOWCODEDOCUMENT_H 0013 0014 #include "flowicndocument.h" 0015 0016 #include <QPointer> 0017 0018 class KTechlab; 0019 class FlowCode; 0020 class MicroInfo; 0021 class PicItem; 0022 class FlowPart; 0023 class MicroSettings; 0024 class TextDocument; 0025 class QString; 0026 0027 typedef QList<FlowPart *> FlowPartList; 0028 typedef QMap<QString, int> StringIntMap; 0029 0030 /** 0031 @short View for editing FlowCode 0032 @author David Saxton 0033 */ 0034 class FlowCodeDocument : public FlowICNDocument 0035 { 0036 Q_OBJECT 0037 public: 0038 FlowCodeDocument(const QString &caption); 0039 ~FlowCodeDocument() override; 0040 0041 View *createView(ViewContainer *viewContainer, uint viewAreaId) override; 0042 0043 /** 0044 * Returns a pointer used for the MicroSettings in this FlowCode document 0045 */ 0046 MicroSettings *microSettings() const 0047 { 0048 return m_microSettings; 0049 } 0050 /** 0051 * Sets the type of PIC to be used. FlowCodeDocument se 0052 virtual void convertToMicrobe();ts the internal MicroInfo pointer to that 0053 * returned by MicroLibrary for the given id. The pic type must be set before anything useful 0054 * (such as compilage) can be done. 0055 */ 0056 void setPicType(const QString &id); 0057 0058 enum ConvertToTarget { MicrobeOutput, AssemblyOutput, HexOutput, PICOutput }; 0059 0060 // TODO clean up this preprocessor jewel :P 0061 #define protected public 0062 signals: 0063 void picTypeChanged(); 0064 #undef protected 0065 0066 signals: 0067 void pinMappingsChangedFlowCode(); 0068 0069 public slots: 0070 /** 0071 * @param target as ConvertToTarget 0072 */ 0073 void slotConvertTo(QAction *action); 0074 void convertToMicrobe() override; 0075 void convertToAssembly() override; 0076 void convertToHex() override; 0077 void convertToPIC() override; 0078 /** 0079 * Called when a variable name has changed (from an entry box) 0080 */ 0081 void varNameChanged(const QString &newValue, const QString &oldValue); 0082 0083 protected: 0084 bool isValidItem(Item *item) override; 0085 bool isValidItem(const QString &itemId) override; 0086 0087 private slots: 0088 void setLastTextOutputTarget(TextDocument *target); 0089 0090 private: 0091 QPointer<TextDocument> m_pLastTextOutputTarget; 0092 MicroInfo *m_microInfo; // Stores information about the PIC 0093 MicroSettings *m_microSettings; // Stores initial settings of the PIC 0094 PicItem *m_picItem; // Allows the user to change the PIC settings 0095 StringIntMap m_varNames; 0096 }; 0097 0098 #endif