diff --git a/limereport/bands/lrdataband.cpp b/limereport/bands/lrdataband.cpp index 2a6eaf7..7119440 100644 --- a/limereport/bands/lrdataband.cpp +++ b/limereport/bands/lrdataband.cpp @@ -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) diff --git a/limereport/bands/lrpagefooter.cpp b/limereport/bands/lrpagefooter.cpp index 68b9f0a..8ee5959 100644 --- a/limereport/bands/lrpagefooter.cpp +++ b/limereport/bands/lrpagefooter.cpp @@ -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 diff --git a/limereport/bands/lrpagefooter.h b/limereport/bands/lrpagefooter.h index 2f634a5..3422b60 100644 --- a/limereport/bands/lrpagefooter.h +++ b/limereport/bands/lrpagefooter.h @@ -35,7 +35,7 @@ #include namespace LimeReport{ -class PageFooter : public LimeReport::BandDesignIntf +class PageFooter : public BandDesignIntf { Q_OBJECT Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage) diff --git a/limereport/images/lock.png b/limereport/images/lock.png new file mode 100644 index 0000000..5485df1 Binary files /dev/null and b/limereport/images/lock.png differ diff --git a/limereport/images/unlock.png b/limereport/images/unlock.png new file mode 100644 index 0000000..72d1314 Binary files /dev/null and b/limereport/images/unlock.png differ diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 190259d..c3fce2f 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -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 diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index 91a3d92..5d474e2 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -33,7 +33,7 @@ namespace LimeReport{ -class ImageItem : public LimeReport::ItemDesignIntf, public IPainterProxy +class ImageItem : public ItemDesignIntf, public IPainterProxy { Q_OBJECT Q_ENUMS(Format) diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 0376655..50de9d5 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -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) { diff --git a/limereport/items/lrtextitem.h b/limereport/items/lrtextitem.h index abc1211..aa624eb 100644 --- a/limereport/items/lrtextitem.h +++ b/limereport/items/lrtextitem.h @@ -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) diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 3751f44..caac574 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -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) diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 18d5130..52970c2 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -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(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 diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 01dfc0f..646e00f 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -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* 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); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 5fe7288..eade90c 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1169,6 +1169,14 @@ void PageDesignIntf::activateItemToJoin(QRectF itemRect, QList& 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(graphicItem); + if (item) item->setProperty("geometryLocked", true); + } +} + +void PageDesignIntf::unlockSelectedItems() +{ + foreach(QGraphicsItem* graphicItem, selectedItems()){ + BaseDesignIntf* item = dynamic_cast(graphicItem); + if (item) item->setProperty("geometryLocked", false); + } +} + + +void PageDesignIntf::selectOneLevelItems() +{ + foreach(QGraphicsItem* graphicItem, selectedItems()){ + BaseDesignIntf* item = dynamic_cast(graphicItem->parentItem()); + if (item) + selectAllChildren(item); + else + selectAllChildren(dynamic_cast(graphicItem)); + } +} + void PageDesignIntf::removeAllItems() { pageItem()->clear(); diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index 0a3c914..2ed583c 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -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& items); + void selectAllChildren(BaseDesignIntf* item); private: enum JoinType{Width, Height}; LimeReport::PageItemDesignIntf::Ptr m_pageItem; diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index de897e7..c2d52b3 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -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*/) { } diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 149dcb5..5de247e 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -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 diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 1fdc9e7..20d1273 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -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()){ diff --git a/limereport/lrreportdesignwindow.h b/limereport/lrreportdesignwindow.h index d5dc790..5701894 100644 --- a/limereport/lrreportdesignwindow.h +++ b/limereport/lrreportdesignwindow.h @@ -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; diff --git a/limereport/objectinspector/lrobjectitemmodel.cpp b/limereport/objectinspector/lrobjectitemmodel.cpp index 9aff3a0..23fa281 100644 --- a/limereport/objectinspector/lrobjectitemmodel.cpp +++ b/limereport/objectinspector/lrobjectitemmodel.cpp @@ -161,6 +161,7 @@ void QObjectPropertyModel::translatePropertyName() tr("hideText"); tr("option3"); tr("units"); + tr("geometryLocked"); } void QObjectPropertyModel::clearObjectsList() diff --git a/limereport/report.qrc b/limereport/report.qrc index 57fbf96..89999d9 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -184,5 +184,7 @@ images/object.png images/vlayuot_4_24.png images/designer.png + images/lock.png + images/unlock.png diff --git a/translations/limereport_ru.qm b/translations/limereport_ru.qm index 35a81f9..c1d81cb 100644 Binary files a/translations/limereport_ru.qm and b/translations/limereport_ru.qm differ diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts index b6da993..d1ea17d 100644 --- a/translations/limereport_ru.ts +++ b/translations/limereport_ru.ts @@ -431,6 +431,10 @@ p, li { white-space: pre-wrap; } Create Vertical Layout Создать Вертикальную Компановку + + Lock item geometry + Блокировать изменения геометрии + LimeReport::ConnectionDesc @@ -1949,12 +1953,16 @@ p, li { white-space: pre-wrap; } option3 - + units Единицы измерения + + geometryLocked + Геометрия заблокирована + LimeReport::RectPropItem @@ -2279,6 +2287,18 @@ p, li { white-space: pre-wrap; } Dialog Designer Tools Панель Инструментов + + Lock selected items + Заблокировать выбранные элементы + + + Unlock selected items + Разблокировать выбранные элементы + + + Select one level items + Выбрать все элементы одного уровня + LimeReport::ReportEnginePrivate @@ -2450,7 +2470,7 @@ This preview is no longer valid. CSV - + Separator