Changeset - 099df007158d
[Not reviewed]
snapshots
0 6 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-09-20 09:50:08
hy@ozderya.net
implemented delete snapshot function and showing snapshot name in the title
6 files changed with 50 insertions and 17 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -743,12 +743,14 @@ void MainWindow::takeSnapShot()
 
        for (unsigned i = 0; i < numOfSamples; i++)
 
        {
 
            snapShot->data[ci][i] = channelBuffers[ci]->sample(i);
 
        }
 
    }
 
    snapshots.append(snapShot);
 
    QObject::connect(snapShot, &SnapShot::deleteRequested,
 
                     this, &MainWindow::deleteSnapshot);
 

	
 
    updateSnapShotMenu();
 
}
 

	
 
void MainWindow::updateSnapShotMenu()
 
{
 
@@ -756,13 +758,13 @@ void MainWindow::updateSnapShotMenu()
 
    ui->menuSnapShots->addAction(ui->actionSnapShot);
 
    if (snapshots.size())
 
    {
 
        ui->menuSnapShots->addSeparator();
 
        for (auto ss : snapshots)
 
        {
 
            ui->menuSnapShots->addAction(ss->menuAction());
 
            ui->menuSnapShots->addAction(ss->showAction());
 
        }
 
        ui->menuSnapShots->addSeparator();
 
        ui->menuSnapShots->addAction(ui->actionClearSnapShots);
 
    }
 
}
 

	
 
@@ -772,6 +774,12 @@ void MainWindow::clearSnapshots()
 
    {
 
        delete snapshot;
 
    }
 
    snapshots.clear();
 
    updateSnapShotMenu();
 
}
 

	
 
void MainWindow::deleteSnapshot(SnapShot* snapshot)
 
{
 
    delete snapshots.takeAt(snapshots.indexOf(snapshot));
 
    updateSnapShotMenu();
 
}
mainwindow.h
Show inline comments
 
@@ -131,12 +131,13 @@ private slots:
 
    void clearPlot();
 

	
 
    void spsTimerTimeout();
 

	
 
    void takeSnapShot();
 
    void clearSnapshots();
 
    void deleteSnapshot(SnapShot* snapshot);
 

	
 
    void demoTimerTimeout();
 
    void enableDemo(bool enabled);
 

	
 
    void onExportCsv();
 
};
snapshot.cpp
Show inline comments
 
@@ -5,30 +5,41 @@
 
#include "snapshotview.h"
 

	
 
#include <QtDebug>
 

	
 
SnapShot::SnapShot(QMainWindow* parent, QString name) :
 
    QObject(parent),
 
    _menuAction(name, this)
 
    _showAction(name, this),
 
    _deleteAction("Delete", this)
 
{
 
    _name = name;
 

	
 
    view = NULL;
 
    mainWindow = parent;
 
    connect(&_menuAction, &QAction::triggered, this, &SnapShot::show);
 
    connect(&_showAction, &QAction::triggered, this, &SnapShot::show);
 

	
 
    _deleteAction.setToolTip(QString("Delete ") + _name);
 
    connect(&_deleteAction, &QAction::triggered, this, &SnapShot::onDeleteTriggered);
 
}
 

	
 
SnapShot::~SnapShot()
 
{
 
    if (view != NULL)
 
    {
 
        delete view;
 
    }
 
}
 

	
 
QAction* SnapShot::menuAction()
 
QAction* SnapShot::showAction()
 
{
 
    return &_menuAction;
 
    return &_showAction;
 
}
 

	
 
QAction* SnapShot::deleteAction()
 
{
 
    return &_deleteAction;
 
}
 

	
 
void SnapShot::show()
 
{
 
    if (view == NULL)
 
    {
 
@@ -48,6 +59,17 @@ void SnapShot::hide()
 

	
 
void SnapShot::viewClosed()
 
{
 
    delete view;
 
    view = NULL;
 
}
 

	
 

	
 
void SnapShot::onDeleteTriggered()
 
{
 
    emit deleteRequested(this);
 
}
 

	
 
QString SnapShot::name()
 
{
 
    return _name;
 
}
snapshot.h
Show inline comments
 
@@ -13,24 +13,33 @@ class SnapShot : public QObject
 
    Q_OBJECT
 

	
 
public:
 
    SnapShot(QMainWindow* parent, QString name);
 
    ~SnapShot();
 

	
 
    // QString _name;
 
    QVector<QVector<QPointF>> data;
 
    QAction* menuAction();
 
    QAction* showAction();
 
    QAction* deleteAction();
 

	
 
    QString name();
 

	
 
public slots:
 
    void show();
 
    void hide();
 

	
 
signals:
 
    void deleteRequested(SnapShot*);
 

	
 
private:
 
    QAction _menuAction;
 
    QString _name;
 
    QAction _showAction;
 
    QAction _deleteAction;
 
    QMainWindow* mainWindow;
 
    SnapShotView* view;
 

	
 
private slots:
 
    void viewClosed();
 

	
 
    void onDeleteTriggered();
 
};
 

	
 
#endif /* SNAPSHOT_H */
snapshotview.cpp
Show inline comments
 
@@ -3,12 +3,14 @@
 

	
 
SnapShotView::SnapShotView(QWidget *parent, SnapShot* snapShot) :
 
    QMainWindow(parent),
 
    ui(new Ui::SnapShotView)
 
{
 
    ui->setupUi(this);
 
    ui->toolBar->addAction(snapShot->deleteAction());
 
    this->setWindowTitle(snapShot->name());
 

	
 
    unsigned numOfChannels = snapShot->data.size();
 

	
 
    for (unsigned ci = 0; ci < numOfChannels; ci++)
 
    {
 
        QwtPlotCurve* curve = new QwtPlotCurve();
snapshotview.ui
Show inline comments
 
@@ -51,27 +51,18 @@
 
    <enum>TopToolBarArea</enum>
 
   </attribute>
 
   <attribute name="toolBarBreak">
 
    <bool>false</bool>
 
   </attribute>
 
   <addaction name="actionExportCSV"/>
 
   <addaction name="actionDelete"/>
 
  </widget>
 
  <action name="actionExportCSV">
 
   <property name="text">
 
    <string>Export CSV</string>
 
   </property>
 
  </action>
 
  <action name="actionDelete">
 
   <property name="text">
 
    <string>Delete</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Delete this snapshot!</string>
 
   </property>
 
  </action>
 
 </widget>
 
 <customwidgets>
 
  <customwidget>
 
   <class>Plot</class>
 
   <extends>QWidget</extends>
 
   <header>plot.h</header>
0 comments (0 inline, 0 general)