mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Now with Grid Matrix!
This commit is contained in:
@ -1,100 +1,103 @@
|
||||
/*
|
||||
Zint Barcode Generator - the open source barcode generator
|
||||
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QUiLoader>
|
||||
#include <QStringList>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "datawindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
DataWindow::DataWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
|
||||
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
|
||||
}
|
||||
|
||||
DataWindow::DataWindow(QString input)
|
||||
{
|
||||
setupUi(this);
|
||||
txtDataInput->setPlainText(input);
|
||||
txtDataInput->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||
|
||||
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
|
||||
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
|
||||
connect(btnFromFile, SIGNAL( clicked( bool )), SLOT(from_file()));
|
||||
}
|
||||
|
||||
DataWindow::~DataWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void DataWindow::quit_now()
|
||||
{
|
||||
Valid = 0;
|
||||
close();
|
||||
}
|
||||
|
||||
void DataWindow::clear_data()
|
||||
{
|
||||
txtDataInput->clear();
|
||||
}
|
||||
|
||||
void DataWindow::okay()
|
||||
{
|
||||
Valid = 1;
|
||||
DataOutput = txtDataInput->toPlainText();
|
||||
close();
|
||||
}
|
||||
|
||||
void DataWindow::from_file()
|
||||
{
|
||||
QString fileName;
|
||||
QFileDialog fdialog;
|
||||
QFile file;
|
||||
QString outstream;
|
||||
char *c;
|
||||
|
||||
fdialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
if(fdialog.exec()) {
|
||||
fileName = fdialog.selectedFiles().at(0);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
file.setFileName(fileName);
|
||||
if(!file.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||
return;
|
||||
}
|
||||
|
||||
while(file.getChar(c)) {
|
||||
outstream += QChar(*c);
|
||||
}
|
||||
|
||||
txtDataInput->setPlainText(outstream);
|
||||
file.close();
|
||||
/*
|
||||
Zint Barcode Generator - the open source barcode generator
|
||||
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QUiLoader>
|
||||
#include <QStringList>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "datawindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
DataWindow::DataWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
|
||||
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
|
||||
}
|
||||
|
||||
DataWindow::DataWindow(QString input)
|
||||
{
|
||||
setupUi(this);
|
||||
txtDataInput->setPlainText(input);
|
||||
txtDataInput->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
|
||||
|
||||
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
|
||||
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
|
||||
connect(btnFromFile, SIGNAL( clicked( bool )), SLOT(from_file()));
|
||||
}
|
||||
|
||||
DataWindow::~DataWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void DataWindow::quit_now()
|
||||
{
|
||||
Valid = 0;
|
||||
close();
|
||||
}
|
||||
|
||||
void DataWindow::clear_data()
|
||||
{
|
||||
txtDataInput->clear();
|
||||
}
|
||||
|
||||
void DataWindow::okay()
|
||||
{
|
||||
Valid = 1;
|
||||
DataOutput = txtDataInput->toPlainText();
|
||||
close();
|
||||
}
|
||||
|
||||
void DataWindow::from_file()
|
||||
{
|
||||
//QString fileName;
|
||||
//QFileDialog fdialog;
|
||||
QFile file;
|
||||
|
||||
//fdialog.setFileMode(QFileDialog::ExistingFile);
|
||||
//
|
||||
//if(fdialog.exec()) {
|
||||
// fileName = fdialog.selectedFiles().at(0);
|
||||
//} else {
|
||||
// return;
|
||||
//}
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open File"),
|
||||
"./",
|
||||
tr("All Files (*);;Text Files (*.txt)"));
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
file.setFileName(fileName);
|
||||
if(!file.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray outstream = file.readAll();
|
||||
|
||||
txtDataInput->setPlainText(QString(outstream));
|
||||
file.close();
|
||||
}
|
@ -31,17 +31,17 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
{
|
||||
|
||||
char bstyle_text[][50] = {
|
||||
"Australia Post Standard Customer",
|
||||
"Australia Post Redirect Code",
|
||||
"Australia Post Reply-Paid",
|
||||
"Australia Post Routing Code",
|
||||
"Australia Post Redirect Code",
|
||||
"Aztec Code",
|
||||
"Australia Post Standard Customer",
|
||||
"Aztec Code (ISO 24778)",
|
||||
"Aztec Runes",
|
||||
"Channel Code",
|
||||
"Codabar",
|
||||
"Codablock-F",
|
||||
"Code 11",
|
||||
"Code 128",
|
||||
"Code 128 (ISO 15417)",
|
||||
"Code 16k",
|
||||
"Code 2 of 5 Data Logic",
|
||||
"Code 2 of 5 IATA",
|
||||
@ -49,7 +49,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
"Code 2 of 5 Interleaved",
|
||||
"Code 2 of 5 Matrix",
|
||||
"Code 32 (Italian Pharmacode)",
|
||||
"Code 39",
|
||||
"Code 39 (ISO 16388)",
|
||||
"Code 39 Extended",
|
||||
"Code 49",
|
||||
"Code 93",
|
||||
@ -60,37 +60,38 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
"Databar Limited",
|
||||
"Databar Stacked",
|
||||
"Databar Stacked Omnidirectional",
|
||||
"Data Matrix",
|
||||
"Data Matrix (ISO 16022)",
|
||||
"Deutsche Post Identcode",
|
||||
"Deutsche Post Leitcode",
|
||||
"Dutch Post KIX",
|
||||
"EAN-14",
|
||||
"European Article Number (EAN)",
|
||||
"FIM",
|
||||
"Facing Identification Mark (FIM)",
|
||||
"Flattermarken",
|
||||
"Grid Matrix",
|
||||
"ITF-14",
|
||||
"International Standard Book Number (ISBN)",
|
||||
"Japanese Postal Barcode",
|
||||
"Korean Postal Barcode",
|
||||
"LOGMARS",
|
||||
"Maxicode",
|
||||
"MicroPDF417",
|
||||
"Maxicode (ISO 16023)",
|
||||
"MicroPDF417 (ISO 24728)",
|
||||
"Micro QR Code",
|
||||
"MSI Plessey",
|
||||
"NVE-18",
|
||||
"PDF417",
|
||||
"PDF417 (ISO 15438)",
|
||||
"Pharmacode",
|
||||
"Pharmacode 2-track",
|
||||
"Pharma Zentralnummer (PZN)",
|
||||
"PLANET",
|
||||
"Postnet",
|
||||
"QR Code",
|
||||
"QR Code (ISO 18004)",
|
||||
"Royal Mail 4-state Barcode",
|
||||
"Telepen",
|
||||
"Telepen Numeric",
|
||||
"UK Plessey",
|
||||
"UPC-A",
|
||||
"UPC-E",
|
||||
"Universal Product Code (UPC-A)",
|
||||
"Universal Product Code (UPC-E)",
|
||||
"USPS One Code"
|
||||
};
|
||||
|
||||
|
@ -38,10 +38,10 @@ class MainWindow : public QWidget, private Ui::mainWindow
|
||||
public:
|
||||
enum BarcodeTypes
|
||||
{
|
||||
AUSPOST =63,
|
||||
AUSREDIRECT =68,
|
||||
AUSREPLY =66,
|
||||
AUSROUTE =67,
|
||||
AUSREDIRECT =68,
|
||||
AUSPOST =63,
|
||||
AZTEC =92,
|
||||
AZRUNE =128,
|
||||
CHANNEL =140,
|
||||
@ -75,6 +75,7 @@ public:
|
||||
EANX =13,
|
||||
FIM =49,
|
||||
FLAT =28,
|
||||
GRIDMATRIX =142,
|
||||
ITF14 =89,
|
||||
ISBNX =69,
|
||||
JAPANPOST =76,
|
||||
|
@ -1,192 +1,196 @@
|
||||
/*
|
||||
Zint Barcode Generator - the open source barcode generator
|
||||
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QUiLoader>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "sequencewindow.h"
|
||||
#include "exportwindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
SequenceWindow::SequenceWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
QValidator *intvalid = new QIntValidator(this);
|
||||
|
||||
linStartVal->setValidator(intvalid);
|
||||
linEndVal->setValidator(intvalid);
|
||||
linIncVal->setValidator(intvalid);
|
||||
connect(btnClose, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||
connect(btnReset, SIGNAL( clicked( bool )), SLOT(reset_preview()));
|
||||
connect(btnCreate, SIGNAL( clicked( bool )), SLOT(create_sequence()));
|
||||
connect(txtPreview, SIGNAL( textChanged()), SLOT(check_generate()));
|
||||
connect(btnImport, SIGNAL( clicked( bool )), SLOT(import()));
|
||||
connect(btnExport, SIGNAL( clicked( bool )), SLOT(generate_sequence()));
|
||||
}
|
||||
|
||||
SequenceWindow::~SequenceWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void SequenceWindow::quit_now()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void SequenceWindow::reset_preview()
|
||||
{
|
||||
txtPreview->clear();
|
||||
}
|
||||
|
||||
QString SequenceWindow::apply_format(QString raw_number)
|
||||
{
|
||||
QString adjusted, reversed;
|
||||
QString format;
|
||||
int format_len, input_len, i, inpos;
|
||||
char format_char;
|
||||
QChar format_qchar;
|
||||
|
||||
format = linFormat->text();
|
||||
input_len = raw_number.length();
|
||||
format_len = format.length();
|
||||
|
||||
inpos = input_len;
|
||||
|
||||
for(i = format_len; i > 0; i--) {
|
||||
format_qchar = format[i - 1];
|
||||
format_char = format_qchar.toAscii();
|
||||
switch(format_char) {
|
||||
case '#':
|
||||
if (inpos > 0) {
|
||||
adjusted += raw_number[inpos - 1];
|
||||
inpos--;
|
||||
} else {
|
||||
adjusted += ' ';
|
||||
}
|
||||
break;
|
||||
case '$':
|
||||
if (inpos > 0) {
|
||||
adjusted += raw_number[inpos - 1];
|
||||
inpos--;
|
||||
} else {
|
||||
adjusted += '0';
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
if (inpos > 0) {
|
||||
adjusted += raw_number[inpos - 1];
|
||||
inpos--;
|
||||
} else {
|
||||
adjusted += '*';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
adjusted += format_char;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = format_len; i > 0; i--) {
|
||||
reversed += adjusted[i - 1];
|
||||
}
|
||||
|
||||
return reversed;
|
||||
}
|
||||
|
||||
void SequenceWindow::create_sequence()
|
||||
{
|
||||
QString startval, endval, incval, part, outputtext;
|
||||
int start, stop, step, i;
|
||||
bool ok;
|
||||
|
||||
startval = linStartVal->text();
|
||||
endval = linEndVal->text();
|
||||
incval = linIncVal->text();
|
||||
start = startval.toInt(&ok, 10);
|
||||
stop = endval.toInt(&ok, 10);
|
||||
step = incval.toInt(&ok, 10);
|
||||
|
||||
if((stop <= start) || (step <= 0)) {
|
||||
QMessageBox::critical(this, tr("Sequence Error"), tr("One or more of the input values is incorrect."));
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = start; i <= stop; i += step) {
|
||||
part = apply_format(QString::number(i, 10));
|
||||
part += '\n';
|
||||
outputtext += part;
|
||||
}
|
||||
|
||||
txtPreview->setPlainText(outputtext);
|
||||
}
|
||||
|
||||
void SequenceWindow::check_generate()
|
||||
{
|
||||
QString preview_copy;
|
||||
|
||||
preview_copy = txtPreview->toPlainText();
|
||||
if(preview_copy.isEmpty()) {
|
||||
btnExport->setEnabled(false);
|
||||
} else {
|
||||
btnExport->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceWindow::import()
|
||||
{
|
||||
QString fileName;
|
||||
QFileDialog fdialog;
|
||||
QFile file;
|
||||
QString outstream;
|
||||
char *c;
|
||||
|
||||
fdialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
if(fdialog.exec()) {
|
||||
fileName = fdialog.selectedFiles().at(0);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
file.setFileName(fileName);
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||
return;
|
||||
}
|
||||
|
||||
while(file.getChar(c)) {
|
||||
outstream += QChar(*c);
|
||||
}
|
||||
|
||||
txtPreview->setPlainText(outstream);
|
||||
file.close();
|
||||
}
|
||||
|
||||
void SequenceWindow::generate_sequence()
|
||||
{
|
||||
int returnval;
|
||||
|
||||
ExportWindow dlg;
|
||||
dlg.barcode = barcode;
|
||||
dlg.output_data = txtPreview->toPlainText();
|
||||
returnval = dlg.exec();
|
||||
/*
|
||||
Zint Barcode Generator - the open source barcode generator
|
||||
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QUiLoader>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "sequencewindow.h"
|
||||
#include "exportwindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
SequenceWindow::SequenceWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
QValidator *intvalid = new QIntValidator(this);
|
||||
|
||||
linStartVal->setValidator(intvalid);
|
||||
linEndVal->setValidator(intvalid);
|
||||
linIncVal->setValidator(intvalid);
|
||||
connect(btnClose, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||
connect(btnReset, SIGNAL( clicked( bool )), SLOT(reset_preview()));
|
||||
connect(btnCreate, SIGNAL( clicked( bool )), SLOT(create_sequence()));
|
||||
connect(txtPreview, SIGNAL( textChanged()), SLOT(check_generate()));
|
||||
connect(btnImport, SIGNAL( clicked( bool )), SLOT(import()));
|
||||
connect(btnExport, SIGNAL( clicked( bool )), SLOT(generate_sequence()));
|
||||
}
|
||||
|
||||
SequenceWindow::~SequenceWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void SequenceWindow::quit_now()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void SequenceWindow::reset_preview()
|
||||
{
|
||||
txtPreview->clear();
|
||||
}
|
||||
|
||||
QString SequenceWindow::apply_format(QString raw_number)
|
||||
{
|
||||
QString adjusted, reversed;
|
||||
QString format;
|
||||
int format_len, input_len, i, inpos;
|
||||
char format_char;
|
||||
QChar format_qchar;
|
||||
|
||||
format = linFormat->text();
|
||||
input_len = raw_number.length();
|
||||
format_len = format.length();
|
||||
|
||||
inpos = input_len;
|
||||
|
||||
for(i = format_len; i > 0; i--) {
|
||||
format_qchar = format[i - 1];
|
||||
format_char = format_qchar.toAscii();
|
||||
switch(format_char) {
|
||||
case '#':
|
||||
if (inpos > 0) {
|
||||
adjusted += raw_number[inpos - 1];
|
||||
inpos--;
|
||||
} else {
|
||||
adjusted += ' ';
|
||||
}
|
||||
break;
|
||||
case '$':
|
||||
if (inpos > 0) {
|
||||
adjusted += raw_number[inpos - 1];
|
||||
inpos--;
|
||||
} else {
|
||||
adjusted += '0';
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
if (inpos > 0) {
|
||||
adjusted += raw_number[inpos - 1];
|
||||
inpos--;
|
||||
} else {
|
||||
adjusted += '*';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
adjusted += format_char;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = format_len; i > 0; i--) {
|
||||
reversed += adjusted[i - 1];
|
||||
}
|
||||
|
||||
return reversed;
|
||||
}
|
||||
|
||||
void SequenceWindow::create_sequence()
|
||||
{
|
||||
QString startval, endval, incval, part, outputtext;
|
||||
int start, stop, step, i;
|
||||
bool ok;
|
||||
|
||||
startval = linStartVal->text();
|
||||
endval = linEndVal->text();
|
||||
incval = linIncVal->text();
|
||||
start = startval.toInt(&ok, 10);
|
||||
stop = endval.toInt(&ok, 10);
|
||||
step = incval.toInt(&ok, 10);
|
||||
|
||||
if((stop <= start) || (step <= 0)) {
|
||||
QMessageBox::critical(this, tr("Sequence Error"), tr("One or more of the input values is incorrect."));
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = start; i <= stop; i += step) {
|
||||
part = apply_format(QString::number(i, 10));
|
||||
part += '\n';
|
||||
outputtext += part;
|
||||
}
|
||||
|
||||
txtPreview->setPlainText(outputtext);
|
||||
}
|
||||
|
||||
void SequenceWindow::check_generate()
|
||||
{
|
||||
QString preview_copy;
|
||||
|
||||
preview_copy = txtPreview->toPlainText();
|
||||
if(preview_copy.isEmpty()) {
|
||||
btnExport->setEnabled(false);
|
||||
} else {
|
||||
btnExport->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceWindow::import()
|
||||
{
|
||||
//QString fileName;
|
||||
//QFileDialog fdialog;
|
||||
QFile file;
|
||||
QString selectedFilter;
|
||||
|
||||
//fdialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
//if(fdialog.exec()) {
|
||||
// fileName = fdialog.selectedFiles().at(0);
|
||||
//} else {
|
||||
// return;
|
||||
//}
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Import File"),
|
||||
"./",
|
||||
tr("All Files (*);;Text Files (*.txt)"));
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
file.setFileName(fileName);
|
||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray outstream = file.readAll();
|
||||
|
||||
txtPreview->setPlainText(QString(outstream));
|
||||
file.close();
|
||||
}
|
||||
|
||||
void SequenceWindow::generate_sequence()
|
||||
{
|
||||
int returnval;
|
||||
|
||||
ExportWindow dlg;
|
||||
dlg.barcode = barcode;
|
||||
dlg.output_data = txtPreview->toPlainText();
|
||||
returnval = dlg.exec();
|
||||
}
|
Reference in New Issue
Block a user