Changeset - 7f2c4af67ad6
[Not reviewed]
default
0 3 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2016-04-03 15:28:26
hy@ozderya.net
use snapshot module for export csv from filemenu
3 files changed with 14 insertions and 29 deletions:
0 comments (0 inline, 0 general)
src/mainwindow.cpp
Show inline comments
 
@@ -468,33 +468,9 @@ void MainWindow::onExportCsv()
 
    }
 
    else
 
    {
 
        QFile file(fileName);
 
        if (file.open(QIODevice::WriteOnly | QIODevice::Text))
 
        {
 
            QTextStream fileStream(&file);
 

	
 
            unsigned numOfChannels = channelMan.numOfChannels();
 
            for (unsigned int ci = 0; ci < numOfChannels; ci++)
 
            {
 
                fileStream << "Channel " << ci;
 
                if (ci != numOfChannels-1) fileStream << ",";
 
            }
 
            fileStream << '\n';
 

	
 
            for (unsigned int i = 0; i < numOfSamples; i++)
 
            {
 
                for (unsigned int ci = 0; ci < numOfChannels; ci++)
 
                {
 
                    fileStream << channelMan.channelBuffer(ci)->sample(i);
 
                    if (ci != numOfChannels-1) fileStream << ",";
 
                }
 
                fileStream << '\n';
 
            }
 
        }
 
        else
 
        {
 
            qCritical() << "File open error during export: " << file.error();
 
        }
 
        Snapshot* snapshot = snapshotMan.makeSnapshot();
 
        snapshot->save(fileName);
 
        delete snapshot;
 
    }
 
}
 

	
src/snapshotmanager.cpp
Show inline comments
 
@@ -60,7 +60,7 @@ SnapshotManager::~SnapshotManager()
 
    }
 
}
 

	
 
void SnapshotManager::takeSnapshot()
 
Snapshot* SnapshotManager::makeSnapshot()
 
{
 
    QString name = QTime::currentTime().toString("'Snapshot ['HH:mm:ss']'");
 
    auto snapshot = new Snapshot(_mainWindow, name);
 
@@ -78,7 +78,12 @@ void SnapshotManager::takeSnapshot()
 
    }
 
    snapshot->setChannelNames(_channelMan->channelNames()->stringList());
 

	
 
    addSnapshot(snapshot);
 
    return snapshot;
 
}
 

	
 
void SnapshotManager::takeSnapshot()
 
{
 
    addSnapshot(makeSnapshot());
 
}
 

	
 
void SnapshotManager::addSnapshot(Snapshot* snapshot, bool update_menu)
src/snapshotmanager.h
Show inline comments
 
@@ -39,6 +39,10 @@ public:
 
    QMenu* menu();
 
    QAction* takeSnapshotAction();
 

	
 
    /// Creates a dynamically allocated snapshot object but doesn't record it in snapshots list.
 
    /// @note Caller is responsible for deletion of the returned `Snapshot` object.
 
    Snapshot* makeSnapshot();
 

	
 
private:
 
    QMainWindow* _mainWindow;
 
    ChannelManager* _channelMan;
0 comments (0 inline, 0 general)