[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkdelibs=5D_kfile=3A_Increase_intuitiveness_of_KFile?=
From:       Parker Coates <parker.coates () gmail ! com>
Date:       2011-04-19 4:33:05
Message-ID: 20110419043305.8F15DA609B () git ! kde ! org
[Download RAW message or body]

Git commit 6344c4f0505f7a0994bd7f36e5c607959d2dfbcf by Parker Coates.
Committed on 19/04/2011 at 05:48.
Pushed by coates into branch 'master'.

Increase intuitiveness of KFileDialog filtering.

This patch attempts to improve the usefulness and usability of
KFileDialog's filter field when in Opening mode.

Firstly, if the filter text isn't:
 * the display name of one of the filters passed to the dialog or
 * one or more space separated mimetype specifiers (containing a '/') or
 * one or more space separated file globs (containing '*', '?' or '['),
we convert the text to a glob by prepending and appending asterisks.
This lets the user enter a piece of text (without having to know any
glob patterns) and see only the files whose names contain that text,
much the same as they would when filtering in Dolphin.

Secondly, the filtering updates on the fly as the filter text is typed.
Previously, the filtering updated only when Return was pressed, which
differs from the behaviour of most of KDE's other filter boxes. The old
behaviour is especially confusing when one clicks the small clear button
embedded in the combobox, because it clears the box, but the filtering
is unchanged until the user goes to the keyboard to press Return.

REVIEW:101013
FEATURE:142900
FIXED-IN:4.7
DIGEST:

M  +14   -2    kfile/kfilewidget.cpp     

http://commits.kde.org/kdelibs/6344c4f0505f7a0994bd7f36e5c607959d2dfbcf

diff --git a/kfile/kfilewidget.cpp b/kfile/kfilewidget.cpp
index 9b8cdeb..e140ae7 100644
--- a/kfile/kfilewidget.cpp
+++ b/kfile/kfilewidget.cpp
@@ -254,6 +254,7 @@ public:
     KUrlComboBox *locationEdit;
     KDirOperator *ops;
     KFileFilterCombo *filterWidget;
+    QTimer filterDelayTimer;
 
     KFilePlacesModel *model;
 
@@ -570,6 +571,11 @@ KFileWidget::KFileWidget( const KUrl& _startDir, QWidget *parent \
)  d->filterLabel->setBuddy(d->filterWidget);
     connect(d->filterWidget, SIGNAL(filterChanged()), SLOT(_k_slotFilterChanged()));
 
+    d->filterDelayTimer.setSingleShot(true);
+    d->filterDelayTimer.setInterval(300);
+    connect(d->filterWidget, SIGNAL(editTextChanged(QString)), &d->filterDelayTimer, \
SLOT(start())); +    connect(&d->filterDelayTimer, SIGNAL(timeout()), \
SLOT(_k_slotFilterChanged())); +
     // the Automatically Select Extension checkbox
     // (the text, visibility etc. is set in updateAutoSelectExtension(), which is \
called by readConfig())  d->autoSelectExtCheckBox = new QCheckBox (this);
@@ -1371,16 +1377,22 @@ void KFileWidgetPrivate::_k_slotFilterChanged()
 {
 //     kDebug(kfile_area);
 
+    filterDelayTimer.stop();
+
     QString filter = filterWidget->currentFilter();
     ops->clearFilter();
 
-    if ( filter.indexOf( '/' ) > -1 ) {
+    if ( filter.contains('/') ) {
         QStringList types = filter.split(' ', QString::SkipEmptyParts);
         types.prepend("inode/directory");
         ops->setMimeFilter( types );
     }
-    else
+    else if ( filter.contains('*') || filter.contains('?') || filter.contains('[') ) \
{  ops->setNameFilter( filter );
+    }
+    else {
+        ops->setNameFilter('*' + filter.replace(' ', '*') + '*');
+    }
 
     ops->updateDir();
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic