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 <QFileDialog>
|
||||||
#include <QUiLoader>
|
#include <QUiLoader>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "datawindow.h"
|
#include "datawindow.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -73,9 +74,8 @@ void DataWindow::from_file()
|
|||||||
QString fileName;
|
QString fileName;
|
||||||
QFileDialog fdialog;
|
QFileDialog fdialog;
|
||||||
QFile file;
|
QFile file;
|
||||||
char *streamdata;
|
QString outstream;
|
||||||
int streamlen;
|
char *c;
|
||||||
QString utfstream;
|
|
||||||
|
|
||||||
fdialog.setFileMode(QFileDialog::ExistingFile);
|
fdialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
|
|
||||||
@ -87,12 +87,14 @@ void DataWindow::from_file()
|
|||||||
|
|
||||||
file.setFileName(fileName);
|
file.setFileName(fileName);
|
||||||
if(!file.open(QIODevice::ReadOnly)) {
|
if(!file.open(QIODevice::ReadOnly)) {
|
||||||
|
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream input(&file);
|
while(file.getChar(c)) {
|
||||||
streamlen = input.readRawData(streamdata, 7095);
|
outstream += QChar(*c);
|
||||||
utfstream = streamdata; /* FIXME: Does not take account of encoding scheme of input data */
|
}
|
||||||
txtDataInput->setPlainText(utfstream);
|
|
||||||
|
txtDataInput->setPlainText(outstream);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user