1 /*************************************************************************** 2 * Copyright (C) 2005 by David Saxton * 3 * david@bluehaze.org * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 ***************************************************************************/ 10 11 #ifndef DOCUMENTIFACE_H 12 #define DOCUMENTIFACE_H 13 14 #include "config.h" 15 16 //#include <dcopobject.h> 17 //#include <dcopref.h> 18 19 #include "dcop_stub.h" 20 21 #include <QStringList> 22 23 class CircuitDocument; 24 class Document; 25 class FlowCodeDocument; 26 class ICNDocument; 27 class ItemDocument; 28 class MechanicsDocument; 29 class TextDocument; 30 class View; 31 32 /** 33 @author David Saxton 34 */ 35 class DocumentIface : public DCOPObject // TODO port to dbus 36 { 37 K_DCOP // TODO port to dbus 38 39 public: 40 DocumentIface( Document * document ); 41 virtual ~DocumentIface(); 42 43 k_dcop: // TODO port to dbus 44 QString caption() const; 45 DCOPRef activeView(); 46 uint numberOfViews(); 47 // View *createView( ViewContainer *viewContainer, uint viewAreaId, const char *name = nullptr ); 48 QString url(); 49 bool openURL( const QString & url ); 50 bool isModified(); 51 bool isUndoAvailable(); 52 bool isRedoAvailable(); 53 void save(); 54 void saveAs(); 55 bool close(); 56 void print(); 57 void cut(); 58 void copy(); 59 void paste(); 60 void undo(); 61 void redo(); 62 void selectAll(); 63 64 protected: 65 DCOPRef viewToRef( View * view ); 66 67 Document * m_pDocument; 68 }; 69 70 class TextDocumentIface : public DocumentIface 71 { 72 // K_DCOP TODO port to dbus 73 74 public: 75 TextDocumentIface( TextDocument * document ); 76 77 //k_dcop: TODO port to dbus 78 void formatAssembly(); 79 void convertToMicrobe(); 80 void convertToHex(); 81 void convertToPIC(); 82 void convertToAssembly(); 83 void clearBookmarks(); 84 bool isDebugging(); 85 void debugRun(); 86 void debugInterrupt(); 87 void debugStop(); 88 void debugStep(); 89 void debugStepOver(); 90 void debugStepOut(); 91 92 protected: 93 TextDocument * m_pTextDocument; 94 }; 95 96 class ItemDocumentIface : public DocumentIface 97 { 98 // K_DCOP TODO port to dbus 99 100 public: 101 ItemDocumentIface( ItemDocument * document ); 102 103 // k_dcop: TODO port to dbus 104 QStringList validItemIDs(); 105 /** 106 * Create an item with the given id (e.g. "ec/resistor") at the given 107 * position. 108 * @return name of item (assigned to it by KTechlab) 109 */ 110 QString addItem( const QString & id, int x, int y ); 111 void selectItem( const QString & id ); 112 void unselectItem( const QString & id ); 113 void clearHistory(); 114 void unselectAll(); 115 void alignHorizontally(); 116 void alignVertically(); 117 void distributeHorizontally(); 118 void distributeVertically(); 119 void deleteSelection(); 120 121 protected: 122 ItemDocument * m_pItemDocument; 123 }; 124 125 class MechanicsDocumentIface : public ItemDocumentIface 126 { 127 // K_DCOP TODO port to dbus 128 129 public: 130 MechanicsDocumentIface( MechanicsDocument * document ); 131 132 protected: 133 MechanicsDocument * m_pMechanicsDocument; 134 }; 135 136 class ICNDocumentIface : public ItemDocumentIface 137 { 138 // K_DCOP TODO port to dbus 139 140 public: 141 ICNDocumentIface( ICNDocument * document ); 142 143 // k_dcop: TODO port to dbus 144 void exportToImage(); 145 QStringList nodeIDs( const QString & id ); 146 /** 147 * Makes a connection from node1 on item1 to node2 on item2 148 */ 149 QString makeConnection( const QString & item1, const QString & node1, const QString & item2, const QString & node2 ); 150 void selectConnector( const QString & id ); 151 void unselectConnector( const QString & id ); 152 153 protected: 154 ICNDocument * m_pICNDocument; 155 }; 156 157 // FIXME: move to separate file and put in same path as circuitdocument.* 158 class CircuitDocumentIface : public ICNDocumentIface 159 { 160 // K_DCOP TODO port to dbus 161 162 public: 163 CircuitDocumentIface( CircuitDocument * document ); 164 165 //k_dcop: TODO port to dbus 166 void setOrientation0(); 167 void setOrientation90(); 168 void setOrientation180(); 169 void setOrientation270(); 170 void rotateCounterClockwise(); 171 void rotateClockwise(); 172 void flipHorizontally(); 173 void flipVertically(); 174 void displayEquations(); 175 void createSubcircuit(); 176 177 protected: 178 CircuitDocument * m_pCircuitDocument; 179 }; 180 181 class FlowCodeDocumentIface : public ICNDocumentIface 182 { 183 // K_DCOP TODO port to dbus 184 185 public: 186 FlowCodeDocumentIface( FlowCodeDocument * document ); 187 void convertToMicrobe(); 188 void convertToHex(); 189 void convertToPIC(); 190 void convertToAssembly(); 191 192 // k_dcop: TODO port to dbus 193 void setPicType( const QString & id ); 194 195 protected: 196 FlowCodeDocument * m_pFlowCodeDocument; 197 }; 198 199 #endif 200