0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 08:34:38 +03:00

Finish 1.4.41

# Conflicts:
#	limereport/lrbasedesignintf.h
#	limereport/lrreportdesignwidget.cpp
#	limereport/lrreportdesignwidget.h
#	limereport/lrreportengine.cpp
This commit is contained in:
Arin Alexander 2017-09-21 22:08:20 +03:00
commit 0ab92681b0
9 changed files with 87 additions and 14 deletions

View File

@ -70,7 +70,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 4 LIMEREPORT_VERSION_MINOR = 4
LIMEREPORT_VERSION_RELEASE = 42 LIMEREPORT_VERSION_RELEASE = 43
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -63,7 +63,7 @@ bool lessThen(BaseDesignIntf *c1, BaseDesignIntf* c2){
HorizontalLayout::HorizontalLayout(QObject *owner, QGraphicsItem *parent) HorizontalLayout::HorizontalLayout(QObject *owner, QGraphicsItem *parent)
: LayoutDesignIntf(xmlTag, owner, parent),m_isRelocating(false),m_layoutType(Layout) : LayoutDesignIntf(xmlTag, owner, parent),m_isRelocating(false),m_layoutType(Layout)
{ {
setPossibleResizeDirectionFlags(ResizeBottom); setPossibleResizeDirectionFlags(AllDirections);
m_layoutMarker = new LayoutMarker(this); m_layoutMarker = new LayoutMarker(this);
m_layoutMarker->setParentItem(this); m_layoutMarker->setParentItem(this);
m_layoutMarker->setColor(Qt::red); m_layoutMarker->setColor(Qt::red);
@ -86,6 +86,7 @@ BaseDesignIntf *HorizontalLayout::createSameTypeItem(QObject *owner, QGraphicsIt
void HorizontalLayout::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void HorizontalLayout::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
LayoutDesignIntf::hoverEnterEvent(event);
// if ((itemMode() & LayoutEditMode) || isSelected()){ // if ((itemMode() & LayoutEditMode) || isSelected()){
// setChildVisibility(false); // setChildVisibility(false);
// } // }
@ -94,6 +95,7 @@ void HorizontalLayout::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void HorizontalLayout::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void HorizontalLayout::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
LayoutDesignIntf::hoverLeaveEvent(event);
// setChildVisibility(true); // setChildVisibility(true);
} }
@ -101,7 +103,7 @@ void HorizontalLayout::geometryChangedEvent(QRectF newRect, QRectF )
{ {
m_layoutMarker->setHeight(newRect.height()); m_layoutMarker->setHeight(newRect.height());
relocateChildren(); relocateChildren();
if (m_layoutType == Table && !m_isRelocating){ if (/*m_layoutType == Table && */!m_isRelocating){
divideSpace(); divideSpace();
} }
} }
@ -203,6 +205,36 @@ void HorizontalLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags)
relocateChildren(); relocateChildren();
} }
QVariant HorizontalLayout::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
{
if (change == QGraphicsItem::ItemSelectedHasChanged){
m_isRelocating = true;
foreach(BaseDesignIntf* item, m_children){
item->setVisible(!value.toBool());
}
m_isRelocating = false;
}
return LayoutDesignIntf::itemChange(change, value);
}
void HorizontalLayout::paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
if (isSelected()){
foreach( BaseDesignIntf* item, m_children){
ppainter->save();
ppainter->setPen(Qt::red);
ppainter->drawRect(
QRectF(item->pos().x(),item->pos().y(),
item->rect().bottomRight().rx(),
item->rect().bottomRight().ry()
)
);
ppainter->restore();
}
}
LayoutDesignIntf::paint(ppainter, option, widget);
}
void HorizontalLayout::restoreChild(BaseDesignIntf* item){ void HorizontalLayout::restoreChild(BaseDesignIntf* item){
if (m_children.contains(item)) return; if (m_children.contains(item)) return;
@ -257,9 +289,22 @@ void HorizontalLayout::addChild(BaseDesignIntf *item, bool updateSize)
item->setFixedPos(true); item->setFixedPos(true);
item->setPossibleResizeDirectionFlags(ResizeRight | ResizeBottom); item->setPossibleResizeDirectionFlags(ResizeRight | ResizeBottom);
connect(item,SIGNAL(destroyed(QObject*)),this,SLOT(slotOnChildDestroy(QObject*))); connect(
connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))); item, SIGNAL(destroyed(QObject*)),
connect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),this,SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))); this, SLOT(slotOnChildDestroy(QObject*))
);
connect(
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
);
connect(
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
this,SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
);
connect(
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
);
if (updateSize){ if (updateSize){
relocateChildren(); relocateChildren();
@ -318,7 +363,7 @@ void HorizontalLayout::relocateChildren()
qreal curX = spaceBorder; qreal curX = spaceBorder;
m_isRelocating = true; m_isRelocating = true;
foreach (BaseDesignIntf* item, m_children) { foreach (BaseDesignIntf* item, m_children) {
if (item->isVisible()){ if (item->isVisible() || itemMode() == DesignMode){
item->setPos(curX,spaceBorder); item->setPos(curX,spaceBorder);
curX+=item->width(); curX+=item->width();
item->setHeight(height()-(spaceBorder * 2)); item->setHeight(height()-(spaceBorder * 2));
@ -423,7 +468,7 @@ void HorizontalLayout::divideSpace(){
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
foreach(BaseDesignIntf* item, m_children){ foreach(BaseDesignIntf* item, m_children){
if (item->isVisible()){ if (item->isVisible() || itemMode() == DesignMode ){
itemsSumSize += item->width(); itemsSumSize += item->width();
visibleItemsCount++; visibleItemsCount++;
} }
@ -431,10 +476,10 @@ void HorizontalLayout::divideSpace(){
qreal delta = (width() - (itemsSumSize+spaceBorder*2)) / (visibleItemsCount!=0 ? visibleItemsCount : 1); qreal delta = (width() - (itemsSumSize+spaceBorder*2)) / (visibleItemsCount!=0 ? visibleItemsCount : 1);
for (int i=0; i<m_children.size(); ++i){ for (int i=0; i<m_children.size(); ++i){
if (m_children[i]->isVisible()) if (m_children[i]->isVisible() || itemMode() == DesignMode)
m_children[i]->setWidth(m_children[i]->width()+delta); m_children[i]->setWidth(m_children[i]->width()+delta);
if ((i+1)<m_children.size()) if ((i+1)<m_children.size())
if (m_children[i+1]->isVisible()) if (m_children[i+1]->isVisible() || itemMode() == DesignMode)
m_children[i+1]->setPos(m_children[i+1]->pos().x()+delta*(i+1),m_children[i+1]->pos().y()); m_children[i+1]->setPos(m_children[i+1]->pos().x()+delta*(i+1),m_children[i+1]->pos().y());
} }
m_isRelocating = false; m_isRelocating = false;
@ -473,6 +518,11 @@ void HorizontalLayout::slotOnChildVisibleHasChanged(BaseDesignIntf *)
} }
} }
void HorizontalLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value)
{
item->setZValue(value ? item->zValue()+1 : item->zValue()-1);
}
HorizontalLayout::LayoutType HorizontalLayout::layoutType() const HorizontalLayout::LayoutType HorizontalLayout::layoutType() const
{ {
return m_layoutType; return m_layoutType;

View File

@ -96,11 +96,15 @@ protected:
void setItemAlign(const ItemAlign &itemAlign); void setItemAlign(const ItemAlign &itemAlign);
void setBorderLinesFlags(BorderLines flags); void setBorderLinesFlags(BorderLines flags);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget);
private slots: private slots:
void slotOnChildDestroy(QObject *child); void slotOnChildDestroy(QObject *child);
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry); void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&); void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
void slotOnChildVisibleHasChanged(BaseDesignIntf*); void slotOnChildVisibleHasChanged(BaseDesignIntf*);
void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value);
//void slotOnPosChanged(QObject*, QPointF newPos, QPointF ); //void slotOnPosChanged(QObject*, QPointF newPos, QPointF );
private: private:
void divideSpace(); void divideSpace();

View File

@ -1035,6 +1035,7 @@ QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co
} }
if (change == QGraphicsItem::ItemSelectedChange) { if (change == QGraphicsItem::ItemSelectedChange) {
turnOnSelectionMarker(value.toBool()); turnOnSelectionMarker(value.toBool());
emit itemSelectedHasBeenChanged(this, value.toBool());
} }
if (change == QGraphicsItem::ItemParentHasChanged) { if (change == QGraphicsItem::ItemParentHasChanged) {
parentChangedEvent(dynamic_cast<BaseDesignIntf*>(value.value<QGraphicsItem*>())); parentChangedEvent(dynamic_cast<BaseDesignIntf*>(value.value<QGraphicsItem*>()));

View File

@ -413,6 +413,7 @@ signals:
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
void posChanged(QObject* object, QPointF newPos, QPointF oldPos); void posChanged(QObject* object, QPointF newPos, QPointF oldPos);
void itemSelected(LimeReport::BaseDesignIntf *item); void itemSelected(LimeReport::BaseDesignIntf *item);
void itemSelectedHasBeenChanged(BaseDesignIntf *item, bool value);
void loadCollectionFinished(const QString& collectionName); void loadCollectionFinished(const QString& collectionName);
void objectLoaded(QObject* object); void objectLoaded(QObject* object);
void objectChanged(QObject* object); void objectChanged(QObject* object);

View File

@ -387,7 +387,7 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){
bool ReportDesignWidget::saveToFile(const QString &fileName){ bool ReportDesignWidget::saveToFile(const QString &fileName){
bool result = false; bool result = false;
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); prepareReport();
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs(); updateDialogs();
#endif #endif
@ -408,7 +408,7 @@ bool ReportDesignWidget::saveToFile(const QString &fileName){
bool ReportDesignWidget::save() bool ReportDesignWidget::save()
{ {
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); prepareReport();
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs(); updateDialogs();
#endif #endif
@ -620,9 +620,15 @@ void ReportDesignWidget::setBorders(const BaseDesignIntf::BorderLines& borders)
activePage()->setBorders(borders); activePage()->setBorders(borders);
} }
void ReportDesignWidget::prepareReport()
{
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
report()->clearSelection();
}
void ReportDesignWidget::previewReport() void ReportDesignWidget::previewReport()
{ {
report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); prepareReport();
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs(); updateDialogs();
#endif #endif
@ -631,7 +637,7 @@ void ReportDesignWidget::previewReport()
void ReportDesignWidget::printReport() void ReportDesignWidget::printReport()
{ {
report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); prepareReport();
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs(); updateDialogs();
#endif #endif

View File

@ -206,6 +206,7 @@ private:
bool m_useGrid; bool m_useGrid;
bool m_useMagnet; bool m_useMagnet;
bool m_dialogChanged; bool m_dialogChanged;
void prepareReport();
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -823,6 +823,15 @@ void ReportEnginePrivate::reorderPages(const QList<PageDesignIntf *>& reorderedP
} }
} }
void ReportEnginePrivate::clearSelection()
{
foreach (PageDesignIntf* page, m_pages) {
foreach(QGraphicsItem* item, page->selectedItems()){
item->setSelected(false);
}
}
}
bool ReportEnginePrivate::addTranslationLanguage(QLocale::Language language) bool ReportEnginePrivate::addTranslationLanguage(QLocale::Language language)
{ {
if (!m_translations.keys().contains(language)){ if (!m_translations.keys().contains(language)){

View File

@ -139,6 +139,7 @@ public:
QList<QLocale::Language> aviableLanguages(); QList<QLocale::Language> aviableLanguages();
ReportTranslation* reportTranslation(QLocale::Language language); ReportTranslation* reportTranslation(QLocale::Language language);
void reorderPages(const QList<PageDesignIntf *> &reorderedPages); void reorderPages(const QList<PageDesignIntf *> &reorderedPages);
void clearSelection();
signals: signals:
void pagesLoadFinished(); void pagesLoadFinished();
void datasourceCollectionLoadFinished(const QString& collectionName); void datasourceCollectionLoadFinished(const QString& collectionName);