Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 91fa062
Show file tree
Hide file tree
Showing 16 changed files with 541 additions and 676 deletions.
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/core/composer/qgscomposerlegend.cpp
Expand Up @@ -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;
Expand All @@ -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 )
Expand All @@ -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;

Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 )
{
Expand All @@ -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
Expand All @@ -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];
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgswmsserver.cpp
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/plugins/topology/CMakeLists.txt
Expand Up @@ -22,7 +22,6 @@ SET (topol_MOC_HDRS
checkDock.h
topolTest.h
dockModel.h
geosFunctions.h
)

SET (topol_RCCS topol.qrc)
Expand Down
41 changes: 17 additions & 24 deletions src/plugins/topology/checkDock.cpp
Expand Up @@ -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>
Expand All @@ -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;

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

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

Expand Down Expand Up @@ -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() )
{
Expand All @@ -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() )
{
Expand All @@ -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();
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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 )
Expand All @@ -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;
}

Expand All @@ -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() ) );
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/topology/dockModel.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 91fa062

Please sign in to comment.