0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-11-25 08:28:06 +03:00

Define code style and format all source file using clang-format-14

except those placed in 3rdparty directories.
This commit is contained in:
Андрей Лухнов
2024-09-04 17:31:16 +03:00
parent c5b9ac265d
commit 0fca7169d3
285 changed files with 19120 additions and 17875 deletions

View File

@@ -28,23 +28,26 @@
* GNU General Public License for more details. *
****************************************************************************/
#include "lrbuttonlineeditor.h"
#include <QMessageBox>
#include <QEvent>
#include <QKeyEvent>
#include <QFocusEvent>
#include <QApplication>
#include <QEvent>
#include <QFocusEvent>
#include <QKeyEvent>
#include <QMessageBox>
#include <QStyle>
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
#include <QDesktopWidget>
#else
#include <QScreen>
#endif
#include "lrtextitempropertyeditor.h"
namespace LimeReport{
namespace LimeReport {
ButtonLineEditor::ButtonLineEditor(const QString &propertyName, QWidget *parent) :
QWidget(parent), m_overButton(false), m_propertyName(propertyName)
ButtonLineEditor::ButtonLineEditor(const QString& propertyName, QWidget* parent):
QWidget(parent),
m_overButton(false),
m_propertyName(propertyName)
{
m_lineEdit = new QLineEdit(this);
m_lineEdit->installEventFilter(this);
@@ -54,55 +57,53 @@ ButtonLineEditor::ButtonLineEditor(const QString &propertyName, QWidget *parent)
m_buttonEdit->installEventFilter(this);
m_buttonEdit->setAttribute(Qt::WA_Hover);
QHBoxLayout *layout = new QHBoxLayout(this);
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(m_lineEdit);
layout->addWidget(m_buttonEdit);
layout->setContentsMargins(1,1,1,1);
layout->setContentsMargins(1, 1, 1, 1);
layout->setSpacing(0);
setAutoFillBackground(true);
connect(m_buttonEdit,SIGNAL(clicked()),this,SLOT(editButtonClicked()));
//connect(m_lineEdit,SIGNAL(editingFinished()),this,SLOT(lineEditEditingFinished()));
connect(m_buttonEdit, SIGNAL(clicked()), this, SLOT(editButtonClicked()));
// connect(m_lineEdit,SIGNAL(editingFinished()),this,SLOT(lineEditEditingFinished()));
}
ButtonLineEditor::~ButtonLineEditor(){}
ButtonLineEditor::~ButtonLineEditor() { }
void ButtonLineEditor::editButtonClicked()
{
TextItemPropertyEditor* editor = new TextItemPropertyEditor(QApplication::activeWindow());
editor->setAttribute(Qt::WA_DeleteOnClose);
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->availableGeometry()));
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(),
QApplication::desktop()->availableGeometry()));
#else
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QGuiApplication::screens().first()->availableGeometry()));
editor->setGeometry(
QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(),
QGuiApplication::screens().first()->availableGeometry()));
#endif
editor->setWindowTitle(m_propertyName);
editor->setText(m_lineEdit->text());
connect(editor,SIGNAL(accepted()),this,SLOT(editingByEditorFinished()));
connect(editor, SIGNAL(accepted()), this, SLOT(editingByEditorFinished()));
editor->exec();
}
void ButtonLineEditor::setText(const QString &value){
m_lineEdit->setText(value);
}
void ButtonLineEditor::setText(const QString& value) { m_lineEdit->setText(value); }
QString ButtonLineEditor::text()
{
return m_lineEdit->text();
}
QString ButtonLineEditor::text() { return m_lineEdit->text(); }
bool ButtonLineEditor::eventFilter(QObject *target, QEvent *event)
bool ButtonLineEditor::eventFilter(QObject* target, QEvent* event)
{
if (target==m_buttonEdit) {
if (target == m_buttonEdit) {
if (event->type()==QEvent::HoverEnter){
m_overButton=true;
if (event->type() == QEvent::HoverEnter) {
m_overButton = true;
}
if (event->type()==QEvent::HoverLeave){
m_overButton=false;
if (event->type() == QEvent::HoverLeave) {
m_overButton = false;
}
if (event->type()==QEvent::FocusOut){
if (static_cast<QFocusEvent*>(event)->reason()!=Qt::MouseFocusReason){
if (event->type() == QEvent::FocusOut) {
if (static_cast<QFocusEvent*>(event)->reason() != Qt::MouseFocusReason) {
m_lineEdit->setFocus();
}
}
@@ -110,29 +111,27 @@ bool ButtonLineEditor::eventFilter(QObject *target, QEvent *event)
enterKeys.insert(Qt::Key_Enter);
enterKeys.insert(Qt::Key_Return);
if (event->type()==QEvent::KeyPress){
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())){
if (event->type() == QEvent::KeyPress) {
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())) {
m_buttonEdit->click();
return true;
}
}
}
if (target==m_lineEdit){
if (event->type()==QEvent::FocusOut){
switch (static_cast<QFocusEvent*>(event)->reason()){
if (target == m_lineEdit) {
if (event->type() == QEvent::FocusOut) {
switch (static_cast<QFocusEvent*>(event)->reason()) {
case Qt::TabFocusReason:
m_overButton=true;
m_overButton = true;
break;
case Qt::MouseFocusReason:
break;
default:
m_overButton=false;
m_overButton = false;
}
}
}
return QWidget::eventFilter(target,event);
return QWidget::eventFilter(target, event);
}
void ButtonLineEditor::editingByEditorFinished()
@@ -142,4 +141,4 @@ void ButtonLineEditor::editingByEditorFinished()
emit editingFinished();
}
} //namespace LimeReport
} // namespace LimeReport

View File

@@ -30,41 +30,44 @@
#ifndef LRBUTTONLINEEDIT_H
#define LRBUTTONLINEEDIT_H
#include <QWidget>
#include "lrtextitempropertyeditor.h"
#include <QDebug>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QToolButton>
#include <QHBoxLayout>
#include <QDebug>
#include "lrtextitempropertyeditor.h"
#include <QWidget>
namespace LimeReport{
namespace LimeReport {
class ButtonLineEditor : public QWidget
{
class ButtonLineEditor: public QWidget {
Q_OBJECT
public:
explicit ButtonLineEditor(const QString& propertyName,QWidget *parent = 0);
explicit ButtonLineEditor(const QString& propertyName, QWidget* parent = 0);
~ButtonLineEditor();
void setText(const QString &value);
void setText(const QString& value);
QString text();
signals:
void editingFinished();
public slots:
virtual void editButtonClicked();
void editingByEditorFinished();
protected:
QString propertyName(){return m_propertyName;}
QString propertyName() { return m_propertyName; }
private:
QLineEdit* m_lineEdit;
QToolButton* m_buttonEdit;
bool m_overButton;
QString m_propertyName;
private:
bool eventFilter(QObject *, QEvent *);
//QHBoxLayout* m_layout;
bool eventFilter(QObject*, QEvent*);
// QHBoxLayout* m_layout;
};
} //namespace LimeReport
} // namespace LimeReport
#endif // LRBUTTONLINEEDIT_H

View File

@@ -28,33 +28,34 @@
* GNU General Public License for more details. *
****************************************************************************/
#include "lrcheckboxeditor.h"
#include <QDebug>
#include <QPainter>
#include <QVBoxLayout>
#include <QKeyEvent>
#include <QApplication>
#include <QDebug>
#include <QKeyEvent>
#include <QPainter>
#include <QStyle>
#include <QVBoxLayout>
namespace LimeReport{
namespace LimeReport {
CheckBoxEditor::CheckBoxEditor(QWidget *parent)
:QWidget(parent), m_editing(false)
{
CheckBoxEditor::CheckBoxEditor(QWidget* parent): QWidget(parent), m_editing(false)
{
m_checkBox = new QCheckBox(this);
init();
}
CheckBoxEditor::CheckBoxEditor(const QString &text, QWidget *parent)
:QWidget(parent), m_editing(false)
CheckBoxEditor::CheckBoxEditor(const QString& text, QWidget* parent):
QWidget(parent),
m_editing(false)
{
m_checkBox = new QCheckBox(text,this);
m_checkBox = new QCheckBox(text, this);
init();
}
CheckBoxEditor::~CheckBoxEditor(){}
CheckBoxEditor::~CheckBoxEditor() { }
void CheckBoxEditor::init()
{
QVBoxLayout *layout=new QVBoxLayout(this);
{
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addStretch();
layout->addWidget(m_checkBox);
#ifdef HAVE_QT5
@@ -62,56 +63,45 @@ void CheckBoxEditor::init()
#endif
connect(m_checkBox, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int)));
layout->addStretch();
layout->setContentsMargins(2,1,1,1);
layout->setContentsMargins(2, 1, 1, 1);
layout->setSpacing(0);
setLayout(layout);
setAutoFillBackground(true);
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
}
void CheckBoxEditor::setEditing(bool value)
{
m_editing=value;
}
void CheckBoxEditor::setEditing(bool value) { m_editing = value; }
void CheckBoxEditor::setChecked(bool value)
{
m_checkBox->setChecked(value);
}
void CheckBoxEditor::setChecked(bool value) { m_checkBox->setChecked(value); }
bool CheckBoxEditor::isChecked()
{
return m_checkBox->isChecked();
}
bool CheckBoxEditor::isChecked() { return m_checkBox->isChecked(); }
void CheckBoxEditor::mousePressEvent(QMouseEvent *)
void CheckBoxEditor::mousePressEvent(QMouseEvent*)
{
m_checkBox->setChecked(!m_checkBox->isChecked());
emit editingFinished();
}
void CheckBoxEditor::keyPressEvent(QKeyEvent *event)
void CheckBoxEditor::keyPressEvent(QKeyEvent* event)
{
if (event->key()==Qt::Key_Space) m_checkBox->setChecked(!m_checkBox->isChecked());
if ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down)){
if (event->key() == Qt::Key_Space)
m_checkBox->setChecked(!m_checkBox->isChecked());
if ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down)) {
emit editingFinished();
}
QWidget::keyPressEvent(event);
}
void CheckBoxEditor::showEvent(QShowEvent *)
void CheckBoxEditor::showEvent(QShowEvent*)
{
int border = (height() - QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth))/2
int border = (height() - QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth)) / 2
#ifdef Q_OS_MAC
+QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
+ QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
#endif
;
layout()->setContentsMargins(border,0,0,0);
;
layout()->setContentsMargins(border, 0, 0, 0);
}
void CheckBoxEditor::slotStateChanged(int)
{
emit editingFinished();
}
void CheckBoxEditor::slotStateChanged(int) { emit editingFinished(); }
}
} // namespace LimeReport

View File

@@ -32,33 +32,33 @@
#include <QCheckBox>
namespace LimeReport{
namespace LimeReport {
class CheckBoxEditor : public QWidget
{
class CheckBoxEditor: public QWidget {
Q_OBJECT
public:
CheckBoxEditor(QWidget * parent = 0);
CheckBoxEditor(const QString & text, QWidget * parent = 0);
CheckBoxEditor(QWidget* parent = 0);
CheckBoxEditor(const QString& text, QWidget* parent = 0);
~CheckBoxEditor();
void setEditing(bool value);
void setChecked(bool value);
bool isChecked();
protected:
void mousePressEvent(QMouseEvent *);
void keyPressEvent(QKeyEvent *event);
void showEvent(QShowEvent *);
void mousePressEvent(QMouseEvent*);
void keyPressEvent(QKeyEvent* event);
void showEvent(QShowEvent*);
signals:
void editingFinished();
private slots:
void slotStateChanged(int);
private:
QCheckBox* m_checkBox;
bool m_editing;
void init();
};
}
} // namespace LimeReport
#endif // LRCHECKBOXEDITOR_H

View File

@@ -28,50 +28,50 @@
* GNU General Public License for more details. *
****************************************************************************/
#include "lrcoloreditor.h"
#include "lrglobal.h"
#include <QHBoxLayout>
#include <QApplication>
#include <QColorDialog>
#include <QHBoxLayout>
#include <QPaintEvent>
#include <QPainter>
#include <QApplication>
#include <QStyle>
namespace LimeReport{
namespace LimeReport {
ColorEditor::ColorEditor(QWidget *parent) :
QWidget(parent), m_buttonPressed(false)
ColorEditor::ColorEditor(QWidget* parent): QWidget(parent), m_buttonPressed(false)
{
m_colorIndicator = new ColorIndicator(this);
m_colorIndicator->setColor(m_color);
m_button = new QToolButton(this);
m_button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_button->setText("...");
m_button->installEventFilter(this);
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(m_colorIndicator);
layout->addWidget(m_button);
layout->setSpacing(0);
layout->setContentsMargins(1,1,1,1);
layout->setContentsMargins(1, 1, 1, 1);
setFocusProxy(m_button);
setAutoFillBackground(true);
setLayout(layout);
setAutoFillBackground(true);
connect(m_button,SIGNAL(clicked()),this,SLOT(slotClicked()));
connect(m_button, SIGNAL(clicked()), this, SLOT(slotClicked()));
}
void ColorEditor::setColor(const QColor &value)
void ColorEditor::setColor(const QColor& value)
{
m_color=value;
m_color = value;
m_colorIndicator->setColor(m_color);
}
bool ColorEditor::eventFilter(QObject *obj, QEvent *event)
bool ColorEditor::eventFilter(QObject* obj, QEvent* event)
{
if (obj == m_button){
if (event->type() == QEvent::FocusOut && !m_buttonPressed){
if (obj == m_button) {
if (event->type() == QEvent::FocusOut && !m_buttonPressed) {
QFocusEvent* focusEvent = dynamic_cast<QFocusEvent*>(event);
if (focusEvent && focusEvent->reason()!=Qt::MouseFocusReason){
if (focusEvent && focusEvent->reason() != Qt::MouseFocusReason) {
setFocusToParent();
emit(editingFinished());
}
@@ -81,7 +81,8 @@ bool ColorEditor::eventFilter(QObject *obj, QEvent *event)
return false;
}
void ColorEditor::setFocusToParent(){
void ColorEditor::setFocusToParent()
{
if (parentWidget())
parentWidget()->setFocus();
}
@@ -91,7 +92,8 @@ void ColorEditor::slotClicked()
m_buttonPressed = true;
QColorDialog* dialog = new QColorDialog(this);
dialog->setCurrentColor(m_color);
if (dialog->exec()) m_color=dialog->currentColor();
if (dialog->exec())
m_color = dialog->currentColor();
delete dialog;
setFocusToParent();
emit(editingFinished());
@@ -107,36 +109,27 @@ void ColorIndicator::paintEvent(QPaintEvent* event)
QColor penColor = isColorDark(m_color) ? Qt::transparent : Qt::darkGray;
painter.setPen(penColor);
int border = (event->rect().height() - style->pixelMetric(QStyle::PM_IndicatorWidth))/2;
int border = (event->rect().height() - style->pixelMetric(QStyle::PM_IndicatorWidth)) / 2;
QRect rect(event->rect().x()+border, event->rect().y()+border,
QRect rect(event->rect().x() + border, event->rect().y() + border,
style->pixelMetric(QStyle::PM_IndicatorWidth),
style->pixelMetric(QStyle::PM_IndicatorWidth));// = option.rect.adjusted(4,4,-4,-6);
style->pixelMetric(QStyle::PM_IndicatorWidth)); // = option.rect.adjusted(4,4,-4,-6);
painter.drawRect(rect);
painter.restore();
}
ColorIndicator::ColorIndicator(QWidget *parent)
:QWidget(parent), m_color(Qt::white){
ColorIndicator::ColorIndicator(QWidget* parent): QWidget(parent), m_color(Qt::white)
{
setAttribute(Qt::WA_StaticContents);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
setFocusPolicy(Qt::NoFocus);
}
QColor ColorIndicator::color() const
{
return m_color;
}
QColor ColorIndicator::color() const { return m_color; }
void ColorIndicator::setColor(const QColor &color)
{
m_color = color;
}
void ColorIndicator::setColor(const QColor& color) { m_color = color; }
QSize ColorIndicator::sizeHint() const
{
return QSize(20,20);
}
QSize ColorIndicator::sizeHint() const { return QSize(20, 20); }
} // namespace LimeReport

View File

@@ -30,45 +30,49 @@
#ifndef LRCOLOREDITOR_H
#define LRCOLOREDITOR_H
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
#include <QWidget>
namespace LimeReport{
namespace LimeReport {
class ColorIndicator : public QWidget{
class ColorIndicator: public QWidget {
Q_OBJECT
public:
ColorIndicator(QWidget* parent = 0);
QColor color() const;
void setColor(const QColor &color);
void setColor(const QColor& color);
QSize sizeHint() const;
protected:
void paintEvent(QPaintEvent *event);
void paintEvent(QPaintEvent* event);
private:
QColor m_color;
};
class ColorEditor : public QWidget
{
class ColorEditor: public QWidget {
Q_OBJECT
public:
explicit ColorEditor(QWidget *parent = 0);
QColor color(){return m_color;}
explicit ColorEditor(QWidget* parent = 0);
QColor color() { return m_color; }
void setColor(const QColor& value);
protected:
bool eventFilter(QObject *obj, QEvent *event);
bool eventFilter(QObject* obj, QEvent* event);
private:
void setFocusToParent();
signals:
void editingFinished();
void editingFinished();
private slots:
void slotClicked();
void slotClicked();
private:
QColor m_color;
QToolButton* m_button;
ColorIndicator* m_colorIndicator;
bool m_buttonPressed;
QColor m_color;
QToolButton* m_button;
ColorIndicator* m_colorIndicator;
bool m_buttonPressed;
};
} // namespace LimeReport

View File

@@ -27,19 +27,20 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
****************************************************************************/
#include <QHBoxLayout>
#include <QToolButton>
#include "lrcomboboxeditor.h"
#include <QComboBox>
#include <QLineEdit>
#include <QDebug>
#include <QEvent>
#include <QFocusEvent>
#include <QHBoxLayout>
#include <QKeyEvent>
#include "lrcomboboxeditor.h"
#include <QLineEdit>
#include <QToolButton>
namespace LimeReport{
namespace LimeReport {
ComboBoxEditor::ComboBoxEditor(QWidget *parent, bool clearable) :
ComboBoxEditor::ComboBoxEditor(QWidget* parent, bool clearable):
QWidget(parent),
m_comboBox(new InternalComboBox(this)),
m_buttonClear(0),
@@ -51,37 +52,41 @@ ComboBoxEditor::ComboBoxEditor(QWidget *parent, bool clearable) :
m_buttonClear = new QToolButton(this);
m_buttonClear->setIcon(QIcon(":/items/clear.png"));
m_buttonClear->installEventFilter(this);
m_buttonClear->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
m_buttonClear->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
m_buttonClear->setMaximumHeight(QWIDGETSIZE_MAX);
connect(m_buttonClear,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
connect(m_buttonClear, SIGNAL(clicked()), this, SLOT(slotClearButtonClicked()));
}
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
connect(m_comboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString)));
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
connect(m_comboBox, SIGNAL(currentTextChanged(QString)), this,
SLOT(slotCurrentIndexChanged(QString)));
#else
connect(m_comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString)));
connect(m_comboBox, SIGNAL(currentIndexChanged(QString)), this,
SLOT(slotCurrentIndexChanged(QString)));
#endif
m_comboBox->installEventFilter(this);
QHBoxLayout *layout = new QHBoxLayout(this);
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(m_comboBox);
if (clearable)
layout->addWidget(m_buttonClear);
layout->setContentsMargins(0,0,0,0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(2);
setLayout(layout);
setAutoFillBackground(true);
}
void ComboBoxEditor::addItems(const QStringList &values){
void ComboBoxEditor::addItems(const QStringList& values)
{
m_settingValues = true;
m_comboBox->addItems(values);
m_settingValues = false;
}
void ComboBoxEditor::setTextValue(const QString &value){
void ComboBoxEditor::setTextValue(const QString& value)
{
m_settingValues = true;
if (m_comboBox->findText(value)>0){
if (m_comboBox->findText(value) > 0) {
m_comboBox->setCurrentIndex(m_comboBox->findText(value));
} else {
m_comboBox->setEditText(value);
@@ -89,20 +94,16 @@ void ComboBoxEditor::setTextValue(const QString &value){
m_settingValues = false;
}
void ComboBoxEditor::slotClearButtonClicked(){
m_comboBox->setCurrentIndex(-1);
}
void ComboBoxEditor::slotClearButtonClicked() { m_comboBox->setCurrentIndex(-1); }
void ComboBoxEditor::slotCurrentIndexChanged(const QString& value)
{
if (!m_settingValues){
if (!m_settingValues) {
emit currentIndexChanged(value);
}
}
QString ComboBoxEditor::text(){
return m_comboBox->currentText();
}
QString ComboBoxEditor::text() { return m_comboBox->currentText(); }
void ComboBoxEditor::setEditable(bool value)
{
@@ -111,10 +112,11 @@ void ComboBoxEditor::setEditable(bool value)
}
}
bool ComboBoxEditor::eventFilter(QObject *target, QEvent *event){
if (target == m_buttonClear){
if (event->type()==QEvent::FocusOut){
if (static_cast<QFocusEvent*>(event)->reason()!=Qt::MouseFocusReason){
bool ComboBoxEditor::eventFilter(QObject* target, QEvent* event)
{
if (target == m_buttonClear) {
if (event->type() == QEvent::FocusOut) {
if (static_cast<QFocusEvent*>(event)->reason() != Qt::MouseFocusReason) {
m_comboBox->setFocus();
}
}
@@ -122,28 +124,27 @@ bool ComboBoxEditor::eventFilter(QObject *target, QEvent *event){
enterKeys.insert(Qt::Key_Enter);
enterKeys.insert(Qt::Key_Return);
if (event->type()==QEvent::KeyPress){
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())){
if (event->type() == QEvent::KeyPress) {
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())) {
m_buttonClear->click();
return true;
}
}
}
if (target == m_comboBox){
if (event->type() == QEvent::FocusOut){
if (target == m_comboBox) {
if (event->type() == QEvent::FocusOut) {
if (!m_comboBox->isPopup() || (m_buttonClear && m_buttonClear->hasFocus()))
emit editingFinished();
}
}
return QWidget::eventFilter(target,event);
return QWidget::eventFilter(target, event);
}
void ComboBoxEditor::resizeEvent(QResizeEvent *e)
void ComboBoxEditor::resizeEvent(QResizeEvent* e)
{
if (m_buttonClear)
m_buttonClear->setMinimumHeight(e->size().height()-4);
m_buttonClear->setMinimumHeight(e->size().height() - 4);
}
} // namespace LimeReport

View File

@@ -30,32 +30,39 @@
#ifndef LRCOMBOBOXEDITOR_H
#define LRCOMBOBOXEDITOR_H
#include <QWidget>
#include <QComboBox>
#include <QWidget>
//#include <QPushButton>
class QToolButton;
namespace LimeReport{
namespace LimeReport {
class InternalComboBox :public QComboBox{
class InternalComboBox: public QComboBox {
Q_OBJECT
public:
InternalComboBox(QWidget* parent=0):QComboBox(parent),m_popup(false){}
void showPopup(){m_popup = true;QComboBox::showPopup();}
void hidePopup(){QComboBox::hidePopup(); m_popup = false;}
bool isPopup(){return m_popup;}
InternalComboBox(QWidget* parent = 0): QComboBox(parent), m_popup(false) { }
void showPopup()
{
m_popup = true;
QComboBox::showPopup();
}
void hidePopup()
{
QComboBox::hidePopup();
m_popup = false;
}
bool isPopup() { return m_popup; }
private:
bool m_popup;
};
class ComboBoxEditor : public QWidget
{
class ComboBoxEditor: public QWidget {
Q_OBJECT
public:
//explicit ComboBoxEditor(QWidget *parent = 0);
ComboBoxEditor(QWidget *parent=0, bool clearable=false);
// explicit ComboBoxEditor(QWidget *parent = 0);
ComboBoxEditor(QWidget* parent = 0, bool clearable = false);
void addItems(const QStringList& values);
void setTextValue(const QString& value);
QString text();
@@ -63,13 +70,15 @@ public:
signals:
void editingFinished();
void currentIndexChanged(const QString&);
protected:
void resizeEvent(QResizeEvent *e);
void resizeEvent(QResizeEvent* e);
private slots:
void slotClearButtonClicked();
void slotCurrentIndexChanged(const QString& value);
private:
bool eventFilter(QObject *target, QEvent *event);
bool eventFilter(QObject* target, QEvent* event);
InternalComboBox* m_comboBox;
QToolButton* m_buttonClear;
bool m_settingValues;

View File

@@ -28,58 +28,57 @@
* GNU General Public License for more details. *
****************************************************************************/
#include "lrfonteditor.h"
#include <QHBoxLayout>
#include <QFontDialog>
#include <QDebug>
#include <QFontDialog>
#include <QHBoxLayout>
namespace LimeReport{
namespace LimeReport {
FontEditor::FontEditor(QWidget *parent) :
QWidget(parent)
FontEditor::FontEditor(QWidget* parent): QWidget(parent)
{
//m_button = new QPushButton(this);
// m_button = new QPushButton(this);
m_button = new QToolButton(this);
m_button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
m_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(m_button);
layout->setSpacing(0);
layout->setContentsMargins(1,1,1,1);
layout->setContentsMargins(1, 1, 1, 1);
setFocusProxy(m_button);
setLayout(layout);
setAutoFillBackground(true);
connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonCliked()));
connect(m_button, SIGNAL(clicked()), this, SLOT(slotButtonCliked()));
}
FontEditor::~FontEditor()
{}
FontEditor::~FontEditor() { }
void FontEditor::setFontValue(const QFont &font)
void FontEditor::setFontValue(const QFont& font)
{
m_font=font;
m_font = font;
m_button->setText(toString(font));
}
QFont FontEditor::fontValue()
{
return m_font;
}
QFont FontEditor::fontValue() { return m_font; }
void FontEditor::slotButtonCliked()
{
QFontDialog* dialog = new QFontDialog(this);
dialog->setCurrentFont(m_font);
if (dialog->exec()) m_font=dialog->currentFont();
if (dialog->exec())
m_font = dialog->currentFont();
delete dialog;
emit(editingFinished());
}
QString FontEditor::toString(const QFont &value) const
QString FontEditor::toString(const QFont& value) const
{
QString attribs="[";
if (value.bold()) (attribs=="[") ? attribs+="b":attribs+=",b";
if (value.italic()) (attribs=="[") ? attribs+="i":attribs+=",i";
attribs+="]";
return value.family()+" "+QString::number(value.pointSize())+" "+attribs;
QString attribs = "[";
if (value.bold())
(attribs == "[") ? attribs += "b" : attribs += ",b";
if (value.italic())
(attribs == "[") ? attribs += "i" : attribs += ",i";
attribs += "]";
return value.family() + " " + QString::number(value.pointSize()) + " " + attribs;
}
} // namespace LimeReport

View File

@@ -30,28 +30,29 @@
#ifndef LRFONTEDITOR_H
#define LRFONTEDITOR_H
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
#include <QWidget>
namespace LimeReport{
namespace LimeReport {
class FontEditor : public QWidget
{
class FontEditor: public QWidget {
Q_OBJECT
public:
explicit FontEditor(QWidget *parent = 0);
explicit FontEditor(QWidget* parent = 0);
~FontEditor();
void setFontValue(const QFont &font);
void setFontValue(const QFont& font);
QFont fontValue();
signals:
void editingFinished();
public slots:
void slotButtonCliked();
private:
QString toString(const QFont& value) const;
private:
//QPushButton* m_button;
// QPushButton* m_button;
QToolButton* m_button;
QFont m_font;
};

View File

@@ -27,14 +27,14 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
****************************************************************************/
#include <QHBoxLayout>
#include <QFileDialog>
#include "lrimageeditor.h"
namespace LimeReport{
#include <QFileDialog>
#include <QHBoxLayout>
ImageEditor::ImageEditor(QWidget* parent)
:QWidget(parent)
namespace LimeReport {
ImageEditor::ImageEditor(QWidget* parent): QWidget(parent)
{
m_button.setIcon(QIcon(":items/ImageItem"));
m_clearButton.setIcon(QIcon(":items/clear.png"));
@@ -42,18 +42,15 @@ ImageEditor::ImageEditor(QWidget* parent)
layout->addWidget(&m_button);
layout->addWidget(&m_clearButton);
layout->setSpacing(1);
layout->setContentsMargins(1,0,1,1);
layout->setContentsMargins(1, 0, 1, 1);
setLayout(layout);
setFocusProxy(&m_button);
setAutoFillBackground(true);
connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
connect(&m_clearButton,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
connect(&m_button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
connect(&m_clearButton, SIGNAL(clicked()), this, SLOT(slotClearButtonClicked()));
}
QImage ImageEditor::image()
{
return m_image;
}
QImage ImageEditor::image() { return m_image; }
void ImageEditor::slotButtonClicked()
{
@@ -67,4 +64,4 @@ void ImageEditor::slotClearButtonClicked()
emit editingFinished();
}
} //namespace LimeReport
} // namespace LimeReport

View File

@@ -29,24 +29,24 @@
****************************************************************************/
#ifndef LRIMAGEEDITOR_H
#define LRIMAGEEDITOR_H
#include <QWidget>
#include <QPushButton>
#include <QWidget>
namespace LimeReport{
namespace LimeReport {
class ImageEditor : public QWidget
{
class ImageEditor: public QWidget {
Q_OBJECT
public:
ImageEditor(QWidget *parent=0);
ImageEditor(QWidget* parent = 0);
QImage image();
void setImage(const QImage& image){m_image=image;}
void setImage(const QImage& image) { m_image = image; }
signals:
void editingFinished();
private slots:
void slotButtonClicked();
void slotClearButtonClicked();
private:
QPushButton m_button;
QPushButton m_clearButton;

View File

@@ -1,12 +1,13 @@
#include "lrsvgeditor.h"
#include <QHBoxLayout>
#include <QFileDialog>
#include "lrimageeditor.h"
namespace LimeReport{
#include <QFileDialog>
#include <QHBoxLayout>
SvgEditor::SvgEditor(QWidget* parent)
:QWidget(parent)
namespace LimeReport {
SvgEditor::SvgEditor(QWidget* parent): QWidget(parent)
{
m_button.setIcon(QIcon(":items/ImageItem"));
m_clearButton.setIcon(QIcon(":items/clear.png"));
@@ -14,25 +15,23 @@ SvgEditor::SvgEditor(QWidget* parent)
layout->addWidget(&m_button);
layout->addWidget(&m_clearButton);
layout->setSpacing(1);
layout->setContentsMargins(1,0,1,1);
layout->setContentsMargins(1, 0, 1, 1);
setLayout(layout);
setFocusProxy(&m_button);
setAutoFillBackground(true);
connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
connect(&m_clearButton,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
connect(&m_button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
connect(&m_clearButton, SIGNAL(clicked()), this, SLOT(slotClearButtonClicked()));
}
QByteArray SvgEditor::image()
{
return m_image;
}
QByteArray SvgEditor::image() { return m_image; }
void SvgEditor::slotButtonClicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", "SVG (*.svg)");
if (!fileName.isEmpty()){
QString fileName
= QFileDialog::getOpenFileName(this, tr("Select image file"), "", "SVG (*.svg)");
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.open(QIODevice::ReadOnly)){
if (file.open(QIODevice::ReadOnly)) {
m_image = file.readAll();
}
}
@@ -45,4 +44,4 @@ void SvgEditor::slotClearButtonClicked()
emit editingFinished();
}
}
} // namespace LimeReport

View File

@@ -1,27 +1,27 @@
#ifndef SVGEDITOR_H
#define SVGEDITOR_H
#include <QWidget>
#include <QPushButton>
#include <QWidget>
namespace LimeReport{
namespace LimeReport {
class SvgEditor : public QWidget
{
class SvgEditor: public QWidget {
Q_OBJECT
public:
SvgEditor(QWidget *parent=0);
SvgEditor(QWidget* parent = 0);
QByteArray image();
void setImage(const QByteArray& image){m_image=image;}
void setImage(const QByteArray& image) { m_image = image; }
signals:
void editingFinished();
private slots:
void slotButtonClicked();
void slotClearButtonClicked();
private:
QPushButton m_button;
QPushButton m_clearButton;
QByteArray m_image;
QByteArray m_image;
};
} // namespace LimeReport

View File

@@ -29,11 +29,12 @@
****************************************************************************/
#include "lrtextitempropertyeditor.h"
#include "ui_ltextitempropertyeditor.h"
#include <QCompleter>
namespace LimeReport{
namespace LimeReport {
TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) :
TextItemPropertyEditor::TextItemPropertyEditor(QWidget* parent):
QDialog(parent),
ui(new Ui::TextItemPropertyEditor)
{
@@ -41,19 +42,10 @@ TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) :
ui->textEdit->setAcceptRichText(false);
}
TextItemPropertyEditor::~TextItemPropertyEditor()
{
delete ui;
}
TextItemPropertyEditor::~TextItemPropertyEditor() { delete ui; }
void TextItemPropertyEditor::setText(const QString &value)
{
ui->textEdit->setPlainText(value);
}
void TextItemPropertyEditor::setText(const QString& value) { ui->textEdit->setPlainText(value); }
QString TextItemPropertyEditor::text()
{
return ui->textEdit->toPlainText();
}
QString TextItemPropertyEditor::text() { return ui->textEdit->toPlainText(); }
} //namespace LimeReport
} // namespace LimeReport

View File

@@ -33,28 +33,28 @@
#include <QDialog>
#include <QWidget>
namespace LimeReport{
namespace LimeReport {
namespace Ui {
class TextItemPropertyEditor;
}
class TextItemPropertyEditor : public QDialog
{
class TextItemPropertyEditor: public QDialog {
Q_OBJECT
public:
explicit TextItemPropertyEditor(QWidget *parent = 0);
explicit TextItemPropertyEditor(QWidget* parent = 0);
~TextItemPropertyEditor();
void setText(const QString &value);
void setText(const QString& value);
QString text();
public slots:
void pbSaveCliked(){ emit editingFinished();}
void pbSaveCliked() { emit editingFinished(); }
signals:
void editingFinished();
private:
Ui::TextItemPropertyEditor *ui;
Ui::TextItemPropertyEditor* ui;
};
} //namespace LimeReport
} // namespace LimeReport
#endif // ATEXTITEMPROPERTYEDITOR_H