rename libs/piqt_widgtes to libs/piqt_utils
add PIVariantEdit for PIGeoPosition
This commit is contained in:
@@ -1 +1 @@
|
||||
qad_library(map "Gui;Widgets;Network" "qad_utils")
|
||||
qad_library(map "Gui;Widgets;Network;Positioning" "qad_utils;qad_piqt_utils")
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "qad_map_export.h"
|
||||
|
||||
#include <QCursor>
|
||||
#include <QGeoCoordinate>
|
||||
#include <QMap>
|
||||
#include <QPainter>
|
||||
#include <QRectF>
|
||||
@@ -58,7 +59,8 @@ public:
|
||||
|
||||
QPointF position() const { return m_position; }
|
||||
void setPosition(QPointF geo);
|
||||
void setPosition(double lat, double lng) { setPosition({lat, lng}); }
|
||||
void setPosition(double lat, double lng) { setPosition(QPointF(lat, lng)); }
|
||||
void setPosition(QGeoCoordinate c) { setPosition(QPointF(c.latitude(), c.longitude())); }
|
||||
|
||||
QPointF offset() const { return m_offset; }
|
||||
void setOffset(QPointF pixels);
|
||||
|
||||
@@ -86,7 +86,10 @@ void MapView::mousePressEvent(QMouseEvent * e) {
|
||||
|
||||
void MapView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
if (!is_pan) {
|
||||
if (hover) emit itemClicked(hover);
|
||||
if (hover)
|
||||
emit itemClicked(hover);
|
||||
else
|
||||
emit mapClicked(last_click_coord);
|
||||
}
|
||||
is_pan = false;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "mapitembase.h"
|
||||
#include "qad_map_export.h"
|
||||
|
||||
#include <QGeoCoordinate>
|
||||
#include <QImage>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -48,6 +49,7 @@ public:
|
||||
|
||||
QPointF center() const;
|
||||
void setCenter(QPointF c);
|
||||
void setCenter(QGeoCoordinate c) { setCenter(QPointF(c.latitude(), c.longitude())); }
|
||||
|
||||
double getZoom() const { return zoom_; }
|
||||
void setZoom(double z);
|
||||
@@ -101,6 +103,7 @@ public slots:
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
void mapClicked(QPointF);
|
||||
void itemClicked(MapItemBase * item);
|
||||
void itemEntered(MapItemBase * item);
|
||||
void itemLeaved(MapItemBase * item);
|
||||
|
||||
63
libs/map/pivariant_geoposition.cpp
Normal file
63
libs/map/pivariant_geoposition.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "pivariant_geoposition.h"
|
||||
|
||||
#include "mapitemimage.h"
|
||||
#include "piqt.h"
|
||||
#include "pivaluetree.h"
|
||||
#include "ui_pivariant_geoposition.h"
|
||||
#include "ui_pivariant_geoposition_map.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
REGISTER_PIVARIANTEDITOR(PIGeoPosition, PIVariantEditors::GeoPosition);
|
||||
|
||||
#define GeoUI reinterpret_cast<Ui::GeoPosition *>(ui)
|
||||
|
||||
using Attribute = PIValueTree::Attribute;
|
||||
|
||||
|
||||
PIVariantEditors::GeoPosition::GeoPosition() {
|
||||
QWidget * w = new QWidget();
|
||||
ui = new Ui::GeoPosition();
|
||||
GeoUI->setupUi(w);
|
||||
layout()->addWidget(w);
|
||||
connect(GeoUI->buttonMap, &QToolButton::clicked, this, [this]() {
|
||||
QDialog dlg;
|
||||
Ui::GeoPositionMap ui;
|
||||
ui.setupUi(&dlg);
|
||||
ui.map->setCenter(PI2QGeoPosition(value().value<PIGeoPosition>()));
|
||||
auto * item = new MapItemImage(QPixmap(":/icons/location.png"));
|
||||
item->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||
item->setScale(0.333 * appScale(this));
|
||||
item->setPosition(ui.map->center());
|
||||
ui.map->addItem(item);
|
||||
connect(ui.map, &MapView::mapClicked, this, [item](QPointF c) { item->setPosition(c); });
|
||||
if (dlg.exec() != QDialog::Accepted) return;
|
||||
PIGeoPosition gp({item->position().x(), item->position().y(), 0.}, PIGeoPosition::Geodetic);
|
||||
setValue(PIVariant::fromValue(gp));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
PIVariantEditors::GeoPosition::~GeoPosition() {
|
||||
delete GeoUI;
|
||||
}
|
||||
|
||||
|
||||
void PIVariantEditors::GeoPosition::setValue(const PIVariant & v) {
|
||||
val = v.value<PIGeoPosition>();
|
||||
GeoUI->line->setText(PI2QString(v.toString()));
|
||||
}
|
||||
|
||||
|
||||
PIVariant PIVariantEditors::GeoPosition::value() const {
|
||||
PIGeoPosition g = __PIVariantFunctions__<PIString>::castVariant<PIGeoPosition>(Q2PIString(GeoUI->line->text()));
|
||||
return PIVariant::fromValue(g);
|
||||
}
|
||||
|
||||
|
||||
void PIVariantEditors::GeoPosition::applyAttributes(const PIVariantMap & a) {
|
||||
bool ro = a.value(Attribute::readOnly, GeoUI->line->isReadOnly()).toBool();
|
||||
GeoUI->line->setReadOnly(ro);
|
||||
GeoUI->buttonMap->setHidden(ro);
|
||||
}
|
||||
48
libs/map/pivariant_geoposition.h
Normal file
48
libs/map/pivariant_geoposition.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef pivariant_geoposition_H
|
||||
#define pivariant_geoposition_H
|
||||
|
||||
#include "mapview.h"
|
||||
#include "pigeoposition.h"
|
||||
#include "pivariant_edit.h"
|
||||
|
||||
namespace PIVariantEditors {
|
||||
|
||||
class QAD_MAP_EXPORT GeoPosition: public PIVariantEditorBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GeoPosition();
|
||||
~GeoPosition();
|
||||
void setValue(const PIVariant & v) override;
|
||||
PIVariant value() const override;
|
||||
|
||||
protected:
|
||||
void applyAttributes(const PIVariantMap & a) override;
|
||||
void * ui = nullptr;
|
||||
PIGeoPosition val;
|
||||
};
|
||||
|
||||
|
||||
}; // namespace PIVariantEditors
|
||||
|
||||
|
||||
#endif
|
||||
113
libs/map/pivariant_geoposition.ui
Normal file
113
libs/map/pivariant_geoposition.ui
Normal file
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GeoPosition</class>
|
||||
<widget class="QWidget" name="GeoPosition">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>57</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="line"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonMap">
|
||||
<property name="toolTip">
|
||||
<string>Select on map ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_map.qrc">
|
||||
<normaloff>:/icons/maps.png</normaloff>:/icons/maps.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionRemove">
|
||||
<property name="icon">
|
||||
<iconset resource="../blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChange">
|
||||
<property name="icon">
|
||||
<iconset resource="../application/qad_application.qrc">
|
||||
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Change ...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRename">
|
||||
<property name="icon">
|
||||
<iconset resource="../graphic/qad_graphic.qrc">
|
||||
<normaloff>:/icons/border-line.png</normaloff>:/icons/border-line.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rename ...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionValue">
|
||||
<property name="icon">
|
||||
<iconset resource="../piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/code-variable.png</normaloff>:/icons/code-variable.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGroup">
|
||||
<property name="icon">
|
||||
<iconset resource="../piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/code-struct.png</normaloff>:/icons/code-struct.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionArray">
|
||||
<property name="icon">
|
||||
<iconset resource="../piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/code-union.png</normaloff>:/icons/code-union.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Array</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReorder">
|
||||
<property name="icon">
|
||||
<iconset resource="../graphic/qad_graphic.qrc">
|
||||
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reorder ...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../application/qad_application.qrc"/>
|
||||
<include location="../blockview/qad_blockview.qrc"/>
|
||||
<include location="../graphic/qad_graphic.qrc"/>
|
||||
<include location="qad_map.qrc"/>
|
||||
<include location="../piqt_utils/qad_piqt_widgets.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
143
libs/map/pivariant_geoposition_map.ui
Normal file
143
libs/map/pivariant_geoposition_map.ui
Normal file
@@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GeoPositionMap</class>
|
||||
<widget class="QDialog" name="GeoPositionMap">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>683</width>
|
||||
<height>634</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select on map</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="MapView" name="map">
|
||||
<property name="zoom">
|
||||
<double>15.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionRemove">
|
||||
<property name="icon">
|
||||
<iconset resource="../blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChange">
|
||||
<property name="icon">
|
||||
<iconset resource="../application/qad_application.qrc">
|
||||
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Change ...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRename">
|
||||
<property name="icon">
|
||||
<iconset resource="../graphic/qad_graphic.qrc">
|
||||
<normaloff>:/icons/border-line.png</normaloff>:/icons/border-line.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rename ...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionValue">
|
||||
<property name="icon">
|
||||
<iconset resource="../piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/code-variable.png</normaloff>:/icons/code-variable.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionGroup">
|
||||
<property name="icon">
|
||||
<iconset resource="../piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/code-struct.png</normaloff>:/icons/code-struct.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionArray">
|
||||
<property name="icon">
|
||||
<iconset resource="../piqt_utils/qad_piqt_widgets.qrc">
|
||||
<normaloff>:/icons/code-union.png</normaloff>:/icons/code-union.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Array</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReorder">
|
||||
<property name="icon">
|
||||
<iconset resource="../graphic/qad_graphic.qrc">
|
||||
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reorder ...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MapView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>mapview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../application/qad_application.qrc"/>
|
||||
<include location="../blockview/qad_blockview.qrc"/>
|
||||
<include location="../graphic/qad_graphic.qrc"/>
|
||||
<include location="../piqt_utils/qad_piqt_widgets.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>GeoPositionMap</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>342</x>
|
||||
<y>607</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>646</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>GeoPositionMap</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>561</x>
|
||||
<y>611</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>525</x>
|
||||
<y>649</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>../../icons/maps.png</file>
|
||||
<file>../../icons/location.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user