Skip to content

Commit

Permalink
Now UI appears properly
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinux committed May 22, 2015
1 parent 46b2606 commit d33bf3d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
15 changes: 11 additions & 4 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,20 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer* layer, QStrin
mLayer->endEditCommand();
}

void QgsAttributeTableDialog::replaceSearchWidget(QWidget* oldw, QWidget* neww)
{
mFilterLayout->removeWidget(oldw);
oldw->setVisible(false);
mFilterLayout->addWidget(neww,0,0,0);
neww->setVisible(true);
}

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
mFilterQuery->setVisible( false );
// delete previous widget
if ( mCurrentSearchWidgetWrapper != 0 )
{
Expand All @@ -427,8 +434,7 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
//replace with createSearch or so
//go to registry and create a create Search method
mCurrentSearchWidgetWrapper= QgsEditorWidgetRegistry::instance()->createSearch( widgetType, mLayer, fldIdx, widgetConfig, mFilterContainer);
mCurrentSearchWidgetWrapper->widget()->setObjectName("searchy");
mCurrentSearchWidgetWrapper->widget()->setVisible( true );
replaceSearchWidget(mFilterQuery, mCurrentSearchWidgetWrapper->widget());

mApplyFilterButton->setVisible( true );
}
Expand Down Expand Up @@ -754,10 +760,11 @@ void QgsAttributeTableDialog::setFilterExpression( QString filterString )
mFilterButton->setDefaultAction( mActionAdvancedFilter );
mFilterButton->setPopupMode( QToolButton::MenuButtonPopup );
mCbxCaseSensitive->setVisible( false );

mFilterQuery->setVisible( true );
if ( mCurrentSearchWidgetWrapper != 0 )
{
mCurrentSearchWidgetWrapper->widget()->setVisible( false );
replaceSearchWidget(mCurrentSearchWidgetWrapper->widget(),mFilterQuery);
}
mApplyFilterButton->setVisible( true );
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowFilteredList );
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsattributetabledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
void updateTitle();

void updateButtonStatus( QString fieldName, bool isValid );

/* replace the search widget with a new one */
void replaceSearchWidget(QWidget* oldw, QWidget* neww);

signals:
/**
* Informs that editing mode has been toggled
Expand Down
2 changes: 2 additions & 0 deletions src/gui/editorwidgets/core/qgsdefaultsearchwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qgsfieldvalidator.h"

#include <QSettings>
#include <QSizePolicy>

QgsDefaultSearchWidgetWrapper::QgsDefaultSearchWidgetWrapper( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent )
: QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
Expand All @@ -39,6 +40,7 @@ QWidget* QgsDefaultSearchWidgetWrapper::createWidget( QWidget* parent )
void QgsDefaultSearchWidgetWrapper::initWidget( QWidget* widget )
{
mLineEdit = qobject_cast<QgsFilterLineEdit*>( widget );
mLineEdit->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Fixed );
connect( widget, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
}

Expand Down
8 changes: 4 additions & 4 deletions src/gui/editorwidgets/core/qgsdefaultsearchwidgetwrapper.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/***************************************************************************
qgstexteditwrapper.h
qgsdefaultsearchwidgetwrapper.h
--------------------------------------
Date : 5.1.2014
Copyright : (C) 2014 Matthias Kuhn
Email : matthias dot kuhn at gmx dot ch
Date : 21.5.2015
Copyright : (C) 2015 Karolina Alexiou
Email : carolinegr at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
Expand Down
8 changes: 4 additions & 4 deletions src/ui/qgsattributetabledialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@
</item>
<item>
<widget class="QWidget" name="mFilterContainer" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="mFilterLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="margin">
<number>0</number>
</property>
Expand All @@ -552,9 +555,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="mSpacer" native="true"/>
</item>
<item>
<widget class="QToolButton" name="mApplyFilterButton">
<property name="toolTip">
Expand Down

0 comments on commit d33bf3d

Please sign in to comment.