Changeset - 7c41467702e0
[Not reviewed]
snapshots
0 4 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-09-20 08:07:34
hy@ozderya.net
delete snapshot window when closed
4 files changed with 29 insertions and 0 deletions:
0 comments (0 inline, 0 general)
snapshot.cpp
Show inline comments
 
@@ -6,31 +6,46 @@
 

	
 
#include <QtDebug>
 

	
 
SnapShot::SnapShot(QMainWindow* parent, QString name) :
 
    QObject(parent),
 
    _menuAction(name, this)
 
{
 
    view = NULL;
 
    mainWindow = parent;
 
    connect(&_menuAction, &QAction::triggered, this, &SnapShot::show);
 
}
 

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

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

	
 
void SnapShot::show()
 
{
 
    if (view == NULL)
 
    {
 
        qDebug() << "view == NULL";
 
        view = new SnapShotView(mainWindow, this);
 
        connect(view, &SnapShotView::closed, this, &SnapShot::viewClosed);
 
    }
 
    view->show();
 
}
 

	
 
void SnapShot::hide()
 
{
 

	
 
}
 

	
 
void SnapShot::viewClosed()
 
{
 
    delete view;
 
    view = NULL;
 
}
snapshot.h
Show inline comments
 
@@ -5,28 +5,32 @@
 
#include <QMainWindow>
 
#include <QAction>
 
#include <QVector>
 

	
 
class SnapShotView;
 

	
 
class SnapShot : public QObject
 
{
 
    Q_OBJECT
 

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

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

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

	
 
private:
 
    QAction _menuAction;
 
    QMainWindow* mainWindow;
 
    SnapShotView* view;
 

	
 
private slots:
 
    void viewClosed();
 
};
 

	
 
#endif /* SNAPSHOT_H */
snapshotview.cpp
Show inline comments
 
@@ -20,12 +20,17 @@ SnapShotView::SnapShotView(QWidget *pare
 

	
 
    _snapShot = snapShot;
 
}
 

	
 
SnapShotView::~SnapShotView()
 
{
 
    for (auto curve : curves)
 
    {
 
        delete curve;
 
    }
 
    delete ui;
 
}
 

	
 
void SnapShotView::closeEvent(QCloseEvent *event)
 
{
 
    emit closed();
 
}
snapshotview.h
Show inline comments
 
#ifndef SNAPSHOTVIEW_H
 
#define SNAPSHOTVIEW_H
 

	
 
#include <QMainWindow>
 
#include <QVector>
 
#include <QPointF>
 
#include <QPen>
 
#include <QCloseEvent>
 
#include <qwt_plot_curve.h>
 
#include "plot.h"
 
#include "snapshot.h"
 

	
 
namespace Ui {
 
class SnapShotView;
 
}
 

	
 
class SnapShotView : public QMainWindow
 
{
 
    Q_OBJECT
 

	
 
public:
 
    explicit SnapShotView(QWidget *parent, SnapShot* snapShot);
 
    ~SnapShotView();
 

	
 
signals:
 
    void closed();
 

	
 
private:
 
    Ui::SnapShotView *ui;
 
    QList<QwtPlotCurve*> curves;
 

	
 
    SnapShot* _snapShot;
 
    void closeEvent(QCloseEvent *event);
 
};
 

	
 
#endif // SNAPSHOTVIEW_H
0 comments (0 inline, 0 general)