Change to subforder project model.

This commit is contained in:
newsages
2016-03-21 02:12:30 +01:00
parent 9797b30d0a
commit 598d4f10ed
531 changed files with 167 additions and 2522 deletions

View File

@@ -0,0 +1,136 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#include "lrbuttonlineeditor.h"
#include <QMessageBox>
#include <QEvent>
#include <QKeyEvent>
#include <QFocusEvent>
#include <QApplication>
#include <QStyle>
#include <QDesktopWidget>
#include "lrtextitempropertyeditor.h"
namespace LimeReport{
ButtonLineEditor::ButtonLineEditor(const QString &propertyName, QWidget *parent) :
QWidget(parent), m_overButton(false), m_propertyName(propertyName)
{
m_lineEdit = new QLineEdit(this);
m_lineEdit->installEventFilter(this);
setFocusProxy(m_lineEdit);
m_buttonEdit = new QToolButton(this);
m_buttonEdit->setText("...");
m_buttonEdit->installEventFilter(this);
m_buttonEdit->setAttribute(Qt::WA_Hover);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(m_lineEdit);
layout->addWidget(m_buttonEdit);
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()));
}
ButtonLineEditor::~ButtonLineEditor(){}
void ButtonLineEditor::editButtonClicked()
{
TextItemPropertyEditor* editor = new TextItemPropertyEditor(QApplication::activeWindow());
editor->setAttribute(Qt::WA_DeleteOnClose);
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->availableGeometry()));
editor->setWindowTitle(m_propertyName);
editor->setText(m_lineEdit->text());
connect(editor,SIGNAL(accepted()),this,SLOT(editingByEditorFinished()));
editor->exec();
}
void ButtonLineEditor::setText(const QString &value){
m_lineEdit->setText(value);
}
QString ButtonLineEditor::text()
{
return m_lineEdit->text();
}
bool ButtonLineEditor::eventFilter(QObject *target, QEvent *event)
{
if (target==m_buttonEdit) {
if (event->type()==QEvent::HoverEnter){
m_overButton=true;
}
if (event->type()==QEvent::HoverLeave){
m_overButton=false;
}
if (event->type()==QEvent::FocusOut){
if (static_cast<QFocusEvent*>(event)->reason()!=Qt::MouseFocusReason){
m_lineEdit->setFocus();
}
}
QSet<int> enterKeys;
enterKeys.insert(Qt::Key_Enter);
enterKeys.insert(Qt::Key_Return);
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()){
case Qt::TabFocusReason:
m_overButton=true;
break;
case Qt::MouseFocusReason:
break;
default:
m_overButton=false;
}
}
}
return QWidget::eventFilter(target,event);
}
void ButtonLineEditor::editingByEditorFinished()
{
setText(qobject_cast<TextItemPropertyEditor*>(sender())->text());
m_lineEdit->setFocus();
}
} //namespace LimeReport

View File

@@ -0,0 +1,70 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#ifndef LRBUTTONLINEEDIT_H
#define LRBUTTONLINEEDIT_H
#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QToolButton>
#include <QHBoxLayout>
#include <QDebug>
#include "lrtextitempropertyeditor.h"
namespace LimeReport{
class ButtonLineEditor : public QWidget
{
Q_OBJECT
public:
explicit ButtonLineEditor(const QString& propertyName,QWidget *parent = 0);
~ButtonLineEditor();
void setText(const QString &value);
QString text();
signals:
void editingFinished();
public slots:
virtual void editButtonClicked();
void editingByEditorFinished();
protected:
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;
};
} //namespace LimeReport
#endif // LRBUTTONLINEEDIT_H

View File

@@ -0,0 +1,115 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#include "lrcheckboxeditor.h"
#include <QDebug>
#include <QPainter>
#include <QVBoxLayout>
#include <QKeyEvent>
#include <QApplication>
#include <QStyle>
namespace LimeReport{
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)
{
m_checkBox = new QCheckBox(text,this);
init();
}
CheckBoxEditor::~CheckBoxEditor(){}
void CheckBoxEditor::init()
{
QVBoxLayout *layout=new QVBoxLayout(this);
layout->addStretch();
layout->addWidget(m_checkBox);
m_checkBox->setFocusPolicy(Qt::NoFocus);
connect(m_checkBox, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int)));
layout->addStretch();
layout->setContentsMargins(2,1,1,1);
layout->setSpacing(0);
setLayout(layout);
setAutoFillBackground(true);
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
}
void CheckBoxEditor::setEditing(bool value)
{
m_editing=value;
}
void CheckBoxEditor::setChecked(bool value)
{
m_checkBox->setChecked(value);
}
bool CheckBoxEditor::isChecked()
{
return m_checkBox->isChecked();
}
void CheckBoxEditor::mousePressEvent(QMouseEvent *)
{
m_checkBox->setChecked(!m_checkBox->isChecked());
emit editingFinished();
}
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)){
emit editingFinished();
}
QWidget::keyPressEvent(event);
}
void CheckBoxEditor::showEvent(QShowEvent *)
{
int border = (height() - QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth))/2
#ifdef Q_OS_MAC
+QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
#endif
;
layout()->setContentsMargins(border,0,0,0);
}
void CheckBoxEditor::slotStateChanged(int)
{
emit editingFinished();
}
}

View File

@@ -0,0 +1,64 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#ifndef LRCHECKBOXEDITOR_H
#define LRCHECKBOXEDITOR_H
#include <QCheckBox>
namespace LimeReport{
class CheckBoxEditor : public QWidget
{
Q_OBJECT
public:
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 *);
signals:
void editingFinished();
private slots:
void slotStateChanged(int);
private:
QCheckBox* m_checkBox;
bool m_editing;
void init();
};
}
#endif // LRCHECKBOXEDITOR_H

View File

@@ -0,0 +1,132 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#include "lrcoloreditor.h"
#include <QHBoxLayout>
#include <QColorDialog>
#include <QPaintEvent>
#include <QPainter>
namespace LimeReport{
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->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);
setFocusProxy(m_button);
setAutoFillBackground(true);
setLayout(layout);
connect(m_button,SIGNAL(clicked()),this,SLOT(slotClicked()));
}
void ColorEditor::setColor(const QColor &value)
{
m_color=value;
m_colorIndicator->setColor(m_color);
}
bool ColorEditor::eventFilter(QObject *obj, QEvent *event)
{
if (obj == m_button){
if (event->type() == QEvent::FocusOut && !m_buttonPressed){
QFocusEvent* focusEvent = dynamic_cast<QFocusEvent*>(event);
if (focusEvent && focusEvent->reason()!=Qt::MouseFocusReason){
setFocusToParent();
emit(editingFinished());
}
return false;
}
}
return false;
}
void ColorEditor::setFocusToParent(){
if (parentWidget())
parentWidget()->setFocus();
}
void ColorEditor::slotClicked()
{
m_buttonPressed = true;
QColorDialog* dialog = new QColorDialog(this);
dialog->setCurrentColor(m_color);
if (dialog->exec()) m_color=dialog->currentColor();
delete dialog;
setFocusToParent();
emit(editingFinished());
}
void ColorIndicator::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.save();
painter.setBrush(m_color);
painter.setPen(Qt::gray);
QRect rect = event->rect().adjusted(3,3,-4,-4);
rect.setWidth(rect.height());
painter.setRenderHint(QPainter::Antialiasing);
painter.drawEllipse(rect);
painter.restore();
}
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;
}
void ColorIndicator::setColor(const QColor &color)
{
m_color = color;
}
QSize ColorIndicator::sizeHint() const
{
return QSize(20,20);
}
} // namespace LimeReport

View File

@@ -0,0 +1,76 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#ifndef LRCOLOREDITOR_H
#define LRCOLOREDITOR_H
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
namespace LimeReport{
class ColorIndicator : public QWidget{
Q_OBJECT
public:
ColorIndicator(QWidget* parent = 0);
QColor color() const;
void setColor(const QColor &color);
QSize sizeHint() const;
protected:
void paintEvent(QPaintEvent *event);
private:
QColor m_color;
};
class ColorEditor : public QWidget
{
Q_OBJECT
public:
explicit ColorEditor(QWidget *parent = 0);
QColor color(){return m_color;}
void setColor(const QColor& value);
protected:
bool eventFilter(QObject *obj, QEvent *event);
private:
void setFocusToParent();
signals:
void editingFinished();
private slots:
void slotClicked();
private:
QColor m_color;
QToolButton* m_button;
ColorIndicator* m_colorIndicator;
bool m_buttonPressed;
};
} // namespace LimeReport
#endif // LRCOLOREDITOR_H

View File

@@ -0,0 +1,144 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#include <QHBoxLayout>
#include <QToolButton>
#include <QComboBox>
#include <QLineEdit>
#include <QDebug>
#include <QEvent>
#include <QFocusEvent>
#include <QKeyEvent>
#include "lrcomboboxeditor.h"
namespace LimeReport{
ComboBoxEditor::ComboBoxEditor(QWidget *parent, bool clearable) :
QWidget(parent),
m_comboBox(new InternalComboBox(this)),
m_buttonClear(0),
m_settingValues(false)
{
setFocusProxy(m_comboBox);
if (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->setMaximumHeight(QWIDGETSIZE_MAX);
connect(m_buttonClear,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
}
connect(m_comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotCurrentIndexChanged(QString)));
m_comboBox->installEventFilter(this);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(m_comboBox);
if (clearable)
layout->addWidget(m_buttonClear);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(2);
setLayout(layout);
setAutoFillBackground(true);
}
void ComboBoxEditor::addItems(const QStringList &values){
m_settingValues = true;
m_comboBox->addItems(values);
m_settingValues = false;
}
void ComboBoxEditor::setTextValue(const QString &value){
m_settingValues = true;
if (m_comboBox->findText(value)>0){
m_comboBox->setCurrentIndex(m_comboBox->findText(value));
} else {
m_comboBox->setEditText(value);
}
m_settingValues = false;
}
void ComboBoxEditor::slotClearButtonClicked(){
m_comboBox->setCurrentIndex(-1);
}
void ComboBoxEditor::slotCurrentIndexChanged(const QString& value)
{
if (!m_settingValues){
emit currentIndexChanged(value);
}
}
QString ComboBoxEditor::text(){
return m_comboBox->currentText();
}
void ComboBoxEditor::setEditable(bool value)
{
if (m_comboBox) {
m_comboBox->setEditable(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){
m_comboBox->setFocus();
}
}
QSet<int> enterKeys;
enterKeys.insert(Qt::Key_Enter);
enterKeys.insert(Qt::Key_Return);
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 (!m_comboBox->isPopup() || (m_buttonClear && m_buttonClear->hasFocus()))
emit editingFinished();
}
}
return QWidget::eventFilter(target,event);
}
void ComboBoxEditor::resizeEvent(QResizeEvent *e)
{
if (m_buttonClear)
m_buttonClear->setMinimumHeight(e->size().height()-4);
}
} // namespace LimeReport

View File

@@ -0,0 +1,80 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#ifndef LRCOMBOBOXEDITOR_H
#define LRCOMBOBOXEDITOR_H
#include <QWidget>
#include <QComboBox>
//#include <QPushButton>
class QToolButton;
namespace LimeReport{
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;}
private:
bool m_popup;
};
class ComboBoxEditor : public QWidget
{
Q_OBJECT
public:
//explicit ComboBoxEditor(QWidget *parent = 0);
ComboBoxEditor(QWidget *parent=0, bool clearable=false);
void addItems(const QStringList& values);
void setTextValue(const QString& value);
QString text();
void setEditable(bool value);
signals:
void editingFinished();
void currentIndexChanged(const QString&);
protected:
void resizeEvent(QResizeEvent *e);
private slots:
void slotClearButtonClicked();
void slotCurrentIndexChanged(const QString& value);
private:
bool eventFilter(QObject *target, QEvent *event);
InternalComboBox* m_comboBox;
QToolButton* m_buttonClear;
bool m_settingValues;
};
} // namespace LimeReport
#endif // LRCOMBOBOXEDITOR_H

View File

@@ -0,0 +1,85 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#include "lrfonteditor.h"
#include <QHBoxLayout>
#include <QFontDialog>
#include <QDebug>
namespace LimeReport{
FontEditor::FontEditor(QWidget *parent) :
QWidget(parent)
{
//m_button = new QPushButton(this);
m_button = new QToolButton(this);
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);
setFocusProxy(m_button);
setLayout(layout);
setAutoFillBackground(true);
connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonCliked()));
}
FontEditor::~FontEditor()
{}
void FontEditor::setFontValue(const QFont &font)
{
m_font=font;
m_button->setText(toString(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();
delete dialog;
emit(editingFinished());
}
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;
}
} // namespace LimeReport

View File

@@ -0,0 +1,61 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#ifndef LRFONTEDITOR_H
#define LRFONTEDITOR_H
#include <QWidget>
#include <QPushButton>
#include <QToolButton>
namespace LimeReport{
class FontEditor : public QWidget
{
Q_OBJECT
public:
explicit FontEditor(QWidget *parent = 0);
~FontEditor();
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;
QToolButton* m_button;
QFont m_font;
};
} // namespace LimeReport
#endif // LRFONTEDITOR_H

View File

@@ -0,0 +1,60 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#include <QHBoxLayout>
#include <QFileDialog>
#include "lrimageeditor.h"
namespace LimeReport{
ImageEditor::ImageEditor(QWidget* parent)
:QWidget(parent)
{
m_button.setIcon(QIcon(":items/ImageItem"));
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(&m_button);
layout->setSpacing(0);
layout->setContentsMargins(1,0,1,1);
setLayout(layout);
setFocusProxy(&m_button);
connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
}
QImage ImageEditor::image()
{
return m_image;
}
void ImageEditor::slotButtonClicked()
{
m_image.load(QFileDialog::getOpenFileName(this));
emit editingFinished();
}
} // namespace LimeReport

View File

@@ -0,0 +1,55 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#ifndef LRIMAGEEDITOR_H
#define LRIMAGEEDITOR_H
#include <QWidget>
#include <QPushButton>
namespace LimeReport{
class ImageEditor : public QWidget
{
Q_OBJECT
public:
ImageEditor(QWidget *parent=0);
QImage image();
void setImage(const QImage& image){m_image=image;}
signals:
void editingFinished();
private slots:
void slotButtonClicked();
private:
QPushButton m_button;
QImage m_image;
};
} // namespace LimeReport
#endif // LRIMAGEEDITOR_H

View File

@@ -0,0 +1,59 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#include "lrtextitempropertyeditor.h"
#include "ui_ltextitempropertyeditor.h"
#include <QCompleter>
namespace LimeReport{
TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) :
QDialog(parent),
ui(new Ui::TextItemPropertyEditor)
{
ui->setupUi(this);
ui->textEdit->setAcceptRichText(false);
}
TextItemPropertyEditor::~TextItemPropertyEditor()
{
delete ui;
}
void TextItemPropertyEditor::setText(const QString &value)
{
ui->textEdit->setPlainText(value);
}
QString TextItemPropertyEditor::text()
{
return ui->textEdit->toPlainText();
}
} //namespace LimeReport

View File

@@ -0,0 +1,60 @@
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* arin_a@bk.ru *
* *
** GNU General Public License Usage **
* *
* This library 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. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
** GNU Lesser General Public License **
* *
* This library is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
* If not, see <http://www.gnu.org/licenses/>. *
* *
* This library 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. *
****************************************************************************/
#ifndef ATEXTITEMPROPERTYEDITOR_H
#define ATEXTITEMPROPERTYEDITOR_H
#include <QDialog>
#include <QWidget>
namespace LimeReport{
namespace Ui {
class TextItemPropertyEditor;
}
class TextItemPropertyEditor : public QDialog
{
Q_OBJECT
public:
explicit TextItemPropertyEditor(QWidget *parent = 0);
~TextItemPropertyEditor();
void setText(const QString &value);
QString text();
public slots:
void pbSaveCliked(){ emit editingFinished();}
signals:
void editingFinished();
private:
Ui::TextItemPropertyEditor *ui;
};
} //namespace LimeReport
#endif // ATEXTITEMPROPERTYEDITOR_H

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LimeReport::TextItemPropertyEditor</class>
<widget class="QDialog" name="LimeReport::TextItemPropertyEditor">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowIcon">
<iconset resource="../../items/items.qrc">
<normaloff>:/items/images/insert-text_3.png</normaloff>:/items/images/insert-text_3.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../items/items.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>LimeReport::TextItemPropertyEditor</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>54</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>5</x>
<y>258</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>LimeReport::TextItemPropertyEditor</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>161</x>
<y>266</y>
</hint>
<hint type="destinationlabel">
<x>397</x>
<y>225</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>pbSaveCliked()</slot>
<slot>pbCancelCliked()</slot>
</slots>
</ui>