X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fprop%2Fint.cpp;h=2930a3ea1e8c96b5d0091e6c2b640050ecb5d09f;hb=ec2aadfe0fc0aca0893ea6fa43af79305e1cdbdb;hp=0edba420b2e8538819d6f4b1d55c9c2a75ef26ba;hpb=2acdb232d6bb452cfdfaea3ef5218fb4da592329;p=pulseview.git
diff --git a/pv/prop/int.cpp b/pv/prop/int.cpp
index 0edba42..2930a3e 100644
--- a/pv/prop/int.cpp
+++ b/pv/prop/int.cpp
@@ -14,12 +14,11 @@
* 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
+#include
#include
@@ -34,36 +33,34 @@ namespace pv {
namespace prop {
Int::Int(QString name,
+ QString desc,
QString suffix,
optional< pair > range,
Getter getter,
Setter setter) :
- Property(name, getter, setter),
+ Property(name, desc, getter, setter),
suffix_(suffix),
range_(range),
- spin_box_(NULL)
-{
-}
-
-Int::~Int()
+ spin_box_(nullptr)
{
}
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 (!getter_)
- return NULL;
+ return nullptr;
value_ = getter_();
GVariant *value = value_.gobj();
if (!value)
- return NULL;
+ return nullptr;
spin_box_ = new QSpinBox(parent);
spin_box_->setSuffix(suffix_);
@@ -71,54 +68,39 @@ QWidget* Int::get_widget(QWidget *parent, bool auto_commit)
const GVariantType *const type = g_variant_get_type(value);
assert(type);
- if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE))
- {
+ if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE)) {
int_val = g_variant_get_byte(value);
range_min = 0, range_max = UINT8_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16))
- {
+ } 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;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16))
- {
+ } 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;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
- {
+ } 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;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32))
- {
+ } 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;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64))
- {
+ } 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;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
- {
+ } 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;
- }
- else
- {
+ } else {
// Unexpected value type.
- assert(0);
+ assert(false);
}
- // @todo Sigrok supports 64-bit quantities, but Qt does not have a
+ // @todo sigrok supports 64-bit quantities, but Qt does not have a
// standard widget to allow the values to be modified over the full
// 64-bit range on 32-bit machines. To solve the issue we need a
// 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, (uint64_t)INT_MAX);
if (range_)
spin_box_->setRange((int)range_->first, (int)range_->second);
@@ -141,7 +123,7 @@ void Int::commit()
if (!spin_box_)
return;
- GVariant *new_value = NULL;
+ GVariant *new_value = nullptr;
const GVariantType *const type = g_variant_get_type(value_.gobj());
assert(type);
@@ -154,15 +136,14 @@ void Int::commit()
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
new_value = g_variant_new_int32(spin_box_->value());
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))
new_value = g_variant_new_int64(spin_box_->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
new_value = g_variant_new_uint64(spin_box_->value());
- else
- {
+ else {
// Unexpected value type.
- assert(0);
+ assert(false);
}
assert(new_value);
@@ -177,5 +158,5 @@ void Int::on_value_changed(int)
commit();
}
-} // prop
-} // pv
+} // namespace prop
+} // namespace pv