Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
kyngchaos committed Apr 1, 2013
2 parents e68b322 + d971a69 commit 70fbea3
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
case QgsVectorLayer::Webview:
setPage( 15 );
break;

case QgsVectorLayer::Color:
setPage( 16 );
break;
}
}

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -699,6 +704,9 @@ void QgsAttributeTypeDialog::accept()
case 15:
mEditType = QgsVectorLayer::Webview;
break;
case 16:
mEditType = QgsVectorLayer::Color;
break;
}

QDialog::accept();
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ void QgsFieldsProperties::attributeTypeDialog()
case QgsVectorLayer::Hidden:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
case QgsVectorLayer::Color:
break;
}

Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -891,6 +893,7 @@ void QgsFieldsProperties::apply()
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
case QgsVectorLayer::Color:
break;
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
case UniqueValuesEditable:
case UuidGenerator:
case Webview:
case Color:
break;
}
}
Expand Down Expand Up @@ -2750,6 +2751,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
case Immutable:
case UuidGenerator:
case Webview:
case Color:
break;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
80 changes: 73 additions & 7 deletions src/gui/qgsattributeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <qgslogger.h>
#include <qgsexpression.h>
#include <qgsfilterlineedit.h>
#include <qgscolorbutton.h>

#include <QScrollArea>
#include <QPushButton>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand All @@ -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 )
Expand All @@ -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();
Expand Down Expand Up @@ -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 )
Expand All @@ -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;
Expand Down Expand Up @@ -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 )
Expand All @@ -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;
}

Expand All @@ -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 ) )
{
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsattributeeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgscolorbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}
Expand Down
31 changes: 30 additions & 1 deletion src/ui/qgsattributetypeedit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 70fbea3

Please sign in to comment.