Show number of points in drawn map
authorunc0rr
Fri, 27 Apr 2012 22:15:08 +0400
changeset 6935 472ed92c4173
parent 6934 14a230552c2e
child 6936 8af2bf10ee62
Show number of points in drawn map
QTfrontend/drawmapscene.cpp
QTfrontend/drawmapscene.h
QTfrontend/ui/widget/drawmapwidget.cpp
QTfrontend/ui/widget/drawmapwidget.h
--- a/QTfrontend/drawmapscene.cpp	Fri Apr 27 00:43:48 2012 +0400
+++ b/QTfrontend/drawmapscene.cpp	Fri Apr 27 22:15:08 2012 +0400
@@ -325,6 +325,15 @@
     emit pathChanged();
 }
 
+int DrawMapScene::pointsCount()
+{
+    int cnt = 0;
+    foreach(PathParams p, paths)
+        cnt += p.points.size();
+
+    return cnt;
+}
+
 QPainterPath DrawMapScene::pointsToPath(const QList<QPoint> points)
 {
     QPainterPath path;
--- a/QTfrontend/drawmapscene.h	Fri Apr 27 00:43:48 2012 +0400
+++ b/QTfrontend/drawmapscene.h	Fri Apr 27 22:15:08 2012 +0400
@@ -42,6 +42,7 @@
 
         QByteArray encode();
         void decode(QByteArray data);
+        int pointsCount();
 
     signals:
         void pathChanged();
--- a/QTfrontend/ui/widget/drawmapwidget.cpp	Fri Apr 27 00:43:48 2012 +0400
+++ b/QTfrontend/ui/widget/drawmapwidget.cpp	Fri Apr 27 22:15:08 2012 +0400
@@ -55,6 +55,7 @@
     m_scene = scene;
 
     ui->graphicsView->setScene(scene);
+    connect(scene, SIGNAL(pathChanged()), this, SLOT(pathChanged()));
 }
 
 void DrawMapWidget::resizeEvent(QResizeEvent * event)
@@ -113,6 +114,11 @@
     }
 }
 
+void DrawMapWidget::pathChanged()
+{
+    ui->lblPoints->setNum(m_scene->pointsCount());
+}
+
 
 
 DrawMapView::DrawMapView(QWidget *parent) :
--- a/QTfrontend/ui/widget/drawmapwidget.h	Fri Apr 27 00:43:48 2012 +0400
+++ b/QTfrontend/ui/widget/drawmapwidget.h	Fri Apr 27 22:15:08 2012 +0400
@@ -23,6 +23,7 @@
 #include <QHBoxLayout>
 #include <QPushButton>
 #include <QGraphicsView>
+#include <QLabel>
 
 #include "qaspectratiolayout.h"
 #include "drawmapscene.h"
@@ -53,11 +54,17 @@
     {
         public:
             DrawMapView *graphicsView;
+            QLabel * lblPoints;
 
             void setupUi(QWidget *drawMapWidget)
             {
-                QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget);
+                QVBoxLayout * vbox = new QVBoxLayout(drawMapWidget);
+                vbox->setMargin(0);
+                lblPoints = new QLabel("0", drawMapWidget);
+                vbox->addWidget(lblPoints);
+                QAspectRatioLayout * arLayout = new QAspectRatioLayout();
                 arLayout->setMargin(0);
+                vbox->addLayout(arLayout);
 
                 graphicsView = new DrawMapView(drawMapWidget);
                 arLayout->addWidget(graphicsView);
@@ -103,6 +110,9 @@
         Ui::DrawMapWidget *ui;
 
         DrawMapScene * m_scene;
+
+    private slots:
+        void pathChanged();
 };
 
 #endif // DRAWMAPWIDGET_H