mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Complete sequence dialog and add export dialog.
This commit is contained in:
parent
0bce27959f
commit
f215d9cc84
@ -4,10 +4,10 @@ project(zint-qt)
|
||||
|
||||
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend" "${CMAKE_SOURCE_DIR}/backend_qt4")
|
||||
|
||||
set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequencewindow.cpp)
|
||||
QT4_WRAP_CPP(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h)
|
||||
set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequencewindow.cpp exportwindow.cpp)
|
||||
QT4_WRAP_CPP(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
|
||||
|
||||
QT4_WRAP_UI(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui)
|
||||
QT4_WRAP_UI(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
|
||||
# grpAztec.ui grpC39.ui grpDM.ui grpMSICheck.ui
|
||||
# grpC128.ui grpChannel.ui grpMicroPDF.ui grpPDF417.ui
|
||||
# grpC16k.ui grpCodablock.ui grpMQR.ui grpQR.ui
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
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>
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef DATAWINDOW_H
|
||||
#define DATAWINDOW_H
|
||||
|
||||
|
33
frontend_qt4/exportwindow.cpp
Normal file
33
frontend_qt4/exportwindow.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
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 <QUiLoader>
|
||||
|
||||
#include "exportwindow.h"
|
||||
|
||||
ExportWindow::ExportWindow()
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
ExportWindow::~ExportWindow()
|
||||
{
|
||||
|
||||
}
|
35
frontend_qt4/exportwindow.h
Normal file
35
frontend_qt4/exportwindow.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef EXPORTWINDOW_H
|
||||
#define EXPORTWINDOW_H
|
||||
|
||||
#include "ui_extExport.h"
|
||||
|
||||
class ExportWindow : public QDialog, private Ui::ExportDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportWindow();
|
||||
~ExportWindow();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -69,18 +69,8 @@
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spnIncrement">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>139</x>
|
||||
<y>80</y>
|
||||
<width>111</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="linFormat">
|
||||
@ -213,6 +203,19 @@
|
||||
<string>Generate Bar Codes:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="linIncVal">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>80</y>
|
||||
<width>113</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
|
@ -1,16 +1,44 @@
|
||||
/*
|
||||
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 "sequencewindow.h"
|
||||
#include <stdio.h>
|
||||
#include "exportwindow.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()
|
||||
@ -26,3 +54,133 @@ 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)) {
|
||||
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;
|
||||
char *streamdata;
|
||||
int streamlen;
|
||||
QString utfstream;
|
||||
|
||||
fdialog.setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
if(fdialog.exec()) {
|
||||
fileName = fdialog.selectedFiles().at(0);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
file.setFileName(fileName);
|
||||
if(!file.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDataStream input(&file);
|
||||
streamlen = input.readRawData(streamdata, 7095);
|
||||
utfstream = streamdata; /* FIXME: Does not take account of encoding scheme of input data */
|
||||
txtPreview->setPlainText(utfstream);
|
||||
file.close();
|
||||
}
|
||||
|
||||
void SequenceWindow::generate_sequence()
|
||||
{
|
||||
int returnval;
|
||||
|
||||
ExportWindow dlg;
|
||||
returnval = dlg.exec();
|
||||
}
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef SEQUENCEWINDOW_H
|
||||
#define SEQUENCEWINDOW_H
|
||||
|
||||
@ -11,9 +30,16 @@ public:
|
||||
SequenceWindow();
|
||||
~SequenceWindow();
|
||||
|
||||
private:
|
||||
QString apply_format(QString raw_number);
|
||||
|
||||
private slots:
|
||||
void quit_now();
|
||||
void reset_preview();
|
||||
void create_sequence();
|
||||
void check_generate();
|
||||
void import();
|
||||
void generate_sequence();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user