@@ -13,24 +13,25 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with serialplot. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QTime>
#include <QMenuBar>
#include <QKeySequence>
#include <QFileDialog>
#include <QFile>
#include <QTextStream>
#include <QVector>
#include <QPointF>
#include <QIcon>
#include <QtDebug>
#include "mainwindow.h"
#include "snapshotmanager.h"
SnapshotManager::SnapshotManager(MainWindow* mainWindow,
ChannelManager* channelMan) :
_menu("&Snapshots"),
_takeSnapshotAction("&Take Snapshot", this),
@@ -150,35 +151,37 @@ void SnapshotManager::loadSnapshotFromFi
qCritical() << "Couldn't open file: " << fileName;
qCritical() << file.errorString();
return;
}
// read first row as headlines and determine number of channels
auto headLine = QString(file.readLine());
QStringList channelNames = headLine.split(',');
unsigned numOfChannels = channelNames.size();
// read data
QVector<QVector<QPointF>> data(numOfChannels);
QTextStream ts(&file);
QString line;
unsigned lineNum = 1;
while (file.canReadLine())
while (ts.readLineInto(&line))
{
// parse line
auto line = QString(file.readLine());
auto split = line.split(',');
if (split.size() != (int) numOfChannels)
qCritical() << "Parsing error at line " << lineNum
<< ": number of columns is not consistent.";
qCritical() << "Line " << lineNum << ": " << line;
for (unsigned ci = 0; ci < numOfChannels; ci++)
// parse column
bool ok;
double y = split[ci].toDouble(&ok);
if (!ok)
<< ", column " << ci
Status change: