@@ -83,6 +83,9 @@ class QgsBrowserTreeView : public QTreeView
83
83
}
84
84
};
85
85
86
+ /* *
87
+ Utility class for filtering browser items
88
+ */
86
89
class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
87
90
{
88
91
public:
@@ -125,7 +128,7 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
125
128
if ( mPatternSyntax == QRegExp::Wildcard ||
126
129
mPatternSyntax == QRegExp::WildcardUnix )
127
130
{
128
- foreach ( QString f, mFilter .split ( " |" ) )
131
+ foreach ( QString f, mFilter .split ( " |" ) )
129
132
{
130
133
QRegExp rx ( f.trimmed () );
131
134
rx.setPatternSyntax ( mPatternSyntax );
@@ -150,11 +153,10 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
150
153
151
154
bool filterAcceptsString ( const QString & value ) const
152
155
{
153
- // return ( filterRegExp().exactMatch( fileInfo.fileName() ) );
154
156
if ( mPatternSyntax == QRegExp::Wildcard ||
155
157
mPatternSyntax == QRegExp::WildcardUnix )
156
158
{
157
- foreach ( QRegExp rx, mREList )
159
+ foreach ( QRegExp rx, mREList )
158
160
{
159
161
QgsDebugMsg ( QString ( " value: [%1] rx: [%2] match: %3" ).arg ( value ).arg ( rx.pattern () ).arg ( rx.exactMatch ( value ) ) );
160
162
if ( rx.exactMatch ( value ) )
@@ -163,15 +165,9 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
163
165
}
164
166
else
165
167
{
166
- foreach ( QRegExp rx, mREList )
168
+ foreach ( QRegExp rx, mREList )
167
169
{
168
170
QgsDebugMsg ( QString ( " value: [%1] rx: [%2] match: %3" ).arg ( value ).arg ( rx.pattern () ).arg ( rx.indexIn ( value ) ) );
169
- QRegExp rx2 ( " \\ b(mail|letter|correspondence)\\ b" );
170
- QgsDebugMsg ( QString ( " value: [%1] rx2: [%2] match: %3" ).arg ( value ).arg ( rx2.pattern () ).arg ( rx2.indexIn ( value ) ) );
171
- QgsDebugMsg ( QString ( " T1 %1" ).arg ( rx2.indexIn ( " I sent you an email" ) ) ); // returns -1 (no match)
172
- QgsDebugMsg ( QString ( " T2 %2" ).arg ( rx2.indexIn ( " Please write the letter" ) ) ); // returns -1 (no match)
173
- QgsDebugMsg ( QString ( " T3 %2" ).arg ( rx.indexIn ( " Please write the letter" ) ) ); // returns -1 (no match)
174
-
175
171
if ( rx.indexIn ( value ) != -1 )
176
172
return true ;
177
173
}
@@ -226,15 +222,14 @@ QgsBrowserDockWidget::QgsBrowserDockWidget( QWidget * parent ) :
226
222
mBrowserView = new QgsBrowserTreeView ( this );
227
223
mLayoutBrowser ->addWidget ( mBrowserView );
228
224
229
- mBtnRefresh ->setIcon ( QgisApp::instance ()-> getThemeIcon ( " mActionRefresh.png" ) );
230
- mBtnAddLayers ->setIcon ( QgisApp::instance ()-> getThemeIcon ( " mActionAdd.png" ) );
231
- mBtnCollapse ->setIcon ( QgisApp::instance ()-> getThemeIcon ( " mActionCollapseTree.png" ) );
225
+ mBtnRefresh ->setIcon ( QgsApplication:: getThemeIcon ( " mActionRefresh.png" ) );
226
+ mBtnAddLayers ->setIcon ( QgsApplication:: getThemeIcon ( " mActionAdd.png" ) );
227
+ mBtnCollapse ->setIcon ( QgsApplication:: getThemeIcon ( " mActionCollapseTree.png" ) );
232
228
233
229
mWidgetFilter ->hide ();
234
230
// icons from http://www.fatcow.com/free-icons License: CC Attribution 3.0
235
- mBtnFilterShow ->setIcon ( QgisApp::instance ()->getThemeIcon ( " mActionFilter.png" ) );
236
- mBtnFilter ->setIcon ( QgisApp::instance ()->getThemeIcon ( " mActionFilter.png" ) );
237
- mBtnFilterClear ->setIcon ( QgisApp::instance ()->getThemeIcon ( " mActionFilterDelete.png" ) );
231
+ mBtnFilterShow ->setIcon ( QgsApplication::getThemeIcon ( " mActionFilter.png" ) );
232
+ mBtnFilter ->setIcon ( QgsApplication::getThemeIcon ( " mActionFilter.png" ) );
238
233
239
234
QMenu* menu = new QMenu ( this );
240
235
menu->setSeparatorsCollapsible ( false );
@@ -243,27 +238,24 @@ QgsBrowserDockWidget::QgsBrowserDockWidget( QWidget * parent ) :
243
238
QAction* action = new QAction ( tr ( " Filter Pattern Syntax" ), group );
244
239
action->setSeparator ( true );
245
240
menu->addAction ( action );
246
- // group->addAction( action );
247
241
action = new QAction ( tr ( " Wildcard(s)" ), group );
248
242
action->setData ( QVariant (( int ) QRegExp::Wildcard ) );
249
243
action->setCheckable ( true );
250
244
action->setChecked ( true );
251
245
menu->addAction ( action );
252
- // group->addAction( action );
253
- // menu->addSeparator()->setText( tr( "Pattern Syntax" ) );
254
246
action = new QAction ( tr ( " Regular Expression" ), group );
255
247
action->setData ( QVariant (( int ) QRegExp::RegExp ) );
256
248
action->setCheckable ( true );
257
249
menu->addAction ( action );
258
- // group->addAction( action );
259
250
260
251
connect ( mBtnRefresh , SIGNAL ( clicked () ), this , SLOT ( refresh () ) );
261
252
connect ( mBtnAddLayers , SIGNAL ( clicked () ), this , SLOT ( addSelectedLayers () ) );
262
253
connect ( mBtnCollapse , SIGNAL ( clicked () ), mBrowserView , SLOT ( collapseAll () ) );
263
254
connect ( mBtnFilterShow , SIGNAL ( toggled ( bool ) ), this , SLOT ( showFilterWidget ( bool ) ) );
264
255
connect ( mBtnFilter , SIGNAL ( clicked () ), this , SLOT ( setFilter () ) );
265
256
connect ( mLeFilter , SIGNAL ( returnPressed () ), this , SLOT ( setFilter () ) );
266
- connect ( mBtnFilterClear , SIGNAL ( clicked () ), this , SLOT ( clearFilter () ) );
257
+ connect ( mLeFilter , SIGNAL ( cleared () ), this , SLOT ( setFilter () ) );
258
+ // connect( mLeFilter, SIGNAL( textChanged( const QString & ) ), this, SLOT( setFilter() ) );
267
259
connect ( group, SIGNAL ( triggered ( QAction * ) ), this , SLOT ( setFilterSyntax ( QAction * ) ) );
268
260
269
261
connect ( mBrowserView , SIGNAL ( customContextMenuRequested ( const QPoint & ) ), this , SLOT ( showContextMenu ( const QPoint & ) ) );
@@ -624,7 +616,10 @@ void QgsBrowserDockWidget::showFilterWidget( bool visible )
624
616
{
625
617
mWidgetFilter ->setVisible ( visible );
626
618
if ( ! visible )
627
- clearFilter ();
619
+ {
620
+ mLeFilter ->setText ( " " );
621
+ setFilter ();
622
+ }
628
623
}
629
624
630
625
void QgsBrowserDockWidget::setFilter ( )
@@ -641,12 +636,6 @@ void QgsBrowserDockWidget::setFilterSyntax( QAction * action )
641
636
mProxyModel ->setFilterSyntax (( QRegExp::PatternSyntax ) action->data ().toInt () );
642
637
}
643
638
644
- void QgsBrowserDockWidget::clearFilter ( )
645
- {
646
- mLeFilter ->setText ( " " );
647
- setFilter ();
648
- }
649
-
650
639
QgsDataItem* QgsBrowserDockWidget::dataItem ( const QModelIndex& index )
651
640
{
652
641
if ( ! mProxyModel )
0 commit comments