航线可以拖入

This commit is contained in:
hm
2022-03-30 16:56:32 +08:00
parent e67e1d2463
commit 98a02885ce
4 changed files with 199 additions and 3 deletions
+52
View File
@@ -47,6 +47,10 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
QCoreApplication::installTranslator(translator);
*/
//this->setAcceptDrops(true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
core = new internals::Core;
@@ -59,6 +63,8 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
map = new MapGraphicItem(core, config);
//map->setAcceptDrops(true);
mscene.addItem(map);//添加图层
this->setScene(&mscene);
@@ -106,6 +112,38 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
NoOperationTimer->start(20000);//20s不操作
}
void OPMapWidget::dragEnterEvent(QDragEnterEvent *event)
{
QString suffix = event->mimeData()->urls()[0].fileName().right(5);
if(!suffix.compare(tr(".plan")))
{
event->acceptProposedAction();
}
else
{
event->ignore();
}
}
void OPMapWidget::dropEvent(QDropEvent *event)
{
const QMimeData *qm = event->mimeData();
QString fileName = qm->urls()[0].toLocalFile();
if(fileName.right(5) == ".plan")
{
//setCommandFile(fileName);
//loadCommandJson(fileName);
WPLoad(fileName);
}
}
void OPMapWidget::SetShowDiagnostics(bool const & value)
{
showDiag = value;
@@ -1183,6 +1221,20 @@ void OPMapWidget::setWPCreate(bool const & value)
{
isWPCreate = value;
if(map)
{
if(value)
{
map->setAcceptDrops(true);
}
else
{
map->setAcceptDrops(false);
}
}
if(altitudeitem)
{
if(value)