0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-04-05 17:03:46 +03:00

Add barcodeVariablesList

This commit is contained in:
Sanych 2024-11-26 17:41:53 +03:00
parent b59dd19555
commit da3e8f302f
11 changed files with 67 additions and 10 deletions

View File

@ -20,6 +20,7 @@ public:
virtual void saveSettings() = 0; virtual void saveSettings() = 0;
virtual void setShowProgressDialog(bool value) = 0; virtual void setShowProgressDialog(bool value) = 0;
virtual void newReport(bool needCheck = true) = 0; virtual void newReport(bool needCheck = true) = 0;
virtual void setBarcodeVariables(const QStringList &) = 0;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -31,6 +31,9 @@
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "qzint.h" #include "qzint.h"
#include "lrglobal.h" #include "lrglobal.h"
#include "objectinspector/editors/lrtextitempropertyeditor.h"
#include <QApplication>
#include "lrreportdesignwindow.h"
namespace{ namespace{
@ -46,9 +49,9 @@ bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instanc
namespace LimeReport{ namespace LimeReport{
BarcodeItem::BarcodeItem(QObject* owner,QGraphicsItem* parent) BarcodeItem::BarcodeItem(QObject* owner,QGraphicsItem* parent)
: ContentItemDesignIntf(xmlTag,owner,parent),m_designTestValue("1"), m_barcodeType(CODE128), : ContentItemDesignIntf(xmlTag,owner,parent),m_designTestValue("1"), m_barcodeType(EAN128),
m_foregroundColor(Qt::black), m_backgroundColor(Qt::white), m_whitespace(10), m_angle(Angle0), m_foregroundColor(Qt::black), m_backgroundColor(Qt::white), m_whitespace(10), m_angle(Angle0),
m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928), m_inputMode(UNICODE_INPUT_MODE), m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928), m_inputMode(GS1_INPUT_MODE),
m_escapeMode(false), m_hideText(false), m_option3(0), m_hideIfEmpty(false) m_escapeMode(false), m_hideText(false), m_option3(0), m_hideIfEmpty(false)
{} {}
@ -353,6 +356,21 @@ bool BarcodeItem::isEmpty() const
return m_content.isEmpty(); return m_content.isEmpty();
} }
QWidget *BarcodeItem::defaultEditor()
{
ReportDesignWindow* dw = nullptr;
auto re = reportEditor();
if(re)
dw = dynamic_cast<ReportDesignWindow*>(re->getDesignerWindow());
qDebug() << re << dw;
auto editor =
new TextItemPropertyEditor(QApplication::activeWindow(),
dw ? dw->barcodeVariables() : QStringList{});
editor->setText(m_content);
editor->setAttribute(Qt::WA_DeleteOnClose);
return editor;
}
void BarcodeItem::expandContent(QString data, DataSourceManager* dataManager, RenderPass pass) void BarcodeItem::expandContent(QString data, DataSourceManager* dataManager, RenderPass pass)
{ {
setContent(expandUserVariables(data, pass, NoEscapeSymbols, dataManager)); setContent(expandUserVariables(data, pass, NoEscapeSymbols, dataManager));

View File

@ -203,7 +203,7 @@ public:
bool hideIfEmpty() const; bool hideIfEmpty() const;
void setHideIfEmpty(bool hideIfEmpty); void setHideIfEmpty(bool hideIfEmpty);
bool isEmpty() const; bool isEmpty() const;
QWidget * defaultEditor();
private: private:
void expandContent(QString data, DataSourceManager *dataManager, RenderPass pass); void expandContent(QString data, DataSourceManager *dataManager, RenderPass pass);

View File

@ -51,7 +51,6 @@ LimeReport::BaseDesignIntf * createTextItem(QObject* owner, LimeReport::BaseDesi
return new LimeReport::TextItem(owner,parent); return new LimeReport::TextItem(owner,parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(xmlTag, LimeReport::ItemAttribs(QObject::tr("Text Item"),"TextItem"), createTextItem); bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(xmlTag, LimeReport::ItemAttribs(QObject::tr("Text Item"),"TextItem"), createTextItem);
} }
namespace LimeReport{ namespace LimeReport{

View File

@ -928,6 +928,13 @@ QImage ReportDesignWindow::previewImage(int pageN)
return QImage{}; return QImage{};
} }
void LimeReport::ReportDesignWindow::setBarcodeVariables(const QStringList &value)
{
m_barcodeVars.clear();
for(const auto &v: value)
m_barcodeVars << QString("$V{%1}").arg(v);
}
bool ReportDesignWindow::checkNeedToSave() bool ReportDesignWindow::checkNeedToSave()
{ {
if (m_reportDesignWidget->isNeedToSave()){ if (m_reportDesignWidget->isNeedToSave()){

View File

@ -75,6 +75,8 @@ public:
void setShowProgressDialog(bool value){m_showProgressDialog = value;} void setShowProgressDialog(bool value){m_showProgressDialog = value;}
void newReport(bool needCheck = true) { slotNewReport(needCheck);} void newReport(bool needCheck = true) { slotNewReport(needCheck);}
QImage previewImage(int pageN = 0); QImage previewImage(int pageN = 0);
virtual void setBarcodeVariables(const QStringList &value);
QStringList barcodeVariables() const {return m_barcodeVars;};
private slots: private slots:
void slotNewReport(bool needCheck = true); void slotNewReport(bool needCheck = true);
void slotNewPage(); void slotNewPage();
@ -292,7 +294,7 @@ private:
QWidget* m_progressWidget; QWidget* m_progressWidget;
QProgressBar* m_progressBar; QProgressBar* m_progressBar;
QLabel* m_progressLabel; QLabel* m_progressLabel;
QStringList m_barcodeVars;
void createProgressBar(); void createProgressBar();
}; };

View File

@ -20,6 +20,7 @@ public:
virtual void saveSettings() = 0; virtual void saveSettings() = 0;
virtual void setShowProgressDialog(bool value) = 0; virtual void setShowProgressDialog(bool value) = 0;
virtual void newReport(bool needCheck = true) = 0; virtual void newReport(bool needCheck = true) = 0;
virtual void setBarcodeVariables(const QStringList &) = 0;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -30,15 +30,22 @@
#include "lrtextitempropertyeditor.h" #include "lrtextitempropertyeditor.h"
#include "ui_ltextitempropertyeditor.h" #include "ui_ltextitempropertyeditor.h"
#include <QCompleter> #include <QCompleter>
#include <QListWidget>
namespace LimeReport{ namespace LimeReport{
TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) : TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent, const QStringList &availVars) :
QDialog(parent), QDialog(parent),
ui(new Ui::TextItemPropertyEditor) ui(new Ui::TextItemPropertyEditor)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->textEdit->setAcceptRichText(false); ui->textEdit->setAcceptRichText(false);
ui->listVars->setVisible(!availVars.isEmpty());
ui->listVars->addItems(availVars);
connect(ui->listVars, &QListWidget::itemClicked, this,
[this](QListWidgetItem *item) {
ui->textEdit->setPlainText(item->text());
});
} }
TextItemPropertyEditor::~TextItemPropertyEditor() TextItemPropertyEditor::~TextItemPropertyEditor()

View File

@ -43,7 +43,7 @@ class TextItemPropertyEditor : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TextItemPropertyEditor(QWidget *parent = 0); explicit TextItemPropertyEditor(QWidget *parent = 0, const QStringList &availVars ={});
~TextItemPropertyEditor(); ~TextItemPropertyEditor();
void setText(const QString &value); void setText(const QString &value);
QString text(); QString text();

View File

@ -9,8 +9,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>530</width>
<height>300</height> <height>369</height>
</rect> </rect>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
@ -24,9 +24,23 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QTextEdit" name="textEdit"/> <widget class="QTextEdit" name="textEdit"/>
</item> </item>
<item>
<widget class="QListWidget" name="listVars">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
@ -38,6 +52,7 @@
</widget> </widget>
<resources> <resources>
<include location="../../items/items.qrc"/> <include location="../../items/items.qrc"/>
<include location="../../items/items.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>

View File

@ -3,6 +3,7 @@
#include "editors/lrbuttonlineeditor.h" #include "editors/lrbuttonlineeditor.h"
#include "items/lrtextitemeditor.h" #include "items/lrtextitemeditor.h"
#include <QApplication> #include <QApplication>
#include <QMessageBox>
namespace{ namespace{
LimeReport::ObjectPropItem * createContentPropItem( LimeReport::ObjectPropItem * createContentPropItem(
@ -11,6 +12,7 @@ namespace{
return new LimeReport::ContentPropItem(object, objects, name, displayName, data, parent, readonly); return new LimeReport::ContentPropItem(object, objects, name, displayName, data, parent, readonly);
} }
bool VARIABLE_IS_NOT_USED registredContentProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("content","LimeReport::TextItem"),QObject::tr("content"),createContentPropItem); bool VARIABLE_IS_NOT_USED registredContentProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("content","LimeReport::TextItem"),QObject::tr("content"),createContentPropItem);
bool VARIABLE_IS_NOT_USED registredContentBProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("content","LimeReport::BarcodeItem"),QObject::tr("content"),createContentPropItem);
} // namespace } // namespace
namespace LimeReport { namespace LimeReport {
@ -22,12 +24,17 @@ QWidget *ContentPropItem::createProperyEditor(QWidget *parent) const
void ContentEditor::editButtonClicked() void ContentEditor::editButtonClicked()
{ {
qDebug() << Q_FUNC_INFO;
QDialog* dialog = new QDialog(QApplication::activeWindow()); QDialog* dialog = new QDialog(QApplication::activeWindow());
dialog->setLayout(new QVBoxLayout()); dialog->setLayout(new QVBoxLayout());
dialog->layout()->setContentsMargins(1,1,1,1); dialog->layout()->setContentsMargins(1,1,1,1);
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowTitle(propertyName()); dialog->setWindowTitle(propertyName());
QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor(); QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor();
if(!editor) {
QMessageBox::critical(QApplication::activeWindow(), tr("Error"), tr("No default editor set"));
return;
}
dialog->layout()->addWidget(editor); dialog->layout()->addWidget(editor);
dialog->resize(editor->size()); dialog->resize(editor->size());
connect(editor,SIGNAL(destroyed()),dialog,SLOT(close())); connect(editor,SIGNAL(destroyed()),dialog,SLOT(close()));