]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Scale SignalView to full height on doubleclick to SignalView widget
authorMichal Malý <madcatxster@prifuk.cz>
Sun, 17 Nov 2013 10:38:37 +0000 (11:38 +0100)
committerMichal Malý <madcatxster@prifuk.cz>
Sun, 17 Nov 2013 10:38:37 +0000 (11:38 +0100)
area.

gui/graphview.cpp
gui/graphview.h
gui/mainwindow.cpp
gui/mainwindow.h
gui/signalview.cpp
gui/signalview.h

index 262b74b82e89be6f32bc15372c8657b98f910932..e0a43802fdbb7eaaf255326999618d045c4a80a4 100644 (file)
@@ -33,6 +33,19 @@ void GraphView::leaveEvent(QEvent *)
   emit mouseCursorLeft();
 }
 
+void GraphView::mouseDoubleClickEvent(QMouseEvent* ev)
+{
+  /* Prevent doubleclick on GraphView from propagating to SignalView */
+  switch (ev->button()) {
+    case Qt::LeftButton:
+      break;
+    case Qt::RightButton:
+      break;
+    default:
+      break;
+  }
+}
+
 void GraphView::mouseMoveEvent(QMouseEvent* ev)
 {
   emit mouseMoved(ev->x(), ev->y());
index 895b4205a30c233a609509db57293177f8787a2b..b3db5b42ba1f1ab0405624714806e30b00ea3be8 100644 (file)
@@ -32,6 +32,7 @@ class GraphView : public QLabel
 public:
   explicit GraphView(QWidget* parent = nullptr);
   void leaveEvent(QEvent* );
+  void mouseDoubleClickEvent(QMouseEvent* );
   void mouseMoveEvent(QMouseEvent* ev);
   void mousePressEvent(QMouseEvent* ev);
 
index bc11e60099cae69eb7622c9bb372cf77f020bded..2c6968cfa38c14cb855f15f0d7fb09bcfa67cce1 100644 (file)
@@ -29,6 +29,7 @@
 
 MainWindow::MainWindow(QWidget *parent) :
   QMainWindow(parent),
+  m_singleSignalView(false),
   ui(new Ui::MainWindow)
 {
   ui->setupUi(this);
@@ -80,8 +81,8 @@ void MainWindow::onAddToDashboard(SignalView* sw)
   else if(ui->qpb_zoom->isChecked())
     sw->setControlMode(GraphControlModes::ZOOM);
 
-  //m_itemsOnDashboard.push_back(sw);
   connect(this, SIGNAL(controlModeChanged(GraphControlModes)), sw, SLOT(onControlModeChanged(GraphControlModes)));
+  connect(sw, SIGNAL(fullSizeToggle()), this, SLOT(onSWFullSizeToggle()));
   m_dashboard->addWidget(sw);
 }
 
@@ -137,12 +138,6 @@ void MainWindow::onLoadSingleRun()
   }
 }
 
-void MainWindow::onZoomSelected()
-{
-  emit controlModeChanged(GraphControlModes::ZOOM);
-}
-
-/* Private slots */
 void MainWindow::onSequenceSelected(const QString &str)
 {
   emit sequenceSelected(str);
@@ -153,6 +148,27 @@ void MainWindow::onSingleRunSelected(const QString &str)
   emit singleRunSelected(str);
 }
 
+void MainWindow::onSWFullSizeToggle()
+{
+  QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
+
+  for (int idx = 0; idx < m_dashboard->count(); idx++) {
+    if (m_dashboard->widget(idx) != sender) {
+      if (!m_singleSignalView)
+        m_dashboard->widget(idx)->hide();
+      else
+        m_dashboard->widget(idx)->show();
+    }
+  }
+
+  m_singleSignalView = !m_singleSignalView;
+}
+
+void MainWindow::onZoomSelected()
+{
+  emit controlModeChanged(GraphControlModes::ZOOM);
+}
+
 MainWindow::~MainWindow()
 {
   delete ui;
index 5dc82ed1ae4d8f512002a126ab72bed0150bb36a..a8140862fc62cbd01b067b7998e55c62599f2f5e 100644 (file)
@@ -57,6 +57,7 @@ private:
   //std::vector<SignalView*> m_itemsOnDashboard;
   QSplitter* m_dashboard;
   QFileDialog* m_loadDataFileDialog;
+  bool m_singleSignalView;
   Ui::MainWindow *ui;
 
 public slots:
@@ -73,6 +74,7 @@ private slots:
   void onLoadSingleRun();
   void onSequenceSelected(const QString& str);
   void onSingleRunSelected(const QString& str);
+  void onSWFullSizeToggle();
   void onZoomSelected();
 
 signals:
index 6dcd17e27bf36dacd548307aa9a66e35cd63f628..b8fb01aecb1c89763125915b399361a1d6313255 100644 (file)
@@ -28,7 +28,7 @@
 #include <QtGui/QFontMetrics>
 #include <QtGui/QPainter>
 
-#include <QDebug>
+//#include <QDebug>
 
 SignalView::SignalView(QWidget *parent) :
   QWidget(parent),
@@ -53,6 +53,17 @@ SignalView::SignalView(QWidget *parent) :
 }
 
 /* Public functions */
+void SignalView::mouseDoubleClickEvent(QMouseEvent* ev)
+{
+  switch (ev->button()) {
+    case Qt::LeftButton:
+      emit fullSizeToggle();
+      break;
+    default:
+      break;
+  }
+}
+
 void SignalView::setControlMode(GraphControlModes mode)
 {
   m_graphCtrlMode = mode;
index 2c0b66c5ee17db02891417dfff705f0de69052f2..cd6507c82392e118c86c59ed609cfeafcee25a80 100644 (file)
@@ -47,6 +47,7 @@ public:
 
   explicit SignalView(QWidget* parent = nullptr);
   ~SignalView();
+  void mouseDoubleClickEvent(QMouseEvent* ev);
   void setControlMode(GraphControlModes mode);
   void setDataTableModel (SignalDataTableModel* model);
   void setIntegrationTableModel(IntegrationTableModel* model);
@@ -109,6 +110,7 @@ private slots:
 signals:
   void crosshairErased();
   void crosshairMoved(const int x, const int y);
+  void fullSizeToggle();
   void integrated(const int fromX, const int fromY, const int toX, const int toY);
   void redrawNeeded();
   void resized(const int x, const int y);