Changeset - f520f2a1546b
[Not reviewed]
snapshots
0 7 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-09-20 17:48:04
hy@ozderya.net
implemented snapshot rename
7 files changed with 51 insertions and 8 deletions:
0 comments (0 inline, 0 general)
snapshot.cpp
Show inline comments
 
@@ -63,6 +63,13 @@ void SnapShot::onDeleteTriggered()
 
}
 

	
 
QString SnapShot::name()
 
{
 
    return _name;
 
}
 

	
 
void SnapShot::setName(QString name)
 
{
 
    _name = name;
 
    _showAction.setText(_name);
 
    emit nameChanged(this);
 
}
snapshot.h
Show inline comments
 
@@ -2,12 +2,13 @@
 
#define SNAPSHOT_H
 

	
 
#include <QObject>
 
#include <QMainWindow>
 
#include <QAction>
 
#include <QVector>
 
#include <QString>
 

	
 
class SnapShotView;
 

	
 
class SnapShot : public QObject
 
{
 
    Q_OBJECT
 
@@ -18,15 +19,17 @@ public:
 

	
 
    QVector<QVector<QPointF>> data;
 
    QAction* showAction();
 
    QAction* deleteAction();
 

	
 
    QString name();
 
    void setName(QString name);
 

	
 
signals:
 
    void deleteRequested(SnapShot*);
 
    void nameChanged(SnapShot*);
 

	
 
private:
 
    QString _name;
 
    QAction _showAction;
 
    QAction _deleteAction;
 
    QMainWindow* mainWindow;
snapshotmanager.cpp
Show inline comments
 
@@ -49,12 +49,14 @@ void SnapshotManager::takeSnapshot()
 
            snapShot->data[ci][i] = _channelBuffers->at(ci)->sample(i);
 
        }
 
    }
 
    snapshots.append(snapShot);
 
    QObject::connect(snapShot, &SnapShot::deleteRequested,
 
                     this, &SnapshotManager::deleteSnapshot);
 
    QObject::connect(snapShot, &SnapShot::deleteRequested,
 
                     this, &SnapshotManager::updateMenu);
 

	
 
    updateMenu();
 
}
 

	
 
void SnapshotManager::updateMenu()
 
{
snapshotmanager.h
Show inline comments
 
@@ -35,10 +35,9 @@ private:
 
    void updateMenu();
 

	
 
private slots:
 
    void takeSnapshot();
 
    void clearSnapshots();
 
    void deleteSnapshot(SnapShot* snapshot);
 

	
 
};
 

	
 
#endif /* SNAPSHOTMANAGER_H */
snapshotview.cpp
Show inline comments
 
#include "snapshotview.h"
 
#include "ui_snapshotview.h"
 

	
 
SnapShotView::SnapShotView(QWidget *parent, SnapShot* snapShot) :
 
    QMainWindow(parent),
 
    ui(new Ui::SnapShotView)
 
    ui(new Ui::SnapShotView),
 
    renameDialog(this)
 
{
 
    _snapShot = snapShot;
 

	
 
    ui->setupUi(this);
 
    ui->toolBar->addAction(snapShot->deleteAction());
 
    this->setWindowTitle(snapShot->name());
 

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

	
 
@@ -17,13 +20,16 @@ SnapShotView::SnapShotView(QWidget *pare
 
        curves.append(curve);
 
        curve->setSamples(snapShot->data[ci]);
 
        curve->setPen(Plot::makeColor(ci));
 
        curve->attach(ui->plot);
 
    }
 

	
 
    _snapShot = snapShot;
 
    renameDialog.setWindowTitle("Rename Snapshot");
 
    renameDialog.setLabelText("Enter new name:");
 
    connect(ui->actionRename, &QAction::triggered,
 
            this, &SnapShotView::showRenameDialog);
 
}
 

	
 
SnapShotView::~SnapShotView()
 
{
 
    for (auto curve : curves)
 
    {
 
@@ -34,6 +40,18 @@ SnapShotView::~SnapShotView()
 

	
 
void SnapShotView::closeEvent(QCloseEvent *event)
 
{
 
    QMainWindow::closeEvent(event);
 
    emit closed();
 
}
 

	
 
void SnapShotView::showRenameDialog()
 
{
 
    renameDialog.setTextValue(_snapShot->name());
 
    renameDialog.open(this, SLOT(renameSnapshot(QString)));
 
}
 

	
 
void SnapShotView::renameSnapshot(QString name)
 
{
 
    _snapShot->setName(name);
 
    setWindowTitle(name);
 
}
snapshotview.h
Show inline comments
 
#ifndef SNAPSHOTVIEW_H
 
#define SNAPSHOTVIEW_H
 

	
 
#include <QMainWindow>
 
#include <QInputDialog>
 
#include <QVector>
 
#include <QPointF>
 
#include <QPen>
 
#include <QCloseEvent>
 
#include <qwt_plot_curve.h>
 
#include "plot.h"
 
@@ -25,12 +26,17 @@ public:
 
signals:
 
    void closed();
 

	
 
private:
 
    Ui::SnapShotView *ui;
 
    QList<QwtPlotCurve*> curves;
 
    SnapShot* _snapShot;
 
    QInputDialog renameDialog;
 

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

	
 
private slots:
 
    void showRenameDialog();
 
    void renameSnapshot(QString name);
 
};
 

	
 
#endif // SNAPSHOTVIEW_H
snapshotview.ui
Show inline comments
 
@@ -26,43 +26,51 @@
 
     <x>0</x>
 
     <y>0</y>
 
     <width>544</width>
 
     <height>27</height>
 
    </rect>
 
   </property>
 
   <widget class="QMenu" name="menuFile">
 
   <widget class="QMenu" name="menuSnapshot">
 
    <property name="title">
 
     <string>File</string>
 
     <string>Snapshot</string>
 
    </property>
 
    <addaction name="actionRename"/>
 
    <addaction name="actionExportCSV"/>
 
   </widget>
 
   <widget class="QMenu" name="menuView">
 
    <property name="title">
 
     <string>View</string>
 
    </property>
 
   </widget>
 
   <addaction name="menuFile"/>
 
   <addaction name="menuSnapshot"/>
 
   <addaction name="menuView"/>
 
  </widget>
 
  <widget class="QToolBar" name="toolBar">
 
   <property name="windowTitle">
 
    <string>toolBar</string>
 
   </property>
 
   <attribute name="toolBarArea">
 
    <enum>TopToolBarArea</enum>
 
   </attribute>
 
   <attribute name="toolBarBreak">
 
    <bool>false</bool>
 
   </attribute>
 
   <addaction name="actionExportCSV"/>
 
  </widget>
 
  <action name="actionExportCSV">
 
   <property name="text">
 
    <string>Export CSV</string>
 
   </property>
 
  </action>
 
  <action name="actionRename">
 
   <property name="text">
 
    <string>Rename</string>
 
   </property>
 
   <property name="toolTip">
 
    <string>Rename this snapshot</string>
 
   </property>
 
  </action>
 
 </widget>
 
 <customwidgets>
 
  <customwidget>
 
   <class>Plot</class>
 
   <extends>QWidget</extends>
 
   <header>plot.h</header>
0 comments (0 inline, 0 general)