Skip to content
Permalink
Browse files

widget fixes:

- add sip bindings for new widgets (and some other missing pieces)
- change Webview to WebView (like in QWebView)
- use proxy settings also for webview widget
- don't disable Photo and webview widget
- use smooth transformation in photo widget
- show disabled color button with dotted border in actual color instead of
  grayed-out
  • Loading branch information
jef-n committed Apr 2, 2013
1 parent 45b931b commit 6e6b8fe64f9cb4b7e925a9459ecb4d8da497dc02
@@ -11534,8 +11534,8 @@ Fehler war:%2</translation>
</message>
<message>
<location filename="../src/ui/qgsattributetypeedit.ui" line="106"/>
<source>Webview</source>
<translation>Webview</translation>
<source>Web view</source>
<translation>Webansicht</translation>
</message>
<message>
<location filename="../src/ui/qgsattributetypeedit.ui" line="137"/>
@@ -115,6 +115,9 @@ class QgsVectorLayer : QgsMapLayer
DialRange, /* dial range @added in 1.5 */
ValueRelation, /* value map from an table @added in 1.8 */
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
@@ -595,6 +598,15 @@ class QgsVectorLayer : QgsMapLayer
/** delete an attribute field (but does not commit it) */
bool deleteAttribute( int attr );

/**
* Deletes a list of attribute fields (but does not commit it)
*
* @param attrs the indices of the attributes to delete
* @return true if at least one attribute has been deleted
*
*/
bool deleteAttributes( QList<int> attrs );

/** Insert a copy of the given features into the layer (but does not commit it) */
bool addFeatures( QList<QgsFeature> features, bool makeSelected = true );

@@ -679,6 +691,11 @@ class QgsVectorLayer : QgsMapLayer
*/
QString &dateFormat( int idx );

/**access widget size for photo and webview widget
* @note added in 1.9
*/
QSize &widgetSize( int idx );

/**is edit widget editable
* @note added in 1.9
**/
@@ -742,6 +759,10 @@ class QgsVectorLayer : QgsMapLayer
@note public and static from version 1.4 */
static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );

/** Assembles mUpdatedFields considering provider fields, joined fields and added fields
@note added in 1.7 */
void updateFields();

/** Caches joined attributes if required (and not already done)
@note added in 1.7 */
void createJoinCaches();
@@ -335,7 +335,7 @@ void QgsAttributeTypeDialog::setPageForEditType( QgsVectorLayer::EditType editTy
setPage( 14 );
break;

case QgsVectorLayer::Webview:
case QgsVectorLayer::WebView:
setPage( 15 );
break;

@@ -527,7 +527,7 @@ void QgsAttributeTypeDialog::setIndex( int index, QgsVectorLayer::EditType editT
case QgsVectorLayer::Hidden:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
case QgsVectorLayer::WebView:
case QgsVectorLayer::Color:
break;
}
@@ -702,7 +702,7 @@ void QgsAttributeTypeDialog::accept()
mWidgetSize = QSize( sbWidgetWidth->value(), sbWidgetHeight->value() );
break;
case 15:
mEditType = QgsVectorLayer::Webview;
mEditType = QgsVectorLayer::WebView;
break;
case 16:
mEditType = QgsVectorLayer::Color;
@@ -534,7 +534,7 @@ void QgsFieldsProperties::attributeTypeDialog()
case QgsVectorLayer::Immutable:
case QgsVectorLayer::Hidden:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
case QgsVectorLayer::WebView:
case QgsVectorLayer::Color:
break;
}
@@ -746,7 +746,7 @@ void QgsFieldsProperties::setupEditTypes()
editTypeMap.insert( QgsVectorLayer::ValueRelation, tr( "Value relation" ) );
editTypeMap.insert( QgsVectorLayer::UuidGenerator, tr( "UUID generator" ) );
editTypeMap.insert( QgsVectorLayer::Photo, tr( "Photo" ) );
editTypeMap.insert( QgsVectorLayer::Webview, tr( "Webview" ) );
editTypeMap.insert( QgsVectorLayer::WebView, tr( "Web view" ) );
editTypeMap.insert( QgsVectorLayer::Color, tr( "Color" ) );
}

@@ -892,7 +892,7 @@ void QgsFieldsProperties::apply()
case QgsVectorLayer::Hidden:
case QgsVectorLayer::TextEdit:
case QgsVectorLayer::UuidGenerator:
case QgsVectorLayer::Webview:
case QgsVectorLayer::WebView:
case QgsVectorLayer::Color:
break;
}
@@ -2424,7 +2424,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
case UniqueValues:
case UniqueValuesEditable:
case UuidGenerator:
case Webview:
case WebView:
case Color:
break;
}
@@ -2750,7 +2750,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
case Enumeration:
case Immutable:
case UuidGenerator:
case Webview:
case WebView:
case Color:
break;
}
@@ -178,7 +178,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
ValueRelation, /* value map from an table @added in 1.8 */
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 */
WebView, /* webview widget @added in 1.9 */
Color, /* color @added in 1.9 */
};

@@ -41,6 +41,7 @@
#include <QDialog>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QWebView>

int QgsAttributeDialog::smFormCounter = 0;

@@ -202,7 +203,28 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat

if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
{
myWidget->setEnabled( vl->isEditable() && vl->fieldEditable( fldIdx ) );
if ( vl->isEditable() && vl->fieldEditable( fldIdx ) )
{
myWidget->setEnabled( true );
}
else if ( vl->editType( fldIdx ) == QgsVectorLayer::Photo )
{
foreach ( QWidget *w, myWidget->findChildren<QWidget *>() )
{
w->setEnabled( qobject_cast<QLabel *>( w ) ? true : false );
}
}
else if ( vl->editType( fldIdx ) == QgsVectorLayer::WebView )
{
foreach ( QWidget *w, myWidget->findChildren<QWidget *>() )
{
w->setEnabled( qobject_cast<QWebView *>( w ) ? true : false );
}
}
else
{
myWidget->setEnabled( false );
}
}

mypInnerLayout->addWidget( myWidget, index, 1 );
@@ -232,13 +254,34 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat
if ( myWidgets.isEmpty() )
continue;

foreach ( QWidget *w, myWidgets )
foreach ( QWidget *myWidget, myWidgets )
{
QgsAttributeEditor::createAttributeEditor( mDialog, w, vl, fldIdx, myAttributes[fldIdx], mProxyWidgets );
QgsAttributeEditor::createAttributeEditor( mDialog, myWidget, vl, fldIdx, myAttributes[fldIdx], mProxyWidgets );

if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable && w->isEnabled() )
if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
{
w->setEnabled( vl->isEditable() && vl->fieldEditable( fldIdx ) );
if ( vl->isEditable() && vl->fieldEditable( fldIdx ) )
{
myWidget->setEnabled( true );
}
else if ( vl->editType( fldIdx ) == QgsVectorLayer::Photo )
{
foreach ( QWidget *w, myWidget->findChildren<QWidget *>() )
{
w->setEnabled( qobject_cast<QLabel *>( w ) ? true : false );
}
}
else if ( vl->editType( fldIdx ) == QgsVectorLayer::WebView )
{
foreach ( QWidget *w, myWidget->findChildren<QWidget *>() )
{
w->setEnabled( qobject_cast<QWebView *>( w ) ? true : false );
}
}
else
{
myWidget->setEnabled( false );
}
}
}
}
@@ -28,6 +28,7 @@
#include <qgsexpression.h>
#include <qgsfilterlineedit.h>
#include <qgscolorbutton.h>
#include <qgsnetworkaccessmanager.h>

#include <QScrollArea>
#include <QPushButton>
@@ -159,7 +160,7 @@ void QgsAttributeEditor::loadPixmap( const QString &name )
size.setHeight( size.width() * pm.size().height() / pm.size().width() );
}

pm = pm.scaled( size, Qt::KeepAspectRatio );
pm = pm.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );

lw->setPixmap( pm );
lw->setMinimumSize( size );
@@ -652,7 +653,9 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
if ( myWidget )
{
if ( editType == QgsVectorLayer::Immutable )
{
myWidget->setDisabled( true );
}

QgsStringRelay* relay = NULL;

@@ -708,7 +711,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
case QgsVectorLayer::FileName:
case QgsVectorLayer::Calendar:
case QgsVectorLayer::Photo:
case QgsVectorLayer::Webview:
case QgsVectorLayer::WebView:
case QgsVectorLayer::Color:
{
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );
@@ -721,6 +724,12 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
QWebView *ww = qobject_cast<QWebView *>( editor );
if ( ww )
{
ww->page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
ww->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
ww->settings()->setAttribute( QWebSettings::LocalContentCanAccessRemoteUrls, true );
#ifdef QGISDEBUG
ww->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true );
#endif
myWidget = ww;
break;
}
@@ -753,47 +762,55 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
}
else
{
le = new QgsFilterLineEdit();
myWidget = new QWidget( parent );
myWidget->setBackgroundRole( QPalette::Window );
myWidget->setAutoFillBackground( true );

le = new QgsFilterLineEdit( myWidget );
switch ( editType )
{
case QgsVectorLayer::FileName:
case QgsVectorLayer::Photo:
pb = new QPushButton( tr( "..." ) );
pb = new QPushButton( tr( "..." ), myWidget );
break;

case QgsVectorLayer::Webview:
pb = new QPushButton( tr( "<" ) );
case QgsVectorLayer::WebView:
pb = new QPushButton( tr( "<" ), myWidget );
break;

case QgsVectorLayer::Color:
pb = new QgsColorButton();
pb = new QgsColorButton( myWidget );
break;

default:
break;
}


int row = 0;
QGridLayout *layout = new QGridLayout();
QGridLayout *layout = new QGridLayout( myWidget );
if ( editType == QgsVectorLayer::Photo )
{
lw = new QLabel();
lw = new QLabel( myWidget );
layout->addWidget( lw, 0, 0, 1, 2 );
row++;
}
else if ( editType == QgsVectorLayer::Webview )
else if ( editType == QgsVectorLayer::WebView )
{
ww = new QWebView();
ww = new QWebView( myWidget );
ww->page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
ww->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
ww->settings()->setAttribute( QWebSettings::LocalContentCanAccessRemoteUrls, true );
#ifdef QGISDEBUG
ww->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true );
#endif
layout->addWidget( ww, 0, 0, 1, 2 );
row++;
}

layout->addWidget( le, row, 0 );
layout->addWidget( pb, row, 1 );

myWidget = new QWidget( parent );
myWidget->setBackgroundRole( QPalette::Window );
myWidget->setAutoFillBackground( true );
myWidget->setLayout( layout );
}

@@ -813,7 +830,7 @@ QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *ed
{
if ( editType == QgsVectorLayer::FileName || editType == QgsVectorLayer::Photo )
connect( pb, SIGNAL( clicked() ), new QgsAttributeEditor( pb ), SLOT( selectFileName() ) );
if ( editType == QgsVectorLayer::Webview )
if ( editType == QgsVectorLayer::WebView )
connect( pb, SIGNAL( clicked() ), new QgsAttributeEditor( pb ), SLOT( updateUrl() ) );
if ( editType == QgsVectorLayer::Calendar )
connect( pb, SIGNAL( clicked() ), new QgsAttributeEditor( pb ), SLOT( selectDate() ) );
@@ -1197,7 +1214,7 @@ bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx,
case QgsVectorLayer::FileName:
case QgsVectorLayer::Calendar:
case QgsVectorLayer::Photo:
case QgsVectorLayer::Webview:
case QgsVectorLayer::WebView:
case QgsVectorLayer::Color:
{
QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( editor );

1 comment on commit 6e6b8fe

@dakcarto

This comment has been minimized.

Copy link
Member

@dakcarto dakcarto commented on 6e6b8fe Apr 2, 2013

Nice touch on the color button edit, Juergen. Keeps the color while still showing it's disabled. Much better than the color shifts I was getting with the fake-disabled method, and helpful when multiple color buttons are next to each other and some are disabled.

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