forked from Ivasoft/DSView
Fix compile warnings
This commit is contained in:
@@ -58,7 +58,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
|
||||
_ch_combobox->addItem(dsoSig->get_name(), qVariantFromValue(dsoSig->get_index()));
|
||||
_ch_combobox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
|
||||
for (unsigned int i = 0; i < windows.size(); i++)
|
||||
{
|
||||
_window_combobox->addItem(windows[i],
|
||||
qVariantFromValue(i));
|
||||
QVariant::fromValue(i));
|
||||
}
|
||||
for (unsigned int i = 0; i < length.size(); i++)
|
||||
{
|
||||
if (length[i] < _sample_limit)
|
||||
_len_combobox->addItem(QString::number(length[i]),
|
||||
qVariantFromValue(length[i]));
|
||||
QVariant::fromValue(length[i]));
|
||||
else
|
||||
break;
|
||||
}
|
||||
@@ -109,19 +109,19 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
|
||||
for (int i = 1; i <= max_interval; i*=2)
|
||||
{
|
||||
_interval_combobox->addItem(QString::number(i),
|
||||
qVariantFromValue(i));
|
||||
QVariant::fromValue(i));
|
||||
}
|
||||
for (unsigned int i = 0; i < view_modes.size(); i++)
|
||||
{
|
||||
_view_combobox->addItem(view_modes[i],
|
||||
qVariantFromValue(i));
|
||||
QVariant::fromValue(i));
|
||||
}
|
||||
assert(_view_combobox->count() > 0);
|
||||
_view_combobox->setCurrentIndex(_view_combobox->count()-1);
|
||||
for (unsigned int i = 0; i < dbv_ranges.size(); i++)
|
||||
{
|
||||
_dbv_combobox->addItem(QString::number(dbv_ranges[i]),
|
||||
qVariantFromValue(dbv_ranges[i]));
|
||||
QVariant::fromValue(dbv_ranges[i]));
|
||||
}
|
||||
|
||||
// load current settings
|
||||
@@ -147,7 +147,7 @@ FftOptions::FftOptions(QWidget *parent, SigSession &session) :
|
||||
for (int i = 1; i <= max_interval; i*=2)
|
||||
{
|
||||
_interval_combobox->addItem(QString::number(i),
|
||||
qVariantFromValue(i));
|
||||
QVariant::fromValue(i));
|
||||
}
|
||||
for (int i = 0; i < _interval_combobox->count(); i++) {
|
||||
if (spectrumTraces->get_spectrum_stack()->get_sample_interval() == _interval_combobox->itemData(i).toInt()) {
|
||||
@@ -258,7 +258,7 @@ void FftOptions::len_changed(int index)
|
||||
for (int i = 1; i <= max_interval; i*=2)
|
||||
{
|
||||
_interval_combobox->addItem(QString::number(i),
|
||||
qVariantFromValue(i));
|
||||
QVariant::fromValue(i));
|
||||
}
|
||||
_interval_combobox->setCurrentIndex(pre_index);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ ProtocolList::ProtocolList(QWidget *parent, SigSession &session) :
|
||||
_protocol_combobox->setCurrentIndex(index);
|
||||
index++;
|
||||
}
|
||||
_protocol_combobox->addItem("", qVariantFromValue(NULL));
|
||||
_protocol_combobox->addItem("", QVariant::fromValue(NULL));
|
||||
if (decoder_model->getDecoderStack() == NULL)
|
||||
_protocol_combobox->setCurrentIndex(index);
|
||||
|
||||
|
||||
@@ -63,9 +63,9 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession &session) :
|
||||
|
||||
_holdoff_label = new QLabel(_widget);
|
||||
_holdoff_comboBox = new QComboBox(_widget);
|
||||
_holdoff_comboBox->addItem(tr("uS"), qVariantFromValue(1000));
|
||||
_holdoff_comboBox->addItem(tr("mS"), qVariantFromValue(1000000));
|
||||
_holdoff_comboBox->addItem(tr("S"), qVariantFromValue(1000000000));
|
||||
_holdoff_comboBox->addItem(tr("uS"), QVariant::fromValue(1000));
|
||||
_holdoff_comboBox->addItem(tr("mS"), QVariant::fromValue(1000000));
|
||||
_holdoff_comboBox->addItem(tr("S"), QVariant::fromValue(1000000000));
|
||||
_holdoff_comboBox->setCurrentIndex(0);
|
||||
_holdoff_spinBox = new QSpinBox(_widget);
|
||||
_holdoff_spinBox->setRange(0, 999);
|
||||
@@ -390,7 +390,7 @@ void DsoTriggerDock::init()
|
||||
BOOST_FOREACH(const boost::shared_ptr<view::Signal> s, _session.get_signals()) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
if ((dsoSig = dynamic_pointer_cast<view::DsoSignal>(s))) {
|
||||
_channel_comboBox->addItem(dsoSig->get_name(), qVariantFromValue(dsoSig->get_index()));
|
||||
_channel_comboBox->addItem(dsoSig->get_name(), QVariant::fromValue(dsoSig->get_index()));
|
||||
}
|
||||
}
|
||||
gvar = _session.get_device()->get_config(NULL, NULL,
|
||||
|
||||
@@ -81,7 +81,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession &sessio
|
||||
|
||||
const bool have_probes = (d->channels || d->opt_channels) != 0;
|
||||
if (true == have_probes) {
|
||||
_protocol_combobox->addItem(QString::fromUtf8(d->name), qVariantFromValue(l->data));
|
||||
_protocol_combobox->addItem(QString::fromUtf8(d->name), QVariant::fromValue(l->data));
|
||||
}
|
||||
}
|
||||
g_slist_free(l);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QEvent>
|
||||
#include <QtGlobal>
|
||||
#include <QScreen>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
@@ -83,7 +84,6 @@
|
||||
#include "view/analogsignal.h"
|
||||
|
||||
/* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
@@ -852,9 +852,10 @@ void MainWindow::on_screenShot()
|
||||
QSettings settings(QApplication::organizationName(), QApplication::applicationName());
|
||||
QString default_name = settings.value(DIR_KEY).toString() + "/DSView" + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss");
|
||||
QPixmap pixmap;
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
pixmap = QPixmap::grabWindow(desktop->winId(), parentWidget()->pos().x(), parentWidget()->pos().y(),
|
||||
parentWidget()->frameGeometry().width(), parentWidget()->frameGeometry().height());
|
||||
pixmap = screen->grabWindow(desktop->winId(), parentWidget()->pos().x(), parentWidget()->pos().y(),
|
||||
parentWidget()->frameGeometry().width(), parentWidget()->frameGeometry().height());
|
||||
QString format = "png";
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
|
||||
@@ -65,7 +65,7 @@ QWidget* Enum::get_widget(QWidget *parent, bool auto_commit)
|
||||
_selector = new QComboBox(parent);
|
||||
for (unsigned int i = 0; i < _values.size(); i++) {
|
||||
const pair<GVariant*, QString> &v = _values[i];
|
||||
_selector->addItem(v.second, qVariantFromValue((void*)v.first));
|
||||
_selector->addItem(v.second, QVariant::fromValue((void*)v.first));
|
||||
if (value && g_variant_compare(v.first, value) == 0)
|
||||
_selector->setCurrentIndex(i);
|
||||
}
|
||||
|
||||
@@ -1406,7 +1406,7 @@ bool SigSession::add_decoder(srd_decoder *const dec, bool silent)
|
||||
_decode_traces.push_back(d);
|
||||
ret = true;
|
||||
}
|
||||
} catch(std::runtime_error e) {
|
||||
} catch(const std::runtime_error &e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ void SamplingBar::reStyle()
|
||||
_instant_button.setIcon(QIcon(iconPath+"/single.svg"));
|
||||
_action_single->setIcon(QIcon(iconPath+"/oneloop.svg"));
|
||||
_action_repeat->setIcon(QIcon(iconPath+"/repeat.svg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SamplingBar::set_device_list(
|
||||
@@ -252,7 +252,7 @@ void SamplingBar::set_device_list(
|
||||
|
||||
_device_selector_map[id] = dev_inst;
|
||||
_device_selector.addItem(title,
|
||||
qVariantFromValue((void*)id));
|
||||
QVariant::fromValue((void*)id));
|
||||
}
|
||||
int width = _device_selector.sizeHint().width();
|
||||
_device_selector.setFixedWidth(min(width+15, _device_selector.maximumWidth()));
|
||||
@@ -465,7 +465,7 @@ void SamplingBar::update_sample_rate_selector()
|
||||
{
|
||||
char *const s = sr_samplerate_string(elements[i]);
|
||||
_sample_rate.addItem(QString(s),
|
||||
qVariantFromValue(elements[i]));
|
||||
QVariant::fromValue(elements[i]));
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ void SamplingBar::update_sample_count_selector()
|
||||
(!stream_mode && duration > hw_duration) ? RLEString : "";
|
||||
char *const s = sr_time_string(duration);
|
||||
_sample_count.addItem(QString(s) + suffix,
|
||||
qVariantFromValue(duration));
|
||||
QVariant::fromValue(duration));
|
||||
g_free(s);
|
||||
|
||||
double unit;
|
||||
|
||||
@@ -782,7 +782,7 @@ QComboBox* DecodeTrace::create_probe_selector(
|
||||
|
||||
QComboBox *selector = new QComboBox(parent);
|
||||
|
||||
selector->addItem("-", qVariantFromValue(-1));
|
||||
selector->addItem("-", QVariant::fromValue(-1));
|
||||
|
||||
if (probe_iter == dec->channels().end())
|
||||
selector->setCurrentIndex(0);
|
||||
@@ -794,7 +794,7 @@ QComboBox* DecodeTrace::create_probe_selector(
|
||||
if (dynamic_pointer_cast<LogicSignal>(s) && s->enabled())
|
||||
{
|
||||
selector->addItem(s->get_name(),
|
||||
qVariantFromValue(s->get_index()));
|
||||
QVariant::fromValue(s->get_index()));
|
||||
if (probe_iter != dec->channels().end()) {
|
||||
if ((*probe_iter).second == s->get_index())
|
||||
selector->setCurrentIndex(i + 1);
|
||||
|
||||
@@ -291,14 +291,19 @@ void MathTrace::paint_trace(QPainter &p,
|
||||
double pixels_per_sample = 1.0/samples_per_pixel;
|
||||
|
||||
for (int64_t index = 0; index < sample_count; index++) {
|
||||
*point++ = QPointF(x, min(max(top, zeroY - (values[index] * _scale)), bottom));
|
||||
const float y = min(max(top, zeroY - (values[index] * _scale)), bottom);
|
||||
if (x > get_view_rect().right()) {
|
||||
point--;
|
||||
const float lastY = point->y() + (y - point->y()) / (x - point->x()) * (get_view_rect().right() - point->x());
|
||||
point++;
|
||||
*point++ = QPointF(get_view_rect().right(), lastY);
|
||||
break;
|
||||
}
|
||||
*point++ = QPointF(x, y);
|
||||
x += pixels_per_sample;
|
||||
}
|
||||
|
||||
p.drawPolyline(points, point - points);
|
||||
p.eraseRect(get_view_rect().right()+1, get_view_rect().top(),
|
||||
_view->viewport()->width() - get_view_rect().width(), get_view_rect().height());
|
||||
|
||||
delete[] points;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
|
||||
pixmap.fill(Qt::transparent);
|
||||
|
||||
QPainter dbp(&pixmap);
|
||||
dbp.initFrom(this);
|
||||
//dbp.begin(this);
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
{
|
||||
assert(t);
|
||||
@@ -489,7 +489,7 @@ void Viewport::mousePressEvent(QMouseEvent *event)
|
||||
_mouse_down_point = event->pos();
|
||||
_mouse_down_offset = _view.offset();
|
||||
_drag_strength = 0;
|
||||
_time.restart();
|
||||
_elapsed_time.restart();
|
||||
|
||||
if (_action_type == NO_ACTION &&
|
||||
event->button() == Qt::RightButton &&
|
||||
@@ -638,7 +638,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
if (_type == TIME_VIEW) {
|
||||
if ((event->buttons() & Qt::LeftButton) ||
|
||||
!(event->buttons() || Qt::NoButton)) {
|
||||
!(event->buttons() | Qt::NoButton)) {
|
||||
if (_action_type == DSO_TRIG_MOVE) {
|
||||
if (_drag_sig) {
|
||||
boost::shared_ptr<view::DsoSignal> dsoSig;
|
||||
@@ -716,7 +716,7 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(event->buttons() || Qt::NoButton)) {
|
||||
if (!(event->buttons() | Qt::NoButton)) {
|
||||
if (_action_type == DSO_XM_STEP1 || _action_type == DSO_XM_STEP2) {
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, _view.session().get_signals()) {
|
||||
assert(s);
|
||||
@@ -749,13 +749,13 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
||||
_view.session().get_capture_state() == SigSession::Stopped) {
|
||||
// priority 1
|
||||
if (_action_type == NO_ACTION) {
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_time.elapsed();
|
||||
if (_time.elapsed() < 200 &&
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
|
||||
if (_elapsed_time.elapsed() < 200 &&
|
||||
abs(_drag_strength) < MinorDragOffsetUp &&
|
||||
abs(strength) > MinorDragRateUp) {
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
_action_type = LOGIC_MOVE;
|
||||
} else if (_time.elapsed() < 200 &&
|
||||
} else if (_elapsed_time.elapsed() < 200 &&
|
||||
abs(strength) > DragTimerInterval) {
|
||||
_drag_strength = strength * 5;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
@@ -894,12 +894,12 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event)
|
||||
_drag_timer.stop();
|
||||
_action_type = NO_ACTION;
|
||||
} else {
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_time.elapsed();
|
||||
if (_time.elapsed() < 200 &&
|
||||
const double strength = _drag_strength*DragTimerInterval*1.0/_elapsed_time.elapsed();
|
||||
if (_elapsed_time.elapsed() < 200 &&
|
||||
abs(_drag_strength) < MinorDragOffsetUp &&
|
||||
abs(strength) > MinorDragRateUp) {
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
} else if (_time.elapsed() < 200 &&
|
||||
} else if (_elapsed_time.elapsed() < 200 &&
|
||||
abs(strength) > DragTimerInterval) {
|
||||
_drag_strength = strength * 5;
|
||||
_drag_timer.start(DragTimerInterval);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
#include <QNativeGestureEvent>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "../view/view.h"
|
||||
#include "../../extdef.h"
|
||||
@@ -201,7 +202,7 @@ private:
|
||||
uint16_t _hover_sig_index;
|
||||
double _hover_sig_value;
|
||||
|
||||
QTime _time;
|
||||
QElapsedTimer _elapsed_time;
|
||||
QTimer _drag_timer;
|
||||
int _drag_strength;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) :
|
||||
if (first_level_decoder == have_probes) {
|
||||
QAction *const action =
|
||||
addAction(QString::fromUtf8(d->name));
|
||||
action->setData(qVariantFromValue(l->data));
|
||||
action->setData(QVariant::fromValue(l->data));
|
||||
_mapper.setMapping(action, action);
|
||||
connect(action, SIGNAL(triggered()),
|
||||
&_mapper, SLOT(map()));
|
||||
|
||||
Reference in New Issue
Block a user