projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't use deprecated headers.
[pulseview.git]
/
pv
/
prop
/
int.cpp
diff --git
a/pv/prop/int.cpp
b/pv/prop/int.cpp
index 8124f9b0c9a2abc88772f99cac0961b9e72fb20a..789c26eb0236c9efb89c3c2291cd92e1a5d0e421 100644
(file)
--- a/
pv/prop/int.cpp
+++ b/
pv/prop/int.cpp
@@
-14,16
+14,15
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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 <http://www.gnu.org/licenses/>.
*/
*/
-#include <
stdint.h
>
-#include <
assert.h
>
+#include <
cstdint
>
+#include <
cassert
>
#include <QSpinBox>
#include <QSpinBox>
-#include "int.h"
+#include "int.h
pp
"
using boost::optional;
using std::max;
using boost::optional;
using std::max;
@@
-39,76
+38,57
@@
Int::Int(QString name,
Getter getter,
Setter setter) :
Property(name, getter, setter),
Getter getter,
Setter setter) :
Property(name, getter, setter),
- _suffix(suffix),
- _range(range),
- _value(NULL),
- _spin_box(NULL)
+ suffix_(suffix),
+ range_(range),
+ spin_box_(nullptr)
{
}
{
}
-Int::~Int()
-{
- if (_value)
- g_variant_unref(_value);
-}
-
QWidget* Int::get_widget(QWidget *parent, bool auto_commit)
{
QWidget* Int::get_widget(QWidget *parent, bool auto_commit)
{
- int64_t int_val = 0, range_min = 0, range_max = 0;
+ int64_t int_val = 0, range_min = 0;
+ uint64_t range_max = 0;
+
+ if (spin_box_)
+ return spin_box_;
- if (
_spin_box
)
- return
_spin_box
;
+ if (
!getter_
)
+ return
nullptr
;
- if (_value)
- g_variant_unref(_value);
+ value_ = getter_();
-
_value = _getter ? _getter() : NULL
;
- if (!
_
value)
- return
NULL
;
+
GVariant *value = value_.gobj()
;
+ if (!value)
+ return
nullptr
;
-
_spin_box
= new QSpinBox(parent);
-
_spin_box->setSuffix(_suffix
);
+
spin_box_
= new QSpinBox(parent);
+
spin_box_->setSuffix(suffix_
);
- const GVariantType *const type = g_variant_get_type(
_
value);
+ const GVariantType *const type = g_variant_get_type(value);
assert(type);
assert(type);
- if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE))
- {
- int_val = g_variant_get_byte(_value);
+ if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE)) {
+ int_val = g_variant_get_byte(value);
range_min = 0, range_max = UINT8_MAX;
range_min = 0, range_max = UINT8_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16))
- {
- int_val = g_variant_get_int16(_value);
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16)) {
+ int_val = g_variant_get_int16(value);
range_min = INT16_MIN, range_max = INT16_MAX;
range_min = INT16_MIN, range_max = INT16_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16))
- {
- int_val = g_variant_get_uint16(_value);
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16)) {
+ int_val = g_variant_get_uint16(value);
range_min = 0, range_max = UINT16_MAX;
range_min = 0, range_max = UINT16_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
- {
- int_val = g_variant_get_int32(_value);
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32)) {
+ int_val = g_variant_get_int32(value);
range_min = INT32_MIN, range_max = INT32_MAX;
range_min = INT32_MIN, range_max = INT32_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32))
- {
- int_val = g_variant_get_uint32(_value);
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32)) {
+ int_val = g_variant_get_uint32(value);
range_min = 0, range_max = UINT32_MAX;
range_min = 0, range_max = UINT32_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64))
- {
- int_val = g_variant_get_int64(_value);
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64)) {
+ int_val = g_variant_get_int64(value);
range_min = INT64_MIN, range_max = INT64_MAX;
range_min = INT64_MIN, range_max = INT64_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
- {
- int_val = g_variant_get_uint64(_value);
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64)) {
+ int_val = g_variant_get_uint64(value);
range_min = 0, range_max = UINT64_MAX;
range_min = 0, range_max = UINT64_MAX;
- }
- else
- {
+ } else {
// Unexpected value type.
assert(0);
}
// Unexpected value type.
assert(0);
}
@@
-119,49
+99,47
@@
QWidget* Int::get_widget(QWidget *parent, bool auto_commit)
// custom widget.
range_min = max(range_min, (int64_t)INT_MIN);
// custom widget.
range_min = max(range_min, (int64_t)INT_MIN);
- range_max = min(range_max, (int64_t)INT_MAX);
+ range_max = min(range_max, (
u
int64_t)INT_MAX);
- if (
_range
)
-
_spin_box->setRange((int)_range->first, (int)_range
->second);
+ if (
range_
)
+
spin_box_->setRange((int)range_->first, (int)range_
->second);
else
else
-
_spin_box
->setRange((int)range_min, (int)range_max);
+
spin_box_
->setRange((int)range_min, (int)range_max);
-
_spin_box
->setValue((int)int_val);
+
spin_box_
->setValue((int)int_val);
if (auto_commit)
if (auto_commit)
- connect(
_spin_box
, SIGNAL(valueChanged(int)),
+ connect(
spin_box_
, SIGNAL(valueChanged(int)),
this, SLOT(on_value_changed(int)));
this, SLOT(on_value_changed(int)));
- return
_spin_box
;
+ return
spin_box_
;
}
void Int::commit()
{
}
void Int::commit()
{
- assert(
_setter
);
+ assert(
setter_
);
- if (!
_spin_box
)
+ if (!
spin_box_
)
return;
return;
- assert(_value);
-
- GVariant *new_value = NULL;
- const GVariantType *const type = g_variant_get_type(_value);
+ GVariant *new_value = nullptr;
+ const GVariantType *const type = g_variant_get_type(value_.gobj());
assert(type);
if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE))
assert(type);
if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE))
- new_value = g_variant_new_byte(
_spin_box
->value());
+ new_value = g_variant_new_byte(
spin_box_
->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16))
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16))
- new_value = g_variant_new_int16(
_spin_box
->value());
+ new_value = g_variant_new_int16(
spin_box_
->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16))
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16))
- new_value = g_variant_new_uint16(
_spin_box
->value());
+ new_value = g_variant_new_uint16(
spin_box_
->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
- new_value = g_variant_new_int32(
_spin_box
->value());
+ new_value = g_variant_new_int32(
spin_box_
->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32))
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32))
- new_value = g_variant_new_
int32(_spin_box
->value());
+ new_value = g_variant_new_
uint32(spin_box_
->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64))
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64))
- new_value = g_variant_new_int64(
_spin_box
->value());
+ new_value = g_variant_new_int64(
spin_box_
->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
- new_value = g_variant_new_uint64(
_spin_box
->value());
+ new_value = g_variant_new_uint64(
spin_box_
->value());
else
{
// Unexpected value type.
else
{
// Unexpected value type.
@@
-170,11
+148,9
@@
void Int::commit()
assert(new_value);
assert(new_value);
- g_variant_unref(_value);
- g_variant_ref(new_value);
- _value = new_value;
+ value_ = Glib::VariantBase(new_value);
-
_setter(new_value
);
+
setter_(value_
);
}
void Int::on_value_changed(int)
}
void Int::on_value_changed(int)