summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <cordlandwehr@kde.org>2016-10-30 12:34:45 (GMT)
committerAndreas Cord-Landwehr <cordlandwehr@kde.org>2016-10-30 12:34:45 (GMT)
commit8d7af4899b3ae66af45e253aafb043315f0c6a54 (patch)
tree3a4bf8c4a935c5d9f34e54dda177c6ac333b45ed
parentac81d6b1e2014ab26b636f4af4f970dc3e2cf260 (diff)
Correctly set and update rendering plugins
-rw-r--r--src/tools/moleculeview.cpp20
-rw-r--r--src/tools/moleculeview.h5
-rw-r--r--src/tools/moleculeviewerwidget.ui15
3 files changed, 23 insertions, 17 deletions
diff --git a/src/tools/moleculeview.cpp b/src/tools/moleculeview.cpp
index 48d6def..fad2008 100644
--- a/src/tools/moleculeview.cpp
+++ b/src/tools/moleculeview.cpp
@@ -92,8 +92,10 @@ MoleculeDialog::MoleculeDialog(QWidget * parent)
m_drawSettings->setValue("bondOrder", 1);
m_drawSettings->setValue("addHydrogens", 0);
- ui.styleCombo->setModel(
- qobject_cast<QAbstractItemModel*>(&ui.glWidget->sceneModel()));
+ ui.styleCombo->addItems({"Wireframe", "Ball and Stick", "Van der Waals"});
+ slotUpdateScenePlugin();
+ connect(ui.styleCombo, static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
+ this, &MoleculeDialog::slotUpdateScenePlugin);
connect(ui.tabWidget, &QTabWidget::currentChanged,
this, &MoleculeDialog::setViewEdit);
@@ -163,6 +165,18 @@ void MoleculeDialog::slotLoadMolecule()
loadMolecule(filename);
}
+void MoleculeDialog::slotUpdateScenePlugin() {
+ const QString text = ui.styleCombo->currentText();
+ for (int i = 0; i < ui.glWidget->sceneModel().rowCount(QModelIndex()); ++i) {
+ QModelIndex index = ui.glWidget->sceneModel().index(i, 0);
+ if (text == ui.glWidget->sceneModel().data(index, Qt::DisplayRole)) {
+ ui.glWidget->sceneModel().setData(index, Qt::Checked, Qt::CheckStateRole);
+ } else {
+ ui.glWidget->sceneModel().setData(index, Qt::Unchecked, Qt::CheckStateRole);
+ }
+ }
+}
+
void MoleculeDialog::loadMolecule(const QString &filename)
{
if (filename.isEmpty()) {
@@ -191,7 +205,7 @@ void MoleculeDialog::loadMolecule(const QString &filename)
this, &MoleculeDialog::slotUpdateStatistics);
}
ui.glWidget->resetCamera();
- ui.glWidget->update();
+ ui.glWidget->updateScene();
}
void MoleculeDialog::clearAllElementsInEditor()
diff --git a/src/tools/moleculeview.h b/src/tools/moleculeview.h
index a13aac1..fd36469 100644
--- a/src/tools/moleculeview.h
+++ b/src/tools/moleculeview.h
@@ -67,6 +67,11 @@ private slots:
void slotLoadMolecule();
/**
+ * Update the currently active scene plugin.
+ */
+ void slotUpdateScenePlugin();
+
+ /**
* Get a new molecule using hot new stuff
*/
void slotDownloadNewStuff();
diff --git a/src/tools/moleculeviewerwidget.ui b/src/tools/moleculeviewerwidget.ui
index 66e0fca..4f719bf 100644
--- a/src/tools/moleculeviewerwidget.ui
+++ b/src/tools/moleculeviewerwidget.ui
@@ -45,20 +45,7 @@
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
- <widget class="KComboBox" name="styleCombo"/>
- </item>
- <item>
- <spacer name="horizontalSpacer_6">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
+ <widget class="QComboBox" name="styleCombo"/>
</item>
</layout>
</item>