Changeset - 40b3b165830c
[Not reviewed]
default
0 3 0
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-09-17 12:03:28
hy@ozderya.net
show snapshot name with an asterisk if not saved
3 files changed with 21 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/snapshot.cpp
Show inline comments
 
@@ -26,7 +26,7 @@
 

	
 
Snapshot::Snapshot(QMainWindow* parent, QString name) :
 
    QObject(parent),
 
    _showAction(name, this),
 
    _showAction(this),
 
    _deleteAction("Delete", this)
 
{
 
    _name = name;
 
@@ -34,6 +34,7 @@ Snapshot::Snapshot(QMainWindow* parent, 
 

	
 
    view = NULL;
 
    mainWindow = parent;
 
    _showAction.setText(displayName());
 
    connect(&_showAction, &QAction::triggered, this, &Snapshot::show);
 

	
 
    _deleteAction.setToolTip(QString("Delete ") + _name);
 
@@ -86,6 +87,18 @@ QString Snapshot::name()
 
    return _name;
 
}
 

	
 
QString Snapshot::displayName()
 
{
 
    if (_saved)
 
    {
 
        return name();
 
    }
 
    else
 
    {
 
        return name() + "*";
 
    }
 
}
 

	
 
void Snapshot::setName(QString name)
 
{
 
    _name = name;
 
@@ -141,6 +154,7 @@ void Snapshot::save(QString fileName)
 
        else
 
        {
 
            _saved = true;
 
            _showAction.setText(displayName());
 
        }
 
    }
 
    else
src/snapshot.h
Show inline comments
 
@@ -42,6 +42,7 @@ public:
 
    QAction* deleteAction();
 

	
 
    QString name();
 
    QString displayName(); ///< `name()` plus '*' if snapshot is not saved
 
    void setName(QString name);
 
    void setChannelNames(QStringList names); // must be called when setting data!
 
    QString channelName(unsigned channel);
src/snapshotview.cpp
Show inline comments
 
@@ -32,7 +32,7 @@ SnapshotView::SnapshotView(QWidget *pare
 
    plotMan = new PlotManager(ui->plotArea);
 

	
 
    ui->menuSnapshot->insertAction(ui->actionClose, snapshot->deleteAction());
 
    this->setWindowTitle(snapshot->name());
 
    this->setWindowTitle(snapshot->displayName());
 

	
 
    // initialize curves
 
    unsigned numOfChannels = snapshot->data.size();
 
@@ -49,6 +49,7 @@ SnapshotView::SnapshotView(QWidget *pare
 
    connect(ui->actionExport, &QAction::triggered,
 
            this, &SnapshotView::save);
 

	
 
    // add 'View' menu items
 
    for (auto a : plotMan->menuActions())
 
    {
 
        ui->menuView->addAction(a);
 
@@ -79,14 +80,15 @@ void SnapshotView::showRenameDialog()
 
void SnapshotView::renameSnapshot(QString name)
 
{
 
    _snapshot->setName(name);
 
    setWindowTitle(name);
 
    setWindowTitle(_snapshot->displayName());
 
}
 

	
 
void SnapshotView::save()
 
{
 
    QString fileName = QFileDialog::getSaveFileName(this, tr("Export CSV File"));
 

	
 
    if (fileName.isNull()) return; // user canceled
 

	
 
    _snapshot->save(fileName);
 

	
 
    setWindowTitle(_snapshot->displayName());
 
}
0 comments (0 inline, 0 general)