Skip to content
Permalink
Browse files

Added a bunch of widgets and dialogs for new symbology.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@10772 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed May 12, 2009
1 parent edb42a1 commit e17777be040f43816eb76bf12fcc4c632767850c
@@ -1,5 +1,15 @@

SET(QGIS_GUI_SRCS

symbology-ng/qgsbrushstylecombobox.cpp
symbology-ng/qgspenstylecombobox.cpp
symbology-ng/qgssymbollayerv2widget.cpp
symbology-ng/qgssymbolv2propertiesdialog.cpp
symbology-ng/qgsrendererv2propertiesdialog.cpp
symbology-ng/qgsstylev2managerdialog.cpp
symbology-ng/qgssymbolv2selectordialog.cpp
symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp

qgisgui.cpp
qgisinterface.cpp
qgscolorbutton.cpp
@@ -29,6 +39,14 @@ qgsvertexmarker.cpp
)

SET(QGIS_GUI_MOC_HDRS

symbology-ng/qgssymbollayerv2widget.h
symbology-ng/qgssymbolv2propertiesdialog.h
symbology-ng/qgsrendererv2propertiesdialog.h
symbology-ng/qgsstylev2managerdialog.h
symbology-ng/qgssymbolv2selectordialog.h
symbology-ng/qgsvectorgradientcolorrampv2dialog.h

qgscomposerview.h
qgsdetaileditemdelegate.h
qgsdetaileditemwidget.h
@@ -45,8 +63,8 @@ qgsquickprint.h

QT4_WRAP_CPP(QGIS_GUI_MOC_SRCS ${QGIS_GUI_MOC_HDRS})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ../core
../core/composer ../core/raster ../core/renderer ../core/symbology
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/symbology-ng ../core
../core/composer ../core/raster ../core/renderer ../core/symbology ../core/symbology-ng
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../ui
${GEOS_INCLUDE_DIR}
@@ -0,0 +1,71 @@

#include "qgsbrushstylecombobox.h"

#include <QList>
#include <QPair>

#include <QBrush>
#include <QPainter>
#include <QPen>

QgsBrushStyleComboBox::QgsBrushStyleComboBox(QWidget* parent)
: QComboBox(parent)
{
QList < QPair<Qt::BrushStyle, QString> > styles;
styles << qMakePair(Qt::SolidPattern, QString("Solid"))
<< qMakePair(Qt::HorPattern, QString("Horizontal"))
<< qMakePair(Qt::VerPattern, QString("Vertical"))
<< qMakePair(Qt::CrossPattern, QString("Cross"))
<< qMakePair(Qt::BDiagPattern, QString("BDiagonal"))
<< qMakePair(Qt::FDiagPattern, QString("FDiagonal"))
<< qMakePair(Qt::DiagCrossPattern, QString("Diagonal X"))
<< qMakePair(Qt::Dense1Pattern, QString("Dense 1"))
<< qMakePair(Qt::Dense2Pattern, QString("Dense 2"))
<< qMakePair(Qt::Dense3Pattern, QString("Dense 3"))
<< qMakePair(Qt::Dense4Pattern, QString("Dense 4"))
<< qMakePair(Qt::Dense5Pattern, QString("Dense 5"))
<< qMakePair(Qt::Dense6Pattern, QString("Dense 6"))
<< qMakePair(Qt::Dense7Pattern, QString("Dense 7"))
<< qMakePair(Qt::NoBrush, QString("No Brush"));

setIconSize(QSize(32,16));

for (int i = 0; i < styles.count(); i++)
{
Qt::BrushStyle style = styles.at(i).first;
QString name = styles.at(i).second;
addItem(iconForBrush(style), name, QVariant(style));
}

setCurrentIndex(1);

}


Qt::BrushStyle QgsBrushStyleComboBox::brushStyle() const
{
return (Qt::BrushStyle) itemData(currentIndex()).toInt();
}

void QgsBrushStyleComboBox::setBrushStyle(Qt::BrushStyle style)
{
int idx = findData(QVariant(style));
setCurrentIndex( idx == -1 ? 0 : idx );
}

QIcon QgsBrushStyleComboBox::iconForBrush(Qt::BrushStyle style)
{
QPixmap pix(iconSize());
QPainter p;
pix.fill(Qt::transparent);

p.begin(&pix);
QBrush brush(QColor(100,100,100), style);
p.setBrush(brush);
QPen pen(Qt::NoPen);
p.setPen(pen);
p.drawRect(QRect(QPoint(0,0),iconSize()));
p.end();

return QIcon(pix);
}
@@ -0,0 +1,21 @@

#ifndef QGSBRUSHSTYLECOMBOBOX_H
#define QGSBRUSHSTYLECOMBOBOX_H

#include <QComboBox>

class QgsBrushStyleComboBox : public QComboBox
{
public:
QgsBrushStyleComboBox(QWidget* parent = NULL);

Qt::BrushStyle brushStyle() const;

void setBrushStyle(Qt::BrushStyle style);

protected:
QIcon iconForBrush(Qt::BrushStyle style);

};

#endif
@@ -0,0 +1,56 @@

#include "qgspenstylecombobox.h"

#include <QList>
#include <QPair>

#include <QPainter>
#include <QPen>

QgsPenStyleComboBox::QgsPenStyleComboBox(QWidget* parent)
: QComboBox(parent)
{
QList < QPair<Qt::PenStyle, QString> > styles;
styles << qMakePair(Qt::SolidLine, QString("Solid Line"))
<< qMakePair(Qt::DashLine, QString("Dash Line"))
<< qMakePair(Qt::DotLine, QString("Dot Line"))
<< qMakePair(Qt::DashDotLine, QString("Dash Dot Line"))
<< qMakePair(Qt::DashDotDotLine, QString("Dash Dot Dot Line"));

setIconSize(QSize(32,12));

for (int i = 0; i < styles.count(); i++)
{
Qt::PenStyle style = styles.at(i).first;
QString name = styles.at(i).second;
addItem(iconForPen(style), name, QVariant(style));
}
}

Qt::PenStyle QgsPenStyleComboBox::penStyle() const
{
return (Qt::PenStyle) itemData(currentIndex()).toInt();
}

void QgsPenStyleComboBox::setPenStyle(Qt::PenStyle style)
{
int idx = findData(QVariant(style));
setCurrentIndex( idx == -1 ? 0 : idx );
}

QIcon QgsPenStyleComboBox::iconForPen(Qt::PenStyle style)
{
QPixmap pix(iconSize());
QPainter p;
pix.fill(Qt::transparent);

p.begin(&pix);
QPen pen(style);
pen.setWidth(2);
p.setPen(pen);
double mid = iconSize().height() / 2.0;
p.drawLine(0,mid,iconSize().width(),mid);
p.end();

return QIcon(pix);
}
@@ -0,0 +1,21 @@

#ifndef QGSPENSTYLECOMBOBOX_H
#define QGSPENSTYLECOMBOBOX_H

#include <QComboBox>

class QgsPenStyleComboBox : public QComboBox
{
public:
QgsPenStyleComboBox(QWidget* parent = NULL);

Qt::PenStyle penStyle() const;

void setPenStyle(Qt::PenStyle style);

protected:
QIcon iconForPen(Qt::PenStyle style);

};

#endif

0 comments on commit e17777b

Please sign in to comment.
You can’t perform that action at this time.