增加地图缓存功能

This commit is contained in:
2022-09-15 09:07:38 +08:00
parent 7e6c5a9b42
commit f8383ab3ad
15 changed files with 564 additions and 284 deletions
+9
View File
@@ -15,6 +15,15 @@ SOURCES += \
## Capture whether this is a release/debug build.
#CONFIG(debug, debug|release)
#{
# LIBS += -L$$DESTDIR -linternalsd
#}
#CONFIG(release, debug|release)
#{
# LIBS += -L$$DESTDIR -linternals
#}
+76 -2
View File
@@ -521,6 +521,33 @@ void GlobalSetting::setMapSource(QStringList const &sources)
ui->comboMapSource->addItems(sources);
}
void GlobalSetting::setDefaultMapSource(const QString &mapName)
{
int index = ui->comboMapSource->findText(mapName);
if(index != -1)
{
ui->comboMapSource->setCurrentIndex(index);
}
}
void GlobalSetting::setLngLatRectRange(double lng1, double lat1, double lng2, double lat2)
{
ui->dSpinStartLng->setValue(lng1);
ui->dSpinStartLat->setValue(lat1);
ui->dSpinEndLng->setValue(lng2);
ui->dSpinEndLat->setValue(lat2);
}
void GlobalSetting::setProgressBarValue(int value)
{
ui->progressBar->setValue(value);
}
void GlobalSetting::setMapSaveGrade(int zoom)
{
ui->labMapGrade->setText(QString("地图级别:%1").arg(zoom) );
}
void GlobalSetting::on_pushButton_readVirtualMargin_clicked()
{
getVirtualMargin();
@@ -558,8 +585,8 @@ void GlobalSetting::on_pushButton_InfoExport_clicked()
void GlobalSetting::on_comboMapSource_currentIndexChanged(int index)
{
QVariant value(ui->comboMapSource->currentText() );
Config *config = new Config();
QVariant value(index);
config->setMapType(value);
delete config;
@@ -569,6 +596,53 @@ void GlobalSetting::on_comboMapSource_currentIndexChanged(int index)
void GlobalSetting::on_btnRectRange_clicked()
{
emit dumpToMap();
emit goToBase();
}
void GlobalSetting::on_pushButton_clicked()
{
//获取需要保存地图级别
internals::RectLatLng range = internals::RectLatLng::FromLTRB(ui->dSpinStartLng->value(), ui->dSpinStartLat->value(),
ui->dSpinEndLng->value(), ui->dSpinEndLat->value() );
QList<QCheckBox*> temp = ui->groupMapGrade->findChildren<QCheckBox*>(); //获取QCheckBox
QList<int> grades;
foreach(QCheckBox *chk, temp)
{
if(chk->isChecked() )
{
grades << chk->text().toInt();
}
}
std::sort(grades.begin(), grades.end() ); //排序
setMapSaveGrade(grades[0]);
emit mapSave(range, grades);
}
void GlobalSetting::on_btnLogin_clicked()
{
int proxyIndex = ui->chkProxyType->currentIndex(); //获取coboBox的当前索引值
QNetworkProxy::ProxyType proxyType;
switch(proxyIndex) //根据当前索引值获取代理类型
{
case 0:
proxyType = QNetworkProxy::NoProxy; break;
case 1:
proxyType = QNetworkProxy::HttpProxy; break;
case 2:
proxyType = QNetworkProxy::Socks5Proxy; break;
}
QHostAddress addr(ui->editAddr->text() ); //获取地址
int port = ui->editPort->text().toInt(); //获取端口号
emit switchProxy(proxyType, addr, port); //发送切换代理的信号
}
+71 -4
View File
@@ -4,6 +4,9 @@
#include <QWidget>
#include "QDebug"
#include "Config/Config.h"
#include "../../bin/include/rectlatlng.h"
#include <QHostAddress>
#include <QNetworkProxy>
namespace Ui {
@@ -33,7 +36,16 @@ public:
void getExportInfo(void);
void getVirtualMargin(void);
void setVirtualMargin(void);
void setMapSource(QStringList const &sources); //设置地图源
/**
* @brief 设置所有支持的地图源
* @param sources 地图源列表
*/
void setMapSource(QStringList const &sources);
/**
* @brief 设置默认的地图源
* @param mapName
*/
void setDefaultMapSource(QString const &mapName);
@@ -42,8 +54,29 @@ public:
QMap<int, Config::_latlng> drop1;
QMap<int, Config::_latlng> drop2;
public slots:
/**
* @brief 设置需要缓存的经纬度范围
* @param lng1 左上角经度
* @param lat1 左上角纬度
* @param lng2 右下角经度
* @param lat2 右下角纬度
*/
void setLngLatRectRange(double lng1, double lat1, double lng2, double lat2);
/**
* @brief 设置当前缓存地图级别进度条的值
* @param value 当前进度条的值
*/
void setProgressBarValue(int value);
/**
* @brief 更改当前正在缓存的地图级别
* @param zoom 当前正在缓存的地图级别
*/
void setMapSaveGrade(int zoom);
private slots:
void on_pushButton_setGCSID_clicked();
void on_pushButton_getServoOffset_clicked();
@@ -64,11 +97,42 @@ private slots:
void on_pushButton_InfoExport_clicked();
/**
* @brief 当用户需要更换地图源的时候,发出信号
* @param index是QComboBox当前项索引
*/
void on_comboMapSource_currentIndexChanged(int index);
/**
* @brief 发出转到base界面的信号,让用户框选范围
*/
void on_btnRectRange_clicked();
/**
* @brief 发出缓存地图的信号
*/
void on_pushButton_clicked();
/**
* @brief 登录代理
*/
void on_btnLogin_clicked();
signals:
/**
* @brief 切换代理的信号
* @param type 代理类型
* @param addr 地址
* @param port 端口
*/
void switchProxy(QNetworkProxy::ProxyType type, QHostAddress const &addr, int port);
/**
* @brief 保存地图的信号
* @param area是地图缓存的范围
* @param grades是一些缓存地图级别
*/
void mapSave(internals::RectLatLng const &area, QList<int> const &grades);
/**
* @brief 转到Base界面的信号
*/
void goToBase();
void showMessage(const QString &message,int TimeOut = 0);
void setGCSID(int id);
@@ -93,8 +157,11 @@ signals:
void setExportInfo(QVariant value,QVariant id);
void setMapTypes(QVariant const &value);
void dumpToMap();
/**
* @brief 更换地图源的信号
* @param value是地图源类型
*/
void setMapTypes(QVariant value);
private:
Ui::GlobalSetting *ui;
+266 -237
View File
@@ -553,201 +553,147 @@
<string>地图设置</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>地图级别</string>
<item row="6" column="1" colspan="2">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout_7">
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labMapGrade">
<property name="text">
<string>地图级别:</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_7">
<property name="title">
<string>代理</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="2" column="1">
<widget class="QCheckBox" name="checkBox_7">
<property name="text">
<string>6</string>
<widget class="QLineEdit" name="editPort">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string>4</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QCheckBox" name="checkBox_23">
<property name="text">
<string>22</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="checkBox_14">
<property name="text">
<string>13</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="checkBox_22">
<property name="text">
<string>21</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QCheckBox" name="checkBox_24">
<property name="text">
<string>23</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="checkBox_20">
<property name="text">
<string>19</string>
</property>
<item row="0" column="1">
<widget class="QComboBox" name="chkProxyType">
<item>
<property name="text">
<string>不使用代理</string>
</property>
</item>
<item>
<property name="text">
<string>HTTP代理</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS代理</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_6">
<widget class="QLabel" name="label_24">
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QCheckBox" name="checkBox_25">
<property name="text">
<string>24</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_21">
<property name="text">
<string>20</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="checkBox_9">
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="checkBox_18">
<property name="text">
<string>17</string>
<string>端口:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_16">
<widget class="QLabel" name="label_26">
<property name="text">
<string>15</string>
<string>密 码:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="checkBox_19">
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>18</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="checkBox_8">
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="checkBox_15">
<property name="text">
<string>14</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBox_12">
<property name="text">
<string>11</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="checkBox_13">
<property name="text">
<string>12</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>3</string>
<string>类型:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_11">
<widget class="QLabel" name="label_25">
<property name="text">
<string>10</string>
<string>用户名:</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QCheckBox" name="checkBox_10">
<property name="text">
<string>9</string>
<item row="1" column="1">
<widget class="QLineEdit" name="editAddr">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBox_17">
<property name="text">
<string>16</string>
<widget class="QLineEdit" name="lineEdit_4">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox">
<widget class="QLabel" name="label_23">
<property name="text">
<string>0</string>
<string>地址:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="btnLogin">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>登录</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>区域选择</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox">
<widget class="QDoubleSpinBox" name="dSpinStartLng">
<property name="suffix">
<string>°</string>
</property>
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
@@ -785,10 +731,13 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_2">
<widget class="QDoubleSpinBox" name="dSpinStartLat">
<property name="suffix">
<string>°</string>
</property>
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
@@ -800,12 +749,15 @@
<item row="4" column="0">
<widget class="QLabel" name="label_28">
<property name="text">
<string>终点度:</string>
<string>终点度:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_3">
<widget class="QDoubleSpinBox" name="dSpinEndLng">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
@@ -815,7 +767,10 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_4">
<widget class="QDoubleSpinBox" name="dSpinEndLat">
<property name="decimals">
<number>8</number>
</property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
@@ -827,110 +782,184 @@
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>开始缓存</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_7">
<item row="3" column="0" colspan="3">
<widget class="QGroupBox" name="groupMapGrade">
<property name="title">
<string>代理</string>
<string>地图级别</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="2" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>端口:</string>
</property>
</widget>
</item>
<layout class="QGridLayout" name="gridLayout_7">
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_2">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_23">
<widget class="QCheckBox" name="chk6">
<property name="text">
<string>地址:</string>
<string>6</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_2">
<item>
<property name="text">
<string>不使用代理</string>
</property>
</item>
<item>
<property name="text">
<string>HTTP代理</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS代理</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_25">
<item row="1" column="4">
<widget class="QCheckBox" name="chk4">
<property name="text">
<string>用户名:</string>
<string>4</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_4">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_22">
<item row="5" column="2">
<widget class="QCheckBox" name="chk22">
<property name="text">
<string>类型:</string>
<string>22</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="chk13">
<property name="text">
<string>13</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="chk21">
<property name="text">
<string>21</string>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QCheckBox" name="chk23">
<property name="text">
<string>23</string>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QCheckBox" name="chk19">
<property name="text">
<string>19</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chk5">
<property name="text">
<string>5</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="chk2">
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="QCheckBox" name="chk24">
<property name="text">
<string>24</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="chk20">
<property name="text">
<string>20</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="chk8">
<property name="text">
<string>8</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="chk17">
<property name="text">
<string>17</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_26">
<widget class="QCheckBox" name="chk15">
<property name="text">
<string>密 码:</string>
<string>15</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QCheckBox" name="chk18">
<property name="text">
<string>18</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="chk7">
<property name="text">
<string>7</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="chk14">
<property name="text">
<string>14</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chk1">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
<widget class="QCheckBox" name="chk11">
<property name="text">
<string>11</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="chk12">
<property name="text">
<string>12</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="chk3">
<property name="text">
<string>3</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chk10">
<property name="text">
<string>10</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QCheckBox" name="chk9">
<property name="text">
<string>9</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="chk16">
<property name="text">
<string>16</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chk0">
<property name="text">
<string>0</string>
</property>
</widget>
</item>
@@ -944,7 +973,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="comboMapSource">
<property name="minimumSize">
<size>
@@ -954,10 +983,10 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
<item row="0" column="0" colspan="3">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>开始缓存</string>
</property>
</widget>
</item>