Commit b2d0fec9 authored by Christoph Cullmann's avatar Christoph Cullmann

initial port of search plugin, think something is still broken, seems like...

initial port of search plugin, think something is still broken, seems like endless loop for pgrep search in project
parent d7b9b104
......@@ -10,6 +10,9 @@ ecm_optional_add_subdirectory (project)
# terminal tool view
ecm_optional_add_subdirectory (konsole)
# search in open documents and files
ecm_optional_add_subdirectory (search)
#if(NOT WIN32)
# add_subdirectory( gdbplugin ) # reading /proc/...
#endif(NOT WIN32)
......@@ -27,7 +30,6 @@ ecm_optional_add_subdirectory (konsole)
#add_subdirectory( kate-ctags )
#add_subdirectory( katebuild-plugin )
#add_subdirectory( search )
#add_subdirectory( kttsd )
......
# building separately or as part of kdesdk?
if(NOT KDE4_FOUND)
cmake_minimum_required( VERSION 2.6 )
find_package(KDE4 REQUIRED)
ADD_DEFINITIONS(-DKDE_DEFAULT_DEBUG_AREA=13040)
include_directories(${KDE4_INCLUDES})
include_directories(${KDE4_KIO_INCLUDES})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif(NOT KDE4_FOUND)
set(katesearchplugin_PART_SRCS
plugin_search.cpp
search_open_files.cpp
......@@ -19,14 +7,19 @@ set(katesearchplugin_PART_SRCS
htmldelegate.cpp
)
kde4_add_ui_files(katesearchplugin_PART_SRCS search.ui results.ui)
qt5_wrap_ui (katesearchplugin_PART_SRCS search.ui results.ui)
kde4_add_plugin(katesearchplugin ${katesearchplugin_PART_SRCS})
add_library(katesearchplugin MODULE ${katesearchplugin_PART_SRCS})
target_link_libraries(katesearchplugin ${KDE4_KDEUI_LIBS} ${KDE4_KDECORE_LIBS} ktexteditor kateinterfaces)
target_link_libraries(katesearchplugin ktexteditor
KF5::Parts
KF5::KDE4Support
KF5::NewStuff Qt5::Script KF5::SonnetCore KF5::Archive KF5::KCMUtils KF5::PrintUtils KF5::ItemViews)
########### install files ###############
install(TARGETS katesearchplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/katesearch)
install(FILES katesearch.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/katesearch)
kservice_desktop_to_json (katesearch.desktop)
install(FILES katesearch.desktop DESTINATION ${SERVICES_INSTALL_DIR})
......@@ -21,7 +21,7 @@
#ifndef HTML_DELEGATE_H
#define HTML_DELEGATE_H
#include <QtGui/QStyledItemDelegate>
#include <QStyledItemDelegate>
class SPHtmlDelegate : public QStyledItemDelegate
{
......
[Desktop Entry]
Type=Service
ServiceTypes=Kate/Plugin
ServiceTypes=KTextEditor/ApplicationPlugin
X-KDE-Library=katesearchplugin
X-Kate-Version=2.9
X-Kate-Load=True
......
This diff is collapsed.
......@@ -21,14 +21,18 @@
#ifndef _PLUGIN_SEARCH_H_
#define _PLUGIN_SEARCH_H_
#include <kate/mainwindow.h>
#include <kate/plugin.h>
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/applicationplugin.h>
#include <ktexteditor/application.h>
#include <ktexteditor/commandinterface.h>
#include <ktexteditor/sessionconfiginterface.h>
#include <kaction.h>
#include <QTreeWidget>
#include <QTimer>
#include <KXMLGUIClient>
#include "ui_search.h"
#include "ui_results.h"
......@@ -67,7 +71,7 @@ protected:
};
class KatePluginSearch : public Kate::Plugin
class KatePluginSearch : public KTextEditor::ApplicationPlugin
{
Q_OBJECT
......@@ -75,7 +79,7 @@ public:
explicit KatePluginSearch(QObject* parent = 0, const QList<QVariant>& = QList<QVariant>());
virtual ~KatePluginSearch();
Kate::PluginView *createView(Kate::MainWindow *mainWindow);
QObject *createView(KTextEditor::MainWindow *mainWindow);
private:
KateSearchCommand* m_searchCommand;
......@@ -83,16 +87,17 @@ private:
class KatePluginSearchView : public Kate::PluginView, public Kate::XMLGUIClient
class KatePluginSearchView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface
{
Q_OBJECT
Q_INTERFACES(KTextEditor::SessionConfigInterface)
public:
KatePluginSearchView(Kate::MainWindow *mainWindow, Kate::Application* application);
KatePluginSearchView(KTextEditor::ApplicationPlugin *plugin, KTextEditor::MainWindow *mainWindow, KTextEditor::Application* application);
~KatePluginSearchView();
virtual void readSessionConfig(KConfigBase* config, const QString& groupPrefix);
virtual void writeSessionConfig(KConfigBase* config, const QString& groupPrefix);
void readSessionConfig (const KConfigGroup& config);
void writeSessionConfig (KConfigGroup& config);
public Q_SLOTS:
void startSearch();
......@@ -148,8 +153,8 @@ private Q_SLOTS:
/**
* keep track if the project plugin is alive and if the project file did change
*/
void slotPluginViewCreated (const QString &name, Kate::PluginView *pluginView);
void slotPluginViewDeleted (const QString &name, Kate::PluginView *pluginView);
void slotPluginViewCreated (const QString &name, QObject *pluginView);
void slotPluginViewDeleted (const QString &name, QObject *pluginView);
void slotProjectFileNameChanged ();
protected:
......@@ -163,13 +168,13 @@ private:
Ui::SearchDialog m_ui;
QWidget *m_toolView;
Kate::Application *m_kateApp;
KTextEditor::Application *m_kateApp;
SearchOpenFiles m_searchOpenFiles;
FolderFilesList m_folderFilesList;
SearchDiskFiles m_searchDiskFiles;
ReplaceMatches m_replacer;
KAction *m_matchCase;
KAction *m_useRegExp;
QAction *m_matchCase;
QAction *m_useRegExp;
Results *m_curResults;
bool m_searchJustOpened;
bool m_switchToProjectModeWhenAvailable;
......@@ -182,7 +187,12 @@ private:
/**
* current project plugin view, if any
*/
Kate::PluginView *m_projectPluginView;
QObject *m_projectPluginView;
/**
* our main window
*/
KTextEditor::MainWindow *m_mainWindow;
};
class KateSearchCommand : public QObject, public KTextEditor::Command
......
......@@ -45,7 +45,8 @@ void ReplaceMatches::replaceChecked(QTreeWidget *tree, const QRegExp &regexp, co
m_cancelReplace = false;
emit replaceNextMatch();
}
void ReplaceMatches::setDocumentManager(Kate::DocumentManager *manager)
void ReplaceMatches::setDocumentManager(KTextEditor::Application *manager)
{
m_manager = manager;
}
......@@ -145,7 +146,7 @@ void ReplaceMatches::doReplaceNextMatch()
}
if (m_regExp.indexIn(matchLines) != 0) {
kDebug() << "expression does not match";
qDebug() << "expression does not match";
continue;
}
......
......@@ -25,7 +25,7 @@
#include <QRegExp>
#include <QTreeWidget>
#include <ktexteditor/document.h>
#include <kate/documentmanager.h>
#include <ktexteditor/application.h>
class ReplaceMatches: public QObject
{
......@@ -44,7 +44,7 @@ public:
};
ReplaceMatches(QObject *parent = 0);
void setDocumentManager(Kate::DocumentManager *manager);
void setDocumentManager(KTextEditor::Application *manager);
void replaceChecked(QTreeWidget *tree, const QRegExp &regexp, const QString &replace);
......@@ -62,7 +62,7 @@ Q_SIGNALS:
void replaceDone();
private:
Kate::DocumentManager *m_manager;
KTextEditor::Application *m_manager;
QTreeWidget *m_tree;
int m_rootIndex;
QRegExp m_regExp;
......
......@@ -25,7 +25,7 @@
</widget>
</item>
<item row="1" column="4">
<widget class="KPushButton" name="replaceButton">
<widget class="QPushButton" name="replaceButton">
<property name="enabled">
<bool>false</bool>
</property>
......@@ -35,7 +35,7 @@
</widget>
</item>
<item row="0" column="4">
<widget class="KPushButton" name="searchButton">
<widget class="QPushButton" name="searchButton">
<property name="enabled">
<bool>false</bool>
</property>
......@@ -88,16 +88,13 @@
<number>0</number>
</property>
<item>
<widget class="KTabWidget" name="resultTabWidget">
<widget class="QTabWidget" name="resultTabWidget">
<property name="tabsClosable">
<bool>true</bool>
</property>
<property name="movable">
<bool>true</bool>
</property>
<property name="automaticResizeTabs">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
......@@ -345,7 +342,7 @@
<number>0</number>
</property>
<item>
<widget class="KPushButton" name="nextButton">
<widget class="QPushButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
......@@ -368,7 +365,7 @@
<number>0</number>
</property>
<item>
<widget class="KPushButton" name="stopButton">
<widget class="QPushButton" name="stopButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -405,7 +402,7 @@
</widget>
</item>
<item row="1" column="5">
<widget class="KPushButton" name="replaceCheckedBtn">
<widget class="QPushButton" name="replaceCheckedBtn">
<property name="enabled">
<bool>false</bool>
</property>
......@@ -427,22 +424,11 @@
<extends>KUrlRequester</extends>
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
<customwidget>
<class>KTabWidget</class>
<extends>QTabWidget</extends>
<header>ktabwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KHistoryComboBox</class>
<extends>KComboBox</extends>
......
......@@ -80,7 +80,7 @@ int SearchOpenFiles::searchOpenFile(KTextEditor::Document *doc, const QRegExp &r
{
if (m_statusTime.elapsed() > 100) {
m_statusTime.restart();
emit searching(doc->url().pathOrUrl());
emit searching(doc->url().toString());
}
if (regExp.pattern().contains("\\n")) {
......@@ -98,13 +98,13 @@ int SearchOpenFiles::searchSingleLineRegExp(KTextEditor::Document *doc, const QR
time.start();
for (int line = startLine; line < doc->lines(); line++) {
if (time.elapsed() > 100) {
kDebug() << "Search time exceeded" << time.elapsed() << line;
qDebug() << "Search time exceeded" << time.elapsed() << line;
return line;
}
column = regExp.indexIn(doc->line(line));
while (column != -1) {
if (regExp.cap().isEmpty()) break;
emit matchFound(doc->url().pathOrUrl(), doc->documentName(), line, column,
emit matchFound(doc->url().toString(), doc->documentName(), line, column,
doc->line(line), regExp.matchedLength());
column = regExp.indexIn(doc->line(line), column + regExp.cap().size());
}
......@@ -166,7 +166,7 @@ int SearchOpenFiles::searchMultiLineRegExp(KTextEditor::Document *doc, const QRe
if (line == -1) {
break;
}
emit matchFound(doc->url().pathOrUrl(), doc->documentName(),
emit matchFound(doc->url().toString(), doc->documentName(),
line,
(column - m_lineStart[line]),
doc->line(line).left(column - m_lineStart[line])+tmpRegExp.cap(),
......
......@@ -64,22 +64,16 @@ void KatePluginManager::setupPluginList ()
KatePluginList others;
foreach(const KService::Ptr &ptr, traderList)
{
double pVersion = ptr->property("X-Kate-Version").toDouble();
// don't use plugins out of 3.x release series
if ((pVersion >= 2.8) && (pVersion <= KateVersion))
{
KatePluginInfo info;
info.service = ptr;
info.alwaysLoad=info.service->property("X-Kate-LoadAlways").toBool();
info.load = false;
info.plugin = 0L;
if (info.alwaysLoad)
alwaysLoad.push_back (info);
else
others.push_back (info);
}
KatePluginInfo info;
info.service = ptr;
info.alwaysLoad=info.service->property("X-Kate-LoadAlways").toBool();
info.load = false;
info.plugin = 0L;
if (info.alwaysLoad)
alwaysLoad.push_back (info);
else
others.push_back (info);
}
/**
......
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