Commit 6f53e6a7 authored by Kåre Särs's avatar Kåre Särs

Replace the matches label with a "Select all ### matches" checkbox

parent c7348650
......@@ -64,6 +64,47 @@ static QAction *menuEntry(QMenu *menu,
return action;
}
Results::Results(QWidget *parent): QWidget(parent), matches(0)
{
setupUi(this);
tree->setItemDelegate(new SPHtmlDelegate(tree));
selectAllCB->setText(i18n("Select all 9999 matches"));
selectAllCB->setFixedWidth(selectAllCB->sizeHint().width());
selectAllCB->setText(i18n("Select all"));
buttonContainer->setDisabled(true);
connect(selectAllCB, SIGNAL(clicked(bool)), this, SLOT(selectAll(bool)));
}
void Results::selectAll(bool)
{
disconnect(tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(checkCheckedState()));
Qt::CheckState state = selectAllCB->checkState();
if (state == Qt::PartiallyChecked) state = Qt::Checked;
selectAllCB->setCheckState(state);
for (int i=0; i<tree->topLevelItemCount(); i++) {
tree->topLevelItem(i)->setCheckState(0, state);
}
connect(tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(checkCheckedState()));
}
void Results::checkCheckedState()
{
Qt::CheckState state;
for (int i=0; i<tree->topLevelItemCount(); i++) {
if (i==0) {
state = tree->topLevelItem(i)->checkState(0);
}
else if (state != tree->topLevelItem(i)->checkState(0)) {
selectAllCB->setCheckState(Qt::PartiallyChecked);
return;
}
}
selectAllCB->setCheckState(state);
}
K_PLUGIN_FACTORY(KatePluginSearchFactory, registerPlugin<KatePluginSearch>();)
K_EXPORT_PLUGIN(KatePluginSearchFactory(KAboutData("katesearch","katesearch",ki18n("Search in files"), "0.1", ki18n("Find in open files plugin"))))
......@@ -303,6 +344,12 @@ void KatePluginSearchView::startSearch()
clearMarks();
m_curResults->tree->clear();
m_curResults->buttonContainer->setEnabled(false);
m_curResults->matches = 0;
m_curResults->selectAllCB->setText(i18n("Select all"));
m_curResults->selectAllCB->setChecked(true);
disconnect(m_curResults->tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), m_curResults, SLOT(checkCheckedState()));
m_ui.resultTabWidget->setTabText(m_ui.resultTabWidget->currentIndex(),
m_ui.searchCombo->currentText());
......@@ -426,8 +473,8 @@ void KatePluginSearchView::matchFound(const QString &url, int line, int column,
item->setCheckState (0, Qt::Checked);
m_curResults->matches++;
m_curResults->matchLabel->setText(i18np("Found %1 match.",
"Found %1 matches.",
m_curResults->selectAllCB->setText(i18np("Select %1 match",
"Select all %1 matches",
m_curResults->matches));
// Add mark if the document is open
......@@ -476,6 +523,9 @@ void KatePluginSearchView::searchDone()
m_curResults->tree->expandAll();
m_curResults->tree->resizeColumnToContents(0);
m_curResults->tree->collapseAll();
m_curResults->buttonContainer->setEnabled(true);
connect(m_curResults->tree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), m_curResults, SLOT(checkCheckedState()));
m_curResults = 0;
m_toolView->unsetCursor();
......@@ -647,9 +697,7 @@ void KatePluginSearchView::writeSessionConfig(KConfigBase* config, const QString
void KatePluginSearchView::addTab()
{
Results *res = new Results();
res->tree->setItemDelegate(new SPHtmlDelegate(res->tree));
connect(res->tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
this, SLOT (itemSelected(QTreeWidgetItem*)));
......
......@@ -44,9 +44,13 @@ class Results: public QWidget, public Ui::Results
{
Q_OBJECT
public:
Results(QWidget *parent = 0): QWidget(parent), matches(0) { setupUi(this); }
Results(QWidget *parent = 0);
int matches;
QRegExp regExp;
public Q_SLOTS:
void selectAll(bool checked);
void checkCheckedState();
};
class KatePluginSearch : public Kate::Plugin
......
......@@ -6,25 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>443</width>
<height>108</height>
<width>381</width>
<height>102</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="1,0" columnstretch="0,1,0">
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="10,0">
<property name="margin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="KHistoryComboBox" name="replaceCombo">
<property name="editable">
<bool>true</bool>
</property>
<property name="autoCompletion">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<item>
<widget class="QTreeWidget" name="tree">
<property name="uniformRowHeights">
<bool>true</bool>
......@@ -45,40 +35,74 @@
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="matchLabel">
<property name="text">
<string>Found matches: xxx</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QStackedWidget" name="buttonStack">
<property name="currentIndex">
<number>0</number>
<item>
<widget class="QWidget" name="buttonContainer" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="replaceButton">
<property name="text">
<string>Replace checked</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,2,0">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="selectAllCB">
<property name="text">
<string>Select all</string>
</property>
</widget>
</item>
<item>
<widget class="KHistoryComboBox" name="replaceCombo">
<property name="editable">
<bool>true</bool>
</property>
<property name="autoCompletion">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="buttonStack">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="replaceButton">
<property name="text">
<string>Replace checked</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="stopButton">
<property name="text">
<string>stop</string>
</property>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="stopButton">
<property name="text">
<string>stop</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment