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
 
@@ -66,3 +66,10 @@ QString SnapShot::name()
 
{
 
    return _name;
 
}
 

	
 
void SnapShot::setName(QString name)
 
{
 
    _name = name;
 
    _showAction.setText(_name);
 
    emit nameChanged(this);
 
}
snapshot.h
Show inline comments
 
@@ -5,6 +5,7 @@
 
#include <QMainWindow>
 
#include <QAction>
 
#include <QVector>
 
#include <QString>
 

	
 
class SnapShotView;
 

	
 
@@ -21,9 +22,11 @@ public:
 
    QAction* deleteAction();
 

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

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

	
 
private:
 
    QString _name;
snapshotmanager.cpp
Show inline comments
 
@@ -52,6 +52,8 @@ void SnapshotManager::takeSnapshot()
 
    snapshots.append(snapShot);
 
    QObject::connect(snapShot, &SnapShot::deleteRequested,
 
                     this, &SnapshotManager::deleteSnapshot);
 
    QObject::connect(snapShot, &SnapShot::deleteRequested,
 
                     this, &SnapshotManager::updateMenu);
 

	
 
    updateMenu();
 
}
snapshotmanager.h
Show inline comments
 
@@ -38,7 +38,6 @@ private slots:
 
    void takeSnapshot();
 
    void clearSnapshots();
 
    void deleteSnapshot(SnapShot* snapshot);
 

	
 
};
 

	
 
#endif /* SNAPSHOTMANAGER_H */
snapshotview.cpp
Show inline comments
 
@@ -3,8 +3,11 @@
 

	
 
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());
 
@@ -20,7 +23,10 @@ SnapShotView::SnapShotView(QWidget *pare
 
        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()
 
@@ -37,3 +43,15 @@ void SnapShotView::closeEvent(QCloseEven
 
    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
 
@@ -2,6 +2,7 @@
 
#define SNAPSHOTVIEW_H
 

	
 
#include <QMainWindow>
 
#include <QInputDialog>
 
#include <QVector>
 
#include <QPointF>
 
#include <QPen>
 
@@ -28,9 +29,14 @@ signals:
 
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
 
@@ -29,10 +29,11 @@
 
     <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">
 
@@ -40,7 +41,7 @@
 
     <string>View</string>
 
    </property>
 
   </widget>
 
   <addaction name="menuFile"/>
 
   <addaction name="menuSnapshot"/>
 
   <addaction name="menuView"/>
 
  </widget>
 
  <widget class="QToolBar" name="toolBar">
 
@@ -53,13 +54,20 @@
 
   <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>
0 comments (0 inline, 0 general)