25 #include <MemoryX/gui-plugins/SceneEditor/ui_SaveSnapshotDialog.h>
26 #include <QPushButton>
45 void gui::dialog::SaveSnapshotDialog::connectSlots()
47 connect(ui->newSnapshotRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(enableSaveNewSnapshot(
bool)));
48 connect(ui->replaceSnapshotRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(enableReplaceSnapshot(
bool)));
49 connect(ui->saveAllRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(enableSaveAllObjects(
bool)));
50 connect(ui->saveGroupsRadioButton, SIGNAL(toggled(
bool)),
this, SLOT(enableSaveGroups(
bool)));
51 connect(ui->snapshotNameLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(checkOkButtonStatus()));
52 connect(ui->groupsListWidget, SIGNAL(itemSelectionChanged()),
this, SLOT(checkOkButtonStatus()));
55 void gui::dialog::SaveSnapshotDialog::showEvent(QShowEvent*)
60 ui->existingSnapshotsComboBox->clear();
61 std::vector<std::string> allSnapshotsVector =
controller->getMemoryXController()->getAllSnapshots();
63 for (std::vector<std::string>::iterator it = allSnapshotsVector.begin(); it != allSnapshotsVector.end(); ++it)
65 ui->existingSnapshotsComboBox->insertItem(ui->existingSnapshotsComboBox->count(), QString::fromStdString(*it));
69 ui->groupsListWidget->clear();
70 std::vector<scene3D::SceneGroupPtr> allGroupsVector =
controller->getScene()->getGroupManager()->getAllGroups();
72 for (std::vector<scene3D::SceneGroupPtr>::iterator it = allGroupsVector.begin(); it != allGroupsVector.end(); ++it)
74 ui->groupsListWidget->insertItem(ui->groupsListWidget->count(), QString::fromStdString((*it)->getGroupId()));
77 checkOkButtonStatus();
81 void gui::dialog::SaveSnapshotDialog::accept()
85 QString snapshotName = newSnapshot ? ui->snapshotNameLineEdit->text() : ui->existingSnapshotsComboBox->currentText();
86 std::string snapshotNameStr = snapshotName.toStdString();
90 controller->saveSnapshotAsJSON(snapshotNameStr);
91 controller->getMemoryXController()->saveSceneInSnapshot(snapshotNameStr);
96 std::vector<std::string> allObjects;
97 QList<QListWidgetItem*> allSelectedGroups = ui->groupsListWidget->selectedItems();
99 for (QList<QListWidgetItem*>::iterator it = allSelectedGroups.begin(); it != allSelectedGroups.end(); ++it)
102 std::vector<scene3D::SceneObjectPtr> allObjectsInGroup = selectedGroup->getAllObjects();
104 for (std::vector<scene3D::SceneObjectPtr>::iterator it = allObjectsInGroup.begin(); it != allObjectsInGroup.end(); ++it)
106 allObjects.insert(allObjects.end(), (*it)->getObjectId());
110 controller->getMemoryXController()->saveObjectsInSnapshot(snapshotNameStr, allObjects);
118 void gui::dialog::SaveSnapshotDialog::checkOkButtonStatus()
120 bool inputIsValid = (!ui->snapshotNameLineEdit->text().isEmpty() || !newSnapshot) && (ui->groupsListWidget->selectedItems().count() > 0 || allObjects);
121 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(inputIsValid);
124 void gui::dialog::SaveSnapshotDialog::enableSaveNewSnapshot(
bool enabled)
128 ui->snapshotNameLineEdit->setEnabled(
enabled);
129 ui->existingSnapshotsComboBox->setDisabled(
enabled);
131 checkOkButtonStatus();
136 void gui::dialog::SaveSnapshotDialog::enableReplaceSnapshot(
bool enabled)
140 ui->existingSnapshotsComboBox->setEnabled(
enabled);
141 ui->snapshotNameLineEdit->setDisabled(
enabled);
143 checkOkButtonStatus();
148 void gui::dialog::SaveSnapshotDialog::enableSaveAllObjects(
bool enabled)
152 ui->groupsListWidget->setDisabled(
enabled);
154 checkOkButtonStatus();
158 void gui::dialog::SaveSnapshotDialog::enableSaveGroups(
bool enabled)
162 ui->groupsListWidget->setEnabled(
enabled);
164 checkOkButtonStatus();
170 this->ui->retranslateUi(
this);