]> Shamusworld >> Repos - architektonas/blob - src/base/rs_blocklist.h
fecaef09c0f367a8f146ae6750d8e4fe56fc331e
[architektonas] / src / base / rs_blocklist.h
1 #ifndef RS_BLOCKLIST_H
2 #define RS_BLOCKLIST_H
3
4 #include <QtCore>
5 #include "rs_block.h"
6 #include "rs_blocklistlistener.h"
7 #include "rs_entity.h"
8
9 /**
10  * List of blocks.
11  *
12  * @see RS_Block
13  *
14  * @author Andrew Mustun
15  */
16 class RS_BlockList
17 {
18         public:
19                 RS_BlockList(bool owner = false);
20                 virtual ~RS_BlockList();
21
22                 void clear();
23                 uint count();
24                 RS_Block * at(uint i);
25
26                 void activate(const QString & name);
27                 void activate(RS_Block * block);
28                 RS_Block * getActive();
29
30                 virtual bool add(RS_Block * block, bool notify = true);
31                 virtual void addNotification();
32                 virtual void remove(RS_Block * block);
33                 virtual bool rename(RS_Block * block, const QString & name);
34                 //virtual void editBlock(RS_Block* block, const RS_Block& source);
35                 RS_Block * find(const QString & name);
36                 QString newName(const QString & suggestion = "");
37                 void toggle(const QString & name);
38                 void toggle(RS_Block * block);
39                 void freezeAll(bool freeze);
40
41                 void addListener(RS_BlockListListener * listener);
42                 void removeListener(RS_BlockListListener * listener);
43
44                 void setModified(bool m);
45                 virtual bool isModified() const;
46
47                 friend std::ostream & operator<<(std::ostream & os, RS_BlockList & b);
48
49         private:
50                 //! Is the list owning the blocks?
51                 bool owner;
52                 //! Blocks in the graphic
53 //              Q3PtrList<RS_Block> blocks;
54                 QList<RS_Block *> blocks;
55                 //! List of registered BlockListListeners
56 //              Q3PtrList<RS_BlockListListener> blockListListeners;
57                 QList<RS_BlockListListener *> blockListListeners;
58                 //! Currently active block
59                 RS_Block * activeBlock;
60                 /** Flag set if the layer list was modified and not yet saved. */
61                 bool modified;
62 };
63
64 #endif