mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 16:44:39 +03:00
Items context menu has been added
Fields drag & drop init band datasource if it empty
This commit is contained in:
parent
117023e920
commit
a2c93601d0
@ -42,6 +42,7 @@
|
|||||||
#include "lrsimpletagparser.h"
|
#include "lrsimpletagparser.h"
|
||||||
#include "lrtextitemeditor.h"
|
#include "lrtextitemeditor.h"
|
||||||
#include "lrreportengine_p.h"
|
#include "lrreportengine_p.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
namespace{
|
namespace{
|
||||||
|
|
||||||
@ -80,6 +81,51 @@ int TextItem::fakeMarginSize() const{
|
|||||||
return marginSize()+5;
|
return marginSize()+5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextItem::preparePopUpMenu(QMenu &menu)
|
||||||
|
{
|
||||||
|
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit"));
|
||||||
|
menu.insertAction(menu.actions().at(0),editAction);
|
||||||
|
menu.insertSeparator(menu.actions().at(1));
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
QAction* action = menu.addAction(tr("Auto height"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(autoHeight());
|
||||||
|
|
||||||
|
action = menu.addAction(tr("Allow HTML"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(allowHTML());
|
||||||
|
|
||||||
|
action = menu.addAction(tr("Allow HTML in fields"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(allowHTMLInFields());
|
||||||
|
|
||||||
|
action = menu.addAction(tr("Strethc to max height"));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setChecked(stretchToMaxHeight());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextItem::processPopUpAction(QAction *action)
|
||||||
|
{
|
||||||
|
if (action->text().compare(tr("Edit")) == 0){
|
||||||
|
this->showEditorDialog();
|
||||||
|
}
|
||||||
|
if (action->text().compare(tr("Auto height")) == 0){
|
||||||
|
setProperty("autoHeight",action->isChecked());
|
||||||
|
}
|
||||||
|
if (action->text().compare(tr("Allow HTML")) == 0){
|
||||||
|
setProperty("allowHTML",action->isChecked());
|
||||||
|
}
|
||||||
|
if (action->text().compare(tr("Allow HTML in fields")) == 0){
|
||||||
|
setProperty("allowHTMLInFields",action->isChecked());
|
||||||
|
}
|
||||||
|
if (action->text().compare(tr("Strethc to max height")) == 0){
|
||||||
|
setProperty("stretchToMaxHeight",action->isChecked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, QWidget* widget) {
|
void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, QWidget* widget) {
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
Q_UNUSED(style);
|
Q_UNUSED(style);
|
||||||
|
@ -172,6 +172,8 @@ protected:
|
|||||||
int fakeMarginSize() const;
|
int fakeMarginSize() const;
|
||||||
QString getTextPart(int height, int skipHeight);
|
QString getTextPart(int height, int skipHeight);
|
||||||
void restoreLinksEvent();
|
void restoreLinksEvent();
|
||||||
|
void preparePopUpMenu(QMenu &menu);
|
||||||
|
void processPopUpAction(QAction *action);
|
||||||
private:
|
private:
|
||||||
void initTextSizes() const;
|
void initTextSizes() const;
|
||||||
void setTextFont(TextPtr text, const QFont &value) const;
|
void setTextFont(TextPtr text, const QFont &value) const;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
namespace LimeReport {
|
namespace LimeReport {
|
||||||
|
|
||||||
@ -431,6 +432,34 @@ void BandDesignIntf::moveItemsDown(qreal startPos, qreal offset){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BandDesignIntf::preparePopUpMenu(QMenu &menu)
|
||||||
|
{
|
||||||
|
foreach (QAction* action, menu.actions()) {
|
||||||
|
if (action->text().compare(tr("Bring to top")) == 0 ||
|
||||||
|
action->text().compare(tr("Send to back")) == 0 )
|
||||||
|
action->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
QAction* autoHeightAction = menu.addAction(tr("Auto height"));
|
||||||
|
autoHeightAction->setCheckable(true);
|
||||||
|
autoHeightAction->setChecked(autoHeight());
|
||||||
|
|
||||||
|
QAction* autoSplittableAction = menu.addAction(tr("Splittable"));
|
||||||
|
autoSplittableAction->setCheckable(true);
|
||||||
|
autoSplittableAction->setChecked(isSplittable());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BandDesignIntf::processPopUpAction(QAction *action)
|
||||||
|
{
|
||||||
|
if (action->text().compare(tr("Auto height")) == 0){
|
||||||
|
setProperty("autoHeight",action->isChecked());
|
||||||
|
}
|
||||||
|
if (action->text().compare(tr("Splittable")) == 0){
|
||||||
|
setProperty("splittable",action->isChecked());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent)
|
BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent)
|
||||||
{
|
{
|
||||||
int maxBottom = 0;
|
int maxBottom = 0;
|
||||||
@ -804,6 +833,14 @@ void BandDesignIntf::setStartNewPage(bool startNewPage)
|
|||||||
m_startNewPage = startNewPage;
|
m_startNewPage = startNewPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BandDesignIntf::setAutoHeight(bool value){
|
||||||
|
if (m_autoHeight != value){
|
||||||
|
m_autoHeight=value;
|
||||||
|
if (!isLoading())
|
||||||
|
notify("autoHeight",!value,value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool BandDesignIntf::reprintOnEachPage() const
|
bool BandDesignIntf::reprintOnEachPage() const
|
||||||
{
|
{
|
||||||
return m_reprintOnEachPage;
|
return m_reprintOnEachPage;
|
||||||
|
@ -207,7 +207,7 @@ public:
|
|||||||
bool startNewPage() const;
|
bool startNewPage() const;
|
||||||
void setStartNewPage(bool startNewPage);
|
void setStartNewPage(bool startNewPage);
|
||||||
|
|
||||||
void setAutoHeight(bool value){m_autoHeight=value;}
|
void setAutoHeight(bool value);
|
||||||
bool autoHeight(){return m_autoHeight;}
|
bool autoHeight(){return m_autoHeight;}
|
||||||
|
|
||||||
bool startFromNewPage() const;
|
bool startFromNewPage() const;
|
||||||
@ -244,6 +244,8 @@ protected:
|
|||||||
void setColumnsCount(int value);
|
void setColumnsCount(int value);
|
||||||
void setColumnsFillDirection(BandColumnsLayoutType value);
|
void setColumnsFillDirection(BandColumnsLayoutType value);
|
||||||
void moveItemsDown(qreal startPos, qreal offset);
|
void moveItemsDown(qreal startPos, qreal offset);
|
||||||
|
void preparePopUpMenu(QMenu &menu);
|
||||||
|
void processPopUpAction(QAction *action);
|
||||||
private slots:
|
private slots:
|
||||||
void childBandDeleted(QObject* band);
|
void childBandDeleted(QObject* band);
|
||||||
private:
|
private:
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#include "qgraphicsitem.h"
|
#include "qgraphicsitem.h"
|
||||||
#include "lrdesignelementsfactory.h"
|
#include "lrdesignelementsfactory.h"
|
||||||
#include "lrhorizontallayout.h"
|
#include "lrhorizontallayout.h"
|
||||||
|
#include "serializators/lrstorageintf.h"
|
||||||
|
#include "serializators/lrxmlreader.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -43,6 +45,8 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
namespace LimeReport
|
namespace LimeReport
|
||||||
{
|
{
|
||||||
@ -1147,6 +1151,53 @@ void BaseDesignIntf::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
QGraphicsItem::mouseDoubleClickEvent(event);
|
QGraphicsItem::mouseDoubleClickEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
PageDesignIntf* page = dynamic_cast<PageDesignIntf*>(scene());
|
||||||
|
if (!page->selectedItems().contains(this)){
|
||||||
|
page->clearSelection();
|
||||||
|
this->setSelected(true);
|
||||||
|
}
|
||||||
|
QMenu menu;
|
||||||
|
QAction* copyAction = menu.addAction(QIcon(":/report/images/copy.png"), tr("Copy"));
|
||||||
|
copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
|
||||||
|
QAction* cutAction = menu.addAction(QIcon(":/report//images/cut"), tr("Cut"));
|
||||||
|
cutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X));
|
||||||
|
QAction* pasteAction = menu.addAction(QIcon(":/report/images/paste.png"), tr("Paste"));
|
||||||
|
pasteAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
|
||||||
|
pasteAction->setEnabled(false);
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
ItemsReaderIntf::Ptr reader = StringXMLreader::create(clipboard->text());
|
||||||
|
if (reader->first() && reader->itemType() == "Object"){
|
||||||
|
pasteAction->setEnabled(true);
|
||||||
|
}
|
||||||
|
menu.addSeparator();
|
||||||
|
QAction* brinToTopAction = menu.addAction(QIcon(":/report//images/bringToTop"), tr("Bring to top"));
|
||||||
|
QAction* sendToBackAction = menu.addAction(QIcon(":/report//images/sendToBack"), tr("Send to back"));
|
||||||
|
menu.addSeparator();
|
||||||
|
QAction* noBordersAction = menu.addAction(QIcon(":/report//images/noLines"), tr("No borders"));
|
||||||
|
QAction* allBordersAction = menu.addAction(QIcon(":/report//images/allLines"), tr("All borders"));
|
||||||
|
preparePopUpMenu(menu);
|
||||||
|
QAction* a = menu.exec(event->screenPos());
|
||||||
|
if (a){
|
||||||
|
if (a == cutAction)
|
||||||
|
page->cut();
|
||||||
|
if (a == copyAction)
|
||||||
|
page->copy();
|
||||||
|
if (a == pasteAction)
|
||||||
|
page->paste();
|
||||||
|
if (a == brinToTopAction)
|
||||||
|
page->bringToFront();
|
||||||
|
if (a == sendToBackAction)
|
||||||
|
page->sendToBack();
|
||||||
|
if (a == noBordersAction)
|
||||||
|
page->setBorders(BaseDesignIntf::NoLine);
|
||||||
|
if (a == allBordersAction)
|
||||||
|
page->setBorders(BaseDesignIntf::AllLines);
|
||||||
|
processPopUpAction(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int BaseDesignIntf::possibleMoveDirectionFlags() const
|
int BaseDesignIntf::possibleMoveDirectionFlags() const
|
||||||
{
|
{
|
||||||
return m_possibleMoveDirectionFlags;
|
return m_possibleMoveDirectionFlags;
|
||||||
|
@ -124,10 +124,13 @@ public:
|
|||||||
TopBotom=2,
|
TopBotom=2,
|
||||||
All=3
|
All=3
|
||||||
};
|
};
|
||||||
enum BorderSide { TopLine = 1,
|
enum BorderSide {
|
||||||
BottomLine = 2,
|
NoLine = 0,
|
||||||
LeftLine = 4,
|
TopLine = 1,
|
||||||
RightLine = 8
|
BottomLine = 2,
|
||||||
|
LeftLine = 4,
|
||||||
|
RightLine = 8,
|
||||||
|
AllLines = 15
|
||||||
};
|
};
|
||||||
enum ObjectState {ObjectLoading, ObjectLoaded, ObjectCreated};
|
enum ObjectState {ObjectLoading, ObjectLoaded, ObjectCreated};
|
||||||
enum ItemAlign {LeftItemAlign,RightItemAlign,CenterItemAlign,ParentWidthItemAlign,DesignedItemAlign};
|
enum ItemAlign {LeftItemAlign,RightItemAlign,CenterItemAlign,ParentWidthItemAlign,DesignedItemAlign};
|
||||||
@ -293,6 +296,7 @@ protected:
|
|||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||||
|
|
||||||
virtual void geometryChangedEvent(QRectF newRect, QRectF oldRect);
|
virtual void geometryChangedEvent(QRectF newRect, QRectF oldRect);
|
||||||
virtual QPen borderPen(BorderSide side) const;
|
virtual QPen borderPen(BorderSide side) const;
|
||||||
@ -333,6 +337,9 @@ protected:
|
|||||||
|
|
||||||
QVariant m_varValue;
|
QVariant m_varValue;
|
||||||
|
|
||||||
|
virtual void preparePopUpMenu(QMenu& menu){Q_UNUSED(menu)}
|
||||||
|
virtual void processPopUpAction(QAction* action){Q_UNUSED(action)}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateSelectionMarker();
|
void updateSelectionMarker();
|
||||||
int resizeDirectionFlags(QPointF position);
|
int resizeDirectionFlags(QPointF position);
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
namespace LimeReport
|
namespace LimeReport
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -744,6 +745,15 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
|
|||||||
QString data = event->mimeData()->text().remove(0,event->mimeData()->text().indexOf(":")+1);
|
QString data = event->mimeData()->text().remove(0,event->mimeData()->text().indexOf(":")+1);
|
||||||
if (isVar) data = data.remove(QRegExp(" \\[.*\\]"));
|
if (isVar) data = data.remove(QRegExp(" \\[.*\\]"));
|
||||||
ti->setContent(data);
|
ti->setContent(data);
|
||||||
|
if (!isVar){
|
||||||
|
BandDesignIntf* parentBand = dynamic_cast<BandDesignIntf*>(ti->parentItem());
|
||||||
|
if (parentBand && parentBand->datasourceName().isEmpty()){
|
||||||
|
QRegExp dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})");
|
||||||
|
if (dataSource.indexIn(data) != -1){
|
||||||
|
parentBand->setProperty("datasource",dataSource.cap(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1231,8 +1241,13 @@ BaseDesignIntf* PageDesignIntf::findDestObject(BaseDesignIntf* item){
|
|||||||
void PageDesignIntf::paste()
|
void PageDesignIntf::paste()
|
||||||
{
|
{
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
if (!selectedItems().isEmpty()) {
|
BaseDesignIntf* destItem = 0;
|
||||||
BaseDesignIntf* destItem = findDestObject(dynamic_cast<BaseDesignIntf*>(selectedItems().at(0)));
|
ItemsReaderIntf::Ptr reader = StringXMLreader::create(clipboard->text());
|
||||||
|
if (reader->first() && reader->itemType() == "Object"){
|
||||||
|
if (!selectedItems().isEmpty())
|
||||||
|
destItem = findDestObject(dynamic_cast<BaseDesignIntf*>(selectedItems().at(0)));
|
||||||
|
else
|
||||||
|
destItem = this->pageItem();
|
||||||
if (destItem){
|
if (destItem){
|
||||||
CommandIf::Ptr command = PasteCommand::create(this, clipboard->text(), destItem);
|
CommandIf::Ptr command = PasteCommand::create(this, clipboard->text(), destItem);
|
||||||
saveCommand(command);
|
saveCommand(command);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
namespace LimeReport {
|
namespace LimeReport {
|
||||||
|
|
||||||
@ -519,6 +520,14 @@ void PageItemDesignIntf::initPageSize(const QSizeF& size)
|
|||||||
setHeight(size.height());
|
setHeight(size.height());
|
||||||
m_sizeChainging=false;
|
m_sizeChainging=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageItemDesignIntf::preparePopUpMenu(QMenu &menu)
|
||||||
|
{
|
||||||
|
foreach (QAction* action, menu.actions()) {
|
||||||
|
if (action->text().compare(tr("Paste")) != 0)
|
||||||
|
action->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
void PageItemDesignIntf::initPageSize(const PageItemDesignIntf::PageSize &size)
|
void PageItemDesignIntf::initPageSize(const PageItemDesignIntf::PageSize &size)
|
||||||
{
|
{
|
||||||
m_sizeChainging = true;
|
m_sizeChainging = true;
|
||||||
|
@ -127,6 +127,7 @@ protected:
|
|||||||
void initPageSize(const PageSize &size);
|
void initPageSize(const PageSize &size);
|
||||||
void initPageSize(const QSizeF &size);
|
void initPageSize(const QSizeF &size);
|
||||||
QColor selectionMarkerColor(){return Qt::transparent;}
|
QColor selectionMarkerColor(){return Qt::transparent;}
|
||||||
|
void preparePopUpMenu(QMenu &menu);
|
||||||
private:
|
private:
|
||||||
void paintGrid(QPainter *ppainter);
|
void paintGrid(QPainter *ppainter);
|
||||||
void initColumnsPos(QVector<qreal>&posByColumns, qreal pos, int columnCount);
|
void initColumnsPos(QVector<qreal>&posByColumns, qreal pos, int columnCount);
|
||||||
|
@ -63,7 +63,6 @@ protected:
|
|||||||
void readCollection(QObject *item, QDomElement *node);
|
void readCollection(QObject *item, QDomElement *node);
|
||||||
QVariant getValue(QDomElement *node);
|
QVariant getValue(QDomElement *node);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool extractFirstNode();
|
bool extractFirstNode();
|
||||||
QString m_error;
|
QString m_error;
|
||||||
@ -72,10 +71,6 @@ private:
|
|||||||
QDomElement m_curNode;
|
QDomElement m_curNode;
|
||||||
QDomElement m_firstNode;
|
QDomElement m_firstNode;
|
||||||
QString m_passPhrase;
|
QString m_passPhrase;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileXMLReader : public XMLReader{
|
class FileXMLReader : public XMLReader{
|
||||||
|
Loading…
Reference in New Issue
Block a user