mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
sneak in color edit widget to accompany data defined symbology
This commit is contained in:
parent
1bfb7ed2cd
commit
d971a69329
@ -338,6 +338,10 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
|
||||
case QgsVectorLayer::Webview:
|
||||
setPage( 15 );
|
||||
break;
|
||||
|
||||
case QgsVectorLayer::Color:
|
||||
setPage( 16 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,6 +528,7 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
|
||||
case QgsVectorLayer::TextEdit:
|
||||
case QgsVectorLayer::UuidGenerator:
|
||||
case QgsVectorLayer::Webview:
|
||||
case QgsVectorLayer::Color:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -699,6 +704,9 @@ void QgsAttributeTypeDialog::accept()
|
||||
case 15:
|
||||
mEditType = QgsVectorLayer::Webview;
|
||||
break;
|
||||
case 16:
|
||||
mEditType = QgsVectorLayer::Color;
|
||||
break;
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
|
@ -535,6 +535,7 @@ void QgsFieldsProperties::attributeTypeDialog()
|
||||
case QgsVectorLayer::Hidden:
|
||||
case QgsVectorLayer::UuidGenerator:
|
||||
case QgsVectorLayer::Webview:
|
||||
case QgsVectorLayer::Color:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -746,6 +747,7 @@ void QgsFieldsProperties::setupEditTypes()
|
||||
editTypeMap.insert( QgsVectorLayer::UuidGenerator, tr( "UUID generator" ) );
|
||||
editTypeMap.insert( QgsVectorLayer::Photo, tr( "Photo" ) );
|
||||
editTypeMap.insert( QgsVectorLayer::Webview, tr( "Webview" ) );
|
||||
editTypeMap.insert( QgsVectorLayer::Color, tr( "Color" ) );
|
||||
}
|
||||
|
||||
QString QgsFieldsProperties::editTypeButtonText( QgsVectorLayer::EditType type )
|
||||
@ -891,6 +893,7 @@ void QgsFieldsProperties::apply()
|
||||
case QgsVectorLayer::TextEdit:
|
||||
case QgsVectorLayer::UuidGenerator:
|
||||
case QgsVectorLayer::Webview:
|
||||
case QgsVectorLayer::Color:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2425,6 +2425,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
|
||||
case UniqueValuesEditable:
|
||||
case UuidGenerator:
|
||||
case Webview:
|
||||
case Color:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2750,6 +2751,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
|
||||
case Immutable:
|
||||
case UuidGenerator:
|
||||
case Webview:
|
||||
case Color:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -179,6 +179,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
UuidGenerator, /* uuid generator - readonly and automatically intialized @added in 1.9 */
|
||||
Photo, /* phote widget @added in 1.9 */
|
||||
Webview, /* webview widget @added in 1.9 */
|
||||
Color, /* color @added in 1.9 */
|
||||
};
|
||||
|
||||
struct RangeData
|
||||
|
@ -2134,7 +2134,7 @@ const QgsExpression* QgsPointPatternFillSymbolLayer::dataDefinedProperty( const
|
||||
QString QgsPointPatternFillSymbolLayer::dataDefinedPropertyString( const QString& property ) const
|
||||
{
|
||||
const QgsExpression* ex = dataDefinedProperty( property );
|
||||
return ( ex ? ex->dump() : QString() );
|
||||
return ex ? ex->dump() : QString();
|
||||
}
|
||||
|
||||
void QgsPointPatternFillSymbolLayer::setDataDefinedProperty( const QString& property, const QString& expressionString )
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <qgslogger.h>
|
||||
#include <qgsexpression.h>
|
||||
#include <qgsfilterlineedit.h>
|
||||
#include <qgscolorbutton.h>
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QPushButton>
|
||||
@ -187,6 +188,42 @@ void QgsAttributeEditor::updateUrl()
|
||||
le->blockSignals( false );
|
||||
}
|
||||
|
||||
void QgsAttributeEditor::updateColor()
|
||||
{
|
||||
QString color;
|
||||
QgsColorButton *scb = qobject_cast<QgsColorButton *>( sender() );
|
||||
QLineEdit *sle = qobject_cast<QLineEdit *>( sender() );
|
||||
|
||||
if ( !scb && !sle )
|
||||
return;
|
||||
|
||||
QWidget *hbox = qobject_cast<QWidget *>( sender()->parent() );
|
||||
if ( !hbox )
|
||||
return;
|
||||
|
||||
QgsColorButton *cb = hbox->findChild<QgsColorButton *>();
|
||||
if ( !cb )
|
||||
return;
|
||||
|
||||
QLineEdit *le = hbox->findChild<QLineEdit *>();
|
||||
if ( !le )
|
||||
return;
|
||||
|
||||
if ( scb )
|
||||
{
|
||||
le->blockSignals( true );
|
||||
le->setText( scb->color().name() );
|
||||
le->blockSignals( false );
|
||||
}
|
||||
|
||||
if ( sle )
|
||||
{
|
||||
cb->blockSignals( true );
|
||||
cb->setColor( QColor( sle->text() ) );
|
||||
cb->blockSignals( false );
|
||||
}
|
||||
}
|
||||
|
||||
QComboBox *QgsAttributeEditor::comboBox( QWidget *editor, QWidget *parent )
|
||||
{
|
||||
QComboBox *cb = 0;
|
||||
@ -672,6 +709,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
|
||||
case QgsVectorLayer::Calendar:
|
||||
case QgsVectorLayer::Photo:
|
||||
case QgsVectorLayer::Webview:
|
||||
case QgsVectorLayer::Color:
|
||||
{
|
||||
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
|
||||
if ( cw )
|
||||
@ -694,6 +732,13 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
|
||||
break;
|
||||
}
|
||||
|
||||
QgsColorButton *cb = qobject_cast<QgsColorButton *>( editor );
|
||||
if ( cb )
|
||||
{
|
||||
myWidget = cb;
|
||||
break;
|
||||
}
|
||||
|
||||
QPushButton *pb = 0;
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>( editor );
|
||||
if ( le )
|
||||
@ -709,10 +754,24 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
|
||||
else
|
||||
{
|
||||
le = new QgsFilterLineEdit();
|
||||
if ( editType == QgsVectorLayer::FileName || editType == QgsVectorLayer::Photo )
|
||||
pb = new QPushButton( tr( "..." ) );
|
||||
else
|
||||
pb = new QPushButton( tr( "<" ) );
|
||||
switch ( editType )
|
||||
{
|
||||
case QgsVectorLayer::FileName:
|
||||
case QgsVectorLayer::Photo:
|
||||
pb = new QPushButton( tr( "..." ) );
|
||||
break;
|
||||
|
||||
case QgsVectorLayer::Webview:
|
||||
pb = new QPushButton( tr( "<" ) );
|
||||
break;
|
||||
|
||||
case QgsVectorLayer::Color:
|
||||
pb = new QgsColorButton();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int row = 0;
|
||||
QGridLayout *layout = new QGridLayout();
|
||||
@ -746,6 +805,8 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
|
||||
connect( le, SIGNAL( textChanged( const QString & ) ), new QgsAttributeEditor( le, vl, idx ), SLOT( loadUrl( const QString & ) ) );
|
||||
if ( lw )
|
||||
connect( le, SIGNAL( textChanged( const QString & ) ), new QgsAttributeEditor( le, vl, idx ), SLOT( loadPixmap( const QString & ) ) );
|
||||
if ( editType == QgsVectorLayer::Color )
|
||||
connect( le, SIGNAL( textChanged( const QString & ) ), new QgsAttributeEditor( le ), SLOT( updateColor() ) );
|
||||
}
|
||||
|
||||
if ( pb )
|
||||
@ -756,6 +817,8 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
|
||||
connect( pb, SIGNAL( clicked() ), new QgsAttributeEditor( pb ), SLOT( updateUrl() ) );
|
||||
if ( editType == QgsVectorLayer::Calendar )
|
||||
connect( pb, SIGNAL( clicked() ), new QgsAttributeEditor( pb ), SLOT( selectDate() ) );
|
||||
if ( editType == QgsVectorLayer::Color )
|
||||
connect( pb, SIGNAL( colorChanged( const QColor & ) ), new QgsAttributeEditor( pb ), SLOT( updateColor() ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1135,6 +1198,7 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
|
||||
case QgsVectorLayer::Calendar:
|
||||
case QgsVectorLayer::Photo:
|
||||
case QgsVectorLayer::Webview:
|
||||
case QgsVectorLayer::Color:
|
||||
{
|
||||
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
|
||||
if ( cw )
|
||||
@ -1152,8 +1216,12 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
|
||||
|
||||
QLabel *lw = qobject_cast<QLabel *>( editor );
|
||||
if ( lw )
|
||||
{
|
||||
break;
|
||||
|
||||
QgsColorButton *cb = qobject_cast<QgsColorButton *>( editor );
|
||||
if ( cb )
|
||||
{
|
||||
cb->setColor( QColor( value.toString() ) );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1165,9 +1233,7 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
|
||||
fle = qobject_cast<QgsFilterLineEdit *>( le );
|
||||
}
|
||||
if ( !le )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( fle && !( myFieldType == QVariant::Int || myFieldType == QVariant::Double || myFieldType == QVariant::LongLong || myFieldType == QVariant::Date ) )
|
||||
{
|
||||
|
@ -85,6 +85,7 @@ class GUI_EXPORT QgsAttributeEditor : public QObject
|
||||
void loadUrl( const QString & );
|
||||
void loadPixmap( const QString & );
|
||||
void updateUrl();
|
||||
void updateColor();
|
||||
|
||||
private:
|
||||
QgsVectorLayer *mLayer;
|
||||
|
@ -140,7 +140,7 @@ void QgsColorButton::setColor( const QColor &color )
|
||||
{
|
||||
// TODO: May be beneficial to have the option to set color without emitting this signal.
|
||||
// Now done by blockSignals( bool ) where button is used
|
||||
emit( colorChanged( mColor ) );
|
||||
emit colorChanged( mColor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,11 @@
|
||||
<string>Webview</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@ -127,7 +132,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>15</number>
|
||||
<number>16</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="lineEditPage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_1">
|
||||
@ -863,6 +868,30 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Field contains a color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_14">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user