Skip to content

Commit 545e9a4

Browse files
committed
Resolved merge conflicts
2 parents dde7032 + 898604d commit 545e9a4

20 files changed

+427
-223
lines changed

images/images.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
<file>themes/default/propertyicons/rendering.png</file>
204204
<file>themes/default/propertyicons/symbology.png</file>
205205
<file>themes/default/propertyicons/transparency.png</file>
206+
<file>themes/default/propertyicons/gdal.png</file>
206207
<file>themes/default/qgis.xpm</file>
207208
<file>themes/default/rendererCategorizedSymbol.png</file>
208209
<file>themes/default/rendererGraduatedSymbol.png</file>
1.99 KB
Loading

resources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ ADD_SUBDIRECTORY(context_help)
55
ADD_SUBDIRECTORY(js)
66
ADD_SUBDIRECTORY(html)
77
ADD_SUBDIRECTORY(css)
8+
ADD_SUBDIRECTORY(function_help)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FILE(GLOB HELP_FILES *-*)
2+
3+
INSTALL(FILES ${HELP_FILES} DESTINATION ${QGIS_DATA_DIR}/resources/function_help)
4+

resources/function_help/length-en_US

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<h3>length() function</h3>
2+
Returns the length of a string.
3+
4+
<p><h4>Syntax</h4>
5+
length(<i>string</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> string</i> -> is string. The String to count the length of.</p>
10+
11+
<p><h4>Example</h4>
12+
<!-- Show example of function.-->
13+
length('HELLO') -> 5</p>

resources/function_help/lower-en_US

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<h3>lower() function</h3>
2+
Converts a string to lower case letters.
3+
4+
<p><h4> Syntax</h4>
5+
lower(<i>string</i>)</p>
6+
7+
<p><h4> Arguments</h4>
8+
<i> string</i> -> is string. The String to convert to lower case.</p>
9+
10+
<p><h4> Example</h4>
11+
lower('HELLO World') -> 'hello world'</p>

resources/function_help/replace-en_US

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h3>replace() function</h3>
2+
Returns a string with the the supplied string replaced.
3+
4+
<p><h4>Syntax</h4>
5+
replace(<i>string,before,after</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> string</i> -> is string. The start string.<br>
10+
<i> before</i> -> is string. The string to replace.<br>
11+
<i> after</i> -> is string. The string that will repalce <i>before</i><br></p>
12+
13+
<p><h4>Example</h4>
14+
<!-- Show example of function.-->
15+
replace('QGIS SHOULD ROCK','SHOULD','DOES') -> 'QGIS DOES ROCK'</p>

resources/function_help/substr-en_US

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<h3>substr() function</h3>
2+
Return a part of a string
3+
4+
<p><h4>Syntax</h4>
5+
substr(<i>string,startpos,length</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> string</i> -> is string. The full string.<br>
10+
<i> startpos</i> -> is number. The start position to extract from.<br>
11+
<i> length</i> -> is number. The length of the string to extract.<br></p>
12+
13+
<p><h4>Example</h4>
14+
<!-- Show example of function.-->
15+
substr('HELLO WORLD',3,5) -> 'LLO W'</p>

resources/function_help/template

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<h3>{function} function</h3>
2+
Converts a string to lower case letters.
3+
4+
<p><h4>Syntax</h4>
5+
lower(<i>args</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> string</i> -> is string. The String to convert to lower case.</p>
10+
11+
<p><h4>Example</h4>
12+
<!-- Show example of function.-->
13+
lower('HELLO World') -> 'hello world'</p>

resources/function_help/upper-en_US

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<h3>upper() function</h3>
2+
Converts a string to upper case letters.
3+
4+
<p><h4>Syntax</h4>
5+
upper(<i>string</i>)</p>
6+
7+
<p><h4>Arguments</h4>
8+
<!-- List args for functions here-->
9+
<i> string</i> -> is string. The String to convert to upper case.</p>
10+
11+
<p><h4>Example</h4>
12+
<!-- Show example of function.-->
13+
upper('hello WOrld') -> 'HELLO WORLD'</p>

src/app/qgsoptions.cpp

100644100755
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
6767
cmbSize->addItem( "32" );
6868

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

185+
spinBoxAttrTableRowCache->setValue( settings.value( "/qgis/attributeTableRowCache", 10000 ).toInt() );
186+
185187
// set the display update threshold
186188
spinBoxUpdateThreshold->setValue( settings.value( "/Map/updateThreshold" ).toInt() );
187189
//set the default projection behaviour radio buttongs
@@ -584,6 +586,7 @@ void QgsOptions::saveOptions()
584586
settings.setValue( "/qgis/showTips", cbxShowTips->isChecked() );
585587
settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
586588
settings.setValue( "/qgis/attributeTableBehaviour", cmbAttrTableBehaviour->currentIndex() );
589+
settings.setValue( "/qgis/attributeTableRowCache", spinBoxAttrTableRowCache->value() );
587590
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
588591
settings.setValue( "/qgis/dockSnapping", cbxSnappingOptionsDocked->isChecked() );
589592
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );

src/core/qgsexpression.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,10 @@ FnDef QgsExpression::BuiltinFunctions[] =
392392
FnDef( "toreal", 1, fcnToReal, "Conversions" ),
393393
FnDef( "tostring", 1, fcnToString, "Conversions" ),
394394
// string manipulation
395-
FnDef( "lower", 1, fcnLower, "String", "<b>Convert to lower case</b> "
396-
"<br> Converts a string to lower case letters. "
397-
"<br> <i>Usage:</i><br>lower('HELLO WORLD') will return 'hello world'" ),
398-
FnDef( "upper", 1, fcnUpper, "String" , "<b>Convert to upper case</b> "
399-
"<br> Converts a string to upper case letters. "
400-
"<br> <i>Usage:</i><br>upper('hello world') will return 'HELLO WORLD'" ),
401-
FnDef( "length", 1, fcnLength, "String", "<b>Length of string</b> "
402-
"<br> Returns the legnth of a string. "
403-
"<br> <i>Usage:</i><br>length('hello') will return 5" ),
404-
FnDef( "replace", 3, fcnReplace, "String", "<b>Replace a section of a string.</b> " ),
395+
FnDef( "lower", 1, fcnLower, "String"),
396+
FnDef( "upper", 1, fcnUpper, "String"),
397+
FnDef( "length", 1, fcnLength, "String"),
398+
FnDef( "replace", 3, fcnReplace, "String"),
405399
FnDef( "regexp_replace", 3, fcnRegexpReplace, "String" ),
406400
FnDef( "substr", 3, fcnSubstr, "String" ),
407401
// geometry accessors

src/core/qgsproject.cpp

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,9 @@ QString QgsProject::readPath( QString src ) const
13651365
// where the source file had to exist and only the project directory was stripped
13661366
// from the filename.
13671367
QFileInfo pfi( fileName() );
1368-
Q_ASSERT( pfi.exists() );
1368+
if ( !pfi.exists() )
1369+
return src;
1370+
13691371
QFileInfo fi( pfi.canonicalPath() + "/" + src );
13701372

13711373
if ( !fi.exists() )

src/gui/attributetable/qgsattributetablememorymodel.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class QgsAttributeTableMemoryModel : public QgsAttributeTableModel
8181
* Loads the layer into the model
8282
*/
8383
virtual void loadLayer();
84-
85-
QHash<QgsFeatureId, QgsFeature> mFeatureMap;
8684
};
8785

8886
#endif //QGSATTRIBUTETABLEMEMORYMODEL_H

src/gui/attributetable/qgsattributetablemodel.cpp

100644100755
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayer *theLayer, QObjec
3333
: QAbstractTableModel( parent )
3434
{
3535
mFeat.setFeatureId( std::numeric_limits<int>::min() );
36+
mFeatureMap.clear();
37+
mFeatureQueue.clear();
38+
3639
mLayer = theLayer;
3740
loadAttributes();
3841

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

5255
if ( fid == std::numeric_limits<int>::min() )
56+
{
5357
return false;
58+
}
59+
else if ( mFeatureMap.contains( fid ) )
60+
{
61+
mFeat = mFeatureMap[ fid ];
62+
return true;
63+
}
64+
else if ( mLayer->featureAtId( fid, mFeat, false, true ) )
65+
{
66+
QSettings settings;
67+
int cacheSize = settings.value( "/qgis/attributeTableRowCache", "10000" ).toInt();
68+
69+
if ( mFeatureQueue.size() == cacheSize )
70+
{
71+
mFeatureMap.remove( mFeatureQueue.dequeue() );
72+
}
73+
74+
mFeatureQueue.enqueue( fid );
75+
mFeatureMap.insert( fid, mFeat );
76+
77+
return true;
78+
}
5479
else
55-
return mLayer->featureAtId( fid, mFeat, false, true );
80+
{
81+
return false;
82+
}
5683
}
5784

5885
void QgsAttributeTableModel::featureDeleted( QgsFeatureId fid )
@@ -152,6 +179,10 @@ void QgsAttributeTableModel::layerDeleted()
152179

153180
void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
154181
{
182+
if ( mFeatureMap.contains( fid ) )
183+
{
184+
mFeatureMap[ fid ].changeAttribute( fieldCol( idx ), value );
185+
}
155186
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
156187
}
157188

src/gui/attributetable/qgsattributetablemodel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QModelIndex>
2222
#include <QObject>
2323
#include <QHash>
24+
#include <QQueue>
2425

2526
#include "qgsfeature.h" // QgsAttributeMap
2627
#include "qgsvectorlayer.h" // QgsAttributeList
@@ -196,6 +197,7 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
196197
int mFieldCount;
197198

198199
mutable QgsFeature mFeat;
200+
mutable QHash<QgsFeatureId, QgsFeature> mFeatureMap;
199201

200202
QgsAttributeList mAttributes;
201203
QMap< int, const QMap<QString, QVariant> * > mValueMaps;
@@ -228,6 +230,10 @@ class GUI_EXPORT QgsAttributeTableModel: public QAbstractTableModel
228230
* @return feature exists
229231
*/
230232
virtual bool featureAtId( QgsFeatureId fid ) const;
233+
234+
private:
235+
mutable QQueue<QgsFeatureId> mFeatureQueue;
236+
231237
};
232238

233239

src/gui/qgsexpressionbuilderwidget.cpp

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717
#include "qgslogger.h"
1818
#include "qgsexpression.h"
1919
#include "qgsmessageviewer.h"
20+
#include "qgsapplication.h"
2021

22+
#include <QSettings>
2123
#include <QMenu>
24+
#include <QFile>
25+
#include <QTextStream>
2226

2327
QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
2428
: QWidget( parent )
@@ -79,7 +83,7 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
7983
QString name = func.mName;
8084
if ( func.mParams >= 1 )
8185
name += "(";
82-
registerItem( func.mGroup, func.mName, " " + name + " ", func.mHelpText );
86+
registerItem( func.mGroup, func.mName, " " + name + " ");
8387
};
8488
}
8589

@@ -106,18 +110,19 @@ void QgsExpressionBuilderWidget::on_expressionTree_clicked( const QModelIndex &i
106110
// right click so we just show the help.
107111
if ( item->getItemType() == QgsExpressionItem::Field )
108112
{
109-
txtHelpText->setText( tr( "Double click to add field name to expression string. <br> "
113+
txtHelpText->setHtml( tr( "Double click to add field name to expression string. <br> "
110114
"Or right click to select loading value options then "
111115
"double click an item in the value list to add it to the expression string." ) );
112-
txtHelpText->setToolTip( txtHelpText->text() );
116+
txtHelpText->setToolTip( txtHelpText->toPlainText() );
113117
}
114118
else
115119
{
116120
// Show the help for the current item.
117121
mValueGroupBox->hide();
118122
mValueListWidget->clear();
119-
txtHelpText->setText( item->getHelpText() );
120-
txtHelpText->setToolTip( txtHelpText->text() );
123+
QString help = loadFunctionHelp( item );
124+
txtHelpText->setText( help );
125+
txtHelpText->setToolTip( txtHelpText->toPlainText() );
121126
}
122127
}
123128

@@ -347,3 +352,74 @@ void QgsExpressionBuilderWidget::loadAllValues()
347352
fillFieldValues( fieldIndex, -1 );
348353
}
349354

355+
QString QgsExpressionBuilderWidget::loadFunctionHelp( QgsExpressionItem* functionName )
356+
{
357+
if ( functionName != NULL )
358+
{
359+
// set up the path to the help file
360+
QString helpFilesPath = QgsApplication::pkgDataPath() + "/resources/function_help/";
361+
/*
362+
* determine the locale and create the file name from
363+
* the context id
364+
*/
365+
QString lang = QLocale::system().name();
366+
367+
QSettings settings;
368+
if ( settings.value( "locale/overrideFlag", false ).toBool() )
369+
{
370+
QLocale l( settings.value( "locale/userLocale", "en_US" ).toString() );
371+
lang = l.name();
372+
}
373+
/*
374+
* If the language isn't set on the system, assume en_US,
375+
* otherwise we get the banner at the top of the help file
376+
* saying it isn't available in "your" language. Some systems
377+
* may be installed without the LANG environment being set.
378+
*/
379+
if ( lang.length() == 0 || lang == "C" )
380+
{
381+
lang = "en_US";
382+
}
383+
QString fullHelpPath = helpFilesPath + functionName->text() + "-" + lang;
384+
// get the help content and title from the localized file
385+
QString helpContents;
386+
QFile file( fullHelpPath );
387+
// check to see if the localized version exists
388+
if ( !file.exists() )
389+
{
390+
// change the file name to the en_US version (default)
391+
fullHelpPath = helpFilesPath + functionName->text() + "-en_US";
392+
file.setFileName( fullHelpPath );
393+
394+
// Check for some sort of english locale and if not found, include
395+
// translate this for us message
396+
if ( !lang.contains( "en_" ) )
397+
{
398+
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 />";
399+
}
400+
401+
}
402+
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
403+
{
404+
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" )
405+
.arg( fullHelpPath );
406+
}
407+
else
408+
{
409+
QTextStream in( &file );
410+
in.setCodec( "UTF-8" ); // Help files must be in Utf-8
411+
while ( !in.atEnd() )
412+
{
413+
QString line = in.readLine();
414+
helpContents += line;
415+
}
416+
}
417+
file.close();
418+
419+
// Set the browser text to the help contents
420+
QString myStyle = QgsApplication::reportStyleSheet();
421+
helpContents = "<head><style>" + myStyle + "</style></head><body>" + helpContents + "</body>";
422+
return helpContents;
423+
}
424+
return "";
425+
}

src/gui/qgsexpressionbuilderwidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
159159

160160
private:
161161
void fillFieldValues( int fieldIndex, int countLimit );
162+
QString loadFunctionHelp( QgsExpressionItem* functionName );
162163

163164
QgsVectorLayer *mLayer;
164165
QStandardItemModel *mModel;

0 commit comments

Comments
 (0)