Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/qgis/Quantum-GIS

  • Loading branch information
Sergey Yakushev
Sergey Yakushev committed Jan 17, 2012
2 parents c56d02f + 3ba2fe9 commit 86ce8593b5fb92fc3706e83e3837fe9cfc3521c2

Large diffs are not rendered by default.

@@ -820,6 +820,109 @@ template<TYPE>
%End
};

%MappedType QMap<QString, int>
{
%TypeHeaderCode
#include <QMap>
#if (SIP_VERSION >= 0x040900)
#define sipClass_QString ((sipWrapperType *) sipTypeAsPyTypeObject (sipType_QString))
#endif
%End

%ConvertFromTypeCode
// Create the dictionary.
PyObject *d = PyDict_New();

if (!d)
return NULL;

// Set the dictionary elements.
QMap<QString, int>::const_iterator i = sipCpp->constBegin();

while (i != sipCpp->constEnd())
{
QString *t1 = new QString(i.key());

PyObject *t1obj = sipConvertFromNewInstance(t1, sipClass_QString, sipTransferObj);
PyObject *t2obj = PyInt_FromLong( (long) i.value() );

if (t1obj == NULL || t2obj == NULL || PyDict_SetItem(d, t1obj, t2obj) < 0)
{
Py_DECREF(d);

if (t1obj) {
Py_DECREF(t1obj);
} else {
delete t1;
}

if (t2obj) {
Py_DECREF(t2obj);
}

return NULL;
}

Py_DECREF(t1obj);
Py_DECREF(t2obj);

++i;
}

return d;
%End

%ConvertToTypeCode
PyObject *t1obj, *t2obj;
#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t i = 0;
#else
int i = 0;
#endif


// Check the type if that is all that is required.
if (sipIsErr == NULL)
{
if (!PyDict_Check(sipPy))
return 0;

while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
{
if (!sipCanConvertToInstance(t1obj, sipClass_QString, SIP_NOT_NONE))
return 0;
}

return 1;
}

QMap<QString, int> *qm = new QMap<QString, int>;

while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
{
int state;

QString *t1 = reinterpret_cast<QString *>(sipConvertToInstance(t1obj, sipClass_QString, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
int t2 = PyInt_AsLong(t1obj);

if (*sipIsErr)
{
sipReleaseInstance(t1, sipClass_QString, state);
delete qm;
return 0;
}

qm->insert(*t1, t2);

sipReleaseInstance(t1, sipClass_QString, state);
}

*sipCppPtr = qm;

return sipGetState(sipTransferObj);
%End
};

template<TYPE1, TYPE2>
%MappedType QMap<TYPE1, TYPE2*>
{
@@ -159,11 +159,11 @@ class QgsCoordinateReferenceSystem
/*! Overloaded == operator used to compare to CRS's.
* Internally it will delegate to the equals method described below
*/
bool operator==(const QgsCoordinateReferenceSystem &theSrs);
bool operator==(const QgsCoordinateReferenceSystem &theSrs) const;
/*! Overloaded != operator used to compare to CRS's.
* Returns opposite bool value to operator ==
*/
bool operator!=(const QgsCoordinateReferenceSystem &theSrs);
bool operator!=(const QgsCoordinateReferenceSystem &theSrs) const;
/*! Overloaded == operator used to compare to CRS's.
* Internally it will use OGR isSameCRS() or isSameGeoCRS() methods as appropriate.
* Additionally logic may also be applied if the result from the OGR methods
@@ -261,6 +261,9 @@ class QgsVectorDataProvider : QgsDataProvider
* Returns the index of a field name or -1 if the field does not exist
*/
int fieldNameIndex(const QString& fieldName) const;

/**Return a map where the key is the name of the field and the value is its index*/
QMap<QString, int> fieldNameMap() const;

/**
* Return list of indexes to fetch all attributes in nextFeature()
@@ -1342,142 +1342,6 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
mComposition->addItemsFromXML( composerElem, doc );
}

#if 0
//composer labels
QDomNodeList composerLabelList = composerElem.elementsByTagName( "ComposerLabel" );
for ( int i = 0; i < composerLabelList.size(); ++i )
{
QDomElement currentComposerLabelElem = composerLabelList.at( i ).toElement();
QgsComposerLabel* newLabel = new QgsComposerLabel( mComposition );
newLabel->readXML( currentComposerLabelElem, doc );
addComposerLabel( newLabel );
mComposition->addItem( newLabel );
mComposition->update();
mComposition->clearSelection();
newLabel->setSelected( true );
showItemOptions( newLabel );
}

//composer maps
QDomNodeList composerMapList = composerElem.elementsByTagName( "ComposerMap" );
for ( int i = 0; i < composerMapList.size(); ++i )
{
QDomElement currentComposerMapElem = composerMapList.at( i ).toElement();
QgsComposerMap* newMap = new QgsComposerMap( mComposition );
newMap->readXML( currentComposerMapElem, doc );

if ( fromTemplate ) //show map directly if loaded from template
{
newMap->updateItem();
}
else //show map only on demand if loaded from project
{
if ( newMap->previewMode() != QgsComposerMap::Rectangle )
{
mMapsToRestore.insert( newMap, newMap->previewMode() );
newMap->setPreviewMode( QgsComposerMap::Rectangle );
}
}

addComposerMap( newMap );
mComposition->addItem( newMap );
mComposition->update();
mComposition->clearSelection();
newMap->setSelected( true );
showItemOptions( newMap );
}

//composer scalebars
QDomNodeList composerScaleBarList = composerElem.elementsByTagName( "ComposerScaleBar" );
for ( int i = 0; i < composerScaleBarList.size(); ++i )
{
QDomElement currentScaleBarElem = composerScaleBarList.at( i ).toElement();
QgsComposerScaleBar* newScaleBar = new QgsComposerScaleBar( mComposition );
newScaleBar->readXML( currentScaleBarElem, doc );
addComposerScaleBar( newScaleBar );
mComposition->addItem( newScaleBar );
mComposition->update();
mComposition->clearSelection();
newScaleBar->setSelected( true );
showItemOptions( newScaleBar );
}

//composer legends
QDomNodeList composerLegendList = composerElem.elementsByTagName( "ComposerLegend" );
for ( int i = 0; i < composerLegendList.size(); ++i )
{
QDomElement currentLegendElem = composerLegendList.at( i ).toElement();
QgsComposerLegend* newLegend = new QgsComposerLegend( mComposition );
newLegend->readXML( currentLegendElem, doc );
addComposerLegend( newLegend );
mComposition->addItem( newLegend );
mComposition->update();
mComposition->clearSelection();
newLegend->setSelected( true );
showItemOptions( newLegend );
}

//composer pictures
QDomNodeList composerPictureList = composerElem.elementsByTagName( "ComposerPicture" );
for ( int i = 0; i < composerPictureList.size(); ++i )
{
QDomElement currentPictureElem = composerPictureList.at( i ).toElement();
QgsComposerPicture* newPicture = new QgsComposerPicture( mComposition );
newPicture->readXML( currentPictureElem, doc );
addComposerPicture( newPicture );
mComposition->addItem( newPicture );
mComposition->update();
mComposition->clearSelection();
newPicture->setSelected( true );
showItemOptions( newPicture );
}

//composer shapes
QDomNodeList composerShapeList = composerElem.elementsByTagName( "ComposerShape" );
for ( int i = 0; i < composerShapeList.size(); ++i )
{
QDomElement currentShapeElem = composerShapeList.at( i ).toElement();
QgsComposerShape* newShape = new QgsComposerShape( mComposition );
newShape->readXML( currentShapeElem, doc );
addComposerShape( newShape );
mComposition->addItem( newShape );
mComposition->update();
mComposition->clearSelection();
newShape->setSelected( true );
showItemOptions( newShape );
}

//composer arrows
QDomNodeList composerArrowList = composerElem.elementsByTagName( "ComposerArrow" );
for ( int i = 0; i < composerArrowList.size(); ++i )
{
QDomElement currentArrowElem = composerArrowList.at( i ).toElement();
QgsComposerArrow* newArrow = new QgsComposerArrow( mComposition );
newArrow->readXML( currentArrowElem, doc );
addComposerArrow( newArrow );
mComposition->addItem( newArrow );
mComposition->update();
mComposition->clearSelection();
newArrow->setSelected( true );
showItemOptions( newArrow );
}

//composer tables
QDomNodeList composerTableList = composerElem.elementsByTagName( "ComposerAttributeTable" );
for ( int i = 0; i < composerTableList.size(); ++i )
{
QDomElement currentTableElem = composerTableList.at( i ).toElement();
QgsComposerAttributeTable* newTable = new QgsComposerAttributeTable( mComposition );
newTable->readXML( currentTableElem, doc );
addComposerTable( newTable );
mComposition->addItem( newTable );
mComposition->update();
mComposition->clearSelection();
newTable->setSelected( true );
showItemOptions( newTable );
}
#endif //0

mComposition->sortZList();
mView->setComposition( mComposition );

@@ -63,15 +63,13 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
QSettings settings;
restoreGeometry( settings.value( "/Windows/BetterAttributeTable/geometry" ).toByteArray() );

connect( mView, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
connect( mView, SIGNAL( finished() ), this, SLOT( finished() ) );
mView->setCanvasAndLayer( QgisApp::instance()->mapCanvas(), mLayer );

mFilterModel = ( QgsAttributeTableFilterModel * ) mView->model();
mModel = qobject_cast<QgsAttributeTableModel * >( dynamic_cast<QgsAttributeTableFilterModel *>( mView->model() )->sourceModel() );

connect( mModel, SIGNAL( progress( int, bool & ) ), this, SLOT( progress( int, bool & ) ) );
connect( mModel, SIGNAL( finished() ), this, SLOT( finished() ) );
mModel->loadLayer();

mQuery = query;
mColumnBox = columnBox;
columnBoxInit();
@@ -834,7 +832,7 @@ void QgsAttributeTableDialog::progress( int i, bool &cancel )

mProgress->setValue( i );

if ( i > 0 && i % 1000 == 0 )
if ( i > 0 && i % 5000 == 0 )
{
mProgress->setLabelText( tr( "%1 features loaded." ).arg( i ) );
}
@@ -989,7 +989,6 @@ void QgsComposition::addComposerArrow( QgsComposerArrow* arrow )
clearSelection();
arrow->setSelected( true );
emit selectedItemChanged( arrow );
//pushAddRemoveCommand( arrow, tr( "Arrow added" ) );
}

void QgsComposition::addComposerLabel( QgsComposerLabel* label )
@@ -999,7 +998,6 @@ void QgsComposition::addComposerLabel( QgsComposerLabel* label )
clearSelection();
label->setSelected( true );
emit selectedItemChanged( label );
//pushAddRemoveCommand( label, tr( "Label added" ) );
}

void QgsComposition::addComposerMap( QgsComposerMap* map )
@@ -1012,7 +1010,6 @@ void QgsComposition::addComposerMap( QgsComposerMap* map )
clearSelection();
map->setSelected( true );
emit selectedItemChanged( map );
//pushAddRemoveCommand( map, tr( "Map added" ) );
}

void QgsComposition::addComposerScaleBar( QgsComposerScaleBar* scaleBar )
@@ -1023,13 +1020,11 @@ void QgsComposition::addComposerScaleBar( QgsComposerScaleBar* scaleBar )
{
scaleBar->setComposerMap( mapItemList.at( 0 ) );
}
scaleBar->applyDefaultSize(); //4 segments, 1/5 of composer map width
addItem( scaleBar );
emit composerScaleBarAdded( scaleBar );
clearSelection();
scaleBar->setSelected( true );
emit selectedItemChanged( scaleBar );
//pushAddRemoveCommand( scaleBar, tr( "Scale bar added" ) );
}

void QgsComposition::addComposerLegend( QgsComposerLegend* legend )
@@ -1045,7 +1040,6 @@ void QgsComposition::addComposerLegend( QgsComposerLegend* legend )
clearSelection();
legend->setSelected( true );
emit selectedItemChanged( legend );
//pushAddRemoveCommand( legend, tr( "Legend added" ) );
}

void QgsComposition::addComposerPicture( QgsComposerPicture* picture )
@@ -1055,7 +1049,6 @@ void QgsComposition::addComposerPicture( QgsComposerPicture* picture )
clearSelection();
picture->setSelected( true );
emit selectedItemChanged( picture );
//pushAddRemoveCommand( picture, tr( "Picture added" ) );
}

void QgsComposition::addComposerShape( QgsComposerShape* shape )
@@ -1065,7 +1058,6 @@ void QgsComposition::addComposerShape( QgsComposerShape* shape )
clearSelection();
shape->setSelected( true );
emit selectedItemChanged( shape );
//pushAddRemoveCommand( shape, tr( "Shape added" ) );
}

void QgsComposition::addComposerTable( QgsComposerAttributeTable* table )
@@ -1075,7 +1067,6 @@ void QgsComposition::addComposerTable( QgsComposerAttributeTable* table )
clearSelection();
table->setSelected( true );
emit selectedItemChanged( table );
//pushAddRemoveCommand( table, tr( "Table added" ) );
}

void QgsComposition::removeComposerItem( QgsComposerItem* item )
@@ -979,12 +979,12 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
return 0;
}

bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs )
bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs ) const
{
return mIsValidFlag && theSrs.mIsValidFlag && toWkt() == theSrs.toWkt();
}

bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs )
bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs ) const
{
return !( *this == theSrs );
}

0 comments on commit 86ce859

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