0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-23 16:22:58 +03:00

geometryLocked property has been added to report items

This commit is contained in:
Arin Alexander 2019-06-28 20:12:47 +03:00
parent 99757097cc
commit f7e1a383e9
22 changed files with 208 additions and 20 deletions

View File

@ -142,7 +142,6 @@ void DataBand::processPopUpAction(QAction *action)
if (action->text().compare(tr("Start from new page")) == 0){
setProperty("startFromNewPage",action->isChecked());
}
}
BaseDesignIntf *DataBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)

View File

@ -87,6 +87,7 @@ void PageFooter::processPopUpAction(QAction *action)
if (action->text().compare(tr("Print on last page")) == 0){
page()->setPropertyToSelectedItems("printOnLastPage",action->isChecked());
}
BandDesignIntf::processPopUpAction(action);
}
bool PageFooter::printOnFirstPage() const

View File

@ -35,7 +35,7 @@
#include <QObject>
namespace LimeReport{
class PageFooter : public LimeReport::BandDesignIntf
class PageFooter : public BandDesignIntf
{
Q_OBJECT
Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage)

BIN
limereport/images/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

View File

@ -93,6 +93,7 @@ void ImageItem::processPopUpAction(QAction *action)
if (action->text().compare(tr("Watermark")) == 0){
page()->setPropertyToSelectedItems("watermark",action->isChecked());
}
ItemDesignIntf::processPopUpAction(action);
}
bool ImageItem::useExternalPainter() const

View File

@ -33,7 +33,7 @@
namespace LimeReport{
class ImageItem : public LimeReport::ItemDesignIntf, public IPainterProxy
class ImageItem : public ItemDesignIntf, public IPainterProxy
{
Q_OBJECT
Q_ENUMS(Format)

View File

@ -152,6 +152,8 @@ void TextItem::processPopUpAction(QAction *action)
if (action->text().compare(tr("Hide if empty")) == 0){
page()->setPropertyToSelectedItems("hideIfEmpty",action->isChecked());
}
ContentItemDesignIntf::processPopUpAction(action);
}
void TextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* style, QWidget* widget) {

View File

@ -41,7 +41,7 @@
namespace LimeReport {
class Tag;
class TextItem : public LimeReport::ContentItemDesignIntf, IPageInit {
class TextItem : public ContentItemDesignIntf, IPageInit {
Q_OBJECT
Q_ENUMS(AutoWidth)
Q_ENUMS(AngleType)

View File

@ -607,7 +607,7 @@ void BandDesignIntf::processPopUpAction(QAction *action)
if (action->text().compare(tr("Print if empty")) == 0){
setProperty("printIfEmpty",action->isChecked());
}
ItemsContainerDesignInft::processPopUpAction(action);
}
void BandDesignIntf::recalcItems(DataSourceManager* dataManager)

View File

@ -83,7 +83,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_joinMarkerOn(false),
m_selectionMarker(0),
m_fillTransparentInDesignMode(true),
m_unitType(Millimeters)
m_unitType(Millimeters),
m_itemGeometryLocked(false)
{
setGeometry(QRectF(0, 0, m_width, m_height));
if (BaseDesignIntf *item = dynamic_cast<BaseDesignIntf *>(parent)) {
@ -96,12 +97,7 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
QRectF BaseDesignIntf::boundingRect() const
{
if (m_boundingRect.isNull()) {
qreal halfpw = pen().widthF() / 2;
halfpw += 2;
m_boundingRect = rect();
};
return m_boundingRect;
return rect();
}
BaseDesignIntf::~BaseDesignIntf(void) {
@ -734,6 +730,32 @@ void BaseDesignIntf::updatePossibleDirectionFlags(){
}
}
bool BaseDesignIntf::isItemGeometryLocked() const
{
return m_itemGeometryLocked;
}
void BaseDesignIntf::setItemGeometryLocked(bool itemLocked)
{
if (m_itemGeometryLocked != itemLocked){
m_itemGeometryLocked = itemLocked;
if (itemLocked){
m_savedPossibleMoveDirectionFlags = m_possibleMoveDirectionFlags;
m_savedPossibleResizeDirectionFlags = m_possibleResizeDirectionFlags;
m_possibleMoveDirectionFlags = None;
m_possibleResizeDirectionFlags = Fixed;
} else {
m_possibleMoveDirectionFlags = m_savedPossibleMoveDirectionFlags;
m_possibleResizeDirectionFlags = m_savedPossibleResizeDirectionFlags;
}
if (!isLoading()){
update();
m_selectionMarker->update();
notify("geometryLocked", !itemLocked, itemLocked);
}
}
}
bool BaseDesignIntf::fillTransparentInDesignMode() const
{
return m_fillTransparentInDesignMode;
@ -1287,6 +1309,13 @@ void BaseDesignIntf::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
this->setSelected(true);
}
QMenu menu(event->widget());
QAction* lockGeometryAction = menu.addAction(tr("Lock item geometry"));
lockGeometryAction->setCheckable(true);
lockGeometryAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
lockGeometryAction->setChecked(isItemGeometryLocked());
menu.addSeparator();
QAction* copyAction = menu.addAction(QIcon(":/report/images/copy"), tr("Copy"));
copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
QAction* cutAction = menu.addAction(QIcon(":/report/images/cut"), tr("Cut"));
@ -1659,12 +1688,21 @@ void Marker::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
rect().bottom()-markerSize,markerSize*2,markerSize*2));
}
QColor Marker::color() const {
return m_color;
}
SelectionMarker::SelectionMarker(QGraphicsItem* parent, BaseDesignIntf* owner)
: Marker(parent, owner)
{
setAcceptHoverEvents(true);
}
QColor SelectionMarker::color() const
{
return owner()->isItemGeometryLocked() ? Qt::darkGray : Marker::color();
}
void SelectionMarker::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
if (owner()) owner()->hoverMoveEvent(event);
@ -1697,4 +1735,12 @@ void SelectionMarker::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (owner()) owner()->mouseMoveEvent(event);
}
void BaseDesignIntf::processPopUpAction(QAction *action){
if (page()){
if (action->text().compare(tr("Lock item geometry")) == 0){
page()->setPropertyToSelectedItems("geometryLocked",action->isChecked());
}
}
}
} //namespace LimeReport

View File

@ -57,7 +57,7 @@ public:
void setRect(QRectF rect){prepareGeometryChange();m_rect=rect;}
void setColor(QColor color){m_color=color;}
QRectF rect() const {return m_rect;}
QColor color() const {return m_color;}
virtual QColor color() const;
BaseDesignIntf* owner() const {return m_owner;}
private:
QRectF m_rect;
@ -68,6 +68,7 @@ private:
class SelectionMarker : public Marker{
public:
SelectionMarker(QGraphicsItem* parent=0, BaseDesignIntf* owner = 0);
QColor color() const;
protected:
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
@ -97,6 +98,7 @@ class BaseDesignIntf :
Q_PROPERTY(int borderLineSize READ borderLineSize WRITE setBorderLineSize)
Q_PROPERTY(bool isVisible READ isVisible WRITE setItemVisible DESIGNABLE false)
Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
Q_PROPERTY(bool geometryLocked READ isItemGeometryLocked WRITE setItemGeometryLocked)
friend class ReportRender;
public:
@ -124,7 +126,8 @@ public:
ResizeBottom = 8,
AllDirections = 15
};
enum MoveFlags { LeftRight=1,
enum MoveFlags { None = 0,
LeftRight=1,
TopBotom=2,
All=3
};
@ -302,6 +305,9 @@ public:
void setFillTransparentInDesignMode(bool fillTransparentInDesignMode);
void emitPosChanged(QPointF oldPos, QPointF newPos);
bool isItemGeometryLocked() const;
void setItemGeometryLocked(bool itemLocked);
protected:
//ICollectionContainer
@ -361,7 +367,7 @@ protected:
QVariant m_varValue;
virtual void preparePopUpMenu(QMenu& menu){Q_UNUSED(menu)}
virtual void processPopUpAction(QAction* action){Q_UNUSED(action)}
virtual void processPopUpAction(QAction* action);
void addChildItems(QList<BaseDesignIntf*>* list);
qreal calcAbsolutePosY(qreal currentOffset, BaseDesignIntf* item);
@ -378,6 +384,8 @@ private:
int m_selectionPenSize;
int m_possibleResizeDirectionFlags;
int m_possibleMoveDirectionFlags;
int m_savedPossibleResizeDirectionFlags;
int m_savedPossibleMoveDirectionFlags;
int m_resizeDirectionFlags;
qreal m_width;
qreal m_height;
@ -427,6 +435,7 @@ private:
bool m_fillTransparentInDesignMode;
QRect m_itemGeometry;
UnitType m_unitType;
bool m_itemGeometryLocked;
signals:
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
void posChanging(QObject* object, QPointF newPos, QPointF oldPos);

View File

@ -1169,6 +1169,14 @@ void PageDesignIntf::activateItemToJoin(QRectF itemRect, QList<ItemProjections>&
if (m_joinItem) m_joinItem->turnOnJoinMarker(true);
}
void PageDesignIntf::selectAllChildren(BaseDesignIntf *item)
{
if (item)
foreach(BaseDesignIntf* child, item->childBaseItems()){
child->setSelected(true);
}
}
void PageDesignIntf::rectMoved(QRectF itemRect, BaseDesignIntf* container){
if (!container){
container = bandAt(QPointF(itemRect.topLeft()));
@ -1772,6 +1780,34 @@ void PageDesignIntf::setBorders(const BaseDesignIntf::BorderLines& border)
changeSelectedGroupProperty("borders", (int)border);
}
void PageDesignIntf::lockSelectedItems()
{
foreach(QGraphicsItem* graphicItem, selectedItems()){
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(graphicItem);
if (item) item->setProperty("geometryLocked", true);
}
}
void PageDesignIntf::unlockSelectedItems()
{
foreach(QGraphicsItem* graphicItem, selectedItems()){
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(graphicItem);
if (item) item->setProperty("geometryLocked", false);
}
}
void PageDesignIntf::selectOneLevelItems()
{
foreach(QGraphicsItem* graphicItem, selectedItems()){
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(graphicItem->parentItem());
if (item)
selectAllChildren(item);
else
selectAllChildren(dynamic_cast<BaseDesignIntf*>(graphicItem));
}
}
void PageDesignIntf::removeAllItems()
{
pageItem()->clear();

View File

@ -252,6 +252,9 @@ namespace LimeReport {
void setFont(const QFont &font);
void setTextAlign(const Qt::Alignment& alignment);
void setBorders(const BaseDesignIntf::BorderLines& border);
void lockSelectedItems();
void unlockSelectedItems();
void selectOneLevelItems();
private slots:
void slotPageGeometryChanged(QObject*, QRectF, QRectF );
void slotItemPropertyChanged(QString propertyName,
@ -277,6 +280,7 @@ namespace LimeReport {
const QVariant& newPropertyValue);
void changeSelectedGroupProperty(const QString& name,const QVariant& value);
void activateItemToJoin(QRectF itemRect, QList<ItemProjections>& items);
void selectAllChildren(BaseDesignIntf* item);
private:
enum JoinType{Width, Height};
LimeReport::PageItemDesignIntf::Ptr m_pageItem;

View File

@ -880,6 +880,24 @@ void ReportDesignWidget::slotDialogDeleted(QString dialogName)
}
}
void ReportDesignWidget::lockSelectedItems()
{
if (activePage())
activePage()->lockSelectedItems();
}
void ReportDesignWidget::unlockSelectedItems()
{
if (activePage())
activePage()->unlockSelectedItems();
}
void ReportDesignWidget::selectOneLevelItems()
{
if (activePage())
activePage()->selectOneLevelItems();
}
void ReportDesignWidget::slotDatasourceCollectionLoaded(const QString & /*collectionName*/)
{
}

View File

@ -201,6 +201,9 @@ public slots:
void deleteCurrentPage();
void slotPagesLoadFinished();
void slotDialogDeleted(QString dialogName);
void lockSelectedItems();
void unlockSelectedItems();
void selectOneLevelItems();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void addNewDialog();
#endif

View File

@ -256,6 +256,24 @@ void ReportDesignWindow::createActions()
m_addNewDialogAction->setIcon(QIcon(":/report//images/addDialog"));
connect(m_addNewDialogAction, SIGNAL(triggered()), this, SLOT(slotAddNewDialog()));
#endif
m_lockSelectedItemsAction = new QAction(tr("Lock selected items"), this);
m_lockSelectedItemsAction->setIcon(QIcon(":/report/images/lock"));
m_lockSelectedItemsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
connect(m_lockSelectedItemsAction, SIGNAL(triggered()),
this, SLOT(slotLockSelectedItems()));
m_unlockSelectedItemsAction = new QAction(tr("Unlock selected items"), this);
m_unlockSelectedItemsAction->setIcon(QIcon(":/report/images/unlock"));
m_unlockSelectedItemsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_L));
connect(m_unlockSelectedItemsAction, SIGNAL(triggered()),
this, SLOT(slotUnlockSelectedItems()));
m_selectOneLevelItems = new QAction(tr("Select one level items"), this);
//m_unlockSelectedItemsAction->setIcon(QIcon(":/report/images/unlock"));
m_selectOneLevelItems->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
connect(m_selectOneLevelItems, SIGNAL(triggered()),
this, SLOT(slotSelectOneLevelItems()));
}
void ReportDesignWindow::createReportToolBar()
@ -465,6 +483,10 @@ void ReportDesignWindow::createMainMenu()
m_editMenu->addAction(m_pasteAction);
m_editMenu->addAction(m_cutAction);
m_editMenu->addAction(m_settingsAction);
m_editMenu->addSeparator();
m_editMenu->addAction(m_lockSelectedItemsAction);
m_editMenu->addAction(m_unlockSelectedItemsAction);
m_editMenu->addAction(m_selectOneLevelItems);
m_infoMenu = menuBar()->addMenu(tr("Info"));
m_infoMenu->addAction(m_aboutAction);
m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent Files"));
@ -783,10 +805,10 @@ void ReportDesignWindow::restoreSetting()
int screenWidth = desktop->screenGeometry().width();
int screenHeight = desktop->screenGeometry().height();
int x = screenWidth*0.1;
int y = screenHeight*0.1;
int x = screenWidth * 0.1;
int y = screenHeight * 0.1;
resize(screenWidth*0.8, screenHeight*0.8);
resize(screenWidth * 0.8, screenHeight * 0.8);
move(x, y);
}
v = settings()->value("PageEditorsState");
@ -1495,8 +1517,24 @@ void ReportDesignWindow::slotAddNewDialog()
{
m_reportDesignWidget->addNewDialog();
}
#endif
void ReportDesignWindow::slotLockSelectedItems()
{
m_reportDesignWidget->lockSelectedItems();
}
void ReportDesignWindow::slotUnlockSelectedItems()
{
m_reportDesignWidget->unlockSelectedItems();
}
void ReportDesignWindow::slotSelectOneLevelItems()
{
m_reportDesignWidget->selectOneLevelItems();
}
void ReportDesignWindow::closeEvent(QCloseEvent * event)
{
if (checkNeedToSave()){

View File

@ -125,6 +125,9 @@ private slots:
void slotDeleteDialog();
void slotAddNewDialog();
#endif
void slotLockSelectedItems();
void slotUnlockSelectedItems();
void slotSelectOneLevelItems();
protected:
void closeEvent(QCloseEvent *event);
void resizeEvent(QResizeEvent *);
@ -232,6 +235,11 @@ private:
QAction* m_deleteDialogAction;
QAction* m_addNewDialogAction;
#endif
QAction* m_lockSelectedItemsAction;
QAction* m_unlockSelectedItemsAction;
QAction* m_selectOneLevelItems;
QMenu* m_recentFilesMenu;
QSignalMapper* m_bandsAddSignalsMap;

View File

@ -161,6 +161,7 @@ void QObjectPropertyModel::translatePropertyName()
tr("hideText");
tr("option3");
tr("units");
tr("geometryLocked");
}
void QObjectPropertyModel::clearObjectsList()

View File

@ -184,5 +184,7 @@
<file alias="/images/object">images/object.png</file>
<file alias="/images/vlayout">images/vlayuot_4_24.png</file>
<file alias="/images/logo32">images/designer.png</file>
<file alias="/images/lock">images/lock.png</file>
<file>images/unlock.png</file>
</qresource>
</RCC>

Binary file not shown.

View File

@ -431,6 +431,10 @@ p, li { white-space: pre-wrap; }
<source>Create Vertical Layout</source>
<translation>Создать Вертикальную Компановку</translation>
</message>
<message>
<source>Lock item geometry</source>
<translation>Блокировать изменения геометрии</translation>
</message>
</context>
<context>
<name>LimeReport::ConnectionDesc</name>
@ -1949,12 +1953,16 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>option3</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<source>units</source>
<translation>Единицы измерения</translation>
</message>
<message>
<source>geometryLocked</source>
<translation>Геометрия заблокирована</translation>
</message>
</context>
<context>
<name>LimeReport::RectPropItem</name>
@ -2279,6 +2287,18 @@ p, li { white-space: pre-wrap; }
<source>Dialog Designer Tools</source>
<translation>Панель Инструментов</translation>
</message>
<message>
<source>Lock selected items</source>
<translation>Заблокировать выбранные элементы</translation>
</message>
<message>
<source>Unlock selected items</source>
<translation>Разблокировать выбранные элементы</translation>
</message>
<message>
<source>Select one level items</source>
<translation>Выбрать все элементы одного уровня</translation>
</message>
</context>
<context>
<name>LimeReport::ReportEnginePrivate</name>
@ -2450,7 +2470,7 @@ This preview is no longer valid.</source>
</message>
<message>
<source>CSV</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<source>Separator</source>