-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockmanager.cpp
42 lines (37 loc) · 963 Bytes
/
blockmanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "blockmanager.h"
BlockManager::BlockManager(BlockViewer *_blockViewer, QWidget *parent)
: QObject(parent), blockViewer(_blockViewer)
{
}
void BlockManager::addBlock(BlockCreator *creator)
{
if(creator == NULL){
qDebug() << "addBlock(BlockManager): creator == NULL";
return;
}
Block *block = creator->create(blockViewer);
sequence.append(block);
blockViewer->addBlock(block);
connect(block, SIGNAL(closeMeManager(Block*)), this, SLOT(onBlockClose(Block*)));
}
void BlockManager::executeBlockList()
{
QMutableListIterator<Block*> it(sequence);
while(it.hasNext()){
it.next();
it.value()->doAlgorithm();
}
}
void BlockManager::onBlockClose(Block *block)
{
QMutableListIterator<Block*> it(sequence);
while(it.hasNext()){
it.next();
if(it.value() == block){
it.remove();
break;
}
}
block->close();
delete block;
}