1
1
#include " FeedbackDialog.h"
2
2
3
- #include " Feedback.h"
4
3
#include " FeedbackTable.h"
4
+ #include " Region.h"
5
+ #include " RegionCollection.h"
5
6
#include " VisualizationContainer.h"
6
7
8
+ #include < QCompleter>
9
+ #include < QDialogButtonBox>
10
+ #include < QPushButton>
11
+ #include < QShortcut>
12
+ #include < QStandardItemModel>
13
+
7
14
// Constructor
8
15
FeedbackDialog::FeedbackDialog (QWidget* parent, VisualizationContainer* visualizationContainer)
9
16
: QDialog(parent), visualizationContainer(visualizationContainer) {
10
17
// Create the GUI from the Qt Designer file
11
18
setupUi (this );
12
19
20
+ buttonBox->button (QDialogButtonBox::Close)->setAutoDefault (false );
21
+
13
22
setWindowFlag (Qt::WindowContextHelpButtonHint, false );
14
23
24
+ // Search autocomplete
25
+ labelModel = new QStandardItemModel (this );
26
+ QCompleter* completer = new QCompleter (labelModel, this );
27
+ searchLineEdit->setCompleter (completer);
28
+
15
29
// Create table
16
30
table = new FeedbackTable (this );
17
31
table->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Expanding);
18
32
table->update (visualizationContainer->GetRegions ());
19
33
tableContainer->layout ()->addWidget (table);
20
34
21
- QObject::connect (table, &FeedbackTable::regionFeedback, this , &FeedbackDialog::on_regionFeedback);
35
+ QObject::connect (table, &FeedbackTable::regionComment, this , &FeedbackDialog::on_regionComment);
36
+ QObject::connect (table, &FeedbackTable::regionDone, this , &FeedbackDialog::on_regionDone);
37
+ QObject::connect (table, &FeedbackTable::regionVerified, this , &FeedbackDialog::on_regionVerified);
38
+ QObject::connect (table, &FeedbackTable::selectRegion, this , &FeedbackDialog::on_selectRegion);
22
39
QObject::connect (table, &FeedbackTable::highlightRegion, this , &FeedbackDialog::on_highlightRegion);
40
+ QObject::connect (table, &FeedbackTable::countChanged, this , &FeedbackDialog::on_countChanged);
41
+
42
+ // Shortcut
43
+ QShortcut* shortcut = new QShortcut (QKeySequence (Qt::ALT + Qt::Key_V), this );
44
+ QObject::connect (shortcut, &QShortcut::activated, this , &FeedbackDialog::on_verifiedShortcut);
23
45
24
46
updateRegions ();
25
47
}
@@ -29,19 +51,64 @@ FeedbackDialog::~FeedbackDialog() {
29
51
}
30
52
31
53
void FeedbackDialog::updateRegions () {
32
- table->update (visualizationContainer->GetRegions ());
54
+ RegionCollection* regions = visualizationContainer->GetRegions ();
55
+
56
+ // Update table
57
+ table->update (regions);
58
+
59
+ // Update autocomplete
60
+ labelModel->clear ();
61
+ for (RegionCollection::Iterator it = regions->Begin (); it != regions->End (); it++) {
62
+ Region* region = regions->Get (it);
63
+
64
+ QStandardItem* item = new QStandardItem (QString::number (region->GetLabel ()));
65
+
66
+ labelModel->appendRow (item);
67
+ }
33
68
}
34
69
35
- void FeedbackDialog::on_filterCheckBox_stateChanged (int state) {
36
- printf (" %d\n " , state);
70
+ void FeedbackDialog::updateRegion (Region* region) {
71
+ table->update (region);
72
+ }
73
+
74
+ void FeedbackDialog::selectRegionLabel (unsigned short label) {
75
+ table->selectRegionLabel (label);
76
+ }
77
+
78
+ void FeedbackDialog::on_searchLineEdit_editingFinished () {
79
+ unsigned short label = searchLineEdit->text ().toInt ();
37
80
81
+ visualizationContainer->SelectRegion (label);
82
+ }
83
+
84
+ void FeedbackDialog::on_filterCheckBox_stateChanged (int state) {
38
85
table->setFilter (state != 0 );
39
86
}
40
87
41
- void FeedbackDialog::on_regionFeedback (int label, Feedback::FeedbackType type, bool value) {
42
- visualizationContainer->SetRegionFeedback (label, type, value);
88
+ void FeedbackDialog::on_regionComment (int label, QString comment) {
89
+ visualizationContainer->SetRegionComment (label, comment.toStdString ());
90
+ }
91
+
92
+ void FeedbackDialog::on_regionDone (int label, bool done) {
93
+ visualizationContainer->SetRegionDone (label, done);
94
+ }
95
+
96
+ void FeedbackDialog::on_regionVerified (int label, bool verified) {
97
+ visualizationContainer->SetRegionVerified (label, verified);
98
+ }
99
+
100
+ void FeedbackDialog::on_selectRegion (int label) {
101
+ visualizationContainer->SelectRegion ((unsigned short )label);
43
102
}
44
103
45
104
void FeedbackDialog::on_highlightRegion (int label) {
46
105
visualizationContainer->HighlightRegion ((unsigned short )label);
106
+ }
107
+
108
+ void FeedbackDialog::on_countChanged (int count) {
109
+ countLabel->setText (" Count: " + QString::number (count));
110
+ }
111
+
112
+ void FeedbackDialog::on_verifiedShortcut () {
113
+ // printf("DLKJF");
47
114
}
0 commit comments