Commit a23814ba authored by Dominik Haumann's avatar Dominik Haumann

initial port of xml completion plugin

parent f4585e8a
project(katexmltoolsplugin)
# Load the frameworks we need
find_package(KF5 CONFIG REQUIRED COMPONENTS KDE4Support)
# TODO: Remove these later
remove_definitions(-DQT_NO_CAST_TO_ASCII)
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
remove_definitions(-DQT_NO_URL_CAST_FROM_STRING)
remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
set(katexmltoolsplugin_PART_SRCS
pseudo_dtd.cpp
plugin_katexmltools.cpp
)
########### next target ###############
add_library(katexmltoolsplugin MODULE ${katexmltoolsplugin_PART_SRCS})
set(katexmltoolsplugin_PART_SRCS pseudo_dtd.cpp plugin_katexmltools.cpp )
kde4_add_plugin(katexmltoolsplugin ${katexmltoolsplugin_PART_SRCS})
target_link_libraries(katexmltoolsplugin ${KDE4_KDECORE_LIBS} kateinterfaces ktexteditor)
target_link_libraries(katexmltoolsplugin
KF5::TextEditor
KF5::Parts
KF5::IconThemes
KF5::I18n
KF5::Service
KF5::KDE4Support
)
########### install files ###############
install(TARGETS katexmltoolsplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
install( FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/katexmltools )
install( FILES html4-loose.dtd.xml html4-strict.dtd.xml kde-docbook.dtd.xml simplify_dtd.xsl
xhtml1-frameset.dtd.xml xhtml1-strict.dtd.xml xhtml1-transitional.dtd.xml xslt-1.0.dtd.xml
testcases.xml language.dtd.xml kpartgui.dtd.xml kcfg.dtd.xml
DESTINATION ${DATA_INSTALL_DIR}/katexmltools )
########### install files ###############
install( FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/katexmltools )
install( FILES html4-loose.dtd.xml html4-strict.dtd.xml kde-docbook.dtd.xml simplify_dtd.xsl xhtml1-frameset.dtd.xml xhtml1-strict.dtd.xml xhtml1-transitional.dtd.xml xslt-1.0.dtd.xml testcases.xml language.dtd.xml kpartgui.dtd.xml kcfg.dtd.xml DESTINATION ${DATA_INSTALL_DIR}/katexmltools )
kservice_desktop_to_json (katexmltools.desktop)
install( FILES katexmltools.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
#original Makefile.am contents follow:
#INCLUDES = $(all_includes)
#METASOURCES = AUTO
#
## Install this plugin in the KDE modules directory
#kde_module_LTLIBRARIES = katexmltoolsplugin.la
#
## This is all standard. Remove the LIB_KHTML reference if you are not
## using the KHTML Part
#katexmltoolsplugin_la_SOURCES = pseudo_dtd.cpp plugin_katexmltools.cpp
#katexmltoolsplugin_la_LIBADD = -lkateinterfaces
#katexmltoolsplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
#
## Install the .rc file in the Part's directory (in this case, the part
## is KHTMLPart)
#pluginsdir = $(kde_datadir)/kate/plugins/katexmltools
#plugins_DATA = ui.rc
#
#xmldir = $(kde_datadir)/katexmltools
#xml_DATA = html4-loose.dtd.xml html4-strict.dtd.xml kde-docbook.dtd.xml \
# simplify_dtd.xsl xhtml1-frameset.dtd.xml xhtml1-strict.dtd.xml \
# xhtml1-transitional.dtd.xml xslt-1.0.dtd.xml \
# testcases.xml language.dtd.xml kpartgui.dtd.xml kcfg.dtd.xml
#
##deskdir=$(kde_datadir)/kate/plugins
##desk_DATA=katexmltools.desktop
#
#kde_services_DATA = katexmltools.desktop
#
#messages: rc.cpp
# $(XGETTEXT) *.cpp -o $(podir)/katexmltools.pot
[Desktop Entry]
Type=Service
ServiceTypes=Kate/Plugin
ServiceTypes=KTextEditor/Plugin
X-KDE-Library=katexmltoolsplugin
X-Kate-Version=2.9
Name=XML Completion
Name[ast]=Terminación XML
Name[bg]=Довършване на XML
......
......@@ -27,11 +27,9 @@
#include <qstring.h>
#include <kate/plugin.h>
#include <kate/application.h>
#include <kate/documentmanager.h>
#include <kate/mainwindow.h>
#include <ktexteditor/plugin.h>
#include <ktexteditor/application.h>
#include <ktexteditor/mainwindow.h>
#include <ktexteditor/document.h>
#include <ktexteditor/view.h>
#include <ktexteditor/codecompletioninterface.h>
......@@ -39,22 +37,22 @@
#include <ktexteditor/codecompletionmodelcontrollerinterface.h>
#include <kcombobox.h>
#include <kdialog.h>
#include <KDE4Support/kdialog.h>
#include <QVariantList>
class PluginKateXMLTools : public Kate::Plugin
class PluginKateXMLTools : public KTextEditor::Plugin
{
Q_OBJECT
public:
explicit PluginKateXMLTools( QObject* parent = 0, const QVariantList& = QVariantList() );
~PluginKateXMLTools();
Kate::PluginView *createView(Kate::MainWindow *mainWindow);
virtual QObject *createView(KTextEditor::MainWindow *mainWindow);
};
class PluginKateXMLToolsCompletionModel
: public KTextEditor::CodeCompletionModel2
: public KTextEditor::CodeCompletionModel
, public KTextEditor::CodeCompletionModelControllerInterface
{
Q_OBJECT
......@@ -64,24 +62,28 @@ class PluginKateXMLToolsCompletionModel
PluginKateXMLToolsCompletionModel( QObject *parent );
virtual ~PluginKateXMLToolsCompletionModel();
//
// KTextEditor::CodeCompletionModel
//
public:
virtual int columnCount(const QModelIndex&) const;
virtual int rowCount(const QModelIndex &parent) const;
virtual QModelIndex parent(const QModelIndex& index) const;
virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
virtual QVariant data(const QModelIndex &idx, int role) const;
virtual void executeCompletionItem2(
KTextEditor::Document *document
, const KTextEditor::Range &word
, const QModelIndex &index
) const;
virtual void executeCompletionItem(KTextEditor::View *view,
const KTextEditor::Range &word,
const QModelIndex &index) const;
virtual bool shouldStartCompletion(
KTextEditor::View *view
, const QString &insertedText
, bool userInsertion
, const KTextEditor::Cursor &position
);
//
// KTextEditor::CodeCompletionModelControllerInterface
//
public:
virtual bool shouldStartCompletion(KTextEditor::View *view,
const QString &insertedText,
bool userInsertion,
const KTextEditor::Cursor &position);
public Q_SLOTS:
......@@ -119,13 +121,13 @@ class PluginKateXMLToolsCompletionModel
enum Level {groupNode = 1};
/// Assign the PseudoDTD @p dtd to the Kate::Document @p doc
void assignDTD( PseudoDTD *dtd, KTextEditor::Document *doc );
/// Assign the PseudoDTD @p dtd to the Kate::View @p view
void assignDTD(PseudoDTD *dtd, KTextEditor::View *view);
/// temporary placeholder for the metaDTD file
QString m_dtdString;
/// temporary placeholder for the document to assign a DTD to while the file is loaded
KTextEditor::Document *m_docToAssignTo;
/// temporary placeholder for the view to assign a DTD to while the file is loaded
KTextEditor::View *m_viewToAssignTo;
/// URL of the last loaded meta DTD
QString m_urlString;
......@@ -144,18 +146,18 @@ class PluginKateXMLToolsCompletionModel
QHash<QString, PseudoDTD *> m_dtds;
};
class PluginKateXMLToolsView : public Kate::PluginView, public Kate::XMLGUIClient
class PluginKateXMLToolsView : public QObject, public KXMLGUIClient
{
Q_OBJECT
public:
explicit PluginKateXMLToolsView( Kate::MainWindow *win);
explicit PluginKateXMLToolsView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mainWin);
virtual ~PluginKateXMLToolsView();
protected:
KTextEditor::MainWindow *m_mainWindow;
PluginKateXMLToolsCompletionModel m_model;
Kate::DocumentManager *m_documentManager;
};
class InsertElement : public KDialog
......
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