X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fprop%2Fdouble.cpp;h=57512d723ff26b5cd3473432040e975cf914e8bb;hb=30fe44fbfb5727c6ca93f10cf4de913b4f13381f;hp=f4e6e443a5bb6f2e7dcf27fe29053f6daed50090;hpb=c6246dc56ed01d7e99aa65ab88b8c191300b1ebd;p=pulseview.git
diff --git a/pv/prop/double.cpp b/pv/prop/double.cpp
index f4e6e44..57512d7 100644
--- a/pv/prop/double.cpp
+++ b/pv/prop/double.cpp
@@ -14,11 +14,10 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see .
*/
-#include
+#include
#include
@@ -31,13 +30,14 @@ namespace pv {
namespace prop {
Double::Double(QString name,
+ QString desc,
int decimals,
QString suffix,
optional< pair > range,
optional step,
Getter getter,
Setter setter) :
- Property(name, getter, setter),
+ Property(name, desc, getter, setter),
decimals_(decimals),
suffix_(suffix),
range_(range),
@@ -58,9 +58,6 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
if (!variant.gobj())
return nullptr;
- double value = Glib::VariantBase::cast_dynamic>(
- variant).get();
-
spin_box_ = new QDoubleSpinBox(parent);
spin_box_->setDecimals(decimals_);
spin_box_->setSuffix(suffix_);
@@ -69,7 +66,7 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
if (step_)
spin_box_->setSingleStep(*step_);
- spin_box_->setValue(value);
+ update_widget();
if (auto_commit)
connect(spin_box_, SIGNAL(valueChanged(double)),
@@ -78,6 +75,19 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
return spin_box_;
}
+void Double::update_widget()
+{
+ if (!spin_box_)
+ return;
+
+ Glib::VariantBase variant = getter_();
+ assert(variant.gobj());
+
+ double value = Glib::VariantBase::cast_dynamic>(
+ variant).get();
+ spin_box_->setValue(value);
+}
+
void Double::commit()
{
assert(setter_);
@@ -93,5 +103,5 @@ void Double::on_value_changed(double)
commit();
}
-} // prop
-} // pv
+} // namespace prop
+} // namespace pv