CMake findQAD miss map
MapItemBase::offset feature PIValueTreeEdit add custom button to show/hide groups
This commit is contained in:
@@ -4,7 +4,7 @@ cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
|||||||
project(QAD)
|
project(QAD)
|
||||||
set(QAD_MAJOR 2)
|
set(QAD_MAJOR 2)
|
||||||
set(QAD_MINOR 14)
|
set(QAD_MINOR 14)
|
||||||
set(QAD_REVISION 1)
|
set(QAD_REVISION 2)
|
||||||
set(QAD_SUFFIX )
|
set(QAD_SUFFIX )
|
||||||
set(QAD_COMPANY SHS)
|
set(QAD_COMPANY SHS)
|
||||||
set(QAD_DOMAIN org.SHS)
|
set(QAD_DOMAIN org.SHS)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ if(QAD_FIND_VERSION VERSION_GREATER QAD_VERSION)
|
|||||||
message(FATAL_ERROR "QAD version ${QAD_VERSION} is available, but ${QAD_FIND_VERSION} requested!")
|
message(FATAL_ERROR "QAD version ${QAD_VERSION} is available, but ${QAD_FIND_VERSION} requested!")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(__libs "utils;widgets;application;blockview;graphic;sql_table;touch_widgets;doc")
|
set(__libs "utils;widgets;application;blockview;graphic;sql_table;touch_widgets;doc;map")
|
||||||
if (PIP_FOUND OR BUILDING_PIP)
|
if (PIP_FOUND OR BUILDING_PIP)
|
||||||
list(APPEND __libs "piqt;piqt_utils")
|
list(APPEND __libs "piqt;piqt_utils")
|
||||||
endif()
|
endif()
|
||||||
@@ -57,6 +57,7 @@ set(__module_graphic Graphic )
|
|||||||
set(__module_sql_table SQLTable )
|
set(__module_sql_table SQLTable )
|
||||||
set(__module_touch_widgets TouchWidgets )
|
set(__module_touch_widgets TouchWidgets )
|
||||||
set(__module_doc Doc )
|
set(__module_doc Doc )
|
||||||
|
set(__module_map Map )
|
||||||
set(__module_piqt PIQt )
|
set(__module_piqt PIQt )
|
||||||
set(__module_piqt_utils PIQtUtils )
|
set(__module_piqt_utils PIQtUtils )
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ set(__deps_application "QAD::Widgets")
|
|||||||
set(__deps_blockview "QAD::Widgets")
|
set(__deps_blockview "QAD::Widgets")
|
||||||
set(__deps_graphic "QAD::Widgets")
|
set(__deps_graphic "QAD::Widgets")
|
||||||
set(__deps_sql_table "QAD::Widgets")
|
set(__deps_sql_table "QAD::Widgets")
|
||||||
|
set(__deps_map "QAD::Utils")
|
||||||
set(__deps_piqt "QAD::Widgets;PIP")
|
set(__deps_piqt "QAD::Widgets;PIP")
|
||||||
set(__deps_piqt_utils "QAD::Blockview;QAD::PIQt")
|
set(__deps_piqt_utils "QAD::Blockview;QAD::PIQt")
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ void MapItemBase::setPosition(QPointF geo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MapItemBase::setOffset(QPointF pixels) {
|
||||||
|
m_offset = pixels;
|
||||||
|
updateParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MapItemBase::setCursor(const QCursor & newCursor) {
|
void MapItemBase::setCursor(const QCursor & newCursor) {
|
||||||
m_cursor = newCursor;
|
m_cursor = newCursor;
|
||||||
updateParent();
|
updateParent();
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ public:
|
|||||||
void setPosition(QPointF geo);
|
void setPosition(QPointF geo);
|
||||||
void setPosition(double lat, double lng) { setPosition({lat, lng}); }
|
void setPosition(double lat, double lng) { setPosition({lat, lng}); }
|
||||||
|
|
||||||
|
QPointF offset() const { return m_offset; }
|
||||||
|
void setOffset(QPointF pixels);
|
||||||
|
void setOffset(double x, double y) { setOffset({x, y}); }
|
||||||
|
|
||||||
const QCursor & cursor() const { return m_cursor; }
|
const QCursor & cursor() const { return m_cursor; }
|
||||||
void setCursor(const QCursor & newCursor);
|
void setCursor(const QCursor & newCursor);
|
||||||
|
|
||||||
@@ -84,7 +88,7 @@ private:
|
|||||||
MapView * parent = nullptr;
|
MapView * parent = nullptr;
|
||||||
bool m_visible = true, m_interacive = false;
|
bool m_visible = true, m_interacive = false;
|
||||||
double m_rotation = 0.;
|
double m_rotation = 0.;
|
||||||
QPointF m_position, m_scale = {1., 1.};
|
QPointF m_position, m_scale = {1., 1.}, m_offset;
|
||||||
QRectF m_bounding;
|
QRectF m_bounding;
|
||||||
QCursor m_cursor;
|
QCursor m_cursor;
|
||||||
QMap<int, QVariant> data_;
|
QMap<int, QVariant> data_;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ void MapItemText::draw(QPainter * p) {
|
|||||||
if (str.isEmpty()) return;
|
if (str.isEmpty()) return;
|
||||||
p->setPen(pen());
|
p->setPen(pen());
|
||||||
p->setFont(font());
|
p->setFont(font());
|
||||||
auto br = p->fontMetrics().boundingRect(str);
|
auto br = p->fontMetrics().boundingRect(str).adjusted(0, 0, 1, 1);
|
||||||
br.translate(-br.topLeft());
|
br.translate(-br.topLeft());
|
||||||
if (m_alignment.testFlag(Qt::AlignHCenter)) {
|
if (m_alignment.testFlag(Qt::AlignHCenter)) {
|
||||||
br.translate(-br.center().x(), 0.);
|
br.translate(-br.center().x(), 0.);
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ void MapView::setZoom(double z) {
|
|||||||
void MapView::mousePressEvent(QMouseEvent * e) {
|
void MapView::mousePressEvent(QMouseEvent * e) {
|
||||||
is_pan = false;
|
is_pan = false;
|
||||||
press_point = e->pos();
|
press_point = e->pos();
|
||||||
|
last_click_coord = OSM::xy2geo(mapToNorm(press_point));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,6 +188,7 @@ void MapView::drawItems(QPainter & p) {
|
|||||||
QPointF ipos = mapFromNorm(i->norm_pos);
|
QPointF ipos = mapFromNorm(i->norm_pos);
|
||||||
p.setTransform(src_tr);
|
p.setTransform(src_tr);
|
||||||
p.translate(ipos);
|
p.translate(ipos);
|
||||||
|
p.translate(i->m_offset.x(), -i->m_offset.y());
|
||||||
p.rotate(i->getRotation());
|
p.rotate(i->getRotation());
|
||||||
if (!i->ignore_scale) p.scale(i->getScale().x(), i->getScale().y());
|
if (!i->ignore_scale) p.scale(i->getScale().x(), i->getScale().y());
|
||||||
i->draw(&p);
|
i->draw(&p);
|
||||||
@@ -257,6 +259,7 @@ void MapView::updateMouse(QPoint mouse) {
|
|||||||
QTransform mtr;
|
QTransform mtr;
|
||||||
if (!i->ignore_scale) mtr.scale(1. / i->getScale().x(), 1. / i->getScale().y());
|
if (!i->ignore_scale) mtr.scale(1. / i->getScale().x(), 1. / i->getScale().y());
|
||||||
mtr.rotate(-i->getRotation());
|
mtr.rotate(-i->getRotation());
|
||||||
|
mtr.translate(-i->m_offset.x(), i->m_offset.y());
|
||||||
mtr.translate(-ipos.x(), -ipos.y());
|
mtr.translate(-ipos.x(), -ipos.y());
|
||||||
QPoint m = mtr.map(mouse);
|
QPoint m = mtr.map(mouse);
|
||||||
if (i->m_bounding.contains(m)) {
|
if (i->m_bounding.contains(m)) {
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ public:
|
|||||||
double getZoom() const { return zoom_; }
|
double getZoom() const { return zoom_; }
|
||||||
void setZoom(double z);
|
void setZoom(double z);
|
||||||
|
|
||||||
private:
|
QPointF clickedCoordinate() const { return last_click_coord; }
|
||||||
|
|
||||||
|
protected:
|
||||||
QSize sizeHint() const override { return QSize(200, 200); }
|
QSize sizeHint() const override { return QSize(200, 200); }
|
||||||
void mousePressEvent(QMouseEvent * e) override;
|
void mousePressEvent(QMouseEvent * e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent * e) override;
|
void mouseReleaseEvent(QMouseEvent * e) override;
|
||||||
@@ -61,6 +63,8 @@ private:
|
|||||||
void wheelEvent(QWheelEvent * e) override;
|
void wheelEvent(QWheelEvent * e) override;
|
||||||
void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
void resizeEvent(QResizeEvent *) override;
|
void resizeEvent(QResizeEvent *) override;
|
||||||
|
|
||||||
|
private:
|
||||||
void drawBackground();
|
void drawBackground();
|
||||||
void drawItems(QPainter & p);
|
void drawItems(QPainter & p);
|
||||||
void checkZoom();
|
void checkZoom();
|
||||||
@@ -78,6 +82,7 @@ private:
|
|||||||
OSMTileCache * cache = nullptr;
|
OSMTileCache * cache = nullptr;
|
||||||
MapItemBase * hover = nullptr;
|
MapItemBase * hover = nullptr;
|
||||||
QPointF center_ = QPointF(0.5, 0.5);
|
QPointF center_ = QPointF(0.5, 0.5);
|
||||||
|
QPointF last_click_coord = center_;
|
||||||
QPoint press_point;
|
QPoint press_point;
|
||||||
QPixmap background;
|
QPixmap background;
|
||||||
QRectF view_rect;
|
QRectF view_rect;
|
||||||
|
|||||||
@@ -19,6 +19,35 @@ using Attribute = PIValueTree::Attribute;
|
|||||||
const char property_name[] = "__name__";
|
const char property_name[] = "__name__";
|
||||||
|
|
||||||
|
|
||||||
|
class GroupBox: public QGroupBox {
|
||||||
|
public:
|
||||||
|
GroupBox(QWidget * content = nullptr): QGroupBox() {
|
||||||
|
icon_show = QIcon(":/icons/layer-visible-on.png");
|
||||||
|
icon_hide = QIcon(":/icons/layer-visible-off.png");
|
||||||
|
setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
|
||||||
|
layout()->addWidget(content);
|
||||||
|
setAlignment(Qt::AlignCenter);
|
||||||
|
btn = new QToolButton(this);
|
||||||
|
btn->setCheckable(true);
|
||||||
|
btn->show();
|
||||||
|
connect(btn, &QToolButton::toggled, this, [this, content](bool on) {
|
||||||
|
btn->setIcon(on ? icon_show : icon_hide);
|
||||||
|
content->setVisible(on);
|
||||||
|
});
|
||||||
|
btn->setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void resizeEvent(QResizeEvent * e) {
|
||||||
|
QGroupBox::resizeEvent(e);
|
||||||
|
btn->resize(btn->height(), btn->height());
|
||||||
|
btn->move(btn->height() / 2, 0);
|
||||||
|
}
|
||||||
|
QToolButton * btn = nullptr;
|
||||||
|
QIcon icon_show, icon_hide;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
PIValueTreeEdit::PIValueTreeEdit(QWidget * parent): QWidget(parent) {
|
PIValueTreeEdit::PIValueTreeEdit(QWidget * parent): QWidget(parent) {
|
||||||
widget_params = new PIValueTreeEditParameters();
|
widget_params = new PIValueTreeEditParameters();
|
||||||
widget_reorder = new PIValueTreeEditReorder();
|
widget_reorder = new PIValueTreeEditReorder();
|
||||||
@@ -356,16 +385,10 @@ PIValueTreeEdit * PIValueTreeEdit::addTreeEdit(const PIValueTree & vt) {
|
|||||||
switch (real_grouping) {
|
switch (real_grouping) {
|
||||||
case Indent: grid->add(vt, vt.name(), ve, vt.comment(), true); break;
|
case Indent: grid->add(vt, vt.name(), ve, vt.comment(), true); break;
|
||||||
case Groups: {
|
case Groups: {
|
||||||
auto * gb = new QGroupBox();
|
auto * gb = new GroupBox(ve);
|
||||||
gb->setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
|
|
||||||
gb->layout()->addWidget(ve);
|
|
||||||
gb->setTitle(PI2QString(vt.name()));
|
gb->setTitle(PI2QString(vt.name()));
|
||||||
gb->setToolTip(PI2QString(vt.comment()));
|
gb->setToolTip(PI2QString(vt.comment()));
|
||||||
gb->setCheckable(true);
|
|
||||||
gb->setChecked(true);
|
|
||||||
gb->setAlignment(Qt::AlignCenter);
|
|
||||||
gb->setProperty(property_name, PI2QString(vt.name()));
|
gb->setProperty(property_name, PI2QString(vt.name()));
|
||||||
connect(gb, &QGroupBox::toggled, ve, &QWidget::setVisible);
|
|
||||||
grid->add(vt, gb, true);
|
grid->add(vt, gb, true);
|
||||||
} break;
|
} break;
|
||||||
case Tabs: {
|
case Tabs: {
|
||||||
|
|||||||
@@ -10,5 +10,7 @@
|
|||||||
<file>../../icons/legend.png</file>
|
<file>../../icons/legend.png</file>
|
||||||
<file>../../icons/document-open.png</file>
|
<file>../../icons/document-open.png</file>
|
||||||
<file>../../icons/document-edit.png</file>
|
<file>../../icons/document-edit.png</file>
|
||||||
|
<file>../../icons/layer-visible-off.png</file>
|
||||||
|
<file>../../icons/layer-visible-on.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
Reference in New Issue
Block a user