mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Add icons for joins status in attribute form
This commit is contained in:
parent
d4789db19a
commit
5c5006c755
@ -342,6 +342,9 @@
|
|||||||
<file>themes/default/mIconDelete.png</file>
|
<file>themes/default/mIconDelete.png</file>
|
||||||
<file>themes/default/mIconDeselected.svg</file>
|
<file>themes/default/mIconDeselected.svg</file>
|
||||||
<file>themes/default/mIconDropDownMenu.svg</file>
|
<file>themes/default/mIconDropDownMenu.svg</file>
|
||||||
|
<file>themes/default/mIconJoinNotEditable.svg</file>
|
||||||
|
<file>themes/default/mIconJoinedLayerNotEditable.svg</file>
|
||||||
|
<file>themes/default/mIconJoinHasNotUpsertOnEdit.svg</file>
|
||||||
<file>themes/default/mIconEditableEdits.svg</file>
|
<file>themes/default/mIconEditableEdits.svg</file>
|
||||||
<file>themes/default/mIconExpand.svg</file>
|
<file>themes/default/mIconExpand.svg</file>
|
||||||
<file>themes/default/mIconExpandSmall.svg</file>
|
<file>themes/default/mIconExpandSmall.svg</file>
|
||||||
|
161
images/themes/default/mIconJoinHasNotUpsertOnEdit.svg
Normal file
161
images/themes/default/mIconJoinHasNotUpsertOnEdit.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 10 KiB |
167
images/themes/default/mIconJoinNotEditable.svg
Normal file
167
images/themes/default/mIconJoinNotEditable.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 12 KiB |
194
images/themes/default/mIconJoinedLayerNotEditable.svg
Normal file
194
images/themes/default/mIconJoinedLayerNotEditable.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 12 KiB |
@ -50,7 +50,6 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QSvgWidget>
|
|
||||||
|
|
||||||
int QgsAttributeForm::sFormCounter = 0;
|
int QgsAttributeForm::sFormCounter = 0;
|
||||||
|
|
||||||
@ -1023,6 +1022,8 @@ void QgsAttributeForm::synchronizeEnabledState()
|
|||||||
{
|
{
|
||||||
bool enabled = isEditable && fieldIsEditable( eww->fieldIdx() );
|
bool enabled = isEditable && fieldIsEditable( eww->fieldIdx() );
|
||||||
ww->setEnabled( enabled );
|
ww->setEnabled( enabled );
|
||||||
|
|
||||||
|
updateIcon( eww );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1230,6 +1231,8 @@ void QgsAttributeForm::init()
|
|||||||
|
|
||||||
// Autogenerate Layout
|
// Autogenerate Layout
|
||||||
// If there is still no layout loaded (defined as autogenerate or other methods failed)
|
// If there is still no layout loaded (defined as autogenerate or other methods failed)
|
||||||
|
mIconMap.clear();
|
||||||
|
|
||||||
if ( !formWidget )
|
if ( !formWidget )
|
||||||
{
|
{
|
||||||
formWidget = new QWidget( this );
|
formWidget = new QWidget( this );
|
||||||
@ -1271,6 +1274,9 @@ void QgsAttributeForm::init()
|
|||||||
|
|
||||||
// This will also create the widget
|
// This will also create the widget
|
||||||
QLabel *l = new QLabel( fieldName );
|
QLabel *l = new QLabel( fieldName );
|
||||||
|
QSvgWidget *i = new QSvgWidget();
|
||||||
|
i->setFixedSize( 18, 18 );
|
||||||
|
|
||||||
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( widgetSetup.type(), mLayer, idx, widgetSetup.config(), nullptr, this, mContext );
|
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( widgetSetup.type(), mLayer, idx, widgetSetup.config(), nullptr, this, mContext );
|
||||||
|
|
||||||
QWidget *w = nullptr;
|
QWidget *w = nullptr;
|
||||||
@ -1293,17 +1299,22 @@ void QgsAttributeForm::init()
|
|||||||
w->setObjectName( field.name() );
|
w->setObjectName( field.name() );
|
||||||
|
|
||||||
if ( eww )
|
if ( eww )
|
||||||
|
{
|
||||||
addWidgetWrapper( eww );
|
addWidgetWrapper( eww );
|
||||||
|
mIconMap[eww->widget()] = i;
|
||||||
|
}
|
||||||
|
|
||||||
if ( labelOnTop )
|
if ( labelOnTop )
|
||||||
{
|
{
|
||||||
gridLayout->addWidget( l, row++, 0, 1, 2 );
|
gridLayout->addWidget( l, row++, 0, 1, 2 );
|
||||||
gridLayout->addWidget( w, row++, 0, 1, 2 );
|
gridLayout->addWidget( w, row++, 0, 1, 2 );
|
||||||
|
gridLayout->addWidget( i, row++, 0, 1, 2 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gridLayout->addWidget( l, row, 0 );
|
gridLayout->addWidget( l, row, 0 );
|
||||||
gridLayout->addWidget( w, row++, 1 );
|
gridLayout->addWidget( w, row, 1 );
|
||||||
|
gridLayout->addWidget( i, row++, 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2025,7 +2036,9 @@ bool QgsAttributeForm::fieldIsEditable( int fieldIndex ) const
|
|||||||
int srcFieldIndex;
|
int srcFieldIndex;
|
||||||
const QgsVectorLayerJoinInfo *info = mLayer->joinBuffer()->joinForFieldIndex( fieldIndex, mLayer->fields(), srcFieldIndex );
|
const QgsVectorLayerJoinInfo *info = mLayer->joinBuffer()->joinForFieldIndex( fieldIndex, mLayer->fields(), srcFieldIndex );
|
||||||
|
|
||||||
if ( info && info->isEditable() && info->joinLayer()->isEditable() )
|
if ( !info->hasUpsertOnEdit() && mMode == QgsAttributeForm::AddFeatureMode )
|
||||||
|
editable = false;
|
||||||
|
else if ( info && info->isEditable() && info->joinLayer()->isEditable() )
|
||||||
editable = fieldIsEditable( *( info->joinLayer() ), srcFieldIndex, mFeature.id() );
|
editable = fieldIsEditable( *( info->joinLayer() ), srcFieldIndex, mFeature.id() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2039,3 +2052,47 @@ bool QgsAttributeForm::fieldIsEditable( const QgsVectorLayer &layer, int fieldIn
|
|||||||
return !layer.editFormConfig().readOnly( fieldIndex ) &&
|
return !layer.editFormConfig().readOnly( fieldIndex ) &&
|
||||||
( ( layer.dataProvider() && layer.dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) || FID_IS_NEW( fid ) );
|
( ( layer.dataProvider() && layer.dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) || FID_IS_NEW( fid ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsAttributeForm::updateIcon( QgsEditorWidgetWrapper *eww )
|
||||||
|
{
|
||||||
|
// no icon by default
|
||||||
|
mIconMap[eww->widget()]->hide();
|
||||||
|
|
||||||
|
if ( !eww->widget()->isEnabled() && mLayer->isEditable() )
|
||||||
|
{
|
||||||
|
if ( mLayer->fields().fieldOrigin( eww->fieldIdx() ) == QgsFields::OriginJoin )
|
||||||
|
{
|
||||||
|
int srcFieldIndex;
|
||||||
|
const QgsVectorLayerJoinInfo *info = mLayer->joinBuffer()->joinForFieldIndex( eww->fieldIdx(), mLayer->fields(), srcFieldIndex );
|
||||||
|
|
||||||
|
if ( !info )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( !info->isEditable() )
|
||||||
|
{
|
||||||
|
QString file = QStringLiteral( "/mIconJoinNotEditable.svg" );
|
||||||
|
QString tooltip = tr( "Join settings do not allow editing" );
|
||||||
|
reloadIcon( file, tooltip, mIconMap[eww->widget()] );
|
||||||
|
}
|
||||||
|
else if ( mMode == QgsAttributeForm::AddFeatureMode && !info->hasUpsertOnEdit() )
|
||||||
|
{
|
||||||
|
QString file = QStringLiteral( "mIconJoinHasNotUpsertOnEdit.svg" );
|
||||||
|
QString tooltip = tr( "Join settings do not allow upsert on edit" );
|
||||||
|
reloadIcon( file, tooltip, mIconMap[eww->widget()] );
|
||||||
|
}
|
||||||
|
else if ( !info->joinLayer()->isEditable() )
|
||||||
|
{
|
||||||
|
QString file = QStringLiteral( "/mIconJoinedLayerNotEditable.svg" );
|
||||||
|
QString tooltip = tr( "Joined layer is not toggled editable" );
|
||||||
|
reloadIcon( file, tooltip, mIconMap[eww->widget()] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgsAttributeForm::reloadIcon( const QString &file, const QString &tooltip, QSvgWidget *sw )
|
||||||
|
{
|
||||||
|
sw->load( QgsApplication::iconPath( file ) );
|
||||||
|
sw->setToolTip( tooltip );
|
||||||
|
sw->show();
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "qgseditorwidgetwrapper.h"
|
#include "qgseditorwidgetwrapper.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QSvgWidget>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include "qgis_gui.h"
|
#include "qgis_gui.h"
|
||||||
@ -373,6 +374,10 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
|
|||||||
|
|
||||||
void registerContainerInformation( ContainerInformation *info );
|
void registerContainerInformation( ContainerInformation *info );
|
||||||
|
|
||||||
|
void updateIcon( QgsEditorWidgetWrapper *eww );
|
||||||
|
|
||||||
|
void reloadIcon( const QString &file, const QString &tooltip, QSvgWidget *sw );
|
||||||
|
|
||||||
// Contains information about tabs and groupboxes, their visibility state visibility conditions
|
// Contains information about tabs and groupboxes, their visibility state visibility conditions
|
||||||
QVector<ContainerInformation *> mContainerVisibilityInformation;
|
QVector<ContainerInformation *> mContainerVisibilityInformation;
|
||||||
QMap<QString, QVector<ContainerInformation *> > mContainerInformationDependency;
|
QMap<QString, QVector<ContainerInformation *> > mContainerInformationDependency;
|
||||||
@ -401,6 +406,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
|
|||||||
|
|
||||||
//! Backlinks widgets to buddies.
|
//! Backlinks widgets to buddies.
|
||||||
QMap<QWidget *, QLabel *> mBuddyMap;
|
QMap<QWidget *, QLabel *> mBuddyMap;
|
||||||
|
QMap<QWidget *, QSvgWidget *> mIconMap;
|
||||||
|
|
||||||
friend class TestQgsDualView;
|
friend class TestQgsDualView;
|
||||||
friend class TestQgsAttributeForm;
|
friend class TestQgsAttributeForm;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user