Skip to content
Permalink
Browse files

New design compiles but does nothing

  • Loading branch information
carolinux authored and m-kuhn committed Jun 13, 2015
1 parent d3c49b3 commit eff1357e2b6355bc30145fd775a977b78d7a6d07
@@ -419,7 +419,6 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
{
mFilterButton->setDefaultAction( qobject_cast<QAction *>( filterAction ) );
mFilterButton->setPopupMode( QToolButton::InstantPopup );
mCbxCaseSensitive->setVisible( true );
// replace the search line edit with a search widget that is suited to the selected field
// delete previous widget
if ( mCurrentSearchWidgetWrapper != 0 )
@@ -435,10 +434,18 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
const QgsEditorWidgetConfig widgetConfig = mLayer->editorWidgetV2Config( fldIdx );
mCurrentSearchWidgetWrapper = QgsEditorWidgetRegistry::instance()->
createSearchWidget( widgetType, mLayer, fldIdx, widgetConfig, mFilterContainer );
if (mCurrentSearchWidgetWrapper->applyDirectly())
{
connect( mCurrentSearchWidgetWrapper, SIGNAL( expressionChanged(QString) ), SLOT( filterQueryChanged(QString) ) );
mApplyFilterButton->setVisible(false);
}
else
{
mApplyFilterButton->setVisible(true);
}

replaceSearchWidget( mFilterQuery, mCurrentSearchWidgetWrapper->widget() );

mApplyFilterButton->setVisible( true );
}

void QgsAttributeTableDialog::filterExpressionBuilder()
@@ -463,7 +470,6 @@ void QgsAttributeTableDialog::filterShowAll()
{
mFilterButton->setDefaultAction( mActionShowAllFilter );
mFilterButton->setPopupMode( QToolButton::InstantPopup );
mCbxCaseSensitive->setVisible( false );
mFilterQuery->setVisible( false );
mApplyFilterButton->setVisible( false );
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowAll );
@@ -474,7 +480,6 @@ void QgsAttributeTableDialog::filterSelected()
{
mFilterButton->setDefaultAction( mActionSelectedFilter );
mFilterButton->setPopupMode( QToolButton::InstantPopup );
mCbxCaseSensitive->setVisible( false );
mFilterQuery->setVisible( false );
mApplyFilterButton->setVisible( false );
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowSelected );
@@ -490,7 +495,6 @@ void QgsAttributeTableDialog::filterVisible()

mFilterButton->setDefaultAction( mActionVisibleFilter );
mFilterButton->setPopupMode( QToolButton::InstantPopup );
mCbxCaseSensitive->setVisible( false );
mFilterQuery->setVisible( false );
mApplyFilterButton->setVisible( false );
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowVisible );
@@ -500,7 +504,6 @@ void QgsAttributeTableDialog::filterEdited()
{
mFilterButton->setDefaultAction( mActionEditedFilter );
mFilterButton->setPopupMode( QToolButton::InstantPopup );
mCbxCaseSensitive->setVisible( false );
mFilterQuery->setVisible( false );
mApplyFilterButton->setVisible( false );
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowEdited );
@@ -706,39 +709,7 @@ void QgsAttributeTableDialog::filterQueryChanged( const QString& query )
}
else
{
QString fieldName = mFilterButton->defaultAction()->text();
const QgsFields& flds = mLayer->pendingFields();
int fldIndex = mLayer->fieldNameIndex( fieldName );
if ( fldIndex < 0 )
return;

QVariant::Type fldType = flds[fldIndex].type();
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );

QString sensString = "ILIKE";
if ( mCbxCaseSensitive->isChecked() )
{
sensString = "LIKE";
}

QSettings settings;
QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
QString value = mCurrentSearchWidgetWrapper->value().toString();

if ( value == nullValue )
{
str = QString( "%1 IS NULL" ).arg( QgsExpression::quotedColumnRef( fieldName ) );
}
else
{
str = QString( "%1 %2 '%3'" )
.arg( QgsExpression::quotedColumnRef( fieldName ) )
.arg( numeric ? "=" : sensString )
.arg( numeric
? value.replace( "'", "''" )
:
"%" + value.replace( "'", "''" ) + "%" ); // escape quotes
}
str = mCurrentSearchWidgetWrapper->expression();
}

setFilterExpression( str );
@@ -749,7 +720,7 @@ void QgsAttributeTableDialog::filterQueryAccepted()
{
if (( mFilterQuery->isVisible() && mFilterQuery->text().isEmpty() ) ||
( mCurrentSearchWidgetWrapper != 0 && mCurrentSearchWidgetWrapper->widget()->isVisible()
&& mCurrentSearchWidgetWrapper->value().toString().isEmpty() ) )
&& mCurrentSearchWidgetWrapper->expression().isEmpty() ) )
{
filterShowAll();
return;
@@ -762,8 +733,6 @@ void QgsAttributeTableDialog::setFilterExpression( QString filterString )
mFilterQuery->setText( filterString );
mFilterButton->setDefaultAction( mActionAdvancedFilter );
mFilterButton->setPopupMode( QToolButton::MenuButtonPopup );
mCbxCaseSensitive->setVisible( false );

mFilterQuery->setVisible( true );
if ( mCurrentSearchWidgetWrapper != 0 )
{
@@ -29,7 +29,7 @@
#include "qgsattributedialog.h"
#include "qgsvectorlayer.h" //QgsFeatureIds
#include "qgsfieldmodel.h"
#include "qgseditorwidgetwrapper.h"
#include "qgssearchwidgetwrapper.h"

class QDialogButtonBox;
class QPushButton;
@@ -213,7 +213,7 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
QgsFieldModel* mFieldModel;

QgsRubberBand* mRubberBand;
QgsEditorWidgetWrapper* mCurrentSearchWidgetWrapper;
QgsSearchWidgetWrapper* mCurrentSearchWidgetWrapper;
};

#endif
@@ -58,11 +58,11 @@ SET(QGIS_GUI_SRCS
attributetable/qgsgenericfeatureselectionmanager.cpp
attributetable/qgsvectorlayerselectionmanager.cpp

editorwidgets/core/qgsdefaultsearchwidgetwrapper.cpp
editorwidgets/core/qgseditorconfigwidget.cpp
editorwidgets/core/qgseditorwidgetfactory.cpp
editorwidgets/core/qgseditorwidgetregistry.cpp
editorwidgets/core/qgseditorwidgetwrapper.cpp
editorwidgets/core/qgssearchwidgetwrapper.cpp
editorwidgets/core/qgswidgetwrapper.cpp

editorwidgets/qgscheckboxconfigdlg.cpp
@@ -76,6 +76,7 @@ SET(QGIS_GUI_SRCS
editorwidgets/qgsdatetimeeditfactory.cpp
editorwidgets/qgsdatetimeeditconfig.cpp
editorwidgets/qgsdatetimeeditwrapper.cpp
editorwidgets/qgsdefaultsearchwidgetwrapper.cpp
editorwidgets/qgsdoublespinbox.cpp
editorwidgets/qgsdummyconfigdlg.cpp
editorwidgets/qgsenumerationwidgetwrapper.cpp
@@ -107,8 +108,10 @@ SET(QGIS_GUI_SRCS
editorwidgets/qgsvaluemapconfigdlg.cpp
editorwidgets/qgsvaluemapwidgetwrapper.cpp
editorwidgets/qgsvaluemapwidgetfactory.cpp
editorwidgets/qgsvaluemapsearchwidgetwrapper.cpp
editorwidgets/qgsvaluerelationconfigdlg.cpp
editorwidgets/qgsvaluerelationwidgetwrapper.cpp
editorwidgets/qgsvaluerelationsearchwidgetwrapper.cpp
editorwidgets/qgsvaluerelationwidgetfactory.cpp


@@ -405,12 +408,12 @@ SET(QGIS_GUI_MOC_HDRS
effects/qgspainteffectwidget.h
effects/qgseffectstackpropertieswidget.h

editorwidgets/core/qgsdefaultsearchwidgetwrapper.h
editorwidgets/core/qgseditorconfigwidget.h
editorwidgets/core/qgseditorwidgetregistry.h
editorwidgets/core/qgseditorconfigwidget.h
editorwidgets/core/qgseditorwidgetregistry.h
editorwidgets/core/qgseditorwidgetwrapper.h
editorwidgets/core/qgssearchwidgetwrapper.h
editorwidgets/core/qgswidgetwrapper.h

editorwidgets/qgscheckboxconfigdlg.h
@@ -420,6 +423,7 @@ SET(QGIS_GUI_MOC_HDRS
editorwidgets/qgsdatetimeedit.h
editorwidgets/qgsdatetimeeditconfig.h
editorwidgets/qgsdatetimeeditwrapper.h
editorwidgets/qgsdefaultsearchwidgetwrapper.h
editorwidgets/qgsdoublespinbox.h
editorwidgets/qgsdummyconfigdlg.h
editorwidgets/qgsenumerationwidgetwrapper.h
@@ -441,8 +445,10 @@ SET(QGIS_GUI_MOC_HDRS
editorwidgets/qgsuuidwidgetwrapper.h
editorwidgets/qgsvaluemapconfigdlg.h
editorwidgets/qgsvaluemapwidgetwrapper.h
editorwidgets/qgsvaluemapsearchwidgetwrapper.h
editorwidgets/qgsvaluerelationconfigdlg.h
editorwidgets/qgsvaluerelationwidgetwrapper.h
editorwidgets/qgsvaluerelationsearchwidgetwrapper.h

layertree/qgscustomlayerorderwidget.h
layertree/qgslayertreemapcanvasbridge.h

This file was deleted.

@@ -15,6 +15,7 @@

#include "qgseditorwidgetfactory.h"
#include "qgsdefaultsearchwidgetwrapper.h"
#include "qgssearchwidgetwrapper.h"

#include <QSettings>

@@ -32,9 +33,9 @@ QgsEditorWidgetFactory::~QgsEditorWidgetFactory()
/** Override in own factory to get something different than the default (a simple QgsFilterLineEdit)
*
*/
QgsEditorWidgetWrapper* QgsEditorWidgetFactory::createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const
QgsSearchWidgetWrapper* QgsEditorWidgetFactory::createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const
{
return new QgsDefaultSearchWidgetWrapper( vl, fieldIdx, 0, parent );
return new QgsDefaultSearchWidgetWrapper( vl, fieldIdx, parent );
}

QString QgsEditorWidgetFactory::name()
@@ -18,7 +18,7 @@

#include "qgseditorwidgetwrapper.h"
#include "qgsapplication.h"
#include "qgsdefaultsearchwidgetwrapper.h"
#include "qgssearchwidgetwrapper.h"

#include <QDomNode>
#include <QMap>
@@ -61,7 +61,7 @@ class GUI_EXPORT QgsEditorWidgetFactory
*/
virtual QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const = 0;

virtual QgsEditorWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const;
virtual QgsSearchWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const;

/**
* Return The human readable identifier name of this widget type
@@ -16,7 +16,6 @@
#include "qgseditorwidgetregistry.h"

#include "qgsattributeeditorcontext.h"
//#include "qgseditorwidgetfactory.h"
#include "qgslegacyhelpers.h"
#include "qgsmessagelog.h"
#include "qgsproject.h"
@@ -102,11 +101,11 @@ QgsEditorWidgetWrapper* QgsEditorWidgetRegistry::create( const QString& widgetId
return 0;
}

QgsEditorWidgetWrapper* QgsEditorWidgetRegistry::createSearchWidget( const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, QWidget* parent, const QgsAttributeEditorContext &context )
QgsSearchWidgetWrapper* QgsEditorWidgetRegistry::createSearchWidget( const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, QWidget* parent, const QgsAttributeEditorContext &context )
{
if ( mWidgetFactories.contains( widgetId ) )
{
QgsEditorWidgetWrapper* ww = mWidgetFactories[widgetId]->createSearchWidget( vl, fieldIdx, parent );
QgsSearchWidgetWrapper* ww = mWidgetFactories[widgetId]->createSearchWidget( vl, fieldIdx, parent );

if ( ww )
{
@@ -83,7 +83,7 @@ class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
QWidget* parent,
const QgsAttributeEditorContext& context = QgsAttributeEditorContext() );

QgsEditorWidgetWrapper* createSearchWidget( const QString& widgetId,
QgsSearchWidgetWrapper* createSearchWidget( const QString& widgetId,
QgsVectorLayer* vl,
int fieldIdx,
const QgsEditorWidgetConfig& config,
@@ -0,0 +1,34 @@
/***************************************************************************
qgssearchwidgetwrapper.cpp
--------------------------------------
Date : 10.6.2015
Copyright : (C) 2015 Karolina Alexiou
Email : carolinegr at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgssearchwidgetwrapper.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsfield.h"

#include <QWidget>

QgsSearchWidgetWrapper::QgsSearchWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* parent )
: QgsWidgetWrapper( vl, 0, parent )
, mFieldIdx( fieldIdx )
, mExpression( QString() )
{
}


void QgsSearchWidgetWrapper::setFeature( const QgsFeature& feature )
{
}

7 comments on commit eff1357

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied Jun 26, 2015

Oops, I thought I had rewritten that commit message

@carolinux

This comment has been minimized.

Copy link
Contributor Author

@carolinux carolinux replied Jun 26, 2015

heh, of all the commit messages .. this was the one to remain

@carolinux

This comment has been minimized.

Copy link
Contributor Author

@carolinux carolinux replied Jun 26, 2015

seems like you didn't use b1b130e at all?

@carolinux

This comment has been minimized.

Copy link
Contributor Author

@carolinux carolinux replied Jun 26, 2015

also in qgsattributetabledialog.cpp :

if ( mCurrentSearchWidgetWrapper != 0 )
  {
    delete mCurrentSearchWidgetWrapper;
  }

this needs

mCurrentSearchWidgetWrapper->widget()->setVisible(false);

before deleting.. otherwise I think we get this rendering problem.

@carolinux

This comment has been minimized.

Copy link
Contributor Author

@carolinux carolinux replied Jun 26, 2015

looks like the merge was done without the most recent pr changes

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied Jun 27, 2015

Hmm can you do a new PR with these?

@carolinux

This comment has been minimized.

Copy link
Contributor Author

@carolinux carolinux replied Jun 27, 2015

#2176
there you go

Please sign in to comment.
You can’t perform that action at this time.