Skip to content

Commit

Permalink
lazy fill meta data page in vector layer properties
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13529 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 19, 2010
1 parent 9c2e17a commit deaec1e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
50 changes: 31 additions & 19 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -65,9 +65,10 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
QWidget * parent,
Qt::WFlags fl
)
: QDialog( parent, fl ),
layer( lyr ),
mRendererDialog( 0 )
: QDialog( parent, fl )
, layer( lyr )
, mMetadataFilled( false )
, mRendererDialog( 0 )
{
setupUi( this );
setupEditTypes();
Expand Down Expand Up @@ -110,7 +111,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
actionDialog = new QgsAttributeActionDialog( layer->actions(), fields, actionOptionsFrame );
actionLayout->addWidget( actionDialog );


reset();

if ( layer->dataProvider() )//enable spatial index button group if supported by provider
Expand Down Expand Up @@ -145,7 +145,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mOverlayDialogs.push_back( d );
//shamelessly hard coded - what will we do if other types of layer plugins exist? TS
QListWidgetItem * mypItem = new QListWidgetItem( QgisApp::getThemeIcon( "propertyicons/diagram.png" ), ( *it )->name() );
listWidget->insertItem( stackedWidget->count()-1, mypItem );
listWidget->insertItem( stackedWidget->count() - 1, mypItem );
}

stackedWidget->setCurrentIndex( 0 );
Expand Down Expand Up @@ -498,11 +498,6 @@ void QgsVectorLayerProperties::reset( void )
// reset fields in label dialog
layer->label()->setFields( layer->pendingFields() );

//set the metadata contents
QString myStyle = QgsApplication::reportStyleSheet();
teMetadata->clear();
teMetadata->document()->setDefaultStyleSheet( myStyle );
teMetadata->setHtml( metadata() );
actionDialog->init();
labelDialog->init();
labelCheckBox->setChecked( layer->hasLabelsEnabled() );
Expand Down Expand Up @@ -561,15 +556,21 @@ void QgsVectorLayerProperties::apply()
// Set up sql subset query if applicable
//
grpSubset->setEnabled( true );
// set the subset sql for the layer
layer->setSubsetString( txtSubsetSQL->toPlainText() );
// update the metadata with the updated sql subset
QString myStyle = QgsApplication::reportStyleSheet();
teMetadata->clear();
teMetadata->document()->setDefaultStyleSheet( myStyle );
teMetadata->setHtml( metadata() );
// update the extents of the layer (fetched from the provider)
layer->updateExtents();

if ( txtSubsetSQL->toPlainText() != layer->subsetString() )
{
// set the subset sql for the layer
layer->setSubsetString( txtSubsetSQL->toPlainText() );

// update the metadata with the updated sql subset
QString myStyle = QgsApplication::reportStyleSheet();
teMetadata->clear();
teMetadata->document()->setDefaultStyleSheet( myStyle );
teMetadata->setHtml( metadata() );

// update the extents of the layer (fetched from the provider)
layer->updateExtents();
}

// set up the scale based layer visibility stuff....
layer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
Expand Down Expand Up @@ -1189,6 +1190,17 @@ void QgsVectorLayerProperties::updateSymbologyPage()
widgetStackRenderers->addWidget( mRendererDialog );
widgetStackRenderers->setCurrentWidget( mRendererDialog );
}
}

void QgsVectorLayerProperties::on_stackedWidget_currentChanged( int index )
{
if ( index != 4 || mMetadataFilled )
return;

//set the metadata contents (which can be expensive)
QString myStyle = QgsApplication::reportStyleSheet();
teMetadata->clear();
teMetadata->document()->setDefaultStyleSheet( myStyle );
teMetadata->setHtml( metadata() );
mMetadataFilled = true;
}
4 changes: 4 additions & 0 deletions src/app/qgsvectorlayerproperties.h
Expand Up @@ -104,6 +104,7 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
void on_tblAttributes_cellChanged( int row, int column );
void on_mCalculateFieldButton_clicked();
void on_pbnSelectEditForm_clicked();
void on_stackedWidget_currentChanged( int idx );
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

void addAttribute();
Expand Down Expand Up @@ -140,6 +141,9 @@ class QgsVectorLayerProperties : public QDialog, private Ui::QgsVectorLayerPrope
};

QgsVectorLayer *layer;

bool mMetadataFilled;

/**Renderer dialog which is shown*/
QDialog* mRendererDialog;
/**Buffer renderer, which is assigned to the vector layer when apply is pressed*/
Expand Down

0 comments on commit deaec1e

Please sign in to comment.