[Bug 72523] Grep dialog doesn't prepopulate with selected text

Jens Dagerbo jens.dagerbo at swipnet.se
Wed Jan 21 15:26:02 UTC 2004


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
      
http://bugs.kde.org/show_bug.cgi?id=72523      
jens.dagerbo at swipnet.se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From jens.dagerbo at swipnet.se  2004-01-21 15:25 -------
Subject: kdevelop/parts/grepview

CVS commit by dagerbo: 

Commit suggested patch for bug 72523.

Thanks to Dan Christensen for the patch.

CCMAIL: 72523-done at bugs.kde.org


  M +17 -0     grepviewwidget.cpp   1.26


--- kdevelop/parts/grepview/grepviewwidget.cpp  #1.25:1.26
@@ -17,4 +17,7 @@
 #include <klocale.h>
 #include <kprocess.h>
+#include <kparts/part.h>
+#include <ktexteditor/selectioninterface.h>
+using namespace KTextEditor;
 
 #include "kdevcore.h"
@@ -119,4 +122,18 @@ GrepViewWidget::~GrepViewWidget()
 void GrepViewWidget::showDialog()
 {
+    // Get the selected text if there is any
+    KParts::ReadOnlyPart *ro_part = dynamic_cast<KParts::ReadOnlyPart*>(m_part->partController()->activePart());
+    if (ro_part)
+    {
+        SelectionInterface *selectIface = dynamic_cast<SelectionInterface*>(ro_part);
+        if(selectIface && selectIface->hasSelection())
+        {
+            QString selText = selectIface->selection();
+            if(!selText.contains('\n'))
+            {
+                grepdlg->setPattern(selText);
+            }
+        }
+    }
     grepdlg->show();
 }




More information about the KDevelop-devel mailing list