Saturday, February 22, 2014

Patch to start quick filter instead of quick search when typing in Krusader

Krusader has both quick search and quick filter, but quick filter needs to be started explicitly with Ctrl+I. With this patch, when you start typing, quick filter is started instead of quick search.

 commit a4aaddc554d9c98b6c7a84fe9a2f2b2b79c4582f  
 Author: sashoalm <sashoalm@aspire>  
 Date:  Fri Feb 14 22:49:05 2014 +0200  
   Start quick filter instead of quick search.  
 diff --git a/krusader/Panel/krview.cpp b/krusader/Panel/krview.cpp  
 index d9ff07d..0c738eb 100644  
 --- a/krusader/Panel/krview.cpp  
 +++ b/krusader/Panel/krview.cpp  
 @@ -213,10 +213,14 @@ void KrViewOperator::quickFilterChanged(const QString &text)  
    _quickFilter->setMatch(_view->_count || !_view->_files->numVfiles());  
  }  
 -void KrViewOperator::startQuickFilter()  
 +void KrViewOperator::startQuickFilter(QEvent *e)  
  {  
    _quickFilter->show();  
    _quickFilter->lineEdit()->setFocus();  
 +  if (e) {  
 +    QLineEdit *p = _quickFilter->lineEdit();  
 +    p->event(e);  
 +  }  
  }  
  void KrViewOperator::stopQuickFilter(bool refreshView)  
 @@ -964,26 +968,8 @@ bool KrView::handleKeyEventInt(QKeyEvent *e)  
        //if ( _config->readBoolEntry( "Do Quicksearch", _DoQuicksearch ) ) {  
        // are we using krusader's classic quicksearch, or wincmd style?  
      {  
 -      KConfigGroup grpSv(_config, "Look&Feel");  
 -      if (!grpSv.readEntry("New Style Quicksearch", _NewStyleQuicksearch))  
 -        return false;  
 -      else {  
 -        // first, show the quicksearch if its hidden  
 -        if (op()->quickSearch()->isHidden()) {  
 -          op()->quickSearch()->show();  
 -          // HACK: if the pressed key requires a scroll down, the selected  
 -          // item is "below" the quick search window, as the icon view will  
 -          // realize its new size after the key processing. The following line  
 -          // will resize the icon view immediately.  
 -          // ACTIVE_PANEL->gui->layout->activate();  
 -          // UPDATE: it seems like this isn't needed anymore, in case I'm wrong  
 -          // do something like op()->emitQuickSearchStartet()  
 -          // -----------------------------  
 -        }  
 -        // now, send the key to the quicksearch  
 -        op()->quickSearch()->myKeyPressEvent(e);  
 -        return true;  
 -      }  
 +      op()->startQuickFilter(e);  
 +      return true;  
      } else {  
        if (!op()->quickSearch()->isHidden()) {  
          op()->quickSearch()->hide();  
 diff --git a/krusader/Panel/krview.h b/krusader/Panel/krview.h  
 index 2f3c8a8..7db5fba 100644  
 --- a/krusader/Panel/krview.h  
 +++ b/krusader/Panel/krview.h  
 @@ -205,7 +205,7 @@ public slots:  
    void stopQuickSearch(QKeyEvent*);  
    void handleQuickSearchEvent(QKeyEvent*);  
 -  void startQuickFilter();  
 +  void startQuickFilter(QEvent *e = 0);  
    void stopQuickFilter(bool refreshView = true);  
  signals:  

No comments:

Post a Comment