Skip to content

Commit

Permalink
Resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Nov 24, 2011
2 parents dde7032 + 898604d commit 545e9a4
Show file tree
Hide file tree
Showing 20 changed files with 427 additions and 223 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -203,6 +203,7 @@
<file>themes/default/propertyicons/rendering.png</file>
<file>themes/default/propertyicons/symbology.png</file>
<file>themes/default/propertyicons/transparency.png</file>
<file>themes/default/propertyicons/gdal.png</file>
<file>themes/default/qgis.xpm</file>
<file>themes/default/rendererCategorizedSymbol.png</file>
<file>themes/default/rendererGraduatedSymbol.png</file>
Expand Down
Binary file added images/themes/default/propertyicons/gdal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/CMakeLists.txt
Expand Up @@ -5,3 +5,4 @@ ADD_SUBDIRECTORY(context_help)
ADD_SUBDIRECTORY(js)
ADD_SUBDIRECTORY(html)
ADD_SUBDIRECTORY(css)
ADD_SUBDIRECTORY(function_help)
4 changes: 4 additions & 0 deletions resources/function_help/CMakeLists.txt
@@ -0,0 +1,4 @@
FILE(GLOB HELP_FILES *-*)

INSTALL(FILES ${HELP_FILES} DESTINATION ${QGIS_DATA_DIR}/resources/function_help)

13 changes: 13 additions & 0 deletions resources/function_help/length-en_US
@@ -0,0 +1,13 @@
<h3>length() function</h3>
Returns the length of a string.

<p><h4>Syntax</h4>
length(<i>string</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> -> is string. The String to count the length of.</p>

<p><h4>Example</h4>
<!-- Show example of function.-->
length('HELLO') -> 5</p>
11 changes: 11 additions & 0 deletions resources/function_help/lower-en_US
@@ -0,0 +1,11 @@
<h3>lower() function</h3>
Converts a string to lower case letters.

<p><h4> Syntax</h4>
lower(<i>string</i>)</p>

<p><h4> Arguments</h4>
<i> string</i> -> is string. The String to convert to lower case.</p>

<p><h4> Example</h4>
lower('HELLO World') -> 'hello world'</p>
15 changes: 15 additions & 0 deletions resources/function_help/replace-en_US
@@ -0,0 +1,15 @@
<h3>replace() function</h3>
Returns a string with the the supplied string replaced.

<p><h4>Syntax</h4>
replace(<i>string,before,after</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> -> is string. The start string.<br>
<i> before</i> -> is string. The string to replace.<br>
<i> after</i> -> is string. The string that will repalce <i>before</i><br></p>

<p><h4>Example</h4>
<!-- Show example of function.-->
replace('QGIS SHOULD ROCK','SHOULD','DOES') -> 'QGIS DOES ROCK'</p>
15 changes: 15 additions & 0 deletions resources/function_help/substr-en_US
@@ -0,0 +1,15 @@
<h3>substr() function</h3>
Return a part of a string

<p><h4>Syntax</h4>
substr(<i>string,startpos,length</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> -> is string. The full string.<br>
<i> startpos</i> -> is number. The start position to extract from.<br>
<i> length</i> -> is number. The length of the string to extract.<br></p>

<p><h4>Example</h4>
<!-- Show example of function.-->
substr('HELLO WORLD',3,5) -> 'LLO W'</p>
13 changes: 13 additions & 0 deletions resources/function_help/template
@@ -0,0 +1,13 @@
<h3>{function} function</h3>
Converts a string to lower case letters.

<p><h4>Syntax</h4>
lower(<i>args</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> -> is string. The String to convert to lower case.</p>

<p><h4>Example</h4>
<!-- Show example of function.-->
lower('HELLO World') -> 'hello world'</p>
13 changes: 13 additions & 0 deletions resources/function_help/upper-en_US
@@ -0,0 +1,13 @@
<h3>upper() function</h3>
Converts a string to upper case letters.

<p><h4>Syntax</h4>
upper(<i>string</i>)</p>

<p><h4>Arguments</h4>
<!-- List args for functions here-->
<i> string</i> -> is string. The String to convert to upper case.</p>

<p><h4>Example</h4>
<!-- Show example of function.-->
upper('hello WOrld') -> 'HELLO WORLD'</p>
5 changes: 4 additions & 1 deletion src/app/qgsoptions.cpp 100644 → 100755
Expand Up @@ -67,7 +67,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cmbSize->addItem( "32" );

QStringList styles = QStyleFactory::keys();
foreach(QString style, styles )
foreach( QString style, styles )
{
cmbStyle->addItem( style );
}
Expand Down Expand Up @@ -182,6 +182,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cmbAttrTableBehaviour->addItem( tr( "Show features in current canvas" ) );
cmbAttrTableBehaviour->setCurrentIndex( settings.value( "/qgis/attributeTableBehaviour", 0 ).toInt() );

spinBoxAttrTableRowCache->setValue( settings.value( "/qgis/attributeTableRowCache", 10000 ).toInt() );

// set the display update threshold
spinBoxUpdateThreshold->setValue( settings.value( "/Map/updateThreshold" ).toInt() );
//set the default projection behaviour radio buttongs
Expand Down Expand Up @@ -584,6 +586,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/showTips", cbxShowTips->isChecked() );
settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
settings.setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->currentIndex() );
settings.setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
Expand Down
14 changes: 4 additions & 10 deletions src/core/qgsexpression.cpp
Expand Up @@ -392,16 +392,10 @@ FnDef QgsExpression::BuiltinFunctions[] =
FnDef( "toreal", 1, fcnToReal, "Conversions" ),
FnDef( "tostring", 1, fcnToString, "Conversions" ),
// string manipulation
FnDef( "lower", 1, fcnLower, "String", "<b>Convert to lower case</b> "
"<br> Converts a string to lower case letters. "
"<br> <i>Usage:</i><br>lower('HELLO WORLD') will return 'hello world'" ),
FnDef( "upper", 1, fcnUpper, "String" , "<b>Convert to upper case</b> "
"<br> Converts a string to upper case letters. "
"<br> <i>Usage:</i><br>upper('hello world') will return 'HELLO WORLD'" ),
FnDef( "length", 1, fcnLength, "String", "<b>Length of string</b> "
"<br> Returns the legnth of a string. "
"<br> <i>Usage:</i><br>length('hello') will return 5" ),
FnDef( "replace", 3, fcnReplace, "String", "<b>Replace a section of a string.</b> " ),
FnDef( "lower", 1, fcnLower, "String"),
FnDef( "upper", 1, fcnUpper, "String"),
FnDef( "length", 1, fcnLength, "String"),
FnDef( "replace", 3, fcnReplace, "String"),
FnDef( "regexp_replace", 3, fcnRegexpReplace, "String" ),
FnDef( "substr", 3, fcnSubstr, "String" ),
// geometry accessors
Expand Down
4 changes: 3 additions & 1 deletion src/core/qgsproject.cpp 100644 → 100755
Expand Up @@ -1365,7 +1365,9 @@ QString QgsProject::readPath( QString src ) const
// where the source file had to exist and only the project directory was stripped
// from the filename.
QFileInfo pfi( fileName() );
Q_ASSERT( pfi.exists() );
if ( !pfi.exists() )
return src;

QFileInfo fi( pfi.canonicalPath() + "/" + src );

if ( !fi.exists() )
Expand Down
2 changes: 0 additions & 2 deletions src/gui/attributetable/qgsattributetablememorymodel.h
Expand Up @@ -81,8 +81,6 @@ class QgsAttributeTableMemoryModel : public QgsAttributeTableModel
* Loads the layer into the model
*/
virtual void loadLayer();

QHash<QgsFeatureId, QgsFeature> mFeatureMap;
};

#endif //QGSATTRIBUTETABLEMEMORYMODEL_H
33 changes: 32 additions & 1 deletion src/gui/attributetable/qgsattributetablemodel.cpp 100644 → 100755
Expand Up @@ -33,6 +33,9 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayer *theLayer, QObjec
: QAbstractTableModel( parent )
{
mFeat.setFeatureId( std::numeric_limits<int>::min() );
mFeatureMap.clear();
mFeatureQueue.clear();

mLayer = theLayer;
loadAttributes();

Expand All @@ -50,9 +53,33 @@ bool QgsAttributeTableModel::featureAtId( QgsFeatureId fid ) const
QgsDebugMsgLevel( QString( "loading feature %1" ).arg( fid ), 3 );

if ( fid == std::numeric_limits<int>::min() )
{
return false;
}
else if ( mFeatureMap.contains( fid ) )
{
mFeat = mFeatureMap[ fid ];
return true;
}
else if ( mLayer->featureAtId( fid, mFeat, false, true ) )
{
QSettings settings;
int cacheSize = settings.value( "/qgis/attributeTableRowCache", "10000" ).toInt();

if ( mFeatureQueue.size() == cacheSize )
{
mFeatureMap.remove( mFeatureQueue.dequeue() );
}

mFeatureQueue.enqueue( fid );
mFeatureMap.insert( fid, mFeat );

return true;
}
else
return mLayer->featureAtId( fid, mFeat, false, true );
{
return false;
}
}

void QgsAttributeTableModel::featureDeleted( QgsFeatureId fid )
Expand Down Expand Up @@ -152,6 +179,10 @@ void QgsAttributeTableModel::layerDeleted()

void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
{
if ( mFeatureMap.contains( fid ) )
{
mFeatureMap[ fid ].changeAttribute( fieldCol( idx ), value );
}
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
}

Expand Down
6 changes: 6 additions & 0 deletions src/gui/attributetable/qgsattributetablemodel.h
Expand Up @@ -21,6 +21,7 @@
#include <QModelIndex>
#include <QObject>
#include <QHash>
#include <QQueue>

#include "qgsfeature.h" // QgsAttributeMap
#include "qgsvectorlayer.h" // QgsAttributeList
Expand Down Expand Up @@ -196,6 +197,7 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
int mFieldCount;

mutable QgsFeature mFeat;
mutable QHash<QgsFeatureId, QgsFeature> mFeatureMap;

QgsAttributeList mAttributes;
QMap< int, const QMap<QString, QVariant> * > mValueMaps;
Expand Down Expand Up @@ -228,6 +230,10 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
* @return feature exists
*/
virtual bool featureAtId( QgsFeatureId fid ) const;

private:
mutable QQueue<QgsFeatureId> mFeatureQueue;

};


Expand Down
86 changes: 81 additions & 5 deletions src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -17,8 +17,12 @@
#include "qgslogger.h"
#include "qgsexpression.h"
#include "qgsmessageviewer.h"
#include "qgsapplication.h"

#include <QSettings>
#include <QMenu>
#include <QFile>
#include <QTextStream>

QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
: QWidget( parent )
Expand Down Expand Up @@ -79,7 +83,7 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
QString name = func.mName;
if ( func.mParams >= 1 )
name += "(";
registerItem( func.mGroup, func.mName, " " + name + " ", func.mHelpText );
registerItem( func.mGroup, func.mName, " " + name + " ");
};
}

Expand All @@ -106,18 +110,19 @@ void QgsExpressionBuilderWidget::on_expressionTree_clicked( const QModelIndex &i
// right click so we just show the help.
if ( item->getItemType() == QgsExpressionItem::Field )
{
txtHelpText->setText( tr( "Double click to add field name to expression string. <br> "
txtHelpText->setHtml( tr( "Double click to add field name to expression string. <br> "
"Or right click to select loading value options then "
"double click an item in the value list to add it to the expression string." ) );
txtHelpText->setToolTip( txtHelpText->text() );
txtHelpText->setToolTip( txtHelpText->toPlainText() );
}
else
{
// Show the help for the current item.
mValueGroupBox->hide();
mValueListWidget->clear();
txtHelpText->setText( item->getHelpText() );
txtHelpText->setToolTip( txtHelpText->text() );
QString help = loadFunctionHelp( item );
txtHelpText->setText( help );
txtHelpText->setToolTip( txtHelpText->toPlainText() );
}
}

Expand Down Expand Up @@ -347,3 +352,74 @@ void QgsExpressionBuilderWidget::loadAllValues()
fillFieldValues( fieldIndex, -1 );
}

QString QgsExpressionBuilderWidget::loadFunctionHelp( QgsExpressionItem* functionName )
{
if ( functionName != NULL )
{
// set up the path to the help file
QString helpFilesPath = QgsApplication::pkgDataPath() + "/resources/function_help/";
/*
* determine the locale and create the file name from
* the context id
*/
QString lang = QLocale::system().name();

QSettings settings;
if ( settings.value( "locale/overrideFlag", false ).toBool() )
{
QLocale l( settings.value( "locale/userLocale", "en_US" ).toString() );
lang = l.name();
}
/*
* If the language isn't set on the system, assume en_US,
* otherwise we get the banner at the top of the help file
* saying it isn't available in "your" language. Some systems
* may be installed without the LANG environment being set.
*/
if ( lang.length() == 0 || lang == "C" )
{
lang = "en_US";
}
QString fullHelpPath = helpFilesPath + functionName->text() + "-" + lang;
// get the help content and title from the localized file
QString helpContents;
QFile file( fullHelpPath );
// check to see if the localized version exists
if ( !file.exists() )
{
// change the file name to the en_US version (default)
fullHelpPath = helpFilesPath + functionName->text() + "-en_US";
file.setFileName( fullHelpPath );

// Check for some sort of english locale and if not found, include
// translate this for us message
if ( !lang.contains( "en_" ) )
{
helpContents = "<i>" + tr( "This help file is not available in your language %1. If you would like to translate it, please contact the QGIS development team." ).arg( lang ) + "</i><hr />";
}

}
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
helpContents = tr( "This help file does not exist for your language:<p><b>%1</b><p>If you would like to create it, contact the QGIS development team" )
.arg( fullHelpPath );
}
else
{
QTextStream in( &file );
in.setCodec( "UTF-8" ); // Help files must be in Utf-8
while ( !in.atEnd() )
{
QString line = in.readLine();
helpContents += line;
}
}
file.close();

// Set the browser text to the help contents
QString myStyle = QgsApplication::reportStyleSheet();
helpContents = "<head><style>" + myStyle + "</style></head><body>" + helpContents + "</body>";
return helpContents;
}
return "";
}
1 change: 1 addition & 0 deletions src/gui/qgsexpressionbuilderwidget.h
Expand Up @@ -159,6 +159,7 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp

private:
void fillFieldValues( int fieldIndex, int countLimit );
QString loadFunctionHelp( QgsExpressionItem* functionName );

QgsVectorLayer *mLayer;
QStandardItemModel *mModel;
Expand Down

0 comments on commit 545e9a4

Please sign in to comment.