1,308 changes: 674 additions & 634 deletions python/core/qgsvectorlayer.sip

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion python/plugins/db_manager/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def __init__(self, editor, db=None):
wordlist = QStringList()
for name, value in dictionary.iteritems():
wordlist << value
wordlist = QStringList() << list(set( wordlist )) # remove duplicates

# setup the completer
QCompleter.__init__(self, sorted(wordlist), editor)
self.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
self.setModelSorting(QCompleter.CaseSensitivelySortedModel)
self.setWrapAround(False)

if isinstance(editor, CompletionTextEdit):
Expand Down
14 changes: 13 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,5 +906,17 @@ def connection_error_types(self):

def getSqlDictionary(self):
from .sql_dictionary import getSqlDictionary
return getSqlDictionary()
sql_dict = getSqlDictionary()

# get schemas, tables and field names
items = []
sql = u"""SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_' AND nspname != 'information_schema'
UNION SELECT relname FROM pg_class WHERE relkind IN ('v', 'r')
UNION SELECT attname FROM pg_attribute WHERE attnum > 0"""
c = self._execute(None, sql)
for row in c.fetchall():
items.append( row[0] )

sql_dict["identifier"] = items
return sql_dict

12 changes: 11 additions & 1 deletion python/plugins/db_manager/db_plugins/spatialite/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,5 +593,15 @@ def connection_error_types(self):

def getSqlDictionary(self):
from .sql_dictionary import getSqlDictionary
return getSqlDictionary()
sql_dict = getSqlDictionary()

items = []
for tbl in self.getTables():
items.append( tbl[1] ) # table name

for fld in self.getTableFields( tbl[0] ):
items.append( fld[1] ) # field name

sql_dict["identifier"] = items
return sql_dict

51 changes: 51 additions & 0 deletions python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,57 @@ def pluginDirectory(packageName):
""" return directory where the plugin resides. Plugin must be loaded already """
return os.path.dirname(sys.modules[packageName].__file__)

def reloadProjectMacros():
# unload old macros
unloadProjectMacros()

from qgis.core import QgsProject
code, ok = QgsProject.instance().readEntry("Macros", "/pythonCode")
if not ok or code.isEmpty():
return

# create a new empty python module
import imp
mod = imp.new_module("proj_macros_mod")

# set the module code and store it sys.modules
exec unicode(code) in mod.__dict__
sys.modules["proj_macros_mod"] = mod

# load new macros
openProjectMacro()

def unloadProjectMacros():
if "proj_macros_mod" not in sys.modules:
return
# unload old macros
closeProjectMacro()
# destroy the reference to the module
del sys.modules["proj_macros_mod"]


def openProjectMacro():
if "proj_macros_mod" not in sys.modules:
return
mod = sys.modules["proj_macros_mod"]
if hasattr(mod, 'openProject'):
mod.openProject()

def saveProjectMacro():
if "proj_macros_mod" not in sys.modules:
return
mod = sys.modules["proj_macros_mod"]
if hasattr(mod, 'saveProject'):
mod.saveProject()

def closeProjectMacro():
if "proj_macros_mod" not in sys.modules:
return
mod = sys.modules["proj_macros_mod"]
if hasattr(mod, 'closeProject'):
mod.closeProject()


#######################
# IMPORT wrapper

Expand Down
Binary file modified resources/symbology-ng-style.db
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/symbol_xml2db.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

_colorramp = "CREATE TABLE colorramp("\
"id INTEGER PRIMARY KEY,"\
"name TEXT,"\
"name TEXT UNIQUE,"\
"xml TEXT,"\
"groupid INTEGER)"

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/network/qgsgraphbuilderintr.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
{
mDa.setSourceCrs( mCrs.srsid() );
mDa.setEllipsoid( ellipsoidID );
mDa.setProjectionsEnabled( ctfEnabled );
mDa.setEllipsoidalMode( ctfEnabled );
}

//! Destructor
Expand Down
3 changes: 3 additions & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SET(QGIS_APP_SRCS
qgsdecorationgriddialog.cpp
qgsembedlayerdialog.cpp
qgsformannotationdialog.cpp
qgshtmlannotationdialog.cpp
qgsdelattrdialog.cpp
qgsdisplayangle.cpp
qgsfieldcalculator.cpp
Expand All @@ -55,6 +56,7 @@ SET(QGIS_APP_SRCS
qgsmaptooledit.cpp
qgsmaptoolfeatureaction.cpp
qgsmaptoolformannotation.cpp
qgsmaptoolhtmlannotation.cpp
qgsmaptoolpinlabels.cpp
qgsmaptoolshowhidelabels.cpp
qgsmaptoolidentify.cpp
Expand Down Expand Up @@ -188,6 +190,7 @@ SET (QGIS_APP_MOC_HDRS
qgsfeatureaction.h
qgsfieldcalculator.h
qgsformannotationdialog.h
qgshtmlannotationdialog.h
qgsgraduatedsymboldialog.h
qgsidentifyresults.h
qgslabeldialog.h
Expand Down
14 changes: 14 additions & 0 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
viewMenu->addSeparator();
viewMenu->addAction( mActionRefreshView );

// Panel and toolbar submenus
mPanelMenu = new QMenu( tr( "Panels" ), this );
mPanelMenu->setObjectName( "mPanelMenu" );
mToolbarMenu = new QMenu( tr( "Toolbars" ), this );
mToolbarMenu->setObjectName( "mToolbarMenu" );
viewMenu->addSeparator();
viewMenu->addMenu( mPanelMenu );
viewMenu->addMenu( mToolbarMenu );
// toolBar already exists, add other widgets as they are created
mToolbarMenu->addAction( toolBar->toggleViewAction() );

QMenu *layoutMenu = menuBar()->addMenu( tr( "Layout" ) );
layoutMenu->addAction( mActionUndo );
layoutMenu->addAction( mActionRedo );
Expand Down Expand Up @@ -244,10 +255,13 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
setTabPosition( Qt::AllDockWidgetAreas, QTabWidget::North );
mGeneralDock = new QDockWidget( tr( "Composition" ), this );
mGeneralDock->setObjectName( "CompositionDock" );
mPanelMenu->addAction( mGeneralDock->toggleViewAction() );
mItemDock = new QDockWidget( tr( "Item Properties" ), this );
mItemDock->setObjectName( "ItemDock" );
mPanelMenu->addAction( mItemDock->toggleViewAction() );
mUndoDock = new QDockWidget( tr( "Command history" ), this );
mUndoDock->setObjectName( "CommandDock" );
mPanelMenu->addAction( mUndoDock->toggleViewAction() );

mGeneralDock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable );
mItemDock->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable );
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
QDockWidget* mItemDock;
QDockWidget* mUndoDock;
QDockWidget* mGeneralDock;

QMenu* mPanelMenu;
QMenu* mToolbarMenu;
};

#endif
18 changes: 12 additions & 6 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ int main( int argc, char *argv[] )
// The user can specify a path which will override the default path of custom
// user settings (~/.qgis) and it will be used for QSettings INI file
QString configpath;
QString optionpath;

#if defined(ANDROID)
QgsDebugMsg( QString( "Android: All params stripped" ) );// Param %1" ).arg( argv[0] ) );
Expand Down Expand Up @@ -318,8 +319,7 @@ int main( int argc, char *argv[] )
}
else if ( i + 1 < argc && ( arg == "--optionspath" || arg == "-o" ) )
{
QSettings::setDefaultFormat( QSettings::IniFormat );
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, argv[++i] );
optionpath = argv[++i];
}
else if ( i + 1 < argc && ( arg == "--configpath" || arg == "-c" ) )
{
Expand Down Expand Up @@ -421,8 +421,7 @@ int main( int argc, char *argv[] )
break;

case 'o':
QSettings::setDefaultFormat( QSettings::IniFormat );
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optarg );
optionpath = optarg;
break;

case 'c':
Expand Down Expand Up @@ -481,11 +480,11 @@ int main( int argc, char *argv[] )
exit( 1 ); //exit for now until a version of qgis is capabable of running non interactive
}

if ( !configpath.isEmpty() )
if ( !optionpath.isEmpty() || !configpath.isEmpty() )
{
// tell QSettings to use INI format and save the file in custom config path
QSettings::setDefaultFormat( QSettings::IniFormat );
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, configpath );
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optionpath.isEmpty() ? configpath : optionpath );
}

// GUI customization is enabled by default unless --nocustomization argument is used
Expand All @@ -505,6 +504,13 @@ int main( int argc, char *argv[] )
QCoreApplication::setApplicationName( "QGIS" );
QCoreApplication::setAttribute( Qt::AA_DontShowIconsInMenus, false );

if ( !optionpath.isEmpty() || !configpath.isEmpty() )
{
// tell QSettings to use INI format and save the file in custom config path
QSettings::setDefaultFormat( QSettings::IniFormat );
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optionpath.isEmpty() ? configpath : optionpath );
}

// Load and set possible default customization, must be done afterQgsApplication init and QSettings ( QCoreApplication ) init
QgsCustomization::instance()->loadDefault();

Expand Down
152 changes: 133 additions & 19 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
#include "qgsexception.h"
#include "qgsfeature.h"
#include "qgsformannotationitem.h"
#include "qgshtmlannotationitem.h"
#include "qgsgenericprojectionselector.h"
#include "qgsgpsinformationwidget.h"
#include "qgslabelinggui.h"
Expand All @@ -139,6 +140,7 @@
#include "qgsmaptip.h"
#include "qgsmergeattributesdialog.h"
#include "qgsmessageviewer.h"
#include "qgsmessagebar.h"
#include "qgsmimedatautils.h"
#include "qgsmessagelog.h"
#include "qgsmultibandcolorrenderer.h"
Expand Down Expand Up @@ -216,6 +218,7 @@
#include "qgsmaptooldeletevertex.h"
#include "qgsmaptoolfeatureaction.h"
#include "qgsmaptoolformannotation.h"
#include "qgsmaptoolhtmlannotation.h"
#include "qgsmaptoolidentify.h"
#include "qgsmaptoolmeasureangle.h"
#include "qgsmaptoolmovefeature.h"
Expand Down Expand Up @@ -455,16 +458,29 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
QSettings settings;
setFontSize( settings.value( "/fontPointSize", QGIS_DEFAULT_FONTSIZE ).toInt() );

QWidget *centralWidget = this->centralWidget();
QGridLayout *centralLayout = new QGridLayout( centralWidget );
centralWidget->setLayout( centralLayout );
centralLayout->setContentsMargins( 0, 0, 0, 0 );

// "theMapCanvas" used to find this canonical instance later
mMapCanvas = new QgsMapCanvas( this, "theMapCanvas" );
mMapCanvas = new QgsMapCanvas( centralWidget, "theMapCanvas" );
mMapCanvas->setWhatsThis( tr( "Map canvas. This is where raster and vector "
"layers are displayed when added to the map" ) );

// set canvas color right away
int myRed = settings.value( "/qgis/default_canvas_color_red", 255 ).toInt();
int myGreen = settings.value( "/qgis/default_canvas_color_green", 255 ).toInt();
int myBlue = settings.value( "/qgis/default_canvas_color_blue", 255 ).toInt();
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );
setCentralWidget( mMapCanvas );

centralLayout->addWidget( mMapCanvas, 0, 0, 2, 1 );

// a bar to warn the user with non-blocking messages
mInfoBar = new QgsMessageBar( centralWidget );
mInfoBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
centralLayout->addWidget( mInfoBar, 0, 0, 1, 1 );

//set the focus to the map canvas
mMapCanvas->setFocus();

Expand Down Expand Up @@ -493,6 +509,20 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
updateProjectFromTemplates();
activateDeactivateLayerRelatedActions( NULL );

// create the notification widget for macros
mMacrosWarn = QgsMessageBar::createMessage( tr( "Security warning:" ),
tr( "macros have been disabled." ),
QgsApplication::getThemeIcon( "/mIconWarn.png" ),
mInfoBar );

QToolButton *btnEnableMacros = new QToolButton( mMacrosWarn );
btnEnableMacros->setText( tr( "Enable" ) );
btnEnableMacros->setStyleSheet( "background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" );
btnEnableMacros->setCursor( Qt::PointingHandCursor );
connect( btnEnableMacros, SIGNAL( clicked() ), mInfoBar, SLOT( popWidget() ) );
connect( btnEnableMacros, SIGNAL( clicked() ), this, SLOT( enableProjectMacros() ) );
mMacrosWarn->layout()->addWidget( btnEnableMacros );

addDockWidget( Qt::LeftDockWidgetArea, mUndoWidget );
mUndoWidget->hide();

Expand Down Expand Up @@ -628,6 +658,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
QgsMessageLog::logMessage( tr( "QGIS Ready!" ) );

mMapTipsVisible = false;
mTrustedMacros = false;

// setup drag drop
setAcceptDrops( true );
Expand Down Expand Up @@ -699,6 +730,7 @@ QgisApp::~QgisApp()
delete mMapTools.mMeasureAngle;
delete mMapTools.mTextAnnotation;
delete mMapTools.mFormAnnotation;
delete mMapTools.mHtmlAnnotation;
delete mMapTools.mAnnotation;
delete mMapTools.mAddFeature;
delete mMapTools.mMoveFeature;
Expand Down Expand Up @@ -813,6 +845,13 @@ void QgisApp::readSettings()

// Add the recently accessed project file paths to the File menu
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();

// this is a new session! reset enable macros value to "ask"
// whether set to "just for this session"
if ( settings.value( "/qgis/enableMacros", 1 ).toInt() == 2 )
{
settings.setValue( "/qgis/enableMacros", 1 );
}
}


Expand Down Expand Up @@ -895,6 +934,7 @@ void QgisApp::createActions()
connect( mActionDraw, SIGNAL( triggered() ), this, SLOT( refreshMapCanvas() ) );
connect( mActionTextAnnotation, SIGNAL( triggered() ), this, SLOT( addTextAnnotation() ) );
connect( mActionFormAnnotation, SIGNAL( triggered() ), this, SLOT( addFormAnnotation() ) );
connect( mActionHtmlAnnotation, SIGNAL( triggered() ), this, SLOT( addHtmlAnnotation() ) );
connect( mActionAnnotation, SIGNAL( triggered() ), this, SLOT( modifyAnnotation() ) );
connect( mActionLabeling, SIGNAL( triggered() ), this, SLOT( labeling() ) );

Expand Down Expand Up @@ -1318,6 +1358,7 @@ void QgisApp::createToolBars()
bt->setPopupMode( QToolButton::MenuButtonPopup );
bt->addAction( mActionTextAnnotation );
bt->addAction( mActionFormAnnotation );
bt->addAction( mActionHtmlAnnotation );
bt->addAction( mActionAnnotation );

QAction* defAnnotationAction = mActionTextAnnotation;
Expand All @@ -1326,6 +1367,7 @@ void QgisApp::createToolBars()
case 0: defAnnotationAction = mActionTextAnnotation; break;
case 1: defAnnotationAction = mActionFormAnnotation; break;
case 2: defAnnotationAction = mActionAnnotation; break;
case 3: defAnnotationAction = mActionHtmlAnnotation; break;
}
bt->setDefaultAction( defAnnotationAction );
QAction* annotationAction = mAttributesToolBar->addWidget( bt );
Expand Down Expand Up @@ -1629,6 +1671,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionAddToOverview->setIcon( QgsApplication::getThemeIcon( "/mActionInOverview.png" ) );
mActionAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionAnnotation.png" ) );
mActionFormAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionFormAnnotation.png" ) );
mActionHtmlAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionFormAnnotation.png" ) );
mActionTextAnnotation->setIcon( QgsApplication::getThemeIcon( "/mActionTextAnnotation.png" ) );
mActionLabeling->setIcon( QgsApplication::getThemeIcon( "/mActionLabeling.png" ) );
mActionShowPinnedLabels->setIcon( QgsApplication::getThemeIcon( "/mActionShowPinnedLabels.svg" ) );
Expand Down Expand Up @@ -1757,6 +1800,8 @@ void QgisApp::createCanvasTools()
mMapTools.mTextAnnotation->setAction( mActionTextAnnotation );
mMapTools.mFormAnnotation = new QgsMapToolFormAnnotation( mMapCanvas );
mMapTools.mFormAnnotation->setAction( mActionFormAnnotation );
mMapTools.mHtmlAnnotation = new QgsMapToolHtmlAnnotation( mMapCanvas );
mMapTools.mHtmlAnnotation->setAction( mActionHtmlAnnotation );
mMapTools.mAnnotation = new QgsMapToolAnnotation( mMapCanvas );
mMapTools.mAnnotation->setAction( mActionAnnotation );
mMapTools.mAddFeature = new QgsMapToolAddFeature( mMapCanvas );
Expand Down Expand Up @@ -2456,7 +2501,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
return false;

zipItem->populate();
QgsDebugMsg( QString( "Got zipitem with %1 children" ).arg( zipItem->rowCount() ) );
QgsDebugMsg( QString( "Path= %1 got zipitem with %2 children" ).arg( path ).arg( zipItem->rowCount() ) );

// if 1 or 0 child found, exit so a normal item is created by gdal or ogr provider
if ( zipItem->rowCount() <= 1 )
Expand Down Expand Up @@ -2487,7 +2532,7 @@ bool QgisApp::askUserForZipItemLayers( QString path )
{
QgsDataItem *item = zipItem->children()[i];
QgsLayerItem *layerItem = dynamic_cast<QgsLayerItem *>( item );
QgsDebugMsg( QString( "item path=%1 provider=" ).arg( item->path() ).arg( layerItem->providerKey() ) );
QgsDebugMsgLevel( QString( "item path=%1 provider=" ).arg( item->path() ).arg( layerItem->providerKey() ), 2 );
if ( layerItem && layerItem->providerKey() == "gdal" )
{
layers << QString( "%1|%2| |%3" ).arg( i ).arg( item->name() ).arg( "Raster" );
Expand All @@ -2509,6 +2554,12 @@ bool QgisApp::askUserForZipItemLayers( QString path )
}
}

if ( childItems.isEmpty() )
{
// return true so dialog doesn't popup again (#6225) - hopefully this doesn't create other trouble
ok = true;
}

// add childItems
foreach ( QgsDataItem* item, childItems )
{
Expand Down Expand Up @@ -2943,10 +2994,7 @@ void QgisApp::fileExit()

if ( saveDirty() )
{
deletePrintComposers();
removeAnnotationItems();
mMapCanvas->freeze( true );
removeAllLayers();
closeProject();
qApp->exit( 0 );
}
}
Expand Down Expand Up @@ -2993,11 +3041,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
}
}

deletePrintComposers();
removeAnnotationItems();

mMapCanvas->freeze( true );
removeAllLayers();
closeProject();
mMapCanvas->clear();

QgsProject* prj = QgsProject::instance();
Expand Down Expand Up @@ -3179,6 +3223,8 @@ void QgisApp::fileOpen()
return;
}

closeProject();

// Fix by Tim - getting the dirPath from the dialog
// directly truncates the last node in the dir path.
// This is a workaround for that
Expand All @@ -3187,12 +3233,6 @@ void QgisApp::fileOpen()
// Persist last used project dir
settings.setValue( "/UI/lastProjectDir", myPath );

deletePrintComposers();
removeAnnotationItems();
// clear out any stuff from previous project
mMapCanvas->freeze( true );
removeAllLayers();

QgsProject::instance()->setFileName( fullPath );

if ( ! QgsProject::instance()->read() )
Expand All @@ -3213,6 +3253,26 @@ void QgisApp::fileOpen()
mScaleEdit->updateScales( QgsProject::instance()->readListEntry( "Scales", "/ScalesList" ) );
}

// does the project have any macros?
if ( mPythonUtils && mPythonUtils->isEnabled() )
{
if ( !QgsProject::instance()->readEntry( "Macros", "/pythonCode", QString::null ).isEmpty() )
{
int enableMacros = settings.value( "/qgis/enableMacros", 1 ).toInt();
// 0 = never, 1 = ask, 2 = just for this session, 3 = always

if ( enableMacros == 3 || enableMacros == 2 )
{
enableProjectMacros();
}
else if ( enableMacros == 1 ) // ask
{
// display the macros notification widget
mInfoBar->pushWidget( mMacrosWarn, 1 );
}
}
}

emit projectRead(); // let plug-ins know that we've read in a new
// project so that they can check any project
// specific plug-in state
Expand All @@ -3225,6 +3285,14 @@ void QgisApp::fileOpen()
}
} // QgisApp::fileOpen

void QgisApp::enableProjectMacros()
{
mTrustedMacros = true;

// load macros
QgsPythonRunner::run( "qgis.utils.reloadProjectMacros()" );
}


/**
adds a saved project to qgis, usually called on startup by specifying a
Expand Down Expand Up @@ -3364,6 +3432,13 @@ bool QgisApp::fileSave()
QgsProject::instance()->error() );
return false;
}

// run the saved project macro
if ( mTrustedMacros )
{
QgsPythonRunner::run( "qgis.utils.saveProjectMacro();" );
}

return true;
} // QgisApp::fileSave

Expand Down Expand Up @@ -3838,6 +3913,11 @@ void QgisApp::addFormAnnotation()
mMapCanvas->setMapTool( mMapTools.mFormAnnotation );
}

void QgisApp::addHtmlAnnotation()
{
mMapCanvas->setMapTool( mMapTools.mHtmlAnnotation );
}

void QgisApp::addTextAnnotation()
{
mMapCanvas->setMapTool( mMapTools.mTextAnnotation );
Expand Down Expand Up @@ -3997,6 +4077,11 @@ void QgisApp::saveAsRasterFile()
}
fileWriter.setCreateOptions( d.createOptions() );

fileWriter.setBuildPyramidsFlag( d.buildPyramidsFlag() );
fileWriter.setPyramidsList( d.overviewList() );
fileWriter.setPyramidsResampling( d.pyramidsResampling() );
fileWriter.setPyramidsFormat( d.pyramidsFormat() );

fileWriter.writeRaster( pipe, d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
delete pipe;
}
Expand Down Expand Up @@ -4360,6 +4445,13 @@ bool QgisApp::loadAnnotationItemsFromProject( const QDomDocument& doc )
QgsFormAnnotationItem* newFormItem = new QgsFormAnnotationItem( mMapCanvas );
newFormItem->readXML( doc, formItemList.at( i ).toElement() );
}

QDomNodeList htmlItemList = doc.elementsByTagName( "HtmlAnnotationItem" );
for ( int i = 0; i < htmlItemList.size(); ++i )
{
QgsHtmlAnnotationItem* newHtmlItem = new QgsHtmlAnnotationItem( mMapCanvas );
newHtmlItem->readXML( doc, htmlItemList.at( i ).toElement() );
}
return true;
}

Expand Down Expand Up @@ -5862,6 +5954,26 @@ bool QgisApp::saveDirty()
return answer != QMessageBox::Cancel;
} // QgisApp::saveDirty()

void QgisApp::closeProject()
{
// unload the project macros before changing anything
if ( mTrustedMacros )
{
QgsPythonRunner::run( "qgis.utils.unloadProjectMacros();" );
}

// remove the warning message from the bar if present
mInfoBar->popWidget( mMacrosWarn );

mTrustedMacros = false;

deletePrintComposers();
removeAnnotationItems();
// clear out any stuff from project
mMapCanvas->freeze( true );
removeAllLayers();
}


void QgisApp::changeEvent( QEvent* event )
{
Expand Down Expand Up @@ -7854,6 +7966,8 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
settings.setValue( "/UI/annotationTool", 1 );
else if ( action == mActionAnnotation )
settings.setValue( "/UI/annotationTool", 2 );
else if ( action == mActionHtmlAnnotation )
settings.setValue( "/UI/annotationTool", 3 );

bt->setDefaultAction( action );
}
Expand Down
17 changes: 16 additions & 1 deletion src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class QgsGPSInformationWidget;
class QgsDecorationItem;

class QgsMessageLogViewer;
class QgsMessageBar;

class QgsScaleComboBox;

Expand Down Expand Up @@ -815,6 +816,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
//annotations
void addFormAnnotation();
void addTextAnnotation();
void addHtmlAnnotation();
void modifyAnnotation();

//! shows label settings dialog (for labeling-ng)
Expand Down Expand Up @@ -888,6 +890,12 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void renderDecorationItems( QPainter *p );
void projectReadDecorationItems( );

//! clear out any stuff from project
void closeProject();

//! trust and load project macros
void enableProjectMacros();

signals:
/** emitted when a key is pressed and we want non widget sublasses to be able
to pick up on this (e.g. maplayer) */
Expand Down Expand Up @@ -972,7 +980,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
/**Deletes all the composer objects and clears mPrintComposers*/
void deletePrintComposers();


void saveAsVectorFileGeneral( bool saveOnlySelection );

/**Returns all annotation items in the canvas*/
Expand Down Expand Up @@ -1078,6 +1085,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QgsMapTool* mRotatePointSymbolsTool;
QgsMapTool* mAnnotation;
QgsMapTool* mFormAnnotation;
QgsMapTool* mHtmlAnnotation;
QgsMapTool* mTextAnnotation;
QgsMapTool* mPinLabels;
QgsMapTool* mShowHideLabels;
Expand Down Expand Up @@ -1228,6 +1236,13 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

QString mOldScale;

//! the user has trusted the project macros
bool mTrustedMacros;

//! a bar to display warnings in a non-blocker manner
QgsMessageBar *mInfoBar;
QWidget *mMacrosWarn;

#ifdef HAVE_TOUCH
bool gestureEvent( QGestureEvent *event );
void tapAndHoldTriggered( QTapAndHoldGesture *gesture );
Expand Down
56 changes: 53 additions & 3 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl )
}

connect( valueRelationLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateLayerColumns( int ) ) );
connect( valueRelationFilterColumn, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateFilterColumn( int ) ) );
valueRelationLayer->setCurrentIndex( -1 );
}

Expand Down Expand Up @@ -606,6 +607,16 @@ void QgsAttributeTypeDialog::accept()
mValueRelationData.mAllowNull = valueRelationAllowNull->isChecked();
mValueRelationData.mOrderByValue = valueRelationOrderByValue->isChecked();
mValueRelationData.mAllowMulti = valueRelationAllowMulti->isChecked();
if( valueRelationFilterColumn->currentIndex() == 0 )
{
mValueRelationData.mFilterAttributeColumn = QString::null;
mValueRelationData.mFilterAttributeValue = QString::null;
}
else
{
mValueRelationData.mFilterAttributeColumn = valueRelationFilterColumn->currentText();
mValueRelationData.mFilterAttributeValue = valueRelationFilterValue->currentText();
}
break;
case 13:
mEditType = QgsVectorLayer::UuidGenerator;
Expand All @@ -631,12 +642,51 @@ void QgsAttributeTypeDialog::updateLayerColumns( int idx )
if ( !vl )
return;

foreach ( const QgsField &f, vl->pendingFields() )
valueRelationFilterColumn->addItem( tr( "No filter" ), -1 );

const QgsFieldMap &fields = vl->pendingFields();
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
{
valueRelationKeyColumn->addItem( f.name() );
valueRelationValueColumn->addItem( f.name() );
valueRelationKeyColumn->addItem( it->name() );
valueRelationValueColumn->addItem( it->name() );
valueRelationFilterColumn->addItem( it->name(), it.key() );
}

valueRelationKeyColumn->setCurrentIndex( valueRelationKeyColumn->findText( mValueRelationData.mKey ) );
valueRelationValueColumn->setCurrentIndex( valueRelationValueColumn->findText( mValueRelationData.mValue ) );

if( mValueRelationData.mFilterAttributeColumn.isNull() )
{
valueRelationFilterColumn->setCurrentIndex( 0 );
}
else
{
valueRelationFilterColumn->setCurrentIndex( valueRelationFilterColumn->findText( mValueRelationData.mFilterAttributeColumn ) );
}
}

void QgsAttributeTypeDialog::updateFilterColumn( int idx )
{
valueRelationFilterValue->clear();
valueRelationFilterValue->setEnabled( idx > 0 );
if ( idx == 0 )
return;

QString id = valueRelationLayer->itemData( valueRelationLayer->currentIndex() ).toString();

QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( id ) );
if ( !vl )
return;

int fidx = valueRelationFilterColumn->itemData( idx ).toInt();

QList<QVariant> uniqueValues;
vl->uniqueValues( fidx, uniqueValues );

foreach( const QVariant &v, uniqueValues )
{
valueRelationFilterValue->addItem( v.toString(), v );
}

valueRelationFilterValue->setCurrentIndex( valueRelationFilterValue->findText( mValueRelationData.mFilterAttributeValue ) );
}
5 changes: 5 additions & 0 deletions src/app/qgsattributetypedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
void updateLayerColumns( int idx );

/**
* update filter value list
*/
void updateFilterColumn( int idx );

private:

QString defaultWindowTitle();
Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsdecorationgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
#include <cmath>


#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

#define FONT_WORKAROUND_SCALE 10 //scale factor for upscaling fontsize and downscaling painter


Expand Down Expand Up @@ -808,7 +804,7 @@ bool QgsDecorationGrid::getIntervalFromExtent( double* values, bool useXAxis )
int factor = pow( 10, floor( log10( interval ) ) );
if ( factor != 0 )
{
interval2 = round( interval / factor ) * factor;
interval2 = qRound( interval / factor ) * factor;
QgsDebugMsg( QString( "interval2: %1" ).arg( interval2 ) );
if ( interval2 != 0 )
interval = interval2;
Expand Down
6 changes: 1 addition & 5 deletions src/app/qgsdecorationnortharrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ email : tim@linfiniti.com
#include <cassert>


#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

const double QgsDecorationNorthArrow::PI = 3.14159265358979323846;
// const double QgsNorthArrowPlugin::DEG2RAD = 0.0174532925199433;
const double QgsDecorationNorthArrow::TOL = 1e-8;
Expand Down Expand Up @@ -298,7 +294,7 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
}
// And set the angle of the north arrow. Perhaps do something
// different if goodDirn = false.
mRotationInt = static_cast<int>( round( fmod( 360.0 - angle * 180.0 / PI, 360.0 ) ) );
mRotationInt = qRound( fmod( 360.0 - angle * 180.0 / PI, 360.0 ) );
}
else
{
Expand Down
7 changes: 1 addition & 6 deletions src/app/qgsdecorationscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ email : sbr00pwb@users.sourceforge.net
#include <cmath>


#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif


QgsDecorationScaleBar::QgsDecorationScaleBar( QObject* parent )
: QgsDecorationItem( parent )
{
Expand Down Expand Up @@ -164,7 +159,7 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
if ( mSnapping )
{
double scaler = pow( 10.0, myPowerOf10 );
myActualSize = round( myActualSize / scaler ) * scaler;
myActualSize = qRound( myActualSize / scaler ) * scaler;
myScaleBarWidth = myActualSize / myMapUnitsPerPixelDouble;
}

Expand Down
90 changes: 90 additions & 0 deletions src/app/qgshtmlannotationdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/***************************************************************************
QgsHTMLAnnotationDialog.cpp
---------------------
begin : March 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgshtmlannotationdialog.h"
#include "qgsannotationwidget.h"
#include "qgsvectorlayer.h"
#include <QFileDialog>
#include <QFileInfo>
#include <QGraphicsScene>

QgsHtmlAnnotationDialog::QgsHtmlAnnotationDialog( QgsHtmlAnnotationItem* item, QWidget * parent, Qt::WindowFlags f )
: QDialog( parent, f ), mItem( item ), mEmbeddedWidget( 0 )
{
setupUi( this );
mEmbeddedWidget = new QgsAnnotationWidget( mItem );
mEmbeddedWidget->show();
mStackedWidget->addWidget( mEmbeddedWidget );
mStackedWidget->setCurrentWidget( mEmbeddedWidget );

if ( item )
{
mFileLineEdit->setText( item->htmlPage() );
}

QObject::connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( applySettingsToItem() ) );
QPushButton* deleteButton = new QPushButton( tr( "Delete" ) );
QObject::connect( deleteButton, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );
}

QgsHtmlAnnotationDialog::~QgsHtmlAnnotationDialog()
{

}

void QgsHtmlAnnotationDialog::applySettingsToItem()
{
//apply settings from embedded item widget
if ( mEmbeddedWidget )
{
mEmbeddedWidget->apply();
}

if ( mItem )
{
mItem->setHTMLPage( mFileLineEdit->text() );
QgsVectorLayer* layer = mItem->vectorLayer();
if ( layer )
{
//set last used annotation form as default for the layer
//layer->setAnnotationForm( mFileLineEdit->text() );
}
mItem->update();
}
}

void QgsHtmlAnnotationDialog::on_mBrowseToolButton_clicked()
{
QString directory;
QFileInfo fi( mFileLineEdit->text() );
if ( fi.exists() )
{
directory = fi.absolutePath();
}
QString filename = QFileDialog::getOpenFileName( 0, tr( "html" ), directory, "*.html" );
mFileLineEdit->setText( filename );
}

void QgsHtmlAnnotationDialog::deleteItem()
{
QGraphicsScene* scene = mItem->scene();
if ( scene )
{
scene->removeItem( mItem );
}
delete mItem;
mItem = 0;
}

40 changes: 40 additions & 0 deletions src/app/qgshtmlannotationdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/***************************************************************************
qgsformannotationdialog.h
---------------------
begin : March 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QgsHTMLAnnotationDialog_H
#define QgsHTMLAnnotationDialog_H

#include "ui_qgsformannotationdialogbase.h"
#include "qgshtmlannotationitem.h"

class QgsAnnotationWidget;

class QgsHtmlAnnotationDialog: public QDialog, private Ui::QgsFormAnnotationDialogBase
{
Q_OBJECT
public:
QgsHtmlAnnotationDialog( QgsHtmlAnnotationItem* item, QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsHtmlAnnotationDialog();

private:
QgsHtmlAnnotationItem* mItem;
QgsAnnotationWidget* mEmbeddedWidget;

private slots:
void applySettingsToItem();
void on_mBrowseToolButton_clicked();
void deleteItem();
};

#endif // QgsHTMLAnnotationDialog_H
136 changes: 128 additions & 8 deletions src/app/qgslabelinggui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM

connect( btnTextColor, SIGNAL( clicked() ), this, SLOT( changeTextColor() ) );
connect( btnChangeFont, SIGNAL( clicked() ), this, SLOT( changeTextFont() ) );
connect( mFontSizeUnitComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updatePreview() ) );
connect( mFontTranspSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ) );
connect( chkBuffer, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ) );
connect( btnBufferColor, SIGNAL( clicked() ), this, SLOT( changeBufferColor() ) );
Expand Down Expand Up @@ -85,6 +84,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
lyr.readFromLayer( layer );
populateFieldNames();
populateDataDefinedCombos( lyr );
populateFontCapitalsComboBox();

chkEnableLabeling->setChecked( lyr.enabled );
mTabWidget->setEnabled( lyr.enabled );
Expand All @@ -97,18 +97,36 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM

// placement
int distUnitIndex = lyr.distInMapUnits ? 1 : 0;
mXQuadOffset = lyr.xQuadOffset;
mYQuadOffset = lyr.yQuadOffset;
switch ( lyr.placement )
{
case QgsPalLayerSettings::AroundPoint:
radAroundPoint->setChecked( true );
radAroundCentroid->setChecked( true );
spinDistPoint->setValue( lyr.dist );
mPointDistanceUnitComboBox->setCurrentIndex( distUnitIndex );
//spinAngle->setValue(lyr.angle);
//spinAngle->setValue( lyr.angle );
break;
case QgsPalLayerSettings::OverPoint:
radOverPoint->setChecked( true );
radOverCentroid->setChecked( true );

mPointOffsetRadioAboveLeft->setChecked( mXQuadOffset == -1 && mYQuadOffset == 1 );
mPointOffsetRadioAbove->setChecked( mXQuadOffset == 0 && mYQuadOffset == 1 );
mPointOffsetRadioAboveRight->setChecked( mXQuadOffset == 1 && mYQuadOffset == 1 );
mPointOffsetRadioLeft->setChecked( mXQuadOffset == -1 && mYQuadOffset == 0 );
mPointOffsetRadioOver->setChecked( mXQuadOffset == 0 && mYQuadOffset == 0 );
mPointOffsetRadioRight->setChecked( mXQuadOffset == 1 && mYQuadOffset == 0 );
mPointOffsetRadioBelowLeft->setChecked( mXQuadOffset == -1 && mYQuadOffset == -1 );
mPointOffsetRadioBelow->setChecked( mXQuadOffset == 0 && mYQuadOffset == -1 );
mPointOffsetRadioBelowRight->setChecked( mXQuadOffset == 1 && mYQuadOffset == -1 );

mPointOffsetXOffsetSpinBox->setValue( lyr.xOffset );
mPointOffsetYOffsetSpinBox->setValue( lyr.yOffset );
mPointOffsetUnitsComboBox->setCurrentIndex( lyr.labelOffsetInMapUnits ? 1 : 0 );
mPointOffsetAngleSpinBox->setValue( lyr.angleOffset );

break;
case QgsPalLayerSettings::Line:
radLineParallel->setChecked( true );
Expand Down Expand Up @@ -203,7 +221,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
}

mRefFont = lyr.textFont;
mFontSizeSpinBox->setValue( mRefFont.pointSizeF() );
mFontSizeSpinBox->setValue( lyr.textFont.pointSizeF() );
btnTextColor->setColor( lyr.textColor );
mFontTranspSpinBox->setValue( lyr.textTransp );

Expand Down Expand Up @@ -231,6 +249,18 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
{
connect( placementRadios[i], SIGNAL( toggled( bool ) ), this, SLOT( updateOptions() ) );
}

// setup connections for label quadrant offsets
QRadioButton* quadrantRadios[] =
{
mPointOffsetRadioAboveLeft, mPointOffsetRadioAbove, mPointOffsetRadioAboveRight,
mPointOffsetRadioLeft, mPointOffsetRadioOver, mPointOffsetRadioRight,
mPointOffsetRadioBelowLeft, mPointOffsetRadioBelow, mPointOffsetRadioBelowRight
};
for ( unsigned int i = 0; i < sizeof( quadrantRadios ) / sizeof( QRadioButton* ); i++ )
{
connect( quadrantRadios[i], SIGNAL( toggled( bool ) ), this, SLOT( updateQuadrant() ) );
}
}

QgsLabelingGui::~QgsLabelingGui()
Expand Down Expand Up @@ -270,6 +300,13 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
|| ( stackedPlacement->currentWidget() == pagePolygon && radOverCentroid->isChecked() ) )
{
lyr.placement = QgsPalLayerSettings::OverPoint;

lyr.xQuadOffset = mXQuadOffset;
lyr.yQuadOffset = mYQuadOffset;
lyr.xOffset = mPointOffsetXOffsetSpinBox->value();
lyr.yOffset = mPointOffsetYOffsetSpinBox->value();
lyr.labelOffsetInMapUnits = ( mPointOffsetUnitsComboBox->currentIndex() == 1 );
lyr.angleOffset = mPointOffsetAngleSpinBox->value();
}
else if (( stackedPlacement->currentWidget() == pageLine && radLineParallel->isChecked() )
|| ( stackedPlacement->currentWidget() == pagePolygon && radPolygonPerimeter->isChecked() )
Expand Down Expand Up @@ -509,6 +546,11 @@ void QgsLabelingGui::changeTextColor()

void QgsLabelingGui::changeTextFont()
{
// store properties of QFont that might be stripped by font dialog
QFont::Capitalization captials = mRefFont.capitalization();
double wordspacing = mRefFont.wordSpacing();
double letterspacing = mRefFont.letterSpacing();

bool ok;
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
// Native Mac dialog works only for Qt Carbon
Expand All @@ -527,6 +569,12 @@ void QgsLabelingGui::changeTextFont()
{
mFontSizeSpinBox->setValue( font.pointSizeF() );
}

// reassign possibly stripped QFont properties
font.setCapitalization( captials );
font.setWordSpacing( wordspacing );
font.setLetterSpacing( QFont::AbsoluteSpacing, letterspacing );

updateFont( font );
}
}
Expand All @@ -535,9 +583,11 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle )
{
QFont styledfont;
bool foundmatch = false;
int fontSize = 12; // QFontDatabase::font() needs an integer for size
if ( !fontstyle.isEmpty() )
{
styledfont = mFontDB.font( mRefFont.family(), fontstyle, mRefFont.pointSizeF() );
styledfont = mFontDB.font( mRefFont.family(), fontstyle, fontSize );
styledfont.setPointSizeF( mRefFont.pointSizeF() );
if ( QApplication::font().toString() != styledfont.toString() )
{
foundmatch = true;
Expand All @@ -547,7 +597,8 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle )
{
foreach ( const QString &style, mFontDB.styles( mRefFont.family() ) )
{
styledfont = mFontDB.font( mRefFont.family(), style, mRefFont.pointSizeF() );
styledfont = mFontDB.font( mRefFont.family(), style, fontSize );
styledfont.setPointSizeF( mRefFont.pointSizeF() );
styledfont = styledfont.resolve( mRefFont );
if ( mRefFont.toString() == styledfont.toString() )
{
Expand All @@ -558,8 +609,12 @@ void QgsLabelingGui::updateFontViaStyle( const QString & fontstyle )
}
if ( foundmatch )
{
// styledfont.setPointSizeF( mRefFont.pointSizeF() );
styledfont.setCapitalization( mRefFont.capitalization() );
styledfont.setUnderline( mRefFont.underline() );
styledfont.setStrikeOut( mRefFont.strikeOut() );
styledfont.setWordSpacing( mRefFont.wordSpacing() );
styledfont.setLetterSpacing( QFont::AbsoluteSpacing, mRefFont.letterSpacing() );
mRefFont = styledfont;
}
// if no match, style combobox will be left blank, which should not affect engine labeling
Expand All @@ -578,7 +633,7 @@ void QgsLabelingGui::updateFont( QFont font )
bool missing = false;
if ( QApplication::font().toString() != mRefFont.toString() )
{
QFont testfont = mFontDB.font( mRefFont.family(), mFontDB.styleString( mRefFont ), mRefFont.pointSizeF() );
QFont testfont = mFontDB.font( mRefFont.family(), mFontDB.styleString( mRefFont ), 12 );
if ( QApplication::font().toString() == testfont.toString() )
{
missing = true;
Expand All @@ -598,12 +653,16 @@ void QgsLabelingGui::updateFont( QFont font )

blockFontChangeSignals( true );
populateFontStyleComboBox();
int idx = mFontCapitalsComboBox->findData( QVariant(( unsigned int ) mRefFont.capitalization() ) );
mFontCapitalsComboBox->setCurrentIndex( idx == -1 ? 0 : idx );
mFontUnderlineBtn->setChecked( mRefFont.underline() );
mFontStrikethroughBtn->setChecked( mRefFont.strikeOut() );
mFontWordSpacingSpinBox->setValue( mRefFont.wordSpacing() );
mFontLetterSpacingSpinBox->setValue( mRefFont.letterSpacing() );
blockFontChangeSignals( false );

// update font name with font face
// font.setPixelSize( 18 );
// font.setPixelSize( 24 );
// lblFontName->setFont( QFont( font ) );

updatePreview();
Expand All @@ -612,8 +671,11 @@ void QgsLabelingGui::updateFont( QFont font )
void QgsLabelingGui::blockFontChangeSignals( bool blk )
{
mFontStyleComboBox->blockSignals( blk );
mFontCapitalsComboBox->blockSignals( blk );
mFontUnderlineBtn->blockSignals( blk );
mFontStrikethroughBtn->blockSignals( blk );
mFontWordSpacingSpinBox->blockSignals( blk );
mFontLetterSpacingSpinBox->blockSignals( blk );
}

void QgsLabelingGui::updatePreview()
Expand All @@ -622,6 +684,7 @@ void QgsLabelingGui::updatePreview()
lblFontPreview->setFont( mRefFont );
QFont previewFont = lblFontPreview->font();
double fontSize = mFontSizeSpinBox->value();
double previewRatio = mPreviewSize / fontSize;
double bufferSize = 0.0;
QString grpboxtitle;

Expand All @@ -632,11 +695,14 @@ void QgsLabelingGui::updatePreview()
mPreviewSizeSlider->setEnabled( true );
grpboxtitle = tr( "Sample @ %1 pts (using map units)" ).arg( mPreviewSize );

previewFont.setWordSpacing( previewRatio * mFontWordSpacingSpinBox->value() );
previewFont.setLetterSpacing( QFont::AbsoluteSpacing, previewRatio * mFontLetterSpacingSpinBox->value() );

if ( chkBuffer->isChecked() )
{
if ( mBufferUnitComboBox->currentIndex() == 1 ) // map units
{
bufferSize = ( mPreviewSize / fontSize ) * spinBufferSize->value() / 2.5;
bufferSize = previewRatio * spinBufferSize->value() / 3.527;
}
else // millimeters
{
Expand Down Expand Up @@ -757,6 +823,11 @@ void QgsLabelingGui::updateOptions()
{
stackedOptions->setCurrentWidget( pageOptionsPoint );
}
else if (( stackedPlacement->currentWidget() == pagePoint && radOverPoint->isChecked() )
|| ( stackedPlacement->currentWidget() == pagePolygon && radOverCentroid->isChecked() ) )
{
stackedOptions->setCurrentWidget( pageOptionsPointOffset );
}
else if (( stackedPlacement->currentWidget() == pageLine && radLineParallel->isChecked() )
|| ( stackedPlacement->currentWidget() == pagePolygon && radPolygonPerimeter->isChecked() )
|| ( stackedPlacement->currentWidget() == pageLine && radLineCurved->isChecked() ) )
Expand All @@ -769,6 +840,32 @@ void QgsLabelingGui::updateOptions()
}
}

void QgsLabelingGui::updateQuadrant()
{
if ( mPointOffsetRadioAboveLeft->isChecked() ) { mXQuadOffset = -1; mYQuadOffset = 1; };
if ( mPointOffsetRadioAbove->isChecked() ) { mXQuadOffset = 0; mYQuadOffset = 1; };
if ( mPointOffsetRadioAboveRight->isChecked() ) { mXQuadOffset = 1; mYQuadOffset = 1; };

if ( mPointOffsetRadioLeft->isChecked() ) { mXQuadOffset = -1; mYQuadOffset = 0; };
if ( mPointOffsetRadioOver->isChecked() ) { mXQuadOffset = 0; mYQuadOffset = 0; };
if ( mPointOffsetRadioRight->isChecked() ) { mXQuadOffset = 1; mYQuadOffset = 0; };

if ( mPointOffsetRadioBelowLeft->isChecked() ) { mXQuadOffset = -1; mYQuadOffset = -1; };
if ( mPointOffsetRadioBelow->isChecked() ) { mXQuadOffset = 0; mYQuadOffset = -1; };
if ( mPointOffsetRadioBelowRight->isChecked() ) { mXQuadOffset = 1; mYQuadOffset = -1; };
}

void QgsLabelingGui::populateFontCapitalsComboBox()
{
mFontCapitalsComboBox->addItem( tr( "Mixed Case" ), QVariant( 0 ) );
mFontCapitalsComboBox->addItem( tr( "All Uppercase" ), QVariant( 1 ) );
mFontCapitalsComboBox->addItem( tr( "All Lowercase" ), QVariant( 2 ) );
// Small caps doesn't work right with QPainterPath::addText()
// https://bugreports.qt-project.org/browse/QTBUG-13965
// mFontCapitalsComboBox->addItem( tr( "Small Caps" ), QVariant( 3 ) );
mFontCapitalsComboBox->addItem( tr( "Title Case" ), QVariant( 4 ) );
}

void QgsLabelingGui::populateFontStyleComboBox()
{
mFontStyleComboBox->clear();
Expand All @@ -791,6 +888,13 @@ void QgsLabelingGui::on_mFontSizeSpinBox_valueChanged( double d )
updateFont( mRefFont );
}

void QgsLabelingGui::on_mFontCapitalsComboBox_currentIndexChanged( int index )
{
int capitalsindex = mFontCapitalsComboBox->itemData( index ).toUInt();
mRefFont.setCapitalization(( QFont::Capitalization ) capitalsindex );
updateFont( mRefFont );
}

void QgsLabelingGui::on_mFontStyleComboBox_currentIndexChanged( const QString & text )
{
updateFontViaStyle( text );
Expand Down Expand Up @@ -821,13 +925,29 @@ void QgsLabelingGui::on_mFontLetterSpacingSpinBox_valueChanged( double spacing )
updateFont( mRefFont );
}

void QgsLabelingGui::on_mFontSizeUnitComboBox_currentIndexChanged( int index )
{
double singleStep = ( index == 1 ) ? 10.0 : 1.0 ; //10 for map units, 1 for mm
mFontSizeSpinBox->setSingleStep( singleStep );
mFontWordSpacingSpinBox->setSingleStep( singleStep );
mFontLetterSpacingSpinBox->setSingleStep( singleStep / 10 );
updateFont( mRefFont );
}

void QgsLabelingGui::on_mBufferUnitComboBox_currentIndexChanged( int index )
{
double singleStep = ( index == 1 ) ? 1.0 : 0.1 ; //1.0 for map units, 0.1 for mm
spinBufferSize->setSingleStep( singleStep );
updateFont( mRefFont );
}

void QgsLabelingGui::on_mPointOffsetUnitsComboBox_currentIndexChanged( int index )
{
double singleStep = ( index == 1 ) ? 1.0 : 0.1 ; //1.0 for map units, 0.1 for mm
mPointOffsetXOffsetSpinBox->setSingleStep( singleStep );
mPointOffsetYOffsetSpinBox->setSingleStep( singleStep );
}

void QgsLabelingGui::on_mXCoordinateComboBox_currentIndexChanged( const QString & text )
{
if ( text.isEmpty() ) //no data defined alignment without data defined position
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgslabelinggui.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
void updatePreview();
void scrollPreview();
void updateOptions();
void updateQuadrant();

void on_mPreviewSizeSlider_valueChanged( int i );
void on_mFontSizeSpinBox_valueChanged( double d );
void on_mFontCapitalsComboBox_currentIndexChanged( int index );
void on_mFontStyleComboBox_currentIndexChanged( const QString & text );
void on_mFontUnderlineBtn_toggled( bool ckd );
void on_mFontStrikethroughBtn_toggled( bool ckd );
void on_mFontWordSpacingSpinBox_valueChanged( double spacing );
void on_mFontLetterSpacingSpinBox_valueChanged( double spacing );
void on_mFontSizeUnitComboBox_currentIndexChanged( int index );
void on_mBufferUnitComboBox_currentIndexChanged( int index );
void on_mPointOffsetUnitsComboBox_currentIndexChanged( int index );
void on_mXCoordinateComboBox_currentIndexChanged( const QString & text );
void on_mYCoordinateComboBox_currentIndexChanged( const QString & text );

Expand All @@ -69,6 +73,7 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
void blockFontChangeSignals( bool blk );
void setPreviewBackground( QColor color );
void updateFontViaStyle( const QString & fontstyle );
void populateFontCapitalsComboBox();
void populateFontStyleComboBox();
void populatePlacementMethods();
void populateFieldNames();
Expand All @@ -88,6 +93,9 @@ class QgsLabelingGui : public QWidget, private Ui::QgsLabelingGuiBase
QFont mRefFont;
int mPreviewSize;

int mXQuadOffset;
int mYQuadOffset;

void disableDataDefinedAlignment();
void enableDataDefinedAlignment();
};
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgsmaptoolannotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "qgsmaptoolannotation.h"
#include "qgsformannotationdialog.h"
#include "qgsformannotationitem.h"
#include "qgshtmlannotationitem.h"
#include "qgshtmlannotationdialog.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgstextannotationdialog.h"
Expand Down Expand Up @@ -60,6 +62,12 @@ QDialog* QgsMapToolAnnotation::createItemEditor( QgsAnnotationItem *item )
return new QgsFormAnnotationDialog( fItem );
}

QgsHtmlAnnotationItem* hItem = dynamic_cast<QgsHtmlAnnotationItem*>( item );
if ( hItem )
{
return new QgsHtmlAnnotationDialog( hItem );
}

return 0;
}

Expand Down
53 changes: 53 additions & 0 deletions src/app/qgsmaptoolhtmlannotation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/***************************************************************************
qgsmaptoolformannotation.cpp
-------------------------------
begin : February 9, 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at hugis dot net
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsmaptoolhtmlannotation.h"
#include "qgshtmlannotationitem.h"
#include "qgsmapcanvas.h"
#include "qgsvectorlayer.h"
#include <QMouseEvent>

QgsMapToolHtmlAnnotation::QgsMapToolHtmlAnnotation( QgsMapCanvas* canvas ): QgsMapToolAnnotation( canvas )
{

}

QgsMapToolHtmlAnnotation::~QgsMapToolHtmlAnnotation()
{

}

QgsAnnotationItem* QgsMapToolHtmlAnnotation::createItem( QMouseEvent* e )
{
//try to associate the current vector layer and a feature to the form item
QgsVectorLayer* currentVectorLayer = 0;
if ( mCanvas )
{
QgsMapLayer* mLayer = mCanvas->currentLayer();
if ( mLayer )
{
currentVectorLayer = dynamic_cast<QgsVectorLayer*>( mLayer );
}
}

QgsHtmlAnnotationItem* formItem = new QgsHtmlAnnotationItem( mCanvas, currentVectorLayer );
formItem->setMapPosition( toMapCoordinates( e->pos() ) );
formItem->setSelected( true );
formItem->setFrameSize( QSizeF( 200, 100 ) );
return formItem;
}

33 changes: 33 additions & 0 deletions src/app/qgsmaptoolhtmlannotation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/***************************************************************************
QgsMapToolHtmlAnnotation.h
-----------------------------
begin : February 9, 2010
copyright : (C) 2010 by Marco Hugentobler
email : marco dot hugentobler at hugis dot net
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSMAPTOOLHTMLANNOTATION_H
#define QGSMAPTOOLHTMLANNOTATION_H

#include "qgsmaptoolannotation.h"

class QgsMapToolHtmlAnnotation: public QgsMapToolAnnotation
{
public:
QgsMapToolHtmlAnnotation( QgsMapCanvas* canvas );
~QgsMapToolHtmlAnnotation();

protected:
QgsAnnotationItem* createItem( QMouseEvent* e );
};

#endif // QgsMapToolHtmlAnnotation_H
36 changes: 8 additions & 28 deletions src/app/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
QgsDistanceArea calc;
if ( !featureList.count() == 0 )
{
calc.setProjectionsEnabled( mCanvas->hasCrsTransformEnabled() ); // project?
calc.setEllipsoidalMode( mCanvas->hasCrsTransformEnabled() );
calc.setEllipsoid( ellipsoid );
calc.setSourceCrs( layer->crs().srsid() );
}
Expand Down Expand Up @@ -387,43 +387,23 @@ void QgsMapToolIdentify::convertMeasurement( QgsDistanceArea &calc, double &meas
// Helper for converting between meters and feet
// The parameter &u is out only...

// Get the canvas units
QGis::UnitType myUnits = mCanvas->mapUnits();
if (( myUnits == QGis::Degrees || myUnits == QGis::Feet ) &&
calc.ellipsoid() != "NONE" &&
calc.hasCrsTransformEnabled() )
{
// Measuring on an ellipsoid returns meters, and so does using projections???
myUnits = QGis::Meters;
QgsDebugMsg( "We're measuring on an ellipsoid or using projections, the system is returning meters" );
}

// Get the units for display
QSettings settings;
QString myDisplayUnitsTxt = settings.value( "/qgis/measure/displayunits", "meters" ).toString();

// Only convert between meters and feet
if ( myUnits == QGis::Meters && myDisplayUnitsTxt == "feet" )
QGis::UnitType displayUnits;
if ( myDisplayUnitsTxt == "feet" )
{
QgsDebugMsg( QString( "Converting %1 meters" ).arg( QString::number( measure ) ) );
measure /= 0.3048;
if ( isArea )
{
measure /= 0.3048;
}
QgsDebugMsg( QString( "to %1 feet" ).arg( QString::number( measure ) ) );
myUnits = QGis::Feet;
displayUnits = QGis::Feet;
}
if ( myUnits == QGis::Feet && myDisplayUnitsTxt == "meters" )
else
{
QgsDebugMsg( QString( "Converting %1 feet" ).arg( QString::number( measure ) ) );
measure *= 0.3048;
if ( isArea )
{
measure *= 0.3048;
}
QgsDebugMsg( QString( "to %1 meters" ).arg( QString::number( measure ) ) );
myUnits = QGis::Meters;
displayUnits = QGis::Meters;
}

calc.convertMeasurement( measure, myUnits, displayUnits, isArea );
u = myUnits;
}
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolmeasureangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void QgsMapToolMeasureAngle::configureDistanceArea()
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
mDa.setSourceCrs( mCanvas->mapRenderer()->destinationCrs().srsid() );
mDa.setEllipsoid( ellipsoidId );
mDa.setProjectionsEnabled( mResultDisplay->projectionEnabled() );
mDa.setEllipsoidalMode( mResultDisplay->projectionEnabled() ); // FIXME (not when proj is turned off)
}


Expand Down
111 changes: 60 additions & 51 deletions src/app/qgsmeasuredialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,19 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
else
mcbProjectionEnabled->setCheckState( Qt::Unchecked );

// Update when the ellipsoidal button has changed state.
connect( mcbProjectionEnabled, SIGNAL( stateChanged( int ) ),
this, SLOT( changeProjectionEnabledState() ) );
// Update whenever the canvas has refreshed. Maybe more often than needed,
// but at least every time any settings changes
connect( mTool->canvas(), SIGNAL( mapCanvasRefreshed() ),
this, SLOT( changeProjectionEnabledState() ) );
// Update when project wide transformation has changed
connect( mTool->canvas()->mapRenderer(), SIGNAL( hasCrsTransformEnabled( bool ) ),
this, SLOT( changeProjectionEnabledState() ) );
// Update when project CRS has changed
connect( mTool->canvas()->mapRenderer(), SIGNAL( destinationSrsChanged() ),
this, SLOT( changeProjectionEnabledState() ) );

updateUi();
}
Expand Down Expand Up @@ -118,6 +129,7 @@ void QgsMeasureDialog::mouseMove( QgsPoint &point )
convertMeasurement( d, myDisplayUnits, false );
QTreeWidgetItem *item = mTable->topLevelItem( mTable->topLevelItemCount() - 1 );
item->setText( 0, QLocale::system().toString( d, 'f', decimalPlaces ) );
QgsDebugMsg( QString( "Final result is %1" ).arg( item->text( 0 ) ) );
}
}

Expand Down Expand Up @@ -214,28 +226,49 @@ QString QgsMeasureDialog::formatArea( double area, int decimalPlaces )

void QgsMeasureDialog::updateUi()
{
// Only enable checkbox when project wide transformation is on
mcbProjectionEnabled->setEnabled( mTool->canvas()->hasCrsTransformEnabled() );

configureDistanceArea();

QSettings settings;
int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();

double dummy = 1.0;
QGis::UnitType myDisplayUnits;
// The dummy distance is ignored
convertMeasurement( dummy, myDisplayUnits, false );
// Set tooltip to indicate how we calculate measurments
QGis::UnitType mapUnits = mTool->canvas()->mapUnits();
QGis::UnitType displayUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );

switch ( myDisplayUnits )
QString toolTip = tr( "The calculations are based on:" );
if ( ! mTool->canvas()->hasCrsTransformEnabled() )
{
case QGis::Meters:
mTable->setHeaderLabels( QStringList( tr( "Segments (in meters)" ) ) );
break;
case QGis::Feet:
mTable->setHeaderLabels( QStringList( tr( "Segments (in feet)" ) ) );
break;
case QGis::Degrees:
mTable->setHeaderLabels( QStringList( tr( "Segments (in degrees)" ) ) );
break;
case QGis::UnknownUnit:
mTable->setHeaderLabels( QStringList( tr( "Segments" ) ) );
toolTip += "<br> * " + tr( "Project CRS transformation is turned off." ) + " ";
toolTip += tr( "Canvas units setting is taken from project properties setting (%1)." ).arg( QGis::tr( mapUnits ) );
toolTip += "<br> * " + tr( "Ellipsoidal calculation is not possible, as project CRS is undefined." );
}
else
{
if ( mDa.ellipsoidalEnabled() )
{
toolTip += "<br> * " + tr( "Project CRS transformation is turned on and ellipsoidal calculation is selected." ) + " ";
toolTip += "<br> * " + tr( "The coordinates are transformed to the chosen ellipsoid (%1), and the result is in meters" ).arg( mDa.ellipsoid() );
}
else
{
toolTip += "<br> * " + tr( "Project CRS transformation is turned on but ellipsoidal calculation is not selected." );
toolTip += "<br> * " + tr( "The canvas units setting is taken from the project CRS (%1)." ).arg( QGis::tr( mapUnits ) );
}
}

if (( mapUnits == QGis::Meters && displayUnits == QGis::Feet ) || ( mapUnits == QGis::Feet && displayUnits == QGis::Meters ) )
{
toolTip += "<br> * " + tr( "Finally, the value is converted from %2 to %3." ).arg( QGis::tr( mapUnits ) ).arg( QGis::tr( displayUnits ) );
}

editTotal->setToolTip( toolTip );
mTable->setToolTip( toolTip );

int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();

mTable->setHeaderLabels( QStringList( tr( "Segments [%1]" ).arg( QGis::tr( displayUnits ) ) ) );

if ( mMeasureArea )
{
Expand All @@ -247,52 +280,23 @@ void QgsMeasureDialog::updateUi()
mTable->show();
editTotal->setText( formatDistance( 0, decimalPlaces ) );
}

configureDistanceArea();
}

void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, bool isArea )
{
// Helper for converting between meters and feet
// The parameter &u is out only...

// Get the canvas units
QGis::UnitType myUnits = mTool->canvas()->mapUnits();
if (( myUnits == QGis::Degrees || myUnits == QGis::Feet ) &&
mcbProjectionEnabled->isChecked() )
{
// Measuring on an ellipsoid returns meters, and so does using projections???
myUnits = QGis::Meters;
QgsDebugMsg( "We're measuring on an ellipsoid or using projections, the system is returning meters" );
}

// Get the units for display
QSettings settings;
QString myDisplayUnitsTxt = settings.value( "/qgis/measure/displayunits", "meters" ).toString();
QGis::UnitType displayUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );

// Only convert between meters and feet
if ( myUnits == QGis::Meters && myDisplayUnitsTxt == "feet" )
{
QgsDebugMsg( QString( "Converting %1 meters" ).arg( QString::number( measure ) ) );
measure /= 0.3048;
if ( isArea )
{
measure /= 0.3048;
}
QgsDebugMsg( QString( "to %1 feet" ).arg( QString::number( measure ) ) );
myUnits = QGis::Feet;
}
if ( myUnits == QGis::Feet && myDisplayUnitsTxt == "meters" )
{
QgsDebugMsg( QString( "Converting %1 feet" ).arg( QString::number( measure ) ) );
measure *= 0.3048;
if ( isArea )
{
measure *= 0.3048;
}
QgsDebugMsg( QString( "to %1 meters" ).arg( QString::number( measure ) ) );
myUnits = QGis::Meters;
}
QgsDebugMsg( QString( "Preferred display units are %1" ).arg( QGis::toLiteral( displayUnits ) ) );

mDa.convertMeasurement( measure, myUnits, displayUnits, isArea );
u = myUnits;
}

Expand All @@ -301,9 +305,13 @@ void QgsMeasureDialog::changeProjectionEnabledState()
// store value
QSettings settings;
if ( mcbProjectionEnabled->isChecked() )
{
settings.setValue( "/qgis/measure/projectionEnabled", 2 );
}
else
{
settings.setValue( "/qgis/measure/projectionEnabled", 0 );
}

// clear interface
mTable->clear();
Expand Down Expand Up @@ -362,5 +370,6 @@ void QgsMeasureDialog::configureDistanceArea()
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
mDa.setSourceCrs( mTool->canvas()->mapRenderer()->destinationCrs().srsid() );
mDa.setEllipsoid( ellipsoidId );
mDa.setProjectionsEnabled( mcbProjectionEnabled->isChecked() );
// Only use ellipsoidal calculation when project wide transformation is enabled.
mDa.setEllipsoidalMode( mcbProjectionEnabled->isChecked() && mTool->canvas()->hasCrsTransformEnabled() );
}
4 changes: 2 additions & 2 deletions src/app/qgsmeasuredialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class QgsMeasureDialog : public QDialog, private Ui::QgsMeasureBase

//! Show the help for the dialog
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
private slots:
//! on change state projection enable

//! on change state projection/ellipsoid enable
void changeProjectionEnabledState();

private:
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsmeasuretool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ QgsMeasureTool::QgsMeasureTool( QgsMapCanvas* canvas, bool measureArea )

QgsMeasureTool::~QgsMeasureTool()
{
delete mDialog;
delete mRubberBand;
}

Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

chbAskToSaveProjectChanges->setChecked( settings.value( "qgis/askToSaveProjectChanges", QVariant( true ) ).toBool() );
chbWarnOldProjectVersion->setChecked( settings.value( "/qgis/warnOldProjectVersion", QVariant( true ) ).toBool() );
cmbEnableMacros->setCurrentIndex( settings.value( "/qgis/enableMacros", 1 ).toInt() );

// templates
cbxProjectDefaultNew->setChecked( settings.value( "/qgis/newProjectDefault", QVariant( false ) ).toBool() );
Expand Down Expand Up @@ -843,6 +844,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/projectTemplateDir", leTemplateFolder->text() );
QgisApp::instance()->updateProjectFromTemplates();
}
settings.setValue( "/qgis/enableMacros", cmbEnableMacros->currentIndex() );

settings.setValue( "/qgis/nullValue", leNullValue->text() );
settings.setValue( "/qgis/style", cmbStyle->currentText() );
Expand Down
29 changes: 28 additions & 1 deletion src/app/qgsprojectproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
mStyle = QgsStyleV2::defaultStyle();
populateStyles();

// Project macros
QString pythonMacros = QgsProject::instance()->readEntry( "Macros", "/pythonCode", QString::null );
grpPythonMacros->setChecked( !pythonMacros.isEmpty() );
if ( !pythonMacros.isEmpty() )
{
ptePythonMacros->setPlainText( pythonMacros );
}
else
{
resetPythonMacros();
}

restoreState();
}

Expand Down Expand Up @@ -565,6 +577,15 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( "DefaultStyles", "/AlphaInt", 255 - mTransparencySlider->value() );
QgsProject::instance()->writeEntry( "DefaultStyles", "/RandomColors", cbxStyleRandomColors->isChecked() );

// store project macros
QString pythonMacros = ptePythonMacros->toPlainText();
if ( !grpPythonMacros->isChecked() || pythonMacros.isEmpty() )
{
pythonMacros = QString::null;
resetPythonMacros();
}
QgsProject::instance()->writeEntry( "Macros", "/pythonCode", pythonMacros );

//todo XXX set canvas color
emit refresh();
}
Expand Down Expand Up @@ -947,4 +968,10 @@ void QgsProjectProperties::editSymbol( QComboBox* cbo )
cbo->setItemIcon( cbo->currentIndex(), icon );
}


void QgsProjectProperties::resetPythonMacros()
{
grpPythonMacros->setChecked( false );
ptePythonMacros->setPlainText( "def openProject():\n pass\n\n" \
"def saveProject():\n pass\n\n" \
"def closeProject():\n pass\n" );
}
5 changes: 5 additions & 0 deletions src/app/qgsprojectproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
*/
void restoreState();

/*!
* Reset the python macros
*/
void resetPythonMacros();

long mProjectSrsId;
long mLayerSrsId;
};
110 changes: 61 additions & 49 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,20 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
return;
}

QgsRasterDataProvider* provider = mRasterLayer->dataProvider();

// Only do pyramids if dealing directly with GDAL.
if ( provider->capabilities() & QgsRasterDataProvider::BuildPyramids )
{
QgsRasterLayer::RasterPyramidList myPyramidList = mRasterLayer->buildPyramidList();
QgsRasterLayer::RasterPyramidList::iterator myRasterPyramidIterator;
// initialize resampling methods
cboResamplingMethod->clear();
foreach ( QString method, QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() ) )
cboResamplingMethod->addItem( method );

// build pyramid list
QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;

for ( myRasterPyramidIterator = myPyramidList.begin();
myRasterPyramidIterator != myPyramidList.end();
Expand Down Expand Up @@ -644,45 +651,49 @@ void QgsRasterLayerProperties::apply()

//transparency settings
QgsRasterRenderer* rasterRenderer = mRasterLayer->renderer();
rasterRenderer->setAlphaBand( cboxTransparencyBand->itemData( cboxTransparencyBand->currentIndex() ).toInt() );

//Walk through each row in table and test value. If not valid set to 0.0 and continue building transparency list
QgsRasterTransparency* rasterTransparency = new QgsRasterTransparency();
if ( tableTransparency->columnCount() == 4 )
if ( rasterRenderer )
{
QgsRasterTransparency::TransparentThreeValuePixel myTransparentPixel;
QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
rasterRenderer->setAlphaBand( cboxTransparencyBand->itemData( cboxTransparencyBand->currentIndex() ).toInt() );

//Walk through each row in table and test value. If not valid set to 0.0 and continue building transparency list
QgsRasterTransparency* rasterTransparency = new QgsRasterTransparency();
if ( tableTransparency->columnCount() == 4 )
{
myTransparentPixel.red = transparencyCellValue( myListRunner, 0 );
myTransparentPixel.green = transparencyCellValue( myListRunner, 1 );
myTransparentPixel.blue = transparencyCellValue( myListRunner, 2 );
myTransparentPixel.percentTransparent = transparencyCellValue( myListRunner, 3 );
myTransparentThreeValuePixelList.append( myTransparentPixel );
QgsRasterTransparency::TransparentThreeValuePixel myTransparentPixel;
QList<QgsRasterTransparency::TransparentThreeValuePixel> myTransparentThreeValuePixelList;
for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
{
myTransparentPixel.red = transparencyCellValue( myListRunner, 0 );
myTransparentPixel.green = transparencyCellValue( myListRunner, 1 );
myTransparentPixel.blue = transparencyCellValue( myListRunner, 2 );
myTransparentPixel.percentTransparent = transparencyCellValue( myListRunner, 3 );
myTransparentThreeValuePixelList.append( myTransparentPixel );
}
rasterTransparency->setTransparentThreeValuePixelList( myTransparentThreeValuePixelList );
}
rasterTransparency->setTransparentThreeValuePixelList( myTransparentThreeValuePixelList );
}
else if ( tableTransparency->columnCount() == 3 )
{
QgsRasterTransparency::TransparentSingleValuePixel myTransparentPixel;
QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
else if ( tableTransparency->columnCount() == 3 )
{
myTransparentPixel.min = transparencyCellValue( myListRunner, 0 );
myTransparentPixel.max = transparencyCellValue( myListRunner, 1 );
myTransparentPixel.percentTransparent = transparencyCellValue( myListRunner, 2 );
QgsRasterTransparency::TransparentSingleValuePixel myTransparentPixel;
QList<QgsRasterTransparency::TransparentSingleValuePixel> myTransparentSingleValuePixelList;
for ( int myListRunner = 0; myListRunner < tableTransparency->rowCount(); myListRunner++ )
{
myTransparentPixel.min = transparencyCellValue( myListRunner, 0 );
myTransparentPixel.max = transparencyCellValue( myListRunner, 1 );
myTransparentPixel.percentTransparent = transparencyCellValue( myListRunner, 2 );

myTransparentSingleValuePixelList.append( myTransparentPixel );
myTransparentSingleValuePixelList.append( myTransparentPixel );
}
rasterTransparency->setTransparentSingleValuePixelList( myTransparentSingleValuePixelList );
}
rasterTransparency->setTransparentSingleValuePixelList( myTransparentSingleValuePixelList );
}
rasterRenderer->setRasterTransparency( rasterTransparency );

//set global transparency
rasterRenderer->setOpacity(( 255 - sliderTransparency->value() ) / 255.0 );
rasterRenderer->setRasterTransparency( rasterTransparency );

//set global transparency
rasterRenderer->setOpacity(( 255 - sliderTransparency->value() ) / 255.0 );

//invert color map
rasterRenderer->setInvertColor( mInvertColorMapCheckBox->isChecked() );
//invert color map
rasterRenderer->setInvertColor( mInvertColorMapCheckBox->isChecked() );
}

QgsDebugMsg( "processing general tab" );
/*
Expand Down Expand Up @@ -762,13 +773,14 @@ void QgsRasterLayerProperties::apply()

void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
{
QgsRasterDataProvider* provider = mRasterLayer->dataProvider();

connect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mPyramidProgress, SLOT( setValue( int ) ) );
connect( provider, SIGNAL( progressUpdate( int ) ), mPyramidProgress, SLOT( setValue( int ) ) );
//
// Go through the list marking any files that are selected in the listview
// as true so that we can generate pyramids for them.
//
QgsRasterLayer::RasterPyramidList myPyramidList = mRasterLayer->buildPyramidList();
QList< QgsRasterPyramid> myPyramidList = provider->buildPyramidList();
for ( int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
{
QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
Expand All @@ -781,15 +793,14 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()

// let the user know we're going to possibly be taking a while
QApplication::setOverrideCursor( Qt::WaitCursor );
bool myBuildInternalFlag = cbxInternalPyramids->isChecked();
QString res = mRasterLayer->buildPyramids(
QString res = provider->buildPyramids(
myPyramidList,
cboResamplingMethod->currentText(),
myBuildInternalFlag );
( QgsRasterDataProvider::RasterPyramidsFormat ) cbxPyramidsFormat->currentIndex() );
QApplication::restoreOverrideCursor();
mPyramidProgress->setValue( 0 );
buttonBuildPyramids->setEnabled( false );
disconnect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mPyramidProgress, SLOT( setValue( int ) ) );
disconnect( provider, SIGNAL( progressUpdate( int ) ), mPyramidProgress, SLOT( setValue( int ) ) );
if ( !res.isNull() )
{
if ( res == "ERROR_WRITE_ACCESS" )
Expand Down Expand Up @@ -821,17 +832,16 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()

}


//
// repopulate the pyramids list
//
lbxPyramidResolutions->clear();
// Need to rebuild list as some or all pyramids may have failed to build
myPyramidList = mRasterLayer->buildPyramidList();
myPyramidList = provider->buildPyramidList();
QIcon myPyramidPixmap( QgsApplication::getThemeIcon( "/mIconPyramid.png" ) );
QIcon myNoPyramidPixmap( QgsApplication::getThemeIcon( "/mIconNoPyramid.png" ) );

QgsRasterLayer::RasterPyramidList::iterator myRasterPyramidIterator;
QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
for ( myRasterPyramidIterator = myPyramidList.begin();
myRasterPyramidIterator != myPyramidList.end();
++myRasterPyramidIterator )
Expand Down Expand Up @@ -948,7 +958,7 @@ void QgsRasterLayerProperties::on_pbnDefaultValues_clicked()
{
if ( mRasterLayer->isNoDataValueValid() )
{
// I dont think that noDataValue should be added to transparency list
// I don't think that noDataValue should be added to transparency list
#if 0
tableTransparency->insertRow( tableTransparency->rowCount() );
setTransparencyCell( 0, 0, mRasterLayer->noDataValue() );
Expand Down Expand Up @@ -1313,7 +1323,7 @@ void QgsRasterLayerProperties::pixelSelected( const QgsPoint& canvasPoint )
if ( value == tr( "null (no data)" ) || // Very bad! TODO: improve identify
mRasterLayer->dataProvider()->isNoDataValue( bands.at( i ), value.toDouble() ) )
{
return; // Dont add nodata, transparent anyway
return; // Don't add nodata, transparent anyway
}
values.append( value.toDouble() );
}
Expand Down Expand Up @@ -1578,13 +1588,15 @@ void QgsRasterLayerProperties::updatePipeList()
texts << QString( "%1 ms" ).arg( interface->time() );
QTreeWidgetItem *item = new QTreeWidgetItem( texts );

#if 0
// Switching on/off would be possible but problematic - drawer is not pipe
// memer so we dont know required output format
// Checkobxes are very usefel however for QgsRasterPipe debugging.
//bool on = interface->on();
//item->setCheckState( 0, on ? Qt::Checked : Qt::Unchecked );
// memer so we don't know required output format
// Checkboxes are very useful however for QgsRasterPipe debugging.
bool on = interface->on();
item->setCheckState( 0, on ? Qt::Checked : Qt::Unchecked );

//Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
#endif
Qt::ItemFlags flags = Qt::ItemIsEnabled;
item->setFlags( flags );

Expand Down
Empty file modified src/app/qgsvectorlayerproperties.cpp
100755 → 100644
Empty file.
28 changes: 19 additions & 9 deletions src/core/composer/qgscomposerscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ double QgsComposerScaleBar::mapWidth() const
else
{
QgsDistanceArea da;
da.setProjectionsEnabled( true );
da.setEllipsoidalMode( mComposerMap->mapRenderer()->hasCrsTransformEnabled() );
da.setSourceCrs( mComposerMap->mapRenderer()->destinationCrs().srsid() );
QSettings s;
da.setEllipsoid( s.value( "/qgis/measure/ellipsoid", "WGS84" ).toString() );
Expand Down Expand Up @@ -218,7 +218,7 @@ void QgsComposerScaleBar::applyDefaultSettings()
delete mStyle;
mStyle = new QgsSingleBoxScaleBarStyle( this );

mHeight = 5;
mHeight = 3;

mPen = QPen( QColor( 0, 0, 0 ) );
mPen.setWidthF( 1.0 );
Expand All @@ -237,14 +237,24 @@ void QgsComposerScaleBar::applyDefaultSize()
{
if ( mComposerMap )
{
//calculate mNumUnitsPerSegment
QgsRectangle composerMapRect = mComposerMap->extent();
setUnits( Meters );
double widthMeter = mapWidth();
int nUnitsPerSegment = widthMeter / 10.0; //default scalebar width equals half the map width
setNumUnitsPerSegment( nUnitsPerSegment );

if( nUnitsPerSegment > 1000 )
{
setNumUnitsPerSegment( (int)( numUnitsPerSegment() / 1000.0 + 0.5 ) * 1000 );
setUnitLabeling( tr("km") );
setNumMapUnitsPerScaleBarUnit( 1000 );
}
else
{
setUnitLabeling( tr("m") );
}

double proposedScaleBarLength = composerMapRect.width() / 4;
int powerOf10 = int ( pow( 10.0, int ( log( proposedScaleBarLength ) / log( 10.0 ) ) ) ); // from scalebar plugin
int nPow10 = proposedScaleBarLength / powerOf10;
mNumSegments = 2;
mNumUnitsPerSegment = ( nPow10 / 2 ) * powerOf10;
setNumSegments( 4 );
setNumSegmentsLeft( 2 );
}

refreshSegmentMillimeters();
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ int QgsComposition::pixelFontSize( double pointSize ) const
{
//in QgsComposition, one unit = one mm
double sizeMillimeters = pointSize * 0.3527;
return ( sizeMillimeters + 0.5 ); //round to nearest mm
return qRound( sizeMillimeters ); //round to nearest mm
}

double QgsComposition::pointFontSize( int pixelSize ) const
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgsnumericscalebarstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ QString QgsNumericScaleBarStyle::scaleText() const
if ( composerMap )
{
scaleDenominator = composerMap->scale();
scaleBarText = "1:" + QString::number( scaleDenominator, 'f', 0 );
scaleBarText = "1:" + QString( "%L1" ).arg( scaleDenominator, 0, 'f', 0 );
}
scaleBarText = "1:" + QString::number( scaleDenominator, 'f', 0 );
scaleBarText = "1:" + QString( "%L1" ).arg( scaleDenominator, 0, 'f', 0 );
}
return scaleBarText;
}
Empty file modified src/core/pal/costcalculator.cpp
100755 → 100644
Empty file.
37 changes: 36 additions & 1 deletion src/core/qgis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef QGSVERSION
#include "qgsversion.h"
#endif

#include <QCoreApplication>
#include "qgsconfig.h"

#include <ogr_api.h>
Expand Down Expand Up @@ -67,5 +67,40 @@ const char* QGis::qgisFeatureTypes[] =
"WKBMultiPolygon"
};


const double QGis::DEFAULT_IDENTIFY_RADIUS = 0.5;

// description strings for units
// Order must match enum indices
const char* QGis::qgisUnitTypes[] =
{
QT_TRANSLATE_NOOP( "QGis::UnitType", "meters" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "feet" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "<unknown>" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" )
};

QGis::UnitType QGis::fromLiteral( QString literal, QGis::UnitType defaultType )
{
for ( unsigned int i = 0; i < ( sizeof( qgisUnitTypes ) / sizeof( qgisUnitTypes[0] ) ); i++ )
{
if ( literal == qgisUnitTypes[ i ] )
{
return static_cast<UnitType>( i );
}
}
return defaultType;
}

QString QGis::toLiteral( QGis::UnitType unit )
{
return QString( qgisUnitTypes[ static_cast<int>( unit )] );
}

QString QGis::tr( QGis::UnitType unit )
{
return QCoreApplication::translate( "QGis::UnitType", qPrintable( toLiteral( unit ) ) );
}
13 changes: 13 additions & 0 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <QEvent>
#include <QString>
#include <QMetaType>
#include <cfloat>
#include <cmath>
#include <qnumeric.h>
Expand Down Expand Up @@ -96,6 +97,13 @@ class CORE_EXPORT QGis
DegreesDecimalMinutes = 2, // was 5
};

// Provides the canonical name of the type value
static QString toLiteral( QGis::UnitType unit );
// Converts from the canonical name to the type value
static UnitType fromLiteral( QString literal, QGis::UnitType defaultType = UnknownUnit );
// Provides translated version of the type value
static QString tr( QGis::UnitType unit );

//! User defined event types
enum UserEvent
{
Expand All @@ -109,6 +117,11 @@ class CORE_EXPORT QGis
};

static const double DEFAULT_IDENTIFY_RADIUS;

private:
// String representation of unit types (set in qgis.cpp)
static const char *qgisUnitTypes[];

};

// hack to workaround warnings when casting void pointers
Expand Down
43 changes: 19 additions & 24 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,43 +77,38 @@ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, QStri
{
init( customConfigPath ); // init can also be called directly by e.g. unit tests that don't inherit QApplication.
}

void QgsApplication::init( QString customConfigPath )
{
if ( customConfigPath.isEmpty() )
{
customConfigPath = QDir::homePath() + QString( "/.qgis/" );
}

qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );

QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );

// check if QGIS is run from build directory (not the install directory)
QDir appDir( prefixPath );
#ifndef _MSC_VER
#define SOURCE_PATH "source_path.txt"
#else
#define SOURCE_PATH "../source_path.txt"
#endif
if ( appDir.exists( SOURCE_PATH ) )
QFile f;
foreach( QString path, QStringList() << "" << "/.." << "/bin" )
{
QFile f( prefixPath + "/" + SOURCE_PATH );
if ( f.open( QIODevice::ReadOnly ) )
{
ABISYM( mRunningFromBuildDir ) = true;
ABISYM( mBuildSourcePath ) = f.readAll();
#if _MSC_VER
QStringList elems = prefixPath.split( "/", QString::SkipEmptyParts );
ABISYM( mCfgIntDir ) = elems.last();
ABISYM( mBuildOutputPath ) = prefixPath + "/../..";
#elif defined(Q_WS_MACX)
ABISYM( mBuildOutputPath ) = prefixPath;
#else
ABISYM( mBuildOutputPath ) = prefixPath + "/.."; // on linux
f.setFileName( prefixPath + path + "/path.txt" );
if( f.exists() )
break;
}
if ( f.exists() && f.open( QIODevice::ReadOnly ) )
{
ABISYM( mRunningFromBuildDir ) = true;
ABISYM( mBuildSourcePath ) = f.readLine().trimmed();
ABISYM( mBuildOutputPath ) = f.readLine().trimmed();
qDebug( "Running from build directory!" );
qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toUtf8().data() );
qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toUtf8().data() );
#ifdef _MSC_VER
ABISYM( mCfgIntDir ) = prefixPath.split( "/", QString::SkipEmptyParts ).last();
qDebug( "- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().data() );
#endif
qDebug( "Running from build directory!" );
qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toAscii().data() );
qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toAscii().data() );
}
}

if ( ABISYM( mRunningFromBuildDir ) )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsattributeaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void QgsAttributeAction::doAction( int index, QgsFeature &feat,
return;

// search for expressions while expanding actions
QString expandedAction = expandAction( action.action(), feat, substitutionMap );
QString expandedAction = QgsExpression::replaceExpressionText( action.action(), feat, mLayer , substitutionMap );
if ( expandedAction.isEmpty() )
return;

Expand Down
20 changes: 17 additions & 3 deletions src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,7 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
QFileInfo myInfo( myDatabaseFileName );
if ( !myInfo.exists() )
{
QgsDebugMsg( "failed : " + myDatabaseFileName +
" does not exist!" );
QgsDebugMsg( "failed : " + myDatabaseFileName + " does not exist!" );
return myMap;
}

Expand All @@ -719,8 +718,18 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
myFieldValue = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, myColNo ) );
myMap[myFieldName] = myFieldValue;
}
if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
{
QgsDebugMsg( "Multiple records found in srs.db" );
myMap.clear();
}
}
else
{
QgsDebugMsg( "failed : " + theSql );
}

if ( myMap.empty() )
{
QgsDebugMsg( "trying user qgis.db" );
sqlite3_finalize( myPreparedStatement );
Expand Down Expand Up @@ -754,11 +763,16 @@ QgsCoordinateReferenceSystem::RecordMap QgsCoordinateReferenceSystem::getRecord(
myFieldValue = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, myColNo ) );
myMap[myFieldName] = myFieldValue;
}

if ( sqlite3_step( myPreparedStatement ) != SQLITE_DONE )
{
QgsDebugMsg( "Multiple records found in srs.db" );
myMap.clear();
}
}
else
{
QgsDebugMsg( "failed : " + theSql );

}
}
sqlite3_finalize( myPreparedStatement );
Expand Down
44 changes: 22 additions & 22 deletions src/core/qgsdataitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ QgsDataItem::QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString n

QgsDataItem::~QgsDataItem()
{
QgsDebugMsg( "mName = " + mName + " mPath = " + mPath );
QgsDebugMsgLevel( "mName = " + mName + " mPath = " + mPath, 2 );
}

void QgsDataItem::emitBeginInsertItems( QgsDataItem* parent, int first, int last )
Expand Down Expand Up @@ -215,7 +215,7 @@ bool QgsDataItem::hasChildren()

void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
{
QgsDebugMsg( QString( "add child #%1 - %2 - %3" ).arg( mChildren.size() ).arg( child->mName ).arg( child->mType ) );
QgsDebugMsg( QString( "path = %1 add child #%2 - %3 - %4" ).arg( mPath ).arg( mChildren.size() ).arg( child->mName ).arg( child->mType ) );

int i;
if ( type() == Directory )
Expand Down Expand Up @@ -256,7 +256,7 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
}
void QgsDataItem::deleteChildItem( QgsDataItem * child )
{
QgsDebugMsg( "mName = " + child->mName );
QgsDebugMsgLevel( "mName = " + child->mName, 2 );
int i = mChildren.indexOf( child );
Q_ASSERT( i >= 0 );
emit beginRemoveItems( this, i, i );
Expand All @@ -267,7 +267,7 @@ void QgsDataItem::deleteChildItem( QgsDataItem * child )

QgsDataItem * QgsDataItem::removeChildItem( QgsDataItem * child )
{
QgsDebugMsg( "mName = " + child->mName );
QgsDebugMsgLevel( "mName = " + child->mName, 2 );
int i = mChildren.indexOf( child );
Q_ASSERT( i >= 0 );
emit beginRemoveItems( this, i, i );
Expand All @@ -289,7 +289,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
{
for ( int i = 0; i < items.size(); i++ )
{
QgsDebugMsg( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath );
QgsDebugMsgLevel( QString::number( i ) + " : " + items[i]->mPath + " x " + item->mPath, 2 );
if ( items[i]->equal( item ) )
return i;
}
Expand All @@ -298,7 +298,7 @@ int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )

void QgsDataItem::refresh()
{
QgsDebugMsg( "mPath = " + mPath );
QgsDebugMsgLevel( "mPath = " + mPath, 2 );

QApplication::setOverrideCursor( Qt::WaitCursor );

Expand Down Expand Up @@ -391,10 +391,10 @@ QgsDataCollectionItem::QgsDataCollectionItem( QgsDataItem* parent, QString name,

QgsDataCollectionItem::~QgsDataCollectionItem()
{
QgsDebugMsg( "Entered" );
QgsDebugMsgLevel( "Entered", 2 );
foreach ( QgsDataItem* i, mChildren )
{
QgsDebugMsg( QString( "delete child = 0x%0" ).arg(( qlonglong )i, 8, 16, QLatin1Char( '0' ) ) );
QgsDebugMsgLevel( QString( "delete child = 0x%0" ).arg(( qlonglong )i, 8, 16, QLatin1Char( '0' ) ), 2 );
delete i;
}
}
Expand Down Expand Up @@ -459,7 +459,7 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
foreach ( QString subdir, entries )
{
QString subdirPath = dir.absoluteFilePath( subdir );
QgsDebugMsg( QString( "creating subdir: %1" ).arg( subdirPath ) );
QgsDebugMsgLevel( QString( "creating subdir: %1" ).arg( subdirPath ), 2 );

QgsDirectoryItem *item = new QgsDirectoryItem( this, subdir, subdirPath );
// propagate signals up to top
Expand Down Expand Up @@ -862,7 +862,7 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )

mZipFileList.clear();

QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ) );
QgsDebugMsgLevel( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ), 2 );

// if scanZipBrowser == no: skip to the next file
if ( scanZipSetting == "no" )
Expand All @@ -886,7 +886,7 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
{
QFileInfo info( fileName );
tmpPath = mVsiPrefix + path() + "/" + fileName;
QgsDebugMsg( "tmpPath = " + tmpPath );
QgsDebugMsgLevel( "tmpPath = " + tmpPath, 3 );

// foreach( dataItem_t *dataItem, mDataItemPtr )
for ( int i = 0; i < mProviderNames.size(); i++ )
Expand All @@ -909,18 +909,18 @@ QVector<QgsDataItem*> QgsZipItem::createChildren( )
dataItem_t *dataItem = mDataItemPtr[i];
if ( dataItem )
{
QgsDebugMsg( QString( "trying to load item %1 with %2" ).arg( tmpPath ).arg( mProviderNames[i] ) );
QgsDebugMsgLevel( QString( "trying to load item %1 with %2" ).arg( tmpPath ).arg( mProviderNames[i] ), 3 );
QgsDataItem * item = dataItem( tmpPath, this );
if ( item )
{
QgsDebugMsg( "loaded item" );
QgsDebugMsgLevel( "loaded item", 3 );
childPath = tmpPath;
children.append( item );
break;
}
else
{
QgsDebugMsg( "not loaded item" );
QgsDebugMsgLevel( "not loaded item", 3 );
}
}
}
Expand Down Expand Up @@ -965,7 +965,7 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
QgsZipItem * zipItem = 0;
bool populated = false;

QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path ).arg( name ).arg( scanZipSetting ).arg( vsiPrefix ) );
QgsDebugMsgLevel( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path ).arg( name ).arg( scanZipSetting ).arg( vsiPrefix ), 3 );

// if scanZipBrowser == no: don't read the zip file
if ( scanZipSetting == "no" )
Expand Down Expand Up @@ -1001,18 +1001,18 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
{
zipItem->populate();
populated = true; // there is no QgsDataItem::isPopulated() function
QgsDebugMsg( QString( "Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->rowCount() ).arg( zipItem->path() ).arg( zipItem->name() ) );
QgsDebugMsgLevel( QString( "Got zipItem with %1 children, path=%2, name=%3" ).arg( zipItem->rowCount() ).arg( zipItem->path() ).arg( zipItem->name() ), 3 );
}
else
{
QgsDebugMsg( QString( "Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->path() ).arg( zipItem->name() ) );
QgsDebugMsgLevel( QString( "Delaying populating zipItem with path=%1, name=%2" ).arg( zipItem->path() ).arg( zipItem->name() ), 3 );
}
}

// only display if has children or if is not populated
if ( zipItem && ( !populated || zipItem->rowCount() > 1 ) )
{
QgsDebugMsg( "returning zipItem" );
QgsDebugMsgLevel( "returning zipItem", 3 );
return zipItem;
}
// if 1 or 0 child found, create a single data item using the normal path or the full path given by QgsZipItem
Expand All @@ -1025,7 +1025,7 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString path, QStrin
delete zipItem;
}

QgsDebugMsg( QString( "will try to create a normal dataItem from path= %2 or %3" ).arg( path ).arg( vsiPath ) );
QgsDebugMsgLevel( QString( "will try to create a normal dataItem from path= %2 or %3" ).arg( path ).arg( vsiPath ), 3 );

// try to open using registered providers (gdal and ogr)
for ( int i = 0; i < mProviderNames.size(); i++ )
Expand Down Expand Up @@ -1062,7 +1062,7 @@ const QStringList & QgsZipItem::getZipFileList()
QSettings settings;
QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser", "basic" ).toString();

QgsDebugMsg( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ) );
QgsDebugMsgLevel( QString( "path = %1 name= %2 scanZipSetting= %3 vsiPrefix= %4" ).arg( path() ).arg( name() ).arg( scanZipSetting ).arg( mVsiPrefix ), 3 );

// if scanZipBrowser == no: skip to the next file
if ( scanZipSetting == "no" )
Expand All @@ -1071,14 +1071,14 @@ const QStringList & QgsZipItem::getZipFileList()
}

// get list of files inside zip file
QgsDebugMsg( QString( "Open file %1 with gdal vsi" ).arg( mVsiPrefix + path() ) );
QgsDebugMsgLevel( QString( "Open file %1 with gdal vsi" ).arg( mVsiPrefix + path() ), 3 );
char **papszSiblingFiles = VSIReadDirRecursive1( QString( mVsiPrefix + path() ).toLocal8Bit().constData() );
if ( papszSiblingFiles )
{
for ( int i = 0; i < CSLCount( papszSiblingFiles ); i++ )
{
tmpPath = papszSiblingFiles[i];
QgsDebugMsg( QString( "Read file %1" ).arg( tmpPath ) );
QgsDebugMsgLevel( QString( "Read file %1" ).arg( tmpPath ), 3 );
// skip directories (files ending with /)
if ( tmpPath.right( 1 ) != "/" )
mZipFileList << tmpPath;
Expand Down
8 changes: 1 addition & 7 deletions src/core/qgsdiagramrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,7 @@ void QgsDiagramRendererV2::convertSizeToMapUnits( QSizeF& size, const QgsRenderC
return;
}

int dpi = dpiPaintDevice( context.constPainter() );
if ( dpi < 0 )
{
return;
}

double pixelToMap = dpi / 25.4 * context.mapToPixel().mapUnitsPerPixel();
double pixelToMap = context.scaleFactor() * context.mapToPixel().mapUnitsPerPixel();
size.rwidth() *= pixelToMap;
size.rheight() *= pixelToMap;
}
Expand Down
Loading