Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New design compiles but does nothing
  • Loading branch information
carolinux authored and m-kuhn committed Jun 26, 2015
1 parent d3c49b3 commit eff1357
Show file tree
Hide file tree
Showing 23 changed files with 630 additions and 144 deletions.
53 changes: 11 additions & 42 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -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 )
Expand All @@ -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()
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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;
Expand All @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributetabledialog.h
Expand Up @@ -29,7 +29,7 @@
#include "qgsattributedialog.h"
#include "qgsvectorlayer.h" //QgsFeatureIds
#include "qgsfieldmodel.h"
#include "qgseditorwidgetwrapper.h"
#include "qgssearchwidgetwrapper.h"

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

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

#endif
10 changes: 8 additions & 2 deletions src/gui/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
61 changes: 0 additions & 61 deletions src/gui/editorwidgets/core/qgsdefaultsearchwidgetwrapper.cpp

This file was deleted.

5 changes: 3 additions & 2 deletions src/gui/editorwidgets/core/qgseditorwidgetfactory.cpp
Expand Up @@ -15,6 +15,7 @@

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

#include <QSettings>

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/core/qgseditorwidgetfactory.h
Expand Up @@ -18,7 +18,7 @@

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

#include <QDomNode>
#include <QMap>
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
Expand Up @@ -16,7 +16,6 @@
#include "qgseditorwidgetregistry.h"

#include "qgsattributeeditorcontext.h"
//#include "qgseditorwidgetfactory.h"
#include "qgslegacyhelpers.h"
#include "qgsmessagelog.h"
#include "qgsproject.h"
Expand Down Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/core/qgseditorwidgetregistry.h
Expand Up @@ -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,
Expand Down
34 changes: 34 additions & 0 deletions src/gui/editorwidgets/core/qgssearchwidgetwrapper.cpp
@@ -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
Copy link
Member

@m-kuhn m-kuhn commented on eff1357 Jun 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I thought I had rewritten that commit message

@carolinux
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@carolinux
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like you didn't use b1b130e at all?

@carolinux
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented on eff1357 Jun 27, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm can you do a new PR with these?

@carolinux
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2176
there you go

Please sign in to comment.