提交 55fc0d96 编写于 作者: D dev

Merge branch 'master' of git@codechina.csdn.net:coloreaglestdio/qtcpp_demo.git

/* -*- c++ -*- */ /* -*- c++ -*- */
/* /*
* Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt
* http://gqrx.dk/ * http://gqrx.dk/
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "bookmarks.h" #include "bookmarks.h"
#include <stdio.h> #include <stdio.h>
#include <wchar.h> #include <wchar.h>
#include <algorithm>
const QColor TagInfo::DefaultColor(Qt::lightGray); const QColor TagInfo::DefaultColor(Qt::lightGray);
const QString TagInfo::strUntagged("Untagged"); const QString TagInfo::strUntagged("Untagged");
Bookmarks* Bookmarks::m_pThis = 0; Bookmarks* Bookmarks::m_pThis = 0;
...@@ -155,7 +155,7 @@ bool Bookmarks::save() ...@@ -155,7 +155,7 @@ bool Bookmarks::save()
QTextStream stream(&file); QTextStream stream(&file);
stream << QString("# Tag name").leftJustified(20) + "; " + stream << QString("# Tag name").leftJustified(20) + "; " +
QString(" color") << endl; QString(" color") << Qt::endl;
QSet<TagInfo*> usedTags; QSet<TagInfo*> usedTags;
for (int iBookmark = 0; iBookmark < m_BookmarkList.size(); iBookmark++) for (int iBookmark = 0; iBookmark < m_BookmarkList.size(); iBookmark++)
...@@ -171,16 +171,16 @@ bool Bookmarks::save() ...@@ -171,16 +171,16 @@ bool Bookmarks::save()
for (QSet<TagInfo*>::iterator i = usedTags.begin(); i != usedTags.end(); i++) for (QSet<TagInfo*>::iterator i = usedTags.begin(); i != usedTags.end(); i++)
{ {
TagInfo& info = **i; TagInfo& info = **i;
stream << info.name.leftJustified(20) + "; " + info.color.name() << endl; stream << info.name.leftJustified(20) + "; " + info.color.name() << Qt::endl;
} }
stream << endl; stream << Qt::endl;
stream << QString("# Frequency").leftJustified(12) + "; " + stream << QString("# Frequency").leftJustified(12) + "; " +
QString("Name").leftJustified(25)+ "; " + QString("Name").leftJustified(25)+ "; " +
QString("Modulation").leftJustified(20) + "; " + QString("Modulation").leftJustified(20) + "; " +
QString("Bandwidth").rightJustified(10) + "; " + QString("Bandwidth").rightJustified(10) + "; " +
QString("Tags") << endl; QString("Tags") << Qt::endl;
for (int i = 0; i < m_BookmarkList.size(); i++) for (int i = 0; i < m_BookmarkList.size(); i++)
{ {
...@@ -199,7 +199,7 @@ bool Bookmarks::save() ...@@ -199,7 +199,7 @@ bool Bookmarks::save()
line.append(tag.name); line.append(tag.name);
} }
stream << line << endl; stream << line << Qt::endl;
} }
file.close(); file.close();
...@@ -212,9 +212,9 @@ QList<BookmarkInfo> Bookmarks::getBookmarksInRange(qint64 low, qint64 high) ...@@ -212,9 +212,9 @@ QList<BookmarkInfo> Bookmarks::getBookmarksInRange(qint64 low, qint64 high)
{ {
BookmarkInfo info; BookmarkInfo info;
info.frequency=low; info.frequency=low;
QList<BookmarkInfo>::const_iterator lb = qLowerBound(m_BookmarkList, info); QList<BookmarkInfo>::const_iterator lb = std::lower_bound(m_BookmarkList.begin(), m_BookmarkList.end(),info);
info.frequency=high; info.frequency=high;
QList<BookmarkInfo>::const_iterator ub = qUpperBound(m_BookmarkList, info); QList<BookmarkInfo>::const_iterator ub = std::upper_bound(m_BookmarkList.begin(), m_BookmarkList.end(),info);
QList<BookmarkInfo> found; QList<BookmarkInfo> found;
......
/* -*- c++ -*- */ /* -*- c++ -*- */
/* /*
* Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt
* http://gqrx.dk/ * http://gqrx.dk/
...@@ -74,7 +74,7 @@ QVariant BookmarksTableModel::data ( const QModelIndex & index, int role ) const ...@@ -74,7 +74,7 @@ QVariant BookmarksTableModel::data ( const QModelIndex & index, int role ) const
{ {
BookmarkInfo& info = *m_Bookmarks[index.row()]; BookmarkInfo& info = *m_Bookmarks[index.row()];
if(role==Qt::BackgroundColorRole) if(role==Qt::BackgroundRole)
{ {
QColor bg(info.GetColor()); QColor bg(info.GetColor());
bg.setAlpha(0x60); bg.setAlpha(0x60);
...@@ -160,7 +160,7 @@ bool BookmarksTableModel::setData(const QModelIndex &index, const QVariant &valu ...@@ -160,7 +160,7 @@ bool BookmarksTableModel::setData(const QModelIndex &index, const QVariant &valu
Qt::ItemFlags BookmarksTableModel::flags ( const QModelIndex& index ) const Qt::ItemFlags BookmarksTableModel::flags ( const QModelIndex& index ) const
{ {
Qt::ItemFlags flags = 0; Qt::ItemFlags flags = Qt::NoItemFlags;
switch(index.column()) switch(index.column())
{ {
......
/* -*- c++ -*- */ /* -*- c++ -*- */
/* /*
* Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt
* http://gqrx.dk/ * http://gqrx.dk/
...@@ -269,7 +269,7 @@ void BookmarksTagList::AddTag(QString name, Qt::CheckState checkstate, QColor co ...@@ -269,7 +269,7 @@ void BookmarksTagList::AddTag(QString name, Qt::CheckState checkstate, QColor co
// Column 0 // Column 0
item = new QTableWidgetItem(); item = new QTableWidgetItem();
item->setFlags(Qt::ItemIsEnabled); item->setFlags(Qt::ItemIsEnabled);
item->setBackgroundColor(color); item->setBackground(color);
setItem(i, 0, item); setItem(i, 0, item);
} }
......
/* /*
* Frequency controller widget (originally from CuteSDR) * Frequency controller widget (originally from CuteSDR)
* *
* This file is part of gqrx sdr. * This file is part of gqrx sdr.
...@@ -93,6 +93,14 @@ bool CFreqCtrl::inRect(QRect &rect, QPoint &point) ...@@ -93,6 +93,14 @@ bool CFreqCtrl::inRect(QRect &rect, QPoint &point)
else else
return false; return false;
} }
bool CFreqCtrl::inRect(QRect &rect, QPointF &point)
{
if ((point.x() < rect.right()) && (point.x() > rect.x()) &&
(point.y() < rect.bottom()) && (point.y() > rect.y()))
return true;
else
return false;
}
static int fmax_to_numdigits(qint64 fmax) static int fmax_to_numdigits(qint64 fmax)
{ {
...@@ -463,8 +471,8 @@ void CFreqCtrl::mousePressEvent(QMouseEvent *event) ...@@ -463,8 +471,8 @@ void CFreqCtrl::mousePressEvent(QMouseEvent *event)
void CFreqCtrl::wheelEvent(QWheelEvent *event) void CFreqCtrl::wheelEvent(QWheelEvent *event)
{ {
QPoint pt = event->pos(); QPointF pt = event->position();
int numDegrees = event->delta() / 8; int numDegrees = (event->angleDelta().x() +event->angleDelta().y() ) / 8;
int numSteps = numDegrees / 15; int numSteps = numDegrees / 15;
for (int i = m_DigStart; i < m_NumDigits; i++) for (int i = m_DigStart; i < m_NumDigits; i++)
......
/* /*
* Frequency controller widget (originally from CuteSDR) * Frequency controller widget (originally from CuteSDR)
*/ */
#pragma once #pragma once
...@@ -80,6 +80,7 @@ private: ...@@ -80,6 +80,7 @@ private:
void moveCursorLeft(); void moveCursorLeft();
void moveCursorRight(); void moveCursorRight();
bool inRect(QRect &rect, QPoint &point); bool inRect(QRect &rect, QPoint &point);
bool inRect(QRect &rect, QPointF &point);
bool m_UpdateAll; bool m_UpdateAll;
bool m_ExternalKeyActive; bool m_ExternalKeyActive;
......
...@@ -404,13 +404,13 @@ void CPlotter::mouseMoveEvent(QMouseEvent* event) ...@@ -404,13 +404,13 @@ void CPlotter::mouseMoveEvent(QMouseEvent* event)
} }
else if (XAXIS == m_CursorCaptured) else if (XAXIS == m_CursorCaptured)
{ {
if (event->buttons() & (Qt::LeftButton | Qt::MidButton)) if (event->buttons() & (Qt::LeftButton | Qt::MiddleButton))
{ {
setCursor(QCursor(Qt::ClosedHandCursor)); setCursor(QCursor(Qt::ClosedHandCursor));
// pan viewable range or move center frequency // pan viewable range or move center frequency
int delta_px = m_Xzero - pt.x(); int delta_px = m_Xzero - pt.x();
qint64 delta_hz = delta_px * m_Span / m_OverlayPixmap.width(); qint64 delta_hz = delta_px * m_Span / m_OverlayPixmap.width();
if (event->buttons() & Qt::MidButton) if (event->buttons() & Qt::MiddleButton)
{ {
m_CenterFreq += delta_hz; m_CenterFreq += delta_hz;
m_DemodCenterFreq += delta_hz; m_DemodCenterFreq += delta_hz;
...@@ -709,7 +709,7 @@ void CPlotter::mousePressEvent(QMouseEvent * event) ...@@ -709,7 +709,7 @@ void CPlotter::mousePressEvent(QMouseEvent * event)
m_GrabPosition = 1; m_GrabPosition = 1;
drawOverlay(); drawOverlay();
} }
else if (event->buttons() == Qt::MidButton) else if (event->buttons() == Qt::MiddleButton)
{ {
// set center freq // set center freq
m_CenterFreq = roundFreq(freqFromX(pt.x()), m_ClickResolution); m_CenterFreq = roundFreq(freqFromX(pt.x()), m_ClickResolution);
...@@ -827,10 +827,10 @@ void CPlotter::zoomOnXAxis(double level) ...@@ -827,10 +827,10 @@ void CPlotter::zoomOnXAxis(double level)
// Called when a mouse wheel is turned // Called when a mouse wheel is turned
void CPlotter::wheelEvent(QWheelEvent * event) void CPlotter::wheelEvent(QWheelEvent * event)
{ {
QPoint pt = event->pos(); QPointF pt = event->position();
pt.setX(pt.x() / pixRatio()+.5); pt.setX(pt.x() / pixRatio()+.5);
pt.setY(pt.y() / pixRatio()+.5); pt.setY(pt.y() / pixRatio()+.5);
int numDegrees = event->delta() / 8; int numDegrees = (event->angleDelta().x() + event->angleDelta().y()) / 8;
int numSteps = numDegrees / 15; /** FIXME: Only used for direction **/ int numSteps = numDegrees / 15; /** FIXME: Only used for direction **/
/** FIXME: zooming could use some optimisation **/ /** FIXME: zooming could use some optimisation **/
...@@ -838,7 +838,7 @@ void CPlotter::wheelEvent(QWheelEvent * event) ...@@ -838,7 +838,7 @@ void CPlotter::wheelEvent(QWheelEvent * event)
{ {
// Vertical zoom. Wheel down: zoom out, wheel up: zoom in // Vertical zoom. Wheel down: zoom out, wheel up: zoom in
// During zoom we try to keep the point (dB or kHz) under the cursor fixed // During zoom we try to keep the point (dB or kHz) under the cursor fixed
double zoom_fac = event->delta() < 0 ? 1.1 : 0.9; double zoom_fac = numDegrees < 0 ? 1.1 : 0.9;
double ratio = (double)pt.y() / (double)m_OverlayPixmap.height(); double ratio = (double)pt.y() / (double)m_OverlayPixmap.height();
double db_range = m_PandMaxdB - m_PandMindB; double db_range = m_PandMaxdB - m_PandMindB;
double y_range = (double)m_OverlayPixmap.height(); double y_range = (double)m_OverlayPixmap.height();
...@@ -857,7 +857,7 @@ void CPlotter::wheelEvent(QWheelEvent * event) ...@@ -857,7 +857,7 @@ void CPlotter::wheelEvent(QWheelEvent * event)
} }
else if (m_CursorCaptured == XAXIS) else if (m_CursorCaptured == XAXIS)
{ {
zoomStepX(event->delta() < 0 ? 1.1 : 0.9, pt.x()); zoomStepX(numDegrees < 0 ? 1.1 : 0.9, pt.x());
} }
else if (event->modifiers() & Qt::ControlModifier) else if (event->modifiers() & Qt::ControlModifier)
{ {
...@@ -1351,7 +1351,7 @@ void CPlotter::drawOverlay() ...@@ -1351,7 +1351,7 @@ void CPlotter::drawOverlay()
QFontMetrics metrics(m_Font); QFontMetrics metrics(m_Font);
QPainter painter(&m_OverlayPixmap); QPainter painter(&m_OverlayPixmap);
painter.initFrom(this); painter.begin(this);
painter.setFont(m_Font); painter.setFont(m_Font);
// solid background // solid background
...@@ -1362,7 +1362,7 @@ void CPlotter::drawOverlay() ...@@ -1362,7 +1362,7 @@ void CPlotter::drawOverlay()
#define VER_MARGIN 5 #define VER_MARGIN 5
// X and Y axis areas // X and Y axis areas
m_YAxisWidth = metrics.width("XXXX") + 2 * HOR_MARGIN; m_YAxisWidth = metrics.horizontalAdvance("XXXX") + 2 * HOR_MARGIN;
m_XAxisYCenter = h - metrics.height()/2; m_XAxisYCenter = h - metrics.height()/2;
int xAxisHeight = metrics.height() + 2 * VER_MARGIN; int xAxisHeight = metrics.height() + 2 * VER_MARGIN;
int xAxisTop = h - xAxisHeight; int xAxisTop = h - xAxisHeight;
...@@ -1384,7 +1384,7 @@ void CPlotter::drawOverlay() ...@@ -1384,7 +1384,7 @@ void CPlotter::drawOverlay()
x = xFromFreq(bookmarks[i].frequency); x = xFromFreq(bookmarks[i].frequency);
#if defined(_WIN16) || defined(_WIN32) || defined(_WIN64) #if defined(_WIN16) || defined(_WIN32) || defined(_WIN64)
int nameWidth = fm.width(bookmarks[i].name); int nameWidth = fm.horizontalAdvance(bookmarks[i].name);
#else #else
int nameWidth = fm.boundingRect(bookmarks[i].name).width(); int nameWidth = fm.boundingRect(bookmarks[i].name).width();
#endif #endif
...@@ -1397,7 +1397,7 @@ void CPlotter::drawOverlay() ...@@ -1397,7 +1397,7 @@ void CPlotter::drawOverlay()
level = 0; level = 0;
tagEnd[level] = x + nameWidth + slant - 1; tagEnd[level] = x + nameWidth + slant - 1;
m_BookmarkTags.append(qMakePair<QRect, qint64>(QRect(x, level * levelHeight, nameWidth + slant, fontHeight), bookmarks[i].frequency)); m_BookmarkTags.append(qMakePair(QRect(x, level * levelHeight, nameWidth + slant, fontHeight), bookmarks[i].frequency));
QColor color = QColor(bookmarks[i].GetColor()); QColor color = QColor(bookmarks[i].GetColor());
color.setAlpha(0x60); color.setAlpha(0x60);
...@@ -1437,7 +1437,7 @@ void CPlotter::drawOverlay() ...@@ -1437,7 +1437,7 @@ void CPlotter::drawOverlay()
QString label; QString label;
label.setNum(double((StartFreq + m_Span) / m_FreqUnits), 'f', m_FreqDigits); label.setNum(double((StartFreq + m_Span) / m_FreqUnits), 'f', m_FreqDigits);
calcDivSize(StartFreq, StartFreq + m_Span, calcDivSize(StartFreq, StartFreq + m_Span,
qMin(w/(metrics.width(label) + metrics.width("O")), HORZ_DIVS_MAX), qMin(w/(metrics.horizontalAdvance(label) + metrics.horizontalAdvance("O")), HORZ_DIVS_MAX),
m_StartFreqAdj, m_FreqPerDiv, m_HorDivs); m_StartFreqAdj, m_FreqPerDiv, m_HorDivs);
pixperdiv = (double)w * (double) m_FreqPerDiv / (double) m_Span; pixperdiv = (double)w * (double) m_FreqPerDiv / (double) m_Span;
adjoffset = pixperdiv * double (m_StartFreqAdj - StartFreq) / (double) m_FreqPerDiv; adjoffset = pixperdiv * double (m_StartFreqAdj - StartFreq) / (double) m_FreqPerDiv;
...@@ -1455,7 +1455,7 @@ void CPlotter::drawOverlay() ...@@ -1455,7 +1455,7 @@ void CPlotter::drawOverlay()
painter.setPen(QColor(PLOTTER_TEXT_COLOR)); painter.setPen(QColor(PLOTTER_TEXT_COLOR));
for (int i = 0; i <= m_HorDivs; i++) for (int i = 0; i <= m_HorDivs; i++)
{ {
int tw = metrics.width(m_HDivText[i]); int tw = metrics.horizontalAdvance(m_HDivText[i]);
x = (int)((double)i*pixperdiv + adjoffset); x = (int)((double)i*pixperdiv + adjoffset);
if (x > m_YAxisWidth) if (x > m_YAxisWidth)
{ {
...@@ -1494,7 +1494,7 @@ void CPlotter::drawOverlay() ...@@ -1494,7 +1494,7 @@ void CPlotter::drawOverlay()
// draw amplitude values (y axis) // draw amplitude values (y axis)
int dB = m_PandMaxdB; int dB = m_PandMaxdB;
m_YAxisWidth = metrics.width("-120 "); m_YAxisWidth = metrics.horizontalAdvance("-120 ");
painter.setPen(QColor(PLOTTER_TEXT_COLOR)); painter.setPen(QColor(PLOTTER_TEXT_COLOR));
for (int i = 0; i < m_VerDivs; i++) for (int i = 0; i < m_VerDivs; i++)
{ {
......
#include "uhd_device_win32.h" #include "uhd_device_win32.h"
#include <QThread> #include <QThread>
#include <QDebug> #include <QDebug>
#include <QCoreApplication> #include <QCoreApplication>
...@@ -262,8 +262,8 @@ quint64 uhd_device::set_center_freq(const quint64 freq_in_hz) ...@@ -262,8 +262,8 @@ quint64 uhd_device::set_center_freq(const quint64 freq_in_hz)
/*.target_freq =*/ (double)freq_in_hz, /*.target_freq =*/ (double)freq_in_hz,
/*.rf_freq_policy =*/ UHD_TUNE_REQUEST_POLICY_AUTO, /*.rf_freq_policy =*/ UHD_TUNE_REQUEST_POLICY_AUTO,
/*.rf_freq =*/ 0, /*.rf_freq =*/ 0,
/*.dsp_freq_policy = */UHD_TUNE_REQUEST_POLICY_MANUAL, /*.dsp_freq_policy = */UHD_TUNE_REQUEST_POLICY_AUTO,
/*.dsp_freq =*/ srate/2, /*.dsp_freq =*/ 0,
/*.args =*/ 0 /*.args =*/ 0
}; };
UHD_DO(uhd_usrp_set_rx_freq(usrp, &rx_tune_request, m_channel, &rx_tune_result)); UHD_DO(uhd_usrp_set_rx_freq(usrp, &rx_tune_request, m_channel, &rx_tune_result));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册