提交 c4292c28 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Qt 6 兼容性修改(win)

上级 67aa313a
......@@ -2,12 +2,10 @@ TEMPLATE = subdirs
#main framework project
SUBDIRS += sources/source_plutosdr \
sources/source_soundcard \
transforms/transform_fft \
transforms/mod_fm \
sources/source_files \
sinks/sink_file \
sinks/sink_soundcard \
sinks/sink_plutosdr \
network/network_p2p \
sinks/sink_SQL \
......@@ -19,3 +17,8 @@ qtHaveModule(charts){
SUBDIRS += \
sinks/sink_plots
}
qtHaveModule(multimedia){
SUBDIRS += \
sinks/sink_soundcard \
sources/source_soundcard
}
......@@ -2,6 +2,7 @@
#include <QThread>
#include <QFile>
#include <QTextStream>
#include <QLocale>
#include "listen_thread.h"
#include "cmdlineparser.h"
#include "tb_interface.h"
......
......@@ -2,6 +2,7 @@
#include <QThread>
#include <QFile>
#include <QTextStream>
#include <QLocale>
#include "listen_thread.h"
#include "cmdlineparser.h"
#include "tb_interface.h"
......
/*
/*
* Copyright 2015 Ettus Research LLC
* Copyright 2018 Ettus Research, a National Instruments Company
*
......@@ -13,6 +13,7 @@
#include "cmdlineparser.h"
#include "tb_interface.h"
#include <QFile>
#include <QLocale>
#ifdef Q_OS_LINUX
#include <unistd.h>
#endif
......@@ -23,48 +24,48 @@ int do_iio(const cmdlineParser & args);
int main(int argc, char * argv[])
{
QCoreApplication a(argc, argv);
init_client();
QCoreApplication a(argc, argv);
init_client();
#ifdef OFFLINEDEBUG
FILE * old_stdin, *old_stdout;
auto ars = debug("D:\\pid1008",&old_stdin,&old_stdout);
const cmdlineParser args (ars);
FILE * old_stdin, *old_stdout;
auto ars = debug("D:\\pid1008",&old_stdin,&old_stdout);
const cmdlineParser args (ars);
#else
const cmdlineParser args (argc,argv);
const cmdlineParser args (argc,argv);
#endif
int ret = 0;
QTextStream stmerr(stderr);
//每个模块要响应 --information参数,打印自己的功能定义字符串。或者提供一个json文件。
if (args.contains("information"))
{
QFile fp(":/uhd_usrp_continous."+QLocale::system().name()+".json");
if (!fp.open(QIODevice::ReadOnly))
{
fp.setFileName(":/uhd_usrp_continous.json");
fp.open(QIODevice::ReadOnly);
}
if (fp.isOpen())
{
QByteArray arr = fp.readAll();
arr.push_back('\0');
puts(arr.constData());
fflush(stdout);
}
ret = -1;
}
else if (args.contains("function"))//正常运行模式
{
int ret = 0;
QTextStream stmerr(stderr);
//每个模块要响应 --information参数,打印自己的功能定义字符串。或者提供一个json文件。
if (args.contains("information"))
{
QFile fp(":/uhd_usrp_continous."+QLocale::system().name()+".json");
if (!fp.open(QIODevice::ReadOnly))
{
fp.setFileName(":/uhd_usrp_continous.json");
fp.open(QIODevice::ReadOnly);
}
if (fp.isOpen())
{
QByteArray arr = fp.readAll();
arr.push_back('\0');
puts(arr.constData());
fflush(stdout);
}
ret = -1;
}
else if (args.contains("function"))//正常运行模式
{
fprintf(stderr,"Entering Loop...\n");
//用于接收消息的线程
ret = do_iio(args);
}
else
{
stmerr<<"Error:Function does not exits.\n";
ret = -1;
}
return ret;
//用于接收消息的线程
ret = do_iio(args);
}
else
{
stmerr<<"Error:Function does not exits.\n";
ret = -1;
}
return ret;
......
/*!
/*!
@author goldenhawking@163.com
@date 2017-02-11
*/
......@@ -32,20 +32,27 @@ namespace TASKBUS {
void set_proc_nice(QProcess * p, int nice)
{
#ifdef WIN32
Q_PID id = p->pid();
const DWORD dw_pn []= {
IDLE_PRIORITY_CLASS,
BELOW_NORMAL_PRIORITY_CLASS,
NORMAL_PRIORITY_CLASS,
ABOVE_NORMAL_PRIORITY_CLASS,
HIGH_PRIORITY_CLASS,
REALTIME_PRIORITY_CLASS
};
if (nice<0) nice = 0;
if (nice>5) nice = 5;
SetPriorityClass(id->hProcess,dw_pn[nice]);
#endif
#ifdef WIN32
qint64 id = p->processId();
HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,
FALSE,id);
if (hProcess)
{
const DWORD dw_pn []= {
IDLE_PRIORITY_CLASS,
BELOW_NORMAL_PRIORITY_CLASS,
NORMAL_PRIORITY_CLASS,
ABOVE_NORMAL_PRIORITY_CLASS,
HIGH_PRIORITY_CLASS,
REALTIME_PRIORITY_CLASS
};
if (nice<0) nice = 0;
if (nice>5) nice = 5;
SetPriorityClass(hProcess,dw_pn[nice]);
CloseHandle(hProcess);
}
#endif
#ifdef linux
Q_PID id = p->pid();
......@@ -59,7 +66,7 @@ namespace TASKBUS {
void set_proc_nice (int nice)
{
#ifdef WIN32
#ifdef WIN32
const DWORD dw_pn []= {
IDLE_PRIORITY_CLASS,
BELOW_NORMAL_PRIORITY_CLASS,
......@@ -71,7 +78,7 @@ namespace TASKBUS {
if (nice<0) nice = 0;
if (nice>5) nice = 5;
SetPriorityClass(GetCurrentProcess(),dw_pn[nice]);
#endif
#endif
#ifdef linux
Q_PID id = getpid();
......@@ -96,7 +103,7 @@ namespace TASKBUS {
QString l = s.readLine();
while (l.size() && hit<2)
{
QStringList lst = l.split(":",QString::SkipEmptyParts);
QStringList lst = l.split(":",Qt::SkipEmptyParts);
if (lst.size()>=2)
{
QString keystr = lst.first().trimmed();
......@@ -158,14 +165,34 @@ namespace TASKBUS {
}
else if (p)
{
GetModuleFileNameExA((HMODULE)p,0,ch_module,MAX_PATH);
info->pid = GetProcessId((HMODULE)p);
HANDLE hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|
PROCESS_VM_READ,
FALSE,p);
info->pid = 0;
if (hProcess)
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleFileNameExA(hProcess,hMod,ch_module,MAX_PATH);
PROCESS_MEMORY_COUNTERS pmc;
GetProcessMemoryInfo(hProcess,&pmc,sizeof(pmc));
info->m_memsize = pmc.WorkingSetSize;
}
info->pid = p;
}
//printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
if (info->pid==0)
return false;
info->phandle = (qint64)p;
PROCESS_MEMORY_COUNTERS pmc;
GetProcessMemoryInfo((HMODULE)p,&pmc,sizeof(pmc));
info->m_memsize = pmc.WorkingSetSize;
}
char * pt =ch_module + strlen(ch_module)-1;
while (pt > ch_module)
......@@ -192,7 +219,7 @@ namespace TASKBUS {
#endif
#ifdef WIN32
if (p)
return (qint64)p->pid()->hProcess;
return (qint64)p->processId();
else
return (qint64)GetCurrentProcess();
#endif
......
......@@ -312,7 +312,7 @@ QString taskCell::set_function_exec(const QString & func , const QString & execs
}
const QString taskCell::function_class(const QString & func) const
{
QStringList strV = func.split(QRegExp("[:_]"),QString::SkipEmptyParts);
QStringList strV = func.split(QRegularExpression("[:_]"),Qt::SkipEmptyParts);
if (strV.size()>1)
{
strV.pop_back();
......@@ -713,7 +713,7 @@ QVariant taskCell::view_to_internal(const QVariant & vtdef
else if (targetType==QVariant::List)
{
QString strVal = vtdef.toString();
QStringList lstv = strVal.split(",",QString::SkipEmptyParts);
QStringList lstv = strVal.split(",",Qt::SkipEmptyParts);
QVariantList lsttag;
foreach(QString vii, lstv)
{
......@@ -739,7 +739,7 @@ QVariant taskCell::view_to_internal(const QVariant & vtdef
QString taskCell::pureName(const QVariant & v)
{
QString sv = v.toString();
QStringList ls = sv.split(QRegExp("[:_]"),QString::SkipEmptyParts);
QStringList ls = sv.split(QRegularExpression("[:_]"),Qt::SkipEmptyParts);
if (ls.size())
return ls.last();
return QString("");
......@@ -758,7 +758,7 @@ QString taskCell::pureName(const QVariant & v)
QString taskCell::className(const QVariant & v)
{
QString sv = v.toString();
QStringList ls = sv.split(QRegExp("[:_]"),QString::SkipEmptyParts);
QStringList ls = sv.split(QRegularExpression("[:_]"),Qt::SkipEmptyParts);
QString res;
while (ls.size()>1)
{
......
......@@ -369,8 +369,8 @@ void PDesignerView::update_paths()
const QList<unsigned int> srcs = m_project->idx_in2instances().keys();
const QList<unsigned int> dsts = m_project->idx_out2instances().keys();
const QSet<unsigned int> setin = QSet<unsigned int>::fromList(srcs);
const QSet<unsigned int> setout = QSet<unsigned int>::fromList(dsts);
const QSet<unsigned int> setin = QSet<unsigned int>(srcs.begin(),srcs.end());
const QSet<unsigned int> setout = QSet<unsigned int>(dsts.begin(),dsts.end());
QEasingCurve cuve(QEasingCurve::InOutCubic);
......
......@@ -91,7 +91,7 @@ void taskBusPlatformFrm::timerEvent(QTimerEvent *event)
if (m_nTmid==event->timerId())
{
extern QAtomicInt g_totalrev, g_totalsent;
QString s = QString().sprintf("down %.2lf Mbps, up %.2lf Mbps",
QString s = QString().asprintf("down %.2lf Mbps, up %.2lf Mbps",
g_totalrev * 8.0 / 1024 / 1024,
g_totalsent * 8.0 / 1024 / 1024
);
......
......@@ -5,7 +5,7 @@
#include <QMimeData>
#include <QBrush>
#include <QDataStream>
#include <QIODevice>
QSet<int> taskModule::m_pinInsValues;
taskModule::taskModule(QObject *parent)
......@@ -449,7 +449,7 @@ int taskModule::draw_direction(const QString & func, bool bInput, int n) const
strMasks = mp["IND"].toString();
else
strMasks = mp["OUTD"].toString();
QStringList lstMasks = strMasks.split(",",QString::SkipEmptyParts);
QStringList lstMasks = strMasks.split(",",Qt::SkipEmptyParts);
if (lstMasks.size()<=n)
return bInput==true?-(n+1):(n+1);
QString nn = lstMasks.at(n);
......@@ -488,7 +488,7 @@ void taskModule::set_draw_direction(const QString & func, bool bInput, int n, in
strMasks = mp["IND"].toString();
else
strMasks = mp["OUTD"].toString();
QStringList lstMasks = strMasks.split(",",QString::SkipEmptyParts);
QStringList lstMasks = strMasks.split(",",Qt::SkipEmptyParts);
QString strVal;
const int sz = lstMasks.size();
QString nstr = QString("%1").arg(direction);
......
#include "tbwatchdog.h"
#include "tbwatchdog.h"
#include <QDebug>
#include <QTimerEvent>
#include <QVector>
......
#include "watchmemmodule.h"
#include "watchmemmodule.h"
#include <QDebug>
WatchMemModule::WatchMemModule(QObject *parent) : QAbstractTableModel(parent)
{
......@@ -35,7 +35,7 @@ QVariant WatchMemModule::headerData(int section, Qt::Orientation orientation, in
else if (orientation==Qt::Vertical)
{
QString strV;
strV.sprintf("%d",section);
strV.asprintf("%d",section);
return strV;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册