From 4a734d6cc7067a490297a5d8bf0dd7a3f285a803 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 14 Jun 2018 18:58:37 +0200 Subject: [PATCH] separate clearProperties --- gui/mainwindow.cc | 15 +++++++++++---- gui/mainwindow.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gui/mainwindow.cc b/gui/mainwindow.cc index eaebe809..c8d072bb 100644 --- a/gui/mainwindow.cc +++ b/gui/mainwindow.cc @@ -164,11 +164,8 @@ void MainWindow::addProperty(QtVariantProperty *property, const QString &id) QtBrowserItem *item = propertyEditor->addProperty(property); } -void MainWindow::onItemClicked(QTreeWidgetItem *item, int pos) +void MainWindow::clearProperties() { - if (!item->parent()) - return; - ElementType type = static_cast(item)->getType(); QMap::ConstIterator itProp = propertyToId.constBegin(); while (itProp != propertyToId.constEnd()) { @@ -177,6 +174,16 @@ void MainWindow::onItemClicked(QTreeWidgetItem *item, int pos) } propertyToId.clear(); idToProperty.clear(); +} + +void MainWindow::onItemClicked(QTreeWidgetItem *item, int pos) +{ + if (!item->parent()) + return; + + clearProperties(); + + ElementType type = static_cast(item)->getType(); if (type == ElementType::BEL) { IdString c = static_cast(item)->getData(); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 3260da14..d9397b5c 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -31,6 +31,7 @@ class MainWindow : public QMainWindow private: void addProperty(QtVariantProperty *property, const QString &id); + void clearProperties(); private Q_SLOTS: void prepareMenu(const QPoint &pos);