Remove unused QgsLabelPreview class

This commit is contained in:
Nyall Dawson 2016-10-04 12:04:34 +10:00
parent 0b88de2487
commit 25b3c63370
3 changed files with 0 additions and 140 deletions

View File

@ -44,7 +44,6 @@ SET(QGIS_APP_SRCS
qgslabelengineconfigdialog.cpp
qgslabelinggui.cpp
qgslabelingwidget.cpp
qgslabelpreview.cpp
qgsloadstylefromdbdialog.cpp
qgsmaplayerstyleguiutils.cpp
qgsrulebasedlabelingwidget.cpp
@ -222,7 +221,6 @@ SET (QGIS_APP_MOC_HDRS
qgsidentifyresultsdialog.h
qgslabelengineconfigdialog.h
qgslabelinggui.h
qgslabelpreview.h
qgslabelingwidget.h
qgslabelpropertydialog.h
qgsloadstylefromdbdialog.h

View File

@ -1,89 +0,0 @@
/***************************************************************************
qgslabelpreview.cpp
---------------------
begin : May 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslabelpreview.h"
#include <QPainter>
#include <QFontMetrics>
#include "qgspallabeling.h"
QgsLabelPreview::QgsLabelPreview( QWidget* parent )
: QLabel( parent )
{
// construct a device-based render context
QgsMapToPixel newCoordXForm( 1 );
mContext.setMapToPixel( newCoordXForm );
}
void QgsLabelPreview::setTextColor( const QColor& color )
{
mTextColor = color;
update();
}
void QgsLabelPreview::setBuffer( double size, const QColor& color, Qt::PenJoinStyle joinStyle, bool noFill )
{
QgsTextBufferSettings buffer = mFormat.buffer();
buffer.setSize( size * 88 / 25.4 ); //assume standard dpi for preview;
buffer.setSizeUnit( QgsUnitTypes::RenderMillimeters );
buffer.setColor( color );
buffer.setJoinStyle( joinStyle );
buffer.setFillBufferInterior( !noFill );
mFormat.setBuffer( buffer );
mFormat.setFont( font() );
update();
}
void QgsLabelPreview::paintEvent( QPaintEvent *e )
{
Q_UNUSED( e );
QPainter p( this );
// TODO: draw all label components when this preview is an actual map canvas
// for now, only preview label's text and buffer
mFormat.shadow().setEnabled( false );
p.setRenderHint( QPainter::Antialiasing );
p.setFont( font() );
QFontMetrics fm( font() );
// otherwise thin buffers don't look like those on canvas
if ( mFormat.buffer().size() != 0 && mFormat.buffer().size() < 1 )
mFormat.buffer().setSize( 1 );
double xtrans = 0;
if ( mFormat.buffer().size() != 0 )
xtrans = mFormat.buffer().size() / 4;
p.translate( xtrans, fm.ascent() + 4 );
if ( mFormat.buffer().size() != 0 )
{
mContext.setPainter( &p );
QgsTextRenderer::Component component;
component.text = text();
QgsTextRenderer::drawBuffer( mContext, component, mFormat );
}
QPainterPath path;
path.addText( 0, 0, font(), text() );
p.setPen( Qt::NoPen );
p.setBrush( mTextColor );
p.drawPath( path );
// p.setPen( mTextColor );
// p.drawText( 0, 0, text() );
}

View File

@ -1,49 +0,0 @@
/***************************************************************************
qgslabelpreview.h
---------------------
begin : May 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLABELPREVIEW_H
#define QGSLABELPREVIEW_H
#include "qgspallabeling.h"
#include <QLabel>
class QgsRenderContext;
class APP_EXPORT QgsLabelPreview : public QLabel
{
Q_OBJECT
public:
QgsLabelPreview( QWidget* parent = nullptr );
void setTextColor( const QColor& color );
void setBuffer( double size, const QColor& color, Qt::PenJoinStyle joinStyle, bool noFill = false );
void setFont( const QFont& f ) { mFont = f; }
QFont font() { return mFont; }
void paintEvent( QPaintEvent* e ) override;
private:
QgsTextFormat mFormat;
QColor mTextColor;
QFont mFont;
// device-based render context
QgsRenderContext mContext;
};
#endif // LABELPREVIEW_H