mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	cleanups:
- use QMetaObject instead of RTTI - no get in getters: - QgsDataProvider: - getProvider => provider - getSelectWidget => selectWidget - getFunction => function - getLibary => providerLibrary - QgsProviderRegistry: - getLibrary => providerLibrary - /* ... */ => #if 0 / #endif - reindentation
This commit is contained in:
		
							parent
							
								
									ee6c516111
								
							
						
					
					
						commit
						4549d0e199
					
				@ -26,7 +26,7 @@ class QgsProviderRegistry
 | 
			
		||||
 | 
			
		||||
    void setLibraryDirectory(const QDir & path);
 | 
			
		||||
 
 | 
			
		||||
    QgsDataProvider * getProvider( const QString & providerKey, 
 | 
			
		||||
    QgsDataProvider *provider( const QString & providerKey,
 | 
			
		||||
                                   const QString & dataSource );
 | 
			
		||||
 | 
			
		||||
    /** Return list of available providers by their keys */
 | 
			
		||||
 | 
			
		||||
@ -8,21 +8,21 @@ export elcr="$(tput el)$(tput cr)"
 | 
			
		||||
 | 
			
		||||
find src -type f -print | while read f; do
 | 
			
		||||
	case "$f" in
 | 
			
		||||
	src/core/spatialite/*)
 | 
			
		||||
		continue
 | 
			
		||||
		;;
 | 
			
		||||
        src/core/spatialite/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*)
 | 
			
		||||
                echo $f skipped
 | 
			
		||||
                continue
 | 
			
		||||
                ;;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        *.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H)
 | 
			
		||||
        *.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
 | 
			
		||||
                cmd=astyle.sh
 | 
			
		||||
                ;;
 | 
			
		||||
 | 
			
		||||
	*.ui|*.qgm|*.txt|*.t2t|*.py|*.sip|resources/context_help/*)
 | 
			
		||||
		cmd="flip -ub"
 | 
			
		||||
		;;
 | 
			
		||||
 | 
			
		||||
        *.ui|*.qgm|*.txt|*.t2t|*.py|*.sip|resources/context_help/*)
 | 
			
		||||
                cmd="flip -ub"
 | 
			
		||||
                ;;
 | 
			
		||||
 | 
			
		||||
        *)
 | 
			
		||||
                echo $f skipped
 | 
			
		||||
                continue
 | 
			
		||||
                ;;
 | 
			
		||||
        esac
 | 
			
		||||
 | 
			
		||||
@ -1979,7 +1979,6 @@ void DualEdgeTriangulation::ruppertRefinement()
 | 
			
		||||
 | 
			
		||||
          }
 | 
			
		||||
          while ( actedge != pointingedge );
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
@ -2190,9 +2189,6 @@ void DualEdgeTriangulation::ruppertRefinement()
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        while ( actedge != pointingedge );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      }
 | 
			
		||||
    } //end fast method
 | 
			
		||||
 | 
			
		||||
@ -2407,7 +2403,6 @@ void DualEdgeTriangulation::ruppertRefinement()
 | 
			
		||||
 | 
			
		||||
      }
 | 
			
		||||
      while ( actedge != pointingedge );
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@
 | 
			
		||||
#include <QVector>
 | 
			
		||||
 | 
			
		||||
class ANALYSIS_EXPORT ParametricLine
 | 
			
		||||
    /**ParametricLine is an Interface for parametric lines. It is possible, that a parametric line is composed of several parametric lines (see the composite pattern in Gamma et al. 'Design Patterns'). Do not build instances of it since it is an abstract class.*/
 | 
			
		||||
      /**ParametricLine is an Interface for parametric lines. It is possible, that a parametric line is composed of several parametric lines (see the composite pattern in Gamma et al. 'Design Patterns'). Do not build instances of it since it is an abstract class.*/
 | 
			
		||||
{
 | 
			
		||||
  protected:
 | 
			
		||||
    /**Degree of the parametric Line*/
 | 
			
		||||
 | 
			
		||||
@ -137,7 +137,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
 | 
			
		||||
  connect( mView->verticalHeader(), SIGNAL( sectionPressed( int ) ), this, SLOT( updateRowPressed( int ) ) );
 | 
			
		||||
  connect( mModel, SIGNAL( modelChanged() ), this, SLOT( updateSelection() ) );
 | 
			
		||||
 | 
			
		||||
  connect( mView, SIGNAL(willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT(viewWillShowContextMenu(QMenu*, QModelIndex ) ) );
 | 
			
		||||
  connect( mView, SIGNAL( willShowContextMenu( QMenu*, QModelIndex ) ), this, SLOT( viewWillShowContextMenu( QMenu*, QModelIndex ) ) );
 | 
			
		||||
 | 
			
		||||
  mLastClickedHeaderIndex = 0;
 | 
			
		||||
  mSelectionModel = new QItemSelectionModel( mFilterModel );
 | 
			
		||||
 | 
			
		||||
@ -499,7 +499,8 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
 | 
			
		||||
 | 
			
		||||
  int result = myQFileDialog->exec();
 | 
			
		||||
  raise();
 | 
			
		||||
  if ( result != QDialog::Accepted ) return;
 | 
			
		||||
  if ( result != QDialog::Accepted )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QString myOutputFileNameQString = myQFileDialog->selectedFiles().first();
 | 
			
		||||
  if ( myOutputFileNameQString == "" )
 | 
			
		||||
@ -666,7 +667,8 @@ void QgsComposer::on_mActionExportAsImage_triggered()
 | 
			
		||||
    QString myFilter = tr( "%1 format (*.%2 *.%3)" )
 | 
			
		||||
                       .arg( myFormat ).arg( myFormat.toLower() ).arg( myFormat.toUpper() );
 | 
			
		||||
 | 
			
		||||
    if ( myCounterInt > 0 ) myFilters += ";;";
 | 
			
		||||
    if ( myCounterInt > 0 )
 | 
			
		||||
      myFilters += ";;";
 | 
			
		||||
    myFilters += myFilter;
 | 
			
		||||
    myFilterMap[myFilter] = myFormat;
 | 
			
		||||
    if ( myFormat == myLastUsedFormat )
 | 
			
		||||
@ -799,7 +801,8 @@ void QgsComposer::on_mActionExportAsSVG_triggered()
 | 
			
		||||
 | 
			
		||||
  int result = myQFileDialog->exec();
 | 
			
		||||
  raise();
 | 
			
		||||
  if ( result != QDialog::Accepted ) return;
 | 
			
		||||
  if ( result != QDialog::Accepted )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QString myOutputFileNameQString = myQFileDialog->selectedFiles().first();
 | 
			
		||||
  if ( myOutputFileNameQString == "" )
 | 
			
		||||
 | 
			
		||||
@ -402,13 +402,17 @@ void QgsComposerMapWidget::updateComposerExtentFromGui()
 | 
			
		||||
  bool conversionSuccess;
 | 
			
		||||
 | 
			
		||||
  xmin = mXMinLineEdit->text().toDouble( &conversionSuccess );
 | 
			
		||||
  if ( !conversionSuccess ) {return;}
 | 
			
		||||
  if ( !conversionSuccess )
 | 
			
		||||
    return;
 | 
			
		||||
  xmax = mXMaxLineEdit->text().toDouble( &conversionSuccess );
 | 
			
		||||
  if ( !conversionSuccess ) {return;}
 | 
			
		||||
  if ( !conversionSuccess )
 | 
			
		||||
    return;
 | 
			
		||||
  ymin = mYMinLineEdit->text().toDouble( &conversionSuccess );
 | 
			
		||||
  if ( !conversionSuccess ) {return;}
 | 
			
		||||
  if ( !conversionSuccess )
 | 
			
		||||
    return;
 | 
			
		||||
  ymax = mYMaxLineEdit->text().toDouble( &conversionSuccess );
 | 
			
		||||
  if ( !conversionSuccess ) {return;}
 | 
			
		||||
  if ( !conversionSuccess )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QgsRectangle newExtent( xmin, ymin, xmax, ymax );
 | 
			
		||||
  mComposerMap->beginCommand( tr( "Map extent changed" ) );
 | 
			
		||||
 | 
			
		||||
@ -870,7 +870,8 @@ void QgsLegend::legendLayerShowInOverview()
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QgsLegendLayer* ll = qobject_cast<QgsLegendLayer *>( li );
 | 
			
		||||
  if ( !ll ) return;
 | 
			
		||||
  if ( !ll )
 | 
			
		||||
    return;
 | 
			
		||||
  ll->showInOverview();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1805,7 +1806,7 @@ void QgsLegend::legendLayerZoom()
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if( extent.isEmpty() )
 | 
			
		||||
  if ( extent.isEmpty() )
 | 
			
		||||
  {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -448,7 +448,7 @@ int main( int argc, char *argv[] )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // GUI customization is enabled by default unless --nocustomization argument is used
 | 
			
		||||
  QgsCustomization::instance()->setEnabled(myCustomization);
 | 
			
		||||
  QgsCustomization::instance()->setEnabled( myCustomization );
 | 
			
		||||
 | 
			
		||||
  QgsApplication myApp( argc, argv, myUseGuiFlag, configpath );
 | 
			
		||||
 | 
			
		||||
@ -624,10 +624,10 @@ int main( int argc, char *argv[] )
 | 
			
		||||
  QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins ); // "QgisApp" used to find canonical instance
 | 
			
		||||
  qgis->setObjectName( "QgisApp" );
 | 
			
		||||
 | 
			
		||||
  myApp.connect ( 
 | 
			
		||||
    &myApp, SIGNAL( preNotify( QObject *, QEvent *, bool *)),
 | 
			
		||||
  myApp.connect(
 | 
			
		||||
    &myApp, SIGNAL( preNotify( QObject *, QEvent *, bool * ) ),
 | 
			
		||||
    //qgis, SLOT( preNotify( QObject *, QEvent *))
 | 
			
		||||
    QgsCustomization::instance(), SLOT( preNotify( QObject *, QEvent *, bool *))
 | 
			
		||||
    QgsCustomization::instance(), SLOT( preNotify( QObject *, QEvent *, bool * ) )
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  /////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
@ -983,9 +983,9 @@ void QgisApp::createMenus()
 | 
			
		||||
 | 
			
		||||
  // Panel and Toolbar Submenus
 | 
			
		||||
  mPanelMenu = new QMenu( tr( "Panels" ) );
 | 
			
		||||
  mPanelMenu->setObjectName("mPanelMenu");
 | 
			
		||||
  mPanelMenu->setObjectName( "mPanelMenu" );
 | 
			
		||||
  mToolbarMenu = new QMenu( tr( "Toolbars" ) );
 | 
			
		||||
  mToolbarMenu->setObjectName("mToolbarMenu");
 | 
			
		||||
  mToolbarMenu->setObjectName( "mToolbarMenu" );
 | 
			
		||||
 | 
			
		||||
  // Get platform for menu layout customization (Gnome, Kde, Mac, Win)
 | 
			
		||||
  QDialogButtonBox::ButtonLayout layout =
 | 
			
		||||
@ -1079,9 +1079,9 @@ void QgisApp::createToolBars()
 | 
			
		||||
 | 
			
		||||
  QList<QAction*> toolbarMenuActions;
 | 
			
		||||
  // Set action names so that they can be used in customization
 | 
			
		||||
  foreach ( QToolBar *toolBar, toolbarMenuToolBars )
 | 
			
		||||
  foreach( QToolBar *toolBar, toolbarMenuToolBars )
 | 
			
		||||
  {
 | 
			
		||||
    toolBar->toggleViewAction()->setObjectName ( "mActionToggle" + toolBar->objectName().mid(1) );
 | 
			
		||||
    toolBar->toggleViewAction()->setObjectName( "mActionToggle" + toolBar->objectName().mid( 1 ) );
 | 
			
		||||
    toolbarMenuActions << toolBar->toggleViewAction();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -2448,16 +2448,16 @@ void QgisApp::addWmsLayer()
 | 
			
		||||
  QgsDebugMsg( "about to addRasterLayer" );
 | 
			
		||||
 | 
			
		||||
  // TODO: QDialog for now, switch to QWidget in future
 | 
			
		||||
  QDialog *wmss = dynamic_cast<QDialog*> ( QgsProviderRegistry::instance()->getSelectWidget( QString("wms"), this ) );
 | 
			
		||||
  if ( !wmss ) 
 | 
			
		||||
  QDialog *wmss = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "wms" ), this ) );
 | 
			
		||||
  if ( !wmss )
 | 
			
		||||
  {
 | 
			
		||||
    QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) );
 | 
			
		||||
    return;   
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  connect ( wmss , SIGNAL ( addRasterLayer( QString const &, QString const &, QString const &,QStringList const &,QStringList const &,QString const &,
 | 
			
		||||
QString const &) ),
 | 
			
		||||
	    this , SLOT ( addRasterLayer( QString const &, QString const &, QString const &,QStringList const &,QStringList const &,QString const &,
 | 
			
		||||
QString const &) ) );
 | 
			
		||||
  connect( wmss , SIGNAL( addRasterLayer( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &,
 | 
			
		||||
                                          QString const & ) ),
 | 
			
		||||
           this , SLOT( addRasterLayer( QString const &, QString const &, QString const &, QStringList const &, QStringList const &, QString const &,
 | 
			
		||||
                                        QString const & ) ) );
 | 
			
		||||
  wmss->exec();
 | 
			
		||||
  delete wmss;
 | 
			
		||||
}
 | 
			
		||||
@ -3103,8 +3103,10 @@ void QgisApp::toggleActiveWindowMaximized()
 | 
			
		||||
  QWidget *window = QApplication::activeWindow();
 | 
			
		||||
  if ( window )
 | 
			
		||||
  {
 | 
			
		||||
    if ( window->isMaximized() ) window->showNormal();
 | 
			
		||||
    else window->showMaximized();
 | 
			
		||||
    if ( window->isMaximized() )
 | 
			
		||||
      window->showNormal();
 | 
			
		||||
    else
 | 
			
		||||
      window->showMaximized();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4554,8 +4556,8 @@ void QgisApp::showPluginManager()
 | 
			
		||||
// implementation of the python runner
 | 
			
		||||
class QgsPythonRunnerImpl : public QgsPythonRunner
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    QgsPythonRunnerImpl(QgsPythonUtils* pythonUtils) : mPythonUtils(pythonUtils) {}
 | 
			
		||||
  public:
 | 
			
		||||
    QgsPythonRunnerImpl( QgsPythonUtils* pythonUtils ) : mPythonUtils( pythonUtils ) {}
 | 
			
		||||
    virtual bool runCommand( QString command, QString messageOnError = QString() )
 | 
			
		||||
    {
 | 
			
		||||
      if ( mPythonUtils && mPythonUtils->isEnabled() )
 | 
			
		||||
@ -4565,7 +4567,7 @@ public:
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  protected:
 | 
			
		||||
    QgsPythonUtils* mPythonUtils;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -4615,7 +4617,7 @@ void QgisApp::loadPythonSupport()
 | 
			
		||||
    QgsPluginRegistry::instance()->setPythonUtils( mPythonUtils );
 | 
			
		||||
 | 
			
		||||
    // init python runner
 | 
			
		||||
    QgsPythonRunner::setInstance( new QgsPythonRunnerImpl(mPythonUtils) );
 | 
			
		||||
    QgsPythonRunner::setInstance( new QgsPythonRunnerImpl( mPythonUtils ) );
 | 
			
		||||
 | 
			
		||||
    std::cout << "Python support ENABLED :-) " << std::endl; // OK
 | 
			
		||||
  }
 | 
			
		||||
@ -5477,7 +5479,8 @@ void QgisApp::updateMouseCoordinatePrecision()
 | 
			
		||||
    dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );
 | 
			
		||||
 | 
			
		||||
  // Keep dp sensible
 | 
			
		||||
  if ( dp < 0 ) dp = 0;
 | 
			
		||||
  if ( dp < 0 )
 | 
			
		||||
    dp = 0;
 | 
			
		||||
 | 
			
		||||
  mMousePrecisionDecimalPlaces = dp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,8 @@ void QgsAbout::init()
 | 
			
		||||
    {
 | 
			
		||||
      line = stream.readLine(); // line of text excluding '\n'
 | 
			
		||||
      //ignore the line if it starts with a hash....
 | 
			
		||||
      if ( line.left( 1 ) == "#" ) continue;
 | 
			
		||||
      if ( line.left( 1 ) == "#" )
 | 
			
		||||
        continue;
 | 
			
		||||
      QStringList myTokens = line.split( "\t", QString::SkipEmptyParts );
 | 
			
		||||
      lines << myTokens[0];
 | 
			
		||||
    }
 | 
			
		||||
@ -102,7 +103,8 @@ void QgsAbout::init()
 | 
			
		||||
    {
 | 
			
		||||
      line = stream.readLine(); // line of text excluding '\n'
 | 
			
		||||
      //ignore the line if it starts with a hash....
 | 
			
		||||
      if ( line.left( 1 ) == "#" ) continue;
 | 
			
		||||
      if ( line.left( 1 ) == "#" )
 | 
			
		||||
        continue;
 | 
			
		||||
      lines += line;
 | 
			
		||||
    }
 | 
			
		||||
    file2.close();
 | 
			
		||||
@ -129,7 +131,8 @@ void QgsAbout::init()
 | 
			
		||||
                               "money to fund QGIS development and other project costs see "
 | 
			
		||||
                               "<a href=\"http://qgis.org/en/sponsorship/donors.html\">"
 | 
			
		||||
                               "http://qgis.org/en/sponsorship/donors.html</a></p>" );
 | 
			
		||||
    /*QString website;
 | 
			
		||||
#if 0
 | 
			
		||||
    QString website;
 | 
			
		||||
    QTextStream donorsStream( &donorsFile );
 | 
			
		||||
    // Always use UTF-8
 | 
			
		||||
    donorsStream.setCodec( "UTF-8" );
 | 
			
		||||
@ -138,7 +141,8 @@ void QgsAbout::init()
 | 
			
		||||
    {
 | 
			
		||||
      sline = donorsStream.readLine(); // line of text excluding '\n'
 | 
			
		||||
      //ignore the line if it starts with a hash....
 | 
			
		||||
      if ( sline.left( 1 ) == "#" ) continue;
 | 
			
		||||
      if ( sline.left( 1 ) == "#" )
 | 
			
		||||
        continue;
 | 
			
		||||
      QStringList myTokens = sline.split( "|", QString::SkipEmptyParts );
 | 
			
		||||
      if ( myTokens.size() > 1 )
 | 
			
		||||
      {
 | 
			
		||||
@ -153,7 +157,8 @@ void QgsAbout::init()
 | 
			
		||||
      // close the row
 | 
			
		||||
      donorsHTML += "</tr>";
 | 
			
		||||
    }
 | 
			
		||||
    donorsHTML += "</table>";*/
 | 
			
		||||
    donorsHTML += "</table>";
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    QString myStyle = QgsApplication::reportStyleSheet();
 | 
			
		||||
    txtDonors->clear();
 | 
			
		||||
@ -187,7 +192,8 @@ void QgsAbout::init()
 | 
			
		||||
    {
 | 
			
		||||
      sline = translatorStream.readLine(); // line of text excluding '\n'
 | 
			
		||||
      //ignore the line if it starts with a hash....
 | 
			
		||||
      if ( sline.left( 1 ) == "#" ) continue;
 | 
			
		||||
      if ( sline.left( 1 ) == "#" )
 | 
			
		||||
        continue;
 | 
			
		||||
      QStringList myTokens = sline.split( "|", QString::SkipEmptyParts );
 | 
			
		||||
      if ( myTokens.size() > 1 )
 | 
			
		||||
      {
 | 
			
		||||
 | 
			
		||||
@ -164,7 +164,8 @@ void QgsAttributeActionDialog::remove()
 | 
			
		||||
    attributeActionTable->removeRow( row );
 | 
			
		||||
 | 
			
		||||
    // And select the row below the one that was selected or the last one.
 | 
			
		||||
    if ( row >= attributeActionTable->rowCount() ) row = attributeActionTable->rowCount() - 1;
 | 
			
		||||
    if ( row >= attributeActionTable->rowCount() )
 | 
			
		||||
      row = attributeActionTable->rowCount() - 1;
 | 
			
		||||
    attributeActionTable->selectRow( row );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -172,7 +173,6 @@ void QgsAttributeActionDialog::remove()
 | 
			
		||||
void QgsAttributeActionDialog::insert()
 | 
			
		||||
{
 | 
			
		||||
  // Add the action details as a new row in the table.
 | 
			
		||||
 | 
			
		||||
  int pos = attributeActionTable->rowCount();
 | 
			
		||||
  insert( pos );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -212,7 +212,8 @@ void QgsConfigureShortcutsDialog::changeShortcut()
 | 
			
		||||
void QgsConfigureShortcutsDialog::resetShortcut()
 | 
			
		||||
{
 | 
			
		||||
  QAction* action = currentAction();
 | 
			
		||||
  if ( !action ) return;
 | 
			
		||||
  if ( !action )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // set default shortcut
 | 
			
		||||
  QString shortcut = QgsShortcutsManager::instance()->actionDefaultShortcut( action );
 | 
			
		||||
@ -361,7 +362,8 @@ void QgsConfigureShortcutsDialog::setGettingShortcut( bool getting )
 | 
			
		||||
void QgsConfigureShortcutsDialog::setCurrentActionShortcut( QKeySequence s )
 | 
			
		||||
{
 | 
			
		||||
  QAction* action = currentAction();
 | 
			
		||||
  if ( !action ) return;
 | 
			
		||||
  if ( !action )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // first check whether this action is not taken already
 | 
			
		||||
  QAction* otherAction = QgsShortcutsManager::instance()->actionForShortcut( s );
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,5 +1,5 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
	               qgscustomization.h  - Customization
 | 
			
		||||
                             qgscustomization.h  - Customization
 | 
			
		||||
                             -------------------
 | 
			
		||||
    begin                : 2011-04-01
 | 
			
		||||
    copyright            : (C) 2011 Radim Blazek
 | 
			
		||||
@ -39,14 +39,14 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD
 | 
			
		||||
    ~QgsCustomizationDialog();
 | 
			
		||||
 | 
			
		||||
    // get item by path
 | 
			
		||||
    QTreeWidgetItem *item ( QString thePath, QTreeWidgetItem *theItem=0  );
 | 
			
		||||
    QTreeWidgetItem *item( QString thePath, QTreeWidgetItem *theItem = 0 );
 | 
			
		||||
 | 
			
		||||
    // 
 | 
			
		||||
    //
 | 
			
		||||
 | 
			
		||||
    // return current item state for given path
 | 
			
		||||
    bool itemChecked ( QString thePath );
 | 
			
		||||
    bool itemChecked( QString thePath );
 | 
			
		||||
    // set item state for given path
 | 
			
		||||
    void setItemChecked ( QString thePath, bool on );
 | 
			
		||||
    void setItemChecked( QString thePath, bool on );
 | 
			
		||||
 | 
			
		||||
    // recursively save tree item to settings
 | 
			
		||||
    void itemToSettings( QString thePath, QTreeWidgetItem *theItem, QSettings *theSettings );
 | 
			
		||||
@ -54,19 +54,19 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD
 | 
			
		||||
    void settingsToItem( QString thePath, QTreeWidgetItem *theItem, QSettings *theSettings );
 | 
			
		||||
 | 
			
		||||
    // save current tree to settings
 | 
			
		||||
    void treeToSettings ( QSettings *theSettings );
 | 
			
		||||
    void treeToSettings( QSettings *theSettings );
 | 
			
		||||
 | 
			
		||||
    // restore current tree from settings
 | 
			
		||||
    void settingsToTree ( QSettings *theSettings );
 | 
			
		||||
    void settingsToTree( QSettings *theSettings );
 | 
			
		||||
 | 
			
		||||
    // switch widget item in tree
 | 
			
		||||
    bool switchWidget ( QWidget * widget, QMouseEvent *event );
 | 
			
		||||
    bool switchWidget( QWidget * widget, QMouseEvent *event );
 | 
			
		||||
 | 
			
		||||
    // Get path of the widget 
 | 
			
		||||
    QString widgetPath ( QWidget * theWidget, QString thePath = QString() );
 | 
			
		||||
    // Get path of the widget
 | 
			
		||||
    QString widgetPath( QWidget * theWidget, QString thePath = QString() );
 | 
			
		||||
 | 
			
		||||
    void setCatch ( bool on );
 | 
			
		||||
    bool catchOn ( );
 | 
			
		||||
    void setCatch( bool on );
 | 
			
		||||
    bool catchOn( );
 | 
			
		||||
 | 
			
		||||
  private slots:
 | 
			
		||||
    //void on_btnQgisUser_clicked();
 | 
			
		||||
@ -92,8 +92,8 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD
 | 
			
		||||
 | 
			
		||||
  private:
 | 
			
		||||
    void init();
 | 
			
		||||
    QTreeWidgetItem * createTreeItemWidgets ( );
 | 
			
		||||
    QTreeWidgetItem * readWidgetsXmlNode ( QDomNode theNode );
 | 
			
		||||
    QTreeWidgetItem * createTreeItemWidgets( );
 | 
			
		||||
    QTreeWidgetItem * readWidgetsXmlNode( QDomNode theNode );
 | 
			
		||||
 | 
			
		||||
    QString mLastDirSettingsName;
 | 
			
		||||
    QSettings mSettings;
 | 
			
		||||
@ -122,7 +122,7 @@ class QgsCustomization : public QObject
 | 
			
		||||
    void updateMainWindow( QMenu * theToolBarMenu );
 | 
			
		||||
 | 
			
		||||
    // make sure to enable/disable before creating QgisApp in order to get it customized (or not)
 | 
			
		||||
    void setEnabled(bool enabled) { mEnabled = enabled; }
 | 
			
		||||
    void setEnabled( bool enabled ) { mEnabled = enabled; }
 | 
			
		||||
    bool isEnabled() const { return mEnabled; }
 | 
			
		||||
 | 
			
		||||
    // Load and set default customization
 | 
			
		||||
@ -144,13 +144,13 @@ class QgsCustomization : public QObject
 | 
			
		||||
    bool mEnabled;
 | 
			
		||||
    QString mStatusPath;
 | 
			
		||||
 | 
			
		||||
    void updateMenu(QMenu* menu, QSettings& settings);
 | 
			
		||||
    void createTreeItemMenus ( );
 | 
			
		||||
    void createTreeItemToolbars ( );
 | 
			
		||||
    void createTreeItemDocks ( );
 | 
			
		||||
    void createTreeItemStatus ( );
 | 
			
		||||
    void addTreeItemMenu(QTreeWidgetItem* parentItem, QMenu* menu);
 | 
			
		||||
    void addTreeItemActions(QTreeWidgetItem* parentItem, const QList<QAction*>& actions);
 | 
			
		||||
    void updateMenu( QMenu* menu, QSettings& settings );
 | 
			
		||||
    void createTreeItemMenus( );
 | 
			
		||||
    void createTreeItemToolbars( );
 | 
			
		||||
    void createTreeItemDocks( );
 | 
			
		||||
    void createTreeItemStatus( );
 | 
			
		||||
    void addTreeItemMenu( QTreeWidgetItem* parentItem, QMenu* menu );
 | 
			
		||||
    void addTreeItemActions( QTreeWidgetItem* parentItem, const QList<QAction*>& actions );
 | 
			
		||||
    QList<QTreeWidgetItem*> mMainWindowItems;
 | 
			
		||||
    friend class QgsCustomizationDialog; // in order to access mMainWindowItems
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -134,6 +134,9 @@ void QgsMapToolAddPart::canvasReleaseEvent( QMouseEvent * e )
 | 
			
		||||
      stopCapturing();
 | 
			
		||||
    }
 | 
			
		||||
    break;
 | 
			
		||||
    default:
 | 
			
		||||
      Q_ASSERT( !"invalid capture mode" );
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QString errorMessage;
 | 
			
		||||
 | 
			
		||||
@ -175,7 +175,8 @@ void QgsPluginManager::getPythonPluginDescriptions()
 | 
			
		||||
    QString version     = mPythonUtils->getPluginMetadata( packageName, "version" );
 | 
			
		||||
    QString iconName    = mPythonUtils->getPluginMetadata( packageName, "icon" );
 | 
			
		||||
 | 
			
		||||
    if ( pluginName == "__error__" || description == "__error__" || version == "__error__" ) continue;
 | 
			
		||||
    if ( pluginName == "__error__" || description == "__error__" || version == "__error__" )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    bool isCompatible = QgsPluginRegistry::instance()->isPythonPluginCompatible( packageName );
 | 
			
		||||
    QString compatibleString; // empty by default
 | 
			
		||||
 | 
			
		||||
@ -189,13 +189,16 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion )
 | 
			
		||||
  int minVerMajor, minVerMinor, minVerBugfix = 0;
 | 
			
		||||
  bool ok;
 | 
			
		||||
  minVerMajor = minVersionParts.at( 0 ).toInt( &ok );
 | 
			
		||||
  if ( !ok ) return false;
 | 
			
		||||
  if ( !ok )
 | 
			
		||||
    return false;
 | 
			
		||||
  minVerMinor = minVersionParts.at( 1 ).toInt( &ok );
 | 
			
		||||
  if ( !ok ) return false;
 | 
			
		||||
  if ( !ok )
 | 
			
		||||
    return false;
 | 
			
		||||
  if ( minVersionParts.count() == 3 )
 | 
			
		||||
  {
 | 
			
		||||
    minVerBugfix = minVersionParts.at( 2 ).toInt( &ok );
 | 
			
		||||
    if ( !ok ) return false;
 | 
			
		||||
    if ( !ok )
 | 
			
		||||
      return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // our qgis version - cut release name after version number
 | 
			
		||||
@ -207,15 +210,19 @@ bool QgsPluginRegistry::checkQgisVersion( QString minVersion )
 | 
			
		||||
  int qgisBugfix = qgisVersionParts.at( 2 ).toInt();
 | 
			
		||||
 | 
			
		||||
  // first check major version
 | 
			
		||||
  if ( minVerMajor > qgisMajor ) return false;
 | 
			
		||||
  if ( minVerMajor < qgisMajor ) return true;
 | 
			
		||||
 | 
			
		||||
  if ( minVerMajor > qgisMajor )
 | 
			
		||||
    return false;
 | 
			
		||||
  if ( minVerMajor < qgisMajor )
 | 
			
		||||
    return true;
 | 
			
		||||
  // if same, check minor version
 | 
			
		||||
  if ( minVerMinor > qgisMinor ) return false;
 | 
			
		||||
  if ( minVerMinor < qgisMinor ) return true;
 | 
			
		||||
  if ( minVerMinor > qgisMinor )
 | 
			
		||||
    return false;
 | 
			
		||||
  if ( minVerMinor < qgisMinor )
 | 
			
		||||
    return true;
 | 
			
		||||
 | 
			
		||||
  // if still same, check bugfix version
 | 
			
		||||
  if ( minVerBugfix > qgisBugfix ) return false;
 | 
			
		||||
  if ( minVerBugfix > qgisBugfix )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  // looks like min version is the same as our version - that's fine
 | 
			
		||||
  return true;
 | 
			
		||||
 | 
			
		||||
@ -41,7 +41,7 @@ int main( int argc, char ** argv )
 | 
			
		||||
#if defined(Q_WS_WIN)
 | 
			
		||||
  QString prefixPath = QApplication::applicationDirPath();
 | 
			
		||||
#else
 | 
			
		||||
  QString prefixPath = QApplication::applicationDirPath()+"/..";
 | 
			
		||||
  QString prefixPath = QApplication::applicationDirPath() + "/..";
 | 
			
		||||
#endif
 | 
			
		||||
  a.setPrefixPath( prefixPath, true );
 | 
			
		||||
  a.initQgis();
 | 
			
		||||
@ -51,7 +51,7 @@ int main( int argc, char ** argv )
 | 
			
		||||
  QCoreApplication::setOrganizationDomain( "qgis.org" );
 | 
			
		||||
  QCoreApplication::setApplicationName( "QGIS" );
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
#if 0
 | 
			
		||||
  QString myTranslationCode = "";
 | 
			
		||||
 | 
			
		||||
  // This is mostly copy from Help viewer - not sure if important
 | 
			
		||||
@ -76,28 +76,28 @@ int main( int argc, char ** argv )
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  QgsDebugMsg( QString( "Setting translation to %1/qgis_%2" ).arg( i18nPath ).arg( myTranslationCode ) );
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
  /* Translation file for Qt.
 | 
			
		||||
   * The strings from the QMenuBar context section are used by Qt/Mac to shift
 | 
			
		||||
   * the About, Preferences and Quit items to the Mac Application menu.
 | 
			
		||||
   * These items must be translated identically in both qt_ and qgis_ files.
 | 
			
		||||
   */
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
  QTranslator qttor( 0 );
 | 
			
		||||
  if ( qttor.load( QString( "qt_" ) + myTranslationCode, i18nPath ) )
 | 
			
		||||
  {
 | 
			
		||||
    a.installTranslator( &qttor );
 | 
			
		||||
  }
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
  /* Translation file for QGIS.
 | 
			
		||||
   */
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
  QTranslator qgistor( 0 );
 | 
			
		||||
  if ( qgistor.load( QString( "qgis_" ) + myTranslationCode, i18nPath ) )
 | 
			
		||||
  {
 | 
			
		||||
    a.installTranslator( &qgistor );
 | 
			
		||||
  }
 | 
			
		||||
*/
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  QgsBrowser w;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/***************************************************************************
 | 
			
		||||
               qgs.cpp  - 
 | 
			
		||||
                             qgsbrowser.cpp  -
 | 
			
		||||
                             -------------------
 | 
			
		||||
    begin                : 2011-04-01
 | 
			
		||||
    copyright            : (C) 2011 Radim Blazek
 | 
			
		||||
@ -15,11 +15,10 @@
 | 
			
		||||
 *                                                                         *
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
/* $Id$ */
 | 
			
		||||
#include <typeinfo>
 | 
			
		||||
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
#include <QMessageBox>
 | 
			
		||||
#include <QKeyEvent>
 | 
			
		||||
#include <QMetaObject>
 | 
			
		||||
 | 
			
		||||
#include "qgsapplication.h"
 | 
			
		||||
#include "qgsdataitem.h"
 | 
			
		||||
@ -38,39 +37,39 @@
 | 
			
		||||
QgsBrowser::QgsBrowser( QWidget *parent, Qt::WFlags flags )
 | 
			
		||||
    : QMainWindow( parent, flags ),
 | 
			
		||||
    mDirtyMetadata( true ), mDirtyPreview( true ), mDirtyAttributes( true ),
 | 
			
		||||
    mLayer( 0 ), mParamWidget(0)
 | 
			
		||||
    mLayer( 0 ), mParamWidget( 0 )
 | 
			
		||||
{
 | 
			
		||||
  setupUi( this );
 | 
			
		||||
 | 
			
		||||
  // Disable tabs by default
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( paramTab ), false );
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( metaTab ), false );
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( previewTab ), false );
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( attributesTab ), false );
 | 
			
		||||
  
 | 
			
		||||
  mModel = new QgsBrowserModel(treeView);
 | 
			
		||||
  treeView->setModel(mModel);
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( paramTab ), false );
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( metaTab ), false );
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( previewTab ), false );
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( attributesTab ), false );
 | 
			
		||||
 | 
			
		||||
  mModel = new QgsBrowserModel( treeView );
 | 
			
		||||
  treeView->setModel( mModel );
 | 
			
		||||
 | 
			
		||||
  // Last expanded is stored, dont cover whole height with file system
 | 
			
		||||
  //treeView->expand( mModel->index(0,0) );
 | 
			
		||||
 | 
			
		||||
  connect(treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(itemClicked(const QModelIndex&)));
 | 
			
		||||
  connect( treeView, SIGNAL( clicked( const QModelIndex& ) ), this, SLOT( itemClicked( const QModelIndex& ) ) );
 | 
			
		||||
 | 
			
		||||
  treeView->setExpandsOnDoubleClick (false);
 | 
			
		||||
  connect(treeView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(itemDoubleClicked(const QModelIndex&)));
 | 
			
		||||
  connect(treeView, SIGNAL(expanded(const QModelIndex&)), this, SLOT(itemExpanded(const QModelIndex&)));
 | 
			
		||||
  treeView->setExpandsOnDoubleClick( false );
 | 
			
		||||
  connect( treeView, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( itemDoubleClicked( const QModelIndex& ) ) );
 | 
			
		||||
  connect( treeView, SIGNAL( expanded( const QModelIndex& ) ), this, SLOT( itemExpanded( const QModelIndex& ) ) );
 | 
			
		||||
 | 
			
		||||
  connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()));
 | 
			
		||||
  connect( tabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( tabChanged() ) );
 | 
			
		||||
 | 
			
		||||
  connect( mActionNewVectorLayer, SIGNAL( triggered() ), this, SLOT( newVectorLayer() ) );
 | 
			
		||||
 | 
			
		||||
  connect(stopRenderingButton, SIGNAL(clicked()), this, SLOT(stopRendering()) );
 | 
			
		||||
  connect( stopRenderingButton, SIGNAL( clicked() ), this, SLOT( stopRendering() ) );
 | 
			
		||||
 | 
			
		||||
  mapCanvas->setCanvasColor(Qt::white);
 | 
			
		||||
  mapCanvas->setCanvasColor( Qt::white );
 | 
			
		||||
 | 
			
		||||
  QSettings settings; 
 | 
			
		||||
  QString lastPath =  settings.value ( "/Browser/lastExpanded" ).toString();
 | 
			
		||||
  QgsDebugMsg ( "lastPath = " + lastPath );
 | 
			
		||||
  QSettings settings;
 | 
			
		||||
  QString lastPath =  settings.value( "/Browser/lastExpanded" ).toString();
 | 
			
		||||
  QgsDebugMsg( "lastPath = " + lastPath );
 | 
			
		||||
  if ( !lastPath.isEmpty() )
 | 
			
		||||
  {
 | 
			
		||||
    expand( lastPath );
 | 
			
		||||
@ -84,29 +83,29 @@ QgsBrowser::~QgsBrowser()
 | 
			
		||||
 | 
			
		||||
void QgsBrowser::expand( QString path, const QModelIndex& index )
 | 
			
		||||
{
 | 
			
		||||
  QStringList paths = path.split('/');  
 | 
			
		||||
  for ( int i = 0; i < mModel->rowCount(index); i++ ) 
 | 
			
		||||
  QStringList paths = path.split( '/' );
 | 
			
		||||
  for ( int i = 0; i < mModel->rowCount( index ); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    QModelIndex idx = mModel->index(i, 0, index);
 | 
			
		||||
    QgsDataItem* ptr = (QgsDataItem*) idx.internalPointer();
 | 
			
		||||
    QModelIndex idx = mModel->index( i, 0, index );
 | 
			
		||||
    QgsDataItem* ptr = ( QgsDataItem* ) idx.internalPointer();
 | 
			
		||||
 | 
			
		||||
    if ( path.indexOf ( ptr->path() ) == 0 )
 | 
			
		||||
    if ( path.indexOf( ptr->path() ) == 0 )
 | 
			
		||||
    {
 | 
			
		||||
      treeView->expand( idx );
 | 
			
		||||
      treeView->scrollTo (idx, QAbstractItemView::PositionAtTop );
 | 
			
		||||
      treeView->scrollTo( idx, QAbstractItemView::PositionAtTop );
 | 
			
		||||
      expand( path, idx );
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsBrowser::itemClicked(const QModelIndex& index)
 | 
			
		||||
void QgsBrowser::itemClicked( const QModelIndex& index )
 | 
			
		||||
{
 | 
			
		||||
  mIndex = index;
 | 
			
		||||
 | 
			
		||||
  QgsDataItem* ptr = (QgsDataItem*) index.internalPointer();  
 | 
			
		||||
  QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
 | 
			
		||||
 | 
			
		||||
  // Disable preview, attributes tab 
 | 
			
		||||
  // Disable preview, attributes tab
 | 
			
		||||
 | 
			
		||||
  bool paramEnable = false;
 | 
			
		||||
  bool metaEnable = false;
 | 
			
		||||
@ -123,8 +122,9 @@ void QgsBrowser::itemClicked(const QModelIndex& index)
 | 
			
		||||
  QList<QgsMapCanvasLayer> nolayers;
 | 
			
		||||
  mapCanvas->setLayerSet( nolayers );
 | 
			
		||||
  metaTextBrowser->clear();
 | 
			
		||||
  if ( mParamWidget ) {
 | 
			
		||||
    paramLayout->removeWidget ( mParamWidget );
 | 
			
		||||
  if ( mParamWidget )
 | 
			
		||||
  {
 | 
			
		||||
    paramLayout->removeWidget( mParamWidget );
 | 
			
		||||
    mParamWidget->hide();
 | 
			
		||||
    delete mParamWidget;
 | 
			
		||||
    mParamWidget = 0;
 | 
			
		||||
@ -139,59 +139,61 @@ void QgsBrowser::itemClicked(const QModelIndex& index)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  mParamWidget = ptr->paramWidget();
 | 
			
		||||
  if ( mParamWidget ) {
 | 
			
		||||
    paramLayout->addWidget ( mParamWidget );
 | 
			
		||||
  if ( mParamWidget )
 | 
			
		||||
  {
 | 
			
		||||
    paramLayout->addWidget( mParamWidget );
 | 
			
		||||
    mParamWidget->show();
 | 
			
		||||
    paramEnable = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (ptr->type() == QgsDataItem::Layer)
 | 
			
		||||
  if ( ptr->type() == QgsDataItem::Layer )
 | 
			
		||||
  {
 | 
			
		||||
    QgsLayerItem* item = static_cast<QgsLayerItem*>(ptr);
 | 
			
		||||
    bool res = layerClicked(item);
 | 
			
		||||
    QgsLayerItem* item = static_cast<QgsLayerItem*>( ptr );
 | 
			
		||||
    bool res = layerClicked( item );
 | 
			
		||||
 | 
			
		||||
    if (res)
 | 
			
		||||
    if ( res )
 | 
			
		||||
    {
 | 
			
		||||
      metaEnable = true;
 | 
			
		||||
      previewEnable = true;
 | 
			
		||||
      if ( mLayer->type() == QgsMapLayer::VectorLayer ) {
 | 
			
		||||
      if ( mLayer->type() == QgsMapLayer::VectorLayer )
 | 
			
		||||
      {
 | 
			
		||||
        attributesEnable = true;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    mActionSetProjection->setEnabled ( false );
 | 
			
		||||
    mActionSetProjection->setEnabled( false );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // force update of the current tab
 | 
			
		||||
  updateCurrentTab();
 | 
			
		||||
 | 
			
		||||
  int selected = -1;
 | 
			
		||||
  if ( mLastTab.contains( typeid(*ptr).name() )  )
 | 
			
		||||
  if ( mLastTab.contains( ptr->metaObject()->className() ) )
 | 
			
		||||
  {
 | 
			
		||||
    selected = mLastTab[ typeid(*ptr).name()];
 | 
			
		||||
    selected = mLastTab[ ptr->metaObject()->className() ];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Enabling tabs call tabChanged !
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( paramTab ), paramEnable);
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( metaTab ), metaEnable );
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( previewTab ), previewEnable );
 | 
			
		||||
  tabWidget->setTabEnabled ( tabWidget->indexOf( attributesTab ), attributesEnable );
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( paramTab ), paramEnable );
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( metaTab ), metaEnable );
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( previewTab ), previewEnable );
 | 
			
		||||
  tabWidget->setTabEnabled( tabWidget->indexOf( attributesTab ), attributesEnable );
 | 
			
		||||
 | 
			
		||||
  // select tab according last selection for this data item
 | 
			
		||||
  if ( selected >= 0  )
 | 
			
		||||
  if ( selected >= 0 )
 | 
			
		||||
  {
 | 
			
		||||
    qDebug("set tab %s %d", typeid(*ptr).name(), selected );
 | 
			
		||||
    tabWidget->setCurrentIndex ( selected );
 | 
			
		||||
    qDebug( "set tab %s %d", ptr->metaObject()->className(), selected );
 | 
			
		||||
    tabWidget->setCurrentIndex( selected );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  qDebug("clicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data());
 | 
			
		||||
  qDebug( "clicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data() );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool QgsBrowser::layerClicked(QgsLayerItem* ptr)
 | 
			
		||||
bool QgsBrowser::layerClicked( QgsLayerItem* ptr )
 | 
			
		||||
{
 | 
			
		||||
  mActionSetProjection->setEnabled ( ptr->capabilities() & QgsLayerItem::SetCrs );
 | 
			
		||||
  mActionSetProjection->setEnabled( ptr->capabilities() & QgsLayerItem::SetCrs );
 | 
			
		||||
 | 
			
		||||
  QString uri = ptr->uri();
 | 
			
		||||
  if ( !uri.isEmpty() )
 | 
			
		||||
@ -199,14 +201,14 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr)
 | 
			
		||||
    QgsMapLayer::LayerType type = ptr->mapLayerType();
 | 
			
		||||
    QString providerKey = ptr->providerKey();
 | 
			
		||||
 | 
			
		||||
    QgsDebugMsg ( providerKey + " : " + uri );
 | 
			
		||||
    if ( type == QgsMapLayer::VectorLayer ) 
 | 
			
		||||
    QgsDebugMsg( providerKey + " : " + uri );
 | 
			
		||||
    if ( type == QgsMapLayer::VectorLayer )
 | 
			
		||||
    {
 | 
			
		||||
      mLayer = new QgsVectorLayer( uri, QString(), providerKey);
 | 
			
		||||
      mLayer = new QgsVectorLayer( uri, QString(), providerKey );
 | 
			
		||||
    }
 | 
			
		||||
    if ( type == QgsMapLayer::RasterLayer ) 
 | 
			
		||||
    if ( type == QgsMapLayer::RasterLayer )
 | 
			
		||||
    {
 | 
			
		||||
      // This should go to WMS provider 
 | 
			
		||||
      // This should go to WMS provider
 | 
			
		||||
      QStringList URIParts = uri.split( "|" );
 | 
			
		||||
      QString rasterLayerPath = URIParts.at( 0 );
 | 
			
		||||
      QStringList layers;
 | 
			
		||||
@ -220,13 +222,17 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr)
 | 
			
		||||
        QString field = part.left( pos );
 | 
			
		||||
        QString value = part.mid( pos + 1 );
 | 
			
		||||
 | 
			
		||||
        if ( field == "layers" ) layers = value.split(",");
 | 
			
		||||
        if ( field == "styles" ) styles = value.split(",");
 | 
			
		||||
        if ( field == "format" ) format = value;
 | 
			
		||||
        if ( field == "crs" ) crs = value;
 | 
			
		||||
        if ( field == "layers" )
 | 
			
		||||
          layers = value.split( "," );
 | 
			
		||||
        if ( field == "styles" )
 | 
			
		||||
          styles = value.split( "," );
 | 
			
		||||
        if ( field == "format" )
 | 
			
		||||
          format = value;
 | 
			
		||||
        if ( field == "crs" )
 | 
			
		||||
          crs = value;
 | 
			
		||||
      }
 | 
			
		||||
      QgsDebugMsg ( "rasterLayerPath = " + rasterLayerPath );
 | 
			
		||||
      QgsDebugMsg ( "layers = " + layers.join(" " ) );
 | 
			
		||||
      QgsDebugMsg( "rasterLayerPath = " + rasterLayerPath );
 | 
			
		||||
      QgsDebugMsg( "layers = " + layers.join( " " ) );
 | 
			
		||||
 | 
			
		||||
      mLayer = new QgsRasterLayer( 0, rasterLayerPath, "", providerKey, layers, styles, format, crs );
 | 
			
		||||
    }
 | 
			
		||||
@ -234,39 +240,39 @@ bool QgsBrowser::layerClicked(QgsLayerItem* ptr)
 | 
			
		||||
 | 
			
		||||
  if ( !mLayer || !mLayer->isValid() )
 | 
			
		||||
  {
 | 
			
		||||
    qDebug("No layer" );
 | 
			
		||||
    qDebug( "No layer" );
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  QgsDebugMsg ( "Layer created");
 | 
			
		||||
  QgsDebugMsg( "Layer created" );
 | 
			
		||||
 | 
			
		||||
  QgsMapLayerRegistry::instance()->addMapLayer(mLayer);
 | 
			
		||||
  QgsMapLayerRegistry::instance()->addMapLayer( mLayer );
 | 
			
		||||
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void QgsBrowser::itemDoubleClicked(const QModelIndex& index)
 | 
			
		||||
void QgsBrowser::itemDoubleClicked( const QModelIndex& index )
 | 
			
		||||
{
 | 
			
		||||
  QgsDataItem* ptr = (QgsDataItem*) index.internalPointer();
 | 
			
		||||
  QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
 | 
			
		||||
 | 
			
		||||
  // Currently doing nothing
 | 
			
		||||
  qDebug("doubleclicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data());
 | 
			
		||||
  qDebug( "doubleclicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data() );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsBrowser::itemExpanded(const QModelIndex& index)
 | 
			
		||||
void QgsBrowser::itemExpanded( const QModelIndex& index )
 | 
			
		||||
{
 | 
			
		||||
  QSettings settings; 
 | 
			
		||||
  QgsDataItem* ptr = (QgsDataItem*) index.internalPointer();
 | 
			
		||||
/*
 | 
			
		||||
  if (ptr->mType == QgsDataItem::Directory || ptr->mType == QgsDataItem::Collection )
 | 
			
		||||
  {
 | 
			
		||||
    QgsDirectoryItem* i = (QgsDirectoryItem*) ptr;
 | 
			
		||||
    settings.setValue ( "/Browser/lastExpandedDir", i->mPath );
 | 
			
		||||
  }
 | 
			
		||||
*/
 | 
			
		||||
  QSettings settings;
 | 
			
		||||
  QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
 | 
			
		||||
  /*
 | 
			
		||||
    if (ptr->mType == QgsDataItem::Directory || ptr->mType == QgsDataItem::Collection )
 | 
			
		||||
    {
 | 
			
		||||
      QgsDirectoryItem* i = (QgsDirectoryItem*) ptr;
 | 
			
		||||
      settings.setValue ( "/Browser/lastExpandedDir", i->mPath );
 | 
			
		||||
    }
 | 
			
		||||
  */
 | 
			
		||||
  // TODO: save separately each type (FS, WMS)
 | 
			
		||||
  settings.setValue ( "/Browser/lastExpanded", ptr->path() );
 | 
			
		||||
  settings.setValue( "/Browser/lastExpanded", ptr->path() );
 | 
			
		||||
  QgsDebugMsg( "last expanded: " + ptr->path() );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -274,7 +280,7 @@ void QgsBrowser::newVectorLayer()
 | 
			
		||||
{
 | 
			
		||||
  // Set file dialog to last selected dir
 | 
			
		||||
  QSettings settings;
 | 
			
		||||
  QString lastPath =  settings.value ( "/Browser/lastExpanded" ).toString();
 | 
			
		||||
  QString lastPath =  settings.value( "/Browser/lastExpanded" ).toString();
 | 
			
		||||
  if ( !lastPath.isEmpty() )
 | 
			
		||||
  {
 | 
			
		||||
    settings.setValue( "/UI/lastVectorFileFilterDir", lastPath );
 | 
			
		||||
@ -286,15 +292,15 @@ void QgsBrowser::newVectorLayer()
 | 
			
		||||
  {
 | 
			
		||||
    QgsDebugMsg( "New vector layer: " + fileName );
 | 
			
		||||
    expand( fileName );
 | 
			
		||||
    QFileInfo fileInfo ( fileName );
 | 
			
		||||
    QFileInfo fileInfo( fileName );
 | 
			
		||||
    QString dirPath = fileInfo.absoluteDir().path();
 | 
			
		||||
    mModel->refresh ( dirPath );
 | 
			
		||||
    mModel->refresh( dirPath );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsBrowser::on_mActionWmsConnections_triggered()
 | 
			
		||||
{
 | 
			
		||||
  QDialog *wmss = dynamic_cast<QDialog*> ( QgsProviderRegistry::instance()->getSelectWidget( QString("wms"), this ) );
 | 
			
		||||
  QDialog *wmss = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( QString( "wms" ), this ) );
 | 
			
		||||
  if ( !wmss )
 | 
			
		||||
  {
 | 
			
		||||
    QMessageBox::warning( this, tr( "WMS" ), tr( "Cannot get WMS select dialog from provider." ) );
 | 
			
		||||
@ -308,7 +314,8 @@ void QgsBrowser::on_mActionWmsConnections_triggered()
 | 
			
		||||
 | 
			
		||||
void QgsBrowser::on_mActionSetProjection_triggered()
 | 
			
		||||
{
 | 
			
		||||
  if ( !mLayer ) { return; }
 | 
			
		||||
  if ( !mLayer )
 | 
			
		||||
    return;
 | 
			
		||||
  QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
 | 
			
		||||
  mySelector->setMessage();
 | 
			
		||||
  mySelector->setSelectedCrsId( mLayer->crs().srsid() );
 | 
			
		||||
@ -320,13 +327,13 @@ void QgsBrowser::on_mActionSetProjection_triggered()
 | 
			
		||||
    // Is this safe?
 | 
			
		||||
    // selectedIndexes() is protected
 | 
			
		||||
 | 
			
		||||
    QgsDataItem* ptr = (QgsDataItem*) mIndex.internalPointer();
 | 
			
		||||
    QgsDataItem* ptr = ( QgsDataItem* ) mIndex.internalPointer();
 | 
			
		||||
    if ( ptr->type() == QgsDataItem::Layer )
 | 
			
		||||
    {
 | 
			
		||||
      QgsLayerItem* layerItem = static_cast<QgsLayerItem*>(ptr);
 | 
			
		||||
      if ( ! layerItem->setCrs ( srs ) )
 | 
			
		||||
      QgsLayerItem* layerItem = static_cast<QgsLayerItem*>( ptr );
 | 
			
		||||
      if ( ! layerItem->setCrs( srs ) )
 | 
			
		||||
      {
 | 
			
		||||
        QMessageBox::critical( this, tr( "CRS" ), tr( "Cannot set layer CRS" ));
 | 
			
		||||
        QMessageBox::critical( this, tr( "CRS" ), tr( "Cannot set layer CRS" ) );
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    QgsDebugMsg( srs.authid() + " - " + srs.description() );
 | 
			
		||||
@ -365,14 +372,14 @@ void QgsBrowser::restoreWindowState()
 | 
			
		||||
    QList<int> sizes;
 | 
			
		||||
    sizes << size0;
 | 
			
		||||
    sizes << settings.value( "/Windows/Browser/sizes/1" ).toInt();
 | 
			
		||||
    QgsDebugMsg( QString("set splitter sizes to %1 %2").arg(sizes[0]).arg(sizes[1]) );
 | 
			
		||||
    splitter->setSizes(sizes);
 | 
			
		||||
    QgsDebugMsg( QString( "set splitter sizes to %1 %2" ).arg( sizes[0] ).arg( sizes[1] ) );
 | 
			
		||||
    splitter->setSizes( sizes );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsBrowser::keyPressEvent( QKeyEvent * e )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "Entered");
 | 
			
		||||
  QgsDebugMsg( "Entered" );
 | 
			
		||||
  if ( e->key() == Qt::Key_Escape )
 | 
			
		||||
  {
 | 
			
		||||
    stopRendering();
 | 
			
		||||
@ -386,7 +393,7 @@ void QgsBrowser::keyPressEvent( QKeyEvent * e )
 | 
			
		||||
void QgsBrowser::stopRendering()
 | 
			
		||||
{
 | 
			
		||||
  // you might have seen this already in QgisApp
 | 
			
		||||
  QgsDebugMsg( "Entered");
 | 
			
		||||
  QgsDebugMsg( "Entered" );
 | 
			
		||||
  if ( mapCanvas )
 | 
			
		||||
  {
 | 
			
		||||
    QgsMapRenderer* mypMapRenderer = mapCanvas->mapRenderer();
 | 
			
		||||
@ -404,9 +411,9 @@ void QgsBrowser::stopRendering()
 | 
			
		||||
QgsBrowser::Tab QgsBrowser::activeTab()
 | 
			
		||||
{
 | 
			
		||||
  QWidget* curr = tabWidget->currentWidget();
 | 
			
		||||
  if (curr == metaTab)
 | 
			
		||||
  if ( curr == metaTab )
 | 
			
		||||
    return Metadata;
 | 
			
		||||
  if (curr == previewTab)
 | 
			
		||||
  if ( curr == previewTab )
 | 
			
		||||
    return Preview;
 | 
			
		||||
  return Attributes;
 | 
			
		||||
}
 | 
			
		||||
@ -417,9 +424,9 @@ void QgsBrowser::updateCurrentTab()
 | 
			
		||||
 | 
			
		||||
  Tab current = activeTab();
 | 
			
		||||
 | 
			
		||||
  if (current == Metadata && mDirtyMetadata)
 | 
			
		||||
  if ( current == Metadata && mDirtyMetadata )
 | 
			
		||||
  {
 | 
			
		||||
    if (mLayer && mLayer->isValid())
 | 
			
		||||
    if ( mLayer && mLayer->isValid() )
 | 
			
		||||
    {
 | 
			
		||||
      // Set meta
 | 
			
		||||
      QString myStyle = QgsApplication::reportStyleSheet();
 | 
			
		||||
@ -429,33 +436,33 @@ void QgsBrowser::updateCurrentTab()
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      metaTextBrowser->setHtml(QString());
 | 
			
		||||
      metaTextBrowser->setHtml( QString() );
 | 
			
		||||
    }
 | 
			
		||||
    mDirtyMetadata = false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (current == Preview && mDirtyPreview)
 | 
			
		||||
  if ( current == Preview && mDirtyPreview )
 | 
			
		||||
  {
 | 
			
		||||
    if (mLayer && mLayer->isValid())
 | 
			
		||||
    if ( mLayer && mLayer->isValid() )
 | 
			
		||||
    {
 | 
			
		||||
      // Create preview: add to map canvas
 | 
			
		||||
      QList<QgsMapCanvasLayer> layers;
 | 
			
		||||
      layers << QgsMapCanvasLayer(mLayer);
 | 
			
		||||
      mapCanvas->setLayerSet(layers);
 | 
			
		||||
      layers << QgsMapCanvasLayer( mLayer );
 | 
			
		||||
      mapCanvas->setLayerSet( layers );
 | 
			
		||||
      QgsRectangle fullExtent = mLayer->extent();
 | 
			
		||||
      fullExtent.scale(1.05); // add some border
 | 
			
		||||
      mapCanvas->setExtent(fullExtent);
 | 
			
		||||
      fullExtent.scale( 1.05 ); // add some border
 | 
			
		||||
      mapCanvas->setExtent( fullExtent );
 | 
			
		||||
      mapCanvas->refresh();
 | 
			
		||||
    }
 | 
			
		||||
    mDirtyPreview = false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (current == Attributes && mDirtyAttributes)
 | 
			
		||||
  if ( current == Attributes && mDirtyAttributes )
 | 
			
		||||
  {
 | 
			
		||||
    if ( mLayer  && mLayer->isValid() && mLayer->type() == QgsMapLayer::VectorLayer )
 | 
			
		||||
    {
 | 
			
		||||
      QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayer );
 | 
			
		||||
      QApplication::setOverrideCursor(Qt::WaitCursor);
 | 
			
		||||
      QApplication::setOverrideCursor( Qt::WaitCursor );
 | 
			
		||||
      attributeTable->setLayer( vlayer );
 | 
			
		||||
      QApplication::restoreOverrideCursor();
 | 
			
		||||
    }
 | 
			
		||||
@ -471,11 +478,11 @@ void QgsBrowser::tabChanged()
 | 
			
		||||
{
 | 
			
		||||
  updateCurrentTab();
 | 
			
		||||
  // Store last selected tab for selected data item
 | 
			
		||||
  if ( mIndex.isValid() ) 
 | 
			
		||||
  if ( mIndex.isValid() )
 | 
			
		||||
  {
 | 
			
		||||
    QObject* ptr = (QObject*) mIndex.internalPointer();
 | 
			
		||||
    QgsDebugMsg( QString("save last tab %1 : %2").arg( typeid(*ptr).name() ).arg(tabWidget->currentIndex()) );
 | 
			
		||||
    mLastTab[typeid(*ptr).name()] = tabWidget->currentIndex();
 | 
			
		||||
    QObject* ptr = ( QObject* ) mIndex.internalPointer();
 | 
			
		||||
    QgsDebugMsg( QString( "save last tab %1 : %2" ).arg( ptr->metaObject()->className() ).arg( tabWidget->currentIndex() ) );
 | 
			
		||||
    mLastTab[ ptr->metaObject()->className() ] = tabWidget->currentIndex();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -488,16 +495,16 @@ void QgsBrowser::on_mActionRefresh_triggered()
 | 
			
		||||
void QgsBrowser::refresh( const QModelIndex& index )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "Entered" );
 | 
			
		||||
  if ( index.isValid() ) 
 | 
			
		||||
  if ( index.isValid() )
 | 
			
		||||
  {
 | 
			
		||||
    QgsDataItem* item = (QgsDataItem*) index.internalPointer();
 | 
			
		||||
    QgsDataItem* item = ( QgsDataItem* ) index.internalPointer();
 | 
			
		||||
    QgsDebugMsg( "path = " + item->path() );
 | 
			
		||||
  }
 | 
			
		||||
  mModel->refresh( index );
 | 
			
		||||
  for ( int i = 0 ; i < mModel->rowCount(index); i++ ) 
 | 
			
		||||
  for ( int i = 0 ; i < mModel->rowCount( index ); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    QModelIndex idx = mModel->index(i, 0, index);
 | 
			
		||||
    if ( treeView->isExpanded ( idx ) )
 | 
			
		||||
    QModelIndex idx = mModel->index( i, 0, index );
 | 
			
		||||
    if ( treeView->isExpanded( idx ) )
 | 
			
		||||
    {
 | 
			
		||||
      refresh( idx );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -35,14 +35,14 @@ class QgsBrowser : public QMainWindow, private Ui::QgsBrowserBase
 | 
			
		||||
    ~QgsBrowser();
 | 
			
		||||
 | 
			
		||||
    // Expand to given path
 | 
			
		||||
    void expand ( QString path, const QModelIndex& index = QModelIndex() );
 | 
			
		||||
    void expand( QString path, const QModelIndex& index = QModelIndex() );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public slots:
 | 
			
		||||
    void itemClicked(const QModelIndex& index);
 | 
			
		||||
    void itemDoubleClicked(const QModelIndex& index);
 | 
			
		||||
    void itemExpanded(const QModelIndex& index);
 | 
			
		||||
    void itemClicked( const QModelIndex& index );
 | 
			
		||||
    void itemDoubleClicked( const QModelIndex& index );
 | 
			
		||||
    void itemExpanded( const QModelIndex& index );
 | 
			
		||||
    void on_mActionSetProjection_triggered();
 | 
			
		||||
    void on_mActionWmsConnections_triggered();
 | 
			
		||||
    void on_mActionRefresh_triggered();
 | 
			
		||||
@ -56,12 +56,12 @@ class QgsBrowser : public QMainWindow, private Ui::QgsBrowserBase
 | 
			
		||||
    void stopRendering();
 | 
			
		||||
 | 
			
		||||
    // Refresh all leaf or expanded items
 | 
			
		||||
    void refresh ( const QModelIndex& index= QModelIndex() );
 | 
			
		||||
    void refresh( const QModelIndex& index = QModelIndex() );
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  protected:
 | 
			
		||||
    void keyPressEvent( QKeyEvent * e );
 | 
			
		||||
 | 
			
		||||
    bool layerClicked(QgsLayerItem* ptr);
 | 
			
		||||
    bool layerClicked( QgsLayerItem* ptr );
 | 
			
		||||
 | 
			
		||||
    enum Tab
 | 
			
		||||
    {
 | 
			
		||||
@ -78,7 +78,7 @@ protected:
 | 
			
		||||
    QModelIndex mIndex;
 | 
			
		||||
    QWidget *mParamWidget;
 | 
			
		||||
    // last (selected) tab for each
 | 
			
		||||
    QMap<QString,int> mLastTab;
 | 
			
		||||
    QMap<QString, int> mLastTab;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // QGSBROWSER_H
 | 
			
		||||
 | 
			
		||||
@ -31,8 +31,9 @@ QgsBrowserModel::QgsBrowserModel( QObject *parent ) :
 | 
			
		||||
  // Add non file top level items
 | 
			
		||||
  foreach( QString key, QgsProviderRegistry::instance()->providerList() )
 | 
			
		||||
  {
 | 
			
		||||
    QLibrary *library = QgsProviderRegistry::instance()->getLibrary( key );
 | 
			
		||||
    if ( !library ) continue;
 | 
			
		||||
    QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( key );
 | 
			
		||||
    if ( !library )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) );
 | 
			
		||||
    if ( !dataCapabilities )
 | 
			
		||||
@ -277,7 +278,8 @@ void QgsBrowserModel::beginInsertItems( QgsDataItem* parent, int first, int last
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "parent mPath = " + parent->path() );
 | 
			
		||||
  QModelIndex idx = index( parent );
 | 
			
		||||
  if ( !idx.isValid() ) return;
 | 
			
		||||
  if ( !idx.isValid() )
 | 
			
		||||
    return;
 | 
			
		||||
  QgsDebugMsg( "valid" );
 | 
			
		||||
  beginInsertRows( idx, first, last );
 | 
			
		||||
  QgsDebugMsg( "end" );
 | 
			
		||||
@ -291,7 +293,8 @@ void QgsBrowserModel::beginRemoveItems( QgsDataItem* parent, int first, int last
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "parent mPath = " + parent->path() );
 | 
			
		||||
  QModelIndex idx = index( parent );
 | 
			
		||||
  if ( !idx.isValid() ) return;
 | 
			
		||||
  if ( !idx.isValid() )
 | 
			
		||||
    return;
 | 
			
		||||
  beginRemoveRows( idx, first, last );
 | 
			
		||||
}
 | 
			
		||||
void QgsBrowserModel::endRemoveItems()
 | 
			
		||||
 | 
			
		||||
@ -9,8 +9,8 @@
 | 
			
		||||
class QgsBrowserModel : public QAbstractItemModel
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    explicit QgsBrowserModel(QObject *parent = 0);
 | 
			
		||||
  public:
 | 
			
		||||
    explicit QgsBrowserModel( QObject *parent = 0 );
 | 
			
		||||
    ~QgsBrowserModel();
 | 
			
		||||
 | 
			
		||||
    // implemented methods from QAbstractItemModel for read-only access
 | 
			
		||||
@ -31,7 +31,7 @@ public:
 | 
			
		||||
    virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
 | 
			
		||||
    /** Provides the number of columns of data exposed by the model. List models do not provide this function
 | 
			
		||||
      because it is already implemented in QAbstractListModel. */
 | 
			
		||||
    virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
 | 
			
		||||
    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
 | 
			
		||||
 | 
			
		||||
    /** Returns the index of the item in the model specified by the given row, column and parent index. */
 | 
			
		||||
    virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
 | 
			
		||||
@ -42,17 +42,17 @@ public:
 | 
			
		||||
    virtual QModelIndex parent( const QModelIndex & index ) const;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const;
 | 
			
		||||
    bool hasChildren( const QModelIndex & parent = QModelIndex() ) const;
 | 
			
		||||
 | 
			
		||||
    // Refresh item specified by path
 | 
			
		||||
    void refresh( QString path, const QModelIndex& index = QModelIndex() );
 | 
			
		||||
    // Refresh item childs
 | 
			
		||||
    void refresh( const QModelIndex& index = QModelIndex() );
 | 
			
		||||
 | 
			
		||||
    void connectItem ( QgsDataItem * item );
 | 
			
		||||
signals:
 | 
			
		||||
    void connectItem( QgsDataItem * item );
 | 
			
		||||
  signals:
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
  public slots:
 | 
			
		||||
    //void removeItems( QgsDataItem * parent, QVector<QgsDataItem *>items );
 | 
			
		||||
    //void addItems( QgsDataItem * parent, QVector<QgsDataItem *>items );
 | 
			
		||||
    //void refreshItems( QgsDataItem * parent, QVector<QgsDataItem *>items );
 | 
			
		||||
@ -62,7 +62,7 @@ public slots:
 | 
			
		||||
    void beginRemoveItems( QgsDataItem* parent, int first, int last );
 | 
			
		||||
    void endRemoveItems();
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  protected:
 | 
			
		||||
    QVector<QgsDataItem*> mRootItems;
 | 
			
		||||
    QIcon mIconDirectory;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1079,7 +1079,7 @@ namespace pal
 | 
			
		||||
  {
 | 
			
		||||
    ASSERT( a_rectA && a_rectB );
 | 
			
		||||
 | 
			
		||||
    Rect newRect = { {0,}, {0,} };
 | 
			
		||||
    Rect newRect = { {0, }, {0, } };
 | 
			
		||||
 | 
			
		||||
    for ( int index = 0; index < NUMDIMS; ++index )
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -115,7 +115,8 @@ bool QgsApplication::notify( QObject * receiver, QEvent * event )
 | 
			
		||||
  bool done = false;
 | 
			
		||||
  emit preNotify( receiver, event, &done );
 | 
			
		||||
 | 
			
		||||
  if ( done ) return true;
 | 
			
		||||
  if ( done )
 | 
			
		||||
    return true;
 | 
			
		||||
 | 
			
		||||
  // Send event to receiver and catch unhandled exceptions
 | 
			
		||||
  done = true;
 | 
			
		||||
 | 
			
		||||
@ -104,8 +104,10 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString theDefinition
 | 
			
		||||
  {
 | 
			
		||||
    QString authName = reCrsId.cap( 1 ).toLower();
 | 
			
		||||
    CrsType type = InternalCrsId;
 | 
			
		||||
    if ( authName == "epsg" ) type = EpsgCrsId;
 | 
			
		||||
    if ( authName == "postgis" ) type = PostgisCrsId;
 | 
			
		||||
    if ( authName == "epsg" )
 | 
			
		||||
      type = EpsgCrsId;
 | 
			
		||||
    if ( authName == "postgis" )
 | 
			
		||||
      type = PostgisCrsId;
 | 
			
		||||
    long id = reCrsId.cap( 2 ).toLong();
 | 
			
		||||
    result = createFromId( id, type );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -222,7 +222,8 @@ void QgsCoordinateTransform::initialise()
 | 
			
		||||
 | 
			
		||||
QgsPoint QgsCoordinateTransform::transform( const QgsPoint thePoint, TransformDirection direction ) const
 | 
			
		||||
{
 | 
			
		||||
  if ( mShortCircuit || !mInitialisedFlag ) return thePoint;
 | 
			
		||||
  if ( mShortCircuit || !mInitialisedFlag )
 | 
			
		||||
    return thePoint;
 | 
			
		||||
  // transform x
 | 
			
		||||
  double x = thePoint.x();
 | 
			
		||||
  double y = thePoint.y();
 | 
			
		||||
@ -258,7 +259,8 @@ QgsPoint QgsCoordinateTransform::transform( const double theX, const double theY
 | 
			
		||||
 | 
			
		||||
QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle theRect, TransformDirection direction ) const
 | 
			
		||||
{
 | 
			
		||||
  if ( mShortCircuit || !mInitialisedFlag ) return theRect;
 | 
			
		||||
  if ( mShortCircuit || !mInitialisedFlag )
 | 
			
		||||
    return theRect;
 | 
			
		||||
  // transform x
 | 
			
		||||
  double x1 = theRect.xMinimum();
 | 
			
		||||
  double y1 = theRect.yMinimum();
 | 
			
		||||
 | 
			
		||||
@ -166,7 +166,8 @@ void QgsDataItem::populate()
 | 
			
		||||
 | 
			
		||||
int QgsDataItem::rowCount()
 | 
			
		||||
{
 | 
			
		||||
  if ( !mPopulated ) populate();
 | 
			
		||||
  if ( !mPopulated )
 | 
			
		||||
    populate();
 | 
			
		||||
  return mChildren.size();
 | 
			
		||||
}
 | 
			
		||||
bool QgsDataItem::hasChildren()
 | 
			
		||||
@ -180,10 +181,13 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
 | 
			
		||||
  int i;
 | 
			
		||||
  for ( i = 0; i < mChildren.size(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 ) break;
 | 
			
		||||
    if ( mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 )
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( refresh ) emit beginInsertItems( this, i, i );
 | 
			
		||||
  if ( refresh )
 | 
			
		||||
    emit beginInsertItems( this, i, i );
 | 
			
		||||
 | 
			
		||||
  mChildren.insert( i, child );
 | 
			
		||||
 | 
			
		||||
  connect( child, SIGNAL( beginInsertItems( QgsDataItem*, int, int ) ),
 | 
			
		||||
@ -195,8 +199,8 @@ void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
 | 
			
		||||
  connect( child, SIGNAL( endRemoveItems() ),
 | 
			
		||||
           this, SLOT( emitEndRemoveItems() ) );
 | 
			
		||||
 | 
			
		||||
  if ( refresh ) emit endInsertItems();
 | 
			
		||||
 | 
			
		||||
  if ( refresh )
 | 
			
		||||
    emit endInsertItems();
 | 
			
		||||
}
 | 
			
		||||
void QgsDataItem::deleteChildItem( QgsDataItem * child )
 | 
			
		||||
{
 | 
			
		||||
@ -214,7 +218,8 @@ 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 );
 | 
			
		||||
    if ( items[i]->equal( item ) ) return i;
 | 
			
		||||
    if ( items[i]->equal( item ) )
 | 
			
		||||
      return i;
 | 
			
		||||
  }
 | 
			
		||||
  return -1;
 | 
			
		||||
}
 | 
			
		||||
@ -229,7 +234,8 @@ void QgsDataItem::refresh()
 | 
			
		||||
  QVector<QgsDataItem*> remove;
 | 
			
		||||
  foreach( QgsDataItem *child, mChildren )
 | 
			
		||||
  {
 | 
			
		||||
    if ( findItem( items, child ) >= 0 ) continue;
 | 
			
		||||
    if ( findItem( items, child ) >= 0 )
 | 
			
		||||
      continue;
 | 
			
		||||
    remove.append( child );
 | 
			
		||||
  }
 | 
			
		||||
  foreach( QgsDataItem *child, remove )
 | 
			
		||||
@ -280,7 +286,8 @@ QgsLayerItem::QgsLayerItem( QgsDataItem* parent, QString name, QString path, QSt
 | 
			
		||||
 | 
			
		||||
QgsMapLayer::LayerType QgsLayerItem::mapLayerType()
 | 
			
		||||
{
 | 
			
		||||
  if ( mLayerType == QgsLayerItem::Raster ) return QgsMapLayer::RasterLayer;
 | 
			
		||||
  if ( mLayerType == QgsLayerItem::Raster )
 | 
			
		||||
    return QgsMapLayer::RasterLayer;
 | 
			
		||||
  return QgsMapLayer::VectorLayer;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -328,7 +335,7 @@ QgsDirectoryItem::QgsDirectoryItem( QgsDataItem* parent, QString name, QString p
 | 
			
		||||
      QString k( *i );
 | 
			
		||||
      // some providers hangs with empty uri (Postgis) etc...
 | 
			
		||||
      // -> using libraries directly
 | 
			
		||||
      QLibrary *library = QgsProviderRegistry::instance()->getLibrary( k );
 | 
			
		||||
      QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( k );
 | 
			
		||||
      if ( library )
 | 
			
		||||
      {
 | 
			
		||||
        dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) );
 | 
			
		||||
@ -384,7 +391,10 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
 | 
			
		||||
 | 
			
		||||
      // TODO: use existing fileVectorFilters(),directoryDrivers() ?
 | 
			
		||||
      dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) );
 | 
			
		||||
      if ( !dataCapabilities ) continue;
 | 
			
		||||
      if ( !dataCapabilities )
 | 
			
		||||
      {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      int capabilities = dataCapabilities();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -667,7 +667,8 @@ void QgsDistanceArea::computeAreaInit()
 | 
			
		||||
 | 
			
		||||
  m_Qp = getQ( M_PI / 2 );
 | 
			
		||||
  m_E  = 4 * M_PI * m_Qp * m_AE;
 | 
			
		||||
  if ( m_E < 0.0 ) m_E = -m_E;
 | 
			
		||||
  if ( m_E < 0.0 )
 | 
			
		||||
    m_E = -m_E;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -720,8 +721,10 @@ double QgsDistanceArea::computePolygonArea( const QList<QgsPoint>& points )
 | 
			
		||||
  * the difference between total surface area of the earth and
 | 
			
		||||
  * the "north pole" area.
 | 
			
		||||
  */
 | 
			
		||||
  if ( area > m_E ) area = m_E;
 | 
			
		||||
  if ( area > m_E / 2 ) area = m_E - area;
 | 
			
		||||
  if ( area > m_E )
 | 
			
		||||
    area = m_E;
 | 
			
		||||
  if ( area > m_E / 2 )
 | 
			
		||||
    area = m_E - area;
 | 
			
		||||
 | 
			
		||||
  return area;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -334,7 +334,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
 | 
			
		||||
 | 
			
		||||
    /** \brief Obtain Metadata for this layer */
 | 
			
		||||
    virtual QString metadata();
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /** Time stamp of data source in the moment when data/metadata were loaded by provider */
 | 
			
		||||
    virtual QDateTime timestamp() const { return QDateTime() ; }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,8 @@ class QgsPalGeometry : public PalGeometry
 | 
			
		||||
 | 
			
		||||
    ~QgsPalGeometry()
 | 
			
		||||
    {
 | 
			
		||||
      if ( mG ) GEOSGeom_destroy( mG );
 | 
			
		||||
      if ( mG )
 | 
			
		||||
        GEOSGeom_destroy( mG );
 | 
			
		||||
      delete mInfo;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -82,7 +83,8 @@ class QgsPalGeometry : public PalGeometry
 | 
			
		||||
 | 
			
		||||
    pal::LabelInfo* info( QFontMetricsF* fm, const QgsMapToPixel* xform, double fontScale )
 | 
			
		||||
    {
 | 
			
		||||
      if ( mInfo ) return mInfo;
 | 
			
		||||
      if ( mInfo )
 | 
			
		||||
        return mInfo;
 | 
			
		||||
 | 
			
		||||
      // create label info!
 | 
			
		||||
      QgsPoint ptZero = xform->toMapCoordinates( 0, 0 );
 | 
			
		||||
@ -714,7 +716,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,
 | 
			
		||||
    case QgsPalLayerSettings::Curved:      arrangement = P_CURVED; break;
 | 
			
		||||
    case QgsPalLayerSettings::Horizontal:  arrangement = P_HORIZ; break;
 | 
			
		||||
    case QgsPalLayerSettings::Free:        arrangement = P_FREE; break;
 | 
			
		||||
    default: Q_ASSERT( "unsupported placement" && 0 ); return 0; break;
 | 
			
		||||
    default: Q_ASSERT( "unsupported placement" && 0 ); return 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // create the pal layer
 | 
			
		||||
 | 
			
		||||
@ -331,8 +331,7 @@ typedef QgsDataProvider * classFactoryFunction_t( const QString * );
 | 
			
		||||
 *        It seems more sensible to provide the code in one place rather than
 | 
			
		||||
 *        in qgsrasterlayer, qgsvectorlayer, serversourceselect, etc.
 | 
			
		||||
 */
 | 
			
		||||
QgsDataProvider* QgsProviderRegistry::getProvider( QString const & providerKey,
 | 
			
		||||
    QString const & dataSource )
 | 
			
		||||
QgsDataProvider *QgsProviderRegistry::provider( QString const & providerKey, QString const & dataSource )
 | 
			
		||||
{
 | 
			
		||||
  // XXX should I check for and possibly delete any pre-existing providers?
 | 
			
		||||
  // XXX How often will that scenario occur?
 | 
			
		||||
@ -430,24 +429,25 @@ QgsDataProvider* QgsProviderRegistry::getProvider( QString const & providerKey,
 | 
			
		||||
// This should be QWidget, not QDialog
 | 
			
		||||
typedef QWidget * selectFactoryFunction_t( QWidget * parent, Qt::WFlags fl );
 | 
			
		||||
 | 
			
		||||
QWidget* QgsProviderRegistry::getSelectWidget( const QString & providerKey,
 | 
			
		||||
   QWidget * parent, Qt::WFlags fl )
 | 
			
		||||
QWidget* QgsProviderRegistry::selectWidget( const QString & providerKey,
 | 
			
		||||
    QWidget * parent, Qt::WFlags fl )
 | 
			
		||||
{
 | 
			
		||||
  QLibrary *myLib = getLibrary( providerKey );
 | 
			
		||||
  if ( !myLib ) return 0;
 | 
			
		||||
  QLibrary *myLib = providerLibrary( providerKey );
 | 
			
		||||
  if ( !myLib )
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  selectFactoryFunction_t * selectFactory =
 | 
			
		||||
    ( selectFactoryFunction_t * ) cast_to_fptr( myLib->resolve( "selectWidget" ) );
 | 
			
		||||
 | 
			
		||||
  if ( !selectFactory ) return 0;
 | 
			
		||||
  if ( !selectFactory )
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  QWidget *widget  = ( *selectFactory )( parent, fl );
 | 
			
		||||
  return widget;
 | 
			
		||||
  return selectFactory( parent, fl );
 | 
			
		||||
}
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
void * QgsProviderRegistry::getFunction( QString const & providerKey,
 | 
			
		||||
    QString const & functionName )
 | 
			
		||||
 | 
			
		||||
void * QgsProviderRegistry::function( QString const & providerKey,
 | 
			
		||||
                                      QString const & functionName )
 | 
			
		||||
{
 | 
			
		||||
  QString lib = library( providerKey );
 | 
			
		||||
 | 
			
		||||
@ -467,20 +467,20 @@ void * QgsProviderRegistry::getFunction( QString const & providerKey,
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QLibrary * QgsProviderRegistry::getLibrary( QString const & providerKey )
 | 
			
		||||
QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey )
 | 
			
		||||
{
 | 
			
		||||
  QString lib = library( providerKey );
 | 
			
		||||
 | 
			
		||||
  QLibrary* myLib = new QLibrary( lib );
 | 
			
		||||
  QLibrary *myLib = new QLibrary( lib );
 | 
			
		||||
 | 
			
		||||
  QgsDebugMsg( "Library name is " + myLib->fileName() );
 | 
			
		||||
 | 
			
		||||
  bool loaded = myLib->load();
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  if ( loaded )
 | 
			
		||||
  {
 | 
			
		||||
    return myLib;
 | 
			
		||||
  } 
 | 
			
		||||
  }
 | 
			
		||||
  delete myLib;
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -65,21 +65,21 @@ class CORE_EXPORT QgsProviderRegistry
 | 
			
		||||
        @param dataSource  string containing data source for the provider
 | 
			
		||||
        @return instance of provider or NULL on error
 | 
			
		||||
     */
 | 
			
		||||
    QgsDataProvider * getProvider( const QString & providerKey,
 | 
			
		||||
                                   const QString & dataSource );
 | 
			
		||||
    QgsDataProvider *provider( const QString & providerKey,
 | 
			
		||||
                               const QString & dataSource );
 | 
			
		||||
 | 
			
		||||
    QWidget * getSelectWidget ( const QString & providerKey, 
 | 
			
		||||
                                QWidget * parent=0, Qt::WFlags fl=0 );
 | 
			
		||||
    QWidget *selectWidget( const QString & providerKey,
 | 
			
		||||
                           QWidget * parent = 0, Qt::WFlags fl = 0 );
 | 
			
		||||
 | 
			
		||||
    /** Get pointer to provider function
 | 
			
		||||
        @param providerKey identificator of the provider
 | 
			
		||||
        @param functionName name of function
 | 
			
		||||
        @return pointer to function or NULL on error
 | 
			
		||||
     */
 | 
			
		||||
    void * getFunction( const QString & providerKey,
 | 
			
		||||
                        const QString & functionName );
 | 
			
		||||
    void *function( const QString & providerKey,
 | 
			
		||||
                    const QString & functionName );
 | 
			
		||||
 | 
			
		||||
    QLibrary * getLibrary ( const QString & providerKey );
 | 
			
		||||
    QLibrary *providerLibrary( const QString & providerKey );
 | 
			
		||||
 | 
			
		||||
    /** Return list of available providers by their keys */
 | 
			
		||||
    QStringList providerList() const;
 | 
			
		||||
 | 
			
		||||
@ -19,7 +19,7 @@ bool QgsPythonRunner::run( QString command, QString messageOnError )
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    QgsDebugMsg("Unable to run Python command: runner not available!");
 | 
			
		||||
    QgsDebugMsg( "Unable to run Python command: runner not available!" );
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,7 @@
 | 
			
		||||
 */
 | 
			
		||||
class CORE_EXPORT QgsPythonRunner
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
  public:
 | 
			
		||||
 | 
			
		||||
    /** returns true if the runner has an instance
 | 
			
		||||
        (and thus is able to run commands) */
 | 
			
		||||
@ -28,7 +28,7 @@ public:
 | 
			
		||||
      Takes ownership of the object, deletes previous instance. */
 | 
			
		||||
    static void setInstance( QgsPythonRunner* runner );
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
  protected:
 | 
			
		||||
    /** protected constructor: can be instantiated only from children */
 | 
			
		||||
    QgsPythonRunner();
 | 
			
		||||
    virtual ~QgsPythonRunner();
 | 
			
		||||
 | 
			
		||||
@ -54,7 +54,8 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle  const & viewExt
 | 
			
		||||
  // TODO: init data by nulls
 | 
			
		||||
 | 
			
		||||
  // If we zoom out too much, projector srcRows / srcCols maybe 0, which can cause problems in providers
 | 
			
		||||
  if ( myProjector.srcRows() <= 0 || myProjector.srcCols() <= 0 ) return;
 | 
			
		||||
  if ( myProjector.srcRows() <= 0 || myProjector.srcCols() <= 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Allocate memory for not projected source data
 | 
			
		||||
  int mySize = dataTypeSize( bandNo ) / 8;
 | 
			
		||||
 | 
			
		||||
@ -16,8 +16,6 @@
 | 
			
		||||
 ***************************************************************************/
 | 
			
		||||
/* $Id: qgsrasterprojector.cpp 15005 2011-01-08 16:35:21Z rblazek $ */
 | 
			
		||||
 | 
			
		||||
#include <cassert>
 | 
			
		||||
 | 
			
		||||
#include "qgslogger.h"
 | 
			
		||||
#include "qgsrasterprojector.h"
 | 
			
		||||
#include "qgscoordinatetransform.h"
 | 
			
		||||
@ -176,10 +174,12 @@ QString QgsRasterProjector::cpToString()
 | 
			
		||||
  QString myString;
 | 
			
		||||
  for ( int i = 0; i < mCPRows; i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( i > 0 ) myString += "\n";
 | 
			
		||||
    if ( i > 0 )
 | 
			
		||||
      myString += "\n";
 | 
			
		||||
    for ( int j = 0; j < mCPCols; j++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( j > 0 ) myString += "  ";
 | 
			
		||||
      if ( j > 0 )
 | 
			
		||||
        myString += "  ";
 | 
			
		||||
      QgsPoint myPoint = mCPMatrix[i][j];
 | 
			
		||||
      myString += myPoint.toString();
 | 
			
		||||
    }
 | 
			
		||||
@ -210,10 +210,12 @@ void QgsRasterProjector::calcSrcRowsCols()
 | 
			
		||||
      QgsPoint myPointB = mCPMatrix[i][j+1];
 | 
			
		||||
      QgsPoint myPointC = mCPMatrix[i+1][j];
 | 
			
		||||
      double mySize = sqrt( myPointA.sqrDist( myPointB ) ) / myDestColsPerMatrixCell;
 | 
			
		||||
      if ( mySize < myMinSize ) { myMinSize = mySize; }
 | 
			
		||||
      if ( mySize < myMinSize )
 | 
			
		||||
        myMinSize = mySize;
 | 
			
		||||
 | 
			
		||||
      mySize = sqrt( myPointA.sqrDist( myPointC ) ) / myDestRowsPerMatrixCell;
 | 
			
		||||
      if ( mySize < myMinSize ) { myMinSize = mySize; }
 | 
			
		||||
      if ( mySize < myMinSize )
 | 
			
		||||
        myMinSize = mySize;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -294,7 +296,8 @@ void QgsRasterProjector::nextHelper()
 | 
			
		||||
 | 
			
		||||
void QgsRasterProjector::srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
 | 
			
		||||
{
 | 
			
		||||
  if ( mApproximate ) approximateSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol );
 | 
			
		||||
  if ( mApproximate )
 | 
			
		||||
    approximateSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol );
 | 
			
		||||
  else preciseSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -321,13 +324,17 @@ void QgsRasterProjector::preciseSrcRowCol( int theDestRow, int theDestCol, int *
 | 
			
		||||
  // With epsg 32661 (Polar Stereographic) it was happening that *theSrcCol == mSrcCols
 | 
			
		||||
  // For now silently correct limits to avoid crashes
 | 
			
		||||
  // TODO: review
 | 
			
		||||
  if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1;
 | 
			
		||||
  if ( *theSrcRow < 0 ) *theSrcRow = 0;
 | 
			
		||||
  if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1;
 | 
			
		||||
  if ( *theSrcCol < 0 ) *theSrcCol = 0;
 | 
			
		||||
  if ( *theSrcRow >= mSrcRows )
 | 
			
		||||
    *theSrcRow = mSrcRows - 1;
 | 
			
		||||
  if ( *theSrcRow < 0 )
 | 
			
		||||
    *theSrcRow = 0;
 | 
			
		||||
  if ( *theSrcCol >= mSrcCols )
 | 
			
		||||
    *theSrcCol = mSrcCols - 1;
 | 
			
		||||
  if ( *theSrcCol < 0 )
 | 
			
		||||
    *theSrcCol = 0;
 | 
			
		||||
 | 
			
		||||
  assert( *theSrcRow < mSrcRows );
 | 
			
		||||
  assert( *theSrcCol < mSrcCols );
 | 
			
		||||
  Q_ASSERT( *theSrcRow < mSrcRows );
 | 
			
		||||
  Q_ASSERT( *theSrcCol < mSrcCols );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
 | 
			
		||||
@ -373,12 +380,16 @@ void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, i
 | 
			
		||||
 | 
			
		||||
  // For now silently correct limits to avoid crashes
 | 
			
		||||
  // TODO: review
 | 
			
		||||
  if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1;
 | 
			
		||||
  if ( *theSrcRow < 0 ) *theSrcRow = 0;
 | 
			
		||||
  if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1;
 | 
			
		||||
  if ( *theSrcCol < 0 ) *theSrcCol = 0;
 | 
			
		||||
  assert( *theSrcRow < mSrcRows );
 | 
			
		||||
  assert( *theSrcCol < mSrcCols );
 | 
			
		||||
  if ( *theSrcRow >= mSrcRows )
 | 
			
		||||
    *theSrcRow = mSrcRows - 1;
 | 
			
		||||
  if ( *theSrcRow < 0 )
 | 
			
		||||
    *theSrcRow = 0;
 | 
			
		||||
  if ( *theSrcCol >= mSrcCols )
 | 
			
		||||
    *theSrcCol = mSrcCols - 1;
 | 
			
		||||
  if ( *theSrcCol < 0 )
 | 
			
		||||
    *theSrcCol = 0;
 | 
			
		||||
  Q_ASSERT( *theSrcRow < mSrcRows );
 | 
			
		||||
  Q_ASSERT( *theSrcCol < mSrcCols );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsRasterProjector::insertRows()
 | 
			
		||||
@ -466,7 +477,8 @@ bool QgsRasterProjector::checkCols()
 | 
			
		||||
      QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
 | 
			
		||||
      QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
 | 
			
		||||
      double mySqrDist = myDestApprox.sqrDist( myDestPoint );
 | 
			
		||||
      if ( mySqrDist > mSqrTolerance ) { return false; }
 | 
			
		||||
      if ( mySqrDist > mSqrTolerance )
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return true;
 | 
			
		||||
@ -489,7 +501,8 @@ bool QgsRasterProjector::checkRows()
 | 
			
		||||
      QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
 | 
			
		||||
      QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
 | 
			
		||||
      double mySqrDist = myDestApprox.sqrDist( myDestPoint );
 | 
			
		||||
      if ( mySqrDist > mSqrTolerance ) { return false; }
 | 
			
		||||
      if ( mySqrDist > mSqrTolerance )
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return true;
 | 
			
		||||
 | 
			
		||||
@ -200,7 +200,7 @@ class QgsRasterProjector
 | 
			
		||||
    /** Maximum source resolution */
 | 
			
		||||
    double mMaxSrcXRes;
 | 
			
		||||
    double mMaxSrcYRes;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /** Use approximation */
 | 
			
		||||
    bool mApproximate;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -150,10 +150,12 @@ bool QgsRectangle::intersects( const QgsRectangle& rect ) const
 | 
			
		||||
{
 | 
			
		||||
  double x1 = ( xmin > rect.xmin ? xmin : rect.xmin );
 | 
			
		||||
  double x2 = ( xmax < rect.xmax ? xmax : rect.xmax );
 | 
			
		||||
  if ( x1 > x2 ) return false;
 | 
			
		||||
  if ( x1 > x2 )
 | 
			
		||||
    return false;
 | 
			
		||||
  double y1 = ( ymin > rect.ymin ? ymin : rect.ymin );
 | 
			
		||||
  double y2 = ( ymax < rect.ymax ? ymax : rect.ymax );
 | 
			
		||||
  if ( y1 > y2 ) return false;
 | 
			
		||||
  if ( y1 > y2 )
 | 
			
		||||
    return false;
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -300,10 +302,14 @@ QgsRectangle & QgsRectangle::operator=( const QgsRectangle & r )
 | 
			
		||||
 | 
			
		||||
void QgsRectangle::unionRect( const QgsRectangle& r )
 | 
			
		||||
{
 | 
			
		||||
  if ( r.xMinimum() < xMinimum() ) setXMinimum( r.xMinimum() );
 | 
			
		||||
  if ( r.xMaximum() > xMaximum() ) setXMaximum( r.xMaximum() );
 | 
			
		||||
  if ( r.yMinimum() < yMinimum() ) setYMinimum( r.yMinimum() );
 | 
			
		||||
  if ( r.yMaximum() > yMaximum() ) setYMaximum( r.yMaximum() );
 | 
			
		||||
  if ( r.xMinimum() < xMinimum() )
 | 
			
		||||
    setXMinimum( r.xMinimum() );
 | 
			
		||||
  if ( r.xMaximum() > xMaximum() )
 | 
			
		||||
    setXMaximum( r.xMaximum() );
 | 
			
		||||
  if ( r.yMinimum() < yMinimum() )
 | 
			
		||||
    setYMinimum( r.yMinimum() );
 | 
			
		||||
  if ( r.yMaximum() > yMaximum() )
 | 
			
		||||
    setYMaximum( r.yMaximum() );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool QgsRectangle::isFinite() const
 | 
			
		||||
 | 
			
		||||
@ -644,19 +644,24 @@ QgsSearchTreeValue QgsSearchTreeNode::valueAgainst( const QgsFieldMap& fields, Q
 | 
			
		||||
      {
 | 
			
		||||
        if ( mLeft->type() != tNodeList )
 | 
			
		||||
        {
 | 
			
		||||
          if ( !getValue( value1, mLeft, fields, f ) ) return value1;
 | 
			
		||||
          if ( !getValue( value1, mLeft, fields, f ) )
 | 
			
		||||
            return value1;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          if ( mLeft->mNodeList.size() > 0 && !getValue( value1, mLeft->mNodeList[0], fields, f ) ) return value1;
 | 
			
		||||
          if ( mLeft->mNodeList.size() > 1 && !getValue( value2, mLeft->mNodeList[1], fields, f ) ) return value2;
 | 
			
		||||
          if ( mLeft->mNodeList.size() > 2 && !getValue( value3, mLeft->mNodeList[2], fields, f ) ) return value3;
 | 
			
		||||
          if ( mLeft->mNodeList.size() > 0 && !getValue( value1, mLeft->mNodeList[0], fields, f ) )
 | 
			
		||||
            return value1;
 | 
			
		||||
          if ( mLeft->mNodeList.size() > 1 && !getValue( value2, mLeft->mNodeList[1], fields, f ) )
 | 
			
		||||
            return value2;
 | 
			
		||||
          if ( mLeft->mNodeList.size() > 2 && !getValue( value3, mLeft->mNodeList[2], fields, f ) )
 | 
			
		||||
            return value3;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      if ( mRight )
 | 
			
		||||
      {
 | 
			
		||||
        Q_ASSERT( !mLeft || mLeft->type() != tNodeList );
 | 
			
		||||
        if ( !getValue( value2, mRight, fields, f ) ) return value2;
 | 
			
		||||
        if ( !getValue( value2, mRight, fields, f ) )
 | 
			
		||||
          return value2;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if ( mOp == opLENGTH || mOp == opAREA || mOp == opPERIMETER || mOp == opX || mOp == opY )
 | 
			
		||||
 | 
			
		||||
@ -2711,7 +2711,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
 | 
			
		||||
  //XXX - This was a dynamic cast but that kills the Windows
 | 
			
		||||
  //      version big-time with an abnormal termination error
 | 
			
		||||
  mDataProvider =
 | 
			
		||||
    ( QgsVectorDataProvider* )( QgsProviderRegistry::instance()->getProvider( provider, mDataSource ) );
 | 
			
		||||
    ( QgsVectorDataProvider* )( QgsProviderRegistry::instance()->provider( provider, mDataSource ) );
 | 
			
		||||
 | 
			
		||||
  if ( mDataProvider )
 | 
			
		||||
  {
 | 
			
		||||
@ -2902,11 +2902,15 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
 | 
			
		||||
 | 
			
		||||
      if ( returnCode == 1 )
 | 
			
		||||
      {
 | 
			
		||||
        errorMessage = tr( "No renderer object" ); delete renderer; return false;
 | 
			
		||||
        errorMessage = tr( "No renderer object" );
 | 
			
		||||
        delete renderer;
 | 
			
		||||
        return false;
 | 
			
		||||
      }
 | 
			
		||||
      else if ( returnCode == 2 )
 | 
			
		||||
      {
 | 
			
		||||
        errorMessage = tr( "Classification field not found" ); delete renderer; return false;
 | 
			
		||||
        errorMessage = tr( "Classification field not found" );
 | 
			
		||||
        delete renderer;
 | 
			
		||||
        return false;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      mRenderer = renderer;
 | 
			
		||||
@ -5514,7 +5518,7 @@ QString QgsVectorLayer::metadata()
 | 
			
		||||
  myMetadata += "</body></html>";
 | 
			
		||||
  return myMetadata;
 | 
			
		||||
}
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
QgsVectorLayer::ValueRelationData &QgsVectorLayer::valueRelation( int idx )
 | 
			
		||||
{
 | 
			
		||||
  const QgsFieldMap &fields = pendingFields();
 | 
			
		||||
 | 
			
		||||
@ -193,10 +193,14 @@ bool QgsContrastEnhancement::generateLookupTable()
 | 
			
		||||
{
 | 
			
		||||
  mEnhancementDirty = false;
 | 
			
		||||
 | 
			
		||||
  if ( 0 == mContrastEnhancementFunction ) { return false; }
 | 
			
		||||
  if ( NoEnhancement == mContrastEnhancementAlgorithm ) { return false; }
 | 
			
		||||
  if ( QGS_Byte != mRasterDataType && QGS_UInt16 != mRasterDataType && QGS_Int16 != mRasterDataType ) { return false; }
 | 
			
		||||
  if ( !mLookupTable ) { return false; }
 | 
			
		||||
  if ( !mContrastEnhancementFunction )
 | 
			
		||||
    return false;
 | 
			
		||||
  if ( NoEnhancement == mContrastEnhancementAlgorithm )
 | 
			
		||||
    return false;
 | 
			
		||||
  if ( QGS_Byte != mRasterDataType && QGS_UInt16 != mRasterDataType && QGS_Int16 != mRasterDataType )
 | 
			
		||||
    return false;
 | 
			
		||||
  if ( !mLookupTable )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  QgsDebugMsg( "building lookup table" );
 | 
			
		||||
  QgsDebugMsg( "***MinimumValue : " + QString::number( mMinimumValue ) );
 | 
			
		||||
 | 
			
		||||
@ -238,7 +238,8 @@ QDateTime QgsRasterLayer::lastModified( QString const & name )
 | 
			
		||||
  QFileInfo fi( name );
 | 
			
		||||
 | 
			
		||||
  // Is it file?
 | 
			
		||||
  if ( !fi.exists() ) return t;
 | 
			
		||||
  if ( !fi.exists() )
 | 
			
		||||
    return t;
 | 
			
		||||
 | 
			
		||||
  t = fi.lastModified();
 | 
			
		||||
 | 
			
		||||
@ -580,7 +581,8 @@ QString QgsRasterLayer::colorShadingAlgorithmAsString() const
 | 
			
		||||
 */
 | 
			
		||||
void QgsRasterLayer::computeMinimumMaximumEstimates( int theBand, double* theMinMax )
 | 
			
		||||
{
 | 
			
		||||
  if ( 0 == theMinMax ) { return; }
 | 
			
		||||
  if ( !theMinMax )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  if ( 0 < theBand && theBand <= ( int ) bandCount() )
 | 
			
		||||
  {
 | 
			
		||||
@ -612,7 +614,8 @@ void QgsRasterLayer::computeMinimumMaximumEstimates( int theBand, double& theMin
 | 
			
		||||
 */
 | 
			
		||||
void QgsRasterLayer::computeMinimumMaximumFromLastExtent( int theBand, double* theMinMax )
 | 
			
		||||
{
 | 
			
		||||
  if ( 0 == theMinMax ) { return; }
 | 
			
		||||
  if ( !theMinMax )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  int myDataType = mDataProvider->dataType( theBand );
 | 
			
		||||
  void* myScanData = readData( theBand, &mLastViewPort );
 | 
			
		||||
@ -2543,7 +2546,7 @@ void QgsRasterLayer::setColorShadingAlgorithm( ColorShadingAlgorithm theShadingA
 | 
			
		||||
  QgsDebugMsg( "called with [" + QString::number( theShadingAlgorithm ) + "]" );
 | 
			
		||||
  if ( mColorShadingAlgorithm != theShadingAlgorithm )
 | 
			
		||||
  {
 | 
			
		||||
    if ( 0 == mRasterShader )
 | 
			
		||||
    if ( !mRasterShader )
 | 
			
		||||
    {
 | 
			
		||||
      mRasterShader = new QgsRasterShader();
 | 
			
		||||
    }
 | 
			
		||||
@ -2898,7 +2901,8 @@ QStringList QgsRasterLayer::subLayers() const
 | 
			
		||||
void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
 | 
			
		||||
{
 | 
			
		||||
  //TODO: This should be depreciated and a new function written that just returns a new QPixmap, it will be safer
 | 
			
		||||
  if ( 0 == theQPixmap ) { return; }
 | 
			
		||||
  if ( !theQPixmap )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  theQPixmap->fill( );  //defaults to white
 | 
			
		||||
 | 
			
		||||
@ -2950,7 +2954,9 @@ void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
 | 
			
		||||
void QgsRasterLayer::thumbnailAsImage( QImage * thepImage )
 | 
			
		||||
{
 | 
			
		||||
  //TODO: This should be depreciated and a new function written that just returns a new QImage, it will be safer
 | 
			
		||||
  if ( 0 == thepImage ) { return; }
 | 
			
		||||
  if ( !thepImage )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  thepImage->fill( Qt::white ); //defaults to white
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,8 @@ class CORE_EXPORT QgsColorBrewerPalette
 | 
			
		||||
      foreach( QString entry, list )
 | 
			
		||||
      {
 | 
			
		||||
        QStringList items = entry.split( QChar( '-' ) );
 | 
			
		||||
        if ( items.count() != 3 ) continue;
 | 
			
		||||
        if ( items.count() != 3 )
 | 
			
		||||
          continue;
 | 
			
		||||
        if ( !schemes.contains( items[0] ) )
 | 
			
		||||
          schemes << items[0];
 | 
			
		||||
      }
 | 
			
		||||
@ -49,7 +50,8 @@ class CORE_EXPORT QgsColorBrewerPalette
 | 
			
		||||
      foreach( QString entry, list )
 | 
			
		||||
      {
 | 
			
		||||
        QStringList items = entry.split( QChar( '-' ) );
 | 
			
		||||
        if ( items.count() != 3 || items[0] != schemeName ) continue;
 | 
			
		||||
        if ( items.count() != 3 || items[0] != schemeName )
 | 
			
		||||
          continue;
 | 
			
		||||
        variants << items[1].toInt();
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -59,7 +61,8 @@ class CORE_EXPORT QgsColorBrewerPalette
 | 
			
		||||
    static QColor parseColor( QString color )
 | 
			
		||||
    {
 | 
			
		||||
      QStringList p = color.split( QChar( ',' ) );
 | 
			
		||||
      if ( p.count() != 3 ) return QColor();
 | 
			
		||||
      if ( p.count() != 3 )
 | 
			
		||||
        return QColor();
 | 
			
		||||
      return QColor( p[0].toInt(), p[1].toInt(), p[2].toInt() );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -64,7 +64,8 @@ void QgsSimpleFillSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context
 | 
			
		||||
  QColor selColor = context.selectionColor();
 | 
			
		||||
  // selColor.setAlphaF( context.alpha() );
 | 
			
		||||
  mSelBrush = QBrush( selColor );
 | 
			
		||||
  if ( selectFillStyle )  mSelBrush.setStyle( mBrushStyle );
 | 
			
		||||
  if ( selectFillStyle )
 | 
			
		||||
    mSelBrush.setStyle( mBrushStyle );
 | 
			
		||||
  mBorderColor.setAlphaF( context.alpha() );
 | 
			
		||||
  mPen = QPen( mBorderColor );
 | 
			
		||||
  mPen.setStyle( mBorderStyle );
 | 
			
		||||
@ -251,7 +252,8 @@ void QgsSVGFillSymbolLayer::renderPolygon( const QPolygonF& points, QList<QPolyg
 | 
			
		||||
  if ( context.selected() )
 | 
			
		||||
  {
 | 
			
		||||
    QColor selColor = context.selectionColor();
 | 
			
		||||
    if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() );
 | 
			
		||||
    if ( ! selectionIsOpaque )
 | 
			
		||||
      selColor.setAlphaF( context.alpha() );
 | 
			
		||||
    p->setBrush( QBrush( selColor ) );
 | 
			
		||||
    _renderPolygon( p, points, rings );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -86,7 +86,8 @@ void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context
 | 
			
		||||
 | 
			
		||||
  mSelPen = mPen;
 | 
			
		||||
  QColor selColor = context.selectionColor();
 | 
			
		||||
  if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() );
 | 
			
		||||
  if ( ! selectionIsOpaque )
 | 
			
		||||
    selColor.setAlphaF( context.alpha() );
 | 
			
		||||
  mSelPen.setColor( selColor );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -619,7 +620,8 @@ void QgsLineDecorationSymbolLayerV2::startRender( QgsSymbolV2RenderContext& cont
 | 
			
		||||
  mPen.setWidth( context.outputLineWidth( mWidth ) );
 | 
			
		||||
  mPen.setColor( penColor );
 | 
			
		||||
  QColor selColor = context.selectionColor();
 | 
			
		||||
  if ( ! selectionIsOpaque ) selColor.setAlphaF( context.alpha() );
 | 
			
		||||
  if ( ! selectionIsOpaque )
 | 
			
		||||
    selColor.setAlphaF( context.alpha() );
 | 
			
		||||
  mSelPen.setWidth( context.outputLineWidth( mWidth ) );
 | 
			
		||||
  mSelPen.setColor( selColor );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -80,8 +80,10 @@ void QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const Qg
 | 
			
		||||
    mTempSymbol = mSymbol->clone();
 | 
			
		||||
 | 
			
		||||
    int hints = 0;
 | 
			
		||||
    if ( mRotationFieldIdx != -1 ) hints |= QgsSymbolV2::DataDefinedRotation;
 | 
			
		||||
    if ( mSizeScaleFieldIdx != -1 ) hints |= QgsSymbolV2::DataDefinedSizeScale;
 | 
			
		||||
    if ( mRotationFieldIdx != -1 )
 | 
			
		||||
      hints |= QgsSymbolV2::DataDefinedRotation;
 | 
			
		||||
    if ( mSizeScaleFieldIdx != -1 )
 | 
			
		||||
      hints |= QgsSymbolV2::DataDefinedSizeScale;
 | 
			
		||||
    mTempSymbol->setRenderHints( hints );
 | 
			
		||||
 | 
			
		||||
    mTempSymbol->startRender( context );
 | 
			
		||||
 | 
			
		||||
@ -366,7 +366,8 @@ QPolygonF offsetLine( QPolygonF polyline, double dist )
 | 
			
		||||
      // if it's not the first line segment
 | 
			
		||||
      // calc intersection with last line (with offset)
 | 
			
		||||
      QPointF pt_tmp = linesIntersection( pt_old, t_old, pt_new, t_new );
 | 
			
		||||
      if ( !pt_tmp.isNull() ) pt_new = pt_tmp;
 | 
			
		||||
      if ( !pt_tmp.isNull() )
 | 
			
		||||
        pt_new = pt_tmp;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    newLine.append( pt_new );
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,8 @@ QgsVectorColorRampV2* QgsVectorGradientColorRampV2::create( const QgsStringMap&
 | 
			
		||||
    foreach( QString stop, props["stops"].split( ':' ) )
 | 
			
		||||
    {
 | 
			
		||||
      int i = stop.indexOf( ';' );
 | 
			
		||||
      if ( i == -1 ) continue;
 | 
			
		||||
      if ( i == -1 )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      QColor c = QgsSymbolLayerV2Utils::decodeColor( stop.mid( i + 1 ) );
 | 
			
		||||
      stops.insert( stop.left( i ).toDouble(), c );
 | 
			
		||||
 | 
			
		||||
@ -205,7 +205,8 @@ QPicture QgsMarkerCatalogue::pictureMarker( QString fullName, double size, QPen
 | 
			
		||||
  {
 | 
			
		||||
    // TODO Change this logic so width is size and height is same
 | 
			
		||||
    // proportion of scale factor as in oritignal SVG TS XXX
 | 
			
		||||
    if ( size < 1 ) size = 1;
 | 
			
		||||
    if ( size < 1 )
 | 
			
		||||
      size = 1;
 | 
			
		||||
    myPicture = QPicture( size );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -116,7 +116,6 @@ qgsmaptoolemitpoint.h
 | 
			
		||||
qgsmessageviewer.h
 | 
			
		||||
qgsnewhttpconnection.h
 | 
			
		||||
qgsnewvectorlayerdialog.h
 | 
			
		||||
qgsnumericsortlistviewitem.h
 | 
			
		||||
qgscredentialdialog.h
 | 
			
		||||
qgsprojectionselector.h
 | 
			
		||||
qgsquickprint.h
 | 
			
		||||
 | 
			
		||||
@ -109,7 +109,7 @@ void QgsAttributeTableView::contextMenuEvent( QContextMenuEvent *event )
 | 
			
		||||
  mActionPopup = new QMenu();
 | 
			
		||||
 | 
			
		||||
  // let some other parts of the application add some actions
 | 
			
		||||
  emit willShowContextMenu(mActionPopup, idx);
 | 
			
		||||
  emit willShowContextMenu( mActionPopup, idx );
 | 
			
		||||
 | 
			
		||||
  if ( mActionPopup->actions().count() > 0 )
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
@ -277,8 +277,10 @@ QStringList QgsDetailedItemDelegate::wordWrap( QString theString,
 | 
			
		||||
    QFontMetrics theMetrics,
 | 
			
		||||
    int theWidth ) const
 | 
			
		||||
{
 | 
			
		||||
  if ( theString.isEmpty() ) return QStringList();
 | 
			
		||||
  if ( 50 >= theWidth ) return QStringList() << theString;
 | 
			
		||||
  if ( theString.isEmpty() )
 | 
			
		||||
    return QStringList();
 | 
			
		||||
  if ( 50 >= theWidth )
 | 
			
		||||
    return QStringList() << theString;
 | 
			
		||||
  //QString myDebug = QString("Word wrapping: %1 into %2 pixels").arg(theString).arg(theWidth);
 | 
			
		||||
  //qDebug(myDebug.toLocal8Bit());
 | 
			
		||||
  //iterate the string
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@ class QFont;
 | 
			
		||||
 * @see also QgsDetailedItemData
 | 
			
		||||
 */
 | 
			
		||||
class GUI_EXPORT QgsDetailedItemDelegate :
 | 
			
		||||
    public QAbstractItemDelegate
 | 
			
		||||
      public QAbstractItemDelegate
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
  public:
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@
 | 
			
		||||
 * @see also QgsDetailedItem and QgsDetailedItemData.
 | 
			
		||||
 */
 | 
			
		||||
class QgsDetailedItemWidget :
 | 
			
		||||
    public QWidget, private Ui::QgsDetailedItemWidgetBase
 | 
			
		||||
      public QWidget, private Ui::QgsDetailedItemWidgetBase
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
  public:
 | 
			
		||||
 | 
			
		||||
@ -395,22 +395,28 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co
 | 
			
		||||
    // check for duplicates
 | 
			
		||||
    if ( keys.contains( connectionName ) && prompt )
 | 
			
		||||
    {
 | 
			
		||||
      int res = QMessageBox::warning( this, tr( "Loading connections" ),
 | 
			
		||||
      int res = QMessageBox::warning( this,
 | 
			
		||||
                                      tr( "Loading connections" ),
 | 
			
		||||
                                      tr( "Connection with name '%1' already exists. Overwrite?" )
 | 
			
		||||
                                      .arg( connectionName ),
 | 
			
		||||
                                      QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 | 
			
		||||
 | 
			
		||||
      switch ( res )
 | 
			
		||||
      {
 | 
			
		||||
        case QMessageBox::Cancel:   return;
 | 
			
		||||
        case QMessageBox::No:       child = child.nextSiblingElement();
 | 
			
		||||
        case QMessageBox::Cancel:
 | 
			
		||||
          return;
 | 
			
		||||
        case QMessageBox::No:
 | 
			
		||||
          child = child.nextSiblingElement();
 | 
			
		||||
          continue;
 | 
			
		||||
        case QMessageBox::Yes:      overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::YesToAll: prompt = false;
 | 
			
		||||
        case QMessageBox::Yes:
 | 
			
		||||
          overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::NoToAll:  prompt = false;
 | 
			
		||||
        case QMessageBox::YesToAll:
 | 
			
		||||
          prompt = false;
 | 
			
		||||
          overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::NoToAll:
 | 
			
		||||
          prompt = false;
 | 
			
		||||
          overwrite = false;
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
@ -471,22 +477,28 @@ void QgsManageConnectionsDialog::loadWFSConnections( const QDomDocument &doc, co
 | 
			
		||||
    // check for duplicates
 | 
			
		||||
    if ( keys.contains( connectionName ) && prompt )
 | 
			
		||||
    {
 | 
			
		||||
      int res = QMessageBox::warning( this, tr( "Loading connections" ),
 | 
			
		||||
      int res = QMessageBox::warning( this,
 | 
			
		||||
                                      tr( "Loading connections" ),
 | 
			
		||||
                                      tr( "Connection with name '%1' already exists. Overwrite?" )
 | 
			
		||||
                                      .arg( connectionName ),
 | 
			
		||||
                                      QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 | 
			
		||||
 | 
			
		||||
      switch ( res )
 | 
			
		||||
      {
 | 
			
		||||
        case QMessageBox::Cancel:   return;
 | 
			
		||||
        case QMessageBox::No:       child = child.nextSiblingElement();
 | 
			
		||||
        case QMessageBox::Cancel:
 | 
			
		||||
          return;
 | 
			
		||||
        case QMessageBox::No:
 | 
			
		||||
          child = child.nextSiblingElement();
 | 
			
		||||
          continue;
 | 
			
		||||
        case QMessageBox::Yes:      overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::YesToAll: prompt = false;
 | 
			
		||||
        case QMessageBox::Yes:
 | 
			
		||||
          overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::NoToAll:  prompt = false;
 | 
			
		||||
        case QMessageBox::YesToAll:
 | 
			
		||||
          prompt = false;
 | 
			
		||||
          overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::NoToAll:
 | 
			
		||||
          prompt = false;
 | 
			
		||||
          overwrite = false;
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
@ -554,15 +566,20 @@ void QgsManageConnectionsDialog::loadPgConnections( const QDomDocument &doc, con
 | 
			
		||||
                                      QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 | 
			
		||||
      switch ( res )
 | 
			
		||||
      {
 | 
			
		||||
        case QMessageBox::Cancel:   return;
 | 
			
		||||
        case QMessageBox::No:       child = child.nextSiblingElement();
 | 
			
		||||
        case QMessageBox::Cancel:
 | 
			
		||||
          return;
 | 
			
		||||
        case QMessageBox::No:
 | 
			
		||||
          child = child.nextSiblingElement();
 | 
			
		||||
          continue;
 | 
			
		||||
        case QMessageBox::Yes:      overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::YesToAll: prompt = false;
 | 
			
		||||
        case QMessageBox::Yes:
 | 
			
		||||
          overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::NoToAll:  prompt = false;
 | 
			
		||||
        case QMessageBox::YesToAll:
 | 
			
		||||
          prompt = false;
 | 
			
		||||
          overwrite = true;
 | 
			
		||||
          break;
 | 
			
		||||
        case QMessageBox::NoToAll:
 | 
			
		||||
          prompt = false;
 | 
			
		||||
          overwrite = false;
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -518,7 +518,8 @@ void QgsMapCanvas::setExtent( QgsRectangle const & r )
 | 
			
		||||
  updateScale();
 | 
			
		||||
  if ( mMapOverview )
 | 
			
		||||
    mMapOverview->drawExtentRect();
 | 
			
		||||
  if ( mLastExtent.size() > 20 ) mLastExtent.removeAt( 0 );
 | 
			
		||||
  if ( mLastExtent.size() > 20 )
 | 
			
		||||
    mLastExtent.removeAt( 0 );
 | 
			
		||||
 | 
			
		||||
  //clear all extent items after current index
 | 
			
		||||
  for ( int i = mLastExtent.size() - 1; i > mLastExtentIndex; i-- )
 | 
			
		||||
 | 
			
		||||
@ -127,10 +127,14 @@ void QgsMapOverviewCanvas::drawExtentRect()
 | 
			
		||||
#if 0
 | 
			
		||||
  // test whether panning widget should be drawn
 | 
			
		||||
  bool show = false;
 | 
			
		||||
  if ( ur.x() >= 0 && ur.x() < width() )  show = true;
 | 
			
		||||
  if ( ll.x() >= 0 && ll.x() < width() )  show = true;
 | 
			
		||||
  if ( ur.y() >= 0 && ur.y() < height() ) show = true;
 | 
			
		||||
  if ( ll.y() >= 0 && ll.y() < height() ) show = true;
 | 
			
		||||
  if ( ur.x() >= 0 && ur.x() < width() )
 | 
			
		||||
    show = true;
 | 
			
		||||
  if ( ll.x() >= 0 && ll.x() < width() )
 | 
			
		||||
    show = true;
 | 
			
		||||
  if ( ur.y() >= 0 && ur.y() < height() )
 | 
			
		||||
    show = true;
 | 
			
		||||
  if ( ll.y() >= 0 && ll.y() < height() )
 | 
			
		||||
    show = true;
 | 
			
		||||
  if ( !show )
 | 
			
		||||
  {
 | 
			
		||||
    QgsDebugMsg( "panning: extent out of overview area" );
 | 
			
		||||
@ -153,8 +157,10 @@ void QgsMapOverviewCanvas::drawExtentRect()
 | 
			
		||||
  // are drawn at odd locations) if both coords are at limit. This may
 | 
			
		||||
  // have something to do with Qt calculating dimensions as x2 - x1 + 1.
 | 
			
		||||
  // (INT_MAX - INT_MIN + 1 is UINT_MAX + 1)
 | 
			
		||||
  if ( x1 == INT_MIN && x2 == INT_MAX ) x1 += 1;  // x2 -= 1 works too
 | 
			
		||||
  if ( y1 == INT_MIN && y2 == INT_MAX ) y1 += 1;
 | 
			
		||||
  if ( x1 == INT_MIN && x2 == INT_MAX )
 | 
			
		||||
    x1 += 1;  // x2 -= 1 works too
 | 
			
		||||
  if ( y1 == INT_MIN && y2 == INT_MAX )
 | 
			
		||||
    y1 += 1;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  QRect r( x1, y1, x2 - x1 + 1, y2 - y1 + 1 );
 | 
			
		||||
 | 
			
		||||
@ -227,7 +227,8 @@ void QgsQuickPrint::printMap()
 | 
			
		||||
  //
 | 
			
		||||
  int myOriginalDpi = mpMapRenderer->outputDpi();
 | 
			
		||||
  //sensible default to prevent divide by zero
 | 
			
		||||
  if ( 0 == myOriginalDpi ) myOriginalDpi = 96;
 | 
			
		||||
  if ( 0 == myOriginalDpi )
 | 
			
		||||
    myOriginalDpi = 96;
 | 
			
		||||
  QSize myOriginalSize = mpMapRenderer->outputSize();
 | 
			
		||||
 | 
			
		||||
  //define the font sizes and family
 | 
			
		||||
@ -797,7 +798,8 @@ void QgsQuickPrint::renderPrintScaleBar( QPainter * thepPainter,
 | 
			
		||||
  //
 | 
			
		||||
  // Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze
 | 
			
		||||
  int myLayerCount = thepMapRenderer->layerSet().count();
 | 
			
		||||
  if ( !myLayerCount || !myMapUnitsPerPixelDouble ) return;
 | 
			
		||||
  if ( !myLayerCount || !myMapUnitsPerPixelDouble )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  //Calculate size of scale bar for preferred number of map units
 | 
			
		||||
  double myScaleBarWidth = myPreferredSize;
 | 
			
		||||
@ -1072,9 +1074,8 @@ QString QgsQuickPrint::pageSizeToString( QPrinter::PageSize theSize )
 | 
			
		||||
  if ( theSize == QPrinter::Ledger ) return "QPrinter::Ledger";
 | 
			
		||||
  if ( theSize == QPrinter::Legal ) return "QPrinter::Legal";
 | 
			
		||||
  if ( theSize == QPrinter::Letter ) return "QPrinter::Letter";
 | 
			
		||||
  //falback
 | 
			
		||||
  //fallback
 | 
			
		||||
  return "QPrinter::A4";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QPrinter::PageSize QgsQuickPrint::stringToPageSize( QString theSize )
 | 
			
		||||
@ -1108,10 +1109,6 @@ QPrinter::PageSize QgsQuickPrint::stringToPageSize( QString theSize )
 | 
			
		||||
  if ( theSize == "QPrinter::Ledger" ) return QPrinter::Ledger;
 | 
			
		||||
  if ( theSize == "QPrinter::Legal" ) return QPrinter::Legal;
 | 
			
		||||
  if ( theSize == "QPrinter::Letter" ) return QPrinter::Letter;
 | 
			
		||||
  //falback
 | 
			
		||||
  //fallback
 | 
			
		||||
  return QPrinter::A4;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -120,7 +120,8 @@ void QgsRuleBasedRendererV2Widget::addRule()
 | 
			
		||||
void QgsRuleBasedRendererV2Widget::editRule()
 | 
			
		||||
{
 | 
			
		||||
  QTreeWidgetItem * item = treeRules->currentItem();
 | 
			
		||||
  if ( ! item ) return;
 | 
			
		||||
  if ( ! item )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  int rule_index = item->data( 0, Qt::UserRole + 1 ).toInt();
 | 
			
		||||
  if ( rule_index < 0 )
 | 
			
		||||
@ -144,7 +145,8 @@ void QgsRuleBasedRendererV2Widget::editRule()
 | 
			
		||||
void QgsRuleBasedRendererV2Widget::removeRule()
 | 
			
		||||
{
 | 
			
		||||
  QTreeWidgetItem * item = treeRules->currentItem();
 | 
			
		||||
  if ( ! item ) return;
 | 
			
		||||
  if ( ! item )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  int rule_index = item->data( 0, Qt::UserRole + 1 ).toInt();
 | 
			
		||||
  if ( rule_index < 0 )
 | 
			
		||||
@ -182,10 +184,12 @@ void QgsRuleBasedRendererV2Widget::removeRule()
 | 
			
		||||
void QgsRuleBasedRendererV2Widget::refineRule( int type )
 | 
			
		||||
{
 | 
			
		||||
  QTreeWidgetItem * item = treeRules->currentItem();
 | 
			
		||||
  if ( ! item ) return;
 | 
			
		||||
  if ( ! item )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  int rule_index = item->data( 0, Qt::UserRole + 1 ).toInt();
 | 
			
		||||
  if ( rule_index < 0 ) return;
 | 
			
		||||
  if ( rule_index < 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QgsRuleBasedRendererV2::Rule& initialRule = mRenderer->ruleAt( rule_index );
 | 
			
		||||
 | 
			
		||||
@ -429,7 +433,8 @@ QString QgsRendererRulesTreeWidget::formatScale( int denom, int size )
 | 
			
		||||
#include "qgslogger.h"
 | 
			
		||||
void QgsRendererRulesTreeWidget::populateRules()
 | 
			
		||||
{
 | 
			
		||||
  if ( !mR ) return;
 | 
			
		||||
  if ( !mR )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  clear();
 | 
			
		||||
 | 
			
		||||
@ -473,7 +478,8 @@ void QgsRendererRulesTreeWidget::populateRulesNoGrouping()
 | 
			
		||||
    item->setIcon( 0, QgsSymbolLayerV2Utils::symbolPreviewIcon( rule.symbol(), QSize( 16, 16 ) ) );
 | 
			
		||||
 | 
			
		||||
    QString txtRule = rule.filterExpression();
 | 
			
		||||
    if ( txtRule.isEmpty() ) txtRule = tr( "(no filter)" );
 | 
			
		||||
    if ( txtRule.isEmpty() )
 | 
			
		||||
      txtRule = tr( "(no filter)" );
 | 
			
		||||
    item->setText( 1, txtRule );
 | 
			
		||||
 | 
			
		||||
    if ( rule.dependsOnScale() )
 | 
			
		||||
@ -536,7 +542,8 @@ void QgsRendererRulesTreeWidget::populateRulesGroupByScale()
 | 
			
		||||
    item->setIcon( 0, QgsSymbolLayerV2Utils::symbolPreviewIcon( rule.symbol(), QSize( 16, 16 ) ) );
 | 
			
		||||
 | 
			
		||||
    QString txtRule = rule.filterExpression();
 | 
			
		||||
    if ( txtRule.isEmpty() ) txtRule = tr( "(no filter)" );
 | 
			
		||||
    if ( txtRule.isEmpty() )
 | 
			
		||||
      txtRule = tr( "(no filter)" );
 | 
			
		||||
    item->setText( 1, txtRule );
 | 
			
		||||
 | 
			
		||||
    if ( rule.dependsOnScale() )
 | 
			
		||||
 | 
			
		||||
@ -205,14 +205,19 @@ void QgsStyleV2ExportImportDialog::moveStyles( QModelIndexList* selection, QgsSt
 | 
			
		||||
                                        QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 | 
			
		||||
        switch ( res )
 | 
			
		||||
        {
 | 
			
		||||
          case QMessageBox::Cancel:   return;
 | 
			
		||||
          case QMessageBox::No:       continue;
 | 
			
		||||
          case QMessageBox::Yes:      dst->addSymbol( symbolName, symbol );
 | 
			
		||||
          case QMessageBox::Cancel:
 | 
			
		||||
            return;
 | 
			
		||||
          case QMessageBox::No:
 | 
			
		||||
            continue;
 | 
			
		||||
          case QMessageBox::YesToAll: prompt = false;
 | 
			
		||||
          case QMessageBox::Yes:
 | 
			
		||||
            dst->addSymbol( symbolName, symbol );
 | 
			
		||||
            continue;
 | 
			
		||||
          case QMessageBox::YesToAll:
 | 
			
		||||
            prompt = false;
 | 
			
		||||
            overwrite = true;
 | 
			
		||||
            break;
 | 
			
		||||
          case QMessageBox::NoToAll:  prompt = false;
 | 
			
		||||
          case QMessageBox::NoToAll:
 | 
			
		||||
            prompt = false;
 | 
			
		||||
            overwrite = false;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
@ -241,11 +246,15 @@ void QgsStyleV2ExportImportDialog::moveStyles( QModelIndexList* selection, QgsSt
 | 
			
		||||
                                        QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
 | 
			
		||||
        switch ( res )
 | 
			
		||||
        {
 | 
			
		||||
          case QMessageBox::Cancel:   return;
 | 
			
		||||
          case QMessageBox::No:       continue;
 | 
			
		||||
          case QMessageBox::Yes:      dst->addColorRamp( symbolName, ramp );
 | 
			
		||||
          case QMessageBox::Cancel:
 | 
			
		||||
            return;
 | 
			
		||||
          case QMessageBox::No:
 | 
			
		||||
            continue;
 | 
			
		||||
          case QMessageBox::YesToAll: prompt = false;
 | 
			
		||||
          case QMessageBox::Yes:
 | 
			
		||||
            dst->addColorRamp( symbolName, ramp );
 | 
			
		||||
            continue;
 | 
			
		||||
          case QMessageBox::YesToAll:
 | 
			
		||||
            prompt = false;
 | 
			
		||||
            overwrite = true;
 | 
			
		||||
            break;
 | 
			
		||||
          case QMessageBox::NoToAll:  prompt = false;
 | 
			
		||||
 | 
			
		||||
@ -83,10 +83,17 @@ void QgsStyleV2ManagerDialog::populateTypes()
 | 
			
		||||
  {
 | 
			
		||||
    switch ( mStyle->symbolRef( symbolNames[i] )->type() )
 | 
			
		||||
    {
 | 
			
		||||
      case QgsSymbolV2::Marker: markerCount++; break;
 | 
			
		||||
      case QgsSymbolV2::Line: lineCount++; break;
 | 
			
		||||
      case QgsSymbolV2::Fill: fillCount++; break;
 | 
			
		||||
      default: Q_ASSERT( 0 && "unknown symbol type" ); break;
 | 
			
		||||
      case QgsSymbolV2::Marker:
 | 
			
		||||
        markerCount++;
 | 
			
		||||
        break;
 | 
			
		||||
      case QgsSymbolV2::Line:
 | 
			
		||||
        lineCount++;
 | 
			
		||||
        break;
 | 
			
		||||
      case QgsSymbolV2::Fill:
 | 
			
		||||
        fillCount++;
 | 
			
		||||
        break;
 | 
			
		||||
      default: Q_ASSERT( 0 && "unknown symbol type" );
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -216,10 +223,18 @@ bool QgsStyleV2ManagerDialog::addSymbol()
 | 
			
		||||
  QgsSymbolV2* symbol;
 | 
			
		||||
  switch ( currentItemType() )
 | 
			
		||||
  {
 | 
			
		||||
    case QgsSymbolV2::Marker: symbol = new QgsMarkerSymbolV2(); break;
 | 
			
		||||
    case QgsSymbolV2::Line:   symbol = new QgsLineSymbolV2(); break;
 | 
			
		||||
    case QgsSymbolV2::Fill:   symbol = new QgsFillSymbolV2(); break;
 | 
			
		||||
    default: Q_ASSERT( 0 && "unknown symbol type" ); return false; break;
 | 
			
		||||
    case QgsSymbolV2::Marker:
 | 
			
		||||
      symbol = new QgsMarkerSymbolV2();
 | 
			
		||||
      break;
 | 
			
		||||
    case QgsSymbolV2::Line:
 | 
			
		||||
      symbol = new QgsLineSymbolV2();
 | 
			
		||||
      break;
 | 
			
		||||
    case QgsSymbolV2::Fill:
 | 
			
		||||
      symbol = new QgsFillSymbolV2();
 | 
			
		||||
      break;
 | 
			
		||||
    default:
 | 
			
		||||
      Q_ASSERT( 0 && "unknown symbol type" );
 | 
			
		||||
      return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // get symbol design
 | 
			
		||||
 | 
			
		||||
@ -300,7 +300,7 @@ void QgsSymbolV2PropertiesDialog::layerChanged()
 | 
			
		||||
 | 
			
		||||
  // get layer info
 | 
			
		||||
  QgsSymbolLayerV2* layer = currentLayer();
 | 
			
		||||
  if ( layer == NULL )
 | 
			
		||||
  if ( !layer )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // update layer type combo box
 | 
			
		||||
@ -316,8 +316,8 @@ void QgsSymbolV2PropertiesDialog::layerChanged()
 | 
			
		||||
void QgsSymbolV2PropertiesDialog::updateLockButton()
 | 
			
		||||
{
 | 
			
		||||
  QgsSymbolLayerV2* layer = currentLayer();
 | 
			
		||||
  if ( layer == NULL ) return;
 | 
			
		||||
 | 
			
		||||
  if ( !layer )
 | 
			
		||||
    return;
 | 
			
		||||
  btnLock->setChecked( layer->isLocked() );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -325,8 +325,8 @@ void QgsSymbolV2PropertiesDialog::updateLockButton()
 | 
			
		||||
void QgsSymbolV2PropertiesDialog::layerTypeChanged()
 | 
			
		||||
{
 | 
			
		||||
  QgsSymbolLayerV2* layer = currentLayer();
 | 
			
		||||
  if ( layer == NULL ) return;
 | 
			
		||||
 | 
			
		||||
  if ( !layer )
 | 
			
		||||
    return;
 | 
			
		||||
  QString newLayerType = cboLayerType->itemData( cboLayerType->currentIndex() ).toString();
 | 
			
		||||
  if ( layer->layerType() == newLayerType )
 | 
			
		||||
    return;
 | 
			
		||||
@ -372,7 +372,8 @@ void QgsSymbolV2PropertiesDialog::addLayer()
 | 
			
		||||
void QgsSymbolV2PropertiesDialog::removeLayer()
 | 
			
		||||
{
 | 
			
		||||
  int idx = currentLayerIndex();
 | 
			
		||||
  if ( idx < 0 ) return;
 | 
			
		||||
  if ( idx < 0 )
 | 
			
		||||
    return;
 | 
			
		||||
  int row = currentRowIndex();
 | 
			
		||||
  mSymbol->deleteSymbolLayer( idx );
 | 
			
		||||
 | 
			
		||||
@ -417,8 +418,8 @@ void QgsSymbolV2PropertiesDialog::moveLayerByOffset( int offset )
 | 
			
		||||
void QgsSymbolV2PropertiesDialog::lockLayer()
 | 
			
		||||
{
 | 
			
		||||
  QgsSymbolLayerV2* layer = currentLayer();
 | 
			
		||||
  if ( layer == NULL ) return;
 | 
			
		||||
 | 
			
		||||
  if ( !layer )
 | 
			
		||||
    return;
 | 
			
		||||
  layer->setLocked( btnLock->isChecked() );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -129,9 +129,9 @@ void QgsVectorGradientColorRampV2Dialog::stopDoubleClicked( QTreeWidgetItem* ite
 | 
			
		||||
  if ( column == 0 )
 | 
			
		||||
  {
 | 
			
		||||
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
 | 
			
		||||
  // Native Mac dialog works only for Qt Carbon
 | 
			
		||||
  // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
 | 
			
		||||
  // FIXME need to also check max QT_VERSION when Qt bug fixed
 | 
			
		||||
    // Native Mac dialog works only for Qt Carbon
 | 
			
		||||
    // Qt bug: http://bugreports.qt.nokia.com/browse/QTBUG-14889
 | 
			
		||||
    // FIXME need to also check max QT_VERSION when Qt bug fixed
 | 
			
		||||
    QColor color = QColorDialog::getColor( item->data( 0, StopColorRole ).value<QColor>(), this, "", QColorDialog::DontUseNativeDialog );
 | 
			
		||||
#else
 | 
			
		||||
    QColor color = QColorDialog::getColor( item->data( 0, StopColorRole ).value<QColor>(), this );
 | 
			
		||||
 | 
			
		||||
@ -296,7 +296,7 @@ int main( int argc, char * argv[] )
 | 
			
		||||
    if ( requestIt->second == "GetCapabilities" )
 | 
			
		||||
    {
 | 
			
		||||
      const QDomDocument* capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument( configFilePath );
 | 
			
		||||
      if( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one
 | 
			
		||||
      if ( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one
 | 
			
		||||
      {
 | 
			
		||||
        QgsMSDebugMsg( "Capabilities document not found in cache" );
 | 
			
		||||
        QDomDocument doc;
 | 
			
		||||
@ -319,7 +319,7 @@ int main( int argc, char * argv[] )
 | 
			
		||||
        QgsMSDebugMsg( "Found capabilities document in cache" );
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if( capabilitiesDocument )
 | 
			
		||||
      if ( capabilitiesDocument )
 | 
			
		||||
      {
 | 
			
		||||
        theRequestHandler->sendGetCapabilitiesResponse( *capabilitiesDocument );
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -32,19 +32,19 @@ const QDomDocument* QgsCapabilitiesCache::searchCapabilitiesDocument( const QStr
 | 
			
		||||
{
 | 
			
		||||
  QCoreApplication::processEvents(); //get updates from file system watcher
 | 
			
		||||
  QHash< QString, QDomDocument >::const_iterator it = mCachedCapabilities.find( configFilePath );
 | 
			
		||||
  if( it == mCachedCapabilities.constEnd() )
 | 
			
		||||
  if ( it == mCachedCapabilities.constEnd() )
 | 
			
		||||
  {
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    return &(it.value());
 | 
			
		||||
    return &( it.value() );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsCapabilitiesCache::insertCapabilitiesDocument( const QString& configFilePath, const QDomDocument* doc )
 | 
			
		||||
{
 | 
			
		||||
  if( mCachedCapabilities.size() > 40 )
 | 
			
		||||
  if ( mCachedCapabilities.size() > 40 )
 | 
			
		||||
  {
 | 
			
		||||
    //remove another cache entry to avoid memory problems
 | 
			
		||||
    QHash<QString, QDomDocument>::iterator capIt = mCachedCapabilities.begin();
 | 
			
		||||
@ -59,7 +59,7 @@ void QgsCapabilitiesCache::removeChangedEntry( const QString& path )
 | 
			
		||||
{
 | 
			
		||||
  QgsMSDebugMsg( "Remove capabilities cache entry because file changed" );
 | 
			
		||||
  QHash< QString, QDomDocument >::iterator it = mCachedCapabilities.find( path );
 | 
			
		||||
  if( it != mCachedCapabilities.end() )
 | 
			
		||||
  if ( it != mCachedCapabilities.end() )
 | 
			
		||||
  {
 | 
			
		||||
    mCachedCapabilities.erase( it );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@
 | 
			
		||||
/**A cache for capabilities xml documents (by configuration file path)*/
 | 
			
		||||
class QgsCapabilitiesCache: public QObject
 | 
			
		||||
{
 | 
			
		||||
  Q_OBJECT
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
  public:
 | 
			
		||||
    QgsCapabilitiesCache();
 | 
			
		||||
    ~QgsCapabilitiesCache();
 | 
			
		||||
 | 
			
		||||
@ -868,13 +868,17 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
 | 
			
		||||
    bool bboxOk = true;
 | 
			
		||||
    QString bbString = bbIt->second;
 | 
			
		||||
    minx = bbString.section( ",", 0, 0 ).toDouble( &conversionSuccess );
 | 
			
		||||
    if ( !conversionSuccess ) {bboxOk = false;}
 | 
			
		||||
    if ( !conversionSuccess )
 | 
			
		||||
      bboxOk = false;
 | 
			
		||||
    miny = bbString.section( ",", 1, 1 ).toDouble( &conversionSuccess );
 | 
			
		||||
    if ( !conversionSuccess ) {bboxOk = false;}
 | 
			
		||||
    if ( !conversionSuccess )
 | 
			
		||||
      bboxOk = false;
 | 
			
		||||
    maxx = bbString.section( ",", 2, 2 ).toDouble( &conversionSuccess );
 | 
			
		||||
    if ( !conversionSuccess ) {bboxOk = false;}
 | 
			
		||||
    if ( !conversionSuccess )
 | 
			
		||||
      bboxOk = false;
 | 
			
		||||
    maxy = bbString.section( ",", 3, 3 ).toDouble( &conversionSuccess );
 | 
			
		||||
    if ( !conversionSuccess ) {bboxOk = false;}
 | 
			
		||||
    if ( !conversionSuccess )
 | 
			
		||||
      bboxOk = false;
 | 
			
		||||
 | 
			
		||||
    if ( !bboxOk )
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -165,11 +165,16 @@ void QgsDelimitedTextPluginGui::on_buttonBox_rejected()
 | 
			
		||||
QString QgsDelimitedTextPluginGui::selectedChars()
 | 
			
		||||
{
 | 
			
		||||
  QString chars = "";
 | 
			
		||||
  if ( cbxDelimSpace->isChecked() ) chars += " ";
 | 
			
		||||
  if ( cbxDelimTab->isChecked() ) chars += "\\t";
 | 
			
		||||
  if ( cbxDelimSemicolon->isChecked() ) chars += ";";
 | 
			
		||||
  if ( cbxDelimComma->isChecked() ) chars += ",";
 | 
			
		||||
  if ( cbxDelimColon->isChecked() ) chars += ":";
 | 
			
		||||
  if ( cbxDelimSpace->isChecked() )
 | 
			
		||||
    chars += " ";
 | 
			
		||||
  if ( cbxDelimTab->isChecked() )
 | 
			
		||||
    chars += "\\t";
 | 
			
		||||
  if ( cbxDelimSemicolon->isChecked() )
 | 
			
		||||
    chars += ";";
 | 
			
		||||
  if ( cbxDelimComma->isChecked() )
 | 
			
		||||
    chars += ",";
 | 
			
		||||
  if ( cbxDelimColon->isChecked() )
 | 
			
		||||
    chars += ":";
 | 
			
		||||
  return chars;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -254,7 +259,8 @@ void QgsDelimitedTextPluginGui::updateFieldLists()
 | 
			
		||||
  cmbYField->setEnabled( false );
 | 
			
		||||
  cmbWktField->setEnabled( false );
 | 
			
		||||
 | 
			
		||||
  if ( ! haveValidFileAndDelimiters() ) return;
 | 
			
		||||
  if ( ! haveValidFileAndDelimiters() )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QFile file( txtFilePath->text() );
 | 
			
		||||
  if ( !file.open( QIODevice::ReadOnly ) )
 | 
			
		||||
 | 
			
		||||
@ -62,7 +62,8 @@ QgsDiagramFactory* QgsSVGDiagramFactoryWidget::createFactory()
 | 
			
		||||
  QgsSVGDiagramFactory* factory = new QgsSVGDiagramFactory();
 | 
			
		||||
  if ( !factory->setSVGData( svgData, filePath ) )
 | 
			
		||||
  {
 | 
			
		||||
    delete factory; return 0;
 | 
			
		||||
    delete factory;
 | 
			
		||||
    return 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return factory;
 | 
			
		||||
@ -194,7 +195,8 @@ int QgsSVGDiagramFactoryWidget::addDirectoryToPreview( const QString& path )
 | 
			
		||||
    //exclude files that are not svg or image
 | 
			
		||||
    if ( !fileIsSvg )
 | 
			
		||||
    {
 | 
			
		||||
      ++counter; continue;
 | 
			
		||||
      ++counter;
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget );
 | 
			
		||||
 | 
			
		||||
@ -266,7 +266,8 @@ bool eVisGenericEventBrowserGui::initBrowser( )
 | 
			
		||||
    mFeatureIds = mVectorLayer->selectedFeaturesIds( ).toList( );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( 0 == mFeatureIds.size( ) ) { return false; }
 | 
			
		||||
  if ( 0 == mFeatureIds.size( ) )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  //get the first feature in the list so we can set the field in the pulldown menues
 | 
			
		||||
  QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );
 | 
			
		||||
@ -534,7 +535,8 @@ void eVisGenericEventBrowserGui::displayImage( )
 | 
			
		||||
      //get a copy of the feature
 | 
			
		||||
      QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );
 | 
			
		||||
 | 
			
		||||
      if ( 0 == myFeature ) { return; }
 | 
			
		||||
      if ( 0 == myFeature )
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
      QgsPoint myPoint = myFeature->geometry( )->asPoint( );
 | 
			
		||||
      myPoint = mCanvas->mapRenderer( )->layerToMapCoordinates( mVectorLayer, myPoint );
 | 
			
		||||
@ -581,7 +583,8 @@ void eVisGenericEventBrowserGui::loadRecord( )
 | 
			
		||||
  QgsFeature* myFeature;
 | 
			
		||||
  myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );
 | 
			
		||||
 | 
			
		||||
  if ( 0 == myFeature ) { return; }
 | 
			
		||||
  if ( 0 == myFeature )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QString myCompassBearingField = cboxCompassBearingField->currentText( );
 | 
			
		||||
  QString myCompassOffsetField = cboxCompassOffsetField->currentText( );
 | 
			
		||||
@ -834,7 +837,8 @@ void eVisGenericEventBrowserGui::on_cboxEventImagePathField_currentIndexChanged(
 | 
			
		||||
    QgsFieldMap myFieldMap = mDataProvider->fields( );
 | 
			
		||||
    QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );
 | 
			
		||||
 | 
			
		||||
    if ( 0 == myFeature ) { return; }
 | 
			
		||||
    if ( 0 == myFeature )
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    QgsAttributeMap myAttributeMap = myFeature->attributeMap( );
 | 
			
		||||
    for ( QgsAttributeMap::const_iterator it = myAttributeMap.begin( ); it != myAttributeMap.end( ); ++it )
 | 
			
		||||
@ -860,7 +864,8 @@ void eVisGenericEventBrowserGui::on_cboxCompassBearingField_currentIndexChanged(
 | 
			
		||||
    QgsFieldMap myFieldMap = mDataProvider->fields( );
 | 
			
		||||
    QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );
 | 
			
		||||
 | 
			
		||||
    if ( 0 == myFeature ) { return; }
 | 
			
		||||
    if ( 0 == myFeature )
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    QgsAttributeMap myAttributeMap = myFeature->attributeMap( );
 | 
			
		||||
    for ( QgsAttributeMap::const_iterator it = myAttributeMap.begin( ); it != myAttributeMap.end( ); ++it )
 | 
			
		||||
@ -886,7 +891,8 @@ void eVisGenericEventBrowserGui::on_cboxCompassOffsetField_currentIndexChanged(
 | 
			
		||||
    QgsFieldMap myFieldMap = mDataProvider->fields( );
 | 
			
		||||
    QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );
 | 
			
		||||
 | 
			
		||||
    if ( 0 == myFeature ) { return; }
 | 
			
		||||
    if ( 0 == myFeature )
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    QgsAttributeMap myAttributeMap = myFeature->attributeMap( );
 | 
			
		||||
    for ( QgsAttributeMap::const_iterator it = myAttributeMap.begin( ); it != myAttributeMap.end( ); ++it )
 | 
			
		||||
@ -1110,7 +1116,8 @@ void eVisGenericEventBrowserGui::renderSymbol( QPainter* thePainter )
 | 
			
		||||
    //Get a pointer to the current feature
 | 
			
		||||
    QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );
 | 
			
		||||
 | 
			
		||||
    if ( 0 == myFeature ) { return; }
 | 
			
		||||
    if ( 0 == myFeature )
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    QgsPoint myPoint = myFeature->geometry( )->asPoint( );
 | 
			
		||||
    myPoint = mCanvas->mapRenderer( )->layerToMapCoordinates( mVectorLayer, myPoint );
 | 
			
		||||
 | 
			
		||||
@ -60,7 +60,8 @@ eVisEventIdTool::eVisEventIdTool( QgsMapCanvas* theCanvas )
 | 
			
		||||
*/
 | 
			
		||||
void eVisEventIdTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
 | 
			
		||||
{
 | 
			
		||||
  if ( 0 == mCanvas || 0 == theMouseEvent ) { return; }
 | 
			
		||||
  if ( 0 == mCanvas || 0 == theMouseEvent )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  //Check to see if there is a layer selected
 | 
			
		||||
  if ( mCanvas->currentLayer( ) )
 | 
			
		||||
@ -88,19 +89,20 @@ void eVisEventIdTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
 | 
			
		||||
void eVisEventIdTool::select( QgsPoint thePoint )
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  if ( 0 == mCanvas ) { return; }
 | 
			
		||||
  
 | 
			
		||||
  if ( 0 == mCanvas )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QgsVectorLayer* myLayer = ( QgsVectorLayer* )mCanvas->currentLayer( );
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  // create the search rectangle. this was modeled after the QgsMapIdentifyTool in core QGIS application
 | 
			
		||||
  double searchWidth = mCanvas->extent( ).width( ) * (( double )QGis::DEFAULT_IDENTIFY_RADIUS / 100.0 );
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  QgsRectangle myRectangle;
 | 
			
		||||
  myRectangle.setXMinimum( thePoint.x( ) - searchWidth );
 | 
			
		||||
  myRectangle.setXMaximum( thePoint.x( ) + searchWidth );
 | 
			
		||||
  myRectangle.setYMinimum( thePoint.y( ) - searchWidth );
 | 
			
		||||
  myRectangle.setYMaximum( thePoint.y( ) + searchWidth );
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  //Transform rectange to map coordinates
 | 
			
		||||
  myRectangle = toLayerCoordinates( myLayer, myRectangle );
 | 
			
		||||
 | 
			
		||||
@ -108,7 +110,7 @@ void eVisEventIdTool::select( QgsPoint thePoint )
 | 
			
		||||
  myLayer->removeSelection( false );
 | 
			
		||||
  //select features
 | 
			
		||||
  myLayer->select( QgsAttributeList(), myRectangle, true, true );
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  QgsFeature f;
 | 
			
		||||
  QgsFeatureIds newSelectedFeatures;
 | 
			
		||||
  while ( myLayer->nextFeature( f ) )
 | 
			
		||||
@ -117,7 +119,7 @@ void eVisEventIdTool::select( QgsPoint thePoint )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  myLayer->setSelectedFeatures( newSelectedFeatures );
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  //Launch a new event browser to view selected features
 | 
			
		||||
  mBrowser = new eVisGenericEventBrowserGui( mCanvas, mCanvas, NULL );
 | 
			
		||||
  mBrowser->setAttribute( Qt::WA_DeleteOnClose );
 | 
			
		||||
 | 
			
		||||
@ -61,7 +61,8 @@ int QgsGCPList::size() const
 | 
			
		||||
  const_iterator it = begin();
 | 
			
		||||
  while ( it != end() )
 | 
			
		||||
  {
 | 
			
		||||
    if (( *it )->isEnabled() ) s++;
 | 
			
		||||
    if (( *it )->isEnabled() )
 | 
			
		||||
      s++;
 | 
			
		||||
    it++;
 | 
			
		||||
  }
 | 
			
		||||
  return s;
 | 
			
		||||
 | 
			
		||||
@ -751,7 +751,8 @@ void QgsGeorefPluginGui::updateMouseCoordinatePrecision()
 | 
			
		||||
    dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );
 | 
			
		||||
 | 
			
		||||
  // Keep dp sensible
 | 
			
		||||
  if ( dp < 0 ) dp = 0;
 | 
			
		||||
  if ( dp < 0 )
 | 
			
		||||
    dp = 0;
 | 
			
		||||
 | 
			
		||||
  mMousePrecisionDecimalPlaces = dp;
 | 
			
		||||
}
 | 
			
		||||
@ -1872,10 +1873,18 @@ QgsRectangle QgsGeorefPluginGui::transformViewportBoundingBox( const QgsRectangl
 | 
			
		||||
      QgsPoint src, raster;
 | 
			
		||||
      switch ( edge )
 | 
			
		||||
      {
 | 
			
		||||
        case 0: src = QgsPoint( oX + ( double )s*stepX, oY ); break;
 | 
			
		||||
        case 1: src = QgsPoint( oX + ( double )s*stepX, dY ); break;
 | 
			
		||||
        case 2: src = QgsPoint( oX, oY + ( double )s*stepY ); break;
 | 
			
		||||
        case 3: src = QgsPoint( dX, oY + ( double )s*stepY ); break;
 | 
			
		||||
        case 0:
 | 
			
		||||
          src = QgsPoint( oX + ( double )s * stepX, oY );
 | 
			
		||||
          break;
 | 
			
		||||
        case 1:
 | 
			
		||||
          src = QgsPoint( oX + ( double )s * stepX, dY );
 | 
			
		||||
          break;
 | 
			
		||||
        case 2:
 | 
			
		||||
          src = QgsPoint( oX, oY + ( double )s * stepY );
 | 
			
		||||
          break;
 | 
			
		||||
        case 3:
 | 
			
		||||
          src = QgsPoint( dX, oY + ( double )s * stepY );
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
      t.transform( src, raster, rasterToWorld );
 | 
			
		||||
      minX = qMin( raster.x(), minX );
 | 
			
		||||
 | 
			
		||||
@ -246,7 +246,6 @@ QgsGeorefTransformInterface *QgsGeorefTransform::createImplementation( Transform
 | 
			
		||||
    case ThinPlateSpline:  return new QgsGDALGeorefTransform( true, 0 );
 | 
			
		||||
    case Projective:       return new QgsProjectiveGeorefTransform;
 | 
			
		||||
    default:               return NULL;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -310,7 +309,8 @@ bool QgsGeorefTransform::gdal_transform( const QgsPoint &src, QgsPoint &dst, int
 | 
			
		||||
{
 | 
			
		||||
  GDALTransformerFunc t = GDALTransformer();
 | 
			
		||||
  // Fail if no transformer function was returned
 | 
			
		||||
  if ( !t ) return false;
 | 
			
		||||
  if ( !t )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  // Copy the source coordinate for inplace transform
 | 
			
		||||
  double x = src.x();
 | 
			
		||||
@ -492,7 +492,8 @@ QgsGDALGeorefTransform::~QgsGDALGeorefTransform()
 | 
			
		||||
bool QgsGDALGeorefTransform::updateParametersFromGCPs( const std::vector<QgsPoint> &mapCoords, const std::vector<QgsPoint> &pixelCoords )
 | 
			
		||||
{
 | 
			
		||||
  assert( mapCoords.size() == pixelCoords.size() );
 | 
			
		||||
  if ( mapCoords.size() != pixelCoords.size() ) return false;
 | 
			
		||||
  if ( mapCoords.size() != pixelCoords.size() )
 | 
			
		||||
    return false;
 | 
			
		||||
  int n = mapCoords.size();
 | 
			
		||||
 | 
			
		||||
  GDAL_GCP *GCPList = new GDAL_GCP[n];
 | 
			
		||||
@ -533,7 +534,8 @@ uint QgsGDALGeorefTransform::getMinimumGCPCount() const
 | 
			
		||||
GDALTransformerFunc QgsGDALGeorefTransform::GDALTransformer() const
 | 
			
		||||
{
 | 
			
		||||
  // Fail if no arguments were calculated through updateParametersFromGCP
 | 
			
		||||
  if ( !mGDALTransformerArgs ) return NULL;
 | 
			
		||||
  if ( !mGDALTransformerArgs )
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  if ( mIsTPSTransform )
 | 
			
		||||
    return GDALTPSTransform;
 | 
			
		||||
 | 
			
		||||
@ -51,7 +51,8 @@ bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, const Resampl
 | 
			
		||||
  // Open input file
 | 
			
		||||
  GDALAllRegister();
 | 
			
		||||
  hSrcDS = GDALOpen( TO8F( input ), GA_ReadOnly );
 | 
			
		||||
  if ( hSrcDS == NULL ) return false;
 | 
			
		||||
  if ( !hSrcDS )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  // Setup warp options.
 | 
			
		||||
  psWarpOptions = GDALCreateWarpOptions();
 | 
			
		||||
@ -80,7 +81,7 @@ bool QgsImageWarper::createDestinationDataset(
 | 
			
		||||
{
 | 
			
		||||
  // create the output file
 | 
			
		||||
  GDALDriverH driver = GDALGetDriverByName( "GTiff" );
 | 
			
		||||
  if ( driver == NULL )
 | 
			
		||||
  if ( !driver )
 | 
			
		||||
  {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
@ -91,7 +92,7 @@ bool QgsImageWarper::createDestinationDataset(
 | 
			
		||||
                       GDALGetRasterCount( hSrcDS ),
 | 
			
		||||
                       GDALGetRasterDataType( GDALGetRasterBand( hSrcDS, 1 ) ),
 | 
			
		||||
                       papszOptions );
 | 
			
		||||
  if ( hDstDS == NULL )
 | 
			
		||||
  if ( !hDstDS )
 | 
			
		||||
  {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
@ -187,12 +188,16 @@ int QgsImageWarper::warpFile( const QString& input,
 | 
			
		||||
  if ( destResX != 0.0 || destResY != 0.0 )
 | 
			
		||||
  {
 | 
			
		||||
    // If only one scale has been specified, fill in the other from the GDAL suggestion
 | 
			
		||||
    if ( destResX == 0.0 ) destResX = adfGeoTransform[1];
 | 
			
		||||
    if ( destResY == 0.0 ) destResY = adfGeoTransform[5];
 | 
			
		||||
    if ( destResX == 0.0 )
 | 
			
		||||
      destResX = adfGeoTransform[1];
 | 
			
		||||
    if ( destResY == 0.0 )
 | 
			
		||||
      destResY = adfGeoTransform[5];
 | 
			
		||||
 | 
			
		||||
    // Make sure user-specified coordinate system has canonical orientation
 | 
			
		||||
    if ( destResX < 0.0 ) destResX = -destResX;
 | 
			
		||||
    if ( destResY > 0.0 ) destResY = -destResY;
 | 
			
		||||
    if ( destResX < 0.0 )
 | 
			
		||||
      destResX = -destResX;
 | 
			
		||||
    if ( destResY > 0.0 )
 | 
			
		||||
      destResY = -destResY;
 | 
			
		||||
 | 
			
		||||
    // Assert that the north-up convention is fullfiled by GDALSuggestedWarpOutput (should always be the case)
 | 
			
		||||
    assert( adfGeoTransform[0] > 0.0 );
 | 
			
		||||
@ -289,7 +294,7 @@ int QgsImageWarper::GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, i
 | 
			
		||||
    double *x, double *y, double *z, int *panSuccess )
 | 
			
		||||
{
 | 
			
		||||
  TransformChain *chain = static_cast<TransformChain*>( pTransformerArg );
 | 
			
		||||
  if ( chain == NULL )
 | 
			
		||||
  if ( !chain )
 | 
			
		||||
  {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
@ -304,7 +309,8 @@ int QgsImageWarper::GeoToPixelTransform( void *pTransformerArg, int bDstToSrc, i
 | 
			
		||||
    // Transform from georeferenced to pixel/line
 | 
			
		||||
    for ( int i = 0; i < nPointCount; ++i )
 | 
			
		||||
    {
 | 
			
		||||
      if ( !panSuccess[i] ) continue;
 | 
			
		||||
      if ( !panSuccess[i] )
 | 
			
		||||
        continue;
 | 
			
		||||
      double xP = x[i];
 | 
			
		||||
      double yP = y[i];
 | 
			
		||||
      x[i] = chain->adfInvGeotransform[0] + xP * chain->adfInvGeotransform[1] + yP * chain->adfInvGeotransform[2];
 | 
			
		||||
 | 
			
		||||
@ -69,9 +69,11 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( const QString &raster, c
 | 
			
		||||
  cbxUserResolution->setChecked( s.value( "/Plugin-Georeferencer/user_specified_resolution", false ).toBool() );
 | 
			
		||||
  bool ok;
 | 
			
		||||
  dsbHorizRes->setValue( s.value( "/Plugin-GeoReferencer/user_specified_resx",     1.0 ).toDouble( &ok ) );
 | 
			
		||||
  if ( !ok ) dsbHorizRes->setValue( 1.0 );
 | 
			
		||||
  if ( !ok )
 | 
			
		||||
    dsbHorizRes->setValue( 1.0 );
 | 
			
		||||
  dsbVerticalRes->setValue( s.value( "/Plugin-GeoReferencer/user_specified_resy", -1.0 ).toDouble( &ok ) );
 | 
			
		||||
  if ( !ok ) dsbHorizRes->setValue( -1.0 );
 | 
			
		||||
  if ( !ok )
 | 
			
		||||
    dsbHorizRes->setValue( -1.0 );
 | 
			
		||||
 | 
			
		||||
  // Activate spin boxes for vertical/horizontal resolution, if the option is checked
 | 
			
		||||
  dsbHorizRes->setEnabled( cbxUserResolution->isChecked() );
 | 
			
		||||
 | 
			
		||||
@ -320,14 +320,10 @@ void QgsGPSPlugin::convertGPSFile( QString inputFileName,
 | 
			
		||||
 | 
			
		||||
  switch ( convertType )
 | 
			
		||||
  {
 | 
			
		||||
    case 0:
 | 
			
		||||
      convertStrings << "-x" << "transform,wpt=rte,del"; break;
 | 
			
		||||
    case 1:
 | 
			
		||||
      convertStrings << "-x" << "transform,rte=wpt,del"; break;
 | 
			
		||||
    case 2:
 | 
			
		||||
      convertStrings << "-x" << "transform,trk=wpt,del"; break;
 | 
			
		||||
    case 3:
 | 
			
		||||
      convertStrings << "-x" << "transform,wpt=trk,del"; break;
 | 
			
		||||
    case 0: convertStrings << "-x" << "transform,wpt=rte,del"; break;
 | 
			
		||||
    case 1: convertStrings << "-x" << "transform,rte=wpt,del"; break;
 | 
			
		||||
    case 2: convertStrings << "-x" << "transform,trk=wpt,del"; break;
 | 
			
		||||
    case 3: convertStrings << "-x" << "transform,wpt=trk,del"; break;
 | 
			
		||||
    default:
 | 
			
		||||
      QgsDebugMsg( "Illegal conversion index!" );
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
@ -138,7 +138,8 @@ int QgsGrassAttributes::addTab( const QString & label )
 | 
			
		||||
  {
 | 
			
		||||
    bool ok = settings.contains( path + QString::number( i ) );
 | 
			
		||||
    int cw = settings.value( path + QString::number( i ), 30 ).toInt();
 | 
			
		||||
    if ( ok ) tb->setColumnWidth( i, cw );
 | 
			
		||||
    if ( ok )
 | 
			
		||||
      tb->setColumnWidth( i, cw );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  connect( tb->horizontalHeader(), SIGNAL( sectionResized( int, int, int ) ),
 | 
			
		||||
@ -220,7 +221,8 @@ void QgsGrassAttributes::updateAttributes( )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
 | 
			
		||||
  if ( tabCats->count() == 0 ) return;
 | 
			
		||||
  if ( tabCats->count() == 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QTableWidget *tb = static_cast<QTableWidget *>( tabCats->currentWidget() );
 | 
			
		||||
 | 
			
		||||
@ -235,7 +237,8 @@ void QgsGrassAttributes::updateAttributes( )
 | 
			
		||||
 | 
			
		||||
    for ( int i = 2; i < tb->rowCount(); i++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( i > 2 ) sql.append( ", " );
 | 
			
		||||
      if ( i > 2 )
 | 
			
		||||
        sql.append( ", " );
 | 
			
		||||
 | 
			
		||||
      QString val = tb->item( i, 1 )->text().trimmed();
 | 
			
		||||
 | 
			
		||||
@ -291,7 +294,8 @@ void QgsGrassAttributes::deleteCat( )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
 | 
			
		||||
  if ( tabCats->count() == 0 ) return;
 | 
			
		||||
  if ( tabCats->count() == 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QTableWidget *tb = static_cast<QTableWidget *>( tabCats->currentWidget() );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -179,7 +179,8 @@ void QgsGrassBrowser::addMap()
 | 
			
		||||
    else if ( type == QgsGrassModel::Region )
 | 
			
		||||
    {
 | 
			
		||||
      struct Cell_head window;
 | 
			
		||||
      if ( !getItemRegion( *it, &window ) ) continue;
 | 
			
		||||
      if ( !getItemRegion( *it, &window ) )
 | 
			
		||||
        continue;
 | 
			
		||||
      writeRegion( &window );
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -267,7 +268,8 @@ void QgsGrassBrowser::copyMap()
 | 
			
		||||
    QString newName = ed.getItem( element, tr( "New name" ),
 | 
			
		||||
                                  tr( "New name for layer \"%1\"" ).arg( map ), suggest, source, &ok );
 | 
			
		||||
 | 
			
		||||
    if ( !ok ) return;
 | 
			
		||||
    if ( !ok )
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    QString module = "g.copy";
 | 
			
		||||
#ifdef WIN32
 | 
			
		||||
@ -315,7 +317,8 @@ void QgsGrassBrowser::renameMap()
 | 
			
		||||
    QString mapset = mModel->itemMapset( *it );
 | 
			
		||||
    QString map = mModel->itemMap( *it );
 | 
			
		||||
 | 
			
		||||
    if ( mapset != QgsGrass::getDefaultMapset() ) continue; // should not happen
 | 
			
		||||
    if ( mapset != QgsGrass::getDefaultMapset() )
 | 
			
		||||
      continue; // should not happen
 | 
			
		||||
 | 
			
		||||
    QString typeName;
 | 
			
		||||
    QString element;
 | 
			
		||||
@ -340,7 +343,8 @@ void QgsGrassBrowser::renameMap()
 | 
			
		||||
    QString newName = ed.getItem( element, tr( "New name" ),
 | 
			
		||||
                                  tr( "New name for layer \"%1\"" ).arg( map ), "", map, &ok );
 | 
			
		||||
 | 
			
		||||
    if ( !ok ) return;
 | 
			
		||||
    if ( !ok )
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    QString module = "g.rename";
 | 
			
		||||
#ifdef WIN32
 | 
			
		||||
@ -396,9 +400,12 @@ void QgsGrassBrowser::deleteMap()
 | 
			
		||||
    QString map = mModel->itemMap( *it );
 | 
			
		||||
 | 
			
		||||
    QString typeName;
 | 
			
		||||
    if ( type == QgsGrassModel::Raster ) typeName = "rast";
 | 
			
		||||
    else if ( type == QgsGrassModel::Vector ) typeName = "vect";
 | 
			
		||||
    else if ( type == QgsGrassModel::Region ) typeName = "region";
 | 
			
		||||
    if ( type == QgsGrassModel::Raster )
 | 
			
		||||
      typeName = "rast";
 | 
			
		||||
    else if ( type == QgsGrassModel::Vector )
 | 
			
		||||
      typeName = "vect";
 | 
			
		||||
    else if ( type == QgsGrassModel::Region )
 | 
			
		||||
      typeName = "region";
 | 
			
		||||
 | 
			
		||||
    if ( mapset != QgsGrass::getDefaultMapset() )
 | 
			
		||||
    {
 | 
			
		||||
@ -442,7 +449,8 @@ void QgsGrassBrowser::setRegion()
 | 
			
		||||
  QList<QModelIndex>::const_iterator it = indexes.begin();
 | 
			
		||||
  for ( ; it != indexes.end(); ++it )
 | 
			
		||||
  {
 | 
			
		||||
    if ( !getItemRegion( *it, &window ) ) return;
 | 
			
		||||
    if ( !getItemRegion( *it, &window ) )
 | 
			
		||||
      return;
 | 
			
		||||
  }
 | 
			
		||||
  writeRegion( &window );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -168,7 +168,8 @@ QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer* layer, bool newMa
 | 
			
		||||
 | 
			
		||||
  mCanvas = mIface->mapCanvas();
 | 
			
		||||
 | 
			
		||||
  if ( !isEditable( layer ) ) return;
 | 
			
		||||
  if ( !isEditable( layer ) )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  //TODO dynamic_cast ?
 | 
			
		||||
  mLayer = ( QgsVectorLayer* )layer;
 | 
			
		||||
@ -182,7 +183,8 @@ QgsGrassEdit::QgsGrassEdit( QgisInterface *iface, QgsMapLayer* layer, bool newMa
 | 
			
		||||
 | 
			
		||||
bool QgsGrassEdit::isEditable( QgsMapLayer *layer )
 | 
			
		||||
{
 | 
			
		||||
  if ( !layer ) return false;
 | 
			
		||||
  if ( !layer )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  QgsDebugMsgLevel( "layer name: " + layer->name(), 3 );
 | 
			
		||||
 | 
			
		||||
@ -466,7 +468,8 @@ void QgsGrassEdit::init()
 | 
			
		||||
 | 
			
		||||
  for ( int i = 0; i < SYMB_COUNT; i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( i == SYMB_NODE_0 ) continue;
 | 
			
		||||
    if ( i == SYMB_NODE_0 )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QPixmap pm( 40, 15 );
 | 
			
		||||
    pm.fill( mSymb[i].color() );
 | 
			
		||||
@ -645,7 +648,8 @@ void QgsGrassEdit::columnTypeChanged( int row, int col )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( QString( "row = %1 col = %2" ).arg( row ).arg( col ) );
 | 
			
		||||
 | 
			
		||||
  if ( col != 1 ) return;
 | 
			
		||||
  if ( col != 1 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QTableWidgetItem *ti = mAttributeTable->item( row, 2 );
 | 
			
		||||
  if ( ti )
 | 
			
		||||
@ -677,7 +681,8 @@ void QgsGrassEdit::alterTable( void )
 | 
			
		||||
 | 
			
		||||
    for ( int i = 0; i < mAttributeTable->rowCount(); i++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( i > 0 ) sql.append( ", " );
 | 
			
		||||
      if ( i > 0 )
 | 
			
		||||
        sql.append( ", " );
 | 
			
		||||
 | 
			
		||||
      type = mAttributeTable->item( i, 1 )->text();
 | 
			
		||||
      sql.append( mAttributeTable->item( i, 0 )->text() + " " + type );
 | 
			
		||||
@ -709,7 +714,8 @@ void QgsGrassEdit::alterTable( void )
 | 
			
		||||
 | 
			
		||||
    for ( int i = 0; i < mAttributeTable->rowCount(); i++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( !( mAttributeTable->item( i, 0 )->flags() & Qt::ItemIsEnabled ) ) continue;
 | 
			
		||||
      if ( !( mAttributeTable->item( i, 0 )->flags() & Qt::ItemIsEnabled ) )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      type = mAttributeTable->item( i, 1 )->text();
 | 
			
		||||
      sql = mAttributeTable->item( i, 0 )->text() + " " + type;
 | 
			
		||||
@ -738,13 +744,15 @@ void QgsGrassEdit::changeSymbology( QTreeWidgetItem * item, int col )
 | 
			
		||||
 | 
			
		||||
  QSettings settings;
 | 
			
		||||
 | 
			
		||||
  if ( !item ) return;
 | 
			
		||||
  if ( !item )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  int index = item->text( 3 ).toInt();
 | 
			
		||||
 | 
			
		||||
  if ( col == 0 )
 | 
			
		||||
  {
 | 
			
		||||
    if ( index == SYMB_BACKGROUND || index == SYMB_HIGHLIGHT || index == SYMB_DYNAMIC ) return;
 | 
			
		||||
    if ( index == SYMB_BACKGROUND || index == SYMB_HIGHLIGHT || index == SYMB_DYNAMIC )
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
    mSymbDisplay[index] = item->checkState( 0 ) == Qt::Checked;
 | 
			
		||||
 | 
			
		||||
@ -825,7 +833,8 @@ void QgsGrassEdit::updateSymb( void )
 | 
			
		||||
  {
 | 
			
		||||
    int line = mProvider->updatedLine( i );
 | 
			
		||||
    QgsDebugMsg( QString( "updated line = %1" ).arg( line ) );
 | 
			
		||||
    if ( !( mProvider->lineAlive( line ) ) ) continue;
 | 
			
		||||
    if ( !( mProvider->lineAlive( line ) ) )
 | 
			
		||||
      continue;
 | 
			
		||||
    mLineSymb[line] = lineSymbFromMap( line );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -838,7 +847,8 @@ void QgsGrassEdit::updateSymb( void )
 | 
			
		||||
  for ( unsigned int i = 0; i < nnodes; i++ )
 | 
			
		||||
  {
 | 
			
		||||
    int node = mProvider->updatedNode( i );
 | 
			
		||||
    if ( !( mProvider->nodeAlive( node ) ) ) continue;
 | 
			
		||||
    if ( !( mProvider->nodeAlive( node ) ) )
 | 
			
		||||
      continue;
 | 
			
		||||
    mNodeSymb[node] = nodeSymbFromMap( node );
 | 
			
		||||
    QgsDebugMsg( QString( "node = %1 mNodeSymb = %2" ).arg( node ).arg( mNodeSymb[node] ) );
 | 
			
		||||
  }
 | 
			
		||||
@ -875,7 +885,8 @@ int QgsGrassEdit::lineSymbFromMap( int line )
 | 
			
		||||
 | 
			
		||||
  int type = mProvider->readLine( NULL, NULL, line );
 | 
			
		||||
 | 
			
		||||
  if ( type < 0 ) return 0;
 | 
			
		||||
  if ( type < 0 )
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  switch ( type )
 | 
			
		||||
  {
 | 
			
		||||
@ -890,22 +901,31 @@ int QgsGrassEdit::lineSymbFromMap( int line )
 | 
			
		||||
    case GV_BOUNDARY:
 | 
			
		||||
      int left, right, nareas;
 | 
			
		||||
 | 
			
		||||
      if ( !( mProvider->lineAreas( line, &left, &right ) ) ) return 0;
 | 
			
		||||
      if ( !( mProvider->lineAreas( line, &left, &right ) ) )
 | 
			
		||||
        return 0;
 | 
			
		||||
 | 
			
		||||
      /* Count areas on both sides */
 | 
			
		||||
      nareas = 0;
 | 
			
		||||
      if ( left > 0 || ( left < 0 && mProvider->isleArea( -left ) > 0 ) ) nareas++;
 | 
			
		||||
      if ( right > 0 || ( right < 0 && mProvider->isleArea( -right ) > 0 ) ) nareas++;
 | 
			
		||||
      if ( nareas == 0 ) return SYMB_BOUNDARY_0;
 | 
			
		||||
      else if ( nareas == 1 ) return SYMB_BOUNDARY_1;
 | 
			
		||||
      else return SYMB_BOUNDARY_2;
 | 
			
		||||
      if ( left > 0 || ( left < 0 && mProvider->isleArea( -left ) > 0 ) )
 | 
			
		||||
        nareas++;
 | 
			
		||||
      if ( right > 0 || ( right < 0 && mProvider->isleArea( -right ) > 0 ) )
 | 
			
		||||
        nareas++;
 | 
			
		||||
      if ( nareas == 0 )
 | 
			
		||||
        return SYMB_BOUNDARY_0;
 | 
			
		||||
      else if ( nareas == 1 )
 | 
			
		||||
        return SYMB_BOUNDARY_1;
 | 
			
		||||
      else
 | 
			
		||||
        return SYMB_BOUNDARY_2;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case GV_CENTROID:
 | 
			
		||||
      int area = mProvider->centroidArea( line );
 | 
			
		||||
      if ( area == 0 ) return SYMB_CENTROID_OUT;
 | 
			
		||||
      else if ( area > 0 ) return SYMB_CENTROID_IN;
 | 
			
		||||
      else return SYMB_CENTROID_DUPL; /* area < 0 */
 | 
			
		||||
      if ( area == 0 )
 | 
			
		||||
        return SYMB_CENTROID_OUT;
 | 
			
		||||
      else if ( area > 0 )
 | 
			
		||||
        return SYMB_CENTROID_IN;
 | 
			
		||||
      else
 | 
			
		||||
        return SYMB_CENTROID_DUPL; /* area < 0 */
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -1198,7 +1218,8 @@ void QgsGrassEdit::snap( QgsPoint & point, double startX, double startY )
 | 
			
		||||
  // Start
 | 
			
		||||
  double startDist = hypot( x - startX, y - startY );
 | 
			
		||||
  bool startIn = false;
 | 
			
		||||
  if ( startDist <= thresh ) startIn = true;
 | 
			
		||||
  if ( startDist <= thresh )
 | 
			
		||||
    startIn = true;
 | 
			
		||||
 | 
			
		||||
  // Nearest node
 | 
			
		||||
  double nodeX = 0;
 | 
			
		||||
@ -1404,14 +1425,16 @@ void QgsGrassEdit::checkOrphan( int field, int cat )
 | 
			
		||||
                          tr( "Cannot check orphan record: %1" ).arg( *error ) );
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  if ( !orphan ) return;
 | 
			
		||||
  if ( !orphan )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QMessageBox::StandardButton ret = QMessageBox::question( 0, tr( "Warning" ),
 | 
			
		||||
                                    tr( "Orphan record was left in attribute table. "
 | 
			
		||||
                                        "<br>Delete the record?" ),
 | 
			
		||||
                                    QMessageBox::Ok | QMessageBox::Cancel );
 | 
			
		||||
 | 
			
		||||
  if ( ret == QMessageBox::Cancel ) return;
 | 
			
		||||
  if ( ret == QMessageBox::Cancel )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Delete record
 | 
			
		||||
  error = mProvider->deleteAttributes( field, cat );
 | 
			
		||||
@ -1496,7 +1519,8 @@ void QgsGrassEdit::addCat( int line )
 | 
			
		||||
 | 
			
		||||
  line = mProvider->rewriteLine( line, type, mPoints, mCats );
 | 
			
		||||
  mSelectedLine = line;
 | 
			
		||||
  if ( mAttributes ) mAttributes->setLine( line );
 | 
			
		||||
  if ( mAttributes )
 | 
			
		||||
    mAttributes->setLine( line );
 | 
			
		||||
  updateSymb();
 | 
			
		||||
  increaseMaxCat();
 | 
			
		||||
 | 
			
		||||
@ -1533,7 +1557,8 @@ void QgsGrassEdit::deleteCat( int line, int field, int cat )
 | 
			
		||||
 | 
			
		||||
  line = mProvider->rewriteLine( line, type, mPoints, mCats );
 | 
			
		||||
  mSelectedLine = line;
 | 
			
		||||
  if ( mAttributes ) mAttributes->setLine( line );
 | 
			
		||||
  if ( mAttributes )
 | 
			
		||||
    mAttributes->setLine( line );
 | 
			
		||||
 | 
			
		||||
  // Check orphan record
 | 
			
		||||
  checkOrphan( field, cat );
 | 
			
		||||
@ -1550,7 +1575,8 @@ void QgsGrassEdit::postRender( QPainter * )
 | 
			
		||||
  //          after disconnect (is it a queue?)
 | 
			
		||||
  //          -> check mValid
 | 
			
		||||
 | 
			
		||||
  if ( !mValid ) return;
 | 
			
		||||
  if ( !mValid )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  displayMap();
 | 
			
		||||
 | 
			
		||||
@ -1594,7 +1620,8 @@ void QgsGrassEdit::displayMap()
 | 
			
		||||
  {
 | 
			
		||||
    for ( int node = 1; node <= nnodes; node++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( mNodeSymb[node] == SYMB_NODE_0 ) continue; // do not display nodes with points only
 | 
			
		||||
      if ( mNodeSymb[node] == SYMB_NODE_0 )
 | 
			
		||||
        continue; // do not display nodes with points only
 | 
			
		||||
      displayNode( node, mSymb[mNodeSymb[node]], mSize, painter );
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -1624,7 +1651,8 @@ void QgsGrassEdit::displayUpdated( void )
 | 
			
		||||
  for ( int i = 0; i < nlines; i++ )
 | 
			
		||||
  {
 | 
			
		||||
    int line = mProvider->updatedLine( i );
 | 
			
		||||
    if ( !( mProvider->lineAlive( line ) ) ) continue;
 | 
			
		||||
    if ( !( mProvider->lineAlive( line ) ) )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    displayElement( line, mSymb[mLineSymb[line]], mSize, painter );
 | 
			
		||||
  }
 | 
			
		||||
@ -1634,8 +1662,10 @@ void QgsGrassEdit::displayUpdated( void )
 | 
			
		||||
  for ( int i = 0; i < nnodes; i++ )
 | 
			
		||||
  {
 | 
			
		||||
    int node = mProvider->updatedNode( i );
 | 
			
		||||
    if ( !( mProvider->nodeAlive( node ) ) ) continue;
 | 
			
		||||
    if ( mNodeSymb[node] == SYMB_NODE_0 ) continue; // do not display nodes with points only
 | 
			
		||||
    if ( !( mProvider->nodeAlive( node ) ) )
 | 
			
		||||
      continue;
 | 
			
		||||
    if ( mNodeSymb[node] == SYMB_NODE_0 )
 | 
			
		||||
      continue; // do not display nodes with points only
 | 
			
		||||
    displayNode( node, mSymb[mNodeSymb[node]], mSize, painter );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -1656,10 +1686,12 @@ void QgsGrassEdit::displayElement( int line, const QPen & pen, int size, QPainte
 | 
			
		||||
  if ( line == 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  if ( !mSymbDisplay[mLineSymb[line]] ) return;
 | 
			
		||||
  if ( !mSymbDisplay[mLineSymb[line]] )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  int type = mProvider->readLine( mPoints, NULL, line );
 | 
			
		||||
  if ( type < 0 ) return;
 | 
			
		||||
  if ( type < 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QPainter *myPainter;
 | 
			
		||||
  if ( !painter )
 | 
			
		||||
@ -1708,7 +1740,8 @@ void QgsGrassEdit::eraseElement( int line )
 | 
			
		||||
  QgsDebugMsg( QString( "line = %1" ).arg( line ) );
 | 
			
		||||
 | 
			
		||||
  int type = mProvider->readLine( NULL, NULL, line );
 | 
			
		||||
  if ( type < 0 ) return;
 | 
			
		||||
  if ( type < 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Erase line
 | 
			
		||||
  displayElement( line, mSymb[SYMB_BACKGROUND], mSize );
 | 
			
		||||
@ -1782,11 +1815,13 @@ void QgsGrassEdit::displayNode( int node, const QPen & pen, int size, QPainter *
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( QString( "node = %1" ).arg( node ) );
 | 
			
		||||
 | 
			
		||||
  if ( !mSymbDisplay[mNodeSymb[node]] ) return;
 | 
			
		||||
  if ( !mSymbDisplay[mNodeSymb[node]] )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  double x, y;
 | 
			
		||||
 | 
			
		||||
  if ( !( mProvider->nodeCoor( node, &x, &y ) ) ) return;
 | 
			
		||||
  if ( !( mProvider->nodeCoor( node, &x, &y ) ) )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  displayIcon( x, y, pen, QgsVertexMarker::ICON_X, size, painter );
 | 
			
		||||
}
 | 
			
		||||
@ -1876,9 +1911,12 @@ void QgsGrassEdit::setCanvasPrompt( QString left, QString mid, QString right )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
  mCanvasPrompt = "";
 | 
			
		||||
  if ( left.length() > 0 ) mCanvasPrompt.append( tr( "Left: %1   " ).arg( left ) );
 | 
			
		||||
  if ( mid.length() > 0 ) mCanvasPrompt.append( tr( "Middle: %1" ).arg( mid ) );
 | 
			
		||||
  if ( right.length() > 0 ) mCanvasPrompt.append( tr( "Right: %1" ).arg( right ) );
 | 
			
		||||
  if ( left.length() > 0 )
 | 
			
		||||
    mCanvasPrompt.append( tr( "Left: %1   " ).arg( left ) );
 | 
			
		||||
  if ( mid.length() > 0 )
 | 
			
		||||
    mCanvasPrompt.append( tr( "Middle: %1" ).arg( mid ) );
 | 
			
		||||
  if ( right.length() > 0 )
 | 
			
		||||
    mCanvasPrompt.append( tr( "Right: %1" ).arg( right ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsGrassEdit::attributesClosed()
 | 
			
		||||
 | 
			
		||||
@ -313,7 +313,8 @@ void QgsGrassEditMoveVertex::mouseClick( QgsPoint & point, Qt::MouseButton butto
 | 
			
		||||
          double dist2 = Vect_points_distance( xl, yl, 0.0, e->mEditPoints->x[e->mSelectedPart],
 | 
			
		||||
                                               e->mEditPoints->y[e->mSelectedPart], 0.0, 0 );
 | 
			
		||||
 | 
			
		||||
          if ( dist1 < dist2 ) e->mSelectedPart--;
 | 
			
		||||
          if ( dist1 < dist2 )
 | 
			
		||||
            e->mSelectedPart--;
 | 
			
		||||
 | 
			
		||||
          e->setCanvasPrompt( tr( "Select new position" ), "", "Release vertex" );
 | 
			
		||||
        }
 | 
			
		||||
@ -579,7 +580,8 @@ void QgsGrassEditDeleteVertex::mouseClick( QgsPoint & point, Qt::MouseButton but
 | 
			
		||||
          double dist2 = Vect_points_distance( xl, yl, 0.0, e->mEditPoints->x[e->mSelectedPart],
 | 
			
		||||
                                               e->mEditPoints->y[e->mSelectedPart], 0.0, 0 );
 | 
			
		||||
 | 
			
		||||
          if ( dist1 < dist2 ) e->mSelectedPart--;
 | 
			
		||||
          if ( dist1 < dist2 )
 | 
			
		||||
            e->mSelectedPart--;
 | 
			
		||||
 | 
			
		||||
          e->displayDynamic( e->mEditPoints->x[e->mSelectedPart], e->mEditPoints->y[e->mSelectedPart],
 | 
			
		||||
                             QgsVertexMarker::ICON_BOX, e->mSize );
 | 
			
		||||
 | 
			
		||||
@ -452,7 +452,8 @@ QStringList QgsGrassMapcalc::checkOutput()
 | 
			
		||||
 | 
			
		||||
  QString value = mOutputLineEdit->text().trimmed();
 | 
			
		||||
 | 
			
		||||
  if ( value.length() == 0 ) return QStringList();
 | 
			
		||||
  if ( value.length() == 0 )
 | 
			
		||||
    return QStringList();
 | 
			
		||||
 | 
			
		||||
  QString path = QgsGrass::getDefaultGisdbase() + "/"
 | 
			
		||||
                 + QgsGrass::getDefaultLocation() + "/"
 | 
			
		||||
@ -633,8 +634,10 @@ void QgsGrassMapcalc::setOption()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
 | 
			
		||||
  if ( mTool != Select ) return;
 | 
			
		||||
  if ( !mObject ) return;
 | 
			
		||||
  if ( mTool != Select )
 | 
			
		||||
    return;
 | 
			
		||||
  if ( !mObject )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  switch ( mObject->type() )
 | 
			
		||||
  {
 | 
			
		||||
@ -666,8 +669,10 @@ void QgsGrassMapcalc::setOption()
 | 
			
		||||
    case QgsGrassMapcalcObject::Function :
 | 
			
		||||
      for ( unsigned int i = 0; i < mFunctions.size(); i++ )
 | 
			
		||||
      {
 | 
			
		||||
        if ( mFunctions[i].name() != mObject->function().name() ) continue;
 | 
			
		||||
        if ( mFunctions[i].inputCount() != mObject->function().inputCount() ) continue;
 | 
			
		||||
        if ( mFunctions[i].name() != mObject->function().name() )
 | 
			
		||||
          continue;
 | 
			
		||||
        if ( mFunctions[i].inputCount() != mObject->function().inputCount() )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        mFunctionComboBox->setCurrentIndex( i );
 | 
			
		||||
        break;
 | 
			
		||||
@ -684,13 +689,17 @@ void QgsGrassMapcalc::setTool( int tool )
 | 
			
		||||
  // Clear old
 | 
			
		||||
  if ( mTool == Select )
 | 
			
		||||
  {
 | 
			
		||||
    if ( mObject ) mObject->setSelected( false );
 | 
			
		||||
    if ( mConnector ) mConnector->setSelected( false );
 | 
			
		||||
    if ( mObject )
 | 
			
		||||
      mObject->setSelected( false );
 | 
			
		||||
    if ( mConnector )
 | 
			
		||||
      mConnector->setSelected( false );
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    if ( mObject ) delete mObject;
 | 
			
		||||
    if ( mConnector ) delete mConnector;
 | 
			
		||||
    if ( mObject )
 | 
			
		||||
      delete mObject;
 | 
			
		||||
    if ( mConnector )
 | 
			
		||||
      delete mConnector;
 | 
			
		||||
    mCanvas->update();
 | 
			
		||||
  }
 | 
			
		||||
  mObject = 0;
 | 
			
		||||
@ -846,7 +855,8 @@ void QgsGrassMapcalc::updateMaps()
 | 
			
		||||
  {
 | 
			
		||||
    QgsMapLayer *layer = canvas->layer( i );
 | 
			
		||||
 | 
			
		||||
    if ( layer->type() != QgsMapLayer::RasterLayer ) continue;
 | 
			
		||||
    if ( layer->type() != QgsMapLayer::RasterLayer )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    // Check if it is GRASS raster
 | 
			
		||||
    QString source = QDir::cleanPath( layer->source() );
 | 
			
		||||
@ -855,16 +865,19 @@ void QgsGrassMapcalc::updateMaps()
 | 
			
		||||
    //QChar sep = QDir::separator();
 | 
			
		||||
    QChar sep = '/';
 | 
			
		||||
 | 
			
		||||
    if ( source.contains( "cellhd" ) == 0 ) continue;
 | 
			
		||||
    if ( source.contains( "cellhd" ) == 0 )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    // Most probably GRASS layer, check GISBASE and LOCATION
 | 
			
		||||
    QStringList split = source.split( sep, QString::SkipEmptyParts );
 | 
			
		||||
 | 
			
		||||
    if ( split.size() < 4 ) continue;
 | 
			
		||||
    if ( split.size() < 4 )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QString map = split.last();
 | 
			
		||||
    split.pop_back(); // map
 | 
			
		||||
    if ( split.last() != "cellhd" ) continue;
 | 
			
		||||
    if ( split.last() != "cellhd" )
 | 
			
		||||
      continue;
 | 
			
		||||
    split.pop_back(); // cellhd
 | 
			
		||||
 | 
			
		||||
    QString mapset = split.last();
 | 
			
		||||
@ -879,12 +892,17 @@ void QgsGrassMapcalc::updateMaps()
 | 
			
		||||
    QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() );
 | 
			
		||||
    QString curloc = curlocDir.canonicalPath();
 | 
			
		||||
 | 
			
		||||
    if ( loc != curloc ) continue;
 | 
			
		||||
    if ( loc != curloc )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    //if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) continue;
 | 
			
		||||
#if 0
 | 
			
		||||
    if ( mUpdate && mapset != QgsGrass::getDefaultMapset() )
 | 
			
		||||
      continue;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    mMapComboBox->addItem( layer->name() );
 | 
			
		||||
    //if ( layer->name() == current ) mMapComboBox->setItemText( mMapComboBox->currentIndex(), current );
 | 
			
		||||
    //if ( layer->name() == current )
 | 
			
		||||
    //  mMapComboBox->setItemText( mMapComboBox->currentIndex(), current );
 | 
			
		||||
    mMaps.push_back( map + "@" + mapset );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -893,8 +911,10 @@ void QgsGrassMapcalc::mapChanged()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
 | 
			
		||||
  if (( mTool != AddMap && mTool != Select )  || !mObject ) return;
 | 
			
		||||
  if ( mObject->type() != QgsGrassMapcalcObject::Map ) return;
 | 
			
		||||
  if (( mTool != AddMap && mTool != Select )  || !mObject )
 | 
			
		||||
    return;
 | 
			
		||||
  if ( mObject->type() != QgsGrassMapcalcObject::Map )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mObject->setValue( mMaps[mMapComboBox->currentIndex()],
 | 
			
		||||
                     mMapComboBox->currentText() );
 | 
			
		||||
@ -905,8 +925,10 @@ void QgsGrassMapcalc::constantChanged()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
 | 
			
		||||
  if (( mTool != AddConstant && mTool != Select ) || !mObject ) return;
 | 
			
		||||
  if ( mObject->type() != QgsGrassMapcalcObject::Constant ) return;
 | 
			
		||||
  if (( mTool != AddConstant && mTool != Select ) || !mObject )
 | 
			
		||||
    return;
 | 
			
		||||
  if ( mObject->type() != QgsGrassMapcalcObject::Constant )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mObject->setValue( mConstantLineEdit->text() );
 | 
			
		||||
  mCanvas->update();
 | 
			
		||||
@ -916,8 +938,10 @@ void QgsGrassMapcalc::functionChanged()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
 | 
			
		||||
  if (( mTool != AddFunction && mTool != Select ) || !mObject ) return;
 | 
			
		||||
  if ( mObject->type() != QgsGrassMapcalcObject::Function ) return;
 | 
			
		||||
  if (( mTool != AddFunction && mTool != Select ) || !mObject )
 | 
			
		||||
    return;
 | 
			
		||||
  if ( mObject->type() != QgsGrassMapcalcObject::Function )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mObject->setFunction( mFunctions[ mFunctionComboBox->currentIndex()] );
 | 
			
		||||
  mCanvas->update();
 | 
			
		||||
@ -925,10 +949,14 @@ void QgsGrassMapcalc::functionChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassMapcalc::limit( QPoint *point )
 | 
			
		||||
{
 | 
			
		||||
  if ( point->x() < 0 ) point->setX( 0 );
 | 
			
		||||
  if ( point->y() < 0 ) point->setY( 0 );
 | 
			
		||||
  if ( point->x() > mCanvas->width() ) point->setX( mCanvas->width() );
 | 
			
		||||
  if ( point->y() > mCanvas->height() ) point->setY( mCanvas->height() );
 | 
			
		||||
  if ( point->x() < 0 )
 | 
			
		||||
    point->setX( 0 );
 | 
			
		||||
  if ( point->y() < 0 )
 | 
			
		||||
    point->setY( 0 );
 | 
			
		||||
  if ( point->x() > mCanvas->width() )
 | 
			
		||||
    point->setX( mCanvas->width() );
 | 
			
		||||
  if ( point->y() > mCanvas->height() )
 | 
			
		||||
    point->setY( mCanvas->height() );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsGrassMapcalc::resizeCanvas( int width, int height )
 | 
			
		||||
@ -1007,10 +1035,14 @@ void QgsGrassMapcalc::autoGrow()
 | 
			
		||||
 | 
			
		||||
    QgsDebugMsg( QString( "r.left = %1 r.right = %2 r.top = %3 bottom = %4" ).arg( r.left() ).arg( r.right() ).arg( r.top() ).arg( r.bottom() ) );
 | 
			
		||||
 | 
			
		||||
    if ( r.left() - thresh < left )     left   = r.left() - thresh;
 | 
			
		||||
    if ( r.right() + thresh > right )   right  = r.right() + thresh;
 | 
			
		||||
    if ( r.top() - thresh < top )       top    = r.top() - thresh;
 | 
			
		||||
    if ( r.bottom() + thresh > bottom ) bottom = r.bottom() + thresh;
 | 
			
		||||
    if ( r.left() - thresh < left )
 | 
			
		||||
      left   = r.left() - thresh;
 | 
			
		||||
    if ( r.right() + thresh > right )
 | 
			
		||||
      right  = r.right() + thresh;
 | 
			
		||||
    if ( r.top() - thresh < top )
 | 
			
		||||
      top    = r.top() - thresh;
 | 
			
		||||
    if ( r.bottom() + thresh > bottom )
 | 
			
		||||
      bottom = r.bottom() + thresh;
 | 
			
		||||
 | 
			
		||||
    QgsDebugMsg( QString( "left = %1 right = %2 top = %3 bottom = %4" ).arg( left ).arg( right ).arg( top ).arg( bottom ) );
 | 
			
		||||
  }
 | 
			
		||||
@ -1051,7 +1083,8 @@ void QgsGrassMapcalc::saveAs()
 | 
			
		||||
    bool ok;
 | 
			
		||||
    name = QInputDialog::getText( this, tr( "New mapcalc" ),
 | 
			
		||||
                                  tr( "Enter new mapcalc name:" ), QLineEdit::Normal, mFileName, &ok );
 | 
			
		||||
    if ( !ok ) return;
 | 
			
		||||
    if ( !ok )
 | 
			
		||||
      return;
 | 
			
		||||
    name = name.trimmed();
 | 
			
		||||
 | 
			
		||||
    if ( name.isEmpty() )
 | 
			
		||||
@ -1067,7 +1100,8 @@ void QgsGrassMapcalc::saveAs()
 | 
			
		||||
                                        tr( "The file already exists. Overwrite?" ),
 | 
			
		||||
                                        QMessageBox::Ok | QMessageBox::Cancel );
 | 
			
		||||
 | 
			
		||||
      if ( ret == QMessageBox::Cancel ) continue;
 | 
			
		||||
      if ( ret == QMessageBox::Cancel )
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
    break;
 | 
			
		||||
  }
 | 
			
		||||
@ -1217,7 +1251,8 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
 | 
			
		||||
  QgsGrassSelect *sel = new QgsGrassSelect( QgsGrassSelect::MAPCALC );
 | 
			
		||||
  if ( sel->exec() == QDialog::Rejected ) return;
 | 
			
		||||
  if ( sel->exec() == QDialog::Rejected )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Open file
 | 
			
		||||
  QString path = sel->gisdbase + "/" + sel->location + "/"
 | 
			
		||||
@ -1269,7 +1304,8 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
  {
 | 
			
		||||
    QDomNode node = objectNodes.item( n );
 | 
			
		||||
    QDomElement e = node.toElement();
 | 
			
		||||
    if ( e.isNull() ) continue;
 | 
			
		||||
    if ( e.isNull() )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QgsDebugMsg( QString( "id = %1" ).arg( e.attribute( "id", "?" ).toLocal8Bit().constData() ) );
 | 
			
		||||
    unsigned int id = e.attribute( "id", "0" ).toInt();
 | 
			
		||||
@ -1278,7 +1314,8 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
    QString typeName = e.attribute( "type", "constant" );
 | 
			
		||||
    QString value = e.attribute( "value", "???" );
 | 
			
		||||
 | 
			
		||||
    if ( id >= mNextId ) mNextId = id + 1;
 | 
			
		||||
    if ( id >= mNextId )
 | 
			
		||||
      mNextId = id + 1;
 | 
			
		||||
    if ( id >= objects.size() )
 | 
			
		||||
    {
 | 
			
		||||
      objects.resize( id + 1 );
 | 
			
		||||
@ -1297,7 +1334,8 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
    else if ( typeName == "output" )
 | 
			
		||||
      type = QgsGrassMapcalcObject::Output;
 | 
			
		||||
 | 
			
		||||
    if ( type == -1 ) continue;
 | 
			
		||||
    if ( type == -1 )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QgsGrassMapcalcObject *obj = new QgsGrassMapcalcObject( type );
 | 
			
		||||
    objects[id] = obj;
 | 
			
		||||
@ -1328,8 +1366,10 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
        int fn = -1;
 | 
			
		||||
        for ( unsigned int i = 0; i < mFunctions.size(); i++ )
 | 
			
		||||
        {
 | 
			
		||||
          if ( mFunctions[i].name() != value ) continue;
 | 
			
		||||
          if ( mFunctions[i].inputCount() != inputCount ) continue;
 | 
			
		||||
          if ( mFunctions[i].name() != value )
 | 
			
		||||
            continue;
 | 
			
		||||
          if ( mFunctions[i].inputCount() != inputCount )
 | 
			
		||||
            continue;
 | 
			
		||||
          fn = i;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -1349,11 +1389,13 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
  {
 | 
			
		||||
    QDomNode node = connectorNodes.item( n );
 | 
			
		||||
    QDomElement e = node.toElement();
 | 
			
		||||
    if ( e.isNull() ) continue;
 | 
			
		||||
    if ( e.isNull() )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QgsDebugMsg( QString( "id = %1" ).arg( e.attribute( "id", "?" ).toLocal8Bit().constData() ) );
 | 
			
		||||
    unsigned int id = e.attribute( "id", "0" ).toInt();
 | 
			
		||||
    if ( id >= mNextId ) mNextId = id + 1;
 | 
			
		||||
    if ( id >= mNextId )
 | 
			
		||||
      mNextId = id + 1;
 | 
			
		||||
 | 
			
		||||
    QgsGrassMapcalcConnector *con = new QgsGrassMapcalcConnector( mCanvas );
 | 
			
		||||
 | 
			
		||||
@ -1367,7 +1409,8 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
    {
 | 
			
		||||
      QDomNode node2 = endNodes.item( n2 );
 | 
			
		||||
      QDomElement e2 = node2.toElement();
 | 
			
		||||
      if ( e2.isNull() ) continue;
 | 
			
		||||
      if ( e2.isNull() )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      int x = e2.attribute( "x", "0" ).toInt();
 | 
			
		||||
      int y = e2.attribute( "y", "0" ).toInt();
 | 
			
		||||
@ -1377,7 +1420,8 @@ void QgsGrassMapcalc::load()
 | 
			
		||||
 | 
			
		||||
      int objId = e2.attribute( "object", "-1" ).toInt();
 | 
			
		||||
      QgsDebugMsg( QString( "objId = %1" ).arg( objId ) );
 | 
			
		||||
      if ( objId < 0 ) continue; // not connected
 | 
			
		||||
      if ( objId < 0 )
 | 
			
		||||
        continue; // not connected
 | 
			
		||||
 | 
			
		||||
      if ( static_cast<uint>( objId ) < objects.size() && objects[objId] )
 | 
			
		||||
      {
 | 
			
		||||
@ -1458,7 +1502,8 @@ QgsGrassMapcalcObject::QgsGrassMapcalcObject( int type )
 | 
			
		||||
  mInputCount = 0;
 | 
			
		||||
  mOutputCount = 1;
 | 
			
		||||
 | 
			
		||||
  if ( mType == Function ) mInputCount = 2;
 | 
			
		||||
  if ( mType == Function )
 | 
			
		||||
    mInputCount = 2;
 | 
			
		||||
 | 
			
		||||
  if ( mType == Output )
 | 
			
		||||
  {
 | 
			
		||||
@ -1608,7 +1653,8 @@ void QgsGrassMapcalcObject::resetSize()
 | 
			
		||||
      */
 | 
			
		||||
      QString l = mFunction.inputLabels().at( i );
 | 
			
		||||
      int len = metrics.width( l );
 | 
			
		||||
      if ( len > mInputTextWidth ) mInputTextWidth = len;
 | 
			
		||||
      if ( len > mInputTextWidth )
 | 
			
		||||
        mInputTextWidth = len;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -1738,7 +1784,8 @@ bool QgsGrassMapcalcObject::tryConnect( QgsGrassMapcalcConnector *connector,
 | 
			
		||||
  {
 | 
			
		||||
    for ( int i = 0; i < mInputCount; i++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( mInputConnectors[i] ) continue; // used
 | 
			
		||||
      if ( mInputConnectors[i] )
 | 
			
		||||
        continue; // used
 | 
			
		||||
 | 
			
		||||
      double d = sqrt( pow(( double )( mInputPoints[i].x() + pos().x() - p.x() ), 2.0 )
 | 
			
		||||
                       + pow(( double )( mInputPoints[i].y() + pos().y() - p.y() ), 2.0 ) );
 | 
			
		||||
@ -2010,7 +2057,8 @@ void QgsGrassMapcalcConnector::setSocket( int end,
 | 
			
		||||
  mSocketDir[end] = direction;
 | 
			
		||||
  mSocket[end] = socket;
 | 
			
		||||
 | 
			
		||||
  if ( !object ) return; // disconnect only
 | 
			
		||||
  if ( !object )
 | 
			
		||||
    return; // disconnect only
 | 
			
		||||
 | 
			
		||||
  mSocketObjects[end]->setConnector( mSocketDir[end],
 | 
			
		||||
                                     mSocket[end], this, end );
 | 
			
		||||
@ -2036,8 +2084,10 @@ QString QgsGrassMapcalcConnector::expression()
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
  for ( int i = 0; i < 2; i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( !mSocketObjects[i] ) continue;
 | 
			
		||||
    if ( mSocketDir[i] != QgsGrassMapcalcObject::Out ) continue;
 | 
			
		||||
    if ( !mSocketObjects[i] )
 | 
			
		||||
      continue;
 | 
			
		||||
    if ( mSocketDir[i] != QgsGrassMapcalcObject::Out )
 | 
			
		||||
      continue;
 | 
			
		||||
    return mSocketObjects[i]->expression();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -2057,7 +2107,8 @@ QgsGrassMapcalcFunction::QgsGrassMapcalcFunction( int type, QString name,
 | 
			
		||||
    mLabel( label ), mDescription( description ),
 | 
			
		||||
    mDrawLabel( drawLabel )
 | 
			
		||||
{
 | 
			
		||||
  if ( mLabel.isEmpty() ) mLabel = mName;
 | 
			
		||||
  if ( mLabel.isEmpty() )
 | 
			
		||||
    mLabel = mName;
 | 
			
		||||
 | 
			
		||||
  if ( !labels.isEmpty() )
 | 
			
		||||
  {
 | 
			
		||||
 | 
			
		||||
@ -99,7 +99,8 @@ void QgsGrassModelItem::copyNames( QgsGrassModelItem *item )
 | 
			
		||||
 | 
			
		||||
QVariant QgsGrassModelItem::data( int role )
 | 
			
		||||
{
 | 
			
		||||
  if ( role != Qt::DisplayRole ) return QVariant();
 | 
			
		||||
  if ( role != Qt::DisplayRole )
 | 
			
		||||
    return QVariant();
 | 
			
		||||
 | 
			
		||||
  return name();
 | 
			
		||||
}
 | 
			
		||||
@ -520,7 +521,8 @@ void QgsGrassModelItem::populate()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "called." );
 | 
			
		||||
 | 
			
		||||
  if ( mPopulated ) return;
 | 
			
		||||
  if ( mPopulated )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mModel->refreshItem( this );
 | 
			
		||||
}
 | 
			
		||||
@ -708,9 +710,12 @@ void QgsGrassModel::refreshItem( QgsGrassModelItem *item )
 | 
			
		||||
                            "windows" );
 | 
			
		||||
 | 
			
		||||
      QStringList list;
 | 
			
		||||
      if ( vectors.count() > 0 ) list.append( "vector" );
 | 
			
		||||
      if ( rasters.count() > 0 ) list.append( "raster" );
 | 
			
		||||
      if ( regions.count() > 0 ) list.append( "region" );
 | 
			
		||||
      if ( vectors.count() > 0 )
 | 
			
		||||
        list.append( "vector" );
 | 
			
		||||
      if ( rasters.count() > 0 )
 | 
			
		||||
        list.append( "raster" );
 | 
			
		||||
      if ( regions.count() > 0 )
 | 
			
		||||
        list.append( "region" );
 | 
			
		||||
 | 
			
		||||
      removeItems( item, list );
 | 
			
		||||
 | 
			
		||||
@ -796,7 +801,8 @@ QModelIndex QgsGrassModel::index( int row, int column,
 | 
			
		||||
  // for example if beginInsertRows(,0,0) is called and the first
 | 
			
		||||
  // item was previously deleted => check if row < 0
 | 
			
		||||
  // and return empty QModelIndex, but is it correct?
 | 
			
		||||
  if ( row < 0 ) return QModelIndex();
 | 
			
		||||
  if ( row < 0 )
 | 
			
		||||
    return QModelIndex();
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  if ( !parent.isValid() )
 | 
			
		||||
@ -807,8 +813,10 @@ QModelIndex QgsGrassModel::index( int row, int column,
 | 
			
		||||
  {
 | 
			
		||||
    item = static_cast<QgsGrassModelItem*>( parent.internalPointer() );
 | 
			
		||||
  }
 | 
			
		||||
  //if ( !item->populated() ) refreshItem(item);
 | 
			
		||||
  if ( !item->populated() ) item->populate();
 | 
			
		||||
  //if ( !item->populated() )
 | 
			
		||||
  //refreshItem(item);
 | 
			
		||||
  if ( !item->populated() )
 | 
			
		||||
    item->populate();
 | 
			
		||||
  return createIndex( row, column, item->child( row ) );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -816,14 +824,16 @@ QModelIndex QgsGrassModel::parent( const QModelIndex & index ) const
 | 
			
		||||
{
 | 
			
		||||
// QgsDebugMsg("entered.");
 | 
			
		||||
 | 
			
		||||
  if ( !index.isValid() ) return QModelIndex();
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QModelIndex();
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *item =
 | 
			
		||||
    static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *parentNode = item->mParent;
 | 
			
		||||
 | 
			
		||||
  if ( parentNode == 0 || parentNode == mRoot ) return QModelIndex();
 | 
			
		||||
  if ( parentNode == 0 || parentNode == mRoot )
 | 
			
		||||
    return QModelIndex();
 | 
			
		||||
 | 
			
		||||
  // parent's row
 | 
			
		||||
  QVector<QgsGrassModelItem*> children = parentNode->mParent ?
 | 
			
		||||
@ -855,8 +865,10 @@ int QgsGrassModel::rowCount( const QModelIndex & parent ) const
 | 
			
		||||
  }
 | 
			
		||||
// QgsDebugMsg(QString("name = %1").arg(item->name()));
 | 
			
		||||
// QgsDebugMsg(QString("count = %1").arg(item->mChildren.size()));
 | 
			
		||||
  if ( !item->populated() ) item->populate();
 | 
			
		||||
  //if ( !item->populated() ) refreshItem(item);
 | 
			
		||||
  if ( !item->populated() )
 | 
			
		||||
    item->populate();
 | 
			
		||||
  //if ( !item->populated() )
 | 
			
		||||
  //refreshItem(item);
 | 
			
		||||
  return item->mChildren.size();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -870,8 +882,10 @@ QVariant QgsGrassModel::data( const QModelIndex &index, int role ) const
 | 
			
		||||
{
 | 
			
		||||
// QgsDebugMsg("entered.");
 | 
			
		||||
 | 
			
		||||
  if ( !index.isValid() ) { return QVariant(); }
 | 
			
		||||
  if ( role != Qt::DisplayRole && role != Qt::DecorationRole ) return QVariant();
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QVariant();
 | 
			
		||||
  if ( role != Qt::DisplayRole && role != Qt::DecorationRole )
 | 
			
		||||
    return QVariant();
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  item = static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
@ -920,7 +934,8 @@ QVariant QgsGrassModel::data( const QModelIndex &index, int role ) const
 | 
			
		||||
 | 
			
		||||
QString QgsGrassModel::itemName( const QModelIndex &index )
 | 
			
		||||
{
 | 
			
		||||
  if ( !index.isValid() ) { return QString(); }
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QString();
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  item = static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
@ -930,7 +945,8 @@ QString QgsGrassModel::itemName( const QModelIndex &index )
 | 
			
		||||
 | 
			
		||||
QString QgsGrassModel::itemMapset( const QModelIndex &index )
 | 
			
		||||
{
 | 
			
		||||
  if ( !index.isValid() ) { return QString(); }
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QString();
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  item = static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
@ -940,7 +956,8 @@ QString QgsGrassModel::itemMapset( const QModelIndex &index )
 | 
			
		||||
 | 
			
		||||
QString QgsGrassModel::itemMap( const QModelIndex &index )
 | 
			
		||||
{
 | 
			
		||||
  if ( !index.isValid() ) { return QString(); }
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QString();
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  item = static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
@ -950,7 +967,8 @@ QString QgsGrassModel::itemMap( const QModelIndex &index )
 | 
			
		||||
 | 
			
		||||
QString QgsGrassModel::itemInfo( const QModelIndex &index )
 | 
			
		||||
{
 | 
			
		||||
  if ( !index.isValid() ) { return QString(); }
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QString();
 | 
			
		||||
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  item = static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
@ -960,7 +978,8 @@ QString QgsGrassModel::itemInfo( const QModelIndex &index )
 | 
			
		||||
 | 
			
		||||
int QgsGrassModel::itemType( const QModelIndex &index ) const
 | 
			
		||||
{
 | 
			
		||||
  if ( !index.isValid() ) { return QgsGrassModel::None; }
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QgsGrassModel::None;
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  item = static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
  return item->type();
 | 
			
		||||
@ -968,7 +987,8 @@ int QgsGrassModel::itemType( const QModelIndex &index ) const
 | 
			
		||||
 | 
			
		||||
QString QgsGrassModel::uri( const QModelIndex &index ) const
 | 
			
		||||
{
 | 
			
		||||
  if ( !index.isValid() ) { return QString(); }
 | 
			
		||||
  if ( !index.isValid() )
 | 
			
		||||
    return QString();
 | 
			
		||||
  QgsGrassModelItem *item;
 | 
			
		||||
  item = static_cast<QgsGrassModelItem*>( index.internalPointer() );
 | 
			
		||||
  return item->uri();
 | 
			
		||||
 | 
			
		||||
@ -73,7 +73,8 @@ QString QgsGrassModule::findExec( QString file )
 | 
			
		||||
    mExecPathInited = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( QFile::exists( file ) ) return file;  // full path
 | 
			
		||||
  if ( QFile::exists( file ) )
 | 
			
		||||
    return file;  // full path
 | 
			
		||||
 | 
			
		||||
#ifdef WIN32
 | 
			
		||||
  // On windows try .bat first
 | 
			
		||||
@ -658,10 +659,12 @@ void QgsGrassModuleStandardOptions::freezeOutput()
 | 
			
		||||
      {
 | 
			
		||||
        QgsMapLayer *layer = mCanvas->layer( i );
 | 
			
		||||
 | 
			
		||||
        if ( layer->type() != QgsMapLayer::VectorLayer ) continue;
 | 
			
		||||
        if ( layer->type() != QgsMapLayer::VectorLayer )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
 | 
			
		||||
        if ( vector->providerType() != "grass" ) continue;
 | 
			
		||||
        if ( vector->providerType() != "grass" )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        //TODO dynamic_cast ?
 | 
			
		||||
        QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider();
 | 
			
		||||
@ -674,7 +677,8 @@ void QgsGrassModuleStandardOptions::freezeOutput()
 | 
			
		||||
        // Check GISBASE and LOCATION
 | 
			
		||||
        QStringList split = source.split( sep );
 | 
			
		||||
 | 
			
		||||
        if ( split.size() < 4 ) continue;
 | 
			
		||||
        if ( split.size() < 4 )
 | 
			
		||||
          continue;
 | 
			
		||||
        split.pop_back(); // layer
 | 
			
		||||
 | 
			
		||||
        QString map = split.last();
 | 
			
		||||
@ -689,11 +693,14 @@ void QgsGrassModuleStandardOptions::freezeOutput()
 | 
			
		||||
        QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() );
 | 
			
		||||
        QString curloc = curlocDir.canonicalPath();
 | 
			
		||||
 | 
			
		||||
        if ( loc != curloc ) continue;
 | 
			
		||||
        if ( loc != curloc )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        if ( mapset != QgsGrass::getDefaultMapset() ) continue;
 | 
			
		||||
        if ( mapset != QgsGrass::getDefaultMapset() )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        if ( provider->isFrozen() ) continue;
 | 
			
		||||
        if ( provider->isFrozen() )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        provider->freeze();
 | 
			
		||||
      }
 | 
			
		||||
@ -727,10 +734,12 @@ void QgsGrassModuleStandardOptions::thawOutput()
 | 
			
		||||
      {
 | 
			
		||||
        QgsMapLayer *layer = mCanvas->layer( i );
 | 
			
		||||
 | 
			
		||||
        if ( layer->type() != QgsMapLayer::VectorLayer ) continue;
 | 
			
		||||
        if ( layer->type() != QgsMapLayer::VectorLayer )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
 | 
			
		||||
        if ( vector->providerType() != "grass" ) continue;
 | 
			
		||||
        if ( vector->providerType() != "grass" )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        //TODO dynamic_cast ?
 | 
			
		||||
        QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider();
 | 
			
		||||
@ -743,7 +752,8 @@ void QgsGrassModuleStandardOptions::thawOutput()
 | 
			
		||||
        // Check GISBASE and LOCATION
 | 
			
		||||
        QStringList split = source.split( sep );
 | 
			
		||||
 | 
			
		||||
        if ( split.size() < 4 ) continue;
 | 
			
		||||
        if ( split.size() < 4 )
 | 
			
		||||
          continue;
 | 
			
		||||
        split.pop_back(); // layer
 | 
			
		||||
 | 
			
		||||
        QString map = split.last();
 | 
			
		||||
@ -758,11 +768,14 @@ void QgsGrassModuleStandardOptions::thawOutput()
 | 
			
		||||
        QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() );
 | 
			
		||||
        QString curloc = curlocDir.canonicalPath();
 | 
			
		||||
 | 
			
		||||
        if ( loc != curloc ) continue;
 | 
			
		||||
        if ( loc != curloc )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        if ( mapset != QgsGrass::getDefaultMapset() ) continue;
 | 
			
		||||
        if ( mapset != QgsGrass::getDefaultMapset() )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        if ( !provider->isFrozen() ) continue;
 | 
			
		||||
        if ( !provider->isFrozen() )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        provider->thaw();
 | 
			
		||||
      }
 | 
			
		||||
@ -815,7 +828,8 @@ bool QgsGrassModuleStandardOptions::hasOutput( int type )
 | 
			
		||||
 | 
			
		||||
    if ( opt->isOutput() )
 | 
			
		||||
    {
 | 
			
		||||
      if ( opt->outputType() == type ) return true;
 | 
			
		||||
      if ( opt->outputType() == type )
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -875,7 +889,8 @@ QStringList QgsGrassModuleStandardOptions::checkRegion()
 | 
			
		||||
    QStringList mm = item->currentMap().split( "@" );
 | 
			
		||||
    QString map = mm.at( 0 );
 | 
			
		||||
    QString mapset = QgsGrass::getDefaultMapset();
 | 
			
		||||
    if ( mm.size() > 1 ) mapset = mm.at( 1 );
 | 
			
		||||
    if ( mm.size() > 1 )
 | 
			
		||||
      mapset = mm.at( 1 );
 | 
			
		||||
    if ( !QgsGrass::mapRegion( mapType,
 | 
			
		||||
                               QgsGrass::getDefaultGisdbase(),
 | 
			
		||||
                               QgsGrass::getDefaultLocation(), mapset, map,
 | 
			
		||||
@ -918,7 +933,8 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, bool
 | 
			
		||||
    if ( !item )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    if ( !all && !item->useRegion() ) continue;
 | 
			
		||||
    if ( !all && !item->useRegion() )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QgsGrass::MapType mapType = QgsGrass::Vector;
 | 
			
		||||
 | 
			
		||||
@ -935,7 +951,8 @@ bool QgsGrassModuleStandardOptions::inputRegion( struct Cell_head *window, bool
 | 
			
		||||
    QStringList mm = item->currentMap().split( "@" );
 | 
			
		||||
    QString map = mm.at( 0 );
 | 
			
		||||
    QString mapset = QgsGrass::getDefaultMapset();
 | 
			
		||||
    if ( mm.size() > 1 ) mapset = mm.at( 1 );
 | 
			
		||||
    if ( mm.size() > 1 )
 | 
			
		||||
      mapset = mm.at( 1 );
 | 
			
		||||
    if ( !QgsGrass::mapRegion( mapType,
 | 
			
		||||
                               QgsGrass::getDefaultGisdbase(),
 | 
			
		||||
                               QgsGrass::getDefaultLocation(), mapset, map,
 | 
			
		||||
@ -1061,14 +1078,16 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
    if ( fi.exists() )
 | 
			
		||||
    {
 | 
			
		||||
      QSvgRenderer pic;
 | 
			
		||||
      if ( ! pic.load( fpath ) ) break;
 | 
			
		||||
      if ( ! pic.load( fpath ) )
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      QRect br( QPoint( 0, 0 ), pic.defaultSize() );
 | 
			
		||||
 | 
			
		||||
      double scale = 1. * height / br.height();
 | 
			
		||||
 | 
			
		||||
      int width = ( int )( scale * br.width() );
 | 
			
		||||
      if ( width <= 0 ) width = height; // should not happen
 | 
			
		||||
      if ( width <= 0 )
 | 
			
		||||
        width = height; // should not happen
 | 
			
		||||
      QPixmap pixmap( width, height );
 | 
			
		||||
      pixmap.fill( Qt::transparent );
 | 
			
		||||
      //pixmap.fill( QColor( 255, 255, 255 ) );
 | 
			
		||||
@ -1085,11 +1104,13 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
      fpath = path + "." + QString::number( cnt ) + ".png";
 | 
			
		||||
      fi.setFile( fpath );
 | 
			
		||||
 | 
			
		||||
      if ( !fi.exists() ) break;
 | 
			
		||||
      if ( !fi.exists() )
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      QPixmap pixmap;
 | 
			
		||||
 | 
			
		||||
      if ( ! pixmap.load( fpath, "PNG" ) ) break;
 | 
			
		||||
      if ( ! pixmap.load( fpath, "PNG" ) )
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      double scale = 1. * height / pixmap.height();
 | 
			
		||||
      int width = ( int )( scale * pixmap.width() );
 | 
			
		||||
@ -1110,7 +1131,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
    width += pixmaps[i].width();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( width <= 0 ) width = height; //should not happen
 | 
			
		||||
  if ( width <= 0 )
 | 
			
		||||
    width = height; //should not happen
 | 
			
		||||
 | 
			
		||||
  QString iconsPath = QgsApplication::pkgDataPath() + "/grass/modules/";
 | 
			
		||||
  QFileInfo iconsfi( iconsPath );
 | 
			
		||||
@ -1130,7 +1152,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
    img = img.scaled( arrowWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
 | 
			
		||||
    arrowPixmap = QPixmap::fromImage( img );
 | 
			
		||||
  }
 | 
			
		||||
  /*if ( iconsfi.exists() )
 | 
			
		||||
#if 0
 | 
			
		||||
  if ( iconsfi.exists() )
 | 
			
		||||
  {
 | 
			
		||||
    QSvgRenderer pic;
 | 
			
		||||
    if ( pic.load( arrowPath ) )
 | 
			
		||||
@ -1140,7 +1163,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
      double scale = 1. * height / br.height();
 | 
			
		||||
 | 
			
		||||
      arrowWidth = ( int )( scale * br.width() );
 | 
			
		||||
      if ( arrowWidth <= 0 ) arrowWidth = height; // should not happen
 | 
			
		||||
      if ( arrowWidth <= 0 )
 | 
			
		||||
        arrowWidth = height; // should not happen
 | 
			
		||||
      arrowPixmap = QPixmap( arrowWidth, height );
 | 
			
		||||
      arrowPixmap.fill( Qt::transparent );
 | 
			
		||||
      QPainter painter( &arrowPixmap );
 | 
			
		||||
@ -1149,12 +1173,14 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
      pic.render( &painter );
 | 
			
		||||
      painter.end();
 | 
			
		||||
    }
 | 
			
		||||
  }*/
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  QString plusPath = iconsPath + "grass_plus.svg";
 | 
			
		||||
  QPixmap plusPixmap;
 | 
			
		||||
  iconsfi.setFile( plusPath );
 | 
			
		||||
  /*if ( iconsfi.exists() && plusPixmap.load( plusPath, "PNG" ) )
 | 
			
		||||
#if 0
 | 
			
		||||
  if ( iconsfi.exists() && plusPixmap.load( plusPath, "PNG" ) )
 | 
			
		||||
  {
 | 
			
		||||
    double scale = 1. * height / plusPixmap.height();
 | 
			
		||||
    plusWidth = ( int )( scale * plusPixmap.width() );
 | 
			
		||||
@ -1162,7 +1188,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
    QImage img = plusPixmap.toImage();
 | 
			
		||||
    img = img.scaled( plusWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
 | 
			
		||||
    plusPixmap = QPixmap::fromImage( img );
 | 
			
		||||
  }*/
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  if ( iconsfi.exists() )
 | 
			
		||||
  {
 | 
			
		||||
    QSvgRenderer pic;
 | 
			
		||||
@ -1173,7 +1200,8 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
      double scale = 1. * height / br.height();
 | 
			
		||||
 | 
			
		||||
      plusWidth = ( int )( scale * br.width() );
 | 
			
		||||
      if ( plusWidth <= 0 ) plusWidth = height; // should not happen
 | 
			
		||||
      if ( plusWidth <= 0 )
 | 
			
		||||
        plusWidth = height; // should not happen
 | 
			
		||||
      plusPixmap = QPixmap( plusWidth, height );
 | 
			
		||||
      plusPixmap.fill( Qt::transparent );
 | 
			
		||||
      QPainter painter( &plusPixmap );
 | 
			
		||||
@ -1184,8 +1212,10 @@ QPixmap QgsGrassModule::pixmap( QString path, int height )
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  int buffer = height / 3; // buffer around a sign
 | 
			
		||||
  if ( pixmaps.size() > 1 ) width += arrowWidth + 2 * buffer; // ->
 | 
			
		||||
  if ( pixmaps.size() > 2 ) width += plusWidth + 2 * buffer; // +
 | 
			
		||||
  if ( pixmaps.size() > 1 )
 | 
			
		||||
    width += arrowWidth + 2 * buffer; // ->
 | 
			
		||||
  if ( pixmaps.size() > 2 )
 | 
			
		||||
    width += plusWidth + 2 * buffer; // +
 | 
			
		||||
 | 
			
		||||
  QPixmap pixmap( width, height );
 | 
			
		||||
  pixmap.fill( Qt::transparent );
 | 
			
		||||
@ -1278,8 +1308,10 @@ void QgsGrassModule::run()
 | 
			
		||||
        }
 | 
			
		||||
        questionBox.exec();
 | 
			
		||||
        QAbstractButton *clicked = questionBox.clickedButton();
 | 
			
		||||
        if ( clicked == questionBox.button( QMessageBox::Cancel ) ) return;
 | 
			
		||||
        if ( clicked == resetButton ) resetRegion = true;
 | 
			
		||||
        if ( clicked == questionBox.button( QMessageBox::Cancel ) )
 | 
			
		||||
          return;
 | 
			
		||||
        if ( clicked == resetButton )
 | 
			
		||||
          resetRegion = true;
 | 
			
		||||
 | 
			
		||||
        if ( resetRegion )
 | 
			
		||||
        {
 | 
			
		||||
@ -1434,7 +1466,8 @@ void QgsGrassModule::run()
 | 
			
		||||
            break;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        if ( used ) continue;
 | 
			
		||||
        if ( used )
 | 
			
		||||
          continue;
 | 
			
		||||
        QString env = "GIS_FLAG_"
 | 
			
		||||
                      + QString( allFlagNames.at( i ).toUpper() )
 | 
			
		||||
                      + "=0";
 | 
			
		||||
@ -1587,7 +1620,8 @@ void QgsGrassModule::viewOutput()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "called." );
 | 
			
		||||
 | 
			
		||||
  if ( !mSuccess ) return;
 | 
			
		||||
  if ( !mSuccess )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  for ( int i = 0; i < mOutputVector.size(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
@ -1644,7 +1678,10 @@ void QgsGrassModule::viewOutput()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QgisInterface *QgsGrassModule::qgisIface() { return mIface; }
 | 
			
		||||
QgisInterface *QgsGrassModule::qgisIface()
 | 
			
		||||
{
 | 
			
		||||
  return mIface;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QgsGrassModule::~QgsGrassModule()
 | 
			
		||||
{
 | 
			
		||||
@ -1696,7 +1733,8 @@ QgsGrassModuleOption::QgsGrassModuleOption( QgsGrassModule *module, QString key,
 | 
			
		||||
  QgsDebugMsg( "called." );
 | 
			
		||||
  setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
 | 
			
		||||
 | 
			
		||||
  if ( mHidden ) hide();
 | 
			
		||||
  if ( mHidden )
 | 
			
		||||
    hide();
 | 
			
		||||
 | 
			
		||||
  mLayout = new QVBoxLayout();
 | 
			
		||||
 | 
			
		||||
@ -1967,7 +2005,8 @@ void QgsGrassModuleOption::removeLineEdit()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "called." );
 | 
			
		||||
 | 
			
		||||
  if ( mLineEdits.size() < 2 ) return;
 | 
			
		||||
  if ( mLineEdits.size() < 2 )
 | 
			
		||||
    return;
 | 
			
		||||
  delete mLineEdits.at( mLineEdits.size() - 1 );
 | 
			
		||||
  mLineEdits.pop_back();
 | 
			
		||||
}
 | 
			
		||||
@ -1976,7 +2015,8 @@ QString QgsGrassModuleOption::outputExists()
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "called." );
 | 
			
		||||
 | 
			
		||||
  if ( !mIsOutput ) return QString();
 | 
			
		||||
  if ( !mIsOutput )
 | 
			
		||||
    return QString();
 | 
			
		||||
 | 
			
		||||
  QLineEdit *lineEdit = mLineEdits.at( 0 );
 | 
			
		||||
  QString value = lineEdit->text().trimmed();
 | 
			
		||||
@ -1984,7 +2024,8 @@ QString QgsGrassModuleOption::outputExists()
 | 
			
		||||
  QgsDebugMsg( "value = " + value );
 | 
			
		||||
  QgsDebugMsg( "mOutputElement = " + mOutputElement );
 | 
			
		||||
 | 
			
		||||
  if ( value.length() == 0 ) return QString();
 | 
			
		||||
  if ( value.length() == 0 )
 | 
			
		||||
    return QString();
 | 
			
		||||
 | 
			
		||||
  QString path = QgsGrass::getDefaultGisdbase() + "/"
 | 
			
		||||
                 + QgsGrass::getDefaultLocation() + "/"
 | 
			
		||||
@ -2012,7 +2053,8 @@ QString QgsGrassModuleOption::value()
 | 
			
		||||
      QLineEdit *lineEdit = mLineEdits.at( i );
 | 
			
		||||
      if ( lineEdit->text().trimmed().length() > 0 )
 | 
			
		||||
      {
 | 
			
		||||
        if ( value.length() > 0 ) value.append( "," );
 | 
			
		||||
        if ( value.length() > 0 )
 | 
			
		||||
          value.append( "," );
 | 
			
		||||
        value.append( lineEdit->text().trimmed() );
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
@ -2082,7 +2124,8 @@ QgsGrassModuleFlag::QgsGrassModuleFlag( QgsGrassModule *module, QString key,
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "called." );
 | 
			
		||||
 | 
			
		||||
  if ( mHidden ) hide();
 | 
			
		||||
  if ( mHidden )
 | 
			
		||||
    hide();
 | 
			
		||||
 | 
			
		||||
  if ( mAnswer == "on" )
 | 
			
		||||
    setChecked( true );
 | 
			
		||||
@ -2374,7 +2417,8 @@ void QgsGrassModuleInput::updateQgisLayers()
 | 
			
		||||
    {
 | 
			
		||||
      QgsVectorLayer *vector = ( QgsVectorLayer* )layer;
 | 
			
		||||
      QgsDebugMsg( "vector->providerType() = " + vector->providerType() );
 | 
			
		||||
      if ( vector->providerType() != "grass" ) continue;
 | 
			
		||||
      if ( vector->providerType() != "grass" )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      //TODO dynamic_cast ?
 | 
			
		||||
      QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider();
 | 
			
		||||
@ -2398,7 +2442,8 @@ void QgsGrassModuleInput::updateQgisLayers()
 | 
			
		||||
      // Check GISBASE and LOCATION
 | 
			
		||||
      QStringList split = source.split( sep, QString::SkipEmptyParts );
 | 
			
		||||
 | 
			
		||||
      if ( split.size() < 4 ) continue;
 | 
			
		||||
      if ( split.size() < 4 )
 | 
			
		||||
        continue;
 | 
			
		||||
      split.pop_back(); // layer
 | 
			
		||||
 | 
			
		||||
      QString map = split.last();
 | 
			
		||||
@ -2420,15 +2465,18 @@ void QgsGrassModuleInput::updateQgisLayers()
 | 
			
		||||
      QgsDebugMsg( "mapset = " + mapset );
 | 
			
		||||
      QgsDebugMsg( "QgsGrass::getDefaultMapset() = " + QgsGrass::getDefaultMapset() );
 | 
			
		||||
 | 
			
		||||
      if ( loc != curloc ) continue;
 | 
			
		||||
      if ( loc != curloc )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) continue;
 | 
			
		||||
      if ( mUpdate && mapset != QgsGrass::getDefaultMapset() )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      // Check if it comes from source map if necessary
 | 
			
		||||
      if ( !mMapId.isEmpty() )
 | 
			
		||||
      {
 | 
			
		||||
        QString cm = map + "@" + mapset;
 | 
			
		||||
        if ( sourceMap != cm ) continue;
 | 
			
		||||
        if ( sourceMap != cm )
 | 
			
		||||
          continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      mMaps.push_back( map + "@" + mapset );
 | 
			
		||||
@ -2459,7 +2507,8 @@ void QgsGrassModuleInput::updateQgisLayers()
 | 
			
		||||
                      + " " + grassLayer + " " + type + " )";
 | 
			
		||||
 | 
			
		||||
      mLayerComboBox->addItem( label );
 | 
			
		||||
      if ( label == current ) mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 );
 | 
			
		||||
      if ( label == current )
 | 
			
		||||
        mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 );
 | 
			
		||||
 | 
			
		||||
      mMapLayers.push_back( vector );
 | 
			
		||||
      mVectorLayerNames.push_back( grassLayer );
 | 
			
		||||
@ -2476,16 +2525,19 @@ void QgsGrassModuleInput::updateQgisLayers()
 | 
			
		||||
      // Check if it is GRASS raster
 | 
			
		||||
      QString source = QDir::cleanPath( layer->source() );
 | 
			
		||||
 | 
			
		||||
      if ( source.contains( "cellhd" ) == 0 ) continue;
 | 
			
		||||
      if ( source.contains( "cellhd" ) == 0 )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      // Most probably GRASS layer, check GISBASE and LOCATION
 | 
			
		||||
      QStringList split = source.split( sep, QString::SkipEmptyParts );
 | 
			
		||||
 | 
			
		||||
      if ( split.size() < 4 ) continue;
 | 
			
		||||
      if ( split.size() < 4 )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      QString map = split.last();
 | 
			
		||||
      split.pop_back(); // map
 | 
			
		||||
      if ( split.last() != "cellhd" ) continue;
 | 
			
		||||
      if ( split.last() != "cellhd" )
 | 
			
		||||
        continue;
 | 
			
		||||
      split.pop_back(); // cellhd
 | 
			
		||||
 | 
			
		||||
      QString mapset = split.last();
 | 
			
		||||
@ -2499,16 +2551,19 @@ void QgsGrassModuleInput::updateQgisLayers()
 | 
			
		||||
      QDir curlocDir( QgsGrass::getDefaultGisdbase() + sep + QgsGrass::getDefaultLocation() );
 | 
			
		||||
      QString curloc = curlocDir.canonicalPath();
 | 
			
		||||
 | 
			
		||||
      if ( loc != curloc ) continue;
 | 
			
		||||
      if ( loc != curloc )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      if ( mUpdate && mapset != QgsGrass::getDefaultMapset() ) continue;
 | 
			
		||||
      if ( mUpdate && mapset != QgsGrass::getDefaultMapset() )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      mMaps.push_back( map + "@" + mapset );
 | 
			
		||||
 | 
			
		||||
      QString label = layer->name() + " ( " + map + "@" + mapset + " )";
 | 
			
		||||
 | 
			
		||||
      mLayerComboBox->addItem( label );
 | 
			
		||||
      if ( label == current ) mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 );
 | 
			
		||||
      if ( label == current )
 | 
			
		||||
        mLayerComboBox->setCurrentIndex( mLayerComboBox->count() - 1 );
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -2703,9 +2758,15 @@ QgsGrassModuleItem::QgsGrassModuleItem( QgsGrassModule *module, QString key,
 | 
			
		||||
  mId = qdesc.attribute( "id" );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool QgsGrassModuleItem::hidden() { return mHidden; }
 | 
			
		||||
bool QgsGrassModuleItem::hidden()
 | 
			
		||||
{
 | 
			
		||||
  return mHidden;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QStringList QgsGrassModuleItem::options() { return QStringList(); }
 | 
			
		||||
QStringList QgsGrassModuleItem::options()
 | 
			
		||||
{
 | 
			
		||||
  return QStringList();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QgsGrassModuleItem::~QgsGrassModuleItem() {}
 | 
			
		||||
 | 
			
		||||
@ -2912,7 +2973,8 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
 | 
			
		||||
      QgsDebugMsg( "ogrLayer = " + ogrLayer );
 | 
			
		||||
 | 
			
		||||
      mLayerComboBox->addItem( layer->name() );
 | 
			
		||||
      if ( layer->name() == current ) mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current );
 | 
			
		||||
      if ( layer->name() == current )
 | 
			
		||||
        mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current );
 | 
			
		||||
 | 
			
		||||
      mUri.push_back( uri );
 | 
			
		||||
      mOgrLayers.push_back( ogrLayer );
 | 
			
		||||
@ -2922,7 +2984,8 @@ void QgsGrassModuleGdalInput::updateQgisLayers()
 | 
			
		||||
    {
 | 
			
		||||
      QString uri = layer->source();
 | 
			
		||||
      mLayerComboBox->addItem( layer->name() );
 | 
			
		||||
      if ( layer->name() == current ) mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current );
 | 
			
		||||
      if ( layer->name() == current )
 | 
			
		||||
        mLayerComboBox->setItemText( mLayerComboBox->currentIndex(), current );
 | 
			
		||||
      mUri.push_back( uri );
 | 
			
		||||
      mOgrLayers.push_back( "" );
 | 
			
		||||
      mOgrWheres.push_back( "" );
 | 
			
		||||
@ -3055,7 +3118,8 @@ void QgsGrassModuleField::updateFields()
 | 
			
		||||
 | 
			
		||||
  //QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas();
 | 
			
		||||
 | 
			
		||||
  if ( mLayerInput == 0 ) return;
 | 
			
		||||
  if ( mLayerInput == 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  std::vector<QgsField> fields = mLayerInput->currentFields();
 | 
			
		||||
 | 
			
		||||
@ -3132,10 +3196,12 @@ void QgsGrassModuleSelection::updateSelection()
 | 
			
		||||
 | 
			
		||||
  mLineEdit->setText( "" );
 | 
			
		||||
  //QgsMapCanvas *canvas = mModule->qgisIface()->mapCanvas();
 | 
			
		||||
  if ( mLayerInput == 0 ) return;
 | 
			
		||||
  if ( mLayerInput == 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QgsMapLayer *layer = mLayerInput->currentLayer();
 | 
			
		||||
  if ( !layer ) return;
 | 
			
		||||
  if ( !layer )
 | 
			
		||||
    return;
 | 
			
		||||
  QgsVectorLayer *vector = qobject_cast<QgsVectorLayer *>( layer );
 | 
			
		||||
 | 
			
		||||
  QgsGrassProvider *provider = ( QgsGrassProvider * ) vector->dataProvider();
 | 
			
		||||
@ -3143,7 +3209,8 @@ void QgsGrassModuleSelection::updateSelection()
 | 
			
		||||
  const QgsFeatureIds& selected = vector->selectedFeaturesIds();
 | 
			
		||||
  int keyField = provider->keyField();
 | 
			
		||||
 | 
			
		||||
  if ( keyField < 0 ) return;
 | 
			
		||||
  if ( keyField < 0 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QString cats;
 | 
			
		||||
  provider->select( allAttributes, QgsRectangle(), true );
 | 
			
		||||
@ -3158,7 +3225,8 @@ void QgsGrassModuleSelection::updateSelection()
 | 
			
		||||
    QgsAttributeMap attr = feature.attributeMap();
 | 
			
		||||
    if ( attr.size() > keyField )
 | 
			
		||||
    {
 | 
			
		||||
      if ( i > 0 ) cats.append( "," );
 | 
			
		||||
      if ( i > 0 )
 | 
			
		||||
        cats.append( "," );
 | 
			
		||||
      cats.append( attr[keyField].toString() );
 | 
			
		||||
      i++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -180,10 +180,10 @@ class QgsGrassModuleOptions
 | 
			
		||||
    virtual QStringList checkOutput() { return QStringList() ; }
 | 
			
		||||
 | 
			
		||||
    //! Freeze output vector maps used in QGIS on Windows
 | 
			
		||||
    virtual void freezeOutput() { return; }
 | 
			
		||||
    virtual void freezeOutput() {}
 | 
			
		||||
 | 
			
		||||
    //! Thaw output vector maps used in QGIS on Windows
 | 
			
		||||
    virtual void thawOutput() { return; }
 | 
			
		||||
    virtual void thawOutput() { }
 | 
			
		||||
 | 
			
		||||
    //! Check if option is ready
 | 
			
		||||
    //  Returns empty string or error message
 | 
			
		||||
 | 
			
		||||
@ -198,7 +198,8 @@ void QgsGrassNewMapset::databaseChanged()
 | 
			
		||||
  QDir d( mDatabaseLineEdit->text() );
 | 
			
		||||
  for ( unsigned int i = 0; i < d.count(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." ) continue;
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QString windName = mDatabaseLineEdit->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
 | 
			
		||||
    QString locationName = mDatabaseLineEdit->text() + "/" + d[i];
 | 
			
		||||
@ -246,7 +247,8 @@ void QgsGrassNewMapset::setLocations( )
 | 
			
		||||
  int sel = -1;
 | 
			
		||||
  for ( unsigned int i = 0; i < d.count(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." ) continue;
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QString windName = mDatabaseLineEdit->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
 | 
			
		||||
    QString locationName = mDatabaseLineEdit->text() + "/" + d[i];
 | 
			
		||||
@ -684,7 +686,8 @@ void QgsGrassNewMapset::checkRegion()
 | 
			
		||||
    err = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( err ) return;
 | 
			
		||||
  if ( err )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mCellHead.north = n;
 | 
			
		||||
  mCellHead.south = s;
 | 
			
		||||
@ -762,22 +765,30 @@ void QgsGrassNewMapset::loadRegions()
 | 
			
		||||
 | 
			
		||||
    QDomElement elem = node.toElement();
 | 
			
		||||
    QDomNodeList nameNodes = elem.elementsByTagName( "gml:name" );
 | 
			
		||||
    if ( nameNodes.count() == 0 ) continue;
 | 
			
		||||
    if ( nameNodes.item( 0 ).isNull() ) continue;
 | 
			
		||||
    if ( nameNodes.count() == 0 )
 | 
			
		||||
      continue;
 | 
			
		||||
    if ( nameNodes.item( 0 ).isNull() )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QDomElement nameElem = nameNodes.item( 0 ).toElement();
 | 
			
		||||
    if ( nameElem.text().isNull() ) continue;
 | 
			
		||||
    if ( nameElem.text().isNull() )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QDomNodeList envNodes = elem.elementsByTagName( "gml:Envelope" );
 | 
			
		||||
    if ( envNodes.count() == 0 ) continue;
 | 
			
		||||
    if ( envNodes.item( 0 ).isNull() ) continue;
 | 
			
		||||
    if ( envNodes.count() == 0 )
 | 
			
		||||
      continue;
 | 
			
		||||
    if ( envNodes.item( 0 ).isNull() )
 | 
			
		||||
      continue;
 | 
			
		||||
    QDomElement envElem = envNodes.item( 0 ).toElement();
 | 
			
		||||
 | 
			
		||||
    QDomNodeList coorNodes = envElem.elementsByTagName( "gml:coordinates" );
 | 
			
		||||
    if ( coorNodes.count() == 0 ) continue;
 | 
			
		||||
    if ( coorNodes.item( 0 ).isNull() ) continue;
 | 
			
		||||
    if ( coorNodes.count() == 0 )
 | 
			
		||||
      continue;
 | 
			
		||||
    if ( coorNodes.item( 0 ).isNull() )
 | 
			
		||||
      continue;
 | 
			
		||||
    QDomElement coorElem = coorNodes.item( 0 ).toElement();
 | 
			
		||||
    if ( coorElem.text().isNull() ) continue;
 | 
			
		||||
    if ( coorElem.text().isNull() )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QStringList coor = coorElem.text().split( " ", QString::SkipEmptyParts );
 | 
			
		||||
    if ( coor.size() != 2 )
 | 
			
		||||
@ -886,21 +897,29 @@ void QgsGrassNewMapset::setSelectedRegion()
 | 
			
		||||
    e = points[1].x();
 | 
			
		||||
    w = points[0].x();
 | 
			
		||||
 | 
			
		||||
    if ( n > 90 ) n = 90;
 | 
			
		||||
    if ( s < -90 ) s = -90;
 | 
			
		||||
    if ( n > 90 )
 | 
			
		||||
      n = 90;
 | 
			
		||||
    if ( s < -90 )
 | 
			
		||||
      s = -90;
 | 
			
		||||
#if 0
 | 
			
		||||
    if ( e > 180 ) e = 180;
 | 
			
		||||
    if ( w < -180 ) w = 180;
 | 
			
		||||
    if ( e > 180 )
 | 
			
		||||
      e = 180;
 | 
			
		||||
    if ( w < -180 )
 | 
			
		||||
      w = 180;
 | 
			
		||||
#endif
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    for ( int i = 0; i < 4; i++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( i == 0 || points[i].y() > n ) n = points[i].y();
 | 
			
		||||
      if ( i == 0 || points[i].y() < s ) s = points[i].y();
 | 
			
		||||
      if ( i == 0 || points[i].x() > e ) e = points[i].x();
 | 
			
		||||
      if ( i == 0 || points[i].x() < w ) w = points[i].x();
 | 
			
		||||
      if ( i == 0 || points[i].y() > n )
 | 
			
		||||
        n = points[i].y();
 | 
			
		||||
      if ( i == 0 || points[i].y() < s )
 | 
			
		||||
        s = points[i].y();
 | 
			
		||||
      if ( i == 0 || points[i].x() > e )
 | 
			
		||||
        e = points[i].x();
 | 
			
		||||
      if ( i == 0 || points[i].x() < w )
 | 
			
		||||
        w = points[i].x();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -987,7 +1006,8 @@ void QgsGrassNewMapset::drawRegion()
 | 
			
		||||
  QPixmap pm = mPixmap;
 | 
			
		||||
  mRegionMap->setPixmap( pm );
 | 
			
		||||
 | 
			
		||||
  if ( mCellHead.proj == PROJECTION_XY ) return;
 | 
			
		||||
  if ( mCellHead.proj == PROJECTION_XY )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QgsDebugMsg( QString( "pm.isNull() = %1" ).arg( pm.isNull() ) );
 | 
			
		||||
  QPainter p( &pm );
 | 
			
		||||
@ -1071,8 +1091,10 @@ void QgsGrassNewMapset::drawRegion()
 | 
			
		||||
      // use 89.9 - for draw it is not so important
 | 
			
		||||
      if ( mCellHead.proj == PROJECTION_LL )
 | 
			
		||||
      {
 | 
			
		||||
        if ( points[i].y() >= 89.9 )  points[i].setY( 89.9 );
 | 
			
		||||
        if ( points[i].y() <= -89.9 )  points[i].setY( -89.9 );
 | 
			
		||||
        if ( points[i].y() >= 89.9 )
 | 
			
		||||
          points[i].setY( 89.9 );
 | 
			
		||||
        if ( points[i].y() <= -89.9 )
 | 
			
		||||
          points[i].setY( -89.9 );
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      QgsDebugMsg( QString( "%1,%2" ).arg( points[i].x() ).arg( points[i].y() ) );
 | 
			
		||||
@ -1149,7 +1171,8 @@ void QgsGrassNewMapset::setMapsets()
 | 
			
		||||
  // Add all subdirs containing WIND
 | 
			
		||||
  for ( unsigned int i = 0; i < d.count(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." ) continue;
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QString mapsetPath = locationPath + "/" + d[i];
 | 
			
		||||
    QString windPath = mapsetPath + "/WIND";
 | 
			
		||||
 | 
			
		||||
@ -69,8 +69,10 @@ QgsGrassPlugin::QgsGrassPlugin( QgisInterface * theQgisInterFace ):
 | 
			
		||||
 | 
			
		||||
QgsGrassPlugin::~QgsGrassPlugin()
 | 
			
		||||
{
 | 
			
		||||
  if ( mTools ) mTools->closeTools();
 | 
			
		||||
  if ( mEdit ) mEdit->closeEdit();
 | 
			
		||||
  if ( mTools )
 | 
			
		||||
    mTools->closeTools();
 | 
			
		||||
  if ( mEdit )
 | 
			
		||||
    mEdit->closeEdit();
 | 
			
		||||
  QString err = QgsGrass::closeMapset();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -509,7 +511,8 @@ void QgsGrassPlugin::newVector()
 | 
			
		||||
  name = dialog.getItem( "vector", tr( "New vector name" ),
 | 
			
		||||
                         tr( "New vector name" ), "", "", &ok );
 | 
			
		||||
 | 
			
		||||
  if ( !ok ) return;
 | 
			
		||||
  if ( !ok )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Create new map
 | 
			
		||||
  QgsGrass::setMapset( QgsGrass::getDefaultGisdbase(),
 | 
			
		||||
@ -589,10 +592,12 @@ void QgsGrassPlugin::displayRegion()
 | 
			
		||||
// QgsDebugMsg("entered.");
 | 
			
		||||
 | 
			
		||||
  mRegionBand->reset();
 | 
			
		||||
  if ( !mRegionAction->isChecked() ) { return; }
 | 
			
		||||
  if ( !mRegionAction->isChecked() )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Display region of current mapset if in active mode
 | 
			
		||||
  if ( !QgsGrass::activeMode() ) return;
 | 
			
		||||
  if ( !QgsGrass::activeMode() )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QString gisdbase = QgsGrass::getDefaultGisdbase();
 | 
			
		||||
  QString location = QgsGrass::getDefaultLocation();
 | 
			
		||||
@ -693,7 +698,8 @@ void QgsGrassPlugin::openMapset()
 | 
			
		||||
 | 
			
		||||
  QgsGrassSelect *sel = new QgsGrassSelect( QgsGrassSelect::MAPSET );
 | 
			
		||||
 | 
			
		||||
  if ( !sel->exec() ) return;
 | 
			
		||||
  if ( !sel->exec() )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QString err = QgsGrass::openMapset( sel->gisdbase,
 | 
			
		||||
                                      sel->location, sel->mapset );
 | 
			
		||||
 | 
			
		||||
@ -71,7 +71,8 @@ void QgsGrassRegionEdit::canvasPressEvent( QMouseEvent * event )
 | 
			
		||||
//! mouse movement in map canvas
 | 
			
		||||
void QgsGrassRegionEdit::canvasMoveEvent( QMouseEvent * event )
 | 
			
		||||
{
 | 
			
		||||
  if ( !mDraw ) return;
 | 
			
		||||
  if ( !mDraw )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mEndPoint = toMapCoordinates( event->pos() );
 | 
			
		||||
  setRegion( mStartPoint, mEndPoint );
 | 
			
		||||
@ -80,7 +81,8 @@ void QgsGrassRegionEdit::canvasMoveEvent( QMouseEvent * event )
 | 
			
		||||
//! mouse button released
 | 
			
		||||
void QgsGrassRegionEdit::canvasReleaseEvent( QMouseEvent * event )
 | 
			
		||||
{
 | 
			
		||||
  if ( !mDraw ) return;
 | 
			
		||||
  if ( !mDraw )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mEndPoint = toMapCoordinates( event->pos() );
 | 
			
		||||
  setRegion( mStartPoint, mEndPoint );
 | 
			
		||||
@ -162,7 +164,8 @@ void QgsGrassRegionEdit::drawRegion( QgsMapCanvas *canvas, QgsRubberBand* rubber
 | 
			
		||||
  for ( int i = 0; i < points.size(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    bool update = false; // true to update canvas
 | 
			
		||||
    if ( i == points.size() - 1 ) update = true;
 | 
			
		||||
    if ( i == points.size() - 1 )
 | 
			
		||||
      update = true;
 | 
			
		||||
    rubberBand->addPoint( points[i], update );
 | 
			
		||||
  }
 | 
			
		||||
  rubberBand->show();
 | 
			
		||||
@ -327,7 +330,8 @@ QgsGrassRegion::~QgsGrassRegion()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::northChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.north = mNorth->text().toDouble();
 | 
			
		||||
  if ( mWindow.north < mWindow.south )
 | 
			
		||||
@ -339,7 +343,8 @@ void QgsGrassRegion::northChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::southChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.south = mSouth->text().toDouble();
 | 
			
		||||
  if ( mWindow.south > mWindow.north )
 | 
			
		||||
@ -351,7 +356,8 @@ void QgsGrassRegion::southChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::eastChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.east = mEast->text().toDouble();
 | 
			
		||||
  if ( mWindow.east < mWindow.west )
 | 
			
		||||
@ -363,7 +369,8 @@ void QgsGrassRegion::eastChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::westChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.west = mWest->text().toDouble();
 | 
			
		||||
  if ( mWindow.west > mWindow.east )
 | 
			
		||||
@ -375,7 +382,8 @@ void QgsGrassRegion::westChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::NSResChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.ns_res = mNSRes->text().toDouble();
 | 
			
		||||
  if ( mWindow.ns_res <= 0 )
 | 
			
		||||
@ -387,7 +395,8 @@ void QgsGrassRegion::NSResChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::EWResChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.ew_res = mEWRes->text().toDouble();
 | 
			
		||||
  if ( mWindow.ew_res <= 0 )
 | 
			
		||||
@ -399,7 +408,8 @@ void QgsGrassRegion::EWResChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::rowsChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.rows = mRows->text().toInt();
 | 
			
		||||
  if ( mWindow.rows < 1 )
 | 
			
		||||
@ -411,7 +421,8 @@ void QgsGrassRegion::rowsChanged()
 | 
			
		||||
 | 
			
		||||
void QgsGrassRegion::colsChanged()
 | 
			
		||||
{
 | 
			
		||||
  if ( mUpdatingGui ) return;
 | 
			
		||||
  if ( mUpdatingGui )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mWindow.cols = mCols->text().toInt();
 | 
			
		||||
  if ( mWindow.cols < 1 )
 | 
			
		||||
 | 
			
		||||
@ -122,18 +122,21 @@ void QgsGrassSelect::setLocations()
 | 
			
		||||
  // Add all subdirs containing PERMANENT/DEFAULT_WIND
 | 
			
		||||
  for ( unsigned int i = 0; i < d.count(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." ) continue;
 | 
			
		||||
    if ( d[i] == "." || d[i] == ".." )
 | 
			
		||||
      continue;
 | 
			
		||||
 | 
			
		||||
    QString ldpath = egisdbase->text() + "/" + d[i];
 | 
			
		||||
 | 
			
		||||
    if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
 | 
			
		||||
    {
 | 
			
		||||
      if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) continue;
 | 
			
		||||
      if ( !G_is_location( ldpath.toLocal8Bit().constData() ) )
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      QString chf = egisdbase->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
 | 
			
		||||
      if ( !QFile::exists( chf ) ) continue;
 | 
			
		||||
      if ( !QFile::exists( chf ) )
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // if type is MAPSET check also if at least one mapset owned by user exists
 | 
			
		||||
@ -145,10 +148,12 @@ void QgsGrassSelect::setLocations()
 | 
			
		||||
 | 
			
		||||
      for ( unsigned int j = 0; j < ld.count(); j++ )
 | 
			
		||||
      {
 | 
			
		||||
        if ( !QgsGrass::isMapset( ldpath + "/" + ld[j] ) ) continue;
 | 
			
		||||
        if ( !QgsGrass::isMapset( ldpath + "/" + ld[j] ) )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        QFileInfo info( ldpath + "/" + ld[j] );
 | 
			
		||||
        if ( !info.isWritable() ) continue;
 | 
			
		||||
        if ( !info.isWritable() )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        // TODO: check if owner == user: how to get uer name in QT
 | 
			
		||||
 | 
			
		||||
@ -156,7 +161,8 @@ void QgsGrassSelect::setLocations()
 | 
			
		||||
        break;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if ( !exists ) continue;
 | 
			
		||||
      if ( !exists )
 | 
			
		||||
        continue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    elocation->addItem( QString( d[i] ) );
 | 
			
		||||
@ -185,7 +191,8 @@ void QgsGrassSelect::setMapsets()
 | 
			
		||||
  emap->clear();
 | 
			
		||||
  elayer->clear();
 | 
			
		||||
 | 
			
		||||
  if ( elocation->count() < 1 ) return;
 | 
			
		||||
  if ( elocation->count() < 1 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Location directory
 | 
			
		||||
  QString ldpath = egisdbase->text() + "/" + elocation->currentText();
 | 
			
		||||
@ -227,7 +234,8 @@ void QgsGrassSelect::setMaps()
 | 
			
		||||
  emap->clear();
 | 
			
		||||
  elayer->clear();
 | 
			
		||||
 | 
			
		||||
  if ( emapset->count() < 1 ) return;
 | 
			
		||||
  if ( emapset->count() < 1 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  // Mapset directory
 | 
			
		||||
  QString ldpath = egisdbase->text() + "/" + elocation->currentText() + "/" + emapset->currentText();
 | 
			
		||||
@ -244,7 +252,8 @@ void QgsGrassSelect::setMaps()
 | 
			
		||||
    for ( int j = 0; j < list.count(); j++ )
 | 
			
		||||
    {
 | 
			
		||||
      emap->addItem( list[j] );
 | 
			
		||||
      if ( list[j] == lastVectorMap ) sel = idx;
 | 
			
		||||
      if ( list[j] == lastVectorMap )
 | 
			
		||||
        sel = idx;
 | 
			
		||||
      idx++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -258,7 +267,8 @@ void QgsGrassSelect::setMaps()
 | 
			
		||||
    for ( int j = 0; j < list.count(); j++ )
 | 
			
		||||
    {
 | 
			
		||||
      emap->addItem( list[j] );
 | 
			
		||||
      if ( list[j] == lastRasterMap ) sel = idx;
 | 
			
		||||
      if ( list[j] == lastRasterMap )
 | 
			
		||||
        sel = idx;
 | 
			
		||||
      idx++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -269,7 +279,8 @@ void QgsGrassSelect::setMaps()
 | 
			
		||||
 | 
			
		||||
    for ( unsigned int j = 0; j < md.count(); j++ )
 | 
			
		||||
    {
 | 
			
		||||
      if ( md[j] == "." || md[j] == ".." ) continue;
 | 
			
		||||
      if ( md[j] == "." || md[j] == ".." )
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      QString m = QString( md[j] + " (GROUP)" );
 | 
			
		||||
      emap->addItem( m );
 | 
			
		||||
@ -320,8 +331,10 @@ void QgsGrassSelect::setLayers()
 | 
			
		||||
 | 
			
		||||
  elayer->clear();
 | 
			
		||||
 | 
			
		||||
  if ( type != VECTOR ) return;
 | 
			
		||||
  if ( emap->count() < 1 ) return;
 | 
			
		||||
  if ( type != VECTOR )
 | 
			
		||||
    return;
 | 
			
		||||
  if ( emap->count() < 1 )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QStringList layers = QgsGrass::vectorLayers( egisdbase->text(),
 | 
			
		||||
                                     elocation->currentText(), emapset->currentText(),
 | 
			
		||||
@ -332,7 +345,8 @@ void QgsGrassSelect::setLayers()
 | 
			
		||||
  for ( int i = 0; i < layers.count(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    elayer->addItem( layers[i] );
 | 
			
		||||
    if ( layers[i] == lastLayer ) sel = idx;
 | 
			
		||||
    if ( layers[i] == lastLayer )
 | 
			
		||||
      sel = idx;
 | 
			
		||||
    idx++;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -120,7 +120,8 @@ QgsGrassTools::QgsGrassTools( QgisInterface *iface,
 | 
			
		||||
void QgsGrassTools::moduleClicked( QTreeWidgetItem * item, int column )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
  if ( !item ) return;
 | 
			
		||||
  if ( !item )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  QString name = item->text( 1 );
 | 
			
		||||
  QgsDebugMsg( QString( "name = %1" ).arg( name ) );
 | 
			
		||||
@ -129,7 +130,8 @@ void QgsGrassTools::moduleClicked( QTreeWidgetItem * item, int column )
 | 
			
		||||
 | 
			
		||||
void QgsGrassTools::runModule( QString name )
 | 
			
		||||
{
 | 
			
		||||
  if ( name.length() == 0 ) return;  // Section
 | 
			
		||||
  if ( name.length() == 0 )
 | 
			
		||||
    return;  // Section
 | 
			
		||||
 | 
			
		||||
#ifndef WIN32
 | 
			
		||||
  QgsGrassShell* sh = 0;
 | 
			
		||||
@ -184,12 +186,15 @@ void QgsGrassTools::runModule( QString name )
 | 
			
		||||
  // We must call resize to reset COLUMNS environment variable
 | 
			
		||||
  // used by bash !!!
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
  /* TODO: Implement something that resizes the terminal without
 | 
			
		||||
   *       crashes.
 | 
			
		||||
  #ifndef WIN32
 | 
			
		||||
    if ( sh ) sh->resizeTerminal();
 | 
			
		||||
  #endif
 | 
			
		||||
  */
 | 
			
		||||
   */
 | 
			
		||||
#ifndef WIN32
 | 
			
		||||
  if ( sh )
 | 
			
		||||
    sh->resizeTerminal();
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool QgsGrassTools::loadConfig( QString filePath )
 | 
			
		||||
 | 
			
		||||
@ -29,21 +29,19 @@ QString QgsGrassUtils::vectorLayerName( QString map, QString layer,
 | 
			
		||||
                                        int nLayers )
 | 
			
		||||
{
 | 
			
		||||
  QString name = map;
 | 
			
		||||
  if ( nLayers > 1 ) name += " " + layer;
 | 
			
		||||
  if ( nLayers > 1 )
 | 
			
		||||
    name += " " + layer;
 | 
			
		||||
  return name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgsGrassUtils::addVectorLayers( QgisInterface *iface,
 | 
			
		||||
                                     QString gisbase, QString location, QString mapset, QString map )
 | 
			
		||||
{
 | 
			
		||||
  QStringList layers = QgsGrass::vectorLayers(
 | 
			
		||||
                         gisbase, location, mapset, map );
 | 
			
		||||
 | 
			
		||||
  QStringList layers = QgsGrass::vectorLayers( gisbase, location, mapset, map );
 | 
			
		||||
 | 
			
		||||
  for ( int i = 0; i < layers.count(); i++ )
 | 
			
		||||
  {
 | 
			
		||||
    QString name = QgsGrassUtils::vectorLayerName(
 | 
			
		||||
                     map, layers[i], layers.size() );
 | 
			
		||||
    QString name = QgsGrassUtils::vectorLayerName( map, layers[i], layers.size() );
 | 
			
		||||
 | 
			
		||||
    QString uri = gisbase + "/" + location + "/"
 | 
			
		||||
                  + mapset + "/" + map + "/" + layers[i];
 | 
			
		||||
@ -78,7 +76,8 @@ QString QgsGrassElementDialog::getItem( QString element,
 | 
			
		||||
                                        QString text, QString source, bool * ok )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "entered." );
 | 
			
		||||
  if ( ok ) *ok = false;
 | 
			
		||||
  if ( ok )
 | 
			
		||||
    *ok = false;
 | 
			
		||||
  mElement = element;
 | 
			
		||||
  mSource = source;
 | 
			
		||||
  mDialog = new QDialog();
 | 
			
		||||
 | 
			
		||||
@ -164,9 +164,15 @@ void QgsScaleBarPlugin::run()
 | 
			
		||||
  int myUnits = qGisInterface->mapCanvas()->mapUnits();
 | 
			
		||||
  switch ( myUnits )
 | 
			
		||||
  {
 | 
			
		||||
    case 0: myPluginGui->getSpinSize()->setSuffix( tr( " metres/km" ) ); break;
 | 
			
		||||
    case 1: myPluginGui->getSpinSize()->setSuffix( tr( " feet/miles" ) ); break;
 | 
			
		||||
    case 2: myPluginGui->getSpinSize()->setSuffix( tr( " degrees" ) ); break;
 | 
			
		||||
    case 0:
 | 
			
		||||
      myPluginGui->getSpinSize()->setSuffix( tr( " metres/km" ) );
 | 
			
		||||
      break;
 | 
			
		||||
    case 1:
 | 
			
		||||
      myPluginGui->getSpinSize()->setSuffix( tr( " feet/miles" ) );
 | 
			
		||||
      break;
 | 
			
		||||
    case 2:
 | 
			
		||||
      myPluginGui->getSpinSize()->setSuffix( tr( " degrees" ) );
 | 
			
		||||
      break;
 | 
			
		||||
    default:
 | 
			
		||||
      QgsDebugMsg( QString( "Error: not picked up map units - actual value = %1" ).arg( myUnits ) );
 | 
			
		||||
  };
 | 
			
		||||
@ -196,7 +202,8 @@ void QgsScaleBarPlugin::renderScaleBar( QPainter * theQPainter )
 | 
			
		||||
 | 
			
		||||
  // Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze
 | 
			
		||||
  int myLayerCount = qGisInterface->mapCanvas()->layerCount();
 | 
			
		||||
  if ( !myLayerCount || !myCanvasWidth || !myMapUnitsPerPixelDouble ) return;
 | 
			
		||||
  if ( !myLayerCount || !myCanvasWidth || !myMapUnitsPerPixelDouble )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  //Large if statement which determines whether to render the scale bar
 | 
			
		||||
  if ( mEnabled )
 | 
			
		||||
 | 
			
		||||
@ -304,7 +304,10 @@ QIcon SaDbTableModel::iconForType( QGis::WkbType type ) const
 | 
			
		||||
  {
 | 
			
		||||
    return SqlAnywhere::getThemeIcon( "/mIconPolygonLayer.png" );
 | 
			
		||||
  }
 | 
			
		||||
  else return QIcon();
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    return QIcon();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QGis::WkbType SaDbTableModel::qgisTypeFromDbType( const QString& dbType ) const
 | 
			
		||||
 | 
			
		||||
@ -404,7 +404,8 @@ void SaSourceSelect::on_btnConnect_clicked()
 | 
			
		||||
      SaDebugMsg( "Unable to get list of spatially enabled tables "
 | 
			
		||||
                  "from the database" );
 | 
			
		||||
    }
 | 
			
		||||
    if ( cmbConnections->count() > 0 ) mAddButton->setEnabled( true );
 | 
			
		||||
    if ( cmbConnections->count() > 0 )
 | 
			
		||||
      mAddButton->setEnabled( true );
 | 
			
		||||
 | 
			
		||||
    conn->release();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -155,13 +155,20 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
 | 
			
		||||
  QString xField;
 | 
			
		||||
  QString yField;
 | 
			
		||||
 | 
			
		||||
  if ( url.hasQueryItem( "delimiter" ) ) mDelimiter = url.queryItemValue( "delimiter" );
 | 
			
		||||
  if ( url.hasQueryItem( "delimiterType" ) ) mDelimiterType = url.queryItemValue( "delimiterType" );
 | 
			
		||||
  if ( url.hasQueryItem( "wktField" ) ) wktField = url.queryItemValue( "wktField" );
 | 
			
		||||
  if ( url.hasQueryItem( "xField" ) ) xField = url.queryItemValue( "xField" );
 | 
			
		||||
  if ( url.hasQueryItem( "yField" ) ) yField = url.queryItemValue( "yField" );
 | 
			
		||||
  if ( url.hasQueryItem( "skipLines" ) ) mSkipLines = url.queryItemValue( "skipLines" ).toInt();
 | 
			
		||||
  if ( url.hasQueryItem( "crs" ) ) mCrs.createFromString( url.queryItemValue( "crs" ) );
 | 
			
		||||
  if ( url.hasQueryItem( "delimiter" ) )
 | 
			
		||||
    mDelimiter = url.queryItemValue( "delimiter" );
 | 
			
		||||
  if ( url.hasQueryItem( "delimiterType" ) )
 | 
			
		||||
    mDelimiterType = url.queryItemValue( "delimiterType" );
 | 
			
		||||
  if ( url.hasQueryItem( "wktField" ) )
 | 
			
		||||
    wktField = url.queryItemValue( "wktField" );
 | 
			
		||||
  if ( url.hasQueryItem( "xField" ) )
 | 
			
		||||
    xField = url.queryItemValue( "xField" );
 | 
			
		||||
  if ( url.hasQueryItem( "yField" ) )
 | 
			
		||||
    yField = url.queryItemValue( "yField" );
 | 
			
		||||
  if ( url.hasQueryItem( "skipLines" ) )
 | 
			
		||||
    mSkipLines = url.queryItemValue( "skipLines" ).toInt();
 | 
			
		||||
  if ( url.hasQueryItem( "crs" ) )
 | 
			
		||||
    mCrs.createFromString( url.queryItemValue( "crs" ) );
 | 
			
		||||
 | 
			
		||||
  QgsDebugMsg( "Data source uri is " + uri );
 | 
			
		||||
  QgsDebugMsg( "Delimited text file is: " + mFileName );
 | 
			
		||||
 | 
			
		||||
@ -105,7 +105,8 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
 | 
			
		||||
  registerGdalDrivers();
 | 
			
		||||
 | 
			
		||||
  // To get buildSupportedRasterFileFilter the provider is called with empty uri
 | 
			
		||||
  if ( uri.isEmpty() ) return;
 | 
			
		||||
  if ( uri.isEmpty() )
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  mGdalDataset = NULL;
 | 
			
		||||
 | 
			
		||||
@ -390,7 +391,8 @@ QgsGdalProvider::~QgsGdalProvider()
 | 
			
		||||
// This was used by raster layer to reload data
 | 
			
		||||
void QgsGdalProvider::closeDataset()
 | 
			
		||||
{
 | 
			
		||||
  if ( !mValid ) return;
 | 
			
		||||
  if ( !mValid )
 | 
			
		||||
    return;
 | 
			
		||||
  mValid = false;
 | 
			
		||||
 | 
			
		||||
  GDALDereferenceDataset( mGdalBaseDataset );
 | 
			
		||||
@ -918,7 +920,8 @@ double  QgsGdalProvider::noDataValue() const
 | 
			
		||||
void QgsGdalProvider::computeMinMax( int theBandNo )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( QString( "theBandNo = %1 mMinMaxComputed = %2" ).arg( theBandNo ).arg( mMinMaxComputed[theBandNo-1] ) );
 | 
			
		||||
  if ( mMinMaxComputed[theBandNo-1] ) return;
 | 
			
		||||
  if ( mMinMaxComputed[theBandNo-1] )
 | 
			
		||||
    return;
 | 
			
		||||
  double GDALrange[2];
 | 
			
		||||
  GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
 | 
			
		||||
  GDALComputeRasterMinMax( myGdalBand, 1, GDALrange ); //Approximate
 | 
			
		||||
@ -1723,7 +1726,7 @@ void buildSupportedRasterFileFilterAndExtensions( QString & theFileFiltersString
 | 
			
		||||
      {
 | 
			
		||||
        // XXX add check for SDTS; in that case we want (*CATD.DDF)
 | 
			
		||||
        QString glob = "*." + myGdalDriverExtension.replace( "/", " *." );
 | 
			
		||||
        theExtensions << myGdalDriverExtension.replace( "/", "" ).replace("*", "").replace(".","");
 | 
			
		||||
        theExtensions << myGdalDriverExtension.replace( "/", "" ).replace( "*", "" ).replace( ".", "" );
 | 
			
		||||
        // Add only the first JP2 driver found to the filter list (it's the one GDAL uses)
 | 
			
		||||
        if ( myGdalDriverDescription == "JPEG2000" ||
 | 
			
		||||
             myGdalDriverDescription.startsWith( "JP2" ) ) // JP2ECW, JP2KAK, JP2MrSID
 | 
			
		||||
@ -1869,18 +1872,19 @@ QGISEXTERN void buildSupportedRasterFileFilter( QString & theFileFiltersString )
 | 
			
		||||
  buildSupportedRasterFileFilterAndExtensions( theFileFiltersString, exts, wildcards );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QGISEXTERN int dataCapabilities () {
 | 
			
		||||
QGISEXTERN int dataCapabilities()
 | 
			
		||||
{
 | 
			
		||||
  return  QgsDataProvider::File | QgsDataProvider::Dir;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QgsGdalLayerItem::QgsGdalLayerItem ( QgsDataItem* parent,
 | 
			
		||||
    QString name, QString path, QString uri )
 | 
			
		||||
  : QgsLayerItem ( parent, name, path, uri, QgsLayerItem::Raster, "gdal" )
 | 
			
		||||
QgsGdalLayerItem::QgsGdalLayerItem( QgsDataItem* parent,
 | 
			
		||||
                                    QString name, QString path, QString uri )
 | 
			
		||||
    : QgsLayerItem( parent, name, path, uri, QgsLayerItem::Raster, "gdal" )
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QgsGdalLayerItem::~QgsGdalLayerItem ()
 | 
			
		||||
QgsGdalLayerItem::~QgsGdalLayerItem()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1891,37 +1895,40 @@ QgsLayerItem::Capability QgsGdalLayerItem::capabilities()
 | 
			
		||||
  GDALAllRegister();
 | 
			
		||||
  GDALDatasetH hDS = GDALOpen( TO8F( mPath ), GA_Update );
 | 
			
		||||
 | 
			
		||||
  if ( hDS == NULL ) return NoCapabilities;
 | 
			
		||||
  if ( !hDS )
 | 
			
		||||
    return NoCapabilities;
 | 
			
		||||
 | 
			
		||||
  return SetCrs;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool QgsGdalLayerItem::setCrs ( QgsCoordinateReferenceSystem crs )
 | 
			
		||||
bool QgsGdalLayerItem::setCrs( QgsCoordinateReferenceSystem crs )
 | 
			
		||||
{
 | 
			
		||||
  QgsDebugMsg( "mPath = " + mPath );
 | 
			
		||||
  GDALAllRegister();
 | 
			
		||||
  GDALDatasetH hDS = GDALOpen( TO8F( mPath ), GA_Update );
 | 
			
		||||
 | 
			
		||||
  if ( hDS == NULL ) return false;
 | 
			
		||||
  if ( !hDS )
 | 
			
		||||
    return false;
 | 
			
		||||
 | 
			
		||||
  QString wkt = crs.toWkt();
 | 
			
		||||
  if ( GDALSetProjection ( hDS, wkt.toLocal8Bit().data() ) != CE_None )
 | 
			
		||||
  if ( GDALSetProjection( hDS, wkt.toLocal8Bit().data() ) != CE_None )
 | 
			
		||||
  {
 | 
			
		||||
    QgsDebugMsg( "Could not set CRS" );
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
  GDALClose ( hDS );
 | 
			
		||||
  GDALClose( hDS );
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static QStringList extensions = QStringList();
 | 
			
		||||
static QStringList wildcards = QStringList();
 | 
			
		||||
 | 
			
		||||
QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem )
 | 
			
		||||
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
 | 
			
		||||
{
 | 
			
		||||
  if ( thePath.isEmpty() ) return 0;
 | 
			
		||||
  if ( thePath.isEmpty() )
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  QFileInfo info ( thePath );
 | 
			
		||||
  QFileInfo info( thePath );
 | 
			
		||||
  if ( info.isFile() )
 | 
			
		||||
  {
 | 
			
		||||
    // Filter files by extension
 | 
			
		||||
@ -1929,29 +1936,30 @@ QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem )
 | 
			
		||||
    {
 | 
			
		||||
      QString filterString;
 | 
			
		||||
      buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards );
 | 
			
		||||
      QgsDebugMsg( "extensions: " + extensions.join(" ") );
 | 
			
		||||
      QgsDebugMsg( "wildcards: " + wildcards.join(" ") );
 | 
			
		||||
      QgsDebugMsg( "extensions: " + extensions.join( " " ) );
 | 
			
		||||
      QgsDebugMsg( "wildcards: " + wildcards.join( " " ) );
 | 
			
		||||
    }
 | 
			
		||||
    if (  extensions.indexOf ( info.suffix().toLower() ) < 0 )
 | 
			
		||||
    if ( extensions.indexOf( info.suffix().toLower() ) < 0 )
 | 
			
		||||
    {
 | 
			
		||||
      bool matches = false;
 | 
			
		||||
      foreach (QString wildcard, wildcards)
 | 
			
		||||
      foreach( QString wildcard, wildcards )
 | 
			
		||||
      {
 | 
			
		||||
        QRegExp rx(wildcard, Qt::CaseInsensitive, QRegExp::Wildcard);
 | 
			
		||||
        if (rx.exactMatch(info.fileName()))
 | 
			
		||||
        QRegExp rx( wildcard, Qt::CaseInsensitive, QRegExp::Wildcard );
 | 
			
		||||
        if ( rx.exactMatch( info.fileName() ) )
 | 
			
		||||
        {
 | 
			
		||||
          matches = true;
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      if (!matches)
 | 
			
		||||
      if ( !matches )
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    GDALAllRegister();
 | 
			
		||||
    GDALDatasetH hDS = GDALOpen( TO8F( thePath ), GA_ReadOnly );
 | 
			
		||||
 | 
			
		||||
    if ( hDS == NULL ) return 0;
 | 
			
		||||
    if ( !hDS )
 | 
			
		||||
      return 0;
 | 
			
		||||
 | 
			
		||||
    QgsDebugMsg( "GdalDataset opened " + thePath );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -289,11 +289,11 @@ class QgsGdalProvider : public QgsRasterDataProvider
 | 
			
		||||
class QgsGdalLayerItem : public QgsLayerItem
 | 
			
		||||
{
 | 
			
		||||
  public:
 | 
			
		||||
    QgsGdalLayerItem ( QgsDataItem* parent,
 | 
			
		||||
    QgsGdalLayerItem( QgsDataItem* parent,
 | 
			
		||||
                      QString name, QString path, QString uri );
 | 
			
		||||
    ~QgsGdalLayerItem ();
 | 
			
		||||
    ~QgsGdalLayerItem();
 | 
			
		||||
 | 
			
		||||
    bool setCrs ( QgsCoordinateReferenceSystem crs );
 | 
			
		||||
    bool setCrs( QgsCoordinateReferenceSystem crs );
 | 
			
		||||
    Capability capabilities();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -161,8 +161,10 @@ int main( int argc, char **argv )
 | 
			
		||||
        {
 | 
			
		||||
          col = ( int ) G_easting_to_col( x, &window );
 | 
			
		||||
          row = ( int ) G_northing_to_row( y, &window );
 | 
			
		||||
          if ( col == window.cols ) col--;
 | 
			
		||||
          if ( row == window.rows ) row--;
 | 
			
		||||
          if ( col == window.cols )
 | 
			
		||||
            col--;
 | 
			
		||||
          if ( row == window.rows )
 | 
			
		||||
            row--;
 | 
			
		||||
 | 
			
		||||
          if ( col < 0 || col > window.cols || row < 0 || row > window.rows )
 | 
			
		||||
          {
 | 
			
		||||
 | 
			
		||||
@ -299,13 +299,15 @@ bool QgsGrass::isValidGrassBaseDir( QString const gisBase )
 | 
			
		||||
#if 0
 | 
			
		||||
  if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
 | 
			
		||||
  {
 | 
			
		||||
    if ( G_is_gisbase( gisBase.toUtf8().constData() ) ) return true;
 | 
			
		||||
    if ( G_is_gisbase( gisBase.toUtf8().constData() ) )
 | 
			
		||||
      return true;
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
#endif
 | 
			
		||||
    QFileInfo gbi( gisBase + "/etc/element_list" );
 | 
			
		||||
    if ( gbi.exists() ) return true;
 | 
			
		||||
    if ( gbi.exists() )
 | 
			
		||||
      return true;
 | 
			
		||||
#if 0
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
@ -443,7 +445,8 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q
 | 
			
		||||
 | 
			
		||||
  // Check if the mapset is in use
 | 
			
		||||
  QString gisBase = getenv( "GISBASE" );
 | 
			
		||||
  if ( gisBase.isEmpty() ) return QObject::tr( "GISBASE is not set." );
 | 
			
		||||
  if ( gisBase.isEmpty() )
 | 
			
		||||
    return QObject::tr( "GISBASE is not set." );
 | 
			
		||||
 | 
			
		||||
  QFileInfo fi( mapsetPath + "/WIND" );
 | 
			
		||||
  if ( !fi.exists() )
 | 
			
		||||
@ -546,7 +549,8 @@ QString GRASS_EXPORT QgsGrass::openMapset( QString gisdbase, QString location, Q
 | 
			
		||||
      {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
      if ( line.contains( "GRASS_GUI:" ) ) guiSet = true;
 | 
			
		||||
      if ( line.contains( "GRASS_GUI:" ) )
 | 
			
		||||
        guiSet = true;
 | 
			
		||||
      stream << line;
 | 
			
		||||
    }
 | 
			
		||||
    in.close();
 | 
			
		||||
@ -635,7 +639,8 @@ QString QgsGrass::closeMapset( )
 | 
			
		||||
      QDir dir( mTmp );
 | 
			
		||||
      for ( unsigned int i = 0; i < dir.count(); i++ )
 | 
			
		||||
      {
 | 
			
		||||
        if ( dir[i] == "." || dir[i] == ".." ) continue;
 | 
			
		||||
        if ( dir[i] == "." || dir[i] == ".." )
 | 
			
		||||
          continue;
 | 
			
		||||
 | 
			
		||||
        dir.remove( dir[i] );
 | 
			
		||||
        if ( dir.remove( dir[i] ) )
 | 
			
		||||
@ -660,7 +665,8 @@ QStringList GRASS_EXPORT QgsGrass::locations( QString gisbase )
 | 
			
		||||
 | 
			
		||||
  QStringList list;
 | 
			
		||||
 | 
			
		||||
  if ( gisbase.isEmpty() ) return list;
 | 
			
		||||
  if ( gisbase.isEmpty() )
 | 
			
		||||
    return list;
 | 
			
		||||
 | 
			
		||||
  QDir d = QDir( gisbase );
 | 
			
		||||
  d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs );
 | 
			
		||||
@ -692,7 +698,8 @@ QStringList GRASS_EXPORT QgsGrass::mapsets( QString locationPath )
 | 
			
		||||
 | 
			
		||||
  QStringList list;
 | 
			
		||||
 | 
			
		||||
  if ( locationPath.isEmpty() ) return list;
 | 
			
		||||
  if ( locationPath.isEmpty() )
 | 
			
		||||
    return list;
 | 
			
		||||
 | 
			
		||||
  QDir d = QDir( locationPath );
 | 
			
		||||
  d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs );
 | 
			
		||||
@ -750,7 +757,8 @@ QStringList GRASS_EXPORT QgsGrass::vectors( QString mapsetPath )
 | 
			
		||||
 | 
			
		||||
  QStringList list;
 | 
			
		||||
 | 
			
		||||
  if ( mapsetPath.isEmpty() ) return list;
 | 
			
		||||
  if ( mapsetPath.isEmpty() )
 | 
			
		||||
    return list;
 | 
			
		||||
 | 
			
		||||
  QDir d = QDir( mapsetPath + "/vector" );
 | 
			
		||||
  d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs );
 | 
			
		||||
@ -905,7 +913,8 @@ QStringList GRASS_EXPORT QgsGrass::rasters( QString mapsetPath )
 | 
			
		||||
 | 
			
		||||
  QStringList list;
 | 
			
		||||
 | 
			
		||||
  if ( mapsetPath.isEmpty() ) return list;
 | 
			
		||||
  if ( mapsetPath.isEmpty() )
 | 
			
		||||
    return list;
 | 
			
		||||
 | 
			
		||||
  QDir d = QDir( mapsetPath + "/cellhd" );
 | 
			
		||||
  d.setFilter( QDir::Files );
 | 
			
		||||
@ -933,7 +942,8 @@ QStringList GRASS_EXPORT QgsGrass::elements( QString mapsetPath, QString element
 | 
			
		||||
 | 
			
		||||
  QStringList list;
 | 
			
		||||
 | 
			
		||||
  if ( mapsetPath.isEmpty() ) return list;
 | 
			
		||||
  if ( mapsetPath.isEmpty() )
 | 
			
		||||
    return list;
 | 
			
		||||
 | 
			
		||||
  QDir d = QDir( mapsetPath + "/" + element );
 | 
			
		||||
  d.setFilter( QDir::Files );
 | 
			
		||||
@ -1356,7 +1366,8 @@ QHash<QString, QString> GRASS_EXPORT QgsGrass::info( QString gisdbase, QString l
 | 
			
		||||
    for ( int i = 0; i < list.size(); i++ )
 | 
			
		||||
    {
 | 
			
		||||
      QStringList keyVal = list[i].split( ':' );
 | 
			
		||||
      if ( list[i].isEmpty() ) { continue; }
 | 
			
		||||
      if ( list[i].isEmpty() )
 | 
			
		||||
        continue;
 | 
			
		||||
      if ( keyVal.size() != 2 )
 | 
			
		||||
      {
 | 
			
		||||
        throw QgsGrass::Exception( "Cannot parse GRASS map info key value : " + list[i] + " (" + str + " ) " );
 | 
			
		||||
@ -1385,7 +1396,8 @@ QList<QgsGrass::Color> GRASS_EXPORT QgsGrass::colors( QString gisdbase, QString
 | 
			
		||||
    for ( int i = 0; i < list.size(); i++ )
 | 
			
		||||
    {
 | 
			
		||||
      QgsGrass::Color c;
 | 
			
		||||
      if ( list[i].isEmpty() ) { continue; }
 | 
			
		||||
      if ( list[i].isEmpty() )
 | 
			
		||||
        continue;
 | 
			
		||||
      if ( sscanf( list[i].toUtf8().data(), "%lf %lf %d %d %d %d %d %d", &( c.value1 ), &( c.value2 ), &( c.red1 ), &( c.green1 ), &( c.blue1 ), &( c.red2 ), &( c.green2 ), &( c.blue2 ) ) != 8 )
 | 
			
		||||
      {
 | 
			
		||||
        throw QgsGrass::Exception( "Cannot parse GRASS colors" + list[i] + " (" + str + " ) " );
 | 
			
		||||
@ -1462,19 +1474,24 @@ QString GRASS_EXPORT QgsGrass::versionString()
 | 
			
		||||
 | 
			
		||||
bool GRASS_EXPORT QgsGrass::isMapset( QString path )
 | 
			
		||||
{
 | 
			
		||||
#if 0
 | 
			
		||||
  /* TODO: G_is_mapset() was added to GRASS 6.1 06-05-24,
 | 
			
		||||
  enable its use after some period (others do update) */
 | 
			
		||||
  /*
 | 
			
		||||
 | 
			
		||||
  if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
 | 
			
		||||
  {
 | 
			
		||||
  if ( G_is_mapset( path.toUtf8().constData() ) ) return true;
 | 
			
		||||
    if ( G_is_mapset( path.toUtf8().constData() ) )
 | 
			
		||||
      return true;
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
  */
 | 
			
		||||
  QString windf = path + "/WIND";
 | 
			
		||||
  if ( QFile::exists( windf ) ) return true;
 | 
			
		||||
  //}
 | 
			
		||||
#endif
 | 
			
		||||
    QString windf = path + "/WIND";
 | 
			
		||||
    if ( QFile::exists( windf ) )
 | 
			
		||||
      return true;
 | 
			
		||||
#if 0
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user