@@ -477,9 +477,9 @@ QList<QPair<int, bool> > QgsComposerAttributeTableV2::sortAttributes() const
477477 return attributesBySortRank;
478478}
479479
480- bool QgsComposerAttributeTableV2::writeXML ( QDomElement& elem, QDomDocument & doc ) const
480+ bool QgsComposerAttributeTableV2::writeXML ( QDomElement& elem, QDomDocument & doc, bool ignoreFrames ) const
481481{
482- QDomElement composerTableElem = doc.createElement ( " ComposerAttributeTable " );
482+ QDomElement composerTableElem = doc.createElement ( " ComposerAttributeTableV2 " );
483483 composerTableElem.setAttribute ( " showOnlyVisibleFeatures" , mShowOnlyVisibleFeatures );
484484 composerTableElem.setAttribute ( " maxFeatures" , mMaximumNumberOfFeatures );
485485 composerTableElem.setAttribute ( " filterFeatures" , mFilterFeatures ? " true" : " false" );
@@ -498,30 +498,30 @@ bool QgsComposerAttributeTableV2::writeXML( QDomElement& elem, QDomDocument & do
498498 composerTableElem.setAttribute ( " vectorLayer" , mVectorLayer ->id () );
499499 }
500500
501+ bool ok = QgsComposerTableV2::writeXML ( composerTableElem, doc, ignoreFrames );
502+
501503 elem.appendChild ( composerTableElem );
502- // todo
503- // bool ok = tableWriteXML( composerTableElem, doc );
504- bool ok = true ;
504+
505505 return ok;
506506}
507507
508- bool QgsComposerAttributeTableV2::readXML ( const QDomElement& itemElem, const QDomDocument& doc )
508+ bool QgsComposerAttributeTableV2::readXML ( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames )
509509{
510510 if ( itemElem.isNull () )
511511 {
512512 return false ;
513513 }
514514
515- // TODO
516515 // read general table properties
517- // if ( !tableReadXML ( itemElem, doc ) )
518- // {
519- // return false;
520- // }
516+ if ( !QgsComposerTableV2::readXML ( itemElem, doc, ignoreFrames ) )
517+ {
518+ return false ;
519+ }
521520
522521 mShowOnlyVisibleFeatures = itemElem.attribute ( " showOnlyVisibleFeatures" , " 1" ).toInt ();
523522 mFilterFeatures = itemElem.attribute ( " filterFeatures" , " false" ) == " true" ? true : false ;
524523 mFeatureFilter = itemElem.attribute ( " featureFilter" , " " );
524+ mMaximumNumberOfFeatures = itemElem.attribute ( " maxFeatures" , " 5" ).toInt ();
525525
526526 // composer map
527527 int composerMapId = itemElem.attribute ( " composerMap" , " -1" ).toInt ();
@@ -565,74 +565,9 @@ bool QgsComposerAttributeTableV2::readXML( const QDomElement& itemElem, const QD
565565 }
566566 }
567567
568- // restore display attribute map. This is required to upgrade pre 2.4 projects.
569- QSet<int > displayAttributes;
570- QDomNodeList displayAttributeList = itemElem.elementsByTagName ( " displayAttributes" );
571- if ( displayAttributeList.size () > 0 )
572- {
573- QDomElement displayAttributesElem = displayAttributeList.at ( 0 ).toElement ();
574- QDomNodeList attributeEntryList = displayAttributesElem.elementsByTagName ( " attributeEntry" );
575- for ( int i = 0 ; i < attributeEntryList.size (); ++i )
576- {
577- QDomElement attributeEntryElem = attributeEntryList.at ( i ).toElement ();
578- int index = attributeEntryElem.attribute ( " index" , " -1" ).toInt ();
579- if ( index != -1 )
580- {
581- displayAttributes.insert ( index );
582- }
583- }
584- setDisplayAttributes ( displayAttributes, false );
585- }
586-
587- // restore alias map. This is required to upgrade pre 2.4 projects.
588- QMap<int , QString> fieldAliasMap;
589- QDomNodeList aliasMapNodeList = itemElem.elementsByTagName ( " attributeAliasMap" );
590- if ( aliasMapNodeList.size () > 0 )
591- {
592- QDomElement attributeAliasMapElem = aliasMapNodeList.at ( 0 ).toElement ();
593- QDomNodeList aliasMepEntryList = attributeAliasMapElem.elementsByTagName ( " aliasEntry" );
594- for ( int i = 0 ; i < aliasMepEntryList.size (); ++i )
595- {
596- QDomElement aliasEntryElem = aliasMepEntryList.at ( i ).toElement ();
597- int key = aliasEntryElem.attribute ( " key" , " -1" ).toInt ();
598- QString value = aliasEntryElem.attribute ( " value" , " " );
599- fieldAliasMap.insert ( key, value );
600- }
601- restoreFieldAliasMap ( fieldAliasMap );
602- }
603-
604- // restore sort columns. This is required to upgrade pre 2.4 projects.
605- QDomElement sortColumnsElem = itemElem.firstChildElement ( " sortColumns" );
606- if ( !sortColumnsElem.isNull () && mVectorLayer )
607- {
608- QDomNodeList columns = sortColumnsElem.elementsByTagName ( " column" );
609- const QgsFields& fields = mVectorLayer ->pendingFields ();
610-
611- for ( int i = 0 ; i < columns.size (); ++i )
612- {
613- QDomElement columnElem = columns.at ( i ).toElement ();
614- int attribute = columnElem.attribute ( " index" ).toInt ();
615- Qt::SortOrder order = columnElem.attribute ( " ascending" ) == " true" ? Qt::AscendingOrder : Qt::DescendingOrder;
616- // find corresponding column
617- QList<QgsComposerTableColumn*>::iterator columnIt = mColumns .begin ();
618- for ( ; columnIt != mColumns .end (); ++columnIt )
619- {
620- if (( *columnIt )->attribute () == fields[attribute].name () )
621- {
622- ( *columnIt )->setSortByRank ( i + 1 );
623- ( *columnIt )->setSortOrder ( order );
624- break ;
625- }
626- }
627- }
628- }
629-
630- // must be done here because tableReadXML->setSceneRect changes mMaximumNumberOfFeatures
631- mMaximumNumberOfFeatures = itemElem.attribute ( " maxFeatures" , " 5" ).toInt ();
632-
633568 refreshAttributes ();
634569
635- emit itemChanged ();
570+ emit changed ();
636571 return true ;
637572}
638573
0 commit comments