0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-04-05 00:43: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 setShowProgressDialog(bool value) = 0;
virtual void newReport(bool needCheck = true) = 0;
virtual void setBarcodeVariables(const QStringList &) = 0;
};
} // namespace LimeReport

View File

@ -31,6 +31,9 @@
#include "lrdesignelementsfactory.h"
#include "qzint.h"
#include "lrglobal.h"
#include "objectinspector/editors/lrtextitempropertyeditor.h"
#include <QApplication>
#include "lrreportdesignwindow.h"
namespace{
@ -46,9 +49,9 @@ bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instanc
namespace LimeReport{
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_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)
{}
@ -353,6 +356,21 @@ bool BarcodeItem::isEmpty() const
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)
{
setContent(expandUserVariables(data, pass, NoEscapeSymbols, dataManager));

View File

@ -203,7 +203,7 @@ public:
bool hideIfEmpty() const;
void setHideIfEmpty(bool hideIfEmpty);
bool isEmpty() const;
QWidget * defaultEditor();
private:
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);
}
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(xmlTag, LimeReport::ItemAttribs(QObject::tr("Text Item"),"TextItem"), createTextItem);
}
namespace LimeReport{

View File

@ -928,6 +928,13 @@ QImage ReportDesignWindow::previewImage(int pageN)
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()
{
if (m_reportDesignWidget->isNeedToSave()){

View File

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

View File

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

View File

@ -30,15 +30,22 @@
#include "lrtextitempropertyeditor.h"
#include "ui_ltextitempropertyeditor.h"
#include <QCompleter>
#include <QListWidget>
namespace LimeReport{
TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) :
TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent, const QStringList &availVars) :
QDialog(parent),
ui(new Ui::TextItemPropertyEditor)
{
ui->setupUi(this);
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()

View File

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

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>530</width>
<height>369</height>
</rect>
</property>
<property name="windowIcon">
@ -25,7 +25,21 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
</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>
<widget class="QDialogButtonBox" name="buttonBox">
@ -38,6 +52,7 @@
</widget>
<resources>
<include location="../../items/items.qrc"/>
<include location="../../items/items.qrc"/>
</resources>
<connections>
<connection>

View File

@ -3,6 +3,7 @@
#include "editors/lrbuttonlineeditor.h"
#include "items/lrtextitemeditor.h"
#include <QApplication>
#include <QMessageBox>
namespace{
LimeReport::ObjectPropItem * createContentPropItem(
@ -11,6 +12,7 @@ namespace{
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 registredContentBProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("content","LimeReport::BarcodeItem"),QObject::tr("content"),createContentPropItem);
} // namespace
namespace LimeReport {
@ -22,12 +24,17 @@ QWidget *ContentPropItem::createProperyEditor(QWidget *parent) const
void ContentEditor::editButtonClicked()
{
qDebug() << Q_FUNC_INFO;
QDialog* dialog = new QDialog(QApplication::activeWindow());
dialog->setLayout(new QVBoxLayout());
dialog->layout()->setContentsMargins(1,1,1,1);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowTitle(propertyName());
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->resize(editor->size());
connect(editor,SIGNAL(destroyed()),dialog,SLOT(close()));