-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsequenceeditor.cpp
More file actions
102 lines (82 loc) · 3.32 KB
/
sequenceeditor.cpp
File metadata and controls
102 lines (82 loc) · 3.32 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
#include "sequenceeditor.h"
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QDebug>
SequenceEditor::SequenceEditor(QWidget *parent) :
QWidget(parent)
{
QLabel* label1 = new QLabel(tr("your pose list"));
QPushButton* loadPoseListButton = new QPushButton(tr("load list from pose edtior"));
poseListFromEditor = new QListWidget();
QPushButton* addButton = new QPushButton(tr("add ->"));
poseListToSend = new QListWidget();
QPushButton* testButton = new QPushButton(tr("test"));
QPushButton* outputButton = new QPushButton(tr("output as file"));
outputButton->setEnabled(false);
QPushButton* removeButton = new QPushButton(tr("<- remove"));
QVBoxLayout* left = new QVBoxLayout();
QVBoxLayout* right = new QVBoxLayout();
QHBoxLayout* entire = new QHBoxLayout();
left->addWidget(label1);
left->addWidget(loadPoseListButton);
left->addWidget(poseListFromEditor);
left->addWidget(addButton);
right->addWidget(poseListToSend);
right->addWidget(testButton);
right->addWidget(outputButton);
right->addWidget(removeButton);
entire->addLayout(left);
entire->addWidget(new QLabel(tr(" "))); // spacer is better
entire->addLayout(right);
this->setLayout(entire);
connect(loadPoseListButton, SIGNAL(clicked()), this, SIGNAL(requestPoseList()));
connect(addButton, SIGNAL(clicked()), this, SLOT(moveItemToSendList()));
connect(removeButton, SIGNAL(clicked()), this, SLOT(removeItemFromSendList()));
connect(testButton, SIGNAL(clicked()), this, SLOT(testSequence()));
}
Q_DECLARE_METATYPE(Pose)
void SequenceEditor::copyPoseList(QListWidget *list){
// poseListFromEditor = list;
// qDebug() << "seqedit::copyPoseList";
poseListFromEditor->clear();
poseListToSend->clear();
for(int i=0; i<list->count(); i++){
// item->clone() is ok?
poseListFromEditor->addItem(list->item(i)->text());
poseListFromEditor->item(i)->setData(Qt::UserRole, list->item(i)->data(Qt::UserRole));
}
}
void SequenceEditor::moveItemToSendList(){
// qDebug() << poseListFromEditor->currentRow();
if(poseListFromEditor->currentRow() == -1){
//not selected any item
return;
}
// Pose temp = poseListFromEditor->currentItem()->data(Qt::UserRole).value<Pose>();
// double tempD = temp.getTarget(3);
// qDebug() << tempD;
QListWidgetItem* added = new QListWidgetItem(poseListFromEditor->currentItem()->text());
added->setData(Qt::UserRole, poseListFromEditor->currentItem()->data(Qt::UserRole));
poseListToSend->addItem(added);
// select next item
if(poseListFromEditor->currentRow() != poseListFromEditor->count()){
poseListFromEditor->setCurrentRow(poseListFromEditor->currentRow()+1);
}
// Pose temp = poseListToSend->item(poseListToSend->count()-1)->data(Qt::UserRole).value<Pose>();
// qDebug() << temp.getTarget(1);
}
void SequenceEditor::removeItemFromSendList(){
if(poseListToSend->currentRow() == -1){
return;
}
poseListToSend->takeItem(poseListToSend->currentRow());
}
void SequenceEditor::testSequence(){
Sequence tempSeq;
for(int i=0; i<poseListToSend->count(); i++){
tempSeq.addPose(poseListToSend->item(i)->data(Qt::UserRole).value<Pose>());
}
emit newSequenceMade(tempSeq);
}