Skip to content

Commit

Permalink
Add (non-functional) locator configuration dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 17, 2017
1 parent 96d8f87 commit ce66393
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 29 deletions.
7 changes: 7 additions & 0 deletions python/gui/locator/qgslocatorwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ class QgsLocatorWidget : QWidget
Triggers the locator widget to focus, open and start searching for a specified ``string``.
%End

signals:

void configTriggered();
%Docstring
Emitted when the configure option is triggered in the widget.
%End

protected:

virtual bool eventFilter( QObject *obj, QEvent *event );
Expand Down
27 changes: 26 additions & 1 deletion src/app/locator/qgslocatoroptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ QgsLocatorFiltersModel::QgsLocatorFiltersModel( QgsLocator *locator, QObject *pa
: QAbstractTableModel( parent )
, mLocator( locator )
{

setHeaderData( Name, Qt::Horizontal, tr( "Filter" ) );
setHeaderData( Prefix, Qt::Horizontal, tr( "Prefix" ) );
setHeaderData( Active, Qt::Horizontal, tr( "Enabled" ) );
setHeaderData( Default, Qt::Horizontal, tr( "Default" ) );
}

int QgsLocatorFiltersModel::rowCount( const QModelIndex & ) const
Expand Down Expand Up @@ -111,8 +114,30 @@ Qt::ItemFlags QgsLocatorFiltersModel::flags( const QModelIndex &index ) const
case Active:
case Default:
flags = flags | Qt::ItemIsUserCheckable;
flags = flags | Qt::ItemIsEditable;
break;
}

return flags;
}

QVariant QgsLocatorFiltersModel::zheaderData( int section, Qt::Orientation orientation, int role ) const
{
if ( orientation == Qt::Horizontal && role == Qt::SizeHintRole )
{
QSize size = QAbstractTableModel::headerData( section, orientation, role ).toSize();
switch ( section )
{
case Name:
break;
case Prefix:
case Active:
case Default:
size.setWidth( 100 );
break;
}
return size;
}

return QAbstractTableModel::headerData( section, orientation, role );
}
3 changes: 2 additions & 1 deletion src/app/locator/qgslocatoroptionswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class QgsLocatorFiltersModel : public QAbstractTableModel
int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
Qt::ItemFlags flags( const QModelIndex &index ) const override;

QVariant zheaderData( int section, Qt::Orientation orientation,
int role = Qt::DisplayRole ) const;
private:

QgsLocator *mLocator = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
new QgsCredentialDialog( this );

mLocatorWidget->setMapCanvas( mMapCanvas );
connect( mLocatorWidget, &QgsLocatorWidget::configTriggered, this, [ = ] { showOptionsDialog( this, QString( "mOptionsPageLocator" ) ); } );

qApp->processEvents();

Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Returns map overview canvas
QgsMapOverviewCanvas *mapOverviewCanvas() { return mOverviewCanvas; }

QgsLocatorWidget *locatorWidget() { return mLocatorWidget; }

//! show layer properties
void showLayerProperties( QgsMapLayer *ml );

Expand Down
8 changes: 8 additions & 0 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "qgsclipboard.h"
#include "qgssettings.h"
#include "qgsoptionswidgetfactory.h"
#include "qgslocatorwidget.h"
#include "qgslocatoroptionswidget.h"

#include <QInputDialog>
#include <QFileDialog>
Expand Down Expand Up @@ -940,6 +942,12 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mVariableEditor->reloadContext();
mVariableEditor->setEditableScopeIndex( 0 );

// locator
mLocatorOptionsWidget = new QgsLocatorOptionsWidget( QgisApp::instance()->locatorWidget()->locator(), this );
QVBoxLayout *locatorLayout = new QVBoxLayout();
locatorLayout->addWidget( mLocatorOptionsWidget );
mOptionsLocatorGroupBox->setLayout( locatorLayout );

mAdvancedSettingsEditor->setSettingsObject( mSettings );

Q_FOREACH ( QgsOptionsWidgetFactory *factory, optionsFactories )
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

class QgsExpressionContext;
class QgsOptionsPageWidget;
class QgsLocatorOptionsWidget;

/**
* \class QgsOptions
Expand Down Expand Up @@ -254,6 +255,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
private:

QList< QgsOptionsPageWidget * > mAdditionalOptionWidgets;
QgsLocatorOptionsWidget *mLocatorOptionsWidget = nullptr;

};

Expand Down
1 change: 1 addition & 0 deletions src/gui/locator/qgslocatorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ void QgsLocatorWidget::configMenuAboutToShow()
}
mMenu->addSeparator();
QAction *configAction = new QAction( trUtf8( "Configure…" ), mMenu );
connect( configAction, &QAction::triggered, this, &QgsLocatorWidget::configTriggered );
mMenu->addAction( configAction );

}
Expand Down
7 changes: 7 additions & 0 deletions src/gui/locator/qgslocatorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ class GUI_EXPORT QgsLocatorWidget : public QWidget
*/
void search( const QString &string );

signals:

/**
* Emitted when the configure option is triggered in the widget.
*/
void configTriggered();

protected:

bool eventFilter( QObject *obj, QEvent *event ) override;
Expand Down
74 changes: 47 additions & 27 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@
<normaloff>:/images/themes/default/mIconExpression.svg</normaloff>:/images/themes/default/mIconExpression.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Locator</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/search.svg</normaloff>:/images/themes/default/search.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Advanced</string>
Expand Down Expand Up @@ -311,7 +320,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>2</number>
<number>15</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -340,8 +349,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>691</width>
<height>702</height>
<width>856</width>
<height>679</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
Expand Down Expand Up @@ -1026,8 +1035,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>579</width>
<height>1110</height>
<width>429</width>
<height>1009</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
Expand Down Expand Up @@ -1556,8 +1565,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>843</width>
<height>787</height>
<width>856</width>
<height>679</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
Expand Down Expand Up @@ -1924,8 +1933,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>713</width>
<height>1110</height>
<width>541</width>
<height>827</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_22">
Expand Down Expand Up @@ -2675,8 +2684,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>151</width>
<height>239</height>
<width>112</width>
<height>219</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_46">
Expand Down Expand Up @@ -2826,8 +2835,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>523</width>
<height>370</height>
<width>453</width>
<height>281</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
Expand Down Expand Up @@ -3169,8 +3178,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>660</height>
<width>506</width>
<height>533</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
Expand Down Expand Up @@ -3613,8 +3622,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>509</width>
<height>623</height>
<width>393</width>
<height>530</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_39">
Expand Down Expand Up @@ -3882,8 +3891,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>572</width>
<height>828</height>
<width>488</width>
<height>612</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
Expand Down Expand Up @@ -4460,8 +4469,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>435</width>
<height>402</height>
<width>345</width>
<height>350</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
Expand Down Expand Up @@ -4599,8 +4608,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>584</height>
<width>332</width>
<height>499</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
Expand Down Expand Up @@ -4812,8 +4821,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>292</width>
<height>258</height>
<width>221</width>
<height>201</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
Expand Down Expand Up @@ -4921,8 +4930,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>534</width>
<height>790</height>
<width>393</width>
<height>618</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
Expand Down Expand Up @@ -5336,6 +5345,17 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsLocatorSettings">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QGroupBox" name="mOptionsLocatorGroupBox">
<property name="title">
<string>Locator Filters</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPageSettingsEditor">
<layout class="QVBoxLayout" name="verticalLayout_43">
<item>
Expand Down

0 comments on commit ce66393

Please sign in to comment.