forked from twiniars/RESpecTa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editWidget.cpp
92 lines (74 loc) · 2.82 KB
/
editWidget.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "editWidget.h"
#include <QtGui>
EditWidget::EditWidget(RESpecTa *parent, Model * newmod )
: QStackedWidget(parent)
{
this->setMinimumWidth(230);
stateWidget = new StateWidget(this, newmod);
this->addWidget(stateWidget);//,tr("State"));
transWidget = new TransWidget(this, newmod);
this->addWidget(transWidget);//, tr("Transition"));
subtaskWidget = new SubtaskWidget(this, newmod);
this->addWidget(subtaskWidget);//, tr("Subtasks"));
this->addWidget(new QWidget());
connect(this, SIGNAL(currentChanged(int)), this, SLOT(refreshWidget(int)));
connect(subtaskWidget, SIGNAL(added(QString)), parent, SLOT(SubtaskAdded(QString)));
connect(subtaskWidget, SIGNAL(changed(QString,QString)), parent, SLOT(SubtaskChanged(QString, QString)));
connect(subtaskWidget, SIGNAL(removed(QString)), parent, SLOT(SubtaskRemoved(QString)));
connect(subtaskWidget, SIGNAL(reportError(QString)), this, SLOT(forwardError(QString)));
connect(subtaskWidget, SIGNAL(UncheckTasksAction()), parent, SLOT(HideSubtask()));
//connect (stateWidget, SIGNAL(InsertState(BaseState*)), parent,SLOT(InsertState(BaseState*)));
connect (stateWidget, SIGNAL(ReplaceState(BaseState * , BaseState * )), parent,SLOT(ReplaceState(BaseState * , BaseState * )));
connect (stateWidget, SIGNAL(reportError(QString)), this, SLOT(forwardError(QString)));
//connect (transWidget, SIGNAL(insertTransition(std::pair<QString,QString>)), parent,SLOT(insertTransition(std::pair<QString,QString>)));
connect (transWidget, SIGNAL(reportError(QString)), this, SLOT(forwardError(QString)));
connect(parent, SIGNAL(refreshWidgets()), this, SLOT(refreshAllWidgets()));
connect(parent, SIGNAL(SignalDeleted()), this, SLOT(SignalDeleted()));
this->setCurrentIndex(3);
}
void EditWidget::refreshAllWidgets()
{
stateWidget->refreshData();
transWidget->refreshData();
subtaskWidget->refreshData();
}
void EditWidget::SignalDeleted()
{
refreshWidget(this->currentIndex());
this->setCurrentIndex(3);
stateWidget->setOKButtonDisabled();
transWidget->setOKButtonDisabled();
}
void EditWidget::refreshWidget(int index)
{
switch(index)
{
case 0:
stateWidget->refreshData();
break;
case 1:
transWidget->refreshData();
break;
case 2:
subtaskWidget->refreshData();
default:
break;
}
}
void EditWidget::itemSelected(QGraphicsItem *item)
{
if (item->type()==BaseState::Type)
{
this->setCurrentWidget(stateWidget);
stateWidget->StateSelected(qgraphicsitem_cast<BaseState *>(item));
}
else if (item->type()==Transition::Type)
{
this->setCurrentWidget(transWidget);
transWidget->TransSelected(qgraphicsitem_cast<Transition *>(item));
}
}
void EditWidget::EditTasks()
{
setCurrentWidget(subtaskWidget);
}