File indexing completed on 2024-04-14 05:37:00

0001 /***************************************************************************
0002  *   Copyright (C) 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 DOCUMENTIFACE_H
0012 #define DOCUMENTIFACE_H
0013 
0014 #include "config.h"
0015 
0016 //#include <dcopobject.h>
0017 //#include <dcopref.h>
0018 
0019 #include "dcop_stub.h"
0020 
0021 #include <QStringList>
0022 
0023 class CircuitDocument;
0024 class Document;
0025 class FlowCodeDocument;
0026 class ICNDocument;
0027 class ItemDocument;
0028 class MechanicsDocument;
0029 class TextDocument;
0030 class View;
0031 
0032 /**
0033 @author David Saxton
0034 */
0035 class DocumentIface : public DCOPObject // TODO port to dbus
0036 {
0037     K_DCOP // TODO port to dbus
0038 
0039         public : DocumentIface(Document *document);
0040     virtual ~DocumentIface();
0041 
0042     k_dcop : // TODO port to dbus
0043              QString
0044              caption() const;
0045     DCOPRef activeView();
0046     uint numberOfViews();
0047     //      View *createView( ViewContainer *viewContainer, uint viewAreaId );
0048     QString url();
0049     bool openURL(const QString &url);
0050     bool isModified();
0051     bool isUndoAvailable();
0052     bool isRedoAvailable();
0053     void save();
0054     void saveAs();
0055     bool close();
0056     void print();
0057     void cut();
0058     void copy();
0059     void paste();
0060     void undo();
0061     void redo();
0062     void selectAll();
0063 
0064 protected:
0065     DCOPRef viewToRef(View *view);
0066 
0067     Document *m_pDocument;
0068 };
0069 
0070 class TextDocumentIface : public DocumentIface
0071 {
0072     // K_DCOP TODO port to dbus
0073 
0074 public:
0075     TextDocumentIface(TextDocument *document);
0076 
0077     // k_dcop: TODO port to dbus
0078     void formatAssembly();
0079     void convertToMicrobe();
0080     void convertToHex();
0081     void convertToPIC();
0082     void convertToAssembly();
0083     void clearBookmarks();
0084     bool isDebugging();
0085     void debugRun();
0086     void debugInterrupt();
0087     void debugStop();
0088     void debugStep();
0089     void debugStepOver();
0090     void debugStepOut();
0091 
0092 protected:
0093     TextDocument *m_pTextDocument;
0094 };
0095 
0096 class ItemDocumentIface : public DocumentIface
0097 {
0098     // K_DCOP TODO port to dbus
0099 
0100 public:
0101     ItemDocumentIface(ItemDocument *document);
0102 
0103     // k_dcop: TODO port to dbus
0104     QStringList validItemIDs();
0105     /**
0106      * Create an item with the given id (e.g. "ec/resistor") at the given
0107      * position.
0108      * @return name of item (assigned to it by KTechlab)
0109      */
0110     QString addItem(const QString &id, int x, int y);
0111     void selectItem(const QString &id);
0112     void unselectItem(const QString &id);
0113     void clearHistory();
0114     void unselectAll();
0115     void alignHorizontally();
0116     void alignVertically();
0117     void distributeHorizontally();
0118     void distributeVertically();
0119     void deleteSelection();
0120 
0121 protected:
0122     ItemDocument *m_pItemDocument;
0123 };
0124 
0125 class MechanicsDocumentIface : public ItemDocumentIface
0126 {
0127     // K_DCOP TODO port to dbus
0128 
0129 public:
0130     MechanicsDocumentIface(MechanicsDocument *document);
0131 
0132 protected:
0133     MechanicsDocument *m_pMechanicsDocument;
0134 };
0135 
0136 class ICNDocumentIface : public ItemDocumentIface
0137 {
0138     // K_DCOP TODO port to dbus
0139 
0140 public:
0141     ICNDocumentIface(ICNDocument *document);
0142 
0143     // k_dcop:  TODO port to dbus
0144     void exportToImage();
0145     QStringList nodeIDs(const QString &id);
0146     /**
0147      * Makes a connection from node1 on item1 to node2 on item2
0148      */
0149     QString makeConnection(const QString &item1, const QString &node1, const QString &item2, const QString &node2);
0150     void selectConnector(const QString &id);
0151     void unselectConnector(const QString &id);
0152 
0153 protected:
0154     ICNDocument *m_pICNDocument;
0155 };
0156 
0157 // FIXME: move to separate file and put in same path as circuitdocument.*
0158 class CircuitDocumentIface : public ICNDocumentIface
0159 {
0160     // K_DCOP TODO port to dbus
0161 
0162 public:
0163     CircuitDocumentIface(CircuitDocument *document);
0164 
0165     // k_dcop: TODO port to dbus
0166     void setOrientation0();
0167     void setOrientation90();
0168     void setOrientation180();
0169     void setOrientation270();
0170     void rotateCounterClockwise();
0171     void rotateClockwise();
0172     void flipHorizontally();
0173     void flipVertically();
0174     void displayEquations();
0175     void createSubcircuit();
0176 
0177 protected:
0178     CircuitDocument *m_pCircuitDocument;
0179 };
0180 
0181 class FlowCodeDocumentIface : public ICNDocumentIface
0182 {
0183     // K_DCOP TODO port to dbus
0184 
0185 public:
0186     FlowCodeDocumentIface(FlowCodeDocument *document);
0187     void convertToMicrobe();
0188     void convertToHex();
0189     void convertToPIC();
0190     void convertToAssembly();
0191 
0192     // k_dcop: TODO port to dbus
0193     void setPicType(const QString &id);
0194 
0195 protected:
0196     FlowCodeDocument *m_pFlowCodeDocument;
0197 };
0198 
0199 #endif