Browse Source

Hide connection editor when switching tabs

Marcus Huderle 6 years ago
parent
commit
1e8d1d9497
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      editor.cpp

+ 19
- 1
editor.cpp View File

38
 void Editor::setEditingMap() {
38
 void Editor::setEditingMap() {
39
     current_view = map_item;
39
     current_view = map_item;
40
     if (map_item) {
40
     if (map_item) {
41
+        displayMapConnections();
41
         map_item->draw();
42
         map_item->draw();
42
         map_item->setVisible(true);
43
         map_item->setVisible(true);
43
         map_item->setEnabled(true);
44
         map_item->setEnabled(true);
49
     if (objects_group) {
50
     if (objects_group) {
50
         objects_group->setVisible(false);
51
         objects_group->setVisible(false);
51
     }
52
     }
53
+    if (connection_item) {
54
+        connection_item->setVisible(false);
55
+        connection_item->setEnabled(false);
56
+    }
52
 }
57
 }
53
 
58
 
54
 void Editor::setEditingCollision() {
59
 void Editor::setEditingCollision() {
63
     if (objects_group) {
68
     if (objects_group) {
64
         objects_group->setVisible(false);
69
         objects_group->setVisible(false);
65
     }
70
     }
71
+    if (connection_item) {
72
+        connection_item->setVisible(false);
73
+        connection_item->setEnabled(false);
74
+    }
66
 }
75
 }
67
 
76
 
68
 void Editor::setEditingObjects() {
77
 void Editor::setEditingObjects() {
78
     if (collision_item) {
87
     if (collision_item) {
79
         collision_item->setVisible(false);
88
         collision_item->setVisible(false);
80
     }
89
     }
90
+    if (connection_item) {
91
+        connection_item->setVisible(false);
92
+        connection_item->setEnabled(false);
93
+    }
81
 }
94
 }
82
 
95
 
83
 void Editor::setEditingConnections(QString direction) {
96
 void Editor::setEditingConnections(QString direction) {
85
     if (map_item) {
98
     if (map_item) {
86
         map_item->draw();
99
         map_item->draw();
87
         map_item->setVisible(true);
100
         map_item->setVisible(true);
88
-        map_item->setEnabled(true);
101
+        map_item->setEnabled(false);
89
         ui->comboBox_ConnectedMap->blockSignals(true);
102
         ui->comboBox_ConnectedMap->blockSignals(true);
90
         ui->comboBox_ConnectedMap->clear();
103
         ui->comboBox_ConnectedMap->clear();
91
         ui->comboBox_ConnectedMap->addItems(*project->mapNames);
104
         ui->comboBox_ConnectedMap->addItems(*project->mapNames);
304
 }
317
 }
305
 
318
 
306
 void Editor::displayMapConnections() {
319
 void Editor::displayMapConnections() {
320
+    for (QString key : map->connection_items.keys()) {
321
+        scene->removeItem(map->connection_items.value(key));
322
+        delete map->connection_items.value(key);
323
+    }
324
+
307
     for (Connection *connection : map->connections) {
325
     for (Connection *connection : map->connections) {
308
         if (connection->direction == "dive" || connection->direction == "emerge") {
326
         if (connection->direction == "dive" || connection->direction == "emerge") {
309
             continue;
327
             continue;