8 changes: 8 additions & 0 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3049,6 +3049,7 @@ QgsPalLabeling::QgsPalLabeling()
mShowingCandidates = false;
mShowingShadowRects = false;
mShowingAllLabels = false;
mShowingPartialsLabels = p.getShowPartial();

mLabelSearchTree = new QgsLabelSearchTree();
}
Expand Down Expand Up @@ -3444,6 +3445,8 @@ void QgsPalLabeling::init( QgsMapRenderer* mr )
mPal->setLineP( mCandLine );
mPal->setPolyP( mCandPolygon );

mPal->setShowPartial( mShowingPartialsLabels );

clearActiveLayers(); // free any previous QgsDataDefined objects
mActiveDiagramLayers.clear();
}
Expand Down Expand Up @@ -4812,6 +4815,8 @@ void QgsPalLabeling::loadEngineSettings()
"PAL", "/ShowingShadowRects", false, &saved );
mShowingAllLabels = QgsProject::instance()->readBoolEntry(
"PAL", "/ShowingAllLabels", false, &saved );
mShowingPartialsLabels = QgsProject::instance()->readBoolEntry(
"PAL", "/ShowingPartialsLabels", p.getShowPartial(), &saved );
mSavedWithProject = saved;
}

Expand All @@ -4824,6 +4829,7 @@ void QgsPalLabeling::saveEngineSettings()
QgsProject::instance()->writeEntry( "PAL", "/ShowingCandidates", mShowingCandidates );
QgsProject::instance()->writeEntry( "PAL", "/ShowingShadowRects", mShowingShadowRects );
QgsProject::instance()->writeEntry( "PAL", "/ShowingAllLabels", mShowingAllLabels );
QgsProject::instance()->writeEntry( "PAL", "/ShowingPartialsLabels", mShowingPartialsLabels );
mSavedWithProject = true;
}

Expand All @@ -4836,6 +4842,7 @@ void QgsPalLabeling::clearEngineSettings()
QgsProject::instance()->removeEntry( "PAL", "/ShowingCandidates" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingShadowRects" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingAllLabels" );
QgsProject::instance()->removeEntry( "PAL", "/ShowingPartialsLabels" );
mSavedWithProject = false;
}

Expand All @@ -4845,5 +4852,6 @@ QgsLabelingEngineInterface* QgsPalLabeling::clone()
lbl->mShowingAllLabels = mShowingAllLabels;
lbl->mShowingCandidates = mShowingCandidates;
lbl->mShowingShadowRects = mShowingShadowRects;
lbl->mShowingPartialsLabels = mShowingPartialsLabels;
return lbl;
}
4 changes: 4 additions & 0 deletions src/core/qgspallabeling.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
bool isShowingAllLabels() const { return mShowingAllLabels; }
void setShowingAllLabels( bool showing ) { mShowingAllLabels = showing; }

bool isShowingPartialsLabels() const { return mShowingPartialsLabels; }
void setShowingPartialsLabels( bool showing ) { mShowingPartialsLabels = showing; }

// implemented methods from labeling engine interface

//! called when we're going to start with rendering
Expand Down Expand Up @@ -781,6 +784,7 @@ class CORE_EXPORT QgsPalLabeling : public QgsLabelingEngineInterface
bool mShowingAllLabels; // whether to avoid collisions or not
bool mSavedWithProject; // whether engine settings have been read from project file
bool mShowingShadowRects; // whether to show debugging rectangles for drop shadows
bool mShowingPartialsLabels; // whether to avoid partials labels or not

QgsLabelSearchTree* mLabelSearchTree;
};
Expand Down
2 changes: 2 additions & 0 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,6 @@ void QgsAttributeTableModel::prefetchColumnData( int column )
void QgsAttributeTableModel::setRequest( const QgsFeatureRequest& request )
{
mFeatureRequest = request;
if( layer() && !layer()->hasGeometryType() )
mFeatureRequest.setFlags( mFeatureRequest.flags() | QgsFeatureRequest::NoGeometry );
}
20 changes: 17 additions & 3 deletions src/gui/qgshighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "qgshighlight.h"
#include "qgsgeometry.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
#include "qgsmaprenderer.h"
#include "qgscoordinatetransform.h"
#include "qgsvectorlayer.h"
Expand All @@ -25,14 +26,27 @@
\brief The QgsHighlight class provides a transparent overlay widget
for highlightng features on the map.
*/
QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer )
QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsMapLayer *layer )
: QgsMapCanvasItem( mapCanvas )
, mLayer( layer )
{
mGeometry = geom ? new QgsGeometry( *geom ) : 0;
if ( mapCanvas->mapRenderer()->hasCrsTransformEnabled() )
init();
}

QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer )
: QgsMapCanvasItem( mapCanvas )
, mLayer( static_cast<QgsMapLayer *>( layer ) )
{
mGeometry = geom ? new QgsGeometry( *geom ) : 0;
init();
}

void QgsHighlight::init()
{
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
QgsCoordinateTransform transform( mLayer->crs(), mapCanvas->mapRenderer()->destinationCrs() );
QgsCoordinateTransform transform( mLayer->crs(), mMapCanvas->mapRenderer()->destinationCrs() );
mGeometry->transform( transform );
}
updateRect();
Expand Down
5 changes: 4 additions & 1 deletion src/gui/qgshighlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
#include <QPainter>
#include <QPainterPath>

class QgsMapLayer;
class QgsVectorLayer;

/** A class for highlight features on the map.
*/
class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
{
public:
QgsHighlight( QgsMapCanvas *mapCanvas, QgsGeometry *geom, QgsMapLayer *layer );
QgsHighlight( QgsMapCanvas *mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer );
~QgsHighlight();

Expand All @@ -43,6 +45,7 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
void updateRect();

private:
void init();
void paintPoint( QPainter *p, QgsPoint point );
void paintLine( QPainter *p, QgsPolyline line );
void paintPolygon( QPainter *p, QgsPolygon polygon );
Expand All @@ -52,7 +55,7 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
QBrush mBrush;
QPen mPen;
QgsGeometry *mGeometry;
QgsVectorLayer *mLayer;
QgsMapLayer *mLayer;
};

#endif
7 changes: 7 additions & 0 deletions src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3661,5 +3661,12 @@ void QgsProjectParser::loadLabelSettings( QgsLabelingEngineInterface* lbl )
{
pal->setShowingAllLabels( showAllLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}

//mShowingPartialsLabels
QDomElement showPartialsLabelsElem = palElem.firstChildElement( "ShowingPartialsLabels" );
if ( !showPartialsLabelsElem.isNull() )
{
pal->setShowingPartialsLabels( showPartialsLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}
}
}
3 changes: 3 additions & 0 deletions src/providers/spatialite/qgsspatialitefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ bool QgsSpatiaLiteFeatureIterator::close()
bool QgsSpatiaLiteFeatureIterator::prepareStatement( QString whereClause )
{
if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) && P->mGeometryColumn.isNull() )
{
QgsMessageLog::logMessage( QObject::tr( "Trying to fetch geometry on a layer without geometry." ), QObject::tr( "SpatiaLite" ) );
return false;
}

try
{
Expand Down
23 changes: 15 additions & 8 deletions src/ui/qgsengineconfigdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Automated Placement Engine</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
Expand Down Expand Up @@ -215,7 +215,7 @@
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="1" column="0">
<item row="2" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -231,7 +231,7 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="chkShowAllLabels">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
Expand All @@ -244,7 +244,7 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="mSaveWithProjectChkBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
Expand All @@ -257,14 +257,14 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="chkShowCandidates">
<property name="text">
<string>Show candidates (for debugging)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
Expand All @@ -277,7 +277,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="2" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -290,13 +290,20 @@
</property>
</spacer>
</item>
<item row="3" column="0" colspan="3">
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="mShadowDebugRectChkBox">
<property name="text">
<string>Show shadow rectangles (for debugging)</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="chkShowPartialsLabels">
<property name="text">
<string>Show partials labels</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
29 changes: 26 additions & 3 deletions tests/src/python/test_qgspallabeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,18 @@ def setUpClass(cls):
cls._MapRenderer.setDestinationCrs(cls._CRS)
# use platform's native logical output dpi for QgsMapRenderer on launch

cls._Pal = QgsPalLabeling()
cls._MapRenderer.setLabelingEngine(cls._Pal)
cls._PalEngine = cls._MapRenderer.labelingEngine()
cls.setDefaultEngineSettings()
msg = ('\nCould not initialize PAL labeling engine, '
'SKIPPING TEST SUITE')
assert cls._PalEngine, msg

@classmethod
def setDefaultEngineSettings(cls):
"""Restore default settings for pal labelling"""
cls._Pal = QgsPalLabeling()
cls._MapRenderer.setLabelingEngine(cls._Pal)
cls._PalEngine = cls._MapRenderer.labelingEngine()

@classmethod
def tearDownClass(cls):
"""Run after all tests"""
Expand Down Expand Up @@ -294,6 +299,24 @@ def test_write_read_settings(self):

msg = '\nLayer settings read not same as settings written'
self.assertDictEqual(lyr1dict, lyr2dict, msg)

def test_default_partials_labels_enabled(self):
# Verify ShowingPartialsLabels is enabled for PAL by default
pal = QgsPalLabeling()
self.assertTrue(pal.isShowingPartialsLabels())

def test_partials_labels_activate(self):
pal = QgsPalLabeling()
# Enable partials labels
pal.setShowingPartialsLabels(True)
self.assertTrue(pal.isShowingPartialsLabels())

def test_partials_labels_deactivate(self):
pal = QgsPalLabeling()
# Disable partials labels
pal.setShowingPartialsLabels(False)
self.assertFalse(pal.isShowingPartialsLabels())



def runSuite(module, tests):
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgspallabeling_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def setUpClass(cls):
def setUp(self):
"""Run before each test."""
self.configTest('pal_canvas', 'sp')
TestQgsPalLabeling.setDefaultEngineSettings()
self.lyr = self.defaultSettings()

def tearDown(self):
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgspallabeling_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def setUpClass(cls):
def setUp(self):
"""Run before each test."""
self.configTest('pal_server', 'sp')
TestQgsPalLabeling.setDefaultEngineSettings()
self.lyr = self.defaultSettings()
self.params = self.defaultWmsParams('point')
self._TestImage = ''
Expand Down
20 changes: 20 additions & 0 deletions tests/src/python/test_qgspallabeling_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ def test_text_color(self):
# Label color change
self.lyr.textColor = Qt.blue
self.checkTest()

def test_partials_labels_enabled(self):
# Set Big font size
font = QFont(self._TestFont)
font.setPointSizeF(90)
self.lyr.textFont = font
# Enable partials labels
self._PalEngine.setShowingPartialsLabels(True)
# Check
self.checkTest()

def test_partials_labels_disabled(self):
# Set Big font size
font = QFont(self._TestFont)
font.setPointSizeF(90)
self.lyr.textFont = font
# Disable partials labels
self._PalEngine.setShowingPartialsLabels(False)
# Check
self.checkTest()


if __name__ == '__main__':
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.