Now with Grid Matrix!

This commit is contained in:
hooper114 2009-10-21 09:08:44 +00:00
parent de7219126a
commit a55b21704e
8 changed files with 2202 additions and 1055 deletions

View File

@ -19,7 +19,6 @@
*/
unsigned long int gb2312_lookup[] = {
{
0x00A4, 0xA1E8,
0x00A7, 0xA1EC,
0x00A8, 0xA1A7,
@ -7465,4 +7464,4 @@ unsigned long int gb2312_lookup[] = {
0xFFE1, 0xA1EA,
0xFFE3, 0xA3FE,
0xFFE5, 0xA3A4
}
};

File diff suppressed because it is too large Load Diff

View File

@ -16,4 +16,144 @@
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.
*/
*/
#define GM_NUMBER 1
#define GM_LOWER 2
#define GM_UPPER 3
#define GM_MIXED 4
#define GM_CONTROL 5
#define GM_BYTE 6
#define GM_CHINESE 7
#define EUROPIUM "0123456789ABCDEFGHIJKLMOPRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
static char shift_set[] = {
/* From Table 7 - Encoding of control characters */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* NULL -> SI */
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* DLE -> US */
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ':',
';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~'
};
static int gm_recommend_cw[] = { 9, 30, 59, 114, 170, 237, 315, 405, 506, 618, 741, 875, 1021 };
static int gm_total_cw[] = { 18, 50, 98, 162, 242, 338, 450, 578, 722, 882, 1058, 1250, 1458 };
static int gm_data_codewords[] = {
0, 15, 13, 11, 9,
45, 40, 35, 30, 25,
89, 79, 69, 59, 49,
146, 130, 114, 98, 81,
218, 194, 170, 146, 121,
305, 271, 237, 203, 169,
405, 360, 315, 270, 225,
521, 463, 405, 347, 289,
650, 578, 506, 434, 361,
794, 706, 618, 530, 441,
953, 847, 741, 635, 529,
1125, 1000, 875, 750, 625,
1313, 1167, 1021, 875, 729
};
static int gm_n1[] = { 18, 50, 98, 81, 121, 113, 113, 116, 121, 126, 118, 125, 122 };
static int gm_b1[] = { 1, 1, 1, 2, 2, 2, 2, 3, 2, 7, 5, 10, 6 };
static int gm_b2[] = { 0, 0, 0, 0, 0, 1, 2, 2, 4, 0, 4, 0, 6 };
static int gm_ebeb[] = {
/* E1 B3 E2 B4 */
0, 0, 0, 0, // version 1
3, 1, 0, 0,
5, 1, 0, 0,
7, 1, 0, 0,
9, 1, 0, 0,
5, 1, 0, 0, // version 2
10, 1, 0, 0,
15, 1, 0, 0,
20, 1, 0, 0,
25, 1, 0, 0,
9, 1, 0, 0, // version 3
19, 1, 0, 0,
29, 1, 0, 0,
39, 1, 0, 0,
49, 1, 0, 0,
8, 2, 0, 0, // version 4
16, 2, 0, 0,
24, 2, 0, 0,
32, 2, 0, 0,
41, 1, 10, 1,
12, 2, 0, 0, // version 5
24, 2, 0, 0,
36, 2, 0, 0,
48, 2, 0, 0,
61, 1, 60, 1,
11, 3, 0, 0, // version 6
23, 1, 22, 2,
34, 2, 33, 1,
45, 3, 0, 0,
57, 1, 56, 2,
12, 1, 11, 3, // version 7
23, 2, 22, 2,
34, 3, 33, 1,
45, 4, 0, 0,
57, 1, 56, 3,
12, 2, 11, 3, // version 8
23, 5, 0, 0,
35, 3, 34, 2,
47, 1, 46, 4,
58, 4, 57, 1,
12, 6, 0, 0, // version 9
24, 6, 0, 0,
36, 6, 0, 0,
48, 6, 0, 0,
61, 1, 60, 5,
13, 4, 12, 3, // version 10
26, 1, 25, 6,
38, 5, 37, 2,
51, 2, 50, 5,
63, 7, 0, 0,
12, 6, 11, 3, // version 11
24, 4, 23, 5,
36, 2, 35, 7,
47, 9, 0, 0,
59, 7, 58, 2,
13, 5, 12, 5, // version 12
25, 10, 0, 0,
38, 5, 37, 5,
50, 10, 0, 0,
63, 5, 62, 5,
13, 1, 12, 11, //version 13
25, 3, 24, 9,
37, 5, 36, 7,
49, 7, 48, 5,
61, 9, 60, 3
};
static int gm_macro_matrix[] = {
728,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,
727,624,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,651,
726,623,528,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,553,652,
725,622,527,440,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,463,554,653,
724,621,526,439,360,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,381,464,555,654,
723,620,525,438,359,288,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,307,382,465,556,655,
722,619,524,437,358,287,224,169,170,171,172,173,174,175,176,177,178,179,180,181,182,241,308,383,466,557,656,
721,618,523,436,357,286,223,168,121,122,123,124,125,126,127,128,129,130,131,132,183,242,309,384,467,558,657,
720,617,522,435,356,285,222,167,120,81,82,83,84,85,86,87,88,89,90,133,184,243,310,385,468,559,658,
719,616,521,434,355,284,221,166,119,80,49,50,51,52,53,54,55,56,91,134,185,244,311,386,469,560,659,
718,615,520,433,354,283,220,165,118,79,48,25,26,27,28,29,30,57,92,135,186,245,312,387,470,561,660,
717,614,519,432,353,282,219,164,117,78,47,24,9,10,11,12,31,58,93,136,187,246,313,388,471,562,661,
716,613,518,431,352,281,218,163,116,77,46,23,8,1,2,13,32,59,94,137,188,247,314,389,472,563,662,
715,612,517,430,351,280,217,162,115,76,45,22,7,0,3,14,33,60,95,138,189,248,315,390,473,564,663,
714,611,516,429,350,279,216,161,114,75,44,21,6,5,4,15,34,61,96,139,190,249,316,391,474,565,664,
713,610,515,428,349,278,215,160,113,74,43,20,19,18,17,16,35,62,97,140,191,250,317,392,475,566,665,
712,609,514,427,348,277,214,159,112,73,42,41,40,39,38,37,36,63,98,141,192,251,318,393,476,567,666,
711,608,513,426,347,276,213,158,111,72,71,70,69,68,67,66,65,64,99,142,193,252,319,394,477,568,667,
710,607,512,425,346,275,212,157,110,109,108,107,106,105,104,103,102,101,100,143,194,253,320,395,478,569,668,
709,606,511,424,345,274,211,156,155,154,153,152,151,150,149,148,147,146,145,144,195,254,321,396,479,570,669,
708,605,510,423,344,273,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,255,322,397,480,571,670,
707,604,509,422,343,272,271,270,269,268,267,266,265,264,263,262,261,260,259,258,257,256,323,398,481,572,671,
706,603,508,421,342,341,340,339,338,337,336,335,334,333,332,331,330,329,328,327,326,325,324,399,482,573,672,
705,602,507,420,419,418,417,416,415,414,413,412,411,410,409,408,407,406,405,404,403,402,401,400,483,574,673,
704,601,506,505,504,503,502,501,500,499,498,497,496,495,494,493,492,491,490,489,488,487,486,485,484,575,674,
703,600,599,598,597,596,595,594,593,592,591,590,589,588,587,586,585,584,583,582,581,580,579,578,577,576,675,
702,701,700,699,698,697,696,695,694,693,692,691,690,689,688,687,686,685,684,683,682,681,680,679,678,677,676,
};

File diff suppressed because it is too large Load Diff

View File

@ -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();
}

View File

@ -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"
};

View File

@ -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,

View File

@ -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();
}