Skip to content

Commit 0595f74

Browse files
committed
Add checkbox to filter non-QGIS-specific vars from current env vars table
1 parent 8d582ad commit 0595f74

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

src/app/qgsoptions.cpp

+22-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
121121
mCustomVariablesTable->setEnabled( false );
122122
}
123123
QStringList customVarsList = settings.value( "qgis/customEnvVars", "" ).toStringList();
124-
mCustomVariablesTable->clearContents();
125124
foreach ( const QString &varStr, customVarsList )
126125
{
127126
int pos = varStr.indexOf( QLatin1Char( '|' ) );
@@ -155,7 +154,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
155154
mCurrentVariablesTable->horizontalHeader()->setFixedHeight( fmCustomVarH );
156155
QMap<QString, QString> sysVarsMap = QgsApplication::systemEnvVars();
157156
QStringList currentVarsList = QProcess::systemEnvironment();
158-
mCurrentVariablesTable->clearContents();
159157

160158
foreach ( const QString &varStr, currentVarsList )
161159
{
@@ -1368,6 +1366,28 @@ void QgsOptions::on_mRemoveCustomVarBtn_clicked()
13681366
mCustomVariablesTable->removeRow( mCustomVariablesTable->currentRow() );
13691367
}
13701368

1369+
void QgsOptions::on_mCurrentVariablesQGISChxBx_toggled( bool qgisSpecific )
1370+
{
1371+
for ( int i = mCurrentVariablesTable->rowCount() - 1; i >= 0; --i )
1372+
{
1373+
if ( qgisSpecific )
1374+
{
1375+
QString itmTxt = mCurrentVariablesTable->item( i, 0 )->text();
1376+
if ( !itmTxt.startsWith( "QGIS", Qt::CaseInsensitive ) )
1377+
mCurrentVariablesTable->hideRow( i );
1378+
}
1379+
else
1380+
{
1381+
mCurrentVariablesTable->showRow( i );
1382+
}
1383+
}
1384+
if ( mCurrentVariablesTable->rowCount() > 0 )
1385+
{
1386+
mCurrentVariablesTable->sortByColumn( 0, Qt::AscendingOrder );
1387+
mCurrentVariablesTable->resizeColumnToContents( 0 );
1388+
}
1389+
}
1390+
13711391
void QgsOptions::on_mBtnAddPluginPath_clicked()
13721392
{
13731393
QString myDir = QFileDialog::getExistingDirectory(

src/app/qgsoptions.h

+5
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase
127127
*/
128128
void on_mRemoveCustomVarBtn_clicked();
129129

130+
/** Slot to filter out current environment variables not specific to QGIS
131+
* @note added in QGIS 1.9
132+
*/
133+
void on_mCurrentVariablesQGISChxBx_toggled( bool qgisSpecific );
134+
130135
/* Let the user add a path to the list of search paths
131136
* used for finding user Plugin libs.
132137
* @note added in QGIS 1.7

src/ui/qgsoptionsbase.ui

+21-14
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,13 @@
11331133
</column>
11341134
</widget>
11351135
</item>
1136+
<item>
1137+
<widget class="QCheckBox" name="mCurrentVariablesQGISChxBx">
1138+
<property name="text">
1139+
<string>Show only QGIS-specific variables</string>
1140+
</property>
1141+
</widget>
1142+
</item>
11361143
</layout>
11371144
</widget>
11381145
</item>
@@ -1751,7 +1758,7 @@
17511758
<rect>
17521759
<x>0</x>
17531760
<y>0</y>
1754-
<width>771</width>
1761+
<width>554</width>
17551762
<height>717</height>
17561763
</rect>
17571764
</property>
@@ -2111,8 +2118,8 @@
21112118
<rect>
21122119
<x>0</x>
21132120
<y>0</y>
2114-
<width>786</width>
2115-
<height>588</height>
2121+
<width>307</width>
2122+
<height>96</height>
21162123
</rect>
21172124
</property>
21182125
<layout class="QGridLayout" name="gridLayout_10">
@@ -2192,7 +2199,7 @@
21922199
<rect>
21932200
<x>0</x>
21942201
<y>0</y>
2195-
<width>771</width>
2202+
<width>583</width>
21962203
<height>618</height>
21972204
</rect>
21982205
</property>
@@ -2568,8 +2575,8 @@
25682575
<rect>
25692576
<x>0</x>
25702577
<y>0</y>
2571-
<width>786</width>
2572-
<height>588</height>
2578+
<width>618</width>
2579+
<height>417</height>
25732580
</rect>
25742581
</property>
25752582
<layout class="QGridLayout" name="gridLayout_15">
@@ -2755,8 +2762,8 @@
27552762
<rect>
27562763
<x>0</x>
27572764
<y>0</y>
2758-
<width>786</width>
2759-
<height>588</height>
2765+
<width>525</width>
2766+
<height>571</height>
27602767
</rect>
27612768
</property>
27622769
<layout class="QGridLayout" name="gridLayout_17">
@@ -2852,7 +2859,7 @@
28522859
<rect>
28532860
<x>0</x>
28542861
<y>0</y>
2855-
<width>771</width>
2862+
<width>491</width>
28562863
<height>598</height>
28572864
</rect>
28582865
</property>
@@ -3093,17 +3100,17 @@
30933100
</widget>
30943101
<layoutdefault spacing="6" margin="11"/>
30953102
<customwidgets>
3103+
<customwidget>
3104+
<class>QgsColorButton</class>
3105+
<extends>QToolButton</extends>
3106+
<header>qgscolorbutton.h</header>
3107+
</customwidget>
30963108
<customwidget>
30973109
<class>QgsCollapsibleGroupBox</class>
30983110
<extends>QGroupBox</extends>
30993111
<header>qgscollapsiblegroupbox.h</header>
31003112
<container>1</container>
31013113
</customwidget>
3102-
<customwidget>
3103-
<class>QgsColorButton</class>
3104-
<extends>QToolButton</extends>
3105-
<header>qgscolorbutton.h</header>
3106-
</customwidget>
31073114
</customwidgets>
31083115
<tabstops>
31093116
<tabstop>tabWidget</tabstop>

0 commit comments

Comments
 (0)