-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubSchedule.cpp
68 lines (54 loc) · 1.09 KB
/
SubSchedule.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "SubSchedule.h"
#include <QtDebug>
#define MAX_STAGE_NUMBER 10
SubSchedule::SubSchedule(QString name,QObject *parent)
: QObject(parent),
m_name(name)
{
}
SubSchedule::~SubSchedule()
{
qDebug() << "destory:" << m_name;
}
bool SubSchedule::addStage(Stage* stage)
{
if( m_stages.size() < MAX_STAGE_NUMBER ) {
m_stages.append(stage);
return true;
}
return false;
}
bool SubSchedule::removeStage(int index)
{
if( index < m_stages.size() ) {
Stage* stage = m_stages.takeAt(index);
delete stage;
stage = NULL;
return true;
}
return false;
}
bool SubSchedule::editStage(int index, Stage* stage)
{
if( index < m_stages.size() ) {
m_stages.replace(index, stage);
return true;
}
return false;
}
Stage* SubSchedule::selectStage(int index)
{
if( index < m_stages.size() ) {
return m_stages.at(index);
}
return new Stage();
}
void SubSchedule::clearStage()
{
foreach(Stage* stage, m_stages)
{
delete stage;
stage = NULL;
}
m_stages.clear();
}