mirror of
https://git.code.sf.net/p/zint/code
synced 2025-06-04 16:54:02 -04:00
Structural changes and updates from tgotic
This commit is contained in:
parent
7fa4b32c1d
commit
1695eae7dd
17 changed files with 671 additions and 439 deletions
|
@ -14,13 +14,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
Q_INIT_RESOURCE(resources);
|
||||
QApplication app(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return app.exec();
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<ui version="4.0">
|
||||
<class>mainWindow</class>
|
||||
<widget class="QWidget" name="mainWindow">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
@ -10,10 +13,16 @@
|
|||
<height>711</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>749</width>
|
||||
<height>711</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>800</height>
|
||||
<width>749</width>
|
||||
<height>711</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -21,10 +30,10 @@
|
|||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/zico.png</normaloff>:/zico.png</iconset>
|
||||
<normaloff>:/images/zico.png</normaloff>:/images/zico.png</iconset>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-image: url(:/blueback.png);</string>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
|
@ -50,7 +59,19 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="toolButton_5">
|
||||
<widget class="QToolButton" name="btnZoomOut">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Zoom out</string>
|
||||
</property>
|
||||
|
@ -59,7 +80,7 @@
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/zoomout.png</normaloff>:/zoomout.png</iconset>
|
||||
<normaloff>:/images/zoomout.png</normaloff>:/images/zoomout.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -74,6 +95,9 @@
|
|||
<property name="toolTip">
|
||||
<string>Adjust zoom</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
|
@ -95,13 +119,25 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QToolButton" name="toolButton_4">
|
||||
<widget class="QToolButton" name="btnZoomIn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Zoom in</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/zoomin.png</normaloff>:/zoomin.png</iconset>
|
||||
<normaloff>:/images/zoomin.png</normaloff>:/images/zoomin.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -112,13 +148,28 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<widget class="QToolButton" name="btnRotateLeft">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rotate anti-clockwise</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/rotateleft.png</normaloff>:/rotateleft.png</iconset>
|
||||
<normaloff>:/images/rotateleft.png</normaloff>:/images/rotateleft.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -133,22 +184,46 @@
|
|||
<property name="toolTip">
|
||||
<string>Adjust Rotation</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>360</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>90</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<widget class="QToolButton" name="btnRotatRight">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>28</width>
|
||||
<height>28</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rotate clockwise</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/rotateright.png</normaloff>:/rotateright.png</iconset>
|
||||
<normaloff>:/images/rotateright.png</normaloff>:/images/rotateright.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -391,7 +466,7 @@
|
|||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'DejaVu Sans'; font-size:8pt; font-weight:400; font-style:normal;">
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Your Data Here!</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="acceptRichText">
|
||||
|
@ -704,80 +779,15 @@ p, li { white-space: pre-wrap; }
|
|||
<tabstop>btnSave</tabstop>
|
||||
<tabstop>btnExit</tabstop>
|
||||
<tabstop>view</tabstop>
|
||||
<tabstop>toolButton_5</tabstop>
|
||||
<tabstop>btnZoomOut</tabstop>
|
||||
<tabstop>scaleSlider</tabstop>
|
||||
<tabstop>toolButton_4</tabstop>
|
||||
<tabstop>toolButton</tabstop>
|
||||
<tabstop>btnZoomIn</tabstop>
|
||||
<tabstop>btnRotateLeft</tabstop>
|
||||
<tabstop>rotateSlider</tabstop>
|
||||
<tabstop>toolButton_2</tabstop>
|
||||
<tabstop>btnRotatRight</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>toolButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>rotateSlider</receiver>
|
||||
<slot>subtractStep()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>29</x>
|
||||
<y>265</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>76</x>
|
||||
<y>265</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>toolButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>rotateSlider</receiver>
|
||||
<slot>addStep()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>491</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>431</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>toolButton_4</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>scaleSlider</receiver>
|
||||
<slot>addStep()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>532</x>
|
||||
<y>231</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>528</x>
|
||||
<y>191</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>toolButton_5</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>scaleSlider</receiver>
|
||||
<slot>subtractStep()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>530</x>
|
||||
<y>56</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>530</x>
|
||||
<y>94</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -132,6 +132,10 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
|||
connect(btnMoreData, SIGNAL(clicked( bool )), SLOT(open_data_dialog()));
|
||||
connect(btnSequence, SIGNAL(clicked( bool )), SLOT(open_sequence_dialog()));
|
||||
connect(chkHRTHide, SIGNAL(stateChanged( int )), SLOT(update_preview()));
|
||||
connect(btnZoomIn, SIGNAL(clicked(void)), SLOT(zoomIn(void)));
|
||||
connect(btnZoomOut, SIGNAL(clicked(void)), SLOT(zoomOut(void)));
|
||||
connect(btnRotateLeft, SIGNAL(clicked(void)), SLOT(rotateLeft(void)));
|
||||
connect(btnRotatRight, SIGNAL(clicked(void)), SLOT(rotateRight(void)));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -848,4 +852,23 @@ void MainWindow::update_preview()
|
|||
view->scene()->update();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::zoomIn(void)
|
||||
{
|
||||
scaleSlider->setValue(scaleSlider->value() + scaleSlider->singleStep());
|
||||
}
|
||||
void
|
||||
MainWindow::zoomOut(void)
|
||||
{
|
||||
scaleSlider->setValue(scaleSlider->value() - scaleSlider->singleStep());
|
||||
}
|
||||
void
|
||||
MainWindow::rotateLeft(void)
|
||||
{
|
||||
rotateSlider->setValue(rotateSlider->value() - rotateSlider->singleStep());
|
||||
}
|
||||
void
|
||||
MainWindow::rotateRight(void)
|
||||
{
|
||||
rotateSlider->setValue(rotateSlider->value() + rotateSlider->singleStep());
|
||||
}
|
||||
|
|
|
@ -118,6 +118,10 @@ public slots:
|
|||
void maxi_primary();
|
||||
void change_print_scale();
|
||||
void scaleRotate();
|
||||
void zoomIn(void);
|
||||
void zoomOut(void);
|
||||
void rotateLeft(void);
|
||||
void rotateRight(void);
|
||||
|
||||
private slots:
|
||||
bool save();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>zoomin.png</file>
|
||||
<file>zoomout.png</file>
|
||||
<file>rotateleft.png</file>
|
||||
<file>rotateright.png</file>
|
||||
<file>zico.png</file>
|
||||
<qresource>
|
||||
<file>images/zoomout.png</file>
|
||||
<file>images/rotateleft.png</file>
|
||||
<file>images/rotateright.png</file>
|
||||
<file>images/zico.png</file>
|
||||
<file>images/zoomin.png</file>
|
||||
<file>grpAztec.ui</file>
|
||||
<file>grpC39.ui</file>
|
||||
<file>grpDM.ui</file>
|
||||
|
@ -21,5 +21,5 @@
|
|||
<file>grpCodeOne.ui</file>
|
||||
<file>grpC49.ui</file>
|
||||
<file>grpGrid.ui</file>
|
||||
</qresource>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -1,196 +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 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();
|
||||
}
|
||||
/*
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue