]> Shamusworld >> Repos - architektonas/blob - src/base/clipboard.cpp
Fixed problem with MDI activation.
[architektonas] / src / base / clipboard.cpp
1 // clipboard.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  05/28/2010  Added this text. :-)
15 // JLH  09/09/2010  Removed implementation from header (where it DOESN'T
16 //                  belong) and moved it here (where it DOES)
17 //
18
19 #include "clipboard.h"
20
21 #include "block.h"
22 #include "layer.h"
23 #include "entity.h"
24
25 Clipboard * Clipboard::uniqueInstance = NULL;
26
27 void Clipboard::clear()
28 {
29         graphic.clear();
30         graphic.clearBlocks();
31         graphic.clearLayers();
32         graphic.clearVariables();
33 }
34
35 void Clipboard::addBlock(Block * b)
36 {
37         if (b)
38                 graphic.addBlock(b, false);
39 }
40
41 bool Clipboard::hasBlock(const QString & name)
42 {
43         return (graphic.findBlock(name) != NULL);
44 }
45
46 void Clipboard::addLayer(Layer * l)
47 {
48         if (l)
49                 graphic.addLayer(l);
50 }
51
52 bool Clipboard::hasLayer(const QString & name)
53 {
54         return (graphic.findLayer(name) != NULL);
55 }
56
57 void Clipboard::addEntity(Entity * e)
58 {
59         if (e)
60         {
61                 graphic.addEntity(e);
62                 e->reparent(&graphic);
63         }
64 }
65
66 /**
67  * Dumps the clipboard contents to stdout.
68  */
69 std::ostream & operator<<(std::ostream & os, Clipboard & cb)
70 {
71         os << "Clipboard: " << cb.graphic << "\n";
72         return os;
73 }
74
75 Clipboard::Clipboard()
76 {
77 }
78
79 /**
80  * @return Instance to the unique clipboard object.
81  */
82 /*static*/ Clipboard * Clipboard::instance()
83 {
84         if (uniqueInstance == NULL)
85                 uniqueInstance = new Clipboard();
86
87         return uniqueInstance;
88 }
89
90 int Clipboard::countBlocks()
91 {
92         return graphic.countBlocks();
93 }
94
95 Block * Clipboard::blockAt(int i)
96 {
97         return graphic.blockAt(i);
98 }
99
100 int Clipboard::countLayers()
101 {
102         return graphic.countLayers();
103 }
104
105 Layer * Clipboard::layerAt(int i)
106 {
107         return graphic.layerAt(i);
108 }
109
110 uint Clipboard::count()
111 {
112         return graphic.count();
113 }
114
115 Entity * Clipboard::entityAt(uint i)
116 {
117         return graphic.entityAt(i);
118 }
119
120 Entity * Clipboard::firstEntity()
121 {
122         return graphic.firstEntity();
123 }
124
125 Entity * Clipboard::nextEntity()
126 {
127         return graphic.nextEntity();
128 }
129
130 Drawing * Clipboard::getGraphic()
131 {
132         return &graphic;
133 }