Skip to content
Permalink
Browse files

Add (non-functional) locator configuration dialog

  • Loading branch information
nyalldawson committed May 17, 2017
1 parent 96d8f87 commit ce66393636f309e46d6b69e01d168c17be28ca17
@@ -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 );
@@ -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
@@ -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 );
}
@@ -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;
@@ -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();

@@ -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 );

@@ -47,6 +47,8 @@
#include "qgsclipboard.h"
#include "qgssettings.h"
#include "qgsoptionswidgetfactory.h"
#include "qgslocatorwidget.h"
#include "qgslocatoroptionswidget.h"

#include <QInputDialog>
#include <QFileDialog>
@@ -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 )
@@ -31,6 +31,7 @@

class QgsExpressionContext;
class QgsOptionsPageWidget;
class QgsLocatorOptionsWidget;

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

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

};

@@ -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 );

}
@@ -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;
@@ -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>
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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>

0 comments on commit ce66393

Please sign in to comment.