Changeset - da766523eb64
[Not reviewed]
gain-offset
0 2 0
Hasan Yavuz Ă–ZDERYA - 7 years ago 2018-07-16 16:03:28
hy@ozderya.net
increase precision of gain/offset spin boxes in channel info table
2 files changed with 27 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/plotcontrolpanel.cpp
Show inline comments
 
@@ -20,6 +20,7 @@
 
#include <QVariant>
 
#include <QMessageBox>
 
#include <QCheckBox>
 
#include <QStyledItemDelegate>
 

	
 
#include <math.h>
 

	
 
@@ -30,6 +31,8 @@
 

	
 
/// Confirm if #samples is being set to a value greater than this
 
const int NUMSAMPLES_CONFIRM_AT = 1000000;
 
/// Precision used for channel info table numbers
 
const int DOUBLESP_PRECISION = 6;
 

	
 
/// Used for scale range selection combobox
 
struct Range
 
@@ -40,6 +43,25 @@ struct Range
 

	
 
Q_DECLARE_METATYPE(Range);
 

	
 
/// Used for customizing double precision in tables
 
class SpinBoxDelegate : public QStyledItemDelegate
 
{
 
public:
 
    QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option,
 
                          const QModelIndex &index) const Q_DECL_OVERRIDE
 
        {
 
            auto w = QStyledItemDelegate::createEditor(
 
                parent, option, index);
 

	
 
            auto sp = qobject_cast<QDoubleSpinBox*>(w);
 
            if (sp)
 
            {
 
                sp->setDecimals(DOUBLESP_PRECISION);
 
            }
 
            return w;
 
        }
 
};
 

	
 
PlotControlPanel::PlotControlPanel(QWidget *parent) :
 
    QWidget(parent),
 
    ui(new Ui::PlotControlPanel),
 
@@ -52,6 +74,9 @@ PlotControlPanel::PlotControlPanel(QWidg
 
{
 
    ui->setupUi(this);
 

	
 
    delegate = new SpinBoxDelegate();
 
    ui->tvChannelInfo->setItemDelegate(delegate);
 

	
 
    warnNumOfSamples = true;    // TODO: load from settings
 
    _numOfSamples = ui->spNumOfSamples->value();
 

	
src/plotcontrolpanel.h
Show inline comments
 
@@ -24,6 +24,7 @@
 
#include <QSettings>
 
#include <QAction>
 
#include <QMenu>
 
#include <QStyledItemDelegate>
 

	
 
#include "channelinfomodel.h"
 

	
 
@@ -72,6 +73,7 @@ private:
 

	
 
    QAction resetAct, resetNamesAct, resetColorsAct, showAllAct, hideAllAct;
 
    QMenu resetMenu;
 
    QStyledItemDelegate* delegate;
 

	
 
    /// Show a confirmation dialog before setting #samples to a big value
 
    bool askNSConfirmation(int value);
0 comments (0 inline, 0 general)