---
This commit is contained in:
@@ -9,8 +9,8 @@ set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Charts Network)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Charts Network)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
main.cpp
|
||||
@@ -24,6 +24,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
MANUAL_FINALIZATION
|
||||
${PROJECT_SOURCES}
|
||||
res.qrc
|
||||
RecordQuery.h RecordQuery.cpp RecordQuery.ui
|
||||
LoggerWidget.h LoggerWidget.cpp LoggerWidget.ui
|
||||
)
|
||||
# Define target properties for Android with Qt 6 as:
|
||||
# set_property(TARGET Satellite APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
|
||||
@@ -43,7 +45,7 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(Satellite PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
target_link_libraries(Satellite PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Charts Qt${QT_VERSION_MAJOR}::Network)
|
||||
|
||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||
# If you are developing for iOS or macOS you should consider setting an
|
||||
|
||||
14
LoggerWidget.cpp
Normal file
14
LoggerWidget.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "LoggerWidget.h"
|
||||
#include "ui_LoggerWidget.h"
|
||||
|
||||
LoggerWidget::LoggerWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::LoggerWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
LoggerWidget::~LoggerWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
22
LoggerWidget.h
Normal file
22
LoggerWidget.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef LOGGERWIDGET_H
|
||||
#define LOGGERWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class LoggerWidget;
|
||||
}
|
||||
|
||||
class LoggerWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LoggerWidget(QWidget *parent = nullptr);
|
||||
~LoggerWidget();
|
||||
|
||||
private:
|
||||
Ui::LoggerWidget *ui;
|
||||
};
|
||||
|
||||
#endif // LOGGERWIDGET_H
|
||||
48
LoggerWidget.ui
Normal file
48
LoggerWidget.ui
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LoggerWidget</class>
|
||||
<widget class="QWidget" name="LoggerWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>584</width>
|
||||
<height>495</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>日志</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>清空</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
14
RecordQuery.cpp
Normal file
14
RecordQuery.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "RecordQuery.h"
|
||||
#include "ui_RecordQuery.h"
|
||||
|
||||
RecordQuery::RecordQuery(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::RecordQuery)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
RecordQuery::~RecordQuery()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
50
RecordQuery.h
Normal file
50
RecordQuery.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef RECORDQUERY_H
|
||||
#define RECORDQUERY_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDateTime>
|
||||
|
||||
enum class Channel{
|
||||
Uhf,
|
||||
S,
|
||||
BeiDou,
|
||||
};
|
||||
|
||||
enum class CommType{
|
||||
Call,
|
||||
ShortMessage,
|
||||
};
|
||||
|
||||
enum class CommDirection{
|
||||
Send,
|
||||
Receive,
|
||||
};
|
||||
|
||||
struct Record{
|
||||
QDateTime beginTime;
|
||||
Channel channel;
|
||||
CommType type;
|
||||
CommDirection direction;
|
||||
QString number;
|
||||
QString content;
|
||||
bool isUnread;
|
||||
};
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class RecordQuery;
|
||||
}
|
||||
|
||||
class RecordQuery : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RecordQuery(QWidget *parent = nullptr);
|
||||
~RecordQuery();
|
||||
|
||||
private:
|
||||
Ui::RecordQuery *ui;
|
||||
};
|
||||
|
||||
#endif // RECORDQUERY_H
|
||||
241
RecordQuery.ui
Normal file
241
RecordQuery.ui
Normal file
@@ -0,0 +1,241 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RecordQuery</class>
|
||||
<widget class="QWidget" name="RecordQuery">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>884</width>
|
||||
<height>677</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>历史记录查询</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_17">
|
||||
<property name="title">
|
||||
<string>记录查询</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_18">
|
||||
<property name="title">
|
||||
<string>过滤条件</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="chbCall">
|
||||
<property name="text">
|
||||
<string>通话</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="chbReceive">
|
||||
<property name="text">
|
||||
<string>接收</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="chbChannelBeiDou">
|
||||
<property name="text">
|
||||
<string>北斗</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="chbSend">
|
||||
<property name="text">
|
||||
<string>发送</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_42">
|
||||
<property name="text">
|
||||
<string>开始时间:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="chbMessage">
|
||||
<property name="text">
|
||||
<string>短消息</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_43">
|
||||
<property name="text">
|
||||
<string>方向:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>通道:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_44">
|
||||
<property name="text">
|
||||
<string>结束时间:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="text">
|
||||
<string>类型:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="text">
|
||||
<string>号码:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="chbChannelS">
|
||||
<property name="text">
|
||||
<string>S</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="chbChannelUHF">
|
||||
<property name="text">
|
||||
<string>UHF</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDateTimeEdit" name="dteBeginTime"/>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QDateTimeEdit" name="dteEndTime"/>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="cmbNumber">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_19">
|
||||
<property name="title">
|
||||
<string>记录列表</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tblRecordList">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>开始时间</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>通道</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>通信类型</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>方向</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>号码</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>通话时长</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>消息</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_22">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_45">
|
||||
<property name="text">
|
||||
<string>当前选择的消息内容:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="txtCurrentItemMessageContent">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
373
mainwindow.cpp
373
mainwindow.cpp
@@ -1,14 +1,375 @@
|
||||
#include "mainwindow.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QChartView>
|
||||
#include <QValueAxis>
|
||||
|
||||
#include <QBarCategoryAxis>
|
||||
#include <QBarSeries>
|
||||
#include <QBarSet>
|
||||
#include <QChart>
|
||||
#include <QLegend>
|
||||
|
||||
#include <QAreaSeries>
|
||||
#include <QLineSeries>
|
||||
#include <QPolarChart>
|
||||
#include <QScatterSeries>
|
||||
#include <QSplineSeries>
|
||||
|
||||
qreal get_rand(qreal maxValue) { return rand() * 1.0 / RAND_MAX * maxValue; }
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
createBeiDouSignalStrengthChart();
|
||||
createAzimuthMapChart();
|
||||
|
||||
ui->btnCallReject->hide();
|
||||
m_udpSocket = std::make_shared<QUdpSocket>();
|
||||
m_recordQueryWidget = std::make_shared<RecordQuery>();
|
||||
m_recordQueryWidget->hide();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
MainWindow::~MainWindow() { delete ui; }
|
||||
|
||||
void MainWindow::test() {
|
||||
|
||||
// 随机生成信号能量数据
|
||||
setSignalStrengthValues(
|
||||
QStringList{"1号星", "2号星", "3号星", "4号星", "5号星", "6号星"},
|
||||
QList{get_rand(10.0), get_rand(10.0), get_rand(10.0), get_rand(10.0),
|
||||
get_rand(10.0), get_rand(10.0)});
|
||||
|
||||
// 随机生成方向图数据
|
||||
QList<QPointF> values;
|
||||
for (int i = 0; i < 6; i += 1) {
|
||||
values.append(QPointF(get_rand(360.0), get_rand(360.0)));
|
||||
}
|
||||
setAzimuthValues(values);
|
||||
|
||||
Record r1;
|
||||
r1.beginTime = QDateTime::currentDateTime();
|
||||
r1.channel = Channel::Uhf;
|
||||
r1.type = CommType::ShortMessage;
|
||||
r1.direction = CommDirection::Receive;
|
||||
r1.number = "10001";
|
||||
r1.content = "地阿斯顿发射点发大水发大水发";
|
||||
r1.isUnread = true;
|
||||
|
||||
Record r2;
|
||||
r2.beginTime = QDateTime::currentDateTime();
|
||||
r2.channel = Channel::BeiDou;
|
||||
r2.type = CommType::ShortMessage;
|
||||
r2.direction = CommDirection::Send;
|
||||
r2.number = "10002";
|
||||
r2.content = "dsfgdsfgsdfgsdfgdfsgdsfgdsfg";
|
||||
r2.isUnread = false;
|
||||
|
||||
Record r3;
|
||||
r3.beginTime = QDateTime::currentDateTime();
|
||||
r3.channel = Channel::S;
|
||||
r3.type = CommType::Call;
|
||||
r3.direction = CommDirection::Receive;
|
||||
r3.number = "10003";
|
||||
r3.content = "fdghfgdhfghdfghdfghdfghf";
|
||||
r3.isUnread = true;
|
||||
|
||||
m_msgList.push_back(r1);
|
||||
m_msgList.push_back(r2);
|
||||
m_msgList.push_back(r3);
|
||||
UpdateMessageList();
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
void MainWindow::createBeiDouSignalStrengthChart() {
|
||||
|
||||
m_signalStrengthChart = new QChart;
|
||||
m_signalStrengthChart->setTitle("信号强度");
|
||||
m_signalStrengthChart->legend()->setVisible(false);
|
||||
m_signalStrengthChart->legend()->setAlignment(Qt::AlignBottom);
|
||||
// m_signalStrengthChart->setAnimationOptions(QChart::SeriesAnimations);
|
||||
|
||||
m_signalStrengthChartXAxis = new QBarCategoryAxis;
|
||||
m_signalStrengthChart->addAxis(m_signalStrengthChartXAxis, Qt::AlignBottom);
|
||||
|
||||
m_signalStrengthChartYAxis = new QValueAxis;
|
||||
m_signalStrengthChartYAxis->setRange(0, 10);
|
||||
m_signalStrengthChart->addAxis(m_signalStrengthChartYAxis, Qt::AlignLeft);
|
||||
// series->attachAxis(axisY);
|
||||
|
||||
QChartView *chartView = new QChartView(m_signalStrengthChart, this);
|
||||
chartView->setRenderHint(QPainter::Antialiasing);
|
||||
ui->vboxChannelBeidouSignalStrength->addWidget(chartView);
|
||||
}
|
||||
void MainWindow::setSignalStrengthValues(const QStringList &categories,
|
||||
const QList<qreal> &yValues) {
|
||||
m_signalStrengthChartXAxis->clear();
|
||||
m_signalStrengthChartXAxis->append(categories);
|
||||
|
||||
auto set0 = new QBarSet("Power");
|
||||
set0->append(yValues);
|
||||
QBarSeries *series = new QBarSeries;
|
||||
series->append(set0);
|
||||
m_signalStrengthChart->removeAllSeries();
|
||||
m_signalStrengthChart->addSeries(series);
|
||||
|
||||
ui->lblSatelliteCount->setText(QString::asprintf("%d", categories.count()));
|
||||
}
|
||||
void MainWindow::createAzimuthMapChart() {
|
||||
const qreal angularMin = 0;
|
||||
const qreal angularMax = 360;
|
||||
const qreal radialMin = 0;
|
||||
const qreal radialMax = 90;
|
||||
|
||||
m_azimuthChart = new QPolarChart;
|
||||
// m_azimuthChart->setTitle("");
|
||||
m_azimuthChart->legend()->setVisible(false);
|
||||
|
||||
auto angularAxis = new QValueAxis;
|
||||
angularAxis->setTickCount(9);
|
||||
angularAxis->setLabelFormat("%.1f");
|
||||
angularAxis->setShadesVisible(true);
|
||||
angularAxis->setShadesBrush(QBrush(QColor(249, 249, 255)));
|
||||
m_azimuthChart->addAxis(angularAxis, QPolarChart::PolarOrientationAngular);
|
||||
|
||||
auto radialAxis = new QValueAxis;
|
||||
radialAxis->setTickCount(7);
|
||||
radialAxis->setLabelFormat("%d");
|
||||
m_azimuthChart->addAxis(radialAxis, QPolarChart::PolarOrientationRadial);
|
||||
|
||||
radialAxis->setRange(radialMin, radialMax);
|
||||
angularAxis->setRange(angularMin, angularMax);
|
||||
|
||||
QChartView *chartView = new QChartView(m_azimuthChart, this);
|
||||
chartView->setRenderHint(QPainter::Antialiasing);
|
||||
ui->vboxAzimuthMap->addWidget(chartView);
|
||||
}
|
||||
void MainWindow::setAzimuthValues(const QList<QPointF> &points) {
|
||||
m_azimuthChart->removeAllSeries();
|
||||
auto series = new QScatterSeries;
|
||||
series->setName("方位");
|
||||
series->append(points);
|
||||
m_azimuthChart->addSeries(series);
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
// 消息列表操作
|
||||
//--------------------------------------------------------------------------------------
|
||||
void MainWindow::UpdateMessageList() {
|
||||
ui->tblMessageList->clear();
|
||||
QStringList column_labels;
|
||||
column_labels << "读取状态"
|
||||
<< "开始时间"
|
||||
<< "通道"
|
||||
<< "方向"
|
||||
<< "号码"
|
||||
<< "消息内容";
|
||||
// 设置列表行数和列数
|
||||
int rowCount = std::count_if(m_msgList.begin(),m_msgList.end(),[](const Record& r){ return r.type == CommType::ShortMessage;});
|
||||
ui->tblMessageList->setRowCount(rowCount); // 设置行数
|
||||
ui->tblMessageList->setColumnCount(column_labels.size()); // 设置列数
|
||||
// 设置水平表头
|
||||
ui->tblMessageList->setHorizontalHeaderLabels(column_labels);
|
||||
// 设置垂直表头
|
||||
// self.ui.tblTestList.setVerticalHeaderLabels([str(v) for v in
|
||||
// range(1,len(self.test_list)+1)]) 设置列宽
|
||||
int column_index = 0;
|
||||
ui->tblMessageList->setColumnWidth(column_index, 80); // 读取状态
|
||||
column_index = column_index + 1;
|
||||
ui->tblMessageList->setColumnWidth(column_index, 180); // 开始时间
|
||||
column_index = column_index + 1;
|
||||
ui->tblMessageList->setColumnWidth(column_index, 60); // 通道
|
||||
column_index = column_index + 1;
|
||||
ui->tblMessageList->setColumnWidth(column_index, 60); // 方向
|
||||
column_index = column_index + 1;
|
||||
ui->tblMessageList->setColumnWidth(column_index, 120); // 号码
|
||||
column_index = column_index + 1;
|
||||
ui->tblMessageList->setColumnWidth(column_index, 400); // 消息内容
|
||||
column_index = column_index + 1;
|
||||
|
||||
//插入所有项
|
||||
int rowIndex = 0;
|
||||
for (int index = 0; index < m_msgList.size(); index++) {
|
||||
Record r = m_msgList[index];
|
||||
int column_index = 0;
|
||||
// 读取状态
|
||||
auto item = new QTableWidgetItem(r.isUnread ? "未读" : "已读");
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tblMessageList->setItem(rowIndex, column_index, item);
|
||||
column_index = column_index + 1;
|
||||
// 开始时间
|
||||
item = new QTableWidgetItem(r.beginTime.toString("yyyy-MM-dd hh:mm:ss"));
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tblMessageList->setItem(rowIndex, column_index, item);
|
||||
column_index = column_index + 1;
|
||||
// 通道
|
||||
item = new QTableWidgetItem(r.channel == Channel::Uhf?"UHF":(r.channel==Channel::S?"S":"北斗"));
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tblMessageList->setItem(rowIndex, column_index, item);
|
||||
column_index = column_index + 1;
|
||||
// 方向
|
||||
item = new QTableWidgetItem(r.direction==CommDirection::Receive?"接收":"发送");
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tblMessageList->setItem(rowIndex, column_index, item);
|
||||
column_index = column_index + 1;
|
||||
// 号码
|
||||
item = new QTableWidgetItem(r.number);
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tblMessageList->setItem(rowIndex, column_index, item);
|
||||
column_index = column_index + 1;
|
||||
// 消息内容
|
||||
item = new QTableWidgetItem(r.content);
|
||||
ui->tblMessageList->setItem(rowIndex, column_index, item);
|
||||
column_index = column_index + 1;
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
// 槽函数
|
||||
//--------------------------------------------------------------------------------------
|
||||
void MainWindow::on_rdbChannelUHF_clicked() {
|
||||
ui->cmbCallNumber->setEnabled(true);
|
||||
ui->btnCallAnswer->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_rdbChannelS_clicked() {
|
||||
ui->cmbCallNumber->setEnabled(true);
|
||||
ui->btnCallAnswer->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_rdbChannelBeiDou_clicked() {
|
||||
if (m_callStatus == CallStatus::Idle) {
|
||||
ui->cmbCallNumber->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_rdbChannelAuto_clicked() {
|
||||
ui->cmbCallNumber->setEnabled(true);
|
||||
ui->btnCallAnswer->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_btnCallAnswer_clicked() {
|
||||
switch (m_callStatus) {
|
||||
case CallStatus::Idle: {
|
||||
// 检查电话号码是否为空
|
||||
QString number = ui->cmbCallNumber->currentText();
|
||||
if (number.isEmpty()) { // TODO:进一步判断电话号码格式是否满足要求
|
||||
QMessageBox::information(this, "错误", "请输入电话号码");
|
||||
return;
|
||||
}
|
||||
// TODO: 检查电话号码格式是否满足要求,比如长度
|
||||
|
||||
// 呼叫
|
||||
call(number);
|
||||
} break;
|
||||
case CallStatus::Incoming:
|
||||
// 接听
|
||||
acceptCall();
|
||||
break;
|
||||
case CallStatus::Calling:
|
||||
case CallStatus::Talking:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_btnCallReject_clicked() {
|
||||
switch (m_callStatus) {
|
||||
case CallStatus::Idle:
|
||||
break;
|
||||
case CallStatus::Calling:
|
||||
// 挂断
|
||||
hangUpCall();
|
||||
break;
|
||||
case CallStatus::Incoming:
|
||||
// 拒接
|
||||
rejectCall();
|
||||
break;
|
||||
case CallStatus::Talking:
|
||||
// 挂断
|
||||
hangUpCall();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_btnSendMessage_clicked() {
|
||||
// 检查电话号码是否为空
|
||||
QString number = ui->cmbMessageNumber->currentText();
|
||||
if (number.isEmpty()) {
|
||||
QMessageBox::information(this, "错误", "请输入电话号码");
|
||||
}
|
||||
// TODO: 检查电话号码格式是否满足要求,比如长度
|
||||
|
||||
// 检查消息是否为空
|
||||
QString message = ui->txtMessageContent->toPlainText();
|
||||
if (message.isEmpty()) {
|
||||
QMessageBox::information(this, "错误", "请输入要发送的消息");
|
||||
}
|
||||
// 检查消息长度
|
||||
if (message.length() > 140) {
|
||||
QMessageBox::information(this, "错误", "消息太长,不能超过140个字符");
|
||||
}
|
||||
|
||||
// 发送信息
|
||||
sendShortMessage(number, message);
|
||||
}
|
||||
|
||||
void MainWindow::on_tblMessageList_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
int currentRow = ui->tblMessageList->currentRow();
|
||||
if(currentRow == -1){
|
||||
ui->txtCurrentItemMessageContent->clear();
|
||||
}else{
|
||||
ui->txtCurrentItemMessageContent->setText(m_msgList[currentRow].content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_btnRecordQuery_clicked() {
|
||||
// m_recordQueryWidget->show();
|
||||
test();
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
// 与底层消息交互
|
||||
//--------------------------------------------------------------------------------------
|
||||
bool MainWindow::sendUdpMessage(const QByteArray &udpMessage) {
|
||||
const QHostAddress address("127.0.0.1");
|
||||
quint16 port = 8080;
|
||||
if (m_udpSocket->writeDatagram(udpMessage, address, port) !=
|
||||
udpMessage.size()) {
|
||||
// 发送错误
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool MainWindow::call(const QString &number) {
|
||||
// TODO:
|
||||
QString udpMessage = "";
|
||||
return sendUdpMessage(udpMessage.toUtf8());
|
||||
}
|
||||
bool MainWindow::hangUpCall() {
|
||||
// TODO:
|
||||
QString udpMessage = "";
|
||||
return sendUdpMessage(udpMessage.toUtf8());
|
||||
}
|
||||
bool MainWindow::acceptCall() {
|
||||
// TODO:
|
||||
QString udpMessage = "";
|
||||
return sendUdpMessage(udpMessage.toUtf8());
|
||||
}
|
||||
bool MainWindow::rejectCall() {
|
||||
// TODO:
|
||||
QString udpMessage = "";
|
||||
return sendUdpMessage(udpMessage.toUtf8());
|
||||
}
|
||||
bool MainWindow::sendShortMessage(const QString &number,
|
||||
const QString &message) {
|
||||
// TODO:
|
||||
QString udpMessage = "";
|
||||
return sendUdpMessage(udpMessage.toUtf8());
|
||||
}
|
||||
//--------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
66
mainwindow.h
66
mainwindow.h
@@ -1,7 +1,12 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QUdpSocket>
|
||||
#include <QMainWindow>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "RecordQuery.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
@@ -9,6 +14,20 @@ class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
enum class CallStatus{
|
||||
Idle,
|
||||
Calling,
|
||||
Incoming,
|
||||
Talking,
|
||||
};
|
||||
|
||||
|
||||
class QPolarChart;
|
||||
class QChart;
|
||||
class QBarCategoryAxis;
|
||||
class QValueAxis;
|
||||
class QTableWidgetItem;
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -16,8 +35,55 @@ class MainWindow : public QMainWindow
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
private slots:
|
||||
void on_rdbChannelUHF_clicked();
|
||||
|
||||
void on_rdbChannelS_clicked();
|
||||
|
||||
void on_rdbChannelBeiDou_clicked();
|
||||
|
||||
void on_rdbChannelAuto_clicked();
|
||||
|
||||
void on_btnCallAnswer_clicked();
|
||||
|
||||
void on_btnCallReject_clicked();
|
||||
|
||||
void on_btnSendMessage_clicked();
|
||||
|
||||
void on_btnRecordQuery_clicked();
|
||||
|
||||
void on_tblMessageList_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
|
||||
private:
|
||||
void createBeiDouSignalStrengthChart();
|
||||
void createAzimuthMapChart();
|
||||
void setSignalStrengthValues(const QStringList& categories,const QList<qreal> &yValues);
|
||||
void setAzimuthValues(const QList<QPointF> &points);
|
||||
//-------------------------------------------------
|
||||
// 消息列表操作
|
||||
//-------------------------------------------------
|
||||
void UpdateMessageList();
|
||||
//-------------------------------------------------
|
||||
// 与底层消息交互
|
||||
//-------------------------------------------------
|
||||
bool sendUdpMessage(const QByteArray &udpMessage);
|
||||
bool call(const QString& number);
|
||||
bool hangUpCall();
|
||||
bool acceptCall();
|
||||
bool rejectCall();
|
||||
bool sendShortMessage(const QString &number,const QString& message);
|
||||
|
||||
void test();
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
CallStatus m_callStatus = CallStatus::Idle;
|
||||
std::shared_ptr<QUdpSocket> m_udpSocket;
|
||||
std::shared_ptr<RecordQuery> m_recordQueryWidget;
|
||||
QChart* m_signalStrengthChart;
|
||||
QPolarChart* m_azimuthChart;
|
||||
QBarCategoryAxis* m_signalStrengthChartXAxis;
|
||||
QValueAxis* m_signalStrengthChartYAxis;
|
||||
|
||||
std::vector<Record> m_msgList;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
3184
mainwindow.ui
3184
mainwindow.ui
File diff suppressed because it is too large
Load Diff
3
res.qrc
3
res.qrc
@@ -3,8 +3,9 @@
|
||||
<file>res/call_cancelled.png</file>
|
||||
<file>res/circle_gray.png</file>
|
||||
<file>res/circle_green.png</file>
|
||||
<file>res/ic_call.png</file>
|
||||
<file>res/sim_gray.png</file>
|
||||
<file>res/sim_green.png</file>
|
||||
<file>res/call_accepted.png</file>
|
||||
<file>res/call_gray.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
res/call_accepted.png
Normal file
BIN
res/call_accepted.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 649 B |
BIN
res/call_gray.png
Normal file
BIN
res/call_gray.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 619 B |
Reference in New Issue
Block a user