Warning, file /sdk/ktechlab/src/documentiface.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 #include "documentiface.h"
0012 #include "circuitdocument.h"
0013 #include "cnitem.h"
0014 #include "connector.h"
0015 #include "flowcodedocument.h"
0016 #include "itemlibrary.h"
0017 #include "libraryitem.h"
0018 #include "mechanicsdocument.h"
0019 #include "textdocument.h"
0020 #include "view.h"
0021 
0022 // BEGIN class DocumentIface
0023 DocumentIface::DocumentIface(Document *document)
0024     : DCOPObject(/* TODO "Document" */)
0025 {
0026     m_pDocument = document;
0027 }
0028 
0029 DocumentIface::~DocumentIface()
0030 {
0031 }
0032 
0033 void DocumentIface::selectAll()
0034 {
0035     m_pDocument->selectAll();
0036 }
0037 
0038 void DocumentIface::redo()
0039 {
0040     m_pDocument->redo();
0041 }
0042 
0043 void DocumentIface::undo()
0044 {
0045     m_pDocument->undo();
0046 }
0047 
0048 void DocumentIface::paste()
0049 {
0050     m_pDocument->paste();
0051 }
0052 
0053 void DocumentIface::copy()
0054 {
0055     m_pDocument->copy();
0056 }
0057 
0058 void DocumentIface::cut()
0059 {
0060     m_pDocument->cut();
0061 }
0062 
0063 void DocumentIface::print()
0064 {
0065     m_pDocument->print();
0066 }
0067 
0068 bool DocumentIface::close()
0069 {
0070     return m_pDocument->fileClose();
0071 }
0072 
0073 void DocumentIface::saveAs()
0074 {
0075     m_pDocument->fileSaveAs();
0076 }
0077 
0078 void DocumentIface::save()
0079 {
0080     m_pDocument->fileSave();
0081 }
0082 
0083 bool DocumentIface::isRedoAvailable()
0084 {
0085     return m_pDocument->isRedoAvailable();
0086 }
0087 
0088 bool DocumentIface::isUndoAvailable()
0089 {
0090     return m_pDocument->isUndoAvailable();
0091 }
0092 
0093 bool DocumentIface::isModified()
0094 {
0095     return m_pDocument->isModified();
0096 }
0097 
0098 bool DocumentIface::openURL(const QString &url)
0099 {
0100     return m_pDocument->openURL(QUrl(url));
0101 }
0102 
0103 QString DocumentIface::url()
0104 {
0105     return m_pDocument->url().url();
0106 }
0107 
0108 uint DocumentIface::numberOfViews()
0109 {
0110     return m_pDocument->numberOfViews();
0111 }
0112 
0113 DCOPRef DocumentIface::activeView()
0114 {
0115     return viewToRef(m_pDocument->activeView());
0116 }
0117 
0118 QString DocumentIface::caption() const
0119 {
0120     return m_pDocument->caption();
0121 }
0122 
0123 DCOPRef DocumentIface::viewToRef(View * /*view*/)
0124 {
0125     return DCOPRef(); //  view->dcopObject() ); TODO
0126 }
0127 // END class DocumentIface
0128 
0129 // BEGIN class FlowCodeDocumentIface
0130 FlowCodeDocumentIface::FlowCodeDocumentIface(FlowCodeDocument *document)
0131     : ICNDocumentIface(document)
0132 {
0133     m_pFlowCodeDocument = document;
0134 }
0135 
0136 void FlowCodeDocumentIface::setPicType(const QString &id)
0137 {
0138     m_pFlowCodeDocument->setPicType(id);
0139 }
0140 
0141 void FlowCodeDocumentIface::convertToMicrobe()
0142 {
0143     m_pFlowCodeDocument->convertToMicrobe();
0144 }
0145 
0146 void FlowCodeDocumentIface::convertToHex()
0147 {
0148     m_pFlowCodeDocument->convertToHex();
0149 }
0150 
0151 void FlowCodeDocumentIface::convertToPIC()
0152 {
0153     m_pFlowCodeDocument->convertToPIC();
0154 }
0155 
0156 void FlowCodeDocumentIface::convertToAssembly()
0157 {
0158     m_pFlowCodeDocument->convertToAssembly();
0159 }
0160 // END class FlowCodeDocumentIface
0161 
0162 // BEGIN class CircuitDocumentIface
0163 CircuitDocumentIface::CircuitDocumentIface(CircuitDocument *document)
0164     : ICNDocumentIface(document)
0165 {
0166     m_pCircuitDocument = document;
0167 }
0168 
0169 void CircuitDocumentIface::setOrientation0()
0170 {
0171     m_pCircuitDocument->setOrientation0();
0172 }
0173 
0174 void CircuitDocumentIface::setOrientation90()
0175 {
0176     m_pCircuitDocument->setOrientation90();
0177 }
0178 
0179 void CircuitDocumentIface::setOrientation180()
0180 {
0181     m_pCircuitDocument->setOrientation180();
0182 }
0183 
0184 void CircuitDocumentIface::setOrientation270()
0185 {
0186     m_pCircuitDocument->setOrientation270();
0187 }
0188 
0189 void CircuitDocumentIface::rotateCounterClockwise()
0190 {
0191     m_pCircuitDocument->rotateCounterClockwise();
0192 }
0193 
0194 void CircuitDocumentIface::rotateClockwise()
0195 {
0196     m_pCircuitDocument->rotateClockwise();
0197 }
0198 
0199 void CircuitDocumentIface::flipHorizontally()
0200 {
0201     m_pCircuitDocument->flipHorizontally();
0202 }
0203 
0204 void CircuitDocumentIface::flipVertically()
0205 {
0206     m_pCircuitDocument->flipVertically();
0207 }
0208 
0209 void CircuitDocumentIface::displayEquations()
0210 {
0211     m_pCircuitDocument->displayEquations();
0212 }
0213 
0214 void CircuitDocumentIface::createSubcircuit()
0215 {
0216     m_pCircuitDocument->createSubcircuit();
0217 }
0218 // END class CircuitDocumentIface
0219 
0220 // BEGIN class ICNDocumentIface
0221 ICNDocumentIface::ICNDocumentIface(ICNDocument *document)
0222     : ItemDocumentIface(document)
0223 {
0224     m_pICNDocument = document;
0225 }
0226 
0227 void ICNDocumentIface::exportToImage()
0228 {
0229     m_pICNDocument->exportToImage();
0230 }
0231 
0232 QStringList ICNDocumentIface::nodeIDs(const QString &id)
0233 {
0234     CNItem *item = m_pICNDocument->cnItemWithID(id);
0235 
0236     QStringList ids;
0237     if (!item)
0238         return ids;
0239 
0240     const NodeInfoMap nm = item->nodeMap();
0241     const NodeInfoMap::const_iterator end = nm.end();
0242     for (NodeInfoMap::const_iterator it = nm.begin(); it != end; ++it)
0243         ids.append(it.key().toLatin1());
0244 
0245     return ids;
0246 }
0247 
0248 QString ICNDocumentIface::makeConnection(const QString &item1, const QString &node1, const QString &item2, const QString &node2)
0249 {
0250     CNItem *i1 = m_pICNDocument->cnItemWithID(item1);
0251     CNItem *i2 = m_pICNDocument->cnItemWithID(item2);
0252 
0253     if (!i1 || !i2)
0254         return QString();
0255 
0256     Node *n1 = m_pICNDocument->nodeWithID(i1->nodeId(node1));
0257     Node *n2 = m_pICNDocument->nodeWithID(i2->nodeId(node2));
0258 
0259     if (!n1 || !n2)
0260         return QString();
0261 
0262     Connector *connector = m_pICNDocument->createConnector(n1, n2);
0263     return connector ? connector->id() : QString();
0264 }
0265 
0266 void ICNDocumentIface::selectConnector(const QString &id)
0267 {
0268     m_pICNDocument->select(m_pICNDocument->connectorWithID(id));
0269 }
0270 
0271 void ICNDocumentIface::unselectConnector(const QString &id)
0272 {
0273     m_pItemDocument->unselect(m_pICNDocument->connectorWithID(id));
0274 }
0275 // END class ICNDocumentIface
0276 
0277 // BEGIN class ItemDocumentIface
0278 ItemDocumentIface::ItemDocumentIface(ItemDocument *document)
0279     : DocumentIface(document)
0280 {
0281     m_pItemDocument = document;
0282 }
0283 
0284 QStringList ItemDocumentIface::validItemIDs()
0285 {
0286     QStringList validIDs;
0287 
0288     LibraryItemList *allItems = itemLibrary()->items();
0289     const LibraryItemList::iterator end = allItems->end();
0290     for (LibraryItemList::iterator it = allItems->begin(); it != end; ++it) {
0291         QString id = (*it)->activeID();
0292         if (m_pItemDocument->isValidItem(id))
0293             validIDs << id.toUtf8();
0294     }
0295     return validIDs;
0296 }
0297 
0298 QString ItemDocumentIface::addItem(const QString &id, int x, int y)
0299 {
0300     Item *item = m_pItemDocument->addItem(id, QPoint(x, y), true);
0301     return item ? item->id() : QString();
0302 }
0303 
0304 void ItemDocumentIface::selectItem(const QString &id)
0305 {
0306     m_pItemDocument->select(m_pItemDocument->itemWithID(id));
0307 }
0308 
0309 void ItemDocumentIface::unselectItem(const QString &id)
0310 {
0311     m_pItemDocument->unselect(m_pItemDocument->itemWithID(id));
0312 }
0313 
0314 void ItemDocumentIface::deleteSelection()
0315 {
0316     m_pItemDocument->deleteSelection();
0317 }
0318 
0319 void ItemDocumentIface::clearHistory()
0320 {
0321     m_pItemDocument->clearHistory();
0322 }
0323 
0324 void ItemDocumentIface::unselectAll()
0325 {
0326     m_pItemDocument->unselectAll();
0327 }
0328 
0329 void ItemDocumentIface::alignHorizontally()
0330 {
0331     m_pItemDocument->alignHorizontally();
0332 }
0333 
0334 void ItemDocumentIface::alignVertically()
0335 {
0336     m_pItemDocument->alignVertically();
0337 }
0338 
0339 void ItemDocumentIface::distributeHorizontally()
0340 {
0341     m_pItemDocument->distributeHorizontally();
0342 }
0343 
0344 void ItemDocumentIface::distributeVertically()
0345 {
0346     m_pItemDocument->distributeVertically();
0347 }
0348 // END class ItemDocumentIface
0349 
0350 // BEGIN class TextDocumentIface
0351 TextDocumentIface::TextDocumentIface(TextDocument *document)
0352     : DocumentIface(document)
0353 {
0354     m_pTextDocument = document;
0355 }
0356 
0357 void TextDocumentIface::debugStepOver()
0358 {
0359     m_pTextDocument->debugStepOver();
0360 }
0361 
0362 void TextDocumentIface::debugStepOut()
0363 {
0364     m_pTextDocument->debugStepOut();
0365 }
0366 
0367 void TextDocumentIface::debugStep()
0368 {
0369     m_pTextDocument->debugStep();
0370 }
0371 
0372 void TextDocumentIface::debugStop()
0373 {
0374     m_pTextDocument->debugStop();
0375 }
0376 
0377 void TextDocumentIface::debugInterrupt()
0378 {
0379     m_pTextDocument->debugInterrupt();
0380 }
0381 
0382 void TextDocumentIface::debugRun()
0383 {
0384     m_pTextDocument->debugRun();
0385 }
0386 
0387 bool TextDocumentIface::isDebugging()
0388 {
0389 #ifndef NO_GPSIM
0390     return m_pTextDocument->debuggerIsRunning();
0391 #else
0392     return false;
0393 #endif
0394 }
0395 
0396 void TextDocumentIface::clearBookmarks()
0397 {
0398     m_pTextDocument->clearBookmarks();
0399 }
0400 
0401 void TextDocumentIface::convertToAssembly()
0402 {
0403     m_pTextDocument->convertToAssembly();
0404 }
0405 
0406 void TextDocumentIface::convertToPIC()
0407 {
0408     m_pTextDocument->convertToPIC();
0409 }
0410 
0411 void TextDocumentIface::convertToHex()
0412 {
0413     m_pTextDocument->convertToHex();
0414 }
0415 
0416 void TextDocumentIface::convertToMicrobe()
0417 {
0418     m_pTextDocument->convertToMicrobe();
0419 }
0420 
0421 void TextDocumentIface::formatAssembly()
0422 {
0423     m_pTextDocument->formatAssembly();
0424 }
0425 // END class TextDocumentIface
0426 
0427 // BEGIN class MechanicsDocumentIface
0428 MechanicsDocumentIface::MechanicsDocumentIface(MechanicsDocument *document)
0429     : ItemDocumentIface(document)
0430 {
0431     m_pMechanicsDocument = document;
0432 }
0433 // END class MechanicsDocumentIface