瀏覽代碼

Hide connection editor when switching tabs

Marcus Huderle 6 年之前
父節點
當前提交
1e8d1d9497
共有 1 個檔案被更改,包括 19 行新增1 行删除
  1. 19
    1
      editor.cpp

+ 19
- 1
editor.cpp 查看文件

@@ -38,6 +38,7 @@ void Editor::redo() {
38 38
 void Editor::setEditingMap() {
39 39
     current_view = map_item;
40 40
     if (map_item) {
41
+        displayMapConnections();
41 42
         map_item->draw();
42 43
         map_item->setVisible(true);
43 44
         map_item->setEnabled(true);
@@ -49,6 +50,10 @@ void Editor::setEditingMap() {
49 50
     if (objects_group) {
50 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 59
 void Editor::setEditingCollision() {
@@ -63,6 +68,10 @@ void Editor::setEditingCollision() {
63 68
     if (objects_group) {
64 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 77
 void Editor::setEditingObjects() {
@@ -78,6 +87,10 @@ void Editor::setEditingObjects() {
78 87
     if (collision_item) {
79 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 96
 void Editor::setEditingConnections(QString direction) {
@@ -85,7 +98,7 @@ void Editor::setEditingConnections(QString direction) {
85 98
     if (map_item) {
86 99
         map_item->draw();
87 100
         map_item->setVisible(true);
88
-        map_item->setEnabled(true);
101
+        map_item->setEnabled(false);
89 102
         ui->comboBox_ConnectedMap->blockSignals(true);
90 103
         ui->comboBox_ConnectedMap->clear();
91 104
         ui->comboBox_ConnectedMap->addItems(*project->mapNames);
@@ -304,6 +317,11 @@ DraggablePixmapItem *Editor::addMapObject(Event *event) {
304 317
 }
305 318
 
306 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 325
     for (Connection *connection : map->connections) {
308 326
         if (connection->direction == "dive" || connection->direction == "emerge") {
309 327
             continue;