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
 
@@ -746,6 +746,8 @@ void MainWindow::takeSnapShot()
 
        }
 
    }
 
    snapshots.append(snapShot);
 
    QObject::connect(snapShot, &SnapShot::deleteRequested,
 
                     this, &MainWindow::deleteSnapshot);
 

	
 
    updateSnapShotMenu();
 
}
 
@@ -759,7 +761,7 @@ void MainWindow::updateSnapShotMenu()
 
        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);
 
@@ -775,3 +777,9 @@ void MainWindow::clearSnapshots()
 
    snapshots.clear();
 
    updateSnapShotMenu();
 
}
 

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

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

	
 
    void demoTimerTimeout();
 
    void enableDemo(bool enabled);
snapshot.cpp
Show inline comments
 
@@ -8,11 +8,17 @@
 

	
 
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()
 
@@ -23,9 +29,14 @@ SnapShot::~SnapShot()
 
    }
 
}
 

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

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

	
 
void SnapShot::show()
 
@@ -51,3 +62,14 @@ void SnapShot::viewClosed()
 
    delete view;
 
    view = NULL;
 
}
 

	
 

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

	
 
QString SnapShot::name()
 
{
 
    return _name;
 
}
snapshot.h
Show inline comments
 
@@ -16,21 +16,30 @@ 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
 
@@ -6,6 +6,8 @@ SnapShotView::SnapShotView(QWidget *pare
 
    ui(new Ui::SnapShotView)
 
{
 
    ui->setupUi(this);
 
    ui->toolBar->addAction(snapShot->deleteAction());
 
    this->setWindowTitle(snapShot->name());
 

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

	
snapshotview.ui
Show inline comments
 
@@ -54,21 +54,12 @@
 
    <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>
0 comments (0 inline, 0 general)