Skip to content

Commit 8eb6aa9

Browse files
committedJan 5, 2018
More UI work on reports
1 parent fc9a451 commit 8eb6aa9

10 files changed

+509
-44
lines changed
 

‎src/app/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ SET(QGIS_APP_SRCS
204204
layout/qgslayoutscalebarwidget.cpp
205205
layout/qgslayoutshapewidget.cpp
206206
layout/qgslayouttablebackgroundcolorsdialog.cpp
207+
layout/qgsreportfieldgroupsectionwidget.cpp
208+
layout/qgsreportlayoutsectionwidget.cpp
207209
layout/qgsreportorganizerwidget.cpp
208210
layout/qgsreportsectionmodel.cpp
209211

@@ -425,6 +427,8 @@ SET (QGIS_APP_MOC_HDRS
425427
layout/qgslayoutscalebarwidget.h
426428
layout/qgslayoutshapewidget.h
427429
layout/qgslayouttablebackgroundcolorsdialog.h
430+
layout/qgsreportfieldgroupsectionwidget.h
431+
layout/qgsreportlayoutsectionwidget.h
428432
layout/qgsreportorganizerwidget.h
429433
layout/qgsreportsectionmodel.h
430434

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/***************************************************************************
2+
qgsreportfieldgroupsectionwidget.cpp
3+
------------------------
4+
begin : December 2017
5+
copyright : (C) 2017 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
8+
/***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
#include "qgsreportfieldgroupsectionwidget.h"
18+
#include "qgsreportsectionfieldgroup.h"
19+
#include "qgslayout.h"
20+
#include "qgslayoutdesignerdialog.h"
21+
22+
QgsReportSectionFieldGroupWidget::QgsReportSectionFieldGroupWidget( QWidget *parent, QgsLayoutDesignerDialog *designer, QgsReportSectionFieldGroup *section )
23+
: QWidget( parent )
24+
, mSection( section )
25+
, mDesigner( designer )
26+
{
27+
setupUi( this );
28+
29+
mLayerComboBox->setFilters( QgsMapLayerProxyModel::VectorLayer );
30+
connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, mFieldComboBox, &QgsFieldComboBox::setLayer );
31+
connect( mButtonEditBody, &QPushButton::clicked, this, &QgsReportSectionFieldGroupWidget::editBody );
32+
33+
mLayerComboBox->setLayer( section->layer() );
34+
mFieldComboBox->setField( section->field() );
35+
mSortAscendingCheckBox->setChecked( section->sortAscending() );
36+
37+
connect( mSortAscendingCheckBox, &QCheckBox::toggled, this, &QgsReportSectionFieldGroupWidget::sortAscendingToggled );
38+
connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsReportSectionFieldGroupWidget::setLayer );
39+
connect( mFieldComboBox, &QgsFieldComboBox::fieldChanged, this, &QgsReportSectionFieldGroupWidget::setField );
40+
}
41+
42+
void QgsReportSectionFieldGroupWidget::editBody()
43+
{
44+
if ( !mSection->body() )
45+
{
46+
std::unique_ptr< QgsLayout > body = qgis::make_unique< QgsLayout >( mSection->project() );
47+
body->initializeDefaults();
48+
mSection->setBody( body.release() );
49+
}
50+
51+
if ( mSection->body() )
52+
{
53+
mSection->body()->reportContext().setLayer( mSection->layer() );
54+
mDesigner->setCurrentLayout( mSection->body() );
55+
}
56+
}
57+
58+
void QgsReportSectionFieldGroupWidget::sortAscendingToggled( bool checked )
59+
{
60+
mSection->setSortAscending( checked );
61+
}
62+
63+
void QgsReportSectionFieldGroupWidget::setLayer( QgsMapLayer *layer )
64+
{
65+
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer );
66+
if ( !vl )
67+
return;
68+
69+
mSection->setLayer( vl );
70+
if ( mSection->body() )
71+
mSection->body()->reportContext().setLayer( mSection->layer() );
72+
}
73+
74+
void QgsReportSectionFieldGroupWidget::setField( const QString &field )
75+
{
76+
mSection->setField( field );
77+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/***************************************************************************
2+
qgsreportfieldgroupsectionwidget.h
3+
----------------------
4+
begin : December 2017
5+
copyright : (C) 2017 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
8+
/***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
#ifndef QGSREPORTFIELDGROUPSECTIONWIDGET_H
18+
#define QGSREPORTFIELDGROUPSECTIONWIDGET_H
19+
20+
#include "ui_qgsreportwidgetfieldgroupsectionbase.h"
21+
22+
class QgsLayoutDesignerDialog;
23+
class QgsReportSectionFieldGroup;
24+
25+
class QgsReportSectionFieldGroupWidget: public QWidget, private Ui::QgsReportWidgetFieldGroupSectionBase
26+
{
27+
Q_OBJECT
28+
public:
29+
QgsReportSectionFieldGroupWidget( QWidget *parent, QgsLayoutDesignerDialog *designer, QgsReportSectionFieldGroup *section );
30+
31+
private slots:
32+
33+
void editBody();
34+
void sortAscendingToggled( bool checked );
35+
void setLayer( QgsMapLayer *layer );
36+
void setField( const QString &field );
37+
38+
private:
39+
40+
QgsReportSectionFieldGroup *mSection = nullptr;
41+
QgsLayoutDesignerDialog *mDesigner = nullptr;
42+
43+
};
44+
45+
#endif // QGSREPORTFIELDGROUPSECTIONWIDGET_H
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/***************************************************************************
2+
qgsreportlayoutsectionwidget.cpp
3+
------------------------
4+
begin : December 2017
5+
copyright : (C) 2017 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
8+
/***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
#include "qgsreportlayoutsectionwidget.h"
18+
#include "qgsreportsectionlayout.h"
19+
#include "qgslayout.h"
20+
#include "qgslayoutdesignerdialog.h"
21+
22+
QgsReportLayoutSectionWidget::QgsReportLayoutSectionWidget( QWidget *parent, QgsLayoutDesignerDialog *designer, QgsReportSectionLayout *section )
23+
: QWidget( parent )
24+
, mSection( section )
25+
, mDesigner( designer )
26+
{
27+
setupUi( this );
28+
29+
connect( mButtonEditBody, &QPushButton::clicked, this, &QgsReportLayoutSectionWidget::editBody );
30+
}
31+
32+
void QgsReportLayoutSectionWidget::editBody()
33+
{
34+
if ( !mSection->body() )
35+
{
36+
std::unique_ptr< QgsLayout > body = qgis::make_unique< QgsLayout >( mSection->project() );
37+
body->initializeDefaults();
38+
mSection->setBody( body.release() );
39+
}
40+
41+
mDesigner->setCurrentLayout( mSection->body() );
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/***************************************************************************
2+
qgsreportlayoutsectionwidget.h
3+
----------------------
4+
begin : December 2017
5+
copyright : (C) 2017 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
8+
/***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
#ifndef QGSREPORTLAYOUTSECTIONWIDGET_H
18+
#define QGSREPORTLAYOUTSECTIONWIDGET_H
19+
20+
#include "ui_qgsreportwidgetlayoutsectionbase.h"
21+
22+
class QgsLayoutDesignerDialog;
23+
class QgsReportSectionLayout;
24+
25+
class QgsReportLayoutSectionWidget: public QWidget, private Ui::QgsReportWidgetLayoutSectionBase
26+
{
27+
Q_OBJECT
28+
public:
29+
QgsReportLayoutSectionWidget( QWidget *parent, QgsLayoutDesignerDialog *designer, QgsReportSectionLayout *section );
30+
31+
private slots:
32+
33+
void editBody();
34+
35+
private:
36+
37+
QgsReportSectionLayout *mSection = nullptr;
38+
QgsLayoutDesignerDialog *mDesigner = nullptr;
39+
40+
};
41+
42+
#endif // QGSREPORTLAYOUTSECTIONWIDGET_H

‎src/app/layout/qgsreportorganizerwidget.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "qgsreportsectionfieldgroup.h"
2222
#include "qgslayout.h"
2323
#include "qgslayoutdesignerdialog.h"
24+
#include "qgsreportlayoutsectionwidget.h"
25+
#include "qgsreportfieldgroupsectionwidget.h"
2426
#include <QMenu>
2527
#include <QMessageBox>
2628

@@ -40,9 +42,14 @@ QgsReportOrganizerWidget::QgsReportOrganizerWidget( QWidget *parent, QgsLayoutDe
4042
mViewSections->setModel( mSectionModel );
4143

4244
#ifdef ENABLE_MODELTEST
43-
//new ModelTest( mSectionModel, this );
45+
new ModelTest( mSectionModel, this );
4446
#endif
4547

48+
QVBoxLayout *vLayout = new QVBoxLayout();
49+
vLayout->setMargin( 0 );
50+
vLayout->setSpacing( 0 );
51+
mSettingsFrame->setLayout( vLayout );
52+
4653
mViewSections->setEditTriggers( QAbstractItemView::AllEditTriggers );
4754

4855
QMenu *addMenu = new QMenu( mButtonAddSection );
@@ -151,4 +158,22 @@ void QgsReportOrganizerWidget::selectionChanged( const QModelIndex &current, con
151158

152159
whileBlocking( mCheckShowHeader )->setChecked( parent->headerEnabled() );
153160
whileBlocking( mCheckShowFooter )->setChecked( parent->footerEnabled() );
161+
162+
delete mConfigWidget;
163+
if ( QgsReportSectionLayout *section = dynamic_cast< QgsReportSectionLayout * >( parent ) )
164+
{
165+
QgsReportLayoutSectionWidget *widget = new QgsReportLayoutSectionWidget( this, mDesigner, section );
166+
mSettingsFrame->layout()->addWidget( widget );
167+
mConfigWidget = widget;
168+
}
169+
else if ( QgsReportSectionFieldGroup *section = dynamic_cast< QgsReportSectionFieldGroup * >( parent ) )
170+
{
171+
QgsReportSectionFieldGroupWidget *widget = new QgsReportSectionFieldGroupWidget( this, mDesigner, section );
172+
mSettingsFrame->layout()->addWidget( widget );
173+
mConfigWidget = widget;
174+
}
175+
else
176+
{
177+
mConfigWidget = nullptr;
178+
}
154179
}

‎src/app/layout/qgsreportorganizerwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class QgsReportOrganizerWidget: public QgsPanelWidget, private Ui::QgsReportOrga
5151
QgsReportSectionModel *mSectionModel = nullptr;
5252
QgsMessageBar *mMessageBar;
5353
QgsLayoutDesignerDialog *mDesigner = nullptr;
54+
QWidget *mConfigWidget = nullptr;
5455

5556
};
5657

‎src/ui/layout/qgsreportorganizerwidgetbase.ui

Lines changed: 101 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -97,54 +97,112 @@
9797
</layout>
9898
</item>
9999
<item>
100-
<layout class="QGridLayout" name="gridLayout">
101-
<item row="1" column="1">
102-
<widget class="QPushButton" name="mButtonEditFooter">
103-
<property name="text">
104-
<string>Edit</string>
105-
</property>
106-
</widget>
107-
</item>
108-
<item row="0" column="0">
109-
<widget class="QCheckBox" name="mCheckShowHeader">
110-
<property name="text">
111-
<string>Show header</string>
112-
</property>
113-
</widget>
114-
</item>
115-
<item row="0" column="1">
116-
<widget class="QPushButton" name="mButtonEditHeader">
117-
<property name="text">
118-
<string>Edit</string>
119-
</property>
120-
</widget>
121-
</item>
122-
<item row="1" column="0">
123-
<widget class="QCheckBox" name="mCheckShowFooter">
124-
<property name="text">
125-
<string>Show footer</string>
126-
</property>
127-
</widget>
128-
</item>
129-
<item row="1" column="2">
130-
<spacer name="horizontalSpacer_2">
131-
<property name="orientation">
132-
<enum>Qt::Horizontal</enum>
133-
</property>
134-
<property name="sizeHint" stdset="0">
135-
<size>
136-
<width>40</width>
137-
<height>20</height>
138-
</size>
139-
</property>
140-
</spacer>
141-
</item>
142-
</layout>
100+
<widget class="QScrollArea" name="scrollArea">
101+
<property name="frameShape">
102+
<enum>QFrame::NoFrame</enum>
103+
</property>
104+
<property name="widgetResizable">
105+
<bool>true</bool>
106+
</property>
107+
<widget class="QWidget" name="scrollAreaWidgetContents">
108+
<property name="geometry">
109+
<rect>
110+
<x>0</x>
111+
<y>0</y>
112+
<width>687</width>
113+
<height>207</height>
114+
</rect>
115+
</property>
116+
<layout class="QVBoxLayout" name="verticalLayout_2">
117+
<item>
118+
<layout class="QGridLayout" name="gridLayout">
119+
<item row="1" column="1">
120+
<widget class="QPushButton" name="mButtonEditFooter">
121+
<property name="text">
122+
<string>Edit</string>
123+
</property>
124+
</widget>
125+
</item>
126+
<item row="0" column="0">
127+
<widget class="QCheckBox" name="mCheckShowHeader">
128+
<property name="text">
129+
<string>Show header</string>
130+
</property>
131+
</widget>
132+
</item>
133+
<item row="0" column="1">
134+
<widget class="QPushButton" name="mButtonEditHeader">
135+
<property name="text">
136+
<string>Edit</string>
137+
</property>
138+
</widget>
139+
</item>
140+
<item row="1" column="0">
141+
<widget class="QCheckBox" name="mCheckShowFooter">
142+
<property name="text">
143+
<string>Show footer</string>
144+
</property>
145+
</widget>
146+
</item>
147+
<item row="1" column="2">
148+
<spacer name="horizontalSpacer_2">
149+
<property name="orientation">
150+
<enum>Qt::Horizontal</enum>
151+
</property>
152+
<property name="sizeHint" stdset="0">
153+
<size>
154+
<width>40</width>
155+
<height>20</height>
156+
</size>
157+
</property>
158+
</spacer>
159+
</item>
160+
</layout>
161+
</item>
162+
<item>
163+
<widget class="QFrame" name="mSettingsFrame">
164+
<property name="frameShape">
165+
<enum>QFrame::NoFrame</enum>
166+
</property>
167+
<property name="frameShadow">
168+
<enum>QFrame::Raised</enum>
169+
</property>
170+
</widget>
171+
</item>
172+
</layout>
173+
</widget>
174+
</widget>
143175
</item>
144176
</layout>
145177
</widget>
146178
<resources>
147179
<include location="../../../images/images.qrc"/>
180+
<include location="../../../images/images.qrc"/>
181+
<include location="../../../images/images.qrc"/>
182+
<include location="../../../images/images.qrc"/>
183+
<include location="../../../images/images.qrc"/>
184+
<include location="../../../images/images.qrc"/>
185+
<include location="../../../images/images.qrc"/>
186+
<include location="../../../images/images.qrc"/>
187+
<include location="../../../images/images.qrc"/>
188+
<include location="../../../images/images.qrc"/>
189+
<include location="../../../images/images.qrc"/>
190+
<include location="../../../images/images.qrc"/>
191+
<include location="../../../images/images.qrc"/>
192+
<include location="../../../images/images.qrc"/>
193+
<include location="../../../images/images.qrc"/>
194+
<include location="../../../images/images.qrc"/>
195+
<include location="../../../images/images.qrc"/>
196+
<include location="../../../images/images.qrc"/>
197+
<include location="../../../images/images.qrc"/>
198+
<include location="../../../images/images.qrc"/>
199+
<include location="../../../images/images.qrc"/>
200+
<include location="../../../images/images.qrc"/>
201+
<include location="../../../images/images.qrc"/>
202+
<include location="../../../images/images.qrc"/>
203+
<include location="../../../images/images.qrc"/>
204+
<include location="../../../images/images.qrc"/>
205+
<include location="../../../images/images.qrc"/>
148206
</resources>
149207
<connections/>
150208
</ui>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsReportWidgetFieldGroupSectionBase</class>
4+
<widget class="QWidget" name="QgsReportWidgetFieldGroupSectionBase">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>705</width>
10+
<height>231</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Layout Manager</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<layout class="QGridLayout" name="gridLayout">
19+
<item row="3" column="0">
20+
<widget class="QLabel" name="label">
21+
<property name="text">
22+
<string>Section body</string>
23+
</property>
24+
</widget>
25+
</item>
26+
<item row="3" column="1">
27+
<widget class="QPushButton" name="mButtonEditBody">
28+
<property name="text">
29+
<string>Edit</string>
30+
</property>
31+
</widget>
32+
</item>
33+
<item row="0" column="0">
34+
<widget class="QLabel" name="label_2">
35+
<property name="text">
36+
<string>Layer</string>
37+
</property>
38+
</widget>
39+
</item>
40+
<item row="0" column="1" colspan="2">
41+
<widget class="QgsMapLayerComboBox" name="mLayerComboBox"/>
42+
</item>
43+
<item row="1" column="0">
44+
<widget class="QLabel" name="label_3">
45+
<property name="text">
46+
<string>Field</string>
47+
</property>
48+
</widget>
49+
</item>
50+
<item row="1" column="1" colspan="2">
51+
<widget class="QgsFieldComboBox" name="mFieldComboBox"/>
52+
</item>
53+
<item row="3" column="2">
54+
<spacer name="horizontalSpacer_2">
55+
<property name="orientation">
56+
<enum>Qt::Horizontal</enum>
57+
</property>
58+
<property name="sizeHint" stdset="0">
59+
<size>
60+
<width>40</width>
61+
<height>20</height>
62+
</size>
63+
</property>
64+
</spacer>
65+
</item>
66+
<item row="2" column="1" colspan="2">
67+
<widget class="QCheckBox" name="mSortAscendingCheckBox">
68+
<property name="text">
69+
<string>Sort ascending</string>
70+
</property>
71+
</widget>
72+
</item>
73+
</layout>
74+
</item>
75+
<item>
76+
<spacer name="verticalSpacer">
77+
<property name="orientation">
78+
<enum>Qt::Vertical</enum>
79+
</property>
80+
<property name="sizeHint" stdset="0">
81+
<size>
82+
<width>20</width>
83+
<height>40</height>
84+
</size>
85+
</property>
86+
</spacer>
87+
</item>
88+
</layout>
89+
</widget>
90+
<customwidgets>
91+
<customwidget>
92+
<class>QgsMapLayerComboBox</class>
93+
<extends>QComboBox</extends>
94+
<header>qgsmaplayercombobox.h</header>
95+
</customwidget>
96+
<customwidget>
97+
<class>QgsFieldComboBox</class>
98+
<extends>QComboBox</extends>
99+
<header>qgsfieldcombobox.h</header>
100+
</customwidget>
101+
</customwidgets>
102+
<resources>
103+
<include location="../../../images/images.qrc"/>
104+
</resources>
105+
<connections/>
106+
</ui>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsReportWidgetLayoutSectionBase</class>
4+
<widget class="QWidget" name="QgsReportWidgetLayoutSectionBase">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>723</width>
10+
<height>89</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Layout Manager</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<layout class="QGridLayout" name="gridLayout">
19+
<item row="0" column="0">
20+
<widget class="QLabel" name="label">
21+
<property name="text">
22+
<string>Section body</string>
23+
</property>
24+
</widget>
25+
</item>
26+
<item row="0" column="1">
27+
<widget class="QPushButton" name="mButtonEditBody">
28+
<property name="text">
29+
<string>Edit</string>
30+
</property>
31+
</widget>
32+
</item>
33+
<item row="0" column="2">
34+
<spacer name="horizontalSpacer_2">
35+
<property name="orientation">
36+
<enum>Qt::Horizontal</enum>
37+
</property>
38+
<property name="sizeHint" stdset="0">
39+
<size>
40+
<width>40</width>
41+
<height>20</height>
42+
</size>
43+
</property>
44+
</spacer>
45+
</item>
46+
</layout>
47+
</item>
48+
<item>
49+
<spacer name="verticalSpacer">
50+
<property name="orientation">
51+
<enum>Qt::Vertical</enum>
52+
</property>
53+
<property name="sizeHint" stdset="0">
54+
<size>
55+
<width>20</width>
56+
<height>40</height>
57+
</size>
58+
</property>
59+
</spacer>
60+
</item>
61+
</layout>
62+
</widget>
63+
<resources/>
64+
<connections/>
65+
</ui>

0 commit comments

Comments
 (0)
Please sign in to comment.