-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
committed
May 12, 2009
1 parent
edb42a1
commit e17777b
Showing
17 changed files
with
2,533 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.