mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Improved data input from file
This commit is contained in:
parent
55f0ea6371
commit
4455c6a893
@ -21,6 +21,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QUiLoader>
|
||||
#include <QStringList>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "datawindow.h"
|
||||
#include <stdio.h>
|
||||
@ -73,9 +74,8 @@ void DataWindow::from_file()
|
||||
QString fileName;
|
||||
QFileDialog fdialog;
|
||||
QFile file;
|
||||
char *streamdata;
|
||||
int streamlen;
|
||||
QString utfstream;
|
||||
QString outstream;
|
||||
char *c;
|
||||
|
||||
fdialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
@ -87,12 +87,14 @@ void DataWindow::from_file()
|
||||
|
||||
file.setFileName(fileName);
|
||||
if(!file.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||
return;
|
||||
}
|
||||
|
||||
QDataStream input(&file);
|
||||
streamlen = input.readRawData(streamdata, 7095);
|
||||
utfstream = streamdata; /* FIXME: Does not take account of encoding scheme of input data */
|
||||
txtDataInput->setPlainText(utfstream);
|
||||
while(file.getChar(c)) {
|
||||
outstream += QChar(*c);
|
||||
}
|
||||
|
||||
txtDataInput->setPlainText(outstream);
|
||||
file.close();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user