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);
77  virtual ~RAddObjectsOperation();
78 
83  void replaceObject(const QSharedPointer<RObject>& object,
84  bool useCurrentAttributes = true);
85 
86  QSharedPointer<RObject> getObject(RObject::Id id);
87 
88  void endCycle();
89 
90  void addObject(const QSharedPointer<RObject>& object,
91  bool useCurrentAttributes = true, bool forceNew=false);
92 
93  void deleteObject(const QSharedPointer<RObject>& object);
94 
95  virtual RTransaction apply(RDocument& document, bool preview = false) const;
96 
97  int getPreviewCounter() const {
98  return previewCounter;
99  }
100 
101  void setLimitPreview(bool on) {
102  limitPreview = on;
103  }
104 
105 private:
106  QList<RModifiedObjects> addedObjects;
107  //QList<QPair<QSharedPointer<RObject>, bool> > addedObjects;
110 };
111 
112 
114 
115 #endif