Commit 78e34a0a authored by Christoph Cullmann's avatar Christoph Cullmann

use the new auto-register magic

parent a0d0710c
......@@ -22,7 +22,7 @@
#include <QIcon>
#include <ktexteditor/commandinterface.h>
#include <KTextEditor/Command>
#include <ktexteditor/document.h>
#include <ktexteditor/editor.h>
#include <KTextEditor/Plugin>
......
......@@ -43,7 +43,7 @@ K_PLUGIN_FACTORY_WITH_JSON(KateOpenHeaderFactory,"kateopenheaderplugin.json", re
PluginViewKateOpenHeader::PluginViewKateOpenHeader(PluginKateOpenHeader *plugin, KTextEditor::MainWindow *mainwindow)
: KTextEditor::Command(mainwindow)
: KTextEditor::Command(QStringList() << QStringLiteral("toggle-header"), mainwindow)
, KXMLGUIClient()
, m_plugin(plugin)
, m_mainWindow(mainwindow)
......@@ -56,15 +56,11 @@ PluginViewKateOpenHeader::PluginViewKateOpenHeader(PluginKateOpenHeader *plugin,
connect( a, SIGNAL(triggered(bool)), plugin, SLOT(slotOpenHeader()) );
mainwindow->guiFactory()->addClient (this);
KTextEditor::Editor::instance()->registerCommand( this );
}
PluginViewKateOpenHeader::~PluginViewKateOpenHeader()
{
m_mainWindow->guiFactory()->removeClient (this);
KTextEditor::Editor::instance()->unregisterCommand( this );
}
PluginKateOpenHeader::PluginKateOpenHeader( QObject* parent, const QList<QVariant>& )
......@@ -209,19 +205,6 @@ void PluginKateOpenHeader::setFileName(QUrl *url,const QString &_txt)
url->setPath(path);
}
const QStringList& PluginViewKateOpenHeader::cmds()
{
static QStringList l;
if (l.empty()) {
l << QStringLiteral("toggle-header");
}
return l;
}
bool PluginViewKateOpenHeader::exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &)
{
Q_UNUSED(view)
......
......@@ -23,7 +23,7 @@
#include <ktexteditor/plugin.h>
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/commandinterface.h>
#include <KTextEditor/Command>
#include <KXMLGUIClient>
#include <kpluginfactory.h>
#include <QObject>
......@@ -57,7 +57,6 @@ class PluginViewKateOpenHeader
PluginViewKateOpenHeader(PluginKateOpenHeader* plugin, KTextEditor::MainWindow *mainwindow);
virtual ~PluginViewKateOpenHeader();
virtual const QStringList &cmds ();
virtual bool exec (KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range::invalid());
virtual bool help (KTextEditor::View *view, const QString &cmd, QString &msg);
......
......@@ -127,14 +127,11 @@ KatePluginSearch::KatePluginSearch(QObject* parent, const QList<QVariant>&)
//KGlobal::locale()->insertCatalog("katesearch");
m_searchCommand = new KateSearchCommand(this);
KTextEditor::Editor::instance()->registerCommand(m_searchCommand);
}
KatePluginSearch::~KatePluginSearch()
{
if (m_searchCommand) {
KTextEditor::Editor::instance()->unregisterCommand(m_searchCommand);
}
delete m_searchCommand;
}
QObject *KatePluginSearch::createView(KTextEditor::MainWindow *mainWindow)
......@@ -1718,16 +1715,10 @@ void KatePluginSearchView::slotProjectFileNameChanged ()
}
KateSearchCommand::KateSearchCommand(QObject *parent)
: KTextEditor::Command(parent)
{
}
const QStringList& KateSearchCommand::cmds()
{
static QStringList sl = QStringList() << QStringLiteral("grep") << QStringLiteral("newGrep")
: KTextEditor::Command(QStringList() << QStringLiteral("grep") << QStringLiteral("newGrep")
<< QStringLiteral("search") << QStringLiteral("newSearch")
<< QStringLiteral("pgrep") << QStringLiteral("newPGrep");
return sl;
<< QStringLiteral("pgrep") << QStringLiteral("newPGrep"), parent)
{
}
bool KateSearchCommand::exec (KTextEditor::View* /*view*/, const QString& cmd, QString& /*msg*/, const KTextEditor::Range &)
......
......@@ -24,7 +24,7 @@
#include <ktexteditor/mainwindow.h>
#include <KTextEditor/Plugin>
#include <ktexteditor/application.h>
#include <ktexteditor/commandinterface.h>
#include <KTextEditor/Command>
#include <ktexteditor/sessionconfiginterface.h>
#include <QAction>
......@@ -212,7 +212,6 @@ Q_SIGNALS:
// KTextEditor::Command
//
public:
const QStringList &cmds ();
bool exec (KTextEditor::View *view, const QString &cmd, QString &msg,
const KTextEditor::Range &range = KTextEditor::Range::invalid());
bool help (KTextEditor::View *view, const QString &cmd, QString &msg);
......
......@@ -65,28 +65,16 @@ PluginViewKateTextFilter::~PluginViewKateTextFilter()
PluginKateTextFilter::PluginKateTextFilter(QObject* parent, const QVariantList&)
: Kate::Plugin((Kate::Application *)parent, "kate-text-filter-plugin")
, KTextEditor::Command()
, KTextEditor::Command(QStringList dummy("textfilter"))
, m_pFilterProcess(NULL)
, copyResult(false)
, mergeOutput(true)
{
KTextEditor::CommandInterface* cmdIface =
qobject_cast<KTextEditor::CommandInterface*>(application()->editor());
if (cmdIface) {
cmdIface->registerCommand(this);
}
}
PluginKateTextFilter::~PluginKateTextFilter()
{
delete m_pFilterProcess;
KTextEditor::CommandInterface* cmdIface =
qobject_cast<KTextEditor::CommandInterface*>(application()->editor());
if (cmdIface) {
cmdIface->unregisterCommand(this);
}
}
......@@ -253,12 +241,6 @@ void PluginKateTextFilter::runFilter(KTextEditor::View *kv, const QString &filte
}
//BEGIN Kate::Command methods
const QStringList &PluginKateTextFilter::cmds()
{
static QStringList dummy("textfilter");
return dummy;
}
bool PluginKateTextFilter::help(KTextEditor::View *, const QString&, QString &msg)
{
msg = i18n("<qt><p>Usage: <code>textfilter COMMAND</code></p>"
......
......@@ -25,7 +25,7 @@
#include <ktexteditor/view.h>
#include <ktexteditor/document.h>
#include <ktexteditor/commandinterface.h>
#include <KTextEditor/Command>
#include <QProcess>
#include <QVariantList>
......@@ -43,7 +43,6 @@ class PluginKateTextFilter : public Kate::Plugin, public KTextEditor::Command
Kate::PluginView *createView (Kate::MainWindow *mainWindow);
// Kate::Command
const QStringList& cmds ();
bool exec(KTextEditor::View *view, const QString &cmd, QString &msg);
bool help(KTextEditor::View *view, const QString &cmd, QString &msg);
private:
......
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