QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RAddObjectsOperation.h
Go to the documentation of this file.
1 
20 #ifndef RADDOBJECTSOPERATION_H
21 #define RADDOBJECTSOPERATION_H
22 
23 #include "operations_global.h"
24 
25 #include <QList>
26 #include <QSharedPointer>
27 
28 #include "RDocument.h"
29 #include "RExporter.h"
30 #include "ROperation.h"
31 #include "RTransaction.h"
32 #include "RVector.h"
33 
34 class RObject;
35 
43 public:
45  public:
46  // constructor to mark cycles:
48  : object(QSharedPointer<RObject>()),
49  useCurrentAttributes(false),
50  forceNew(false),
51  deleteIt(false) {}
52 
53  // constructor to delete object:
54  RModifiedObjects(QSharedPointer<RObject> object)
55  : object(object),
56  useCurrentAttributes(false),
57  forceNew(false),
58  deleteIt(true) {}
59 
60  // constructor to add object:
61  RModifiedObjects(QSharedPointer<RObject> object, bool useCurrentAttributes, bool forceNew)
62  : object(object),
63  useCurrentAttributes(useCurrentAttributes),
64  forceNew(forceNew),
65  deleteIt(false) {}
66 
67  QSharedPointer<RObject> object;
69  bool forceNew;
70  bool deleteIt;
71  };
72 
73 public:
74  RAddObjectsOperation(bool undoable = true);
75  RAddObjectsOperation(QList<QSharedPointer<RObject> >& list,
76  bool useCurrentAttributes = true, bool undoable = true);
78  }
79 
84  void replaceObject(const QSharedPointer<RObject>& object,
85  bool useCurrentAttributes = true);
86 
87  QSharedPointer<RObject> getObject(RObject::Id id);
88 
89  void endCycle();
90 
91  void addObject(const QSharedPointer<RObject>& object,
92  bool useCurrentAttributes = true, bool forceNew=false);
93 
94  void deleteObject(const QSharedPointer<RObject>& object);
95 
96  virtual RTransaction apply(RDocument& document, bool preview = false) const;
97 
98  int getPreviewCounter() const {
99  return previewCounter;
100  }
101 
102  void setLimitPreview(bool on) {
103  limitPreview = on;
104  }
105 
106 private:
107  QList<RModifiedObjects> addedObjects;
108  //QList<QPair<QSharedPointer<RObject>, bool> > addedObjects;
111 };
112 
113 
115 
116 #endif