[kde-doc-english] KDE/kdesdk/kate/plugins/findinfiles
Andrius da Costa Ribas
andriusmao at gmail.com
Tue Mar 30 03:42:24 CEST 2010
SVN commit 1108895 by andriusr:
Implement "Open All" and "Open Selected" features in "Find in Files" operation. <http://reviewboard.kde.org/r/3416/>
FEATURE: 160574
CCMAIL: avarga71 at gmail.com
GUI: results widget now allows multi-selection and two buttons "Open All" and "Open Selected" have been added.
M +51 -1 kateresultview.cpp
M +2 -0 kateresultview.h
M +55 -37 resultwidget.ui
--- trunk/KDE/kdesdk/kate/plugins/findinfiles/kateresultview.cpp #1108894:1108895
@@ -64,6 +64,14 @@
btnRefine->setGuiItem(KStandardGuiItem::find());
btnRefine->setText(i18n("Refine Search..."));
+
+ btnOpenAll->setGuiItem(KStandardGuiItem::open());
+ btnOpenAll->setText(i18n("Open All"));
+ btnOpenAll->setToolTip(i18n("Open all files found"));
+
+ btnOpenSelected->setGuiItem(KStandardGuiItem::open());
+ btnOpenSelected->setText(i18n("Open Selected"));
+ btnOpenSelected->setToolTip(i18n("Open selected files"));
// auto-accels
KAcceleratorManager::manage(m_toolView);
@@ -74,12 +82,14 @@
"on the item to show the respective line in the editor."));
setFocusProxy(twResults);
- connect(twResults, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
+ connect(twResults, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
this, SLOT(itemSelected(QTreeWidgetItem *, int)));
connect(btnCancel, SIGNAL(clicked()), this, SLOT(killThread()));
connect(btnRemove, SIGNAL(clicked()), this, SLOT(deleteToolview()));
connect(btnRefine, SIGNAL(clicked()), this, SLOT(refineSearch()));
+ connect(btnOpenAll, SIGNAL(clicked()), this, SLOT(openAllFound()));
+ connect(btnOpenSelected, SIGNAL(clicked()), this, SLOT(openSelected()));
connect(m_grepThread, SIGNAL(finished()), this, SLOT(searchFinished()));
connect(m_grepThread, SIGNAL(foundMatch (const QString &, const QString &, const QList<int> &,
const QList<int> &, const QString &, const QStringList &)),
@@ -211,6 +221,15 @@
event->accept();
return;
}
+ if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
+ {
+ if( !(twResults->selectedItems().empty()) )
+ {
+ itemSelected(twResults->currentItem(), 0);
+ event->accept();
+ return;
+ }
+ }
QWidget::keyPressEvent(event);
}
@@ -239,6 +258,37 @@
dlg->show();
}
+void KateResultView::openAllFound()
+{
+ QString lastFilename;
+ QString filename;
+ for (int i = 0; i < twResults->topLevelItemCount(); ++i )
+ {
+ QTreeWidgetItem *item = twResults->topLevelItem(i);
+ filename = item->data(0, Qt::UserRole).toString();
+ if ( filename != lastFilename )
+ {
+ itemSelected(item, 0);
+ lastFilename = filename;
+ }
+ }
+}
+
+void KateResultView::openSelected()
+{
+ QString lastFilename;
+ QString filename;
+ foreach( QTreeWidgetItem *item, twResults->selectedItems() )
+ {
+ filename = item->data(0, Qt::UserRole).toString();
+ if ( filename != lastFilename )
+ {
+ itemSelected(item, 0);
+ lastFilename = filename;
+ }
+ }
+}
+
int KateResultView::id() const
{
return m_id;
--- trunk/KDE/kdesdk/kate/plugins/findinfiles/kateresultview.h #1108894:1108895
@@ -64,6 +64,8 @@
void killThread ();
void deleteToolview();
void refineSearch();
+ void openAllFound();
+ void openSelected();
private:
--- trunk/KDE/kdesdk/kate/plugins/findinfiles/resultwidget.ui #1108894:1108895
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>ResultWidget</class>
- <widget class="QWidget" name="ResultWidget" >
- <property name="geometry" >
+ <widget class="QWidget" name="ResultWidget">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@@ -9,94 +10,97 @@
<height>305</height>
</rect>
</property>
- <layout class="QGridLayout" name="gridLayout" >
- <property name="margin" >
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="margin">
<number>0</number>
</property>
- <item row="0" column="0" >
- <widget class="QTreeWidget" name="twResults" >
- <property name="indentation" >
+ <item row="0" column="0">
+ <widget class="QTreeWidget" name="twResults">
+ <property name="selectionMode">
+ <enum>QAbstractItemView::MultiSelection</enum>
+ </property>
+ <property name="indentation">
<number>0</number>
</property>
- <property name="rootIsDecorated" >
+ <property name="rootIsDecorated">
<bool>false</bool>
</property>
- <property name="uniformRowHeights" >
+ <property name="uniformRowHeights">
<bool>true</bool>
</property>
- <property name="itemsExpandable" >
+ <property name="itemsExpandable">
<bool>false</bool>
</property>
- <property name="allColumnsShowFocus" >
+ <property name="allColumnsShowFocus">
<bool>true</bool>
</property>
- <property name="expandsOnDoubleClick" >
+ <property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
- <property name="columnCount" >
+ <property name="columnCount">
<number>3</number>
</property>
<column>
- <property name="text" >
+ <property name="text">
<string>File</string>
</property>
</column>
<column>
- <property name="text" >
+ <property name="text">
<string>Line</string>
</property>
</column>
<column>
- <property name="text" >
+ <property name="text">
<string>Text</string>
</property>
</column>
</widget>
</item>
- <item row="1" column="0" >
- <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item row="1" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QProgressBar" name="progressBar" >
- <property name="maximum" >
+ <widget class="QProgressBar" name="progressBar">
+ <property name="maximum">
<number>0</number>
</property>
- <property name="value" >
+ <property name="value">
<number>0</number>
</property>
- <property name="textVisible" >
+ <property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
- <widget class="QToolButton" name="btnCancel" >
- <property name="autoRaise" >
+ <widget class="QToolButton" name="btnCancel">
+ <property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
- <widget class="QLabel" name="lblStatus" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <widget class="QLabel" name="lblStatus">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" >
+ <property name="text">
<string>Searching for files...</string>
</property>
- <property name="buddy" >
+ <property name="buddy">
<cstring>btnCancel</cstring>
</property>
</widget>
</item>
<item>
- <spacer name="horizontalSpacer" >
- <property name="orientation" >
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" stdset="0" >
+ <property name="sizeHint" stdset="0">
<size>
<width>128</width>
<height>20</height>
@@ -105,15 +109,29 @@
</spacer>
</item>
<item>
- <widget class="KPushButton" name="btnRefine" >
- <property name="text" >
+ <widget class="KPushButton" name="btnOpenSelected">
+ <property name="text">
+ <string>Open Selected</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KPushButton" name="btnOpenAll">
+ <property name="text">
+ <string>Open All</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KPushButton" name="btnRefine">
+ <property name="text">
<string>Refine Search...</string>
</property>
</widget>
</item>
<item>
- <widget class="KPushButton" name="btnRemove" >
- <property name="text" >
+ <widget class="KPushButton" name="btnRemove">
+ <property name="text">
<string>Remove</string>
</property>
</widget>
More information about the kde-doc-english
mailing list