Skip to content
Permalink
Browse files

topology plugin:

- cleanups & fixes for warnings
- log messages
- translation strings
- return plugin category (fixes persistent loading)
  • Loading branch information
jef-n committed Mar 26, 2013
1 parent 349b123 commit 91fa06265ca7cbf7c38eb4c03332777269eff765
@@ -322,7 +322,6 @@ SET(QGIS_CORE_MOC_HDRS

composer/qgsaddremoveitemcommand.h
composer/qgscomposerlegend.h
composer/qgscomposerlegendstyle.h
composer/qgscomposermap.h
composer/qgscomposerpicture.h
composer/qgscomposerscalebar.h
@@ -111,7 +111,7 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
double columnTop = mBoxSpace + titleSize.height() + style( QgsComposerLegendStyle::Group ).margin( QgsComposerLegendStyle::Top );

QPointF point( mBoxSpace, columnTop );
bool firstInColumn = true;
// bool firstInColumn = true;
double columnMaxHeight = 0;
qreal columnWidth = 0;
int column = 0;
@@ -131,7 +131,7 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
point.ry() = columnTop;
columnWidth = 0;
column++;
firstInColumn = true;
// firstInColumn = true;
}
// Add space if necessary, unfortunately it depends on first nucleon
//if ( !firstInColumn )
@@ -145,7 +145,7 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
point.ry() += atom.size.height();
columnMaxHeight = qMax( point.y() - columnTop, columnMaxHeight );

firstInColumn = false;
// firstInColumn = false;
}
point.rx() += columnWidth + mBoxSpace;

@@ -962,7 +962,7 @@ QList<QgsComposerLegend::Atom> QgsComposerLegend::createAtomList( QStandardItem*
// Draw atom and expand its size (using actual nucleons labelXOffset)
QSizeF QgsComposerLegend::drawAtom( Atom atom, QPainter* painter, QPointF point )
{
bool first = true;
// bool first = true;
QSizeF size = QSizeF( atom.size );
foreach ( Nucleon nucleon, atom.nucleons )
{
@@ -1006,7 +1006,7 @@ QSizeF QgsComposerLegend::drawAtom( Atom atom, QPainter* painter, QPointF point
size.rwidth() = qMax( symbolNucleon.size.width(), size.width() );
}
point.ry() += nucleon.size.height();
first = false;
// first = false;
}
return size;
}
@@ -1046,7 +1046,7 @@ void QgsComposerLegend::setColumns( QList<Atom>& atomList )

// Divide atoms to columns
double totalHeight = 0;
bool first = true;
// bool first = true;
qreal maxAtomHeight = 0;
foreach ( Atom atom, atomList )
{
@@ -1056,7 +1056,7 @@ void QgsComposerLegend::setColumns( QList<Atom>& atomList )
//}
totalHeight += atom.size.height();
maxAtomHeight = qMax( atom.size.height(), maxAtomHeight );
first = false;
// first = false;
}

// We know height of each atom and we have to split them into columns
@@ -1071,7 +1071,7 @@ void QgsComposerLegend::setColumns( QList<Atom>& atomList )
double currentColumnHeight = 0;
double maxColumnHeight = 0;
double closedColumnsHeight = 0;
first = true; // first in column
// first = true; // first in column
for ( int i = 0; i < atomList.size(); i++ )
{
Atom atom = atomList[i];
@@ -1104,7 +1104,7 @@ void QgsComposerLegend::setColumns( QList<Atom>& atomList )
currentColumnAtomCount++;
maxColumnHeight = qMax( currentColumnHeight, maxColumnHeight );

first = false;
// first = false;
}

// Alling labels of symbols for each layr/column to the same labelXOffset
@@ -1552,6 +1552,9 @@ void QgsWMSServer::drawLegendLayerItem( QgsComposerLayerItem* item, QPainter* p,
case QgsComposerLegendItem::LayerItem:
//QgsDebugMsg( "GroupItem not handled" );
break;
case QgsComposerLegendItem::StyleItem:
//QgsDebugMsg( "StyleItem not handled" );
break;
}

//finally draw text
@@ -22,7 +22,6 @@ SET (topol_MOC_HDRS
checkDock.h
topolTest.h
dockModel.h
geosFunctions.h
)

SET (topol_RCCS topol.qrc)
@@ -22,8 +22,6 @@
#include <qgsvectordataprovider.h>
#include <qgsvectorlayer.h>
#include <qgsmaplayer.h>
//#include <qgssearchstring.h>
//#include <qgssearchtreenode.h>
#include <qgsmaplayer.h>
#include <qgsmaplayerregistry.h>
#include <qgsgeometry.h>
@@ -35,13 +33,11 @@
#include <qgslogger.h>
#include <qgsspatialindex.h>
#include <qgisinterface.h>

//#include "../../app/qgisapp.h"
#include <qgsmessagelog.h>

#include "topolTest.h"
#include "rulesDialog.h"
#include "dockModel.h"
//#include "geosFunctions.h"

//class QgisInterface;

@@ -107,7 +103,6 @@ checkDock::checkDock( QgisInterface* qIface, QWidget* parent )

checkDock::~checkDock()
{
delete mRBConflict, mRBFeature1, mRBFeature2;
delete mConfigureDialog;
delete mErrorListModel;

@@ -168,9 +163,8 @@ void checkDock::deleteErrors()

void checkDock::parseErrorListByLayer( QString layerId )
{
QgsVectorLayer* layer = ( QgsVectorLayer* )mLayerRegistry->mapLayers()[layerId];
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer*>( mLayerRegistry->mapLayers()[layerId] );
QList<TopolError*>::Iterator it = mErrorList.begin();
QList<TopolError*>::Iterator end = mErrorList.end();

while ( it != mErrorList.end() )
{
@@ -185,13 +179,12 @@ void checkDock::parseErrorListByLayer( QString layerId )
}

mErrorListModel->resetModel();
mComment->setText( QString( "No errors were found" ) );
mComment->setText( tr( "No errors were found" ) );
}

void checkDock::parseErrorListByFeature( int featureId )
{
QList<TopolError*>::Iterator it = mErrorList.begin();
QList<TopolError*>::Iterator end = mErrorList.end();

while ( it != mErrorList.end() )
{
@@ -205,7 +198,7 @@ void checkDock::parseErrorListByFeature( int featureId )
++it;
}

mComment->setText( QString( "No errors were found" ) );
mComment->setText( tr( "No errors were found" ) );
mErrorListModel->resetModel();
}

@@ -225,14 +218,14 @@ void checkDock::errorListClicked( const QModelIndex& index )

mFixBox->clear();
mFixBox->addItems( mErrorList[row]->fixNames() );
mFixBox->setCurrentIndex( mFixBox->findText( "Select automatic fix" ) );
mFixBox->setCurrentIndex( mFixBox->findText( tr( "Select automatic fix" ) ) );

QgsFeature f;
QgsGeometry* g;
FeatureLayer fl = mErrorList[row]->featurePairs().first();
if ( !fl.layer )
{
std::cout << "invalid layer 1\n";
QgsMessageLog::logMessage( tr( "Invalid first layer" ), tr( "Topology plugin" ) );
return;
}

@@ -242,8 +235,8 @@ void checkDock::errorListClicked( const QModelIndex& index )
g = f.geometry();
if ( !g )
{
std::cout << "invalid geometry 1\n" << std::flush;
QMessageBox::information( this, "Topology test", "Feature not found in the layer.\nThe layer has probably changed.\nRun topology check again." );
QgsMessageLog::logMessage( tr( "Invalid first geometry" ), tr( "Topology plugin" ) );
QMessageBox::information( this, tr( "Topology test" ), tr( "Feature not found in the layer.\nThe layer has probably changed.\nRun topology check again." ) );
return;
}

@@ -266,7 +259,7 @@ void checkDock::errorListClicked( const QModelIndex& index )
fl = mErrorList[row]->featurePairs()[1];
if ( !fl.layer )
{
std::cout << "invalid layer 2\n";
QgsMessageLog::logMessage( tr( "Invalid second layer" ), tr( "Topology plugin" ) );
return;
}

@@ -275,8 +268,8 @@ void checkDock::errorListClicked( const QModelIndex& index )
g = f.geometry();
if ( !g )
{
std::cout << "invalid geometry 2\n" << std::flush;
QMessageBox::information( this, "Topology test", "Feature not found in the layer.\nThe layer has probably changed.\nRun topology check again." );
QgsMessageLog::logMessage( tr( "Invalid second geometry" ), tr( "Topology plugin" ) );
QMessageBox::information( this, tr( "Topology test" ), tr( "Feature not found in the layer.\nThe layer has probably changed.\nRun topology check again." ) );
return;
}

@@ -294,7 +287,7 @@ void checkDock::errorListClicked( const QModelIndex& index )

if ( !mErrorList[row]->conflict() )
{
std::cout << "invalid conflict\n" << std::flush;
QgsMessageLog::logMessage( tr( "Invalid conflict" ), tr( "Topology plugin" ) );
return;
}

@@ -330,11 +323,11 @@ void checkDock::fix()
mErrorList.removeAt( row );
mErrorListModel->resetModel();
//parseErrorListByFeature();
mComment->setText( QString( "%1 errors were found" ).arg( mErrorList.count() ) );
mComment->setText( tr( "%1 errors were found" ).arg( mErrorList.count() ) );
qgsInterface->mapCanvas()->refresh();
}
else
QMessageBox::information( this, "Topology fix error", "Fixing failed!" );
QMessageBox::information( this, tr( "Topology fix error" ), tr( "Fixing failed!" ) );
}

void checkDock::runTests( ValidateType type )
@@ -349,7 +342,7 @@ void checkDock::runTests( ValidateType type )
// test if layer1 is in the registry
if ( !(( QgsVectorLayer* )mLayerRegistry->mapLayers().contains( layer1Str ) ) )
{
std::cout << "CheckDock: layer " << layer1Str.toStdString() << " not found in registry!" << std::flush;
QgsMessageLog::logMessage( tr( "Layer %1 not found in registry." ).arg( layer1Str ), tr( "Topology plugin" ) );
return;
}

@@ -359,7 +352,7 @@ void checkDock::runTests( ValidateType type )
if (( QgsVectorLayer* )mLayerRegistry->mapLayers().contains( layer2Str ) )
layer2 = ( QgsVectorLayer* )mLayerRegistry->mapLayers()[layer2Str];

QProgressDialog progress( testName, "Abort", 0, layer1->featureCount(), this );
QProgressDialog progress( testName, tr( "Abort" ), 0, layer1->featureCount(), this );
progress.setWindowModality( Qt::WindowModal );

connect( &progress, SIGNAL( canceled() ), mTest, SLOT( setTestCancelled() ) );
@@ -414,7 +407,7 @@ void checkDock::validate( ValidateType type )
mRbErrorMarkers.clear();

runTests( type );
mComment->setText( QString( "%1 errors were found" ).arg( mErrorList.count() ) );
mComment->setText( tr( "%1 errors were found" ).arg( mErrorList.count() ) );

mRBFeature1->reset();
mRBFeature2->reset();
@@ -20,17 +20,20 @@

DockModel::DockModel( ErrorList& theErrorList, QObject *parent = 0 ) : mErrorlist( theErrorList )
{
Q_UNUSED( parent );
mHeader << "Error" << "Layer" << "Feature ID";

}

int DockModel::rowCount( const QModelIndex &parent ) const
{
Q_UNUSED( parent );
return mErrorlist.count();
}

int DockModel::columnCount( const QModelIndex &parent ) const
{
Q_UNUSED( parent );
return 3;
}

@@ -101,6 +104,9 @@ QVariant DockModel::data( const QModelIndex &index, int role ) const

bool DockModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
Q_UNUSED( index );
Q_UNUSED( value );
Q_UNUSED( role );
return false;
}

0 comments on commit 91fa062

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